@zuplo/editor 1.0.32407368354 → 1.0.32772092313
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +2 -2
- package/dist/client/static/css/{main-4CKlJs8E.css → main-BLDYkhRa.css} +1 -1
- package/dist/client/static/js/{GraphiQLConsole-BIM6Kiy9.js → GraphiQLConsole-CZejKwC9.js} +4 -4
- package/dist/client/static/js/{McpCapabilityFilterDesigner-CE9HGiq3.js → McpCapabilityFilterDesigner-CG8ZVkh4.js} +1 -1
- package/dist/client/static/js/{SchemaReference-BTHiCCxp.js → SchemaReference-CVISAWin.js} +1 -1
- package/dist/client/static/js/{esm-nB3Krza4.js → esm-DT7XeAdc.js} +1 -1
- package/dist/client/static/js/{hint-BXOZ20H2.js → hint-CCoTt5GK.js} +1 -1
- package/dist/client/static/js/{hint-DF-qAzJe.js → hint-DNFkA331.js} +1 -1
- package/dist/client/static/js/{info-DzwBvw5W.js → info-YdH-rhDt.js} +1 -1
- package/dist/client/static/js/{jump-C2Hchxb2.js → jump-8XyX3WVu.js} +1 -1
- package/dist/client/static/js/{lint-9obDRCaW.js → lint-CwJ2CwI5.js} +1 -1
- package/dist/client/static/js/{main-BdjYGIQx.js → main-Ca-EGG-M.js} +5 -5
- package/dist/client/static/js/{mode-C46RVO5-.js → mode-C60KbNsM.js} +1 -1
- package/dist/client/static/js/{mode-KwcM8Lam.js → mode-_ctRsloH.js} +1 -1
- package/dist/client/static/js/{mode-B44gI6gX.js → mode-hY8bkHTk.js} +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["static/js/editor.main-B7ZQNwu9.js","static/js/chunk-6hGRweTZ.js","static/js/preload-helper-DxkSl20Q.js","static/js/editor.api2-DJi3_-IJ.js","static/css/editor-DU9oqspw.css","static/js/workers-CfQPK2eg.js","static/js/monaco.contribution-CZRO3JpP.js","static/js/McpCapabilityFilterDesigner-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["static/js/editor.main-B7ZQNwu9.js","static/js/chunk-6hGRweTZ.js","static/js/preload-helper-DxkSl20Q.js","static/js/editor.api2-DJi3_-IJ.js","static/css/editor-DU9oqspw.css","static/js/workers-CfQPK2eg.js","static/js/monaco.contribution-CZRO3JpP.js","static/js/McpCapabilityFilterDesigner-CG8ZVkh4.js","static/js/dist-DSg6bEGY.js","static/js/GraphiQLConsole-CZejKwC9.js","static/js/esm-DT7XeAdc.js","static/js/definition-C7QrKMH2.js","static/css/GraphiQLConsole-C4zv7lh0.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{a as e,i as t,n,o as r,r as i,t as a}from"./chunk-6hGRweTZ.js";import{$ as o,$n as s,$t as c,A as l,An as u,At as d,B as f,Bn as p,Bt as m,C as h,Cn as g,Ct as _,D as v,Dn as y,Dt as b,E as x,En as S,Et as C,F as w,Fn as T,Ft as E,G as D,Gn as O,Gt as k,H as A,Hn as j,Ht as M,I as N,In as P,It as F,J as I,Jn as L,Jt as R,K as z,Kn as B,Kt as ee,L as V,Ln as te,Lt as ne,M as re,Mn as ie,Mt as ae,N as oe,Nn as se,Nt as ce,O as le,On as ue,Ot as de,P as fe,Pn as pe,Q as me,Qn as he,Qt as ge,R as _e,Rn as ve,Rt as ye,S as be,Sn as xe,St as Se,T as Ce,Tn as we,Tt as Te,U as Ee,Un as De,Ut as Oe,V as ke,Vn as Ae,Vt as je,W as Me,Wn as Ne,Wt as Pe,X as Fe,Xn as Ie,Xt as Le,Y as Re,Yn as ze,Yt as Be,Z as Ve,Zn as He,Zt as Ue,_n as We,_t as Ge,a as Ke,an as qe,ar as Je,at as Ye,b as Xe,bn as Ze,bt as Qe,c as $e,cn as et,ct as tt,d as nt,dn as rt,dt as it,en as at,er as ot,et as st,f as ct,fn as lt,ft as ut,gn as dt,gt as ft,hn as pt,ht as mt,i as ht,in as gt,ir as _t,it as vt,j as yt,jn as bt,jt as xt,k as St,kn as Ct,kt as wt,l as Tt,ln as Et,lt as Dt,mn as Ot,mt as kt,n as At,nn as jt,nr as Mt,nt as Nt,o as Pt,on as Ft,ot as It,pn as Lt,pt as Rt,q as zt,qn as Bt,qt as Vt,r as Ht,rn as Ut,rr as Wt,rt as Gt,s as Kt,sn as qt,st as Jt,t as Yt,tn as Xt,tr as Zt,tt as Qt,u as $t,un as en,ut as tn,vn as nn,vt as rn,w as an,wn as on,wt as sn,x as cn,xn as ln,xt as un,yn as dn,yt as fn,z as pn,zn as mn,zt as hn}from"./dist-DSg6bEGY.js";import{t as gn}from"./preload-helper-DxkSl20Q.js";import{$ as _n,C as vn,E as yn,F as bn,G as xn,I as Sn,J as Cn,K as wn,M as Tn,O as En,P as Dn,Q as On,S as kn,V as An,X as jn,Y as Mn,Z as eee,_ as Nn,a as Pn,at as Fn,b as In,c as tee,ct as Ln,d as nee,et as Rn,f as zn,h as Bn,i as Vn,k as Hn,l as Un,lt as Wn,m as Gn,n as Kn,nt as qn,o as Jn,p as Yn,r as ree,rt as Xn,s as Zn,st as Qn,t as $n,tt as er,ut as tr,w as nr,x as rr,y as ir}from"./definition-C7QrKMH2.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ar=a((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),iee=a(((e,t)=>{t.exports=ar()})),or=a((e=>{var t=iee(),n=Je(),r=_t();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function R(e){return{current:e}}function z(e){0>L||(e.current=I[L],I[L]=null,L--)}function B(e,t){L++,I[L]=e.current,e.current=t}var ee=R(null),V=R(null),te=R(null),ne=R(null);function re(e,t){switch(B(te,t),B(V,e),B(ee,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ed(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ed(t),e=Dd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(ee),B(ee,e)}function ie(){z(ee),z(V),z(te)}function ae(e){e.memoizedState!==null&&B(ne,e);var t=ee.current,n=Dd(t,e.type);t!==n&&(B(V,e),B(ee,n))}function oe(e){V.current===e&&(z(ee),z(V)),ne.current===e&&(z(ne),jf._currentValue=F)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+se+e+ce}var ue=!1;function de(e,t){if(!e||ue)return``;ue=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -240,7 +240,7 @@ ${t}`,d++;break;case`id`:l=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.t
|
|
|
240
240
|
span {
|
|
241
241
|
text-decoration: underline;
|
|
242
242
|
}
|
|
243
|
-
`]),`#666`),NE=function(e){return e/1024/1024},YAe=function(e){return e===void 0?``:e.map((function(e){return`.${e.toLowerCase()}`})).join(`,`)};function XAe(e){var t=e.types,n=e.minSize,r=e.maxSize;if(t){var i=t.toString(),a=``;return r&&(a+=`size >= ${r}, `),n&&(a+=`size <= ${n}, `),(0,U.jsx)(`span`,jE({title:`${a}types: ${i}`,className:`file-types`},{children:i}),void 0)}return null}function ZAe(){return(0,U.jsxs)(`svg`,jE({width:`32`,height:`32`,viewBox:`0 0 32 32`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},{children:[(0,U.jsx)(`path`,{d:`M5.33317 6.66667H22.6665V16H25.3332V6.66667C25.3332 5.196 24.1372 4 22.6665 4H5.33317C3.8625 4 2.6665 5.196 2.6665 6.66667V22.6667C2.6665 24.1373 3.8625 25.3333 5.33317 25.3333H15.9998V22.6667H5.33317V6.66667Z`,fill:`#0658C2`},void 0),(0,U.jsx)(`path`,{d:`M10.6665 14.6667L6.6665 20H21.3332L15.9998 12L11.9998 17.3333L10.6665 14.6667Z`,fill:`#0658C2`},void 0),(0,U.jsx)(`path`,{d:`M25.3332 18.6667H22.6665V22.6667H18.6665V25.3333H22.6665V29.3333H25.3332V25.3333H29.3332V22.6667H25.3332V18.6667Z`,fill:`#0658C2`},void 0)]}),void 0)}var PE=0,QAe=function(e,t,n,r,i,a){return n?(0,U.jsx)(`span`,{children:`File type/size error, Hovered on types!`},void 0):(0,U.jsx)(JAe,{children:r?(0,U.jsx)(`span`,{children:`Upload disabled`},void 0):(0,U.jsx)(U.Fragment,e||t?{children:a?(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(`span`,{children:a},void 0)},void 0):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{children:`Uploaded Successfully!`},void 0),` Upload another?`]},void 0)}:{children:(0,U.jsxs)(U.Fragment,i?{children:[(0,U.jsx)(`span`,{children:i.split(` `)[0]},void 0),` `,i.substr(i.indexOf(` `)+1)]}:{children:[(0,U.jsx)(`span`,{children:`Upload`},void 0),` or drop a file right here`]},void 0)},void 0)},void 0)},FE=function(e){var t=e.name,n=e.hoverTitle,r=e.types,i=e.handleChange,a=e.classes,o=e.children,s=e.maxSize,c=e.minSize,l=e.fileOrFiles,u=e.onSizeError,d=e.onTypeError,f=e.onSelect,p=e.onDrop,m=e.disabled,h=e.label,g=e.uploadedLabel,_=e.multiple,v=e.required,y=e.onDraggingStateChange,b=e.dropMessageStyle,x=e.ariaLabel,S=e.ariaDescribedby,C=(0,H.useRef)(null),w=(0,H.useRef)(null),T=(0,H.useState)(!1),E=T[0],D=T[1],O=(0,H.useState)(null),k=O[0],A=O[1],j=(0,H.useState)(!1),M=j[0],N=j[1],P=function(e){return r&&!function(e,t){var n=e.name.split(`.`).pop();return t.map((function(e){return e.toLowerCase()})).includes(n.toLowerCase())}(e,r)?(N(!0),d&&d(`File type is not supported`),!1):s&&NE(e.size)>s?(N(!0),u&&u(`File size is too big`),!1):!(c&&NE(e.size)<c)||(N(!0),u&&u(`File size is too small`),!1)},F=function(e){var t=!1;if(e){if(e instanceof File)t=!P(e);else for(var n=0;n<e.length;n++){var r=e[n];t=!P(r)||t}return!t&&(i&&i(e),A(e),D(!0),N(!1),!0)}return!1},I=function(e){var t=e.labelRef,n=e.inputRef,r=e.multiple,i=e.handleChanges,a=e.onDrop,o=(0,H.useState)(!1),s=o[0],c=o[1],l=(0,H.useCallback)((function(){n.current.click()}),[n]),u=(0,H.useCallback)((function(e){e.preventDefault(),e.stopPropagation(),PE++,e.dataTransfer.items&&e.dataTransfer.items.length!==0&&c(!0)}),[]),d=(0,H.useCallback)((function(e){e.preventDefault(),e.stopPropagation(),--PE>0||c(!1)}),[]),f=(0,H.useCallback)((function(e){e.preventDefault(),e.stopPropagation()}),[]),p=(0,H.useCallback)((function(e){e.preventDefault(),e.stopPropagation(),c(!1),PE=0;var t=e.dataTransfer.files;if(t&&t.length>0){var n=r?t:t[0],o=i(n);a&&o&&a(n)}}),[i]);return(0,H.useEffect)((function(){var e=t.current;return e.addEventListener(`click`,l),e.addEventListener(`dragenter`,u),e.addEventListener(`dragleave`,d),e.addEventListener(`dragover`,f),e.addEventListener(`drop`,p),function(){e.removeEventListener(`click`,l),e.removeEventListener(`dragenter`,u),e.removeEventListener(`dragleave`,d),e.removeEventListener(`dragover`,f),e.removeEventListener(`drop`,p)}}),[l,u,d,f,p,t]),s}({labelRef:C,inputRef:w,multiple:_,handleChanges:F,onDrop:p});return(0,H.useEffect)((function(){y?.(I)}),[I]),(0,H.useEffect)((function(){l?(D(!0),A(l)):(w.current&&(w.current.value=``),D(!1),A(null))}),[l]),(0,U.jsxs)(GAe,jE({overRide:o,className:`${a||``} ${m?`is-disabled`:``}`,ref:C,htmlFor:t,onClick:function(e){e.preventDefault(),e.stopPropagation()},"aria-describedby":S,role:`button`,"aria-label":x},{children:[(0,U.jsx)(`input`,{onClick:function(e){e.stopPropagation(),w&&w.current&&(w.current.value=``,w.current.click())},onChange:function(e){var t=e.target.files,n=_?t:t[0],r=F(n);f&&r&&f(n)},accept:YAe(r),ref:w,type:`file`,id:t,name:t,disabled:m,multiple:_,required:v},void 0),I&&(0,U.jsx)(KAe,jE({style:b},{children:(0,U.jsx)(`span`,{children:n||`Drop Here`},void 0)}),void 0),!o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ZAe,{},void 0),(0,U.jsxs)(qAe,jE({error:M},{children:[QAe(k,E,M,m,h,g),(0,U.jsx)(XAe,{types:r,minSize:c,maxSize:s},void 0)]}),void 0)]},void 0),o]}),void 0)},IE=e=>e.productType===`ai`,LE=e=>e.productType===`ai`&&e.productVersion===2,RE=e=>e.productType===`ai`&&e.productVersion!==2,zE=`__custom`,$Ae=`BedrockMantle`,eje=/^[a-z]{2,4}(?:-[a-z]+)+-\d+$/,BE=e=>`https://bedrock-mantle.${e}.api.aws`,tje=e=>{if(!e)return;let t;try{t=new URL(e).hostname}catch{return}return/^bedrock-mantle\.([a-z]{2,4}(?:-[a-z]+)+-\d+)\.api\.aws$/.exec(t)?.[1]},VE=`ZuploDemo`,HE=`Zuplo Demo`,UE=e=>e?.trim()===VE,nje=`Zuplo Demo is available on AI Gateway v2 projects`,WE=e=>e.productType!==void 0&&LE({...e,productType:e.productType}),rje=new Set([`present-options`,`present-link`,`present-consumer`,`present-environment-variable`,`present-source`,`celebrate`,`present-file`,`show-test-console`,`switch-project`,`update-working-copy`,`request-openapi-import`,`request-ai-provider`,`request-ai-team`,`request-ai-app`]);function GE(e){return jx(e)?e.state!==`output-available`&&e.state!==`output-error`&&e.state!==`output-denied`:!1}var ije=new Set([`approval-requested`,`approval-responded`,`output-denied`]);function KE(e){return jx(e)&&ije.has(e.state)}function aje(e){let t=[],n=null;return e.forEach((e,r)=>{if(jx(e)){let i=Nx(e);if(!rje.has(i)&&!KE(e)){let a={name:i,pending:GE(e)};n?n.tools.push(a):(n={kind:`tools`,index:r,tools:[a]},t.push(n));return}}sje(e)||(n=null,t.push({kind:`part`,index:r,part:e}))}),t}function qE(e){return e.kind===`part`&&jx(e.part)&&Nx(e.part)===`present-options`}function oje(e){if(!e.some(qE))return e;let t=e.filter(e=>!qE(e)),n=e.filter(qE);return[...t,...n]}function sje(e){return e.type===`step-start`?!0:e.type===`text`||e.type===`reasoning`?e.text.trim()===``:!1}var cje=/\b(save|write|create|edit|update|patch|append|delete|remove|rename|move)\b/i,lje=new Set([`get-deployment-versions`,`get-deployment-logs`,`get-build-logs`,`check-build-status`,`check-deployed-version`]),uje=new Set([`search-zuplo-docs`,`get-available-doc-pages`,`get-doc-page`]),dje={get:`Getting`,list:`Listing`,check:`Checking`,create:`Creating`,query:`Querying`,search:`Searching`,redeploy:`Redeploying`,request:`Requesting`,present:`Presenting`};function fje(e){if(uje.has(e))return`Planning next steps`;let t=JE(e),n=/\b(files?|director(?:y|ies)|folders?)\b/i.test(t);return n&&cje.test(t)?`Writing Code`:n||lje.has(e)?`Exploring Project`:pje(t)}function pje(e){let[t,...n]=e.split(` `),r=dje[t.toLowerCase()];return r?[r,...n].join(` `):e}function mje(e){let t=new Map;for(let{name:n,pending:r}of e){let e=fje(n),i=t.get(e);i?(i.count+=1,i.pending=i.pending||r):t.set(e,{count:1,pending:r})}return Array.from(t,([e,{count:t,pending:n}])=>({label:e,count:t,pending:n}))}var hje=new Set([`ai`,`api`,`http`,`mcp`,`url`]);function JE(e){let t=e.trim();return t&&(t.replace(/[_-]tool$/i,``).replace(/([a-z0-9])Tool$/,`$1`)||t).replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/\s+/g,` `).trim().split(` `).map(e=>hje.has(e.toLowerCase())?e.toUpperCase():e&&e[0].toUpperCase()+e.slice(1)).join(` `)}function YE({isUser:e=!1,footer:t,children:n}){return(0,U.jsx)(`div`,{className:W(`group flex items-start gap-2.5`,e?`justify-end`:`justify-start`),children:(0,U.jsxs)(`div`,{className:W(`flex flex-col`,e?`max-w-[85%]`:`min-w-0 flex-1`),children:[(0,U.jsx)(`div`,{className:W(`flex flex-col gap-3 rounded-2xl px-4 py-2.5 text-sm`,e?`bg-primary text-primary-foreground`:`border bg-background`),children:n}),t]})})}var XE=4;function ZE({tools:e}){let t=mje(e),n=t.slice(0,XE),r=t.slice(XE),i=r.length,a=r.some(e=>e.pending);return(0,U.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(rb,{weight:`fill`,className:`mt-0.5 size-3 shrink-0`}),(0,U.jsxs)(`span`,{children:[n.map((e,t)=>(0,U.jsxs)(H.Fragment,{children:[t>0?`, `:null,(0,U.jsx)(`span`,{className:W(`font-medium`,e.pending&&`animate-text-shimmer`),children:e.label}),e.count>1?` ×${e.count}`:null]},e.label)),i>0?(0,U.jsxs)(U.Fragment,{children:[`, `,(0,U.jsx)(`span`,{className:W(a&&`animate-text-shimmer`),children:`+${i} more`})]}):null]})]})}function gje({text:e}){let[t,n]=(0,H.useState)(!1);return(0,U.jsxs)(Fw,{open:t,onOpenChange:n,children:[(0,U.jsxs)(Iw,{className:`flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[(0,U.jsx)(rd,{className:W(`size-3 shrink-0 transition-transform`,t&&`rotate-90`)}),(0,U.jsx)(`span`,{className:`font-medium`,children:`Thinking`})]}),(0,U.jsx)(Lw,{children:(0,U.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap border-l-2 pl-3 text-xs italic text-muted-foreground`,children:e})})]})}function _je({data:e,onSend:t,disabled:n}){let r=e.options.slice(0,3);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.prompt?(0,U.jsx)(kC,{content:e.prompt}):null,(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map((e,r)=>(0,U.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>t(e.label),className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none disabled:opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-6 shrink-0 items-center justify-center rounded-md border border-brand/30 bg-brand/10 text-xs font-medium text-brand`,children:r+1}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),e.description?(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description}):null]})]},e.id))})]})}function vje({data:e}){let t;try{t=new URL(e.url).host}catch{}return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.description?(0,U.jsx)(kC,{content:e.description}):null,(0,U.jsxs)(Rw,{href:e.url,variant:`ghost`,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left text-foreground transition-colors`,`hover:border-brand/40 hover:bg-accent`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(Td,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.label}),t?(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:t}):null]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]})]})}function yje({data:e}){let t=e.url;try{t=new URL(e.url).pathname}catch{}return(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Source:`,` `,(0,U.jsx)(Rw,{href:e.url,showIcon:!0,children:e.title||t})]})}function bje({message:e}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-brand/30 bg-gradient-to-br from-brand/15 via-brand/5 to-transparent p-3`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(Oee,{className:`size-4`})}),(0,U.jsx)(kC,{content:e,className:`min-w-0 flex-1 font-medium prose-p:my-0`})]})}function xje({sub:e,description:t,loading:n=!1,errorText:r,onOpen:i}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t?(0,U.jsx)(kC,{content:t}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:n,onClick:i,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:n?(0,U.jsx)(nf,{className:`size-4 animate-spin`}):(0,U.jsx)(Zd,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`API key consumer`})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]}),r?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:r}):null]})}function Sje({name:e,description:t,loading:n=!1,disabled:r=!1,errorText:i,onOpen:a}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t?(0,U.jsx)(kC,{content:t}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:n||r,onClick:a,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`,r&&`opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:n?(0,U.jsx)(nf,{className:`size-4 animate-spin`}):(0,U.jsx)(_d,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate font-mono text-sm font-medium`,children:e}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Environment variable`})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]}),i?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:i}):null]})}function Cje({path:e,label:t,description:n,disabled:r=!1,onOpen:i}){let a=e.split(`/`).filter(Boolean).pop()??e;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[n?(0,U.jsx)(kC,{content:n}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:r,onClick:i,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none disabled:opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(Od,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t??a}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]})]})}function wje({method:e,path:t,description:n,loading:r=!1,disabled:i=!1,errorText:a,onOpen:o}){let s=t?`${(e??`GET`).toUpperCase()} ${t}`:`Send a live request to your gateway`;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[n?(0,U.jsx)(kC,{content:n}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:r||i,onClick:o,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`,i&&`opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:r?(0,U.jsx)(nf,{className:`size-4 animate-spin`}):(0,U.jsx)(Lf,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Open test console`}),(0,U.jsx)(`span`,{className:W(`truncate text-xs text-muted-foreground`,t&&`font-mono`),children:s})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]}),a?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:a}):null]})}function Tje({projectName:e,reason:t,isActive:n=!1,disabled:r=!1,onSwitch:i}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t?(0,U.jsx)(kC,{content:t}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:n||r,onClick:i,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:n?(0,U.jsx)(td,{className:`size-4`}):(0,U.jsx)(zd,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n?`Working on ${e}`:`Switch to ${e}`}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n?`Zuplo AI is working on this project`:`Move this conversation to that project`})]}),n?null:(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]})]})}function Eje({description:e,disabled:t=!1,onOpen:n}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e?(0,U.jsx)(kC,{content:e}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:t,onClick:n,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none disabled:opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(vf,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Update working copy`}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:`Pull the latest changes from your repo`})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]})]})}function QE({provider:e,description:t,loading:n=!1,disabled:r=!1,unavailableText:i,errorText:a,onOpen:o}){let s=UE(e),c=s?HE:e,l=!!i;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t?(0,U.jsx)(kC,{content:t}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:n||r||l,onClick:o,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`,(r||l)&&`opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:n?(0,U.jsx)(nf,{className:`size-4 animate-spin`}):(0,U.jsx)(Yu,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:c?`Add ${c}`:`Add AI provider`}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:i??(c?s?`No API key needed — pick models`:`Connect your ${c} API key and pick models`:`Connect an API key and pick models`)})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]}),a?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:a}):null]})}function Dje({name:e,description:t,disabled:n=!1,onOpen:r}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t?(0,U.jsx)(kC,{content:t}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:n,onClick:r,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none disabled:opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(gee,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e?`Create app “${e}”`:`Create app`}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:`Name it and pick its team; models come next`})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]})]})}function Oje({name:e,isSubTeam:t=!1,description:n,loading:r=!1,disabled:i=!1,errorText:a,onOpen:o}){let s=t?`sub-team`:`team`;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[n?(0,U.jsx)(kC,{content:n}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:r||i,onClick:o,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`,i&&`opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:r?(0,U.jsx)(nf,{className:`size-4 animate-spin`}):(0,U.jsx)(Uf,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e?`Create ${s} “${e}”`:`Create ${s}`}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:`Group apps and set shared usage limits`})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]}),a?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:a}):null]})}var kje=[`JSON`,`YML`,`YAML`],$E=`50`;function Aje({data:e,status:t,fileName:n,errorText:r,disabled:i=!1,onFileSelected:a}){return t===`done`?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.message?(0,U.jsx)(kC,{content:e.message}):null,(0,U.jsxs)(`div`,{className:`flex w-full items-center gap-3 rounded-lg border bg-surface p-3`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(td,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n?`Imported ${n}`:`OpenAPI file imported`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saved to your working copy`})]})]})]}):t===`saving`?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.message?(0,U.jsx)(kC,{content:e.message}):null,(0,U.jsxs)(`div`,{className:`flex w-full items-center gap-3 rounded-lg border bg-surface p-3`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(nf,{className:`size-4 animate-spin`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n?`Importing ${n}…`:`Importing…`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saving to your working copy`})]})]})]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.message?(0,U.jsx)(kC,{content:e.message}):null,(0,U.jsx)(FE,{handleChange:a,name:`file`,types:kje,maxSize:$E,disabled:i,classes:`w-full`,children:(0,U.jsxs)(`div`,{className:W(`flex w-full flex-col items-center justify-center gap-1 rounded-lg border border-dashed bg-surface px-4 py-6 text-center transition-colors`,i?`opacity-60`:`cursor-pointer hover:border-brand/40 hover:bg-accent`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`mb-1 flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(Fd,{className:`size-4`})}),(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Drop your OpenAPI file here`}),(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`or click to choose — JSON, YAML or YML up to`,` `,$E,`MB`]})]})}),r?(0,U.jsxs)(`p`,{className:W(`flex items-start gap-1.5 text-xs`,t===`error`?`text-destructive-foreground`:`text-muted-foreground`),children:[(0,U.jsx)(sd,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,U.jsx)(`span`,{children:r})]}):null]})}function jje({toolLabel:e,input:t,status:n,onRespond:r}){let i=n.kind===`denied`||n.kind===`responded`&&!n.approved,a=t&&typeof t==`object`&&Object.keys(t).length>0?JSON.stringify(t,null,2):null;return(0,U.jsxs)(`div`,{className:`flex w-full flex-col gap-3 rounded-lg border bg-surface p-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:W(`flex size-9 shrink-0 items-center justify-center rounded-lg border`,i?`border-border bg-muted text-muted-foreground`:`border-brand/30 bg-brand/10 text-brand`),children:i?(0,U.jsx)(Vu,{className:`size-4`}):(0,U.jsx)(Of,{className:`size-4`})}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.kind===`requested`?`Zuplo AI needs your approval to run this`:i?`Denied — this was not run`:`Approved — running…`})]})]}),a&&n.kind===`requested`?(0,U.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded-md bg-surface-muted px-3 py-2 font-mono text-xs text-muted-foreground`,children:a}):null,n.kind===`requested`?(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(X,{type:`button`,size:`sm`,onClick:()=>r(!0),children:`Approve`}),(0,U.jsx)(X,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(!1),children:`Deny`})]}):null]})}function eD(){return(0,U.jsx)(`output`,{className:`flex items-center gap-1 py-1`,"aria-label":`Zuplo AI is thinking`,children:[0,1,2].map(e=>(0,U.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/70 motion-safe:animate-bounce`,style:{animationDelay:`${e*.15}s`}},e))})}function Mje(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.message==`string`?t.message.trim():void 0;return n?{message:n}:null}var tD=null;function Nje(){typeof window>`u`||(tD||=new wke,tD.addConfetti({emojis:[`🎉`,`✨`,`🎊`,`⭐️`,`🚀`],confettiNumber:60}))}function Pje({data:e}){let{logEvent:t}=on(),{account:n,project:r}=Wb([]),i=(0,H.useRef)(!1);return(0,H.useEffect)(()=>{i.current||(i.current=!0,t(`agent-z-celebrate-shown`,{account:n,project:r}),typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||Nje())},[t,n,r]),(0,U.jsx)(bje,{message:e.message})}var nD=e=>e.type===`checkbox`,rD=e=>e instanceof Date,iD=e=>e==null,aD=e=>typeof e==`object`,oD=e=>!iD(e)&&!Array.isArray(e)&&aD(e)&&!rD(e),sD=e=>oD(e)&&e.target?nD(e.target)?e.target.checked:e.target.value:e,Fje=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,cD=(e,t)=>e.has(Fje(t)),Ije=e=>{let t=e.constructor&&e.constructor.prototype;return oD(t)&&t.hasOwnProperty(`isPrototypeOf`)},lD=typeof window<`u`&&window.HTMLElement!==void 0&&typeof document<`u`;function uD(e){let t,n=Array.isArray(e),r=typeof FileList<`u`?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(lD&&(e instanceof Blob||r))&&(n||oD(e)))if(t=n?[]:{},!n&&!Ije(e))t=e;else for(let n in e)e.hasOwnProperty(n)&&(t[n]=uD(e[n]));else return e;return t}var dD=e=>Array.isArray(e)?e.filter(Boolean):[],fD=e=>e===void 0,pD=(e,t,n)=>{if(!t||!oD(e))return n;let r=dD(t.split(/[,[\].]+?/)).reduce((e,t)=>iD(e)?e:e[t],e);return fD(r)||r===e?fD(e[t])?n:e[t]:r},mD=e=>typeof e==`boolean`,hD=e=>/^\w*$/.test(e),gD=e=>dD(e.replace(/["|']|\]/g,``).split(/\.|\[/)),_D=(e,t,n)=>{let r=-1,i=hD(t)?[t]:gD(t),a=i.length,o=a-1;for(;++r<a;){let t=i[r],a=n;if(r!==o){let n=e[t];a=oD(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if(t===`__proto__`||t===`constructor`||t===`prototype`)return;e[t]=a,e=e[t]}},vD={BLUR:`blur`,FOCUS_OUT:`focusout`,CHANGE:`change`},yD={onBlur:`onBlur`,onChange:`onChange`,onSubmit:`onSubmit`,onTouched:`onTouched`,all:`all`},bD={max:`max`,min:`min`,maxLength:`maxLength`,minLength:`minLength`,pattern:`pattern`,required:`required`,validate:`validate`},xD=H.createContext(null),SD=()=>H.useContext(xD),CD=e=>{let{children:t,...n}=e;return H.createElement(xD.Provider,{value:n},t)},wD=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let a in e)Object.defineProperty(i,a,{get:()=>{let i=a;return t._proxyFormState[i]!==yD.all&&(t._proxyFormState[i]=!r||yD.all),n&&(n[i]=!0),e[i]}});return i},TD=e=>iD(e)||!aD(e);function ED(e,t){if(TD(e)||TD(t))return e===t;if(rD(e)&&rD(t))return e.getTime()===t.getTime();let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n){let n=e[i];if(!r.includes(i))return!1;if(i!==`ref`){let e=t[i];if(rD(n)&&rD(e)||oD(n)&&oD(e)||Array.isArray(n)&&Array.isArray(e)?!ED(n,e):n!==e)return!1}}return!0}var DD=(e,t)=>{let n=H.useRef(t);ED(t,n.current)||(n.current=t),H.useEffect(e,n.current)};function OD(e){let t=SD(),{control:n=t.control,disabled:r,name:i,exact:a}=e||{},[o,s]=H.useState(n._formState),c=H.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return DD(()=>n._subscribe({name:i,formState:c.current,exact:a,callback:e=>{!r&&s({...n._formState,...e})}}),[i,r,a]),H.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),H.useMemo(()=>wD(o,n,c.current,!1),[o,n])}var kD=e=>typeof e==`string`,AD=(e,t,n,r,i)=>kD(e)?(r&&t.watch.add(e),pD(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),pD(n,e))):(r&&(t.watchAll=!0),n);function Lje(e){let t=SD(),{control:n=t.control,name:r,defaultValue:i,disabled:a,exact:o}=e||{},[s,c]=H.useState(n._getWatch(r,i));return DD(()=>n._subscribe({name:r,formState:{values:!0},exact:o,callback:e=>!a&&c(AD(r,n._names,e.values||n._formValues,!1,i))}),[r,i,a,o]),H.useEffect(()=>n._removeUnmounted()),s}function Rje(e){let t=SD(),{name:n,disabled:r,control:i=t.control,shouldUnregister:a}=e,o=cD(i._names.array,n),s=Lje({control:i,name:n,defaultValue:pD(i._formValues,n,pD(i._defaultValues,n,e.defaultValue)),exact:!0}),c=OD({control:i,name:n,exact:!0}),l=H.useRef(e),u=H.useRef(i.register(n,{...e.rules,value:s,...mD(e.disabled)?{disabled:e.disabled}:{}})),d=H.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!pD(c.errors,n)},isDirty:{enumerable:!0,get:()=>!!pD(c.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!pD(c.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!pD(c.validatingFields,n)},error:{enumerable:!0,get:()=>pD(c.errors,n)}}),[c,n]),f=H.useCallback(e=>u.current.onChange({target:{value:sD(e),name:n},type:vD.CHANGE}),[n]),p=H.useCallback(()=>u.current.onBlur({target:{value:pD(i._formValues,n),name:n},type:vD.BLUR}),[n,i._formValues]),m=H.useCallback(e=>{let t=pD(i._fields,n);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})},[i._fields,n]),h=H.useMemo(()=>({name:n,value:s,...mD(r)||c.disabled?{disabled:c.disabled||r}:{},onChange:f,onBlur:p,ref:m}),[n,r,c.disabled,f,p,m,s]);return H.useEffect(()=>{let e=i._options.shouldUnregister||a;i.register(n,{...l.current.rules,...mD(l.current.disabled)?{disabled:l.current.disabled}:{}});let t=(e,t)=>{let n=pD(i._fields,e);n&&n._f&&(n._f.mount=t)};if(t(n,!0),e){let e=uD(pD(i._options.defaultValues,n));_D(i._defaultValues,n,e),fD(pD(i._formValues,n))&&_D(i._formValues,n,e)}return!o&&i.register(n),()=>{(o?e&&!i._state.action:e)?i.unregister(n):t(n,!1)}},[n,i,o,a]),H.useEffect(()=>{i._setDisabledField({disabled:r,name:n})},[r,n,i]),H.useMemo(()=>({field:h,formState:c,fieldState:d}),[h,c,d])}var jD=e=>e.render(Rje(e)),MD=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},ND=e=>Array.isArray(e)?e:[e],PD=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}},FD=e=>oD(e)&&!Object.keys(e).length,ID=e=>e.type===`file`,LD=e=>typeof e==`function`,RD=e=>{if(!lD)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},zD=e=>e.type===`select-multiple`,BD=e=>e.type===`radio`,zje=e=>BD(e)||nD(e),VD=e=>RD(e)&&e.isConnected;function Bje(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;)e=fD(e)?r++:e[t[r++]];return e}function Vje(e){for(let t in e)if(e.hasOwnProperty(t)&&!fD(e[t]))return!1;return!0}function HD(e,t){let n=Array.isArray(t)?t:hD(t)?[t]:gD(t),r=n.length===1?e:Bje(e,n),i=n.length-1,a=n[i];return r&&delete r[a],i!==0&&(oD(r)&&FD(r)||Array.isArray(r)&&Vje(r))&&HD(e,n.slice(0,-1)),e}var UD=e=>{for(let t in e)if(LD(e[t]))return!0;return!1};function WD(e,t={}){let n=Array.isArray(e);if(oD(e)||n)for(let n in e)Array.isArray(e[n])||oD(e[n])&&!UD(e[n])?(t[n]=Array.isArray(e[n])?[]:{},WD(e[n],t[n])):iD(e[n])||(t[n]=!0);return t}function GD(e,t,n){let r=Array.isArray(e);if(oD(e)||r)for(let r in e)Array.isArray(e[r])||oD(e[r])&&!UD(e[r])?fD(t)||TD(n[r])?n[r]=Array.isArray(e[r])?WD(e[r],[]):{...WD(e[r])}:GD(e[r],iD(t)?{}:t[r],n[r]):n[r]=!ED(e[r],t[r]);return n}var KD=(e,t)=>GD(e,t,WD(t)),qD={value:!1,isValid:!1},JD={value:!0,isValid:!0},YD=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!fD(e[0].attributes.value)?fD(e[0].value)||e[0].value===``?JD:{value:e[0].value,isValid:!0}:JD:qD}return qD},XD=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>fD(e)?e:t?e===``?NaN:e&&+e:n&&kD(e)?new Date(e):r?r(e):e,ZD={isValid:!1,value:null},QD=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,ZD):ZD;function $D(e){let t=e.ref;return ID(t)?t.files:BD(t)?QD(e.refs).value:zD(t)?[...t.selectedOptions].map(({value:e})=>e):nD(t)?YD(e.refs).value:XD(fD(t.value)?e.ref.value:t.value,e)}var Hje=(e,t,n,r)=>{let i={};for(let n of e){let e=pD(t,n);e&&_D(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},eO=e=>e instanceof RegExp,tO=e=>fD(e)?e:eO(e)?e.source:oD(e)?eO(e.value)?e.value.source:e.value:e,nO=e=>({isOnSubmit:!e||e===yD.onSubmit,isOnBlur:e===yD.onBlur,isOnChange:e===yD.onChange,isOnAll:e===yD.all,isOnTouch:e===yD.onTouched}),rO=`AsyncFunction`,Uje=e=>!!e&&!!e.validate&&!!(LD(e.validate)&&e.validate.constructor.name===rO||oD(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===rO)),Wje=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),iO=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))),aO=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=pD(e,i);if(n){let{_f:e,...a}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r||e.ref&&t(e.ref,e.name)&&!r)return!0;if(aO(a,t))break}else if(oD(a)&&aO(a,t))break}}};function oO(e,t,n){let r=pD(e,n);if(r||hD(n))return{error:r,name:n};let i=n.split(`.`);for(;i.length;){let r=i.join(`.`),a=pD(t,r),o=pD(e,r);if(a&&!Array.isArray(a)&&n!==r)return{name:n};if(o&&o.type)return{name:r,error:o};i.pop()}return{name:n}}var Gje=(e,t,n,r)=>{n(e);let{name:i,...a}=e;return FD(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(e=>t[e]===(!r||yD.all))},Kje=(e,t,n)=>!e||!t||e===t||ND(e).some(e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e))),qje=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,Jje=(e,t)=>!dD(pD(e,t)).length&&HD(e,t),sO=(e,t,n)=>{let r=ND(pD(e,n));return _D(r,`root`,t[n]),_D(e,n,r),e},cO=e=>kD(e);function lO(e,t,n=`validate`){if(cO(e)||Array.isArray(e)&&e.every(cO)||mD(e)&&!e)return{type:n,message:cO(e)?e:``,ref:t}}var uO=e=>oD(e)&&!eO(e)?e:{value:e,message:``},dO=async(e,t,n,r,i,a)=>{let{ref:o,refs:s,required:c,maxLength:l,minLength:u,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:_}=e._f,v=pD(n,h);if(!_||t.has(h))return{};let y=s?s[0]:o,b=e=>{i&&y.reportValidity&&(y.setCustomValidity(mD(e)?``:e||``),y.reportValidity())},x={},S=BD(o),C=nD(o),w=S||C,T=(g||ID(o))&&fD(o.value)&&fD(v)||RD(o)&&o.value===``||v===``||Array.isArray(v)&&!v.length,E=MD.bind(null,h,r,x),D=(e,t,n,r=bD.maxLength,i=bD.minLength)=>{let a=e?t:n;x[h]={type:e?r:i,message:a,ref:o,...E(e?r:i,a)}};if(a?!Array.isArray(v)||!v.length:c&&(!w&&(T||iD(v))||mD(v)&&!v||C&&!YD(s).isValid||S&&!QD(s).isValid)){let{value:e,message:t}=cO(c)?{value:!!c,message:c}:uO(c);if(e&&(x[h]={type:bD.required,message:t,ref:y,...E(bD.required,t)},!r))return b(t),x}if(!T&&(!iD(d)||!iD(f))){let e,t,n=uO(f),i=uO(d);if(!iD(v)&&!isNaN(v)){let r=o.valueAsNumber||v&&+v;iD(n.value)||(e=r>n.value),iD(i.value)||(t=r<i.value)}else{let r=o.valueAsDate||new Date(v),a=e=>new Date(new Date().toDateString()+` `+e),s=o.type==`time`,c=o.type==`week`;kD(n.value)&&v&&(e=s?a(v)>a(n.value):c?v>n.value:r>new Date(n.value)),kD(i.value)&&v&&(t=s?a(v)<a(i.value):c?v<i.value:r<new Date(i.value))}if((e||t)&&(D(!!e,n.message,i.message,bD.max,bD.min),!r))return b(x[h].message),x}if((l||u)&&!T&&(kD(v)||a&&Array.isArray(v))){let e=uO(l),t=uO(u),n=!iD(e.value)&&v.length>+e.value,i=!iD(t.value)&&v.length<+t.value;if((n||i)&&(D(n,e.message,t.message),!r))return b(x[h].message),x}if(p&&!T&&kD(v)){let{value:e,message:t}=uO(p);if(eO(e)&&!v.match(e)&&(x[h]={type:bD.pattern,message:t,ref:o,...E(bD.pattern,t)},!r))return b(t),x}if(m){if(LD(m)){let e=lO(await m(v,n),y);if(e&&(x[h]={...e,...E(bD.validate,e.message)},!r))return b(e.message),x}else if(oD(m)){let e={};for(let t in m){if(!FD(e)&&!r)break;let i=lO(await m[t](v,n),y,t);i&&(e={...i,...E(t,i.message)},b(i.message),r&&(x[h]=e))}if(!FD(e)&&(x[h]={ref:y,...e},!r))return x}}return b(!0),x},Yje={mode:yD.onSubmit,reValidateMode:yD.onChange,shouldFocusError:!0};function Xje(e={}){let t={...Yje,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:LD(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=(oD(t.defaultValues)||oD(t.values))&&uD(t.values||t.defaultValues)||{},a=t.shouldUnregister?{}:uD(i),o={action:!1,mount:!1,watch:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,l=0,u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...u},f={array:PD(),state:PD()},p=nO(t.mode),m=nO(t.reValidateMode),h=t.criteriaMode===yD.all,g=e=>t=>{clearTimeout(l),l=setTimeout(e,t)},_=async e=>{if(!t.disabled&&(u.isValid||d.isValid||e)){let e=t.resolver?FD((await T()).errors):await D(r,!0);e!==n.isValid&&f.state.next({isValid:e})}},v=(e,r)=>{!t.disabled&&(u.isValidating||u.validatingFields||d.isValidating||d.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(r?_D(n.validatingFields,e,r):HD(n.validatingFields,e))}),f.state.next({validatingFields:n.validatingFields,isValidating:!FD(n.validatingFields)}))},y=(e,s=[],c,l,p=!0,m=!0)=>{if(l&&c&&!t.disabled){if(o.action=!0,m&&Array.isArray(pD(r,e))){let t=c(pD(r,e),l.argA,l.argB);p&&_D(r,e,t)}if(m&&Array.isArray(pD(n.errors,e))){let t=c(pD(n.errors,e),l.argA,l.argB);p&&_D(n.errors,e,t),Jje(n.errors,e)}if((u.touchedFields||d.touchedFields)&&m&&Array.isArray(pD(n.touchedFields,e))){let t=c(pD(n.touchedFields,e),l.argA,l.argB);p&&_D(n.touchedFields,e,t)}(u.dirtyFields||d.dirtyFields)&&(n.dirtyFields=KD(i,a)),f.state.next({name:e,isDirty:k(e,s),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else _D(a,e,s)},b=(e,t)=>{_D(n.errors,e,t),f.state.next({errors:n.errors})},x=e=>{n.errors=e,f.state.next({errors:n.errors,isValid:!1})},S=(e,t,n,s)=>{let c=pD(r,e);if(c){let r=pD(a,e,fD(n)?pD(i,e):n);fD(r)||s&&s.defaultChecked||t?_D(a,e,t?r:$D(c._f)):M(e,r),o.mount&&_()}},C=(e,r,a,o,s)=>{let c=!1,l=!1,p={name:e};if(!t.disabled){if(!a||o){(u.isDirty||d.isDirty)&&(l=n.isDirty,n.isDirty=p.isDirty=k(),c=l!==p.isDirty);let t=ED(pD(i,e),r);l=!!pD(n.dirtyFields,e),t?HD(n.dirtyFields,e):_D(n.dirtyFields,e,!0),p.dirtyFields=n.dirtyFields,c||=(u.dirtyFields||d.dirtyFields)&&l!==!t}if(a){let t=pD(n.touchedFields,e);t||(_D(n.touchedFields,e,a),p.touchedFields=n.touchedFields,c||=(u.touchedFields||d.touchedFields)&&t!==a)}c&&s&&f.state.next(p)}return c?p:{}},w=(e,r,i,a)=>{let o=pD(n.errors,e),s=(u.isValid||d.isValid)&&mD(r)&&n.isValid!==r;if(t.delayError&&i?(c=g(()=>b(e,i)),c(t.delayError)):(clearTimeout(l),c=null,i?_D(n.errors,e,i):HD(n.errors,e)),(i?!ED(o,i):o)||!FD(a)||s){let t={...a,...s&&mD(r)?{isValid:r}:{},errors:n.errors,name:e};n={...n,...t},f.state.next(t)}},T=async e=>{v(e,!0);let n=await t.resolver(a,t.context,Hje(e||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return v(e),n},E=async e=>{let{errors:t}=await T(e);if(e)for(let r of e){let e=pD(t,r);e?_D(n.errors,r,e):HD(n.errors,r)}else n.errors=t;return t},D=async(e,r,i={valid:!0})=>{for(let o in e){let c=e[o];if(c){let{_f:e,...l}=c;if(e){let l=s.array.has(e.name),d=c._f&&Uje(c._f);d&&u.validatingFields&&v([o],!0);let f=await dO(c,s.disabled,a,h,t.shouldUseNativeValidation&&!r,l);if(d&&u.validatingFields&&v([o]),f[e.name]&&(i.valid=!1,r))break;!r&&(pD(f,e.name)?l?sO(n.errors,f,e.name):_D(n.errors,e.name,f[e.name]):HD(n.errors,e.name))}!FD(l)&&await D(l,r,i)}}return i.valid},O=()=>{for(let e of s.unMount){let t=pD(r,e);t&&(t._f.refs?t._f.refs.every(e=>!VD(e)):!VD(t._f.ref))&&re(e)}s.unMount=new Set},k=(e,n)=>!t.disabled&&(e&&n&&_D(a,e,n),!ED(R(),i)),A=(e,t,n)=>AD(e,s,{...o.mount?a:fD(t)?i:kD(e)?{[e]:t}:t},n,t),j=e=>dD(pD(o.mount?a:i,e,t.shouldUnregister?pD(i,e,[]):[])),M=(e,t,n={})=>{let i=pD(r,e),o=t;if(i){let n=i._f;n&&(!n.disabled&&_D(a,e,XD(t,n)),o=RD(n.ref)&&iD(t)?``:t,zD(n.ref)?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?nD(n.ref)?n.refs.length>1?n.refs.forEach(e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(o)?!!o.find(t=>t===e.value):o===e.value)):n.refs[0]&&(n.refs[0].checked=!!o):n.refs.forEach(e=>e.checked=e.value===o):ID(n.ref)?n.ref.value=``:(n.ref.value=o,n.ref.type||f.state.next({name:e,values:uD(a)})))}(n.shouldDirty||n.shouldTouch)&&C(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&L(e)},N=(e,t,n)=>{for(let i in t){let a=t[i],o=`${e}.${i}`,c=pD(r,o);(s.array.has(e)||oD(a)||c&&!c._f)&&!rD(a)?N(o,a,n):M(o,a,n)}},P=(e,t,c={})=>{let l=pD(r,e),p=s.array.has(e),m=uD(t);_D(a,e,m),p?(f.array.next({name:e,values:uD(a)}),(u.isDirty||u.dirtyFields||d.isDirty||d.dirtyFields)&&c.shouldDirty&&f.state.next({name:e,dirtyFields:KD(i,a),isDirty:k(e,m)})):l&&!l._f&&!iD(m)?N(e,m,c):M(e,m,c),iO(e,s)&&f.state.next({...n}),f.state.next({name:o.mount?e:void 0,values:uD(a)})},F=async e=>{o.mount=!0;let i=e.target,l=i.name,g=!0,y=pD(r,l),b=e=>{g=Number.isNaN(e)||rD(e)&&isNaN(e.getTime())||ED(e,pD(a,l,e))};if(y){let o,x,S=i.type?$D(y._f):sD(e),E=e.type===vD.BLUR||e.type===vD.FOCUS_OUT,O=!Wje(y._f)&&!t.resolver&&!pD(n.errors,l)&&!y._f.deps||qje(E,pD(n.touchedFields,l),n.isSubmitted,m,p),k=iO(l,s,E);_D(a,l,S),E?(y._f.onBlur&&y._f.onBlur(e),c&&c(0)):y._f.onChange&&y._f.onChange(e);let A=C(l,S,E),j=!FD(A)||k;if(!E&&f.state.next({name:l,type:e.type,values:uD(a)}),O)return(u.isValid||d.isValid)&&(t.mode===`onBlur`?E&&_():E||_()),j&&f.state.next({name:l,...k?{}:A});if(!E&&k&&f.state.next({...n}),t.resolver){let{errors:e}=await T([l]);if(b(S),g){let t=oO(e,r,oO(n.errors,r,l).name||l);o=t.error,l=t.name,x=FD(e)}}else v([l],!0),o=(await dO(y,s.disabled,a,h,t.shouldUseNativeValidation))[l],v([l]),b(S),g&&(o?x=!1:(u.isValid||d.isValid)&&(x=await D(r,!0)));g&&(y._f.deps&&L(y._f.deps),w(l,x,o,A))}},I=(e,t)=>{if(pD(n.errors,t)&&e.focus)return e.focus(),1},L=async(e,i={})=>{let a,o,c=ND(e);if(t.resolver){let t=await E(fD(e)?e:c);a=FD(t),o=e?!c.some(e=>pD(t,e)):a}else e?(o=(await Promise.all(c.map(async e=>{let t=pD(r,e);return await D(t&&t._f?{[e]:t}:t)}))).every(Boolean),!(!o&&!n.isValid)&&_()):o=a=await D(r);return f.state.next({...!kD(e)||(u.isValid||d.isValid)&&a!==n.isValid?{}:{name:e},...t.resolver||!e?{isValid:a}:{},errors:n.errors}),i.shouldFocus&&!o&&aO(r,I,e?c:s.mount),o},R=e=>{let t={...o.mount?a:i};return fD(e)?t:kD(e)?pD(t,e):e.map(e=>pD(t,e))},z=(e,t)=>({invalid:!!pD((t||n).errors,e),isDirty:!!pD((t||n).dirtyFields,e),error:pD((t||n).errors,e),isValidating:!!pD(n.validatingFields,e),isTouched:!!pD((t||n).touchedFields,e)}),B=e=>{e&&ND(e).forEach(e=>HD(n.errors,e)),f.state.next({errors:e?n.errors:{}})},ee=(e,t,i)=>{let a=(pD(r,e,{_f:{}})._f||{}).ref,{ref:o,message:s,type:c,...l}=pD(n.errors,e)||{};_D(n.errors,e,{...l,...t,ref:a}),f.state.next({name:e,errors:n.errors,isValid:!1}),i&&i.shouldFocus&&a&&a.focus&&a.focus()},V=(e,t)=>LD(e)?f.state.subscribe({next:n=>e(A(void 0,t),n)}):A(e,t,!0),te=e=>f.state.subscribe({next:t=>{Kje(e.name,t.name,e.exact)&&Gje(t,e.formState||u,pe,e.reRenderRoot)&&e.callback({values:{...a},...n,...t})}}).unsubscribe,ne=e=>(o.mount=!0,d={...d,...e.formState},te({...e,formState:d})),re=(e,o={})=>{for(let c of e?ND(e):s.mount)s.mount.delete(c),s.array.delete(c),o.keepValue||(HD(r,c),HD(a,c)),!o.keepError&&HD(n.errors,c),!o.keepDirty&&HD(n.dirtyFields,c),!o.keepTouched&&HD(n.touchedFields,c),!o.keepIsValidating&&HD(n.validatingFields,c),!t.shouldUnregister&&!o.keepDefaultValue&&HD(i,c);f.state.next({values:uD(a)}),f.state.next({...n,...o.keepDirty?{isDirty:k()}:{}}),!o.keepIsValid&&_()},ie=({disabled:e,name:t})=>{(mD(e)&&o.mount||e||s.disabled.has(t))&&(e?s.disabled.add(t):s.disabled.delete(t))},ae=(e,n={})=>{let a=pD(r,e),c=mD(n.disabled)||mD(t.disabled);return _D(r,e,{...a||{},_f:{...a&&a._f?a._f:{ref:{name:e}},name:e,mount:!0,...n}}),s.mount.add(e),a?ie({disabled:mD(n.disabled)?n.disabled:t.disabled,name:e}):S(e,!0,n.value),{...c?{disabled:n.disabled||t.disabled}:{},...t.progressive?{required:!!n.required,min:tO(n.min),max:tO(n.max),minLength:tO(n.minLength),maxLength:tO(n.maxLength),pattern:tO(n.pattern)}:{},name:e,onChange:F,onBlur:F,ref:c=>{if(c){ae(e,n),a=pD(r,e);let t=fD(c.value)&&c.querySelectorAll&&c.querySelectorAll(`input,select,textarea`)[0]||c,o=zje(t),s=a._f.refs||[];if(o?s.find(e=>e===t):t===a._f.ref)return;_D(r,e,{_f:{...a._f,...o?{refs:[...s.filter(VD),t,...Array.isArray(pD(i,e))?[{}]:[]],ref:{type:t.type,name:e}}:{ref:t}}}),S(e,!1,void 0,t)}else a=pD(r,e,{}),a._f&&(a._f.mount=!1),(t.shouldUnregister||n.shouldUnregister)&&!(cD(s.array,e)&&o.action)&&s.unMount.add(e)}}},oe=()=>t.shouldFocusError&&aO(r,I,s.mount),se=e=>{mD(e)&&(f.state.next({disabled:e}),aO(r,(t,n)=>{let i=pD(r,n);i&&(t.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach(t=>{t.disabled=i._f.disabled||e}))},0,!1))},ce=(e,i)=>async o=>{let c;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let l=uD(a);if(f.state.next({isSubmitting:!0}),t.resolver){let{errors:e,values:t}=await T();n.errors=e,l=t}else await D(r);if(s.disabled.size)for(let e of s.disabled)_D(l,e,void 0);if(HD(n.errors,`root`),FD(n.errors)){f.state.next({errors:{}});try{await e(l,o)}catch(e){c=e}}else i&&await i({...n.errors},o),oe(),setTimeout(oe);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:FD(n.errors)&&!c,submitCount:n.submitCount+1,errors:n.errors}),c)throw c},le=(e,t={})=>{pD(r,e)&&(fD(t.defaultValue)?P(e,uD(pD(i,e))):(P(e,t.defaultValue),_D(i,e,uD(t.defaultValue))),t.keepTouched||HD(n.touchedFields,e),t.keepDirty||(HD(n.dirtyFields,e),n.isDirty=t.defaultValue?k(e,uD(pD(i,e))):k()),t.keepError||(HD(n.errors,e),u.isValid&&_()),f.state.next({...n}))},ue=(e,c={})=>{let l=e?uD(e):i,d=uD(l),p=FD(e),m=p?i:d;if(c.keepDefaultValues||(i=l),!c.keepValues){if(c.keepDirtyValues){let e=new Set([...s.mount,...Object.keys(KD(i,a))]);for(let t of Array.from(e))pD(n.dirtyFields,t)?_D(m,t,pD(a,t)):P(t,pD(m,t))}else{if(lD&&fD(e))for(let e of s.mount){let t=pD(r,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(RD(e)){let t=e.closest(`form`);if(t){t.reset();break}}}}for(let e of s.mount)P(e,pD(m,e))}a=uD(m),f.array.next({values:{...m}}),f.state.next({values:{...m}})}s={mount:c.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:``},o.mount=!u.isValid||!!c.keepIsValid||!!c.keepDirtyValues,o.watch=!!t.shouldUnregister,f.state.next({submitCount:c.keepSubmitCount?n.submitCount:0,isDirty:p?!1:c.keepDirty?n.isDirty:!!(c.keepDefaultValues&&!ED(e,i)),isSubmitted:c.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:p?{}:c.keepDirtyValues?c.keepDefaultValues&&a?KD(i,a):n.dirtyFields:c.keepDefaultValues&&e?KD(i,e):c.keepDirty?n.dirtyFields:{},touchedFields:c.keepTouched?n.touchedFields:{},errors:c.keepErrors?n.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},de=(e,t)=>ue(LD(e)?e(a):e,t),fe=(e,t={})=>{let n=pD(r,e),i=n&&n._f;if(i){let e=i.refs?i.refs[0]:i.ref;e.focus&&(e.focus(),t.shouldSelect&&LD(e.select)&&e.select())}},pe=e=>{n={...n,...e}},me={control:{register:ae,unregister:re,getFieldState:z,handleSubmit:ce,setError:ee,_subscribe:te,_runSchema:T,_getWatch:A,_getDirty:k,_setValid:_,_setFieldArray:y,_setDisabledField:ie,_setErrors:x,_getFieldArray:j,_reset:ue,_resetDefaultValues:()=>LD(t.defaultValues)&&t.defaultValues().then(e=>{de(e,t.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:O,_disableForm:se,_subjects:f,_proxyFormState:u,get _fields(){return r},get _formValues(){return a},get _state(){return o},set _state(e){o=e},get _defaultValues(){return i},get _names(){return s},set _names(e){s=e},get _formState(){return n},get _options(){return t},set _options(e){t={...t,...e}}},subscribe:ne,trigger:L,register:ae,handleSubmit:ce,watch:V,setValue:P,getValues:R,reset:de,resetField:le,clearErrors:B,unregister:re,setError:ee,setFocus:fe,getFieldState:z};return{...me,formControl:me}}var fO=()=>{let e=typeof performance>`u`?Date.now():performance.now()*1e3;return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let n=(Math.random()*16+e)%16|0;return(t==`x`?n:n&3|8).toString(16)})},pO=(e,t,n={})=>n.shouldFocus||fD(n.shouldFocus)?n.focusName||`${e}.${fD(n.focusIndex)?t:n.focusIndex}.`:``,mO=(e,t)=>[...e,...ND(t)],hO=e=>Array.isArray(e)?e.map(()=>void 0):void 0;function gO(e,t,n){return[...e.slice(0,t),...ND(n),...e.slice(t)]}var _O=(e,t,n)=>Array.isArray(e)?(fD(e[n])&&(e[n]=void 0),e.splice(n,0,e.splice(t,1)[0]),e):[],vO=(e,t)=>[...ND(t),...ND(e)];function Zje(e,t){let n=0,r=[...e];for(let e of t)r.splice(e-n,1),n++;return dD(r).length?r:[]}var yO=(e,t)=>fD(t)?[]:Zje(e,ND(t).sort((e,t)=>e-t)),bO=(e,t,n)=>{[e[t],e[n]]=[e[n],e[t]]},xO=(e,t,n)=>(e[t]=n,e);function SO(e){let t=SD(),{control:n=t.control,name:r,keyName:i=`id`,shouldUnregister:a,rules:o}=e,[s,c]=H.useState(n._getFieldArray(r)),l=H.useRef(n._getFieldArray(r).map(fO)),u=H.useRef(s),d=H.useRef(r),f=H.useRef(!1);d.current=r,u.current=s,n._names.array.add(r),o&&n.register(r,o),H.useEffect(()=>n._subjects.array.subscribe({next:({values:e,name:t})=>{if(t===d.current||!t){let t=pD(e,d.current);Array.isArray(t)&&(c(t),l.current=t.map(fO))}}}).unsubscribe,[n]);let p=H.useCallback(e=>{f.current=!0,n._setFieldArray(r,e)},[n,r]);return H.useEffect(()=>{if(n._state.action=!1,iO(r,n._names)&&n._subjects.state.next({...n._formState}),f.current&&(!nO(n._options.mode).isOnSubmit||n._formState.isSubmitted)&&!nO(n._options.reValidateMode).isOnSubmit)if(n._options.resolver)n._runSchema([r]).then(e=>{let t=pD(e.errors,r),i=pD(n._formState.errors,r);(i?!t&&i.type||t&&(i.type!==t.type||i.message!==t.message):t&&t.type)&&(t?_D(n._formState.errors,r,t):HD(n._formState.errors,r),n._subjects.state.next({errors:n._formState.errors}))});else{let e=pD(n._fields,r);e&&e._f&&!(nO(n._options.reValidateMode).isOnSubmit&&nO(n._options.mode).isOnSubmit)&&dO(e,n._names.disabled,n._formValues,n._options.criteriaMode===yD.all,n._options.shouldUseNativeValidation,!0).then(e=>!FD(e)&&n._subjects.state.next({errors:sO(n._formState.errors,e,r)}))}n._subjects.state.next({name:r,values:uD(n._formValues)}),n._names.focus&&aO(n._fields,(e,t)=>{if(n._names.focus&&t.startsWith(n._names.focus)&&e.focus)return e.focus(),1}),n._names.focus=``,n._setValid(),f.current=!1},[s,r,n]),H.useEffect(()=>(!pD(n._formValues,r)&&n._setFieldArray(r),()=>{n._options.shouldUnregister||a?n.unregister(r):((e,t)=>{let r=pD(n._fields,e);r&&r._f&&(r._f.mount=t)})(r,!1)}),[r,n,i,a]),{swap:H.useCallback((e,t)=>{let i=n._getFieldArray(r);bO(i,e,t),bO(l.current,e,t),p(i),c(i),n._setFieldArray(r,i,bO,{argA:e,argB:t},!1)},[p,r,n]),move:H.useCallback((e,t)=>{let i=n._getFieldArray(r);_O(i,e,t),_O(l.current,e,t),p(i),c(i),n._setFieldArray(r,i,_O,{argA:e,argB:t},!1)},[p,r,n]),prepend:H.useCallback((e,t)=>{let i=ND(uD(e)),a=vO(n._getFieldArray(r),i);n._names.focus=pO(r,0,t),l.current=vO(l.current,i.map(fO)),p(a),c(a),n._setFieldArray(r,a,vO,{argA:hO(e)})},[p,r,n]),append:H.useCallback((e,t)=>{let i=ND(uD(e)),a=mO(n._getFieldArray(r),i);n._names.focus=pO(r,a.length-1,t),l.current=mO(l.current,i.map(fO)),p(a),c(a),n._setFieldArray(r,a,mO,{argA:hO(e)})},[p,r,n]),remove:H.useCallback(e=>{let t=yO(n._getFieldArray(r),e);l.current=yO(l.current,e),p(t),c(t),!Array.isArray(pD(n._fields,r))&&_D(n._fields,r,void 0),n._setFieldArray(r,t,yO,{argA:e})},[p,r,n]),insert:H.useCallback((e,t,i)=>{let a=ND(uD(t)),o=gO(n._getFieldArray(r),e,a);n._names.focus=pO(r,e,i),l.current=gO(l.current,e,a.map(fO)),p(o),c(o),n._setFieldArray(r,o,gO,{argA:e,argB:hO(t)})},[p,r,n]),update:H.useCallback((e,t)=>{let i=uD(t),a=xO(n._getFieldArray(r),e,i);l.current=[...a].map((t,n)=>!t||n===e?fO():l.current[n]),p(a),c([...a]),n._setFieldArray(r,a,xO,{argA:e,argB:i},!0,!1)},[p,r,n]),replace:H.useCallback(e=>{let t=ND(uD(e));l.current=t.map(fO),p([...t]),c([...t]),n._setFieldArray(r,[...t],e=>e,{},!0,!1)},[p,r,n]),fields:H.useMemo(()=>s.map((e,t)=>({...e,[i]:l.current[t]||fO()})),[s,i])}}var Qje=typeof window<`u`?H.useLayoutEffect:H.useEffect;function CO(e={}){let t=H.useRef(void 0),n=H.useRef(void 0),[r,i]=H.useState({isDirty:!1,isValidating:!1,isLoading:LD(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:LD(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...e.formControl?e.formControl:Xje(e),formState:r},e.formControl&&e.defaultValues&&!LD(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions));let a=t.current.control;return a._options=e,Qje(()=>{let e=a._subscribe({formState:a._proxyFormState,callback:()=>i({...a._formState}),reRenderRoot:!0});return i(e=>({...e,isReady:!0})),a._formState.isReady=!0,e},[a]),H.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),H.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode),e.errors&&!FD(e.errors)&&a._setErrors(e.errors)},[a,e.errors,e.mode,e.reValidateMode]),H.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),H.useEffect(()=>{if(a._proxyFormState.isDirty){let e=a._getDirty();e!==r.isDirty&&a._subjects.state.next({isDirty:e})}},[a,r.isDirty]),H.useEffect(()=>{e.values&&!ED(e.values,n.current)?(a._reset(e.values,a._options.resetOptions),n.current=e.values,i(e=>({...e}))):a._resetDefaultValues()},[a,e.values]),H.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=wD(r,a),t.current}var wO=(e,t,n)=>{if(e&&`reportValidity`in e){let r=pD(n,t);e.setCustomValidity(r&&r.message||``),e.reportValidity()}},TO=(e,t)=>{for(let n in t.fields){let r=t.fields[n];r&&r.ref&&`reportValidity`in r.ref?wO(r.ref,n,e):r.refs&&r.refs.forEach(t=>wO(t,n,e))}},$je=(e,t)=>{t.shouldUseNativeValidation&&TO(e,t);let n={};for(let r in e){let i=pD(t.fields,r),a=Object.assign(e[r]||{},{ref:i&&i.ref});if(eMe(t.names||Object.keys(e),r)){let e=Object.assign({},pD(n,r));_D(e,`root`,a),_D(n,r,e)}else _D(n,r,a)}return n},eMe=(e,t)=>e.some(e=>e.startsWith(t+`.`)),tMe=function(e,t){for(var n={};e.length;){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(`unionErrors`in r){var s=r.unionErrors[0].errors[0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(`unionErrors`in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=MD(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()}return n},EO=function(e,t,n){return n===void 0&&(n={}),function(r,i,a){try{return Promise.resolve(function(i,o){try{var s=Promise.resolve(e[n.mode===`sync`?`parse`:`parseAsync`](r,t)).then(function(e){return a.shouldUseNativeValidation&&TO({},a),{errors:{},values:n.raw?r:e}})}catch(e){return o(e)}return s&&s.then?s.then(void 0,o):s}(0,function(e){if(function(e){return Array.isArray(e?.errors)}(e))return{values:{},errors:$je(tMe(e.errors,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}}},nMe=e=>{if(e instanceof He&&e.body){let t=e.body.extensions;if(t&&Array.isArray(t.validationErrors)&&t.validationErrors.length>0)return t.validationErrors}return[]},DO=({error:e,className:t,onRetry:n,...r})=>{if(!e)return null;let i=nMe(e);return(0,U.jsx)(Sb,{variant:`destructive`,className:W(`mb-2`,t),...r,children:(0,U.jsxs)(wb,{children:[Qb(e),i.length>0&&(0,U.jsx)(`ul`,{className:`mt-1 list-disc pl-4`,children:i.map(e=>(0,U.jsx)(`li`,{children:e.message},e.code??e.message))}),n&&(0,U.jsx)(X,{variant:`ghost`,className:`absolute right-0 top-0`,onClick:n,children:(0,U.jsx)(yf,{size:16})})]})})},rMe=Ou(`inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-zuplo-200 dark:border-zuplo-900/60 bg-zuplo-50 dark:bg-zuplo-950/40 text-zuplo-700 dark:text-zuplo-300`,invert:`border-transparent bg-pink-100 dark:bg-pink-950/40 text-pink-500 dark:text-pink-300`,secondary:`border-transparent bg-gray-200 dark:bg-neutral-700 text-secondary-foreground`,info:`border-transparent bg-blue-200 dark:bg-blue-950/50 text-blue-500 dark:text-blue-400`,warn:`border-amber-200 dark:border-amber-900/60 bg-amber-100 dark:bg-amber-950/40 text-amber-800 dark:text-amber-300`,destructive:`border-transparent bg-destructive text-destructive-foreground`,"destructive-solid":`border-transparent bg-destructive text-white`,ghost:`border-transparent text-destructive-foreground`,outline:`text-foreground`},button:{false:``,true:`cursor-pointer hover:bg-gray-200`},size:{default:`text-xs`,sm:`text-[10px] py-0.5 px-1.5`,lg:`text-sm py-1 px-3.5`}},compoundVariants:[{button:!0,variant:`default`,className:`hover:bg-primary/80`},{button:!0,variant:`secondary`,className:`bg-muted hover:bg-muted/80`},{button:!0,variant:`destructive`,className:`hover:bg-destructive/80`}],defaultVariants:{variant:`default`,button:!1}});function OO({className:e,variant:t,button:n,size:r,...i}){return(0,U.jsx)(`div`,{className:W(rMe({variant:t,button:n,size:r}),e),...i})}var iMe=Ou(`rounded-xl border bg-card text-card-foreground shadow-xs`,{variants:{variant:{default:``,muted:`border-gray-300 dark:border-neutral-700 bg-gray-100 dark:bg-neutral-800`,primary:`border-pink-200 dark:border-pink-900/50 bg-zuplo-pink-light dark:bg-zuplo-950/30`,info:`bg-blue-50 dark:bg-blue-950/40 border-blue-200 dark:border-blue-900/60`,danger:`bg-red-50 dark:bg-red-950/40 border-red-200 dark:border-red-900/60`},offset:{default:``,md:[`px-4`,`py-4`]}},defaultVariants:{variant:`default`,offset:`default`}}),aMe=Ou(`flex items-center px-6 py-2 border-t rounded-b-xl`,{variants:{variant:{default:``,danger:`bg-red-100 dark:bg-red-950/40 border-red-200 dark:border-red-900/60`,muted:`bg-surface-muted border-neutral-200 dark:border-neutral-700`}},defaultVariants:{variant:`default`}}),kO=H.forwardRef(({className:e,variant:t,offset:n,...r},i)=>(0,U.jsx)(`div`,{ref:i,className:W(iMe({variant:t,offset:n,className:e})),...r}));kO.displayName=`Card`;var AO=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(`div`,{ref:n,className:W(`flex flex-col space-y-1.5 p-6 pb-0 text-lg`,e),...t}));AO.displayName=`CardHeader`;var jO=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(`h3`,{ref:n,className:W(`text-xl text-gray-900 dark:text-white font-semibold leading-none`,e),...t}));jO.displayName=`CardTitle`;var MO=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(`p`,{ref:n,className:W(`text-sm py-2`,e),...t}));MO.displayName=`CardDescription`;var NO=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(`div`,{ref:n,className:W(`p-6 pt-0`,e),...t}));NO.displayName=`CardContent`;var PO=H.forwardRef(({className:e,variant:t,...n},r)=>(0,U.jsx)(`div`,{ref:r,className:W(aMe({variant:t,className:e})),...n}));PO.displayName=`CardFooter`;function FO({className:e,...t}){return(0,U.jsx)(`div`,{className:W(`animate-pulse rounded-md bg-primary/10`,e),...t})}var IO=`**********************************************`,oMe=({secret:e=IO,reveal:t=!1,loading:n,mask:r=IO,className:i})=>(0,U.jsxs)(`div`,{className:W(`ph-no-capture font-mono shrink bg-surface-muted rounded-sm border border-border px-2 truncate relative overflow-hidden`,i),children:[t?e:r,(0,U.jsx)(FO,{className:W(`hidden absolute inset-0 h-full bg-background/80`,n&&`block`)})]});function LO(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function sMe(e,t=[]){let n=[];function r(t,r){let i=H.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=H.useMemo(()=>o,Object.values(o));return(0,U.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=H.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>H.createContext(e));return function(n){let r=n?.[e]||t;return H.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,cMe(i,...t)]}function cMe(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return H.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function RO(e,t=[]){let n=[];function r(t,r){let i=H.createContext(r),a=n.length;n=[...n,r];function o(t){let{scope:n,children:r,...o}=t,s=n?.[e][a]||i,c=H.useMemo(()=>o,Object.values(o));return(0,U.jsx)(s.Provider,{value:c,children:r})}function s(n,o){let s=o?.[e][a]||i,c=H.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return o.displayName=t+`Provider`,[o,s]}let i=()=>{let t=n.map(e=>H.createContext(e));return function(n){let r=n?.[e]||t;return H.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,lMe(i,...t)]}function lMe(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return H.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function uMe(e,t){typeof e==`function`?e(t):e!=null&&(e.current=t)}function zO(...e){return t=>e.forEach(e=>uMe(e,t))}function BO(...e){return H.useCallback(zO(...e),e)}var VO=H.forwardRef((e,t)=>{let{children:n,...r}=e,i=H.Children.toArray(n),a=i.find(fMe);if(a){let e=a.props.children,n=i.map(t=>t===a?H.Children.count(e)>1?H.Children.only(null):H.isValidElement(e)?e.props.children:null:t);return(0,U.jsx)(HO,{...r,ref:t,children:H.isValidElement(e)?H.cloneElement(e,void 0,n):null})}return(0,U.jsx)(HO,{...r,ref:t,children:n})});VO.displayName=`Slot`;var HO=H.forwardRef((e,t)=>{let{children:n,...r}=e;if(H.isValidElement(n)){let e=mMe(n);return H.cloneElement(n,{...pMe(r,n.props),ref:t?zO(t,e):e})}return H.Children.count(n)>1?H.Children.only(null):null});HO.displayName=`SlotClone`;var dMe=({children:e})=>(0,U.jsx)(U.Fragment,{children:e});function fMe(e){return H.isValidElement(e)&&e.type===dMe}function pMe(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{a(...e),i(...e)}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function mMe(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function hMe(e){let t=e+`CollectionProvider`,[n,r]=RO(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=H.useRef(null),a=H.useRef(new Map).current;return(0,U.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=H.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,U.jsx)(VO,{ref:BO(t,a(s,n).collectionRef),children:r})});c.displayName=s;let l=e+`CollectionItemSlot`,u=`data-radix-collection-item`,d=H.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=H.useRef(null),s=BO(t,o),c=a(l,n);return H.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,U.jsx)(VO,{[u]:``,ref:s,children:r})});d.displayName=l;function f(t){let n=a(e+`CollectionConsumer`,t);return H.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${u}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:c,ItemSlot:d},f,r]}var UO=globalThis?.document?H.useLayoutEffect:()=>{},gMe=H.useId||(()=>void 0),_Me=0;function WO(e){let[t,n]=H.useState(gMe());return UO(()=>{e||n(e=>e??String(_Me++))},[e]),e||(t?`radix-${t}`:``)}var GO=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=H.forwardRef((e,n)=>{let{asChild:r,...i}=e,a=r?VO:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,U.jsx)(a,{...i,ref:n})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function KO(e){let t=H.useRef(e);return H.useEffect(()=>{t.current=e}),H.useMemo(()=>(...e)=>t.current?.(...e),[])}function qO({prop:e,defaultProp:t,onChange:n=()=>{}}){let[r,i]=vMe({defaultProp:t,onChange:n}),a=e!==void 0,o=a?e:r,s=KO(n);return[o,H.useCallback(t=>{if(a){let n=typeof t==`function`?t(e):t;n!==e&&s(n)}else i(t)},[a,e,i,s])]}function vMe({defaultProp:e,onChange:t}){let n=H.useState(e),[r]=n,i=H.useRef(r),a=KO(t);return H.useEffect(()=>{i.current!==r&&(a(r),i.current=r)},[r,i,a]),n}var yMe=H.createContext(void 0);function JO(e){let t=H.useContext(yMe);return e||t||`ltr`}var YO=`rovingFocusGroup.onEntryFocus`,bMe={bubbles:!1,cancelable:!0},XO=`RovingFocusGroup`,[ZO,QO,xMe]=hMe(XO),[SMe,$O]=RO(XO,[xMe]),[CMe,wMe]=SMe(XO),ek=H.forwardRef((e,t)=>(0,U.jsx)(ZO.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,U.jsx)(ZO.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,U.jsx)(TMe,{...e,ref:t})})}));ek.displayName=XO;var TMe=H.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=H.useRef(null),p=BO(t,f),m=JO(a),[h=null,g]=qO({prop:o,defaultProp:s,onChange:c}),[_,v]=H.useState(!1),y=KO(l),b=QO(n),x=H.useRef(!1),[S,C]=H.useState(0);return H.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(YO,y),()=>e.removeEventListener(YO,y)},[y]),(0,U.jsx)(CMe,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:H.useCallback(e=>g(e),[g]),onItemShiftTab:H.useCallback(()=>v(!0),[]),onFocusableItemAdd:H.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:H.useCallback(()=>C(e=>e-1),[]),children:(0,U.jsx)(GO.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:LO(e.onMouseDown,()=>{x.current=!0}),onFocus:LO(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(YO,bMe);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);rk([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:LO(e.onBlur,()=>v(!1))})})}),tk=`RovingFocusGroupItem`,nk=H.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,...o}=e,s=WO(),c=a||s,l=wMe(tk,n),u=l.currentTabStopId===c,d=QO(n),{onFocusableItemAdd:f,onFocusableItemRemove:p}=l;return H.useEffect(()=>{if(r)return f(),()=>p()},[r,f,p]),(0,U.jsx)(ZO.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:(0,U.jsx)(GO.span,{tabIndex:u?0:-1,"data-orientation":l.orientation,...o,ref:t,onMouseDown:LO(e.onMouseDown,e=>{r?l.onItemFocus(c):e.preventDefault()}),onFocus:LO(e.onFocus,()=>l.onItemFocus(c)),onKeyDown:LO(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){l.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=OMe(e,l.orientation,l.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=d().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=l.loop?kMe(n,r+1):n.slice(r+1)}setTimeout(()=>rk(n))}})})})});nk.displayName=tk;var EMe={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function DMe(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function OMe(e,t,n){let r=DMe(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return EMe[r]}function rk(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function kMe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var AMe=ek,jMe=nk;function MMe(e,t){return H.useReducer((e,n)=>t[e][n]??e,e)}var ik=e=>{let{present:t,children:n}=e,r=NMe(t),i=typeof n==`function`?n({present:r.isPresent}):H.Children.only(n),a=BO(r.ref,PMe(i));return typeof n==`function`||r.isPresent?H.cloneElement(i,{ref:a}):null};ik.displayName=`Presence`;function NMe(e){let[t,n]=H.useState(),r=H.useRef({}),i=H.useRef(e),a=H.useRef(`none`),[o,s]=MMe(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return H.useEffect(()=>{let e=ak(r.current);a.current=o===`mounted`?e:`none`},[o]),UO(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=ak(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),UO(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=ak(r.current).includes(a.animationName);if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=ak(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:H.useCallback(e=>{e&&(r.current=getComputedStyle(e)),n(e)},[])}}function ak(e){return e?.animationName||`none`}function PMe(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ok=`Tabs`,[FMe,IMe]=sMe(ok,[$O]),sk=$O(),[LMe,ck]=FMe(ok),lk=H.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=JO(s),[d,f]=qO({prop:r,onChange:i,defaultProp:a});return(0,U.jsx)(LMe,{scope:n,baseId:WO(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,U.jsx)(GO.div,{dir:u,"data-orientation":o,...l,ref:t})})});lk.displayName=ok;var uk=`TabsList`,dk=H.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=ck(uk,n),o=sk(n);return(0,U.jsx)(AMe,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,U.jsx)(GO.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});dk.displayName=uk;var fk=`TabsTrigger`,pk=H.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=ck(fk,n),s=sk(n),c=gk(o.baseId,r),l=_k(o.baseId,r),u=r===o.value;return(0,U.jsx)(jMe,{asChild:!0,...s,focusable:!i,active:u,children:(0,U.jsx)(GO.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:LO(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:LO(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:LO(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});pk.displayName=fk;var mk=`TabsContent`,hk=H.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=ck(mk,n),c=gk(s.baseId,r),l=_k(s.baseId,r),u=r===s.value,d=H.useRef(u);return H.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,U.jsx)(ik,{present:i||u,children:({present:n})=>(0,U.jsx)(GO.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});hk.displayName=mk;function gk(e,t){return`${e}-trigger-${t}`}function _k(e,t){return`${e}-content-${t}`}var vk=lk,yk=dk,bk=pk,xk=hk,Sk=vk,RMe=Ou(`inline-flex items-center justify-center rounded-md bg-muted text-muted-foreground`,{variants:{variant:{default:``,underline:`w-full justify-start gap-6 rounded-none border-b border-border bg-transparent`},size:{sm:`h-8 px-1 py-1`,default:`h-10 p-1`}},compoundVariants:[{variant:`underline`,className:`h-auto p-0`}],defaultVariants:{variant:`default`,size:`default`}}),zMe=Ou(`inline-flex items-center justify-center whitespace-nowrap rounded-xs font-medium ring-offset-background transition-all focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-xs text-sm`,{variants:{variant:{default:``,underline:`gap-1.5 border-b-2 border-transparent text-muted-foreground hover:text-foreground data-[state=active]:border-brand data-[state=active]:bg-transparent data-[state=active]:text-brand data-[state=active]:shadow-none`},size:{sm:`px-2 py-0.5 rounded-sm`,default:`px-3 py-1.5`}},compoundVariants:[{variant:`underline`,className:`rounded-none px-1 py-2`}],defaultVariants:{variant:`default`,size:`default`}}),Ck=H.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,U.jsx)(yk,{ref:i,className:W(RMe({variant:t,size:n}),e),...r}));Ck.displayName=yk.displayName;var wk=H.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,U.jsx)(bk,{ref:i,className:W(zMe({variant:t,size:n}),e),...r}));wk.displayName=bk.displayName;var Tk=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(xk,{ref:n,className:W(`data-[state=inactive]:hidden`,`mt-2 ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));Tk.displayName=xk.displayName;var BMe=a(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()})),Ek=(0,H.createContext)({});function VMe(e){let t=(0,H.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Dk=(0,H.createContext)(null),Ok=(0,H.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function HMe(e=!0){let t=(0,H.useContext)(Dk);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,H.useId)();(0,H.useEffect)(()=>{e&&i(a)},[e]);let o=(0,H.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var kk=typeof window<`u`,UMe=kk?H.useLayoutEffect:H.useEffect,Ak=e=>e,jk=Ak,Mk=Ak,Nk={skipAnimations:!1,useManualTiming:!1};function WMe(e){let t=new Set,n=new Set,r=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(c.schedule(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.has(e)||s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0,[t,n]=[n,t],t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var Pk=[`read`,`resolveKeyframes`,`update`,`preRender`,`render`,`postRender`],GMe=40;function Fk(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Pk.reduce((e,t)=>(e[t]=WMe(a),e),{}),{read:s,resolveKeyframes:c,update:l,preRender:u,render:d,postRender:f}=o,p=()=>{let a=Nk.useManualTiming?i.timestamp:performance.now();n=!1,i.delta=r?1e3/60:Math.max(Math.min(a-i.timestamp,GMe),1),i.timestamp=a,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(p))},m=()=>{n=!0,r=!0,i.isProcessing||e(p)};return{schedule:Pk.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||m(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<Pk.length;t++)o[Pk[t]].cancel(e)},state:i,steps:o}}var{schedule:Ik,cancel:Lk,state:Rk,steps:zk}=Fk(typeof requestAnimationFrame<`u`?requestAnimationFrame:Ak,!0),Bk=(0,H.createContext)({strict:!1}),Vk={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},Hk={};for(let e in Vk)Hk[e]={isEnabled:t=>Vk[e].some(e=>!!t[e])};function KMe(e){for(let t in e)Hk[t]={...Hk[t],...e[t]}}var qMe=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.ignoreStrict.viewport`.split(`.`));function Uk(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||qMe.has(e)}var Wk=e=>!Uk(e);function JMe(e){e&&(Wk=t=>t.startsWith(`on`)?!Uk(t):e(t))}try{JMe((an(),e(h)).default)}catch{}function YMe(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||(Wk(i)||n===!0&&Uk(i)||!t&&!Uk(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}function XMe(e){if(typeof Proxy>`u`)return e;let t=new Map;return new Proxy((...t)=>e(...t),{get:(n,r)=>r===`create`?e:(t.has(r)||t.set(r,e(r)),t.get(r))})}var Gk=(0,H.createContext)({});function Kk(e){return typeof e==`string`||Array.isArray(e)}function qk(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}var Jk=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Yk=[`initial`,...Jk];function Xk(e){return qk(e.animate)||Yk.some(t=>Kk(e[t]))}function Zk(e){return!!(Xk(e)||e.variants)}function ZMe(e,t){if(Xk(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Kk(t)?t:void 0,animate:Kk(n)?n:void 0}}return e.inherit===!1?{}:t}function QMe(e){let{initial:t,animate:n}=ZMe(e,(0,H.useContext)(Gk));return(0,H.useMemo)(()=>({initial:t,animate:n}),[Qk(t),Qk(n)])}function Qk(e){return Array.isArray(e)?e.join(` `):e}var $Me=Symbol.for(`motionComponentSymbol`);function $k(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function eNe(e,t,n){return(0,H.useCallback)(r=>{r&&e.onMount&&e.onMount(r),t&&(r?t.mount(r):t.unmount()),n&&(typeof n==`function`?n(r):$k(n)&&(n.current=r))},[t])}var eA=e=>e.replace(/([a-z])([A-Z])/gu,`$1-$2`).toLowerCase(),tA=`data-`+eA(`framerAppearId`),{schedule:nA,cancel:tNe}=Fk(queueMicrotask,!1),rA=(0,H.createContext)({});function nNe(e,t,n,r,i){let{visualElement:a}=(0,H.useContext)(Gk),o=(0,H.useContext)(Bk),s=(0,H.useContext)(Dk),c=(0,H.useContext)(Ok).reducedMotion,l=(0,H.useRef)(null);r||=o.renderer,!l.current&&r&&(l.current=r(e,{visualState:t,parent:a,props:n,presenceContext:s,blockInitialAnimation:s?s.initial===!1:!1,reducedMotionConfig:c}));let u=l.current,d=(0,H.useContext)(rA);u&&!u.projection&&i&&(u.type===`html`||u.type===`svg`)&&rNe(l.current,n,i,d);let f=(0,H.useRef)(!1);(0,H.useInsertionEffect)(()=>{u&&f.current&&u.update(n,s)});let p=n[tA],m=(0,H.useRef)(!!p&&!window.MotionHandoffIsComplete?.call(window,p)&&window.MotionHasOptimisedAnimation?.call(window,p));return UMe(()=>{u&&(f.current=!0,window.MotionIsMounted=!0,u.updateFeatures(),nA.render(u.render),m.current&&u.animationState&&u.animationState.animateChanges())}),(0,H.useEffect)(()=>{u&&(!m.current&&u.animationState&&u.animationState.animateChanges(),m.current&&=(queueMicrotask(()=>{var e;(e=window.MotionHandoffMarkAsComplete)==null||e.call(window,p)}),!1))}),u}function rNe(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:iA(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&$k(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,layoutScroll:c,layoutRoot:l})}function iA(e){if(e)return e.options.allowProjection===!1?iA(e.parent):e.projection}function iNe({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:r,Component:i}){e&&KMe(e);function a(a,o){let s,c={...(0,H.useContext)(Ok),...a,layoutId:aNe(a)},{isStatic:l}=c,u=QMe(a),d=r(a,l);if(!l&&kk){oNe(c,e);let n=sNe(c);s=n.MeasureLayout,u.visualElement=nNe(i,d,c,t,n.ProjectionNode)}return(0,U.jsxs)(Gk.Provider,{value:u,children:[s&&u.visualElement?(0,U.jsx)(s,{visualElement:u.visualElement,...c}):null,n(i,a,eNe(d,u.visualElement,o),d,l,u.visualElement)]})}a.displayName=`motion.${typeof i==`string`?i:`create(${i.displayName??i.name??``})`}`;let o=(0,H.forwardRef)(a);return o[$Me]=i,o}function aNe({layoutId:e}){let t=(0,H.useContext)(Ek).id;return t&&e!==void 0?t+`-`+e:e}function oNe(e,t){(0,H.useContext)(Bk).strict}function sNe(e){let{drag:t,layout:n}=Hk;if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}var cNe=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function aA(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(cNe.indexOf(e)>-1||/[A-Z]/u.test(e))}function oA(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function sA(e,t,n,r){if(typeof t==`function`){let[i,a]=oA(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=oA(r);t=t(n===void 0?e.custom:n,i,a)}return t}var cA=e=>Array.isArray(e),lNe=e=>!!(e&&typeof e==`object`&&e.mix&&e.toValue),uNe=e=>cA(e)?e[e.length-1]||0:e,lA=e=>!!(e&&e.getVelocity);function uA(e){let t=lA(e)?e.get():e;return lNe(t)?t.toValue():t}function dNe({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},r,i,a){let o={latestValues:fNe(r,i,a,e),renderState:t()};return n&&(o.onMount=e=>n({props:r,current:e,...o}),o.onUpdate=e=>n(e)),o}var dA=e=>(t,n)=>{let r=(0,H.useContext)(Gk),i=(0,H.useContext)(Dk),a=()=>dNe(e,t,r,i);return n?a():VMe(a)};function fNe(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=uA(a[e]);let{initial:o,animate:s}=e,c=Xk(e),l=Zk(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!qk(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=sA(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var fA=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],pA=new Set(fA),mA=e=>t=>typeof t==`string`&&t.startsWith(e),hA=mA(`--`),pNe=mA(`var(--`),gA=e=>pNe(e)?mNe.test(e.split(`/*`)[0].trim()):!1,mNe=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,_A=(e,t)=>t&&typeof e==`number`?t.transform(e):e,vA=(e,t,n)=>n>t?t:n<e?e:n,yA={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},bA={...yA,transform:e=>vA(0,1,e)},xA={...yA,default:1},SA=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),CA=SA(`deg`),wA=SA(`%`),TA=SA(`px`),hNe=SA(`vh`),gNe=SA(`vw`),EA={...wA,parse:e=>wA.parse(e)/100,transform:e=>wA.transform(e*100)},_Ne={borderWidth:TA,borderTopWidth:TA,borderRightWidth:TA,borderBottomWidth:TA,borderLeftWidth:TA,borderRadius:TA,radius:TA,borderTopLeftRadius:TA,borderTopRightRadius:TA,borderBottomRightRadius:TA,borderBottomLeftRadius:TA,width:TA,maxWidth:TA,height:TA,maxHeight:TA,top:TA,right:TA,bottom:TA,left:TA,padding:TA,paddingTop:TA,paddingRight:TA,paddingBottom:TA,paddingLeft:TA,margin:TA,marginTop:TA,marginRight:TA,marginBottom:TA,marginLeft:TA,backgroundPositionX:TA,backgroundPositionY:TA},vNe={rotate:CA,rotateX:CA,rotateY:CA,rotateZ:CA,scale:xA,scaleX:xA,scaleY:xA,scaleZ:xA,skew:CA,skewX:CA,skewY:CA,distance:TA,translateX:TA,translateY:TA,translateZ:TA,x:TA,y:TA,z:TA,perspective:TA,transformPerspective:TA,opacity:bA,originX:EA,originY:EA,originZ:TA},DA={...yA,transform:Math.round},OA={..._Ne,...vNe,zIndex:DA,size:TA,fillOpacity:bA,strokeOpacity:bA,numOctaves:DA},yNe={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},bNe=fA.length;function xNe(e,t,n){let r=``,i=!0;for(let a=0;a<bNe;a++){let o=fA[a],s=e[o];if(s===void 0)continue;let c=!0;if(c=typeof s==`number`?s===(o.startsWith(`scale`)?1:0):parseFloat(s)===0,!c||n){let e=_A(s,OA[o]);if(!c){i=!1;let t=yNe[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function kA(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(pA.has(e)){o=!0;continue}else if(hA(e)){i[e]=n;continue}else{let t=_A(n,OA[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=xNe(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}var SNe={offset:`stroke-dashoffset`,array:`stroke-dasharray`},CNe={offset:`strokeDashoffset`,array:`strokeDasharray`};function wNe(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?SNe:CNe;e[a.offset]=TA.transform(-r);let o=TA.transform(t),s=TA.transform(n);e[a.array]=`${o} ${s}`}function AA(e,t,n){return typeof e==`string`?e:TA.transform(t+n*e)}function TNe(e,t,n){return`${AA(t,e.x,e.width)} ${AA(n,e.y,e.height)}`}function jA(e,{attrX:t,attrY:n,attrScale:r,originX:i,originY:a,pathLength:o,pathSpacing:s=1,pathOffset:c=0,...l},u,d){if(kA(e,l,d),u){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:f,style:p,dimensions:m}=e;f.transform&&(m&&(p.transform=f.transform),delete f.transform),m&&(i!==void 0||a!==void 0||p.transform)&&(p.transformOrigin=TNe(m,i===void 0?.5:i,a===void 0?.5:a)),t!==void 0&&(f.x=t),n!==void 0&&(f.y=n),r!==void 0&&(f.scale=r),o!==void 0&&wNe(f,o,s,c,!1)}var MA=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),NA=()=>({...MA(),attrs:{}}),PA=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function FA(e,{style:t,vars:n},r,i){Object.assign(e.style,t,i&&i.getProjectionStyles(r));for(let t in n)e.style.setProperty(t,n[t])}var IA=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]);function LA(e,t,n,r){FA(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(IA.has(n)?n:eA(n),t.attrs[n])}var RA={};function ENe(e){Object.assign(RA,e)}function zA(e,{layout:t,layoutId:n}){return pA.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!RA[e]||e===`opacity`)}function BA(e,t,n){let{style:r}=e,i={};for(let a in r)(lA(r[a])||t.style&&lA(t.style[a])||zA(a,e)||n?.getValue(a)?.liveStyle!==void 0)&&(i[a]=r[a]);return i}function VA(e,t,n){let r=BA(e,t,n);for(let n in e)if(lA(e[n])||lA(t[n])){let t=fA.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}function DNe(e,t){try{t.dimensions=typeof e.getBBox==`function`?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}var HA=[`x`,`y`,`width`,`height`,`cx`,`cy`,`r`],ONe={useVisualState:dA({scrapeMotionValuesFromProps:VA,createRenderState:NA,onUpdate:({props:e,prevProps:t,current:n,renderState:r,latestValues:i})=>{if(!n)return;let a=!!e.drag;if(!a){for(let e in i)if(pA.has(e)){a=!0;break}}if(!a)return;let o=!t;if(t)for(let n=0;n<HA.length;n++){let r=HA[n];e[r]!==t[r]&&(o=!0)}o&&Ik.read(()=>{DNe(n,r),Ik.render(()=>{jA(r,i,PA(n.tagName),e.transformTemplate),LA(n,r)})})}})},kNe={useVisualState:dA({scrapeMotionValuesFromProps:BA,createRenderState:MA})};function UA(e,t,n){for(let r in t)!lA(t[r])&&!zA(r,n)&&(e[r]=t[r])}function ANe({transformTemplate:e},t){return(0,H.useMemo)(()=>{let n=MA();return kA(n,t,e),Object.assign({},n.vars,n.style)},[t])}function jNe(e,t){let n=e.style||{},r={};return UA(r,n,e),Object.assign(r,ANe(e,t)),r}function MNe(e,t){let n={},r=jNe(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}function NNe(e,t,n,r){let i=(0,H.useMemo)(()=>{let n=NA();return jA(n,t,PA(r),e.transformTemplate),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};UA(t,e.style,e),i.style={...t,...i.style}}return i}function PNe(e=!1){return(t,n,r,{latestValues:i},a)=>{let o=(aA(t)?NNe:MNe)(n,i,a,t),s=YMe(n,typeof t==`string`,e),c=t===H.Fragment?{}:{...s,...o,ref:r},{children:l}=n,u=(0,H.useMemo)(()=>lA(l)?l.get():l,[l]);return(0,H.createElement)(t,{...c,children:u})}}function FNe(e,t){return function(n,{forwardMotionProps:r}={forwardMotionProps:!1}){return iNe({...aA(n)?ONe:kNe,preloadedFeatures:e,useRender:PNe(r),createVisualElement:t,Component:n})}}function WA(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function GA(e,t,n){let r=e.getProps();return sA(r,t,n===void 0?r.custom:n,e)}function KA(e,t){return e?e[t]||e.default||e:void 0}var qA=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...fA]),JA;function INe(){JA=void 0}var YA={now:()=>(JA===void 0&&YA.set(Rk.isProcessing||Nk.useManualTiming?Rk.timestamp:performance.now()),JA),set:e=>{JA=e,queueMicrotask(INe)}};function XA(e,t){e.indexOf(t)===-1&&e.push(t)}function ZA(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var QA=class{constructor(){this.subscriptions=[]}add(e){return XA(this.subscriptions,e),()=>ZA(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}};function $A(e,t){return t?1e3/t*e:0}var ej=30,LNe=e=>!isNaN(parseFloat(e)),tj={current:void 0},RNe=class{constructor(e,t={}){this.version=`11.18.2`,this.canTrackVelocity=null,this.events={},this.updateAndNotify=(e,t=!0)=>{let n=YA.now();this.updatedAt!==n&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),t&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=YA.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=LNe(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new QA);let n=this.events[e].add(t);return e===`change`?()=>{n(),Ik.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e,t=!0){!t||!this.passiveEffect?this.updateAndNotify(e,t):this.passiveEffect(e,this.updateAndNotify)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return tj.current&&tj.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=YA.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>ej)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,ej);return $A(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function nj(e,t){return new RNe(e,t)}function zNe(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,nj(n))}function BNe(e,t){let{transitionEnd:n={},transition:r={},...i}=GA(e,t)||{};i={...i,...n};for(let t in i)zNe(e,t,uNe(i[t]))}function VNe(e){return!!(lA(e)&&e.add)}function rj(e,t){let n=e.getValue(`willChange`);if(VNe(n))return n.add(t)}function ij(e){return e.props[tA]}function aj(e){let t;return()=>(t===void 0&&(t=e()),t)}var HNe=aj(()=>window.ScrollTimeline!==void 0),UNe=class{constructor(e){this.stop=()=>this.runAll(`stop`),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>`finished`in e?e.finished:e))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;n<this.animations.length;n++)this.animations[n][e]=t}attachTimeline(e,t){let n=this.animations.map(n=>{if(HNe()&&n.attachTimeline)return n.attachTimeline(e);if(typeof t==`function`)return t(n)});return()=>{n.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll(`time`)}set time(e){this.setAll(`time`,e)}get speed(){return this.getAll(`speed`)}set speed(e){this.setAll(`speed`,e)}get startTime(){return this.getAll(`startTime`)}get duration(){let e=0;for(let t=0;t<this.animations.length;t++)e=Math.max(e,this.animations[t].duration);return e}runAll(e){this.animations.forEach(t=>t[e]())}flatten(){this.runAll(`flatten`)}play(){this.runAll(`play`)}pause(){this.runAll(`pause`)}cancel(){this.runAll(`cancel`)}complete(){this.runAll(`complete`)}},WNe=class extends UNe{then(e,t){return Promise.all(this.animations).then(e).catch(t)}},oj=e=>e*1e3,sj=e=>e/1e3,cj={current:!1};function lj(e){return typeof e==`function`}function uj(e,t){e.timeline=t,e.onfinish=null}var dj=e=>Array.isArray(e)&&typeof e[0]==`number`,GNe={linearEasing:void 0};function KNe(e,t){let n=aj(e);return()=>GNe[t]??n()}var fj=KNe(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),pj=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},mj=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=e(pj(0,i-1,t))+`, `;return`linear(${r.substring(0,r.length-2)})`};function hj(e){return!!(typeof e==`function`&&fj()||!e||typeof e==`string`&&(e in _j||fj())||dj(e)||Array.isArray(e)&&e.every(hj))}var gj=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,_j={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:gj([0,.65,.55,1]),circOut:gj([.55,0,1,.45]),backIn:gj([.31,.01,.66,-.59]),backOut:gj([.33,1.53,.69,.99])};function vj(e,t){if(e)return typeof e==`function`&&fj()?mj(e,t):dj(e)?gj(e):Array.isArray(e)?e.map(e=>vj(e,t)||_j.easeOut):_j[e]}var yj=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,qNe=1e-7,JNe=12;function YNe(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=yj(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>qNe&&++s<JNe);return o}function bj(e,t,n,r){if(e===t&&n===r)return Ak;let i=t=>YNe(t,0,1,e,n);return e=>e===0||e===1?e:yj(i(e),t,r)}var xj=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Sj=e=>t=>1-e(1-t),Cj=bj(.33,1.53,.69,.99),wj=Sj(Cj),Tj=xj(wj),Ej=e=>(e*=2)<1?.5*wj(e):.5*(2-2**(-10*(e-1))),Dj=e=>1-Math.sin(Math.acos(e)),Oj=Sj(Dj),kj=xj(Dj),Aj=e=>/^0[^.\s]+$/u.test(e);function XNe(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Aj(e)}var jj=e=>Math.round(e*1e5)/1e5,Mj=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function ZNe(e){return e==null}var QNe=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Nj=(e,t)=>n=>!!(typeof n==`string`&&QNe.test(n)&&n.startsWith(e)||t&&!ZNe(n)&&Object.prototype.hasOwnProperty.call(n,t)),Pj=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Mj);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},$Ne=e=>vA(0,255,e),Fj={...yA,transform:e=>Math.round($Ne(e))},Ij={test:Nj(`rgb`,`red`),parse:Pj(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Fj.transform(e)+`, `+Fj.transform(t)+`, `+Fj.transform(n)+`, `+jj(bA.transform(r))+`)`};function ePe(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var Lj={test:Nj(`#`),parse:ePe,transform:Ij.transform},Rj={test:Nj(`hsl`,`hue`),parse:Pj(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+wA.transform(jj(t))+`, `+wA.transform(jj(n))+`, `+jj(bA.transform(r))+`)`},zj={test:e=>Ij.test(e)||Lj.test(e)||Rj.test(e),parse:e=>Ij.test(e)?Ij.parse(e):Rj.test(e)?Rj.parse(e):Lj.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Ij.transform(e):Rj.transform(e)},tPe=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function nPe(e){return isNaN(e)&&typeof e==`string`&&(e.match(Mj)?.length||0)+(e.match(tPe)?.length||0)>0}var Bj=`number`,Vj=`color`,rPe=`var`,iPe=`var(`,Hj="${}",aPe=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Uj(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(aPe,e=>(zj.test(e)?(r.color.push(a),i.push(Vj),n.push(zj.parse(e))):e.startsWith(iPe)?(r.var.push(a),i.push(rPe),n.push(e)):(r.number.push(a),i.push(Bj),n.push(parseFloat(e))),++a,Hj)).split(Hj),indexes:r,types:i}}function Wj(e){return Uj(e).values}function Gj(e){let{split:t,types:n}=Uj(e),r=t.length;return e=>{let i=``;for(let a=0;a<r;a++)if(i+=t[a],e[a]!==void 0){let t=n[a];t===Bj?i+=jj(e[a]):t===Vj?i+=zj.transform(e[a]):i+=e[a]}return i}}var oPe=e=>typeof e==`number`?0:e;function sPe(e){let t=Wj(e);return Gj(e)(t.map(oPe))}var Kj={test:nPe,parse:Wj,createTransformer:Gj,getAnimatableNone:sPe},cPe=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function lPe(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Mj)||[];if(!r)return e;let i=n.replace(r,``),a=cPe.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var uPe=/\b([a-z-]*)\(.*?\)/gu,qj={...Kj,getAnimatableNone:e=>{let t=e.match(uPe);return t?t.map(lPe).join(` `):e}},dPe={...OA,color:zj,backgroundColor:zj,outlineColor:zj,fill:zj,stroke:zj,borderColor:zj,borderTopColor:zj,borderRightColor:zj,borderBottomColor:zj,borderLeftColor:zj,filter:qj,WebkitFilter:qj},Jj=e=>dPe[e];function Yj(e,t){let n=Jj(e);return n!==qj&&(n=Kj),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var fPe=new Set([`auto`,`none`,`0`]);function pPe(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!fPe.has(t)&&Uj(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=Yj(n,i)}var Xj=e=>e===yA||e===TA,Zj=(e,t)=>parseFloat(e.split(`, `)[t]),Qj=(e,t)=>(n,{transform:r})=>{if(r===`none`||!r)return 0;let i=r.match(/^matrix3d\((.+)\)$/u);if(i)return Zj(i[1],t);{let t=r.match(/^matrix\((.+)\)$/u);return t?Zj(t[1],e):0}},mPe=new Set([`x`,`y`,`z`]),hPe=fA.filter(e=>!mPe.has(e));function gPe(e){let t=[];return hPe.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var $j={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:Qj(4,13),y:Qj(5,14)};$j.translateX=$j.x,$j.translateY=$j.y;var eM=new Set,tM=!1,nM=!1;function rM(){if(nM){let e=Array.from(eM).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=gPe(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{var r;(r=e.getValue(t))==null||r.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}nM=!1,tM=!1,eM.forEach(e=>e.complete()),eM.clear()}function iM(){eM.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(nM=!0)})}function _Pe(){iM(),rM()}var aM=class{constructor(e,t,n,r,i,a=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.isScheduled=!0,this.isAsync?(eM.add(this),tM||(tM=!0,Ik.read(iM),Ik.resolveKeyframes(rM))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;for(let i=0;i<e.length;i++)if(e[i]===null)if(i===0){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}else e[i]=e[i-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),eM.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,eM.delete(this))}resume(){this.isComplete||this.scheduleResolve()}},oM=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),vPe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function yPe(e){let t=vPe.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}var bPe=4;function sM(e,t,n=1){Mk(n<=bPe,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`);let[r,i]=yPe(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return oM(e)?parseFloat(e):e}return gA(i)?sM(i,t,n+1):i}var cM=e=>t=>t.test(e),lM=[yA,TA,wA,CA,gNe,hNe,{test:e=>e===`auto`,parse:e=>e}],uM=e=>lM.find(cM(e)),dM=class extends aM{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),gA(r))){let i=sM(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!qA.has(n)||e.length!==2)return;let[r,i]=e,a=uM(r),o=uM(i);if(a!==o)if(Xj(a)&&Xj(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else this.needsMeasurement=!0}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)XNe(e[t])&&n.push(t);n.length&&pPe(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=$j[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=$j[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},fM=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Kj.test(e)||e===`0`)&&!e.startsWith(`url(`));function xPe(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function SPe(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=fM(i,t),s=fM(a,t);return jk(o===s,`You are trying to animate ${t} from "${i}" to "${a}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${a} via the \`style\` property.`),!o||!s?!1:xPe(e)||(n===`spring`||lj(n))&&r}var CPe=e=>e!==null;function pM(e,{repeat:t,repeatType:n=`loop`},r){let i=e.filter(CPe),a=t&&n!==`loop`&&t%2==1?0:i.length-1;return!a||r===void 0?i[a]:r}var wPe=40,mM=class{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,...o}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=YA.now(),this.options={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,...o},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt&&this.resolvedAt-this.createdAt>wPe?this.resolvedAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&_Pe(),this._resolved}onKeyframesResolved(e,t){this.resolvedAt=YA.now(),this.hasAttemptedResolve=!0;let{name:n,type:r,velocity:i,delay:a,onComplete:o,onUpdate:s,isGenerator:c}=this.options;if(!c&&!SPe(e,n,r,i))if(cj.current||!a){s&&s(pM(e,this.options,t)),o&&o(),this.resolveFinishedPromise();return}else this.options.duration=0;let l=this.initPlayback(e,t);l!==!1&&(this._resolved={keyframes:e,finalKeyframe:t,...l},this.onPostResolved())}onPostResolved(){}then(e,t){return this.currentFinishedPromise.then(e,t)}flatten(){this.options.type=`keyframes`,this.options.ease=`linear`}updateFinishedPromise(){this.currentFinishedPromise=new Promise(e=>{this.resolveFinishedPromise=e})}},TPe=2e4;function hM(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}var gM=(e,t,n)=>e+(t-e)*n;function _M(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function EPe({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=_M(s,r,e+1/3),a=_M(s,r,e),o=_M(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function vM(e,t){return n=>n>0?t:e}var yM=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},DPe=[Lj,Ij,Rj],OPe=e=>DPe.find(t=>t.test(e));function bM(e){let t=OPe(e);if(jk(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`),!t)return!1;let n=t.parse(e);return t===Rj&&(n=EPe(n)),n}var xM=(e,t)=>{let n=bM(e),r=bM(t);if(!n||!r)return vM(e,t);let i={...n};return e=>(i.red=yM(n.red,r.red,e),i.green=yM(n.green,r.green,e),i.blue=yM(n.blue,r.blue,e),i.alpha=gM(n.alpha,r.alpha,e),Ij.transform(i))},kPe=(e,t)=>n=>t(e(n)),SM=(...e)=>e.reduce(kPe),CM=new Set([`none`,`hidden`]);function APe(e,t){return CM.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function jPe(e,t){return n=>gM(e,t,n)}function wM(e){return typeof e==`number`?jPe:typeof e==`string`?gA(e)?vM:zj.test(e)?xM:PPe:Array.isArray(e)?TM:typeof e==`object`?zj.test(e)?xM:MPe:vM}function TM(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>wM(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function MPe(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=wM(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function NPe(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var PPe=(e,t)=>{let n=Kj.createTransformer(t),r=Uj(e),i=Uj(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?CM.has(e)&&!i.values.length||CM.has(t)&&!r.values.length?APe(e,t):SM(TM(NPe(r,i),i.values),n):(jk(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),vM(e,t))};function EM(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?gM(e,t,n):wM(e)(e,t)}var FPe=5;function DM(e,t,n){let r=Math.max(t-FPe,0);return $A(n-e(r),t-r)}var OM={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},kM=.001;function IPe({duration:e=OM.duration,bounce:t=OM.bounce,velocity:n=OM.velocity,mass:r=OM.mass}){let i,a;jk(e<=oj(OM.maxDuration),`Spring duration must be 10 seconds or less`);let o=1-t;o=vA(OM.minDamping,OM.maxDamping,o),e=vA(OM.minDuration,OM.maxDuration,sj(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=AM(t,o),c=Math.exp(-i);return kM-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=AM(t**2,o);return(-i(t)+kM>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-kM+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=RPe(i,a,s);if(e=oj(e),isNaN(c))return{stiffness:OM.stiffness,damping:OM.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var LPe=12;function RPe(e,t,n){let r=n;for(let n=1;n<LPe;n++)r-=e(r)/t(r);return r}function AM(e,t){return e*Math.sqrt(1-t*t)}var zPe=[`duration`,`bounce`],BPe=[`stiffness`,`damping`,`mass`];function jM(e,t){return t.some(t=>e[t]!==void 0)}function VPe(e){let t={velocity:OM.velocity,stiffness:OM.stiffness,damping:OM.damping,mass:OM.mass,isResolvedFromDuration:!1,...e};if(!jM(e,BPe)&&jM(e,zPe))if(e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*vA(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:OM.mass,stiffness:i,damping:a}}else{let n=IPe(e);t={...t,...n,mass:OM.mass},t.isResolvedFromDuration=!0}return t}function MM(e=OM.visualDuration,t=OM.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=VPe({...n,velocity:-sj(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=sj(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?OM.restSpeed.granular:OM.restSpeed.default,i||=v?OM.restDelta.granular:OM.restDelta.default;let y;if(h<1){let e=AM(_,h);y=t=>o-Math.exp(-h*_*t)*((m+h*_*g)/e*Math.sin(e*t)+g*Math.cos(e*t))}else if(h===1)y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e}}let b={calculatedDuration:p&&d||null,next:e=>{let t=y(e);if(p)s.done=e>=d;else{let n=0;h<1&&(n=e===0?oj(m):DM(y,e,t));let a=Math.abs(n)<=r,c=Math.abs(o-t)<=i;s.done=a&&c}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(hM(b),TPe),t=mj(t=>b.next(e*t).value,e,30);return e+`ms `+t}};return b}function NM({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=MM({keyframes:[f.value,m(f.value)],velocity:DM(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}var HPe=bj(.42,0,1,1),UPe=bj(0,0,.58,1),PM=bj(.42,0,.58,1),WPe=e=>Array.isArray(e)&&typeof e[0]!=`number`,FM={linear:Ak,easeIn:HPe,easeInOut:PM,easeOut:UPe,circIn:Dj,circInOut:kj,circOut:Oj,backIn:wj,backInOut:Tj,backOut:Cj,anticipate:Ej},IM=e=>{if(dj(e)){Mk(e.length===4,`Cubic bezier arrays must contain four numerical values.`);let[t,n,r,i]=e;return bj(t,n,r,i)}else if(typeof e==`string`)return Mk(FM[e]!==void 0,`Invalid easing type '${e}'`),FM[e];return e};function GPe(e,t,n){let r=[],i=n||EM,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=SM(Array.isArray(t)?t[n]||Ak:t,a)),r.push(a)}return r}function KPe(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(Mk(a===t.length,`Both input and output ranges must be the same length`),a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=GPe(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=pj(e[r],e[r+1],n);return s[r](i)};return n?t=>l(vA(e[0],e[a-1],t)):l}function qPe(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=pj(0,t,r);e.push(gM(n,1,i))}}function JPe(e){let t=[0];return qPe(t,e.length-1),t}function YPe(e,t){return e.map(e=>e*t)}function XPe(e,t){return e.map(()=>t||PM).splice(0,e.length-1)}function LM({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=WPe(r)?r.map(IM):IM(r),a={done:!1,value:t[0]},o=KPe(YPe(n&&n.length===t.length?n:JPe(t),e),t,{ease:Array.isArray(i)?i:XPe(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var ZPe=e=>{let t=({timestamp:t})=>e(t);return{start:()=>Ik.update(t,!0),stop:()=>Lk(t),now:()=>Rk.isProcessing?Rk.timestamp:YA.now()}},QPe={decay:NM,inertia:NM,tween:LM,keyframes:LM,spring:MM},$Pe=e=>e/100,RM=class extends mM{constructor(e){super(e),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState=`running`,this.startTime=null,this.state=`idle`,this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state===`idle`)return;this.teardown();let{onStop:e}=this.options;e&&e()};let{name:t,motionValue:n,element:r,keyframes:i}=this.options;this.resolver=new(r?.KeyframeResolver||aM)(i,(e,t)=>this.onKeyframesResolved(e,t),t,n,r),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(e){let{type:t=`keyframes`,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=this.options,o=lj(t)?t:QPe[t]||LM,s,c;o!==LM&&typeof e[0]!=`number`&&(s=SM($Pe,EM(e[0],e[1])),e=[0,100]);let l=o({...this.options,keyframes:e});i===`mirror`&&(c=o({...this.options,keyframes:[...e].reverse(),velocity:-a})),l.calculatedDuration===null&&(l.calculatedDuration=hM(l));let{calculatedDuration:u}=l,d=u+r,f=d*(n+1)-r;return{generator:l,mirroredGenerator:c,mapPercentToKeyframes:s,calculatedDuration:u,resolvedDuration:d,totalDuration:f}}onPostResolved(){let{autoplay:e=!0}=this.options;this.play(),this.pendingPlayState===`paused`||!e?this.pause():this.state=this.pendingPlayState}tick(e,t=!1){let{resolved:n}=this;if(!n){let{keyframes:e}=this.options;return{done:!0,value:e[e.length-1]}}let{finalKeyframe:r,generator:i,mirroredGenerator:a,mapPercentToKeyframes:o,keyframes:s,calculatedDuration:c,totalDuration:l,resolvedDuration:u}=n;if(this.startTime===null)return i.next(0);let{delay:d,repeat:f,repeatType:p,repeatDelay:m,onUpdate:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-l/this.speed,this.startTime)),t?this.currentTime=e:this.holdTime===null?this.currentTime=Math.round(e-this.startTime)*this.speed:this.currentTime=this.holdTime;let g=this.currentTime-d*(this.speed>=0?1:-1),_=this.speed>=0?g<0:g>l;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=l);let v=this.currentTime,y=i;if(f){let e=Math.min(this.currentTime,l)/u,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,f+1),t%2&&(p===`reverse`?(n=1-n,m&&(n-=m/u)):p===`mirror`&&(y=a)),v=vA(0,1,n)*u}let b=_?{done:!1,value:s[0]}:y.next(v);o&&(b.value=o(b.value));let{done:x}=b;!_&&c!==null&&(x=this.speed>=0?this.currentTime>=l:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&r!==void 0&&(b.value=pM(s,this.options,r)),h&&h(b.value),S&&this.finish(),b}get duration(){let{resolved:e}=this;return e?sj(e.calculatedDuration):0}get time(){return sj(this.currentTime)}set time(e){e=oj(e),this.currentTime=e,this.holdTime!==null||this.speed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.speed)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=sj(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState=`running`;return}if(this.isStopped)return;let{driver:e=ZPe,onPlay:t,startTime:n}=this.options;this.driver||=e(e=>this.tick(e)),t&&t();let r=this.driver.now();this.holdTime===null?this.startTime?this.state===`finished`&&(this.startTime=r):this.startTime=n??this.calcStartTime():this.startTime=r-this.holdTime,this.state===`finished`&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state=`running`,this.driver.start()}pause(){if(!this._resolved){this.pendingPlayState=`paused`;return}this.state=`paused`,this.holdTime=this.currentTime??0}complete(){this.state!==`running`&&this.play(),this.pendingPlayState=this.state=`finished`,this.holdTime=null}finish(){this.teardown(),this.state=`finished`;let{onComplete:e}=this.options;e&&e()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state=`idle`,this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}},eFe=new Set([`opacity`,`clipPath`,`filter`,`transform`]);function tFe(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeInOut`,times:c}={}){let l={[t]:n};c&&(l.offset=c);let u=vj(s,i);return Array.isArray(u)&&(l.easing=u),e.animate(l,{delay:r,duration:i,easing:Array.isArray(u)?`linear`:u,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`})}var nFe=aj(()=>Object.hasOwnProperty.call(Element.prototype,`animate`)),zM=10,rFe=2e4;function iFe(e){return lj(e.type)||e.type===`spring`||!hj(e.ease)}function aFe(e,t){let n=new RM({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0}),r={done:!1,value:e[0]},i=[],a=0;for(;!r.done&&a<rFe;)r=n.sample(a),i.push(r.value),a+=zM;return{times:void 0,keyframes:i,duration:a-zM,ease:`linear`}}var BM={anticipate:Ej,backInOut:Tj,circInOut:kj};function oFe(e){return e in BM}var VM=class extends mM{constructor(e){super(e);let{name:t,motionValue:n,element:r,keyframes:i}=this.options;this.resolver=new dM(i,(e,t)=>this.onKeyframesResolved(e,t),t,n,r),this.resolver.scheduleResolve()}initPlayback(e,t){let{duration:n=300,times:r,ease:i,type:a,motionValue:o,name:s,startTime:c}=this.options;if(!o.owner||!o.owner.current)return!1;if(typeof i==`string`&&fj()&&oFe(i)&&(i=BM[i]),iFe(this.options)){let{onComplete:t,onUpdate:o,motionValue:s,element:c,...l}=this.options,u=aFe(e,l);e=u.keyframes,e.length===1&&(e[1]=e[0]),n=u.duration,r=u.times,i=u.ease,a=`keyframes`}let l=tFe(o.owner.current,s,e,{...this.options,duration:n,times:r,ease:i});return l.startTime=c??this.calcStartTime(),this.pendingTimeline?(uj(l,this.pendingTimeline),this.pendingTimeline=void 0):l.onfinish=()=>{let{onComplete:n}=this.options;o.set(pM(e,this.options,t)),n&&n(),this.cancel(),this.resolveFinishedPromise()},{animation:l,duration:n,times:r,type:a,ease:i,keyframes:e}}get duration(){let{resolved:e}=this;if(!e)return 0;let{duration:t}=e;return sj(t)}get time(){let{resolved:e}=this;if(!e)return 0;let{animation:t}=e;return sj(t.currentTime||0)}set time(e){let{resolved:t}=this;if(!t)return;let{animation:n}=t;n.currentTime=oj(e)}get speed(){let{resolved:e}=this;if(!e)return 1;let{animation:t}=e;return t.playbackRate}set speed(e){let{resolved:t}=this;if(!t)return;let{animation:n}=t;n.playbackRate=e}get state(){let{resolved:e}=this;if(!e)return`idle`;let{animation:t}=e;return t.playState}get startTime(){let{resolved:e}=this;if(!e)return null;let{animation:t}=e;return t.startTime}attachTimeline(e){if(!this._resolved)this.pendingTimeline=e;else{let{resolved:t}=this;if(!t)return Ak;let{animation:n}=t;uj(n,e)}return Ak}play(){if(this.isStopped)return;let{resolved:e}=this;if(!e)return;let{animation:t}=e;t.playState===`finished`&&this.updateFinishedPromise(),t.play()}pause(){let{resolved:e}=this;if(!e)return;let{animation:t}=e;t.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state===`idle`)return;this.resolveFinishedPromise(),this.updateFinishedPromise();let{resolved:e}=this;if(!e)return;let{animation:t,keyframes:n,duration:r,type:i,ease:a,times:o}=e;if(t.playState===`idle`||t.playState===`finished`)return;if(this.time){let{motionValue:e,onUpdate:t,onComplete:s,element:c,...l}=this.options,u=new RM({...l,keyframes:n,duration:r,type:i,ease:a,times:o,isGenerator:!0}),d=oj(this.time);e.setWithVelocity(u.sample(d-zM).value,u.sample(d).value,zM)}let{onStop:s}=this.options;s&&s(),this.cancel()}complete(){let{resolved:e}=this;e&&e.animation.finish()}cancel(){let{resolved:e}=this;e&&e.animation.cancel()}static supports(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o}=e;if(!t||!t.owner||!(t.owner.current instanceof HTMLElement))return!1;let{onUpdate:s,transformTemplate:c}=t.owner.getProps();return nFe()&&n&&eFe.has(n)&&!s&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}},sFe={type:`spring`,stiffness:500,damping:25,restSpeed:10},cFe=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),lFe={type:`keyframes`,duration:.8},uFe={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},dFe=(e,{keyframes:t})=>t.length>2?lFe:pA.has(e)?e.startsWith(`scale`)?cFe(t[1]):sFe:uFe;function fFe({when:e,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:i,repeat:a,repeatType:o,repeatDelay:s,from:c,elapsed:l,...u}){return!!Object.keys(u).length}var HM=(e,t,n,r={},i,a)=>o=>{let s=KA(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=oj(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};fFe(s)||(u={...u,...dFe(e,u)}),u.duration&&=oj(u.duration),u.repeatDelay&&=oj(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(u.duration=0,u.delay===0&&(d=!0)),(cj.current||Nk.skipAnimations)&&(d=!0,u.duration=0,u.delay=0),d&&!a&&t.get()!==void 0){let e=pM(u.keyframes,s);if(e!==void 0)return Ik.update(()=>{u.onUpdate(e),u.onComplete()}),new WNe([])}return!a&&VM.supports(u)?new VM(u):new RM(u)};function pFe({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function UM(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a=e.getDefaultTransition(),transitionEnd:o,...s}=t;r&&(a=r);let c=[],l=i&&e.animationState&&e.animationState.getState()[i];for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||l&&pFe(l,t))continue;let o={delay:n,...KA(a||{},t)},u=!1;if(window.MotionHandoffAnimation){let n=ij(e);if(n){let e=window.MotionHandoffAnimation(n,t,Ik);e!==null&&(o.startTime=e,u=!0)}}rj(e,t),r.start(HM(t,r,i,e.shouldReduceMotion&&qA.has(t)?{type:!1}:o,e,u));let d=r.animation;d&&c.push(d)}return o&&Promise.all(c).then(()=>{Ik.update(()=>{o&&BNe(e,o)})}),c}function WM(e,t,n={}){let r=GA(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(UM(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return mFe(e,t,a+r,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function mFe(e,t,n=0,r=0,i=1,a){let o=[],s=(e.variantChildren.size-1)*r,c=i===1?(e=0)=>e*r:(e=0)=>s-e*r;return Array.from(e.variantChildren).sort(hFe).forEach((e,r)=>{e.notify(`AnimationStart`,t),o.push(WM(e,t,{...a,delay:n+c(r)}).then(()=>e.notify(`AnimationComplete`,t)))}),Promise.all(o)}function hFe(e,t){return e.sortNodePosition(t)}function gFe(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>WM(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=WM(e,t,n);else{let i=typeof t==`function`?GA(e,t,n.custom):t;r=Promise.all(UM(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var _Fe=Yk.length;function GM(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&GM(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<_Fe;n++){let r=Yk[n],i=e.props[r];(Kk(i)||i===!1)&&(t[r]=i)}return t}var vFe=[...Jk].reverse(),yFe=Jk.length;function bFe(e){return t=>Promise.all(t.map(({animation:t,options:n})=>gFe(e,t,n)))}function xFe(e){let t=bFe(e),n=qM(),r=!0,i=t=>(n,r)=>{let i=GA(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function a(n){t=n(e)}function o(a){let{props:o}=e,s=GM(e.parent)||{},c=[],l=new Set,u={},d=1/0;for(let t=0;t<yFe;t++){let f=vFe[t],p=n[f],m=o[f]===void 0?s[f]:o[f],h=Kk(m),g=f===a?p.isActive:null;g===!1&&(d=t);let _=m===s[f]&&m!==o[f]&&h;if(_&&r&&e.manuallyAnimateOnMount&&(_=!1),p.protectedKeys={...u},!p.isActive&&g===null||!m&&!p.prevProp||qk(m)||typeof m==`boolean`)continue;let v=SFe(p.prevProp,m),y=v||f===a&&p.isActive&&!_&&h||t>d&&h,b=!1,x=Array.isArray(m)?m:[m],S=x.reduce(i(f),{});g===!1&&(S={});let{prevResolvedValues:C={}}=p,w={...C,...S},T=t=>{y=!0,l.has(t)&&(b=!0,l.delete(t)),p.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in w){let t=S[e],n=C[e];if(u.hasOwnProperty(e))continue;let r=!1;r=cA(t)&&cA(n)?!WA(t,n):t!==n,r?t==null?l.add(e):T(e):t!==void 0&&l.has(e)?T(e):p.protectedKeys[e]=!0}p.prevProp=m,p.prevResolvedValues=S,p.isActive&&(u={...u,...S}),r&&e.blockInitialAnimation&&(y=!1),y&&(!(_&&v)||b)&&c.push(...x.map(e=>({animation:e,options:{type:f}})))}if(l.size){let t={};l.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),c.push({animation:t})}let f=!!c.length;return r&&(o.initial===!1||o.initial===o.animate)&&!e.manuallyAnimateOnMount&&(f=!1),r=!1,f?t(c):Promise.resolve()}function s(t,r){var i;if(n[t].isActive===r)return Promise.resolve();(i=e.variantChildren)==null||i.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let a=o(t);for(let e in n)n[e].protectedKeys={};return a}return{animateChanges:o,setActive:s,setAnimateFunction:a,getState:()=>n,reset:()=>{n=qM(),r=!0}}}function SFe(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!WA(t,e):!1}function KM(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function qM(){return{animate:KM(!0),whileInView:KM(),whileHover:KM(),whileTap:KM(),whileDrag:KM(),whileFocus:KM(),exit:KM()}}var JM=class{constructor(e){this.isMounted=!1,this.node=e}update(){}},CFe=class extends JM{constructor(e){super(e),e.animationState||=xFe(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();qk(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}},wFe=0,TFe={animation:{Feature:CFe},exit:{Feature:class extends JM{constructor(){super(...arguments),this.id=wFe++}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>t(this.id))}mount(){let{register:e}=this.node.presenceContext||{};e&&(this.unmount=e(this.id))}unmount(){}}}},YM={x:!1,y:!1};function XM(){return YM.x||YM.y}function EFe(e){return e===`x`||e===`y`?YM[e]?null:(YM[e]=!0,()=>{YM[e]=!1}):YM.x||YM.y?null:(YM.x=YM.y=!0,()=>{YM.x=YM.y=!1})}var ZM=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1;function QM(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}function $M(e){return{point:{x:e.pageX,y:e.pageY}}}var DFe=e=>t=>ZM(t)&&e(t,$M(t));function eN(e,t,n,r){return QM(e,t,DFe(n),r)}var tN=(e,t)=>Math.abs(e-t);function OFe(e,t){let n=tN(e.x,t.x),r=tN(e.y,t.y);return Math.sqrt(n**2+r**2)}var nN=class{constructor(e,t,{transformPagePoint:n,contextWindow:r,dragSnapToOrigin:i=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let e=aN(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=OFe(e.offset,{x:0,y:0})>=3;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Rk;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastMoveEventInfo=rN(t,this.transformPagePoint),Ik.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if(this.dragSnapToOrigin&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=aN(e.type===`pointercancel`?this.lastMoveEventInfo:rN(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!ZM(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.contextWindow=r||window;let a=rN($M(e),this.transformPagePoint),{point:o}=a,{timestamp:s}=Rk;this.history=[{...o,timestamp:s}];let{onSessionStart:c}=t;c&&c(e,aN(a,this.history)),this.removeListeners=SM(eN(this.contextWindow,`pointermove`,this.handlePointerMove),eN(this.contextWindow,`pointerup`,this.handlePointerUp),eN(this.contextWindow,`pointercancel`,this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Lk(this.updatePoint)}};function rN(e,t){return t?{point:t(e.point)}:e}function iN(e,t){return{x:e.x-t.x,y:e.y-t.y}}function aN({point:e},t){return{point:e,delta:iN(e,oN(t)),offset:iN(e,kFe(t)),velocity:AFe(t,.1)}}function kFe(e){return e[0]}function oN(e){return e[e.length-1]}function AFe(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=oN(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>oj(t)));)n--;if(!r)return{x:0,y:0};let a=sj(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}var sN=1e-4,jFe=1-sN,MFe=1+sN,cN=.01,NFe=0-cN,PFe=0+cN;function lN(e){return e.max-e.min}function FFe(e,t,n){return Math.abs(e-t)<=n}function uN(e,t,n,r=.5){e.origin=r,e.originPoint=gM(t.min,t.max,e.origin),e.scale=lN(n)/lN(t),e.translate=gM(n.min,n.max,e.origin)-e.originPoint,(e.scale>=jFe&&e.scale<=MFe||isNaN(e.scale))&&(e.scale=1),(e.translate>=NFe&&e.translate<=PFe||isNaN(e.translate))&&(e.translate=0)}function dN(e,t,n,r){uN(e.x,t.x,n.x,r?r.originX:void 0),uN(e.y,t.y,n.y,r?r.originY:void 0)}function fN(e,t,n){e.min=n.min+t.min,e.max=e.min+lN(t)}function IFe(e,t,n){fN(e.x,t.x,n.x),fN(e.y,t.y,n.y)}function pN(e,t,n){e.min=t.min-n.min,e.max=e.min+lN(t)}function mN(e,t,n){pN(e.x,t.x,n.x),pN(e.y,t.y,n.y)}function LFe(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?gM(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?gM(n,e,r.max):Math.min(e,n)),e}function hN(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function RFe(e,{top:t,left:n,bottom:r,right:i}){return{x:hN(e.x,n,i),y:hN(e.y,t,r)}}function gN(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function zFe(e,t){return{x:gN(e.x,t.x),y:gN(e.y,t.y)}}function BFe(e,t){let n=.5,r=lN(e),i=lN(t);return i>r?n=pj(t.min,t.max-r,e.min):r>i&&(n=pj(e.min,e.max-i,t.min)),vA(0,1,n)}function VFe(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var _N=.35;function HFe(e=_N){return e===!1?e=0:e===!0&&(e=_N),{x:vN(e,`left`,`right`),y:vN(e,`top`,`bottom`)}}function vN(e,t,n){return{min:yN(e,t),max:yN(e,n)}}function yN(e,t){return typeof e==`number`?e:e[t]||0}var bN=()=>({translate:0,scale:1,origin:0,originPoint:0}),xN=()=>({x:bN(),y:bN()}),SN=()=>({min:0,max:0}),CN=()=>({x:SN(),y:SN()});function wN(e){return[e(`x`),e(`y`)]}function TN({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function UFe({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function WFe(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function EN(e){return e===void 0||e===1}function DN({scale:e,scaleX:t,scaleY:n}){return!EN(e)||!EN(t)||!EN(n)}function ON(e){return DN(e)||kN(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function kN(e){return AN(e.x)||AN(e.y)}function AN(e){return e&&e!==`0%`}function jN(e,t,n){return n+t*(e-n)}function MN(e,t,n,r,i){return i!==void 0&&(e=jN(e,i,r)),jN(e,n,r)+t}function NN(e,t=0,n=1,r,i){e.min=MN(e.min,t,n,r,i),e.max=MN(e.max,t,n,r,i)}function PN(e,{x:t,y:n}){NN(e.x,t.translate,t.scale,t.originPoint),NN(e.y,n.translate,n.scale,n.originPoint)}var FN=.999999999999,IN=1.0000000000001;function GFe(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&zN(e,{x:-a.scroll.offset.x,y:-a.scroll.offset.y}),o&&(t.x*=o.x.scale,t.y*=o.y.scale,PN(e,o)),r&&ON(a.latestValues)&&zN(e,a.latestValues))}t.x<IN&&t.x>FN&&(t.x=1),t.y<IN&&t.y>FN&&(t.y=1)}function LN(e,t){e.min+=t,e.max+=t}function RN(e,t,n,r,i=.5){NN(e,t,n,gM(e.min,e.max,i),r)}function zN(e,t){RN(e.x,t.x,t.scaleX,t.scale,t.originX),RN(e.y,t.y,t.scaleY,t.scale,t.originY)}function BN(e,t){return TN(WFe(e.getBoundingClientRect(),t))}function KFe(e,t,n){let r=BN(e,n),{scroll:i}=t;return i&&(LN(r.x,i.offset.x),LN(r.y,i.offset.y)),r}var VN=({current:e})=>e?e.ownerDocument.defaultView:null,qFe=new WeakMap,JFe=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=CN(),this.visualElement=e}start(e,{snapToCursor:t=!1}={}){let{presenceContext:n}=this.visualElement;if(n&&n.isPresent===!1)return;let r=e=>{let{dragSnapToOrigin:n}=this.getProps();n?this.pauseAnimation():this.stopAnimation(),t&&this.snapToCursor($M(e).point)},i=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=EFe(n),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),wN(e=>{let t=this.getAxisMotionValue(e).get()||0;if(wA.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=lN(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&Ik.postRender(()=>i(e,t)),rj(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},a=(e,t)=>{let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=YFe(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&a(e,t)},o=(e,t)=>this.stop(e,t),s=()=>wN(e=>this.getAnimationState(e)===`paused`&&this.getAxisMotionValue(e).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new nN(e,{onSessionStart:r,onStart:i,onMove:a,onSessionEnd:o,resumeAnimation:s},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,contextWindow:VN(this.visualElement)})}stop(e,t){let n=this.isDragging;if(this.cancel(),!n)return;let{velocity:r}=t;this.startAnimation(r);let{onDragEnd:i}=this.getProps();i&&Ik.postRender(()=>i(e,t))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!HN(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=LFe(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&$k(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=RFe(n.layoutBox,e):this.constraints=!1,this.elastic=HFe(t),r!==this.constraints&&n&&this.constraints&&!this.hasMutatedConstraints&&wN(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=VFe(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!$k(e))return!1;let n=e.current;Mk(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");let{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=KFe(n,r.root,this.visualElement.getTransformPagePoint()),a=zFe(r.layout.layoutBox,i);if(t){let e=t(UFe(a));this.hasMutatedConstraints=!!e,e&&(a=TN(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=wN(o=>{if(!HN(o,t,this.currentDirection))return;let c=s&&s[o]||{};a&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return rj(this.visualElement,e),n.start(HM(e,n,0,t,this.visualElement,!1))}stopAnimation(){wN(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){wN(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps();return n[t]||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){wN(t=>{let{drag:n}=this.getProps();if(!HN(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t];i.set(e[t]-gM(n,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!$k(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};wN(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=BFe({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),wN(t=>{if(!HN(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(gM(i,a,r[t]))})}addListeners(){if(!this.visualElement.current)return;qFe.set(this.visualElement,this);let e=this.visualElement.current,t=eN(e,`pointerdown`,e=>{let{drag:t,dragListener:n=!0}=this.getProps();t&&n&&this.start(e)}),n=()=>{let{dragConstraints:e}=this.getProps();$k(e)&&e.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,i=r.addEventListener(`measure`,n);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),Ik.read(n);let a=QM(window,`resize`,()=>this.scalePositionWithinConstraints()),o=r.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(wN(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{a(),t(),i(),o&&o()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=_N,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function HN(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function YFe(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var XFe=class extends JM{constructor(e){super(e),this.removeGroupControls=Ak,this.removeListeners=Ak,this.controls=new JFe(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ak}unmount(){this.removeGroupControls(),this.removeListeners()}},UN=e=>(t,n)=>{e&&Ik.postRender(()=>e(t,n))},ZFe=class extends JM{constructor(){super(...arguments),this.removePointerDownListener=Ak}onPointerDown(e){this.session=new nN(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:VN(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:UN(e),onStart:UN(t),onMove:n,onEnd:(e,t)=>{delete this.session,r&&Ik.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=eN(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},WN={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function GN(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var KN={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(TA.test(e))e=parseFloat(e);else return e;return`${GN(e,t.target.x)}% ${GN(e,t.target.y)}%`}},QFe={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Kj.parse(e);if(i.length>5)return r;let a=Kj.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=gM(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},$Fe=class extends H.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;ENe(eIe),i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),WN.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,a=n.projection;return a?(a.isPresent=i,r||e.layoutDependency!==t||t===void 0?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||Ik.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),nA.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function qN(e){let[t,n]=HMe(),r=(0,H.useContext)(Ek);return(0,U.jsx)($Fe,{...e,layoutGroup:r,switchLayoutGroup:(0,H.useContext)(rA),isPresent:t,safeToRemove:n})}var eIe={borderRadius:{...KN,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:KN,borderTopRightRadius:KN,borderBottomLeftRadius:KN,borderBottomRightRadius:KN,boxShadow:QFe};function tIe(e,t,n){let r=lA(e)?e:nj(e);return r.start(HM(``,r,t,n)),r.animation}function nIe(e){return e instanceof SVGElement&&e.tagName!==`svg`}var rIe=(e,t)=>e.depth-t.depth,iIe=class{constructor(){this.children=[],this.isDirty=!1}add(e){XA(this.children,e),this.isDirty=!0}remove(e){ZA(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(rIe),this.isDirty=!1,this.children.forEach(e)}};function aIe(e,t){let n=YA.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Lk(r),e(a-t))};return Ik.read(r,!0),()=>Lk(r)}var JN=[`TopLeft`,`TopRight`,`BottomLeft`,`BottomRight`],oIe=JN.length,YN=e=>typeof e==`string`?parseFloat(e):e,XN=e=>typeof e==`number`||TA.test(e);function sIe(e,t,n,r,i,a){i?(e.opacity=gM(0,n.opacity===void 0?1:n.opacity,cIe(r)),e.opacityExit=gM(t.opacity===void 0?1:t.opacity,0,lIe(r))):a&&(e.opacity=gM(t.opacity===void 0?1:t.opacity,n.opacity===void 0?1:n.opacity,r));for(let i=0;i<oIe;i++){let a=`border${JN[i]}Radius`,o=ZN(t,a),s=ZN(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||XN(o)===XN(s)?(e[a]=Math.max(gM(YN(o),YN(s),r),0),(wA.test(s)||wA.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=gM(t.rotate||0,n.rotate||0,r))}function ZN(e,t){return e[t]===void 0?e.borderRadius:e[t]}var cIe=QN(0,.5,Oj),lIe=QN(.5,.95,Ak);function QN(e,t,n){return r=>r<e?0:r>t?1:n(pj(e,t,r))}function $N(e,t){e.min=t.min,e.max=t.max}function eP(e,t){$N(e.x,t.x),$N(e.y,t.y)}function tP(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function nP(e,t,n,r,i){return e-=t,e=jN(e,1/n,r),i!==void 0&&(e=jN(e,1/i,r)),e}function uIe(e,t=0,n=1,r=.5,i,a=e,o=e){if(wA.test(t)&&(t=parseFloat(t),t=gM(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=gM(a.min,a.max,r);e===a&&(s-=t),e.min=nP(e.min,t,n,s,i),e.max=nP(e.max,t,n,s,i)}function rP(e,t,[n,r,i],a,o){uIe(e,t[n],t[r],t[i],t.scale,a,o)}var dIe=[`x`,`scaleX`,`originX`],fIe=[`y`,`scaleY`,`originY`];function iP(e,t,n,r){rP(e.x,t,dIe,n?n.x:void 0,r?r.x:void 0),rP(e.y,t,fIe,n?n.y:void 0,r?r.y:void 0)}function aP(e){return e.translate===0&&e.scale===1}function oP(e){return aP(e.x)&&aP(e.y)}function sP(e,t){return e.min===t.min&&e.max===t.max}function pIe(e,t){return sP(e.x,t.x)&&sP(e.y,t.y)}function cP(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function lP(e,t){return cP(e.x,t.x)&&cP(e.y,t.y)}function uP(e){return lN(e.x)/lN(e.y)}function dP(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}var mIe=class{constructor(){this.members=[]}add(e){XA(this.members,e),e.scheduleRender()}remove(e){if(ZA(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){let t=this.members.findIndex(t=>e===t);if(t===0)return!1;let n;for(let e=t;e>=0;e--){let t=this.members[e];if(t.isPresent!==!1){n=t;break}}return n?(this.promote(n),!0):!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.instance&&n.scheduleRender(),e.scheduleRender(),e.resumeFrom=n,t&&(e.resumeFrom.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);let{crossfade:r}=e.options;r===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{let{options:t,resumingFrom:n}=e;t.onExitComplete&&t.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}};function hIe(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,rotateX:i,rotateY:a,skewX:o,skewY:s}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotateX(${i}deg) `),a&&(r+=`rotateY(${a}deg) `),o&&(r+=`skewX(${o}deg) `),s&&(r+=`skewY(${s}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var fP={type:`projectionFrame`,totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},pP=typeof window<`u`&&window.MotionDebug!==void 0,mP=[``,`X`,`Y`,`Z`],gIe={visibility:`hidden`},hP=1e3,_Ie=0;function gP(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function _P(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=ij(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Ik,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&_P(r)}function vP({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=_Ie++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,pP&&(fP.totalNodes=fP.resolvedTargetDeltas=fP.recalculatedProjection=0),this.nodes.forEach(bIe),this.nodes.forEach(TIe),this.nodes.forEach(EIe),this.nodes.forEach(xIe),pP&&window.MotionDebug.record(fP)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new iIe)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new QA),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t,n=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=nIe(t),this.instance=t;let{layoutId:r,layout:i,visualElement:a}=this.options;if(a&&!a.current&&a.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),n&&(i||r)&&(this.isLayoutDirty=!0),e){let n,r=()=>this.root.updateBlockedByResize=!1;e(t,()=>{this.root.updateBlockedByResize=!0,n&&n(),n=aIe(r,250),WN.hasAnimatedSinceResize&&(WN.hasAnimatedSinceResize=!1,this.nodes.forEach(bP))})}r&&this.root.registerSharedNode(r,this),this.options.animate!==!1&&a&&(r||i)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeTargetChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let i=this.options.transition||a.getDefaultTransition()||jIe,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=a.getProps(),c=!this.targetLayout||!lP(this.targetLayout,r)||n,l=!t&&n;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(e,l);let t={...KA(i,`layout`),onPlay:o,onComplete:s};(a.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t)}else t||bP(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Lk(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(DIe),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&_P(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(yP);return}this.isUpdating||this.nodes.forEach(CIe),this.isUpdating=!1,this.nodes.forEach(wIe),this.nodes.forEach(vIe),this.nodes.forEach(yIe),this.clearAllSnapshots();let e=YA.now();Rk.delta=vA(0,1e3/60,e-Rk.timestamp),Rk.timestamp=e,Rk.isProcessing=!0,zk.update.process(Rk),zk.preRender.process(Rk),zk.render.process(Rk),Rk.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,nA.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(SIe),this.sharedNodes.forEach(OIe)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ik.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ik.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutCorrected=CN(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!oP(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&(t||ON(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),MIe(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return CN();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(NIe))){let{scroll:e}=this.root;e&&(LN(t.x,e.offset.x),LN(t.y,e.offset.y))}return t}removeElementScroll(e){let t=CN();if(eP(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&eP(t,e),LN(t.x,i.offset.x),LN(t.y,i.offset.y))}return t}applyTransform(e,t=!1){let n=CN();eP(n,e);for(let e=0;e<this.path.length;e++){let r=this.path[e];!t&&r.options.layoutScroll&&r.scroll&&r!==r.root&&zN(n,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),ON(r.latestValues)&&zN(n,r.latestValues)}return ON(this.latestValues)&&zN(n,this.latestValues),n}removeTransform(e){let t=CN();eP(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!n.instance||!ON(n.latestValues))continue;DN(n.latestValues)&&n.updateSnapshot();let r=CN();eP(r,n.measurePageBox()),iP(t,n.latestValues,n.snapshot?n.snapshot.layoutBox:void 0,r)}return ON(this.latestValues)&&iP(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0?!0:e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Rk.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!(!this.layout||!(r||i))){if(this.resolvedRelativeTargetAt=Rk.timestamp,!this.targetDelta&&!this.relativeTarget){let e=this.getClosestProjectingParent();e&&e.layout&&this.animationProgress!==1?(this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget=CN(),this.relativeTargetOrigin=CN(),mN(this.relativeTargetOrigin,this.layout.layoutBox,e.layout.layoutBox),eP(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=CN(),this.targetWithTransforms=CN()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),IFe(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):eP(this.target,this.layout.layoutBox),PN(this.target,this.targetDelta)):eP(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;let e=this.getClosestProjectingParent();e&&!!e.resumingFrom==!!this.resumingFrom&&!e.options.layoutScroll&&e.target&&this.animationProgress!==1?(this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget=CN(),this.relativeTargetOrigin=CN(),mN(this.relativeTargetOrigin,this.target,e.target),eP(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}pP&&fP.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||DN(this.parent.latestValues)||kN(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Rk.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;eP(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;GFe(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=CN());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(tP(this.prevProjectionDelta.x,this.projectionDelta.x),tP(this.prevProjectionDelta.y,this.projectionDelta.y)),dN(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!dP(this.projectionDelta.x,this.prevProjectionDelta.x)||!dP(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),pP&&fP.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){var t;if((t=this.options.visualElement)==null||t.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=xN(),this.projectionDelta=xN(),this.projectionDeltaWithTransform=xN()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=xN();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=CN(),s=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),c=this.getStack(),l=!c||c.members.length<=1,u=!!(s&&!l&&this.options.crossfade===!0&&!this.path.some(AIe));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;xP(a.x,e.x,n),xP(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(mN(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox),kIe(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&pIe(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=CN(),eP(d,this.relativeTarget)),s&&(this.animationValues=i,sIe(i,r,this.latestValues,n,u,l)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&=(Lk(this.pendingAnimation),void 0),this.pendingAnimation=Ik.update(()=>{WN.hasAnimatedSinceResize=!0,this.currentAnimation=tIe(0,hP,{...e,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(hP),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&EP(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||CN();let t=lN(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=lN(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}eP(t,n),zN(t,i),dN(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new mIe),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return e?e.lead===this:!0}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&gP(`z`,e,r,this.animationValues);for(let t=0;t<mP.length;t++)gP(`rotate${mP[t]}`,e,r,this.animationValues),gP(`skew${mP[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}getProjectionStyles(e){if(!this.instance||this.isSVG)return;if(!this.isVisible)return gIe;let t={visibility:``},n=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,t.opacity=``,t.pointerEvents=uA(e?.pointerEvents)||``,t.transform=n?n(this.latestValues,``):`none`,t;let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){let t={};return this.options.layoutId&&(t.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,t.pointerEvents=uA(e?.pointerEvents)||``),this.hasProjected&&!ON(this.latestValues)&&(t.transform=n?n({},``):`none`,this.hasProjected=!1),t}let i=r.animationValues||r.latestValues;this.applyTransformsToTarget(),t.transform=hIe(this.projectionDeltaWithTransform,this.treeScale,i),n&&(t.transform=n(i,t.transform));let{x:a,y:o}=this.projectionDelta;t.transformOrigin=`${a.origin*100}% ${o.origin*100}% 0`,r.animationValues?t.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:t.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let e in RA){if(i[e]===void 0)continue;let{correct:n,applyTo:a}=RA[e],o=t.transform===`none`?i[e]:n(i[e],r);if(a){let e=a.length;for(let n=0;n<e;n++)t[a[n]]=o}else t[e]=o}return this.options.layoutId&&(t.pointerEvents=r===this?uA(e?.pointerEvents)||``:`none`),t}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(yP),this.root.sharedNodes.clear()}}}function vIe(e){e.updateLayout()}function yIe(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;i===`size`?wN(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=lN(r);r.min=n[e].min,r.max=r.min+i}):EP(i,t.layoutBox,n)&&wN(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=lN(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=xN();dN(o,n,t.layoutBox);let s=xN();a?dN(s,e.applyTransform(r,!0),t.measuredBox):dN(s,n,t.layoutBox);let c=!oP(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=CN();mN(o,t.layoutBox,i.layoutBox);let s=CN();mN(s,n,a.layoutBox),lP(o,s)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=s,e.relativeTargetOrigin=o,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeTargetChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function bIe(e){pP&&fP.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function xIe(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function SIe(e){e.clearSnapshot()}function yP(e){e.clearMeasurements()}function CIe(e){e.isLayoutDirty=!1}function wIe(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function bP(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function TIe(e){e.resolveTargetDelta()}function EIe(e){e.calcProjection()}function DIe(e){e.resetSkewAndRotation()}function OIe(e){e.removeLeadSnapshot()}function xP(e,t,n){e.translate=gM(t.translate,0,n),e.scale=gM(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function SP(e,t,n,r){e.min=gM(t.min,n.min,r),e.max=gM(t.max,n.max,r)}function kIe(e,t,n,r){SP(e.x,t.x,n.x,r),SP(e.y,t.y,n.y,r)}function AIe(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var jIe={duration:.45,ease:[.4,0,.1,1]},CP=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),wP=CP(`applewebkit/`)&&!CP(`chrome/`)?Math.round:Ak;function TP(e){e.min=wP(e.min),e.max=wP(e.max)}function MIe(e){TP(e.x),TP(e.y)}function EP(e,t,n){return e===`position`||e===`preserve-aspect`&&!FFe(uP(t),uP(n),.2)}function NIe(e){return e!==e.root&&e.scroll?.wasRoot}var PIe=vP({attachResizeListener:(e,t)=>QM(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),DP={current:void 0},OP=vP({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!DP.current){let e=new PIe({});e.mount(window),e.setOptions({layoutScroll:!0}),DP.current=e}return DP.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),FIe={pan:{Feature:ZFe},drag:{Feature:XFe,ProjectionNode:OP,MeasureLayout:qN}};function IIe(e,t,n){if(e instanceof Element)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e)}function kP(e,t){let n=IIe(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function AP(e){return t=>{t.pointerType===`touch`||XM()||e(t)}}function LIe(e,t,n={}){let[r,i,a]=kP(e,n),o=AP(e=>{let{target:n}=e,r=t(e);if(typeof r!=`function`||!n)return;let a=AP(e=>{r(e),n.removeEventListener(`pointerleave`,a)});n.addEventListener(`pointerleave`,a,i)});return r.forEach(e=>{e.addEventListener(`pointerenter`,o,i)}),a}function jP(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&Ik.postRender(()=>i(t,$M(t)))}var RIe=class extends JM{mount(){let{current:e}=this.node;e&&(this.unmount=LIe(e,e=>(jP(this.node,e,`Start`),e=>jP(this.node,e,`End`))))}unmount(){}},zIe=class extends JM{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=SM(QM(this.node.current,`focus`,()=>this.onFocus()),QM(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}},MP=(e,t)=>t?e===t?!0:MP(e,t.parentElement):!1,BIe=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function VIe(e){return BIe.has(e.tagName)||e.tabIndex!==-1}var NP=new WeakSet;function PP(e){return t=>{t.key===`Enter`&&e(t)}}function FP(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var HIe=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=PP(()=>{if(NP.has(n))return;FP(n,`down`);let e=PP(()=>{FP(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>FP(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function IP(e){return ZM(e)&&!XM()}function UIe(e,t,n={}){let[r,i,a]=kP(e,n),o=e=>{let r=e.currentTarget;if(!IP(e)||NP.has(r))return;NP.add(r);let a=t(e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),!(!IP(e)||!NP.has(r))&&(NP.delete(r),typeof a==`function`&&a(e,{success:t}))},s=e=>{o(e,n.useGlobalTarget||MP(r,e.target))},c=e=>{o(e,!1)};window.addEventListener(`pointerup`,s,i),window.addEventListener(`pointercancel`,c,i)};return r.forEach(e=>{!VIe(e)&&e.getAttribute(`tabindex`)===null&&(e.tabIndex=0),(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),e.addEventListener(`focus`,e=>HIe(e,i),i)}),a}function LP(e,t,n){let{props:r}=e;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&Ik.postRender(()=>i(t,$M(t)))}var WIe=class extends JM{mount(){let{current:e}=this.node;e&&(this.unmount=UIe(e,e=>(LP(this.node,e,`Start`),(e,{success:t})=>LP(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}},RP=new WeakMap,zP=new WeakMap,GIe=e=>{let t=RP.get(e.target);t&&t(e)},KIe=e=>{e.forEach(GIe)};function qIe({root:e,...t}){let n=e||document;zP.has(n)||zP.set(n,{});let r=zP.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(KIe,{root:e,...t})),r[i]}function JIe(e,t,n){let r=qIe(t);return RP.set(e,n),r.observe(e),()=>{RP.delete(e),r.unobserve(e)}}var YIe={some:0,all:1},XIe=class extends JM{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:YIe[r]};return JIe(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(ZIe(e,t))&&this.startObserver()}unmount(){}};function ZIe({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var QIe={inView:{Feature:XIe},tap:{Feature:WIe},focus:{Feature:zIe},hover:{Feature:RIe}},$Ie={layout:{ProjectionNode:OP,MeasureLayout:qN}},BP={current:null},VP={current:!1};function eLe(){if(VP.current=!0,kk)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>BP.current=e.matches;e.addListener(t),t()}else BP.current=!1}var tLe=[...lM,zj,Kj],nLe=e=>tLe.find(cM(e)),HP=new WeakMap;function rLe(e,t,n){for(let r in t){let i=t[r],a=n[r];if(lA(i))e.addValue(r,i);else if(lA(a))e.addValue(r,nj(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,nj(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var UP=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],iLe=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,blockInitialAnimation:i,visualState:a},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=aM,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=YA.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Ik.render(this.render,!1,!0))};let{latestValues:s,renderState:c,onUpdate:l}=a;this.onUpdate=l,this.latestValues=s,this.baseTarget={...s},this.initialValues=t.initial?{...s}:{},this.renderState=c,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.options=o,this.blockInitialAnimation=!!i,this.isControllingVariants=Xk(t),this.isVariantNode=Zk(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];s[e]!==void 0&&lA(t)&&t.set(s[e],!1)}}mount(e){this.current=e,HP.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),VP.current||eLe(),this.shouldReduceMotion=this.reducedMotionConfig===`never`?!1:this.reducedMotionConfig===`always`?!0:BP.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){HP.delete(this.current),this.projection&&this.projection.unmount(),Lk(this.notifyUpdate),Lk(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}bindToMotionValue(e,t){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();let n=pA.has(e),r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Ik.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0)}),i=t.on(`renderRequest`,this.scheduleRender),a;window.MotionCheckAppearSync&&(a=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i(),a&&a(),t.owner&&t.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Hk){let t=Hk[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):CN()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<UP.length;t++){let n=UP[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=rLe(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=nj(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(oM(n)||Aj(n))?n=parseFloat(n):!nLe(n)&&Kj.test(t)&&(n=Yj(e,t)),this.setBaseTarget(e,lA(n)?n.get():n)),lA(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=sA(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!lA(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new QA),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}},WP=class extends iLe{constructor(){super(...arguments),this.KeyframeResolver=dM}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){return e.style?e.style[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;lA(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}};function aLe(e){return window.getComputedStyle(e)}var oLe=class extends WP{constructor(){super(...arguments),this.type=`html`,this.renderInstance=FA}readValueFromInstance(e,t){if(pA.has(t)){let e=Jj(t);return e&&e.default||0}else{let n=aLe(e),r=(hA(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return BN(e,t)}build(e,t,n){kA(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return BA(e,t,n)}},sLe=class extends WP{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=CN}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(pA.has(t)){let e=Jj(t);return e&&e.default||0}return t=IA.has(t)?t:eA(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return VA(e,t,n)}build(e,t,n){jA(e,t,this.isSVGTag,n.transformTemplate)}renderInstance(e,t,n,r){LA(e,t,n,r)}mount(e){this.isSVGTag=PA(e.tagName),super.mount(e)}},cLe=(e,t)=>aA(e)?new sLe(t):new oLe(t,{allowProjection:e!==H.Fragment}),GP=XMe(FNe({...TFe,...QIe,...FIe,...$Ie},cLe)),KP=r(BMe()),qP={width:5,height:5,borderRadius:`50%`},JP=({className:e,color:t=`white`})=>{let n=t===`white`?`bg-white/60`:t===`current`?`bg-current/60`:`bg-zuplo-600/60`;return(0,U.jsxs)(GP.div,{className:`flex items-center gap-1`,initial:`hidden`,animate:`visible`,variants:{visible:{transition:{staggerChildren:.2}}},children:[(0,U.jsx)(GP.div,{className:W(n,e),variants:{hidden:{opacity:0,y:3},visible:{opacity:1,y:0,transition:{y:{type:`spring`,stiffness:300,damping:10,repeat:1/0,repeatType:`reverse`}}}},style:qP}),(0,U.jsx)(GP.div,{className:W(n,e),variants:{hidden:{opacity:0,y:3},visible:{opacity:1,y:0,transition:{y:{type:`spring`,stiffness:300,damping:10,repeat:1/0,repeatType:`reverse`}}}},style:qP}),(0,U.jsx)(GP.div,{className:W(n,e),variants:{hidden:{opacity:0,y:3},visible:{opacity:1,y:0,transition:{y:{type:`spring`,stiffness:300,damping:10,repeat:1/0,repeatType:`reverse`}}}},style:qP})]})},YP=({children:e,className:t,loading:n,alternative:r})=>(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`div`,{className:W(t,`transition-opacity`,n&&`opacity-0`),children:e}),(0,U.jsx)(`div`,{className:W(`absolute top-1/2 left-1/2 opacity-0 transform -translate-x-1/2 -translate-y-1/2`,n&&`opacity-100`),children:r??(0,U.jsx)(JP,{color:`current`})})]}),lLe=Ou([`file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-background px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,`read-only:cursor-not-allowed read-only:opacity-50`],{variants:{size:{sm:`px-2 h-7.5`,default:``},hideNumberArrows:{true:`[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}},defaultVariants:{hideNumberArrows:!1,size:`default`}}),XP=({className:e,hideNumberArrows:t,size:n,selectOnFocus:r,...i})=>(0,U.jsx)(`input`,{className:W(lLe({hideNumberArrows:t,size:n}),e),...i,onFocus:e=>{r&&e.target.select(),i.onFocus?.(e)}}),ZP=`ph-no-capture`,uLe=`session-replay-unmask`,QP=({borderPositionAndSize:e,className:t})=>(0,U.jsx)(`div`,{style:{borderTopColor:`transparent`},className:W(`border-zuplo-pink`,{"border-4":!e,[`${e}`]:e},`border-solid rounded-full animate-spin`,t)}),dLe=({success:e,className:t})=>e?(0,U.jsx)(td,{className:W(`w-5 h-5 text-green-600`,t)}):(0,U.jsx)(xd,{className:W(`w-5 h-5 rotate-90`,t),"aria-hidden":`true`}),$P=({textToCopy:e,onClick:t,title:n,className:r,iconClassName:i})=>{let a=jC(e??``);return(0,U.jsx)(`button`,{disabled:a.state===`copied`,onClick:e=>{t?.(e),a.copyToClipboard()},type:`button`,title:n??`Copy`,className:(0,KP.default)(r,`ml-1 hover:text-gray-800 text-gray-400 cursor-pointer`),children:a.state===`loading`?(0,U.jsx)(QP,{className:`h-4 w-4 border-2`}):(0,U.jsx)(dLe,{success:a.state===`copied`,className:W(`w-3.5 h-3.5`,i)})})},eF=null,tF=null;function fLe(){return tF??=gn(()=>import(`./editor.main-B7ZQNwu9.js`).then(e=>(eF=e,e)),__vite__mapDeps([0,1,2,3,4,5,6])),tF}function nF(){let[e,t]=(0,H.useState)(eF);return(0,H.useEffect)(()=>{if(eF){t(eF);return}let e=!0;return fLe().then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}var rF=null;function iF(e,t,n){let r=(0,H.useRef)(!1);(0,H.useEffect)(()=>{if(!e)return;if(!r.current){r.current=!0;return}let i=requestAnimationFrame(()=>{if(n.current&&t!==rF)try{e.editor.setTheme(t),rF=t}catch{}});return()=>cancelAnimationFrame(i)},[e,t,n])}var aF={display:`flex`,position:`relative`,textAlign:`initial`};function pLe({value:e,defaultValue:t,language:n,defaultLanguage:r,path:i,theme:a=`vs`,line:o,options:s={},overrideServices:c,onChange:l,onMount:u,beforeMount:d,className:f,width:p=`100%`,height:m=`100%`,keepCurrentModel:h=!1,wrapperProps:g}){let _=nF(),v=(0,H.useRef)(null),y=(0,H.useRef)(null),b=(0,H.useRef)(l);b.current=l;let x=(0,H.useRef)(h);x.current=h;let S=(0,H.useRef)(!1);return(0,H.useEffect)(()=>{if(!_)return;let l=v.current;if(!l)return;d?.(_);let f=i?_.Uri.parse(i):void 0,p=f&&_.editor.getModel(f)||_.editor.createModel(e??t??``,n??r,f),m=_.editor.create(l,{...s,model:p,theme:a},c);y.current=m,o!=null&&m.revealLine(o);let h=m.onDidChangeModelContent(e=>{S.current||b.current?.(m.getValue(),e)});return u?.(m,_),()=>{h.dispose();let e=m.getModel();m.dispose(),x.current||e?.dispose(),y.current=null}},[_]),(0,H.useEffect)(()=>{let t=y.current;if(!t||e===void 0)return;let n=t.getModel();!n||e===n.getValue()||(S.current=!0,t.executeEdits(``,[{range:n.getFullModelRange(),text:e,forceMoveMarkers:!0}]),t.pushUndoStop(),S.current=!1)},[e]),(0,H.useEffect)(()=>{let e=y.current?.getModel();_&&e&&n&&_.editor.setModelLanguage(e,n)},[_,n]),iF(_,a,y),(0,H.useEffect)(()=>{y.current?.updateOptions(s)},[s]),(0,H.useEffect)(()=>{o!=null&&y.current?.revealLine(o)},[o]),(0,U.jsx)(`section`,{...g,style:{...aF,width:p,height:m},children:(0,U.jsx)(`div`,{ref:v,className:f,style:{width:`100%`}})})}function mLe({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,theme:a=`vs`,options:o={},onMount:s,beforeMount:c,className:l,width:u=`100%`,height:d=`100%`,keepCurrentOriginalModel:f=!1,keepCurrentModifiedModel:p=!1,wrapperProps:m}){let h=nF(),g=(0,H.useRef)(null),_=(0,H.useRef)(null),v=(0,H.useRef)(f);v.current=f;let y=(0,H.useRef)(p);return y.current=p,(0,H.useEffect)(()=>{if(!h)return;let l=g.current;if(!l)return;c?.(h);let u=h.editor.createDiffEditor(l,{...o,theme:a});return _.current=u,u.setModel({original:h.editor.createModel(e??``,r??n),modified:h.editor.createModel(t??``,i??n)}),s?.(u,h),()=>{let e=u.getModel();u.dispose(),v.current||e?.original.dispose(),y.current||e?.modified.dispose(),_.current=null}},[h]),(0,H.useEffect)(()=>{let t=_.current?.getModel();t&&e!=null&&e!==t.original.getValue()&&t.original.setValue(e)},[e]),(0,H.useEffect)(()=>{let e=_.current?.getModel();e&&t!=null&&t!==e.modified.getValue()&&e.modified.setValue(t)},[t]),iF(h,a,_),(0,U.jsx)(`section`,{...m,style:{...aF,width:u,height:d},children:(0,U.jsx)(`div`,{ref:g,className:l,style:{width:`100%`}})})}var oF=`zuplo-light`,sF=`zuplo-dark`,cF=`#191918`,lF=e=>{e.editor.defineTheme(oF,{base:`vs`,inherit:!0,rules:[],colors:{}}),e.editor.defineTheme(sF,{base:`vs-dark`,inherit:!0,rules:[],colors:{"editor.background":cF,"editorGutter.background":cF,"minimap.background":cF,"editorStickyScroll.background":cF,"editorStickyScrollHover.background":`#262626`,"breadcrumb.background":cF,"editorWidget.background":cF}})},hLe=e=>e===`dark`?sF:oF,uF=()=>{let{colorScheme:e}=Xe();return hLe(e)},dF=({beforeMount:e,theme:t,...n})=>{let r=uF(),i=t=>{lF(t),e?.(t)};return(0,U.jsx)(pLe,{...n,beforeMount:i,theme:r})},fF=({beforeMount:e,theme:t,...n})=>{let r=uF(),i=t=>{lF(t),e?.(t)};return(0,U.jsx)(mLe,{...n,beforeMount:i,theme:r})},pF=`AlertDialog`,[gLe,_Le]=T(pF,[b]),mF=b(),hF=e=>{let{__scopeAlertDialog:t,...n}=e,r=mF(t);return(0,U.jsx)(_,{...r,...n,modal:!0})};hF.displayName=pF;var vLe=`AlertDialogTrigger`,yLe=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=mF(n);return(0,U.jsx)(Te,{...i,...r,ref:t})});yLe.displayName=vLe;var bLe=`AlertDialogPortal`,gF=e=>{let{__scopeAlertDialog:t,...n}=e,r=mF(t);return(0,U.jsx)(Se,{...r,...n})};gF.displayName=bLe;var xLe=`AlertDialogOverlay`,_F=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=mF(n);return(0,U.jsx)(un,{...i,...r,ref:t})});_F.displayName=xLe;var vF=`AlertDialogContent`,[SLe,CLe]=gLe(vF),wLe=F(`AlertDialogContent`),yF=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:r,...i}=e,a=mF(n),o=H.useRef(null),s=ve(t,o),c=H.useRef(null);return(0,U.jsx)(C,{contentName:vF,titleName:bF,docsSlug:`alert-dialog`,children:(0,U.jsx)(SLe,{scope:n,cancelRef:c,children:(0,U.jsxs)(fn,{role:`alertdialog`,...a,...i,ref:s,onOpenAutoFocus:hn(i.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,U.jsx)(wLe,{children:r}),(0,U.jsx)(ELe,{contentRef:o})]})})})});yF.displayName=vF;var bF=`AlertDialogTitle`,xF=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=mF(n);return(0,U.jsx)(sn,{...i,...r,ref:t})});xF.displayName=bF;var SF=`AlertDialogDescription`,CF=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=mF(n);return(0,U.jsx)(Qe,{...i,...r,ref:t})});CF.displayName=SF;var TLe=`AlertDialogAction`,wF=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=mF(n);return(0,U.jsx)(rn,{...i,...r,ref:t})});wF.displayName=TLe;var TF=`AlertDialogCancel`,EF=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=CLe(TF,n),a=mF(n),o=ve(t,i);return(0,U.jsx)(rn,{...a,...r,ref:o})});EF.displayName=TF;var ELe=({contentRef:e})=>{let t=`\`${vF}\` requires a description for the component to be accessible for screen reader users.
|
|
243
|
+
`]),`#666`),NE=function(e){return e/1024/1024},YAe=function(e){return e===void 0?``:e.map((function(e){return`.${e.toLowerCase()}`})).join(`,`)};function XAe(e){var t=e.types,n=e.minSize,r=e.maxSize;if(t){var i=t.toString(),a=``;return r&&(a+=`size >= ${r}, `),n&&(a+=`size <= ${n}, `),(0,U.jsx)(`span`,jE({title:`${a}types: ${i}`,className:`file-types`},{children:i}),void 0)}return null}function ZAe(){return(0,U.jsxs)(`svg`,jE({width:`32`,height:`32`,viewBox:`0 0 32 32`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},{children:[(0,U.jsx)(`path`,{d:`M5.33317 6.66667H22.6665V16H25.3332V6.66667C25.3332 5.196 24.1372 4 22.6665 4H5.33317C3.8625 4 2.6665 5.196 2.6665 6.66667V22.6667C2.6665 24.1373 3.8625 25.3333 5.33317 25.3333H15.9998V22.6667H5.33317V6.66667Z`,fill:`#0658C2`},void 0),(0,U.jsx)(`path`,{d:`M10.6665 14.6667L6.6665 20H21.3332L15.9998 12L11.9998 17.3333L10.6665 14.6667Z`,fill:`#0658C2`},void 0),(0,U.jsx)(`path`,{d:`M25.3332 18.6667H22.6665V22.6667H18.6665V25.3333H22.6665V29.3333H25.3332V25.3333H29.3332V22.6667H25.3332V18.6667Z`,fill:`#0658C2`},void 0)]}),void 0)}var PE=0,QAe=function(e,t,n,r,i,a){return n?(0,U.jsx)(`span`,{children:`File type/size error, Hovered on types!`},void 0):(0,U.jsx)(JAe,{children:r?(0,U.jsx)(`span`,{children:`Upload disabled`},void 0):(0,U.jsx)(U.Fragment,e||t?{children:a?(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(`span`,{children:a},void 0)},void 0):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{children:`Uploaded Successfully!`},void 0),` Upload another?`]},void 0)}:{children:(0,U.jsxs)(U.Fragment,i?{children:[(0,U.jsx)(`span`,{children:i.split(` `)[0]},void 0),` `,i.substr(i.indexOf(` `)+1)]}:{children:[(0,U.jsx)(`span`,{children:`Upload`},void 0),` or drop a file right here`]},void 0)},void 0)},void 0)},FE=function(e){var t=e.name,n=e.hoverTitle,r=e.types,i=e.handleChange,a=e.classes,o=e.children,s=e.maxSize,c=e.minSize,l=e.fileOrFiles,u=e.onSizeError,d=e.onTypeError,f=e.onSelect,p=e.onDrop,m=e.disabled,h=e.label,g=e.uploadedLabel,_=e.multiple,v=e.required,y=e.onDraggingStateChange,b=e.dropMessageStyle,x=e.ariaLabel,S=e.ariaDescribedby,C=(0,H.useRef)(null),w=(0,H.useRef)(null),T=(0,H.useState)(!1),E=T[0],D=T[1],O=(0,H.useState)(null),k=O[0],A=O[1],j=(0,H.useState)(!1),M=j[0],N=j[1],P=function(e){return r&&!function(e,t){var n=e.name.split(`.`).pop();return t.map((function(e){return e.toLowerCase()})).includes(n.toLowerCase())}(e,r)?(N(!0),d&&d(`File type is not supported`),!1):s&&NE(e.size)>s?(N(!0),u&&u(`File size is too big`),!1):!(c&&NE(e.size)<c)||(N(!0),u&&u(`File size is too small`),!1)},F=function(e){var t=!1;if(e){if(e instanceof File)t=!P(e);else for(var n=0;n<e.length;n++){var r=e[n];t=!P(r)||t}return!t&&(i&&i(e),A(e),D(!0),N(!1),!0)}return!1},I=function(e){var t=e.labelRef,n=e.inputRef,r=e.multiple,i=e.handleChanges,a=e.onDrop,o=(0,H.useState)(!1),s=o[0],c=o[1],l=(0,H.useCallback)((function(){n.current.click()}),[n]),u=(0,H.useCallback)((function(e){e.preventDefault(),e.stopPropagation(),PE++,e.dataTransfer.items&&e.dataTransfer.items.length!==0&&c(!0)}),[]),d=(0,H.useCallback)((function(e){e.preventDefault(),e.stopPropagation(),--PE>0||c(!1)}),[]),f=(0,H.useCallback)((function(e){e.preventDefault(),e.stopPropagation()}),[]),p=(0,H.useCallback)((function(e){e.preventDefault(),e.stopPropagation(),c(!1),PE=0;var t=e.dataTransfer.files;if(t&&t.length>0){var n=r?t:t[0],o=i(n);a&&o&&a(n)}}),[i]);return(0,H.useEffect)((function(){var e=t.current;return e.addEventListener(`click`,l),e.addEventListener(`dragenter`,u),e.addEventListener(`dragleave`,d),e.addEventListener(`dragover`,f),e.addEventListener(`drop`,p),function(){e.removeEventListener(`click`,l),e.removeEventListener(`dragenter`,u),e.removeEventListener(`dragleave`,d),e.removeEventListener(`dragover`,f),e.removeEventListener(`drop`,p)}}),[l,u,d,f,p,t]),s}({labelRef:C,inputRef:w,multiple:_,handleChanges:F,onDrop:p});return(0,H.useEffect)((function(){y?.(I)}),[I]),(0,H.useEffect)((function(){l?(D(!0),A(l)):(w.current&&(w.current.value=``),D(!1),A(null))}),[l]),(0,U.jsxs)(GAe,jE({overRide:o,className:`${a||``} ${m?`is-disabled`:``}`,ref:C,htmlFor:t,onClick:function(e){e.preventDefault(),e.stopPropagation()},"aria-describedby":S,role:`button`,"aria-label":x},{children:[(0,U.jsx)(`input`,{onClick:function(e){e.stopPropagation(),w&&w.current&&(w.current.value=``,w.current.click())},onChange:function(e){var t=e.target.files,n=_?t:t[0],r=F(n);f&&r&&f(n)},accept:YAe(r),ref:w,type:`file`,id:t,name:t,disabled:m,multiple:_,required:v},void 0),I&&(0,U.jsx)(KAe,jE({style:b},{children:(0,U.jsx)(`span`,{children:n||`Drop Here`},void 0)}),void 0),!o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ZAe,{},void 0),(0,U.jsxs)(qAe,jE({error:M},{children:[QAe(k,E,M,m,h,g),(0,U.jsx)(XAe,{types:r,minSize:c,maxSize:s},void 0)]}),void 0)]},void 0),o]}),void 0)},IE=e=>e.productType===`ai`,LE=e=>e.productType===`ai`&&e.productVersion===2,RE=e=>e.productType===`ai`&&e.productVersion!==2,zE=`__custom`,$Ae=`BedrockMantle`,eje=/^[a-z]{2,4}(?:-[a-z]+)+-\d+$/,BE=e=>`https://bedrock-mantle.${e}.api.aws`,tje=e=>{if(!e)return;let t;try{t=new URL(e).hostname}catch{return}return/^bedrock-mantle\.([a-z]{2,4}(?:-[a-z]+)+-\d+)\.api\.aws$/.exec(t)?.[1]},VE=`ZuploDemo`,HE=`Zuplo Demo`,UE=e=>e?.trim()===VE,nje=`Zuplo Demo is available on AI Gateway v2 projects`,WE=e=>e.productType!==void 0&&LE({...e,productType:e.productType}),rje=new Set([`present-options`,`present-link`,`present-consumer`,`present-environment-variable`,`present-source`,`celebrate`,`present-file`,`show-test-console`,`switch-project`,`update-working-copy`,`request-openapi-import`,`request-ai-provider`,`request-ai-team`,`request-ai-app`]);function GE(e){return jx(e)?e.state!==`output-available`&&e.state!==`output-error`&&e.state!==`output-denied`:!1}var ije=new Set([`approval-requested`,`approval-responded`,`output-denied`]);function KE(e){return jx(e)&&ije.has(e.state)}function aje(e){let t=[],n=null;return e.forEach((e,r)=>{if(jx(e)){let i=Nx(e);if(!rje.has(i)&&!KE(e)){let a={name:i,pending:GE(e)};n?n.tools.push(a):(n={kind:`tools`,index:r,tools:[a]},t.push(n));return}}sje(e)||(n=null,t.push({kind:`part`,index:r,part:e}))}),t}function qE(e){return e.kind===`part`&&jx(e.part)&&Nx(e.part)===`present-options`}function oje(e){if(!e.some(qE))return e;let t=e.filter(e=>!qE(e)),n=e.filter(qE);return[...t,...n]}function sje(e){return e.type===`step-start`?!0:e.type===`text`||e.type===`reasoning`?e.text.trim()===``:!1}var cje=/\b(save|write|create|edit|update|patch|append|delete|remove|rename|move)\b/i,lje=new Set([`get-deployment-versions`,`get-deployment-logs`,`get-build-logs`,`check-build-status`,`check-deployed-version`]),uje=new Set([`search-zuplo-docs`,`get-available-doc-pages`,`get-doc-page`]),dje={get:`Getting`,list:`Listing`,check:`Checking`,create:`Creating`,query:`Querying`,search:`Searching`,redeploy:`Redeploying`,request:`Requesting`,present:`Presenting`};function fje(e){if(uje.has(e))return`Planning next steps`;let t=JE(e),n=/\b(files?|director(?:y|ies)|folders?)\b/i.test(t);return n&&cje.test(t)?`Writing Code`:n||lje.has(e)?`Exploring Project`:pje(t)}function pje(e){let[t,...n]=e.split(` `),r=dje[t.toLowerCase()];return r?[r,...n].join(` `):e}function mje(e){let t=new Map;for(let{name:n,pending:r}of e){let e=fje(n),i=t.get(e);i?(i.count+=1,i.pending=i.pending||r):t.set(e,{count:1,pending:r})}return Array.from(t,([e,{count:t,pending:n}])=>({label:e,count:t,pending:n}))}var hje=new Set([`ai`,`api`,`http`,`mcp`,`url`]);function JE(e){let t=e.trim();return t&&(t.replace(/[_-]tool$/i,``).replace(/([a-z0-9])Tool$/,`$1`)||t).replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/\s+/g,` `).trim().split(` `).map(e=>hje.has(e.toLowerCase())?e.toUpperCase():e&&e[0].toUpperCase()+e.slice(1)).join(` `)}function YE({isUser:e=!1,footer:t,children:n}){return(0,U.jsx)(`div`,{className:W(`group flex items-start gap-2.5`,e?`justify-end`:`justify-start`),children:(0,U.jsxs)(`div`,{className:W(`flex flex-col`,e?`max-w-[85%]`:`min-w-0 flex-1`),children:[(0,U.jsx)(`div`,{className:W(`flex flex-col gap-3 rounded-2xl px-4 py-2.5 text-sm`,e?`bg-primary text-primary-foreground`:`border bg-background`),children:n}),t]})})}var XE=4;function ZE({tools:e}){let t=mje(e),n=t.slice(0,XE),r=t.slice(XE),i=r.length,a=r.some(e=>e.pending);return(0,U.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-muted-foreground`,children:[(0,U.jsx)(rb,{weight:`fill`,className:`mt-0.5 size-3 shrink-0`}),(0,U.jsxs)(`span`,{children:[n.map((e,t)=>(0,U.jsxs)(H.Fragment,{children:[t>0?`, `:null,(0,U.jsx)(`span`,{className:W(`font-medium`,e.pending&&`animate-text-shimmer`),children:e.label}),e.count>1?` ×${e.count}`:null]},e.label)),i>0?(0,U.jsxs)(U.Fragment,{children:[`, `,(0,U.jsx)(`span`,{className:W(a&&`animate-text-shimmer`),children:`+${i} more`})]}):null]})]})}function gje({text:e}){let[t,n]=(0,H.useState)(!1);return(0,U.jsxs)(Fw,{open:t,onOpenChange:n,children:[(0,U.jsxs)(Iw,{className:`flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[(0,U.jsx)(rd,{className:W(`size-3 shrink-0 transition-transform`,t&&`rotate-90`)}),(0,U.jsx)(`span`,{className:`font-medium`,children:`Thinking`})]}),(0,U.jsx)(Lw,{children:(0,U.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap border-l-2 pl-3 text-xs italic text-muted-foreground`,children:e})})]})}function _je({data:e,onSend:t,disabled:n}){let r=e.options.slice(0,3);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.prompt?(0,U.jsx)(kC,{content:e.prompt}):null,(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map((e,r)=>(0,U.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>t(e.label),className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none disabled:opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-6 shrink-0 items-center justify-center rounded-md border border-brand/30 bg-brand/10 text-xs font-medium text-brand`,children:r+1}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),e.description?(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description}):null]})]},e.id))})]})}function vje({data:e}){let t;try{t=new URL(e.url).host}catch{}return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.description?(0,U.jsx)(kC,{content:e.description}):null,(0,U.jsxs)(Rw,{href:e.url,variant:`ghost`,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left text-foreground transition-colors`,`hover:border-brand/40 hover:bg-accent`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(Td,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.label}),t?(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:t}):null]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]})]})}function yje({data:e}){let t=e.url;try{t=new URL(e.url).pathname}catch{}return(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Source:`,` `,(0,U.jsx)(Rw,{href:e.url,showIcon:!0,children:e.title||t})]})}function bje({message:e}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-brand/30 bg-gradient-to-br from-brand/15 via-brand/5 to-transparent p-3`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(Oee,{className:`size-4`})}),(0,U.jsx)(kC,{content:e,className:`min-w-0 flex-1 font-medium prose-p:my-0`})]})}function xje({sub:e,description:t,loading:n=!1,errorText:r,onOpen:i}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t?(0,U.jsx)(kC,{content:t}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:n,onClick:i,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:n?(0,U.jsx)(nf,{className:`size-4 animate-spin`}):(0,U.jsx)(Zd,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`API key consumer`})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]}),r?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:r}):null]})}function Sje({name:e,description:t,loading:n=!1,disabled:r=!1,errorText:i,onOpen:a}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t?(0,U.jsx)(kC,{content:t}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:n||r,onClick:a,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`,r&&`opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:n?(0,U.jsx)(nf,{className:`size-4 animate-spin`}):(0,U.jsx)(_d,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate font-mono text-sm font-medium`,children:e}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Environment variable`})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]}),i?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:i}):null]})}function Cje({path:e,label:t,description:n,disabled:r=!1,onOpen:i}){let a=e.split(`/`).filter(Boolean).pop()??e;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[n?(0,U.jsx)(kC,{content:n}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:r,onClick:i,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none disabled:opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(Od,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t??a}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]})]})}function wje({method:e,path:t,description:n,loading:r=!1,disabled:i=!1,errorText:a,onOpen:o}){let s=t?`${(e??`GET`).toUpperCase()} ${t}`:`Send a live request to your gateway`;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[n?(0,U.jsx)(kC,{content:n}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:r||i,onClick:o,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`,i&&`opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:r?(0,U.jsx)(nf,{className:`size-4 animate-spin`}):(0,U.jsx)(Lf,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Open test console`}),(0,U.jsx)(`span`,{className:W(`truncate text-xs text-muted-foreground`,t&&`font-mono`),children:s})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]}),a?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:a}):null]})}function Tje({projectName:e,reason:t,isActive:n=!1,disabled:r=!1,onSwitch:i}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t?(0,U.jsx)(kC,{content:t}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:n||r,onClick:i,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:n?(0,U.jsx)(td,{className:`size-4`}):(0,U.jsx)(zd,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n?`Working on ${e}`:`Switch to ${e}`}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n?`Zuplo AI is working on this project`:`Move this conversation to that project`})]}),n?null:(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]})]})}function Eje({description:e,disabled:t=!1,onOpen:n}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e?(0,U.jsx)(kC,{content:e}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:t,onClick:n,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none disabled:opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(vf,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Update working copy`}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:`Pull the latest changes from your repo`})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]})]})}function QE({provider:e,description:t,loading:n=!1,disabled:r=!1,unavailableText:i,errorText:a,onOpen:o}){let s=UE(e),c=s?HE:e,l=!!i;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t?(0,U.jsx)(kC,{content:t}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:n||r||l,onClick:o,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`,(r||l)&&`opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:n?(0,U.jsx)(nf,{className:`size-4 animate-spin`}):(0,U.jsx)(Yu,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:c?`Add ${c}`:`Add AI provider`}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:i??(c?s?`No API key needed — pick models`:`Connect your ${c} API key and pick models`:`Connect an API key and pick models`)})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]}),a?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:a}):null]})}function Dje({name:e,description:t,disabled:n=!1,onOpen:r}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[t?(0,U.jsx)(kC,{content:t}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:n,onClick:r,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none disabled:opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(gee,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e?`Create app “${e}”`:`Create app`}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:`Name it and pick its team; models come next`})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]})]})}function Oje({name:e,isSubTeam:t=!1,description:n,loading:r=!1,disabled:i=!1,errorText:a,onOpen:o}){let s=t?`sub-team`:`team`;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[n?(0,U.jsx)(kC,{content:n}):null,(0,U.jsxs)(`button`,{type:`button`,disabled:r||i,onClick:o,className:W(`flex w-full items-center gap-3 rounded-lg border bg-surface p-3 text-left transition-colors`,`hover:border-brand/40 hover:bg-accent disabled:pointer-events-none`,i&&`opacity-60`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:r?(0,U.jsx)(nf,{className:`size-4 animate-spin`}):(0,U.jsx)(Uf,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e?`Create ${s} “${e}”`:`Create ${s}`}),(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:`Group apps and set shared usage limits`})]}),(0,U.jsx)(rd,{className:`ml-auto size-4 shrink-0 text-muted-foreground`})]}),a?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:a}):null]})}var kje=[`JSON`,`YML`,`YAML`],$E=`50`;function Aje({data:e,status:t,fileName:n,errorText:r,disabled:i=!1,onFileSelected:a}){return t===`done`?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.message?(0,U.jsx)(kC,{content:e.message}):null,(0,U.jsxs)(`div`,{className:`flex w-full items-center gap-3 rounded-lg border bg-surface p-3`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(td,{className:`size-4`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n?`Imported ${n}`:`OpenAPI file imported`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saved to your working copy`})]})]})]}):t===`saving`?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.message?(0,U.jsx)(kC,{content:e.message}):null,(0,U.jsxs)(`div`,{className:`flex w-full items-center gap-3 rounded-lg border bg-surface p-3`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(nf,{className:`size-4 animate-spin`})}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n?`Importing ${n}…`:`Importing…`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saving to your working copy`})]})]})]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.message?(0,U.jsx)(kC,{content:e.message}):null,(0,U.jsx)(FE,{handleChange:a,name:`file`,types:kje,maxSize:$E,disabled:i,classes:`w-full`,children:(0,U.jsxs)(`div`,{className:W(`flex w-full flex-col items-center justify-center gap-1 rounded-lg border border-dashed bg-surface px-4 py-6 text-center transition-colors`,i?`opacity-60`:`cursor-pointer hover:border-brand/40 hover:bg-accent`),children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:`mb-1 flex size-9 shrink-0 items-center justify-center rounded-lg border border-brand/30 bg-brand/10 text-brand`,children:(0,U.jsx)(Fd,{className:`size-4`})}),(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Drop your OpenAPI file here`}),(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`or click to choose — JSON, YAML or YML up to`,` `,$E,`MB`]})]})}),r?(0,U.jsxs)(`p`,{className:W(`flex items-start gap-1.5 text-xs`,t===`error`?`text-destructive-foreground`:`text-muted-foreground`),children:[(0,U.jsx)(sd,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,U.jsx)(`span`,{children:r})]}):null]})}function jje({toolLabel:e,input:t,status:n,onRespond:r}){let i=n.kind===`denied`||n.kind===`responded`&&!n.approved,a=t&&typeof t==`object`&&Object.keys(t).length>0?JSON.stringify(t,null,2):null;return(0,U.jsxs)(`div`,{className:`flex w-full flex-col gap-3 rounded-lg border bg-surface p-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`span`,{"aria-hidden":!0,className:W(`flex size-9 shrink-0 items-center justify-center rounded-lg border`,i?`border-border bg-muted text-muted-foreground`:`border-brand/30 bg-brand/10 text-brand`),children:i?(0,U.jsx)(Vu,{className:`size-4`}):(0,U.jsx)(Of,{className:`size-4`})}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.kind===`requested`?`Zuplo AI needs your approval to run this`:i?`Denied — this was not run`:`Approved — running…`})]})]}),a&&n.kind===`requested`?(0,U.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded-md bg-surface-muted px-3 py-2 font-mono text-xs text-muted-foreground`,children:a}):null,n.kind===`requested`?(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(X,{type:`button`,size:`sm`,onClick:()=>r(!0),children:`Approve`}),(0,U.jsx)(X,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(!1),children:`Deny`})]}):null]})}function eD(){return(0,U.jsx)(`output`,{className:`flex items-center gap-1 py-1`,"aria-label":`Zuplo AI is thinking`,children:[0,1,2].map(e=>(0,U.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/70 motion-safe:animate-bounce`,style:{animationDelay:`${e*.15}s`}},e))})}function Mje(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.message==`string`?t.message.trim():void 0;return n?{message:n}:null}var tD=null;function Nje(){typeof window>`u`||(tD||=new wke,tD.addConfetti({emojis:[`🎉`,`✨`,`🎊`,`⭐️`,`🚀`],confettiNumber:60}))}function Pje({data:e}){let{logEvent:t}=on(),{account:n,project:r}=Wb([]),i=(0,H.useRef)(!1);return(0,H.useEffect)(()=>{i.current||(i.current=!0,t(`agent-z-celebrate-shown`,{account:n,project:r}),typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||Nje())},[t,n,r]),(0,U.jsx)(bje,{message:e.message})}var nD=e=>e.type===`checkbox`,rD=e=>e instanceof Date,iD=e=>e==null,aD=e=>typeof e==`object`,oD=e=>!iD(e)&&!Array.isArray(e)&&aD(e)&&!rD(e),sD=e=>oD(e)&&e.target?nD(e.target)?e.target.checked:e.target.value:e,Fje=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,cD=(e,t)=>e.has(Fje(t)),Ije=e=>{let t=e.constructor&&e.constructor.prototype;return oD(t)&&t.hasOwnProperty(`isPrototypeOf`)},lD=typeof window<`u`&&window.HTMLElement!==void 0&&typeof document<`u`;function uD(e){let t,n=Array.isArray(e),r=typeof FileList<`u`?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(lD&&(e instanceof Blob||r))&&(n||oD(e)))if(t=n?[]:{},!n&&!Ije(e))t=e;else for(let n in e)e.hasOwnProperty(n)&&(t[n]=uD(e[n]));else return e;return t}var dD=e=>Array.isArray(e)?e.filter(Boolean):[],fD=e=>e===void 0,pD=(e,t,n)=>{if(!t||!oD(e))return n;let r=dD(t.split(/[,[\].]+?/)).reduce((e,t)=>iD(e)?e:e[t],e);return fD(r)||r===e?fD(e[t])?n:e[t]:r},mD=e=>typeof e==`boolean`,hD=e=>/^\w*$/.test(e),gD=e=>dD(e.replace(/["|']|\]/g,``).split(/\.|\[/)),_D=(e,t,n)=>{let r=-1,i=hD(t)?[t]:gD(t),a=i.length,o=a-1;for(;++r<a;){let t=i[r],a=n;if(r!==o){let n=e[t];a=oD(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if(t===`__proto__`||t===`constructor`||t===`prototype`)return;e[t]=a,e=e[t]}},vD={BLUR:`blur`,FOCUS_OUT:`focusout`,CHANGE:`change`},yD={onBlur:`onBlur`,onChange:`onChange`,onSubmit:`onSubmit`,onTouched:`onTouched`,all:`all`},bD={max:`max`,min:`min`,maxLength:`maxLength`,minLength:`minLength`,pattern:`pattern`,required:`required`,validate:`validate`},xD=H.createContext(null),SD=()=>H.useContext(xD),CD=e=>{let{children:t,...n}=e;return H.createElement(xD.Provider,{value:n},t)},wD=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let a in e)Object.defineProperty(i,a,{get:()=>{let i=a;return t._proxyFormState[i]!==yD.all&&(t._proxyFormState[i]=!r||yD.all),n&&(n[i]=!0),e[i]}});return i},TD=e=>iD(e)||!aD(e);function ED(e,t){if(TD(e)||TD(t))return e===t;if(rD(e)&&rD(t))return e.getTime()===t.getTime();let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n){let n=e[i];if(!r.includes(i))return!1;if(i!==`ref`){let e=t[i];if(rD(n)&&rD(e)||oD(n)&&oD(e)||Array.isArray(n)&&Array.isArray(e)?!ED(n,e):n!==e)return!1}}return!0}var DD=(e,t)=>{let n=H.useRef(t);ED(t,n.current)||(n.current=t),H.useEffect(e,n.current)};function OD(e){let t=SD(),{control:n=t.control,disabled:r,name:i,exact:a}=e||{},[o,s]=H.useState(n._formState),c=H.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return DD(()=>n._subscribe({name:i,formState:c.current,exact:a,callback:e=>{!r&&s({...n._formState,...e})}}),[i,r,a]),H.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),H.useMemo(()=>wD(o,n,c.current,!1),[o,n])}var kD=e=>typeof e==`string`,AD=(e,t,n,r,i)=>kD(e)?(r&&t.watch.add(e),pD(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),pD(n,e))):(r&&(t.watchAll=!0),n);function Lje(e){let t=SD(),{control:n=t.control,name:r,defaultValue:i,disabled:a,exact:o}=e||{},[s,c]=H.useState(n._getWatch(r,i));return DD(()=>n._subscribe({name:r,formState:{values:!0},exact:o,callback:e=>!a&&c(AD(r,n._names,e.values||n._formValues,!1,i))}),[r,i,a,o]),H.useEffect(()=>n._removeUnmounted()),s}function Rje(e){let t=SD(),{name:n,disabled:r,control:i=t.control,shouldUnregister:a}=e,o=cD(i._names.array,n),s=Lje({control:i,name:n,defaultValue:pD(i._formValues,n,pD(i._defaultValues,n,e.defaultValue)),exact:!0}),c=OD({control:i,name:n,exact:!0}),l=H.useRef(e),u=H.useRef(i.register(n,{...e.rules,value:s,...mD(e.disabled)?{disabled:e.disabled}:{}})),d=H.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!pD(c.errors,n)},isDirty:{enumerable:!0,get:()=>!!pD(c.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!pD(c.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!pD(c.validatingFields,n)},error:{enumerable:!0,get:()=>pD(c.errors,n)}}),[c,n]),f=H.useCallback(e=>u.current.onChange({target:{value:sD(e),name:n},type:vD.CHANGE}),[n]),p=H.useCallback(()=>u.current.onBlur({target:{value:pD(i._formValues,n),name:n},type:vD.BLUR}),[n,i._formValues]),m=H.useCallback(e=>{let t=pD(i._fields,n);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})},[i._fields,n]),h=H.useMemo(()=>({name:n,value:s,...mD(r)||c.disabled?{disabled:c.disabled||r}:{},onChange:f,onBlur:p,ref:m}),[n,r,c.disabled,f,p,m,s]);return H.useEffect(()=>{let e=i._options.shouldUnregister||a;i.register(n,{...l.current.rules,...mD(l.current.disabled)?{disabled:l.current.disabled}:{}});let t=(e,t)=>{let n=pD(i._fields,e);n&&n._f&&(n._f.mount=t)};if(t(n,!0),e){let e=uD(pD(i._options.defaultValues,n));_D(i._defaultValues,n,e),fD(pD(i._formValues,n))&&_D(i._formValues,n,e)}return!o&&i.register(n),()=>{(o?e&&!i._state.action:e)?i.unregister(n):t(n,!1)}},[n,i,o,a]),H.useEffect(()=>{i._setDisabledField({disabled:r,name:n})},[r,n,i]),H.useMemo(()=>({field:h,formState:c,fieldState:d}),[h,c,d])}var jD=e=>e.render(Rje(e)),MD=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},ND=e=>Array.isArray(e)?e:[e],PD=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}},FD=e=>oD(e)&&!Object.keys(e).length,ID=e=>e.type===`file`,LD=e=>typeof e==`function`,RD=e=>{if(!lD)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},zD=e=>e.type===`select-multiple`,BD=e=>e.type===`radio`,zje=e=>BD(e)||nD(e),VD=e=>RD(e)&&e.isConnected;function Bje(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;)e=fD(e)?r++:e[t[r++]];return e}function Vje(e){for(let t in e)if(e.hasOwnProperty(t)&&!fD(e[t]))return!1;return!0}function HD(e,t){let n=Array.isArray(t)?t:hD(t)?[t]:gD(t),r=n.length===1?e:Bje(e,n),i=n.length-1,a=n[i];return r&&delete r[a],i!==0&&(oD(r)&&FD(r)||Array.isArray(r)&&Vje(r))&&HD(e,n.slice(0,-1)),e}var UD=e=>{for(let t in e)if(LD(e[t]))return!0;return!1};function WD(e,t={}){let n=Array.isArray(e);if(oD(e)||n)for(let n in e)Array.isArray(e[n])||oD(e[n])&&!UD(e[n])?(t[n]=Array.isArray(e[n])?[]:{},WD(e[n],t[n])):iD(e[n])||(t[n]=!0);return t}function GD(e,t,n){let r=Array.isArray(e);if(oD(e)||r)for(let r in e)Array.isArray(e[r])||oD(e[r])&&!UD(e[r])?fD(t)||TD(n[r])?n[r]=Array.isArray(e[r])?WD(e[r],[]):{...WD(e[r])}:GD(e[r],iD(t)?{}:t[r],n[r]):n[r]=!ED(e[r],t[r]);return n}var KD=(e,t)=>GD(e,t,WD(t)),qD={value:!1,isValid:!1},JD={value:!0,isValid:!0},YD=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!fD(e[0].attributes.value)?fD(e[0].value)||e[0].value===``?JD:{value:e[0].value,isValid:!0}:JD:qD}return qD},XD=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>fD(e)?e:t?e===``?NaN:e&&+e:n&&kD(e)?new Date(e):r?r(e):e,ZD={isValid:!1,value:null},QD=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,ZD):ZD;function $D(e){let t=e.ref;return ID(t)?t.files:BD(t)?QD(e.refs).value:zD(t)?[...t.selectedOptions].map(({value:e})=>e):nD(t)?YD(e.refs).value:XD(fD(t.value)?e.ref.value:t.value,e)}var Hje=(e,t,n,r)=>{let i={};for(let n of e){let e=pD(t,n);e&&_D(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},eO=e=>e instanceof RegExp,tO=e=>fD(e)?e:eO(e)?e.source:oD(e)?eO(e.value)?e.value.source:e.value:e,nO=e=>({isOnSubmit:!e||e===yD.onSubmit,isOnBlur:e===yD.onBlur,isOnChange:e===yD.onChange,isOnAll:e===yD.all,isOnTouch:e===yD.onTouched}),rO=`AsyncFunction`,Uje=e=>!!e&&!!e.validate&&!!(LD(e.validate)&&e.validate.constructor.name===rO||oD(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===rO)),Wje=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),iO=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))),aO=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=pD(e,i);if(n){let{_f:e,...a}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r||e.ref&&t(e.ref,e.name)&&!r)return!0;if(aO(a,t))break}else if(oD(a)&&aO(a,t))break}}};function oO(e,t,n){let r=pD(e,n);if(r||hD(n))return{error:r,name:n};let i=n.split(`.`);for(;i.length;){let r=i.join(`.`),a=pD(t,r),o=pD(e,r);if(a&&!Array.isArray(a)&&n!==r)return{name:n};if(o&&o.type)return{name:r,error:o};i.pop()}return{name:n}}var Gje=(e,t,n,r)=>{n(e);let{name:i,...a}=e;return FD(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(e=>t[e]===(!r||yD.all))},Kje=(e,t,n)=>!e||!t||e===t||ND(e).some(e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e))),qje=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,Jje=(e,t)=>!dD(pD(e,t)).length&&HD(e,t),sO=(e,t,n)=>{let r=ND(pD(e,n));return _D(r,`root`,t[n]),_D(e,n,r),e},cO=e=>kD(e);function lO(e,t,n=`validate`){if(cO(e)||Array.isArray(e)&&e.every(cO)||mD(e)&&!e)return{type:n,message:cO(e)?e:``,ref:t}}var uO=e=>oD(e)&&!eO(e)?e:{value:e,message:``},dO=async(e,t,n,r,i,a)=>{let{ref:o,refs:s,required:c,maxLength:l,minLength:u,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:_}=e._f,v=pD(n,h);if(!_||t.has(h))return{};let y=s?s[0]:o,b=e=>{i&&y.reportValidity&&(y.setCustomValidity(mD(e)?``:e||``),y.reportValidity())},x={},S=BD(o),C=nD(o),w=S||C,T=(g||ID(o))&&fD(o.value)&&fD(v)||RD(o)&&o.value===``||v===``||Array.isArray(v)&&!v.length,E=MD.bind(null,h,r,x),D=(e,t,n,r=bD.maxLength,i=bD.minLength)=>{let a=e?t:n;x[h]={type:e?r:i,message:a,ref:o,...E(e?r:i,a)}};if(a?!Array.isArray(v)||!v.length:c&&(!w&&(T||iD(v))||mD(v)&&!v||C&&!YD(s).isValid||S&&!QD(s).isValid)){let{value:e,message:t}=cO(c)?{value:!!c,message:c}:uO(c);if(e&&(x[h]={type:bD.required,message:t,ref:y,...E(bD.required,t)},!r))return b(t),x}if(!T&&(!iD(d)||!iD(f))){let e,t,n=uO(f),i=uO(d);if(!iD(v)&&!isNaN(v)){let r=o.valueAsNumber||v&&+v;iD(n.value)||(e=r>n.value),iD(i.value)||(t=r<i.value)}else{let r=o.valueAsDate||new Date(v),a=e=>new Date(new Date().toDateString()+` `+e),s=o.type==`time`,c=o.type==`week`;kD(n.value)&&v&&(e=s?a(v)>a(n.value):c?v>n.value:r>new Date(n.value)),kD(i.value)&&v&&(t=s?a(v)<a(i.value):c?v<i.value:r<new Date(i.value))}if((e||t)&&(D(!!e,n.message,i.message,bD.max,bD.min),!r))return b(x[h].message),x}if((l||u)&&!T&&(kD(v)||a&&Array.isArray(v))){let e=uO(l),t=uO(u),n=!iD(e.value)&&v.length>+e.value,i=!iD(t.value)&&v.length<+t.value;if((n||i)&&(D(n,e.message,t.message),!r))return b(x[h].message),x}if(p&&!T&&kD(v)){let{value:e,message:t}=uO(p);if(eO(e)&&!v.match(e)&&(x[h]={type:bD.pattern,message:t,ref:o,...E(bD.pattern,t)},!r))return b(t),x}if(m){if(LD(m)){let e=lO(await m(v,n),y);if(e&&(x[h]={...e,...E(bD.validate,e.message)},!r))return b(e.message),x}else if(oD(m)){let e={};for(let t in m){if(!FD(e)&&!r)break;let i=lO(await m[t](v,n),y,t);i&&(e={...i,...E(t,i.message)},b(i.message),r&&(x[h]=e))}if(!FD(e)&&(x[h]={ref:y,...e},!r))return x}}return b(!0),x},Yje={mode:yD.onSubmit,reValidateMode:yD.onChange,shouldFocusError:!0};function Xje(e={}){let t={...Yje,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:LD(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=(oD(t.defaultValues)||oD(t.values))&&uD(t.values||t.defaultValues)||{},a=t.shouldUnregister?{}:uD(i),o={action:!1,mount:!1,watch:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,l=0,u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...u},f={array:PD(),state:PD()},p=nO(t.mode),m=nO(t.reValidateMode),h=t.criteriaMode===yD.all,g=e=>t=>{clearTimeout(l),l=setTimeout(e,t)},_=async e=>{if(!t.disabled&&(u.isValid||d.isValid||e)){let e=t.resolver?FD((await T()).errors):await D(r,!0);e!==n.isValid&&f.state.next({isValid:e})}},v=(e,r)=>{!t.disabled&&(u.isValidating||u.validatingFields||d.isValidating||d.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(r?_D(n.validatingFields,e,r):HD(n.validatingFields,e))}),f.state.next({validatingFields:n.validatingFields,isValidating:!FD(n.validatingFields)}))},y=(e,s=[],c,l,p=!0,m=!0)=>{if(l&&c&&!t.disabled){if(o.action=!0,m&&Array.isArray(pD(r,e))){let t=c(pD(r,e),l.argA,l.argB);p&&_D(r,e,t)}if(m&&Array.isArray(pD(n.errors,e))){let t=c(pD(n.errors,e),l.argA,l.argB);p&&_D(n.errors,e,t),Jje(n.errors,e)}if((u.touchedFields||d.touchedFields)&&m&&Array.isArray(pD(n.touchedFields,e))){let t=c(pD(n.touchedFields,e),l.argA,l.argB);p&&_D(n.touchedFields,e,t)}(u.dirtyFields||d.dirtyFields)&&(n.dirtyFields=KD(i,a)),f.state.next({name:e,isDirty:k(e,s),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else _D(a,e,s)},b=(e,t)=>{_D(n.errors,e,t),f.state.next({errors:n.errors})},x=e=>{n.errors=e,f.state.next({errors:n.errors,isValid:!1})},S=(e,t,n,s)=>{let c=pD(r,e);if(c){let r=pD(a,e,fD(n)?pD(i,e):n);fD(r)||s&&s.defaultChecked||t?_D(a,e,t?r:$D(c._f)):M(e,r),o.mount&&_()}},C=(e,r,a,o,s)=>{let c=!1,l=!1,p={name:e};if(!t.disabled){if(!a||o){(u.isDirty||d.isDirty)&&(l=n.isDirty,n.isDirty=p.isDirty=k(),c=l!==p.isDirty);let t=ED(pD(i,e),r);l=!!pD(n.dirtyFields,e),t?HD(n.dirtyFields,e):_D(n.dirtyFields,e,!0),p.dirtyFields=n.dirtyFields,c||=(u.dirtyFields||d.dirtyFields)&&l!==!t}if(a){let t=pD(n.touchedFields,e);t||(_D(n.touchedFields,e,a),p.touchedFields=n.touchedFields,c||=(u.touchedFields||d.touchedFields)&&t!==a)}c&&s&&f.state.next(p)}return c?p:{}},w=(e,r,i,a)=>{let o=pD(n.errors,e),s=(u.isValid||d.isValid)&&mD(r)&&n.isValid!==r;if(t.delayError&&i?(c=g(()=>b(e,i)),c(t.delayError)):(clearTimeout(l),c=null,i?_D(n.errors,e,i):HD(n.errors,e)),(i?!ED(o,i):o)||!FD(a)||s){let t={...a,...s&&mD(r)?{isValid:r}:{},errors:n.errors,name:e};n={...n,...t},f.state.next(t)}},T=async e=>{v(e,!0);let n=await t.resolver(a,t.context,Hje(e||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return v(e),n},E=async e=>{let{errors:t}=await T(e);if(e)for(let r of e){let e=pD(t,r);e?_D(n.errors,r,e):HD(n.errors,r)}else n.errors=t;return t},D=async(e,r,i={valid:!0})=>{for(let o in e){let c=e[o];if(c){let{_f:e,...l}=c;if(e){let l=s.array.has(e.name),d=c._f&&Uje(c._f);d&&u.validatingFields&&v([o],!0);let f=await dO(c,s.disabled,a,h,t.shouldUseNativeValidation&&!r,l);if(d&&u.validatingFields&&v([o]),f[e.name]&&(i.valid=!1,r))break;!r&&(pD(f,e.name)?l?sO(n.errors,f,e.name):_D(n.errors,e.name,f[e.name]):HD(n.errors,e.name))}!FD(l)&&await D(l,r,i)}}return i.valid},O=()=>{for(let e of s.unMount){let t=pD(r,e);t&&(t._f.refs?t._f.refs.every(e=>!VD(e)):!VD(t._f.ref))&&re(e)}s.unMount=new Set},k=(e,n)=>!t.disabled&&(e&&n&&_D(a,e,n),!ED(R(),i)),A=(e,t,n)=>AD(e,s,{...o.mount?a:fD(t)?i:kD(e)?{[e]:t}:t},n,t),j=e=>dD(pD(o.mount?a:i,e,t.shouldUnregister?pD(i,e,[]):[])),M=(e,t,n={})=>{let i=pD(r,e),o=t;if(i){let n=i._f;n&&(!n.disabled&&_D(a,e,XD(t,n)),o=RD(n.ref)&&iD(t)?``:t,zD(n.ref)?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?nD(n.ref)?n.refs.length>1?n.refs.forEach(e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(o)?!!o.find(t=>t===e.value):o===e.value)):n.refs[0]&&(n.refs[0].checked=!!o):n.refs.forEach(e=>e.checked=e.value===o):ID(n.ref)?n.ref.value=``:(n.ref.value=o,n.ref.type||f.state.next({name:e,values:uD(a)})))}(n.shouldDirty||n.shouldTouch)&&C(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&L(e)},N=(e,t,n)=>{for(let i in t){let a=t[i],o=`${e}.${i}`,c=pD(r,o);(s.array.has(e)||oD(a)||c&&!c._f)&&!rD(a)?N(o,a,n):M(o,a,n)}},P=(e,t,c={})=>{let l=pD(r,e),p=s.array.has(e),m=uD(t);_D(a,e,m),p?(f.array.next({name:e,values:uD(a)}),(u.isDirty||u.dirtyFields||d.isDirty||d.dirtyFields)&&c.shouldDirty&&f.state.next({name:e,dirtyFields:KD(i,a),isDirty:k(e,m)})):l&&!l._f&&!iD(m)?N(e,m,c):M(e,m,c),iO(e,s)&&f.state.next({...n}),f.state.next({name:o.mount?e:void 0,values:uD(a)})},F=async e=>{o.mount=!0;let i=e.target,l=i.name,g=!0,y=pD(r,l),b=e=>{g=Number.isNaN(e)||rD(e)&&isNaN(e.getTime())||ED(e,pD(a,l,e))};if(y){let o,x,S=i.type?$D(y._f):sD(e),E=e.type===vD.BLUR||e.type===vD.FOCUS_OUT,O=!Wje(y._f)&&!t.resolver&&!pD(n.errors,l)&&!y._f.deps||qje(E,pD(n.touchedFields,l),n.isSubmitted,m,p),k=iO(l,s,E);_D(a,l,S),E?(y._f.onBlur&&y._f.onBlur(e),c&&c(0)):y._f.onChange&&y._f.onChange(e);let A=C(l,S,E),j=!FD(A)||k;if(!E&&f.state.next({name:l,type:e.type,values:uD(a)}),O)return(u.isValid||d.isValid)&&(t.mode===`onBlur`?E&&_():E||_()),j&&f.state.next({name:l,...k?{}:A});if(!E&&k&&f.state.next({...n}),t.resolver){let{errors:e}=await T([l]);if(b(S),g){let t=oO(e,r,oO(n.errors,r,l).name||l);o=t.error,l=t.name,x=FD(e)}}else v([l],!0),o=(await dO(y,s.disabled,a,h,t.shouldUseNativeValidation))[l],v([l]),b(S),g&&(o?x=!1:(u.isValid||d.isValid)&&(x=await D(r,!0)));g&&(y._f.deps&&L(y._f.deps),w(l,x,o,A))}},I=(e,t)=>{if(pD(n.errors,t)&&e.focus)return e.focus(),1},L=async(e,i={})=>{let a,o,c=ND(e);if(t.resolver){let t=await E(fD(e)?e:c);a=FD(t),o=e?!c.some(e=>pD(t,e)):a}else e?(o=(await Promise.all(c.map(async e=>{let t=pD(r,e);return await D(t&&t._f?{[e]:t}:t)}))).every(Boolean),!(!o&&!n.isValid)&&_()):o=a=await D(r);return f.state.next({...!kD(e)||(u.isValid||d.isValid)&&a!==n.isValid?{}:{name:e},...t.resolver||!e?{isValid:a}:{},errors:n.errors}),i.shouldFocus&&!o&&aO(r,I,e?c:s.mount),o},R=e=>{let t={...o.mount?a:i};return fD(e)?t:kD(e)?pD(t,e):e.map(e=>pD(t,e))},z=(e,t)=>({invalid:!!pD((t||n).errors,e),isDirty:!!pD((t||n).dirtyFields,e),error:pD((t||n).errors,e),isValidating:!!pD(n.validatingFields,e),isTouched:!!pD((t||n).touchedFields,e)}),B=e=>{e&&ND(e).forEach(e=>HD(n.errors,e)),f.state.next({errors:e?n.errors:{}})},ee=(e,t,i)=>{let a=(pD(r,e,{_f:{}})._f||{}).ref,{ref:o,message:s,type:c,...l}=pD(n.errors,e)||{};_D(n.errors,e,{...l,...t,ref:a}),f.state.next({name:e,errors:n.errors,isValid:!1}),i&&i.shouldFocus&&a&&a.focus&&a.focus()},V=(e,t)=>LD(e)?f.state.subscribe({next:n=>e(A(void 0,t),n)}):A(e,t,!0),te=e=>f.state.subscribe({next:t=>{Kje(e.name,t.name,e.exact)&&Gje(t,e.formState||u,pe,e.reRenderRoot)&&e.callback({values:{...a},...n,...t})}}).unsubscribe,ne=e=>(o.mount=!0,d={...d,...e.formState},te({...e,formState:d})),re=(e,o={})=>{for(let c of e?ND(e):s.mount)s.mount.delete(c),s.array.delete(c),o.keepValue||(HD(r,c),HD(a,c)),!o.keepError&&HD(n.errors,c),!o.keepDirty&&HD(n.dirtyFields,c),!o.keepTouched&&HD(n.touchedFields,c),!o.keepIsValidating&&HD(n.validatingFields,c),!t.shouldUnregister&&!o.keepDefaultValue&&HD(i,c);f.state.next({values:uD(a)}),f.state.next({...n,...o.keepDirty?{isDirty:k()}:{}}),!o.keepIsValid&&_()},ie=({disabled:e,name:t})=>{(mD(e)&&o.mount||e||s.disabled.has(t))&&(e?s.disabled.add(t):s.disabled.delete(t))},ae=(e,n={})=>{let a=pD(r,e),c=mD(n.disabled)||mD(t.disabled);return _D(r,e,{...a||{},_f:{...a&&a._f?a._f:{ref:{name:e}},name:e,mount:!0,...n}}),s.mount.add(e),a?ie({disabled:mD(n.disabled)?n.disabled:t.disabled,name:e}):S(e,!0,n.value),{...c?{disabled:n.disabled||t.disabled}:{},...t.progressive?{required:!!n.required,min:tO(n.min),max:tO(n.max),minLength:tO(n.minLength),maxLength:tO(n.maxLength),pattern:tO(n.pattern)}:{},name:e,onChange:F,onBlur:F,ref:c=>{if(c){ae(e,n),a=pD(r,e);let t=fD(c.value)&&c.querySelectorAll&&c.querySelectorAll(`input,select,textarea`)[0]||c,o=zje(t),s=a._f.refs||[];if(o?s.find(e=>e===t):t===a._f.ref)return;_D(r,e,{_f:{...a._f,...o?{refs:[...s.filter(VD),t,...Array.isArray(pD(i,e))?[{}]:[]],ref:{type:t.type,name:e}}:{ref:t}}}),S(e,!1,void 0,t)}else a=pD(r,e,{}),a._f&&(a._f.mount=!1),(t.shouldUnregister||n.shouldUnregister)&&!(cD(s.array,e)&&o.action)&&s.unMount.add(e)}}},oe=()=>t.shouldFocusError&&aO(r,I,s.mount),se=e=>{mD(e)&&(f.state.next({disabled:e}),aO(r,(t,n)=>{let i=pD(r,n);i&&(t.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach(t=>{t.disabled=i._f.disabled||e}))},0,!1))},ce=(e,i)=>async o=>{let c;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let l=uD(a);if(f.state.next({isSubmitting:!0}),t.resolver){let{errors:e,values:t}=await T();n.errors=e,l=t}else await D(r);if(s.disabled.size)for(let e of s.disabled)_D(l,e,void 0);if(HD(n.errors,`root`),FD(n.errors)){f.state.next({errors:{}});try{await e(l,o)}catch(e){c=e}}else i&&await i({...n.errors},o),oe(),setTimeout(oe);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:FD(n.errors)&&!c,submitCount:n.submitCount+1,errors:n.errors}),c)throw c},le=(e,t={})=>{pD(r,e)&&(fD(t.defaultValue)?P(e,uD(pD(i,e))):(P(e,t.defaultValue),_D(i,e,uD(t.defaultValue))),t.keepTouched||HD(n.touchedFields,e),t.keepDirty||(HD(n.dirtyFields,e),n.isDirty=t.defaultValue?k(e,uD(pD(i,e))):k()),t.keepError||(HD(n.errors,e),u.isValid&&_()),f.state.next({...n}))},ue=(e,c={})=>{let l=e?uD(e):i,d=uD(l),p=FD(e),m=p?i:d;if(c.keepDefaultValues||(i=l),!c.keepValues){if(c.keepDirtyValues){let e=new Set([...s.mount,...Object.keys(KD(i,a))]);for(let t of Array.from(e))pD(n.dirtyFields,t)?_D(m,t,pD(a,t)):P(t,pD(m,t))}else{if(lD&&fD(e))for(let e of s.mount){let t=pD(r,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(RD(e)){let t=e.closest(`form`);if(t){t.reset();break}}}}for(let e of s.mount)P(e,pD(m,e))}a=uD(m),f.array.next({values:{...m}}),f.state.next({values:{...m}})}s={mount:c.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:``},o.mount=!u.isValid||!!c.keepIsValid||!!c.keepDirtyValues,o.watch=!!t.shouldUnregister,f.state.next({submitCount:c.keepSubmitCount?n.submitCount:0,isDirty:p?!1:c.keepDirty?n.isDirty:!!(c.keepDefaultValues&&!ED(e,i)),isSubmitted:c.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:p?{}:c.keepDirtyValues?c.keepDefaultValues&&a?KD(i,a):n.dirtyFields:c.keepDefaultValues&&e?KD(i,e):c.keepDirty?n.dirtyFields:{},touchedFields:c.keepTouched?n.touchedFields:{},errors:c.keepErrors?n.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},de=(e,t)=>ue(LD(e)?e(a):e,t),fe=(e,t={})=>{let n=pD(r,e),i=n&&n._f;if(i){let e=i.refs?i.refs[0]:i.ref;e.focus&&(e.focus(),t.shouldSelect&&LD(e.select)&&e.select())}},pe=e=>{n={...n,...e}},me={control:{register:ae,unregister:re,getFieldState:z,handleSubmit:ce,setError:ee,_subscribe:te,_runSchema:T,_getWatch:A,_getDirty:k,_setValid:_,_setFieldArray:y,_setDisabledField:ie,_setErrors:x,_getFieldArray:j,_reset:ue,_resetDefaultValues:()=>LD(t.defaultValues)&&t.defaultValues().then(e=>{de(e,t.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:O,_disableForm:se,_subjects:f,_proxyFormState:u,get _fields(){return r},get _formValues(){return a},get _state(){return o},set _state(e){o=e},get _defaultValues(){return i},get _names(){return s},set _names(e){s=e},get _formState(){return n},get _options(){return t},set _options(e){t={...t,...e}}},subscribe:ne,trigger:L,register:ae,handleSubmit:ce,watch:V,setValue:P,getValues:R,reset:de,resetField:le,clearErrors:B,unregister:re,setError:ee,setFocus:fe,getFieldState:z};return{...me,formControl:me}}var fO=()=>{let e=typeof performance>`u`?Date.now():performance.now()*1e3;return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let n=(Math.random()*16+e)%16|0;return(t==`x`?n:n&3|8).toString(16)})},pO=(e,t,n={})=>n.shouldFocus||fD(n.shouldFocus)?n.focusName||`${e}.${fD(n.focusIndex)?t:n.focusIndex}.`:``,mO=(e,t)=>[...e,...ND(t)],hO=e=>Array.isArray(e)?e.map(()=>void 0):void 0;function gO(e,t,n){return[...e.slice(0,t),...ND(n),...e.slice(t)]}var _O=(e,t,n)=>Array.isArray(e)?(fD(e[n])&&(e[n]=void 0),e.splice(n,0,e.splice(t,1)[0]),e):[],vO=(e,t)=>[...ND(t),...ND(e)];function Zje(e,t){let n=0,r=[...e];for(let e of t)r.splice(e-n,1),n++;return dD(r).length?r:[]}var yO=(e,t)=>fD(t)?[]:Zje(e,ND(t).sort((e,t)=>e-t)),bO=(e,t,n)=>{[e[t],e[n]]=[e[n],e[t]]},xO=(e,t,n)=>(e[t]=n,e);function SO(e){let t=SD(),{control:n=t.control,name:r,keyName:i=`id`,shouldUnregister:a,rules:o}=e,[s,c]=H.useState(n._getFieldArray(r)),l=H.useRef(n._getFieldArray(r).map(fO)),u=H.useRef(s),d=H.useRef(r),f=H.useRef(!1);d.current=r,u.current=s,n._names.array.add(r),o&&n.register(r,o),H.useEffect(()=>n._subjects.array.subscribe({next:({values:e,name:t})=>{if(t===d.current||!t){let t=pD(e,d.current);Array.isArray(t)&&(c(t),l.current=t.map(fO))}}}).unsubscribe,[n]);let p=H.useCallback(e=>{f.current=!0,n._setFieldArray(r,e)},[n,r]);return H.useEffect(()=>{if(n._state.action=!1,iO(r,n._names)&&n._subjects.state.next({...n._formState}),f.current&&(!nO(n._options.mode).isOnSubmit||n._formState.isSubmitted)&&!nO(n._options.reValidateMode).isOnSubmit)if(n._options.resolver)n._runSchema([r]).then(e=>{let t=pD(e.errors,r),i=pD(n._formState.errors,r);(i?!t&&i.type||t&&(i.type!==t.type||i.message!==t.message):t&&t.type)&&(t?_D(n._formState.errors,r,t):HD(n._formState.errors,r),n._subjects.state.next({errors:n._formState.errors}))});else{let e=pD(n._fields,r);e&&e._f&&!(nO(n._options.reValidateMode).isOnSubmit&&nO(n._options.mode).isOnSubmit)&&dO(e,n._names.disabled,n._formValues,n._options.criteriaMode===yD.all,n._options.shouldUseNativeValidation,!0).then(e=>!FD(e)&&n._subjects.state.next({errors:sO(n._formState.errors,e,r)}))}n._subjects.state.next({name:r,values:uD(n._formValues)}),n._names.focus&&aO(n._fields,(e,t)=>{if(n._names.focus&&t.startsWith(n._names.focus)&&e.focus)return e.focus(),1}),n._names.focus=``,n._setValid(),f.current=!1},[s,r,n]),H.useEffect(()=>(!pD(n._formValues,r)&&n._setFieldArray(r),()=>{n._options.shouldUnregister||a?n.unregister(r):((e,t)=>{let r=pD(n._fields,e);r&&r._f&&(r._f.mount=t)})(r,!1)}),[r,n,i,a]),{swap:H.useCallback((e,t)=>{let i=n._getFieldArray(r);bO(i,e,t),bO(l.current,e,t),p(i),c(i),n._setFieldArray(r,i,bO,{argA:e,argB:t},!1)},[p,r,n]),move:H.useCallback((e,t)=>{let i=n._getFieldArray(r);_O(i,e,t),_O(l.current,e,t),p(i),c(i),n._setFieldArray(r,i,_O,{argA:e,argB:t},!1)},[p,r,n]),prepend:H.useCallback((e,t)=>{let i=ND(uD(e)),a=vO(n._getFieldArray(r),i);n._names.focus=pO(r,0,t),l.current=vO(l.current,i.map(fO)),p(a),c(a),n._setFieldArray(r,a,vO,{argA:hO(e)})},[p,r,n]),append:H.useCallback((e,t)=>{let i=ND(uD(e)),a=mO(n._getFieldArray(r),i);n._names.focus=pO(r,a.length-1,t),l.current=mO(l.current,i.map(fO)),p(a),c(a),n._setFieldArray(r,a,mO,{argA:hO(e)})},[p,r,n]),remove:H.useCallback(e=>{let t=yO(n._getFieldArray(r),e);l.current=yO(l.current,e),p(t),c(t),!Array.isArray(pD(n._fields,r))&&_D(n._fields,r,void 0),n._setFieldArray(r,t,yO,{argA:e})},[p,r,n]),insert:H.useCallback((e,t,i)=>{let a=ND(uD(t)),o=gO(n._getFieldArray(r),e,a);n._names.focus=pO(r,e,i),l.current=gO(l.current,e,a.map(fO)),p(o),c(o),n._setFieldArray(r,o,gO,{argA:e,argB:hO(t)})},[p,r,n]),update:H.useCallback((e,t)=>{let i=uD(t),a=xO(n._getFieldArray(r),e,i);l.current=[...a].map((t,n)=>!t||n===e?fO():l.current[n]),p(a),c([...a]),n._setFieldArray(r,a,xO,{argA:e,argB:i},!0,!1)},[p,r,n]),replace:H.useCallback(e=>{let t=ND(uD(e));l.current=t.map(fO),p([...t]),c([...t]),n._setFieldArray(r,[...t],e=>e,{},!0,!1)},[p,r,n]),fields:H.useMemo(()=>s.map((e,t)=>({...e,[i]:l.current[t]||fO()})),[s,i])}}var Qje=typeof window<`u`?H.useLayoutEffect:H.useEffect;function CO(e={}){let t=H.useRef(void 0),n=H.useRef(void 0),[r,i]=H.useState({isDirty:!1,isValidating:!1,isLoading:LD(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:LD(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...e.formControl?e.formControl:Xje(e),formState:r},e.formControl&&e.defaultValues&&!LD(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions));let a=t.current.control;return a._options=e,Qje(()=>{let e=a._subscribe({formState:a._proxyFormState,callback:()=>i({...a._formState}),reRenderRoot:!0});return i(e=>({...e,isReady:!0})),a._formState.isReady=!0,e},[a]),H.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),H.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode),e.errors&&!FD(e.errors)&&a._setErrors(e.errors)},[a,e.errors,e.mode,e.reValidateMode]),H.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),H.useEffect(()=>{if(a._proxyFormState.isDirty){let e=a._getDirty();e!==r.isDirty&&a._subjects.state.next({isDirty:e})}},[a,r.isDirty]),H.useEffect(()=>{e.values&&!ED(e.values,n.current)?(a._reset(e.values,a._options.resetOptions),n.current=e.values,i(e=>({...e}))):a._resetDefaultValues()},[a,e.values]),H.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=wD(r,a),t.current}var wO=(e,t,n)=>{if(e&&`reportValidity`in e){let r=pD(n,t);e.setCustomValidity(r&&r.message||``),e.reportValidity()}},TO=(e,t)=>{for(let n in t.fields){let r=t.fields[n];r&&r.ref&&`reportValidity`in r.ref?wO(r.ref,n,e):r.refs&&r.refs.forEach(t=>wO(t,n,e))}},$je=(e,t)=>{t.shouldUseNativeValidation&&TO(e,t);let n={};for(let r in e){let i=pD(t.fields,r),a=Object.assign(e[r]||{},{ref:i&&i.ref});if(eMe(t.names||Object.keys(e),r)){let e=Object.assign({},pD(n,r));_D(e,`root`,a),_D(n,r,e)}else _D(n,r,a)}return n},eMe=(e,t)=>e.some(e=>e.startsWith(t+`.`)),tMe=function(e,t){for(var n={};e.length;){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(`unionErrors`in r){var s=r.unionErrors[0].errors[0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(`unionErrors`in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=MD(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()}return n},EO=function(e,t,n){return n===void 0&&(n={}),function(r,i,a){try{return Promise.resolve(function(i,o){try{var s=Promise.resolve(e[n.mode===`sync`?`parse`:`parseAsync`](r,t)).then(function(e){return a.shouldUseNativeValidation&&TO({},a),{errors:{},values:n.raw?r:e}})}catch(e){return o(e)}return s&&s.then?s.then(void 0,o):s}(0,function(e){if(function(e){return Array.isArray(e?.errors)}(e))return{values:{},errors:$je(tMe(e.errors,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}}},nMe=e=>{if(e instanceof He&&e.body){let t=e.body.extensions;if(t&&Array.isArray(t.validationErrors)&&t.validationErrors.length>0)return t.validationErrors}return[]},DO=({error:e,className:t,onRetry:n,...r})=>{if(!e)return null;let i=nMe(e);return(0,U.jsx)(Sb,{variant:`destructive`,className:W(`mb-2`,t),...r,children:(0,U.jsxs)(wb,{children:[Qb(e),i.length>0&&(0,U.jsx)(`ul`,{className:`mt-1 list-disc pl-4`,children:i.map(e=>(0,U.jsx)(`li`,{children:e.message},e.code??e.message))}),n&&(0,U.jsx)(X,{variant:`ghost`,className:`absolute right-0 top-0`,onClick:n,children:(0,U.jsx)(yf,{size:16})})]})})},rMe=Ou(`inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-zuplo-200 dark:border-zuplo-900/60 bg-zuplo-50 dark:bg-zuplo-950/40 text-zuplo-700 dark:text-zuplo-300`,invert:`border-transparent bg-pink-100 dark:bg-pink-950/40 text-pink-500 dark:text-pink-300`,secondary:`border-transparent bg-gray-200 dark:bg-neutral-700 text-secondary-foreground`,info:`border-transparent bg-blue-200 dark:bg-blue-950/50 text-blue-500 dark:text-blue-400`,warn:`border-amber-200 dark:border-amber-900/60 bg-amber-100 dark:bg-amber-950/40 text-amber-800 dark:text-amber-300`,destructive:`border-transparent bg-destructive text-white`,"destructive-solid":`border-transparent bg-destructive text-white`,ghost:`border-transparent text-destructive-foreground`,outline:`text-foreground`},button:{false:``,true:`cursor-pointer hover:bg-gray-200`},size:{default:`text-xs`,sm:`text-[10px] py-0.5 px-1.5`,lg:`text-sm py-1 px-3.5`}},compoundVariants:[{button:!0,variant:`default`,className:`hover:bg-primary/80`},{button:!0,variant:`secondary`,className:`bg-muted hover:bg-muted/80`},{button:!0,variant:`destructive`,className:`hover:bg-destructive/80`}],defaultVariants:{variant:`default`,button:!1}});function OO({className:e,variant:t,button:n,size:r,...i}){return(0,U.jsx)(`div`,{className:W(rMe({variant:t,button:n,size:r}),e),...i})}var iMe=Ou(`rounded-xl border bg-card text-card-foreground shadow-xs`,{variants:{variant:{default:``,muted:`border-gray-300 dark:border-neutral-700 bg-gray-100 dark:bg-neutral-800`,primary:`border-pink-200 dark:border-pink-900/50 bg-zuplo-pink-light dark:bg-zuplo-950/30`,info:`bg-blue-50 dark:bg-blue-950/40 border-blue-200 dark:border-blue-900/60`,danger:`bg-red-50 dark:bg-red-950/40 border-red-200 dark:border-red-900/60`},offset:{default:``,md:[`px-4`,`py-4`]}},defaultVariants:{variant:`default`,offset:`default`}}),aMe=Ou(`flex items-center px-6 py-2 border-t rounded-b-xl`,{variants:{variant:{default:``,danger:`bg-red-100 dark:bg-red-950/40 border-red-200 dark:border-red-900/60`,muted:`bg-surface-muted border-neutral-200 dark:border-neutral-700`}},defaultVariants:{variant:`default`}}),kO=H.forwardRef(({className:e,variant:t,offset:n,...r},i)=>(0,U.jsx)(`div`,{ref:i,className:W(iMe({variant:t,offset:n,className:e})),...r}));kO.displayName=`Card`;var AO=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(`div`,{ref:n,className:W(`flex flex-col space-y-1.5 p-6 pb-0 text-lg`,e),...t}));AO.displayName=`CardHeader`;var jO=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(`h3`,{ref:n,className:W(`text-xl text-gray-900 dark:text-white font-semibold leading-none`,e),...t}));jO.displayName=`CardTitle`;var MO=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(`p`,{ref:n,className:W(`text-sm py-2`,e),...t}));MO.displayName=`CardDescription`;var NO=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(`div`,{ref:n,className:W(`p-6 pt-0`,e),...t}));NO.displayName=`CardContent`;var PO=H.forwardRef(({className:e,variant:t,...n},r)=>(0,U.jsx)(`div`,{ref:r,className:W(aMe({variant:t,className:e})),...n}));PO.displayName=`CardFooter`;function FO({className:e,...t}){return(0,U.jsx)(`div`,{className:W(`animate-pulse rounded-md bg-primary/10`,e),...t})}var IO=`**********************************************`,oMe=({secret:e=IO,reveal:t=!1,loading:n,mask:r=IO,className:i})=>(0,U.jsxs)(`div`,{className:W(`ph-no-capture font-mono shrink bg-surface-muted rounded-sm border border-border px-2 truncate relative overflow-hidden`,i),children:[t?e:r,(0,U.jsx)(FO,{className:W(`hidden absolute inset-0 h-full bg-background/80`,n&&`block`)})]});function LO(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function sMe(e,t=[]){let n=[];function r(t,r){let i=H.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=H.useMemo(()=>o,Object.values(o));return(0,U.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=H.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>H.createContext(e));return function(n){let r=n?.[e]||t;return H.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,cMe(i,...t)]}function cMe(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return H.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function RO(e,t=[]){let n=[];function r(t,r){let i=H.createContext(r),a=n.length;n=[...n,r];function o(t){let{scope:n,children:r,...o}=t,s=n?.[e][a]||i,c=H.useMemo(()=>o,Object.values(o));return(0,U.jsx)(s.Provider,{value:c,children:r})}function s(n,o){let s=o?.[e][a]||i,c=H.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return o.displayName=t+`Provider`,[o,s]}let i=()=>{let t=n.map(e=>H.createContext(e));return function(n){let r=n?.[e]||t;return H.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,lMe(i,...t)]}function lMe(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return H.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function uMe(e,t){typeof e==`function`?e(t):e!=null&&(e.current=t)}function zO(...e){return t=>e.forEach(e=>uMe(e,t))}function BO(...e){return H.useCallback(zO(...e),e)}var VO=H.forwardRef((e,t)=>{let{children:n,...r}=e,i=H.Children.toArray(n),a=i.find(fMe);if(a){let e=a.props.children,n=i.map(t=>t===a?H.Children.count(e)>1?H.Children.only(null):H.isValidElement(e)?e.props.children:null:t);return(0,U.jsx)(HO,{...r,ref:t,children:H.isValidElement(e)?H.cloneElement(e,void 0,n):null})}return(0,U.jsx)(HO,{...r,ref:t,children:n})});VO.displayName=`Slot`;var HO=H.forwardRef((e,t)=>{let{children:n,...r}=e;if(H.isValidElement(n)){let e=mMe(n);return H.cloneElement(n,{...pMe(r,n.props),ref:t?zO(t,e):e})}return H.Children.count(n)>1?H.Children.only(null):null});HO.displayName=`SlotClone`;var dMe=({children:e})=>(0,U.jsx)(U.Fragment,{children:e});function fMe(e){return H.isValidElement(e)&&e.type===dMe}function pMe(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{a(...e),i(...e)}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function mMe(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function hMe(e){let t=e+`CollectionProvider`,[n,r]=RO(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=H.useRef(null),a=H.useRef(new Map).current;return(0,U.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=H.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,U.jsx)(VO,{ref:BO(t,a(s,n).collectionRef),children:r})});c.displayName=s;let l=e+`CollectionItemSlot`,u=`data-radix-collection-item`,d=H.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=H.useRef(null),s=BO(t,o),c=a(l,n);return H.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,U.jsx)(VO,{[u]:``,ref:s,children:r})});d.displayName=l;function f(t){let n=a(e+`CollectionConsumer`,t);return H.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${u}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:c,ItemSlot:d},f,r]}var UO=globalThis?.document?H.useLayoutEffect:()=>{},gMe=H.useId||(()=>void 0),_Me=0;function WO(e){let[t,n]=H.useState(gMe());return UO(()=>{e||n(e=>e??String(_Me++))},[e]),e||(t?`radix-${t}`:``)}var GO=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=H.forwardRef((e,n)=>{let{asChild:r,...i}=e,a=r?VO:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,U.jsx)(a,{...i,ref:n})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function KO(e){let t=H.useRef(e);return H.useEffect(()=>{t.current=e}),H.useMemo(()=>(...e)=>t.current?.(...e),[])}function qO({prop:e,defaultProp:t,onChange:n=()=>{}}){let[r,i]=vMe({defaultProp:t,onChange:n}),a=e!==void 0,o=a?e:r,s=KO(n);return[o,H.useCallback(t=>{if(a){let n=typeof t==`function`?t(e):t;n!==e&&s(n)}else i(t)},[a,e,i,s])]}function vMe({defaultProp:e,onChange:t}){let n=H.useState(e),[r]=n,i=H.useRef(r),a=KO(t);return H.useEffect(()=>{i.current!==r&&(a(r),i.current=r)},[r,i,a]),n}var yMe=H.createContext(void 0);function JO(e){let t=H.useContext(yMe);return e||t||`ltr`}var YO=`rovingFocusGroup.onEntryFocus`,bMe={bubbles:!1,cancelable:!0},XO=`RovingFocusGroup`,[ZO,QO,xMe]=hMe(XO),[SMe,$O]=RO(XO,[xMe]),[CMe,wMe]=SMe(XO),ek=H.forwardRef((e,t)=>(0,U.jsx)(ZO.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,U.jsx)(ZO.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,U.jsx)(TMe,{...e,ref:t})})}));ek.displayName=XO;var TMe=H.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=H.useRef(null),p=BO(t,f),m=JO(a),[h=null,g]=qO({prop:o,defaultProp:s,onChange:c}),[_,v]=H.useState(!1),y=KO(l),b=QO(n),x=H.useRef(!1),[S,C]=H.useState(0);return H.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(YO,y),()=>e.removeEventListener(YO,y)},[y]),(0,U.jsx)(CMe,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:H.useCallback(e=>g(e),[g]),onItemShiftTab:H.useCallback(()=>v(!0),[]),onFocusableItemAdd:H.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:H.useCallback(()=>C(e=>e-1),[]),children:(0,U.jsx)(GO.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:LO(e.onMouseDown,()=>{x.current=!0}),onFocus:LO(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(YO,bMe);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);rk([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:LO(e.onBlur,()=>v(!1))})})}),tk=`RovingFocusGroupItem`,nk=H.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,...o}=e,s=WO(),c=a||s,l=wMe(tk,n),u=l.currentTabStopId===c,d=QO(n),{onFocusableItemAdd:f,onFocusableItemRemove:p}=l;return H.useEffect(()=>{if(r)return f(),()=>p()},[r,f,p]),(0,U.jsx)(ZO.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:(0,U.jsx)(GO.span,{tabIndex:u?0:-1,"data-orientation":l.orientation,...o,ref:t,onMouseDown:LO(e.onMouseDown,e=>{r?l.onItemFocus(c):e.preventDefault()}),onFocus:LO(e.onFocus,()=>l.onItemFocus(c)),onKeyDown:LO(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){l.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=OMe(e,l.orientation,l.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=d().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=l.loop?kMe(n,r+1):n.slice(r+1)}setTimeout(()=>rk(n))}})})})});nk.displayName=tk;var EMe={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function DMe(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function OMe(e,t,n){let r=DMe(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return EMe[r]}function rk(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function kMe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var AMe=ek,jMe=nk;function MMe(e,t){return H.useReducer((e,n)=>t[e][n]??e,e)}var ik=e=>{let{present:t,children:n}=e,r=NMe(t),i=typeof n==`function`?n({present:r.isPresent}):H.Children.only(n),a=BO(r.ref,PMe(i));return typeof n==`function`||r.isPresent?H.cloneElement(i,{ref:a}):null};ik.displayName=`Presence`;function NMe(e){let[t,n]=H.useState(),r=H.useRef({}),i=H.useRef(e),a=H.useRef(`none`),[o,s]=MMe(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return H.useEffect(()=>{let e=ak(r.current);a.current=o===`mounted`?e:`none`},[o]),UO(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=ak(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),UO(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=ak(r.current).includes(a.animationName);if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=ak(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:H.useCallback(e=>{e&&(r.current=getComputedStyle(e)),n(e)},[])}}function ak(e){return e?.animationName||`none`}function PMe(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ok=`Tabs`,[FMe,IMe]=sMe(ok,[$O]),sk=$O(),[LMe,ck]=FMe(ok),lk=H.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=JO(s),[d,f]=qO({prop:r,onChange:i,defaultProp:a});return(0,U.jsx)(LMe,{scope:n,baseId:WO(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,U.jsx)(GO.div,{dir:u,"data-orientation":o,...l,ref:t})})});lk.displayName=ok;var uk=`TabsList`,dk=H.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=ck(uk,n),o=sk(n);return(0,U.jsx)(AMe,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,U.jsx)(GO.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});dk.displayName=uk;var fk=`TabsTrigger`,pk=H.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=ck(fk,n),s=sk(n),c=gk(o.baseId,r),l=_k(o.baseId,r),u=r===o.value;return(0,U.jsx)(jMe,{asChild:!0,...s,focusable:!i,active:u,children:(0,U.jsx)(GO.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:LO(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:LO(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:LO(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});pk.displayName=fk;var mk=`TabsContent`,hk=H.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=ck(mk,n),c=gk(s.baseId,r),l=_k(s.baseId,r),u=r===s.value,d=H.useRef(u);return H.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,U.jsx)(ik,{present:i||u,children:({present:n})=>(0,U.jsx)(GO.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});hk.displayName=mk;function gk(e,t){return`${e}-trigger-${t}`}function _k(e,t){return`${e}-content-${t}`}var vk=lk,yk=dk,bk=pk,xk=hk,Sk=vk,RMe=Ou(`inline-flex items-center justify-center rounded-md bg-muted text-muted-foreground`,{variants:{variant:{default:``,underline:`w-full justify-start gap-6 rounded-none border-b border-border bg-transparent`},size:{sm:`h-8 px-1 py-1`,default:`h-10 p-1`}},compoundVariants:[{variant:`underline`,className:`h-auto p-0`}],defaultVariants:{variant:`default`,size:`default`}}),zMe=Ou(`inline-flex items-center justify-center whitespace-nowrap rounded-xs font-medium ring-offset-background transition-all focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-xs text-sm`,{variants:{variant:{default:``,underline:`gap-1.5 border-b-2 border-transparent text-muted-foreground hover:text-foreground data-[state=active]:border-brand data-[state=active]:bg-transparent data-[state=active]:text-brand data-[state=active]:shadow-none`},size:{sm:`px-2 py-0.5 rounded-sm`,default:`px-3 py-1.5`}},compoundVariants:[{variant:`underline`,className:`rounded-none px-1 py-2`}],defaultVariants:{variant:`default`,size:`default`}}),Ck=H.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,U.jsx)(yk,{ref:i,className:W(RMe({variant:t,size:n}),e),...r}));Ck.displayName=yk.displayName;var wk=H.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,U.jsx)(bk,{ref:i,className:W(zMe({variant:t,size:n}),e),...r}));wk.displayName=bk.displayName;var Tk=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(xk,{ref:n,className:W(`data-[state=inactive]:hidden`,`mt-2 ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));Tk.displayName=xk.displayName;var BMe=a(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()})),Ek=(0,H.createContext)({});function VMe(e){let t=(0,H.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Dk=(0,H.createContext)(null),Ok=(0,H.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function HMe(e=!0){let t=(0,H.useContext)(Dk);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,H.useId)();(0,H.useEffect)(()=>{e&&i(a)},[e]);let o=(0,H.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var kk=typeof window<`u`,UMe=kk?H.useLayoutEffect:H.useEffect,Ak=e=>e,jk=Ak,Mk=Ak,Nk={skipAnimations:!1,useManualTiming:!1};function WMe(e){let t=new Set,n=new Set,r=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(c.schedule(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.has(e)||s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0,[t,n]=[n,t],t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var Pk=[`read`,`resolveKeyframes`,`update`,`preRender`,`render`,`postRender`],GMe=40;function Fk(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Pk.reduce((e,t)=>(e[t]=WMe(a),e),{}),{read:s,resolveKeyframes:c,update:l,preRender:u,render:d,postRender:f}=o,p=()=>{let a=Nk.useManualTiming?i.timestamp:performance.now();n=!1,i.delta=r?1e3/60:Math.max(Math.min(a-i.timestamp,GMe),1),i.timestamp=a,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(p))},m=()=>{n=!0,r=!0,i.isProcessing||e(p)};return{schedule:Pk.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||m(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<Pk.length;t++)o[Pk[t]].cancel(e)},state:i,steps:o}}var{schedule:Ik,cancel:Lk,state:Rk,steps:zk}=Fk(typeof requestAnimationFrame<`u`?requestAnimationFrame:Ak,!0),Bk=(0,H.createContext)({strict:!1}),Vk={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},Hk={};for(let e in Vk)Hk[e]={isEnabled:t=>Vk[e].some(e=>!!t[e])};function KMe(e){for(let t in e)Hk[t]={...Hk[t],...e[t]}}var qMe=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.ignoreStrict.viewport`.split(`.`));function Uk(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||qMe.has(e)}var Wk=e=>!Uk(e);function JMe(e){e&&(Wk=t=>t.startsWith(`on`)?!Uk(t):e(t))}try{JMe((an(),e(h)).default)}catch{}function YMe(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||(Wk(i)||n===!0&&Uk(i)||!t&&!Uk(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}function XMe(e){if(typeof Proxy>`u`)return e;let t=new Map;return new Proxy((...t)=>e(...t),{get:(n,r)=>r===`create`?e:(t.has(r)||t.set(r,e(r)),t.get(r))})}var Gk=(0,H.createContext)({});function Kk(e){return typeof e==`string`||Array.isArray(e)}function qk(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}var Jk=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Yk=[`initial`,...Jk];function Xk(e){return qk(e.animate)||Yk.some(t=>Kk(e[t]))}function Zk(e){return!!(Xk(e)||e.variants)}function ZMe(e,t){if(Xk(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Kk(t)?t:void 0,animate:Kk(n)?n:void 0}}return e.inherit===!1?{}:t}function QMe(e){let{initial:t,animate:n}=ZMe(e,(0,H.useContext)(Gk));return(0,H.useMemo)(()=>({initial:t,animate:n}),[Qk(t),Qk(n)])}function Qk(e){return Array.isArray(e)?e.join(` `):e}var $Me=Symbol.for(`motionComponentSymbol`);function $k(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function eNe(e,t,n){return(0,H.useCallback)(r=>{r&&e.onMount&&e.onMount(r),t&&(r?t.mount(r):t.unmount()),n&&(typeof n==`function`?n(r):$k(n)&&(n.current=r))},[t])}var eA=e=>e.replace(/([a-z])([A-Z])/gu,`$1-$2`).toLowerCase(),tA=`data-`+eA(`framerAppearId`),{schedule:nA,cancel:tNe}=Fk(queueMicrotask,!1),rA=(0,H.createContext)({});function nNe(e,t,n,r,i){let{visualElement:a}=(0,H.useContext)(Gk),o=(0,H.useContext)(Bk),s=(0,H.useContext)(Dk),c=(0,H.useContext)(Ok).reducedMotion,l=(0,H.useRef)(null);r||=o.renderer,!l.current&&r&&(l.current=r(e,{visualState:t,parent:a,props:n,presenceContext:s,blockInitialAnimation:s?s.initial===!1:!1,reducedMotionConfig:c}));let u=l.current,d=(0,H.useContext)(rA);u&&!u.projection&&i&&(u.type===`html`||u.type===`svg`)&&rNe(l.current,n,i,d);let f=(0,H.useRef)(!1);(0,H.useInsertionEffect)(()=>{u&&f.current&&u.update(n,s)});let p=n[tA],m=(0,H.useRef)(!!p&&!window.MotionHandoffIsComplete?.call(window,p)&&window.MotionHasOptimisedAnimation?.call(window,p));return UMe(()=>{u&&(f.current=!0,window.MotionIsMounted=!0,u.updateFeatures(),nA.render(u.render),m.current&&u.animationState&&u.animationState.animateChanges())}),(0,H.useEffect)(()=>{u&&(!m.current&&u.animationState&&u.animationState.animateChanges(),m.current&&=(queueMicrotask(()=>{var e;(e=window.MotionHandoffMarkAsComplete)==null||e.call(window,p)}),!1))}),u}function rNe(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:iA(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&$k(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,layoutScroll:c,layoutRoot:l})}function iA(e){if(e)return e.options.allowProjection===!1?iA(e.parent):e.projection}function iNe({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:r,Component:i}){e&&KMe(e);function a(a,o){let s,c={...(0,H.useContext)(Ok),...a,layoutId:aNe(a)},{isStatic:l}=c,u=QMe(a),d=r(a,l);if(!l&&kk){oNe(c,e);let n=sNe(c);s=n.MeasureLayout,u.visualElement=nNe(i,d,c,t,n.ProjectionNode)}return(0,U.jsxs)(Gk.Provider,{value:u,children:[s&&u.visualElement?(0,U.jsx)(s,{visualElement:u.visualElement,...c}):null,n(i,a,eNe(d,u.visualElement,o),d,l,u.visualElement)]})}a.displayName=`motion.${typeof i==`string`?i:`create(${i.displayName??i.name??``})`}`;let o=(0,H.forwardRef)(a);return o[$Me]=i,o}function aNe({layoutId:e}){let t=(0,H.useContext)(Ek).id;return t&&e!==void 0?t+`-`+e:e}function oNe(e,t){(0,H.useContext)(Bk).strict}function sNe(e){let{drag:t,layout:n}=Hk;if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}var cNe=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function aA(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(cNe.indexOf(e)>-1||/[A-Z]/u.test(e))}function oA(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function sA(e,t,n,r){if(typeof t==`function`){let[i,a]=oA(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=oA(r);t=t(n===void 0?e.custom:n,i,a)}return t}var cA=e=>Array.isArray(e),lNe=e=>!!(e&&typeof e==`object`&&e.mix&&e.toValue),uNe=e=>cA(e)?e[e.length-1]||0:e,lA=e=>!!(e&&e.getVelocity);function uA(e){let t=lA(e)?e.get():e;return lNe(t)?t.toValue():t}function dNe({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},r,i,a){let o={latestValues:fNe(r,i,a,e),renderState:t()};return n&&(o.onMount=e=>n({props:r,current:e,...o}),o.onUpdate=e=>n(e)),o}var dA=e=>(t,n)=>{let r=(0,H.useContext)(Gk),i=(0,H.useContext)(Dk),a=()=>dNe(e,t,r,i);return n?a():VMe(a)};function fNe(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=uA(a[e]);let{initial:o,animate:s}=e,c=Xk(e),l=Zk(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!qk(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=sA(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var fA=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],pA=new Set(fA),mA=e=>t=>typeof t==`string`&&t.startsWith(e),hA=mA(`--`),pNe=mA(`var(--`),gA=e=>pNe(e)?mNe.test(e.split(`/*`)[0].trim()):!1,mNe=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,_A=(e,t)=>t&&typeof e==`number`?t.transform(e):e,vA=(e,t,n)=>n>t?t:n<e?e:n,yA={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},bA={...yA,transform:e=>vA(0,1,e)},xA={...yA,default:1},SA=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),CA=SA(`deg`),wA=SA(`%`),TA=SA(`px`),hNe=SA(`vh`),gNe=SA(`vw`),EA={...wA,parse:e=>wA.parse(e)/100,transform:e=>wA.transform(e*100)},_Ne={borderWidth:TA,borderTopWidth:TA,borderRightWidth:TA,borderBottomWidth:TA,borderLeftWidth:TA,borderRadius:TA,radius:TA,borderTopLeftRadius:TA,borderTopRightRadius:TA,borderBottomRightRadius:TA,borderBottomLeftRadius:TA,width:TA,maxWidth:TA,height:TA,maxHeight:TA,top:TA,right:TA,bottom:TA,left:TA,padding:TA,paddingTop:TA,paddingRight:TA,paddingBottom:TA,paddingLeft:TA,margin:TA,marginTop:TA,marginRight:TA,marginBottom:TA,marginLeft:TA,backgroundPositionX:TA,backgroundPositionY:TA},vNe={rotate:CA,rotateX:CA,rotateY:CA,rotateZ:CA,scale:xA,scaleX:xA,scaleY:xA,scaleZ:xA,skew:CA,skewX:CA,skewY:CA,distance:TA,translateX:TA,translateY:TA,translateZ:TA,x:TA,y:TA,z:TA,perspective:TA,transformPerspective:TA,opacity:bA,originX:EA,originY:EA,originZ:TA},DA={...yA,transform:Math.round},OA={..._Ne,...vNe,zIndex:DA,size:TA,fillOpacity:bA,strokeOpacity:bA,numOctaves:DA},yNe={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},bNe=fA.length;function xNe(e,t,n){let r=``,i=!0;for(let a=0;a<bNe;a++){let o=fA[a],s=e[o];if(s===void 0)continue;let c=!0;if(c=typeof s==`number`?s===(o.startsWith(`scale`)?1:0):parseFloat(s)===0,!c||n){let e=_A(s,OA[o]);if(!c){i=!1;let t=yNe[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function kA(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(pA.has(e)){o=!0;continue}else if(hA(e)){i[e]=n;continue}else{let t=_A(n,OA[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=xNe(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}var SNe={offset:`stroke-dashoffset`,array:`stroke-dasharray`},CNe={offset:`strokeDashoffset`,array:`strokeDasharray`};function wNe(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?SNe:CNe;e[a.offset]=TA.transform(-r);let o=TA.transform(t),s=TA.transform(n);e[a.array]=`${o} ${s}`}function AA(e,t,n){return typeof e==`string`?e:TA.transform(t+n*e)}function TNe(e,t,n){return`${AA(t,e.x,e.width)} ${AA(n,e.y,e.height)}`}function jA(e,{attrX:t,attrY:n,attrScale:r,originX:i,originY:a,pathLength:o,pathSpacing:s=1,pathOffset:c=0,...l},u,d){if(kA(e,l,d),u){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:f,style:p,dimensions:m}=e;f.transform&&(m&&(p.transform=f.transform),delete f.transform),m&&(i!==void 0||a!==void 0||p.transform)&&(p.transformOrigin=TNe(m,i===void 0?.5:i,a===void 0?.5:a)),t!==void 0&&(f.x=t),n!==void 0&&(f.y=n),r!==void 0&&(f.scale=r),o!==void 0&&wNe(f,o,s,c,!1)}var MA=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),NA=()=>({...MA(),attrs:{}}),PA=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function FA(e,{style:t,vars:n},r,i){Object.assign(e.style,t,i&&i.getProjectionStyles(r));for(let t in n)e.style.setProperty(t,n[t])}var IA=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]);function LA(e,t,n,r){FA(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(IA.has(n)?n:eA(n),t.attrs[n])}var RA={};function ENe(e){Object.assign(RA,e)}function zA(e,{layout:t,layoutId:n}){return pA.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!RA[e]||e===`opacity`)}function BA(e,t,n){let{style:r}=e,i={};for(let a in r)(lA(r[a])||t.style&&lA(t.style[a])||zA(a,e)||n?.getValue(a)?.liveStyle!==void 0)&&(i[a]=r[a]);return i}function VA(e,t,n){let r=BA(e,t,n);for(let n in e)if(lA(e[n])||lA(t[n])){let t=fA.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}function DNe(e,t){try{t.dimensions=typeof e.getBBox==`function`?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}var HA=[`x`,`y`,`width`,`height`,`cx`,`cy`,`r`],ONe={useVisualState:dA({scrapeMotionValuesFromProps:VA,createRenderState:NA,onUpdate:({props:e,prevProps:t,current:n,renderState:r,latestValues:i})=>{if(!n)return;let a=!!e.drag;if(!a){for(let e in i)if(pA.has(e)){a=!0;break}}if(!a)return;let o=!t;if(t)for(let n=0;n<HA.length;n++){let r=HA[n];e[r]!==t[r]&&(o=!0)}o&&Ik.read(()=>{DNe(n,r),Ik.render(()=>{jA(r,i,PA(n.tagName),e.transformTemplate),LA(n,r)})})}})},kNe={useVisualState:dA({scrapeMotionValuesFromProps:BA,createRenderState:MA})};function UA(e,t,n){for(let r in t)!lA(t[r])&&!zA(r,n)&&(e[r]=t[r])}function ANe({transformTemplate:e},t){return(0,H.useMemo)(()=>{let n=MA();return kA(n,t,e),Object.assign({},n.vars,n.style)},[t])}function jNe(e,t){let n=e.style||{},r={};return UA(r,n,e),Object.assign(r,ANe(e,t)),r}function MNe(e,t){let n={},r=jNe(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}function NNe(e,t,n,r){let i=(0,H.useMemo)(()=>{let n=NA();return jA(n,t,PA(r),e.transformTemplate),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};UA(t,e.style,e),i.style={...t,...i.style}}return i}function PNe(e=!1){return(t,n,r,{latestValues:i},a)=>{let o=(aA(t)?NNe:MNe)(n,i,a,t),s=YMe(n,typeof t==`string`,e),c=t===H.Fragment?{}:{...s,...o,ref:r},{children:l}=n,u=(0,H.useMemo)(()=>lA(l)?l.get():l,[l]);return(0,H.createElement)(t,{...c,children:u})}}function FNe(e,t){return function(n,{forwardMotionProps:r}={forwardMotionProps:!1}){return iNe({...aA(n)?ONe:kNe,preloadedFeatures:e,useRender:PNe(r),createVisualElement:t,Component:n})}}function WA(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function GA(e,t,n){let r=e.getProps();return sA(r,t,n===void 0?r.custom:n,e)}function KA(e,t){return e?e[t]||e.default||e:void 0}var qA=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...fA]),JA;function INe(){JA=void 0}var YA={now:()=>(JA===void 0&&YA.set(Rk.isProcessing||Nk.useManualTiming?Rk.timestamp:performance.now()),JA),set:e=>{JA=e,queueMicrotask(INe)}};function XA(e,t){e.indexOf(t)===-1&&e.push(t)}function ZA(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var QA=class{constructor(){this.subscriptions=[]}add(e){return XA(this.subscriptions,e),()=>ZA(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}};function $A(e,t){return t?1e3/t*e:0}var ej=30,LNe=e=>!isNaN(parseFloat(e)),tj={current:void 0},RNe=class{constructor(e,t={}){this.version=`11.18.2`,this.canTrackVelocity=null,this.events={},this.updateAndNotify=(e,t=!0)=>{let n=YA.now();this.updatedAt!==n&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),t&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=YA.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=LNe(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new QA);let n=this.events[e].add(t);return e===`change`?()=>{n(),Ik.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e,t=!0){!t||!this.passiveEffect?this.updateAndNotify(e,t):this.passiveEffect(e,this.updateAndNotify)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return tj.current&&tj.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=YA.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>ej)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,ej);return $A(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function nj(e,t){return new RNe(e,t)}function zNe(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,nj(n))}function BNe(e,t){let{transitionEnd:n={},transition:r={},...i}=GA(e,t)||{};i={...i,...n};for(let t in i)zNe(e,t,uNe(i[t]))}function VNe(e){return!!(lA(e)&&e.add)}function rj(e,t){let n=e.getValue(`willChange`);if(VNe(n))return n.add(t)}function ij(e){return e.props[tA]}function aj(e){let t;return()=>(t===void 0&&(t=e()),t)}var HNe=aj(()=>window.ScrollTimeline!==void 0),UNe=class{constructor(e){this.stop=()=>this.runAll(`stop`),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>`finished`in e?e.finished:e))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;n<this.animations.length;n++)this.animations[n][e]=t}attachTimeline(e,t){let n=this.animations.map(n=>{if(HNe()&&n.attachTimeline)return n.attachTimeline(e);if(typeof t==`function`)return t(n)});return()=>{n.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll(`time`)}set time(e){this.setAll(`time`,e)}get speed(){return this.getAll(`speed`)}set speed(e){this.setAll(`speed`,e)}get startTime(){return this.getAll(`startTime`)}get duration(){let e=0;for(let t=0;t<this.animations.length;t++)e=Math.max(e,this.animations[t].duration);return e}runAll(e){this.animations.forEach(t=>t[e]())}flatten(){this.runAll(`flatten`)}play(){this.runAll(`play`)}pause(){this.runAll(`pause`)}cancel(){this.runAll(`cancel`)}complete(){this.runAll(`complete`)}},WNe=class extends UNe{then(e,t){return Promise.all(this.animations).then(e).catch(t)}},oj=e=>e*1e3,sj=e=>e/1e3,cj={current:!1};function lj(e){return typeof e==`function`}function uj(e,t){e.timeline=t,e.onfinish=null}var dj=e=>Array.isArray(e)&&typeof e[0]==`number`,GNe={linearEasing:void 0};function KNe(e,t){let n=aj(e);return()=>GNe[t]??n()}var fj=KNe(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),pj=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},mj=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=e(pj(0,i-1,t))+`, `;return`linear(${r.substring(0,r.length-2)})`};function hj(e){return!!(typeof e==`function`&&fj()||!e||typeof e==`string`&&(e in _j||fj())||dj(e)||Array.isArray(e)&&e.every(hj))}var gj=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,_j={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:gj([0,.65,.55,1]),circOut:gj([.55,0,1,.45]),backIn:gj([.31,.01,.66,-.59]),backOut:gj([.33,1.53,.69,.99])};function vj(e,t){if(e)return typeof e==`function`&&fj()?mj(e,t):dj(e)?gj(e):Array.isArray(e)?e.map(e=>vj(e,t)||_j.easeOut):_j[e]}var yj=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,qNe=1e-7,JNe=12;function YNe(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=yj(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>qNe&&++s<JNe);return o}function bj(e,t,n,r){if(e===t&&n===r)return Ak;let i=t=>YNe(t,0,1,e,n);return e=>e===0||e===1?e:yj(i(e),t,r)}var xj=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Sj=e=>t=>1-e(1-t),Cj=bj(.33,1.53,.69,.99),wj=Sj(Cj),Tj=xj(wj),Ej=e=>(e*=2)<1?.5*wj(e):.5*(2-2**(-10*(e-1))),Dj=e=>1-Math.sin(Math.acos(e)),Oj=Sj(Dj),kj=xj(Dj),Aj=e=>/^0[^.\s]+$/u.test(e);function XNe(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Aj(e)}var jj=e=>Math.round(e*1e5)/1e5,Mj=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function ZNe(e){return e==null}var QNe=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Nj=(e,t)=>n=>!!(typeof n==`string`&&QNe.test(n)&&n.startsWith(e)||t&&!ZNe(n)&&Object.prototype.hasOwnProperty.call(n,t)),Pj=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Mj);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},$Ne=e=>vA(0,255,e),Fj={...yA,transform:e=>Math.round($Ne(e))},Ij={test:Nj(`rgb`,`red`),parse:Pj(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Fj.transform(e)+`, `+Fj.transform(t)+`, `+Fj.transform(n)+`, `+jj(bA.transform(r))+`)`};function ePe(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var Lj={test:Nj(`#`),parse:ePe,transform:Ij.transform},Rj={test:Nj(`hsl`,`hue`),parse:Pj(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+wA.transform(jj(t))+`, `+wA.transform(jj(n))+`, `+jj(bA.transform(r))+`)`},zj={test:e=>Ij.test(e)||Lj.test(e)||Rj.test(e),parse:e=>Ij.test(e)?Ij.parse(e):Rj.test(e)?Rj.parse(e):Lj.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Ij.transform(e):Rj.transform(e)},tPe=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function nPe(e){return isNaN(e)&&typeof e==`string`&&(e.match(Mj)?.length||0)+(e.match(tPe)?.length||0)>0}var Bj=`number`,Vj=`color`,rPe=`var`,iPe=`var(`,Hj="${}",aPe=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Uj(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(aPe,e=>(zj.test(e)?(r.color.push(a),i.push(Vj),n.push(zj.parse(e))):e.startsWith(iPe)?(r.var.push(a),i.push(rPe),n.push(e)):(r.number.push(a),i.push(Bj),n.push(parseFloat(e))),++a,Hj)).split(Hj),indexes:r,types:i}}function Wj(e){return Uj(e).values}function Gj(e){let{split:t,types:n}=Uj(e),r=t.length;return e=>{let i=``;for(let a=0;a<r;a++)if(i+=t[a],e[a]!==void 0){let t=n[a];t===Bj?i+=jj(e[a]):t===Vj?i+=zj.transform(e[a]):i+=e[a]}return i}}var oPe=e=>typeof e==`number`?0:e;function sPe(e){let t=Wj(e);return Gj(e)(t.map(oPe))}var Kj={test:nPe,parse:Wj,createTransformer:Gj,getAnimatableNone:sPe},cPe=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function lPe(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Mj)||[];if(!r)return e;let i=n.replace(r,``),a=cPe.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var uPe=/\b([a-z-]*)\(.*?\)/gu,qj={...Kj,getAnimatableNone:e=>{let t=e.match(uPe);return t?t.map(lPe).join(` `):e}},dPe={...OA,color:zj,backgroundColor:zj,outlineColor:zj,fill:zj,stroke:zj,borderColor:zj,borderTopColor:zj,borderRightColor:zj,borderBottomColor:zj,borderLeftColor:zj,filter:qj,WebkitFilter:qj},Jj=e=>dPe[e];function Yj(e,t){let n=Jj(e);return n!==qj&&(n=Kj),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var fPe=new Set([`auto`,`none`,`0`]);function pPe(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!fPe.has(t)&&Uj(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=Yj(n,i)}var Xj=e=>e===yA||e===TA,Zj=(e,t)=>parseFloat(e.split(`, `)[t]),Qj=(e,t)=>(n,{transform:r})=>{if(r===`none`||!r)return 0;let i=r.match(/^matrix3d\((.+)\)$/u);if(i)return Zj(i[1],t);{let t=r.match(/^matrix\((.+)\)$/u);return t?Zj(t[1],e):0}},mPe=new Set([`x`,`y`,`z`]),hPe=fA.filter(e=>!mPe.has(e));function gPe(e){let t=[];return hPe.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var $j={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:Qj(4,13),y:Qj(5,14)};$j.translateX=$j.x,$j.translateY=$j.y;var eM=new Set,tM=!1,nM=!1;function rM(){if(nM){let e=Array.from(eM).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=gPe(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{var r;(r=e.getValue(t))==null||r.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}nM=!1,tM=!1,eM.forEach(e=>e.complete()),eM.clear()}function iM(){eM.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(nM=!0)})}function _Pe(){iM(),rM()}var aM=class{constructor(e,t,n,r,i,a=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.isScheduled=!0,this.isAsync?(eM.add(this),tM||(tM=!0,Ik.read(iM),Ik.resolveKeyframes(rM))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;for(let i=0;i<e.length;i++)if(e[i]===null)if(i===0){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}else e[i]=e[i-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),eM.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,eM.delete(this))}resume(){this.isComplete||this.scheduleResolve()}},oM=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),vPe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function yPe(e){let t=vPe.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}var bPe=4;function sM(e,t,n=1){Mk(n<=bPe,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`);let[r,i]=yPe(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return oM(e)?parseFloat(e):e}return gA(i)?sM(i,t,n+1):i}var cM=e=>t=>t.test(e),lM=[yA,TA,wA,CA,gNe,hNe,{test:e=>e===`auto`,parse:e=>e}],uM=e=>lM.find(cM(e)),dM=class extends aM{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),gA(r))){let i=sM(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!qA.has(n)||e.length!==2)return;let[r,i]=e,a=uM(r),o=uM(i);if(a!==o)if(Xj(a)&&Xj(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else this.needsMeasurement=!0}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)XNe(e[t])&&n.push(t);n.length&&pPe(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=$j[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=$j[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},fM=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Kj.test(e)||e===`0`)&&!e.startsWith(`url(`));function xPe(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function SPe(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=fM(i,t),s=fM(a,t);return jk(o===s,`You are trying to animate ${t} from "${i}" to "${a}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${a} via the \`style\` property.`),!o||!s?!1:xPe(e)||(n===`spring`||lj(n))&&r}var CPe=e=>e!==null;function pM(e,{repeat:t,repeatType:n=`loop`},r){let i=e.filter(CPe),a=t&&n!==`loop`&&t%2==1?0:i.length-1;return!a||r===void 0?i[a]:r}var wPe=40,mM=class{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,...o}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=YA.now(),this.options={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,...o},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt&&this.resolvedAt-this.createdAt>wPe?this.resolvedAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&_Pe(),this._resolved}onKeyframesResolved(e,t){this.resolvedAt=YA.now(),this.hasAttemptedResolve=!0;let{name:n,type:r,velocity:i,delay:a,onComplete:o,onUpdate:s,isGenerator:c}=this.options;if(!c&&!SPe(e,n,r,i))if(cj.current||!a){s&&s(pM(e,this.options,t)),o&&o(),this.resolveFinishedPromise();return}else this.options.duration=0;let l=this.initPlayback(e,t);l!==!1&&(this._resolved={keyframes:e,finalKeyframe:t,...l},this.onPostResolved())}onPostResolved(){}then(e,t){return this.currentFinishedPromise.then(e,t)}flatten(){this.options.type=`keyframes`,this.options.ease=`linear`}updateFinishedPromise(){this.currentFinishedPromise=new Promise(e=>{this.resolveFinishedPromise=e})}},TPe=2e4;function hM(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}var gM=(e,t,n)=>e+(t-e)*n;function _M(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function EPe({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=_M(s,r,e+1/3),a=_M(s,r,e),o=_M(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function vM(e,t){return n=>n>0?t:e}var yM=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},DPe=[Lj,Ij,Rj],OPe=e=>DPe.find(t=>t.test(e));function bM(e){let t=OPe(e);if(jk(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`),!t)return!1;let n=t.parse(e);return t===Rj&&(n=EPe(n)),n}var xM=(e,t)=>{let n=bM(e),r=bM(t);if(!n||!r)return vM(e,t);let i={...n};return e=>(i.red=yM(n.red,r.red,e),i.green=yM(n.green,r.green,e),i.blue=yM(n.blue,r.blue,e),i.alpha=gM(n.alpha,r.alpha,e),Ij.transform(i))},kPe=(e,t)=>n=>t(e(n)),SM=(...e)=>e.reduce(kPe),CM=new Set([`none`,`hidden`]);function APe(e,t){return CM.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function jPe(e,t){return n=>gM(e,t,n)}function wM(e){return typeof e==`number`?jPe:typeof e==`string`?gA(e)?vM:zj.test(e)?xM:PPe:Array.isArray(e)?TM:typeof e==`object`?zj.test(e)?xM:MPe:vM}function TM(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>wM(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function MPe(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=wM(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function NPe(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var PPe=(e,t)=>{let n=Kj.createTransformer(t),r=Uj(e),i=Uj(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?CM.has(e)&&!i.values.length||CM.has(t)&&!r.values.length?APe(e,t):SM(TM(NPe(r,i),i.values),n):(jk(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),vM(e,t))};function EM(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?gM(e,t,n):wM(e)(e,t)}var FPe=5;function DM(e,t,n){let r=Math.max(t-FPe,0);return $A(n-e(r),t-r)}var OM={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},kM=.001;function IPe({duration:e=OM.duration,bounce:t=OM.bounce,velocity:n=OM.velocity,mass:r=OM.mass}){let i,a;jk(e<=oj(OM.maxDuration),`Spring duration must be 10 seconds or less`);let o=1-t;o=vA(OM.minDamping,OM.maxDamping,o),e=vA(OM.minDuration,OM.maxDuration,sj(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=AM(t,o),c=Math.exp(-i);return kM-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=AM(t**2,o);return(-i(t)+kM>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-kM+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=RPe(i,a,s);if(e=oj(e),isNaN(c))return{stiffness:OM.stiffness,damping:OM.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var LPe=12;function RPe(e,t,n){let r=n;for(let n=1;n<LPe;n++)r-=e(r)/t(r);return r}function AM(e,t){return e*Math.sqrt(1-t*t)}var zPe=[`duration`,`bounce`],BPe=[`stiffness`,`damping`,`mass`];function jM(e,t){return t.some(t=>e[t]!==void 0)}function VPe(e){let t={velocity:OM.velocity,stiffness:OM.stiffness,damping:OM.damping,mass:OM.mass,isResolvedFromDuration:!1,...e};if(!jM(e,BPe)&&jM(e,zPe))if(e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*vA(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:OM.mass,stiffness:i,damping:a}}else{let n=IPe(e);t={...t,...n,mass:OM.mass},t.isResolvedFromDuration=!0}return t}function MM(e=OM.visualDuration,t=OM.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=VPe({...n,velocity:-sj(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=sj(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?OM.restSpeed.granular:OM.restSpeed.default,i||=v?OM.restDelta.granular:OM.restDelta.default;let y;if(h<1){let e=AM(_,h);y=t=>o-Math.exp(-h*_*t)*((m+h*_*g)/e*Math.sin(e*t)+g*Math.cos(e*t))}else if(h===1)y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e}}let b={calculatedDuration:p&&d||null,next:e=>{let t=y(e);if(p)s.done=e>=d;else{let n=0;h<1&&(n=e===0?oj(m):DM(y,e,t));let a=Math.abs(n)<=r,c=Math.abs(o-t)<=i;s.done=a&&c}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(hM(b),TPe),t=mj(t=>b.next(e*t).value,e,30);return e+`ms `+t}};return b}function NM({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=MM({keyframes:[f.value,m(f.value)],velocity:DM(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}var HPe=bj(.42,0,1,1),UPe=bj(0,0,.58,1),PM=bj(.42,0,.58,1),WPe=e=>Array.isArray(e)&&typeof e[0]!=`number`,FM={linear:Ak,easeIn:HPe,easeInOut:PM,easeOut:UPe,circIn:Dj,circInOut:kj,circOut:Oj,backIn:wj,backInOut:Tj,backOut:Cj,anticipate:Ej},IM=e=>{if(dj(e)){Mk(e.length===4,`Cubic bezier arrays must contain four numerical values.`);let[t,n,r,i]=e;return bj(t,n,r,i)}else if(typeof e==`string`)return Mk(FM[e]!==void 0,`Invalid easing type '${e}'`),FM[e];return e};function GPe(e,t,n){let r=[],i=n||EM,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=SM(Array.isArray(t)?t[n]||Ak:t,a)),r.push(a)}return r}function KPe(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(Mk(a===t.length,`Both input and output ranges must be the same length`),a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=GPe(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=pj(e[r],e[r+1],n);return s[r](i)};return n?t=>l(vA(e[0],e[a-1],t)):l}function qPe(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=pj(0,t,r);e.push(gM(n,1,i))}}function JPe(e){let t=[0];return qPe(t,e.length-1),t}function YPe(e,t){return e.map(e=>e*t)}function XPe(e,t){return e.map(()=>t||PM).splice(0,e.length-1)}function LM({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=WPe(r)?r.map(IM):IM(r),a={done:!1,value:t[0]},o=KPe(YPe(n&&n.length===t.length?n:JPe(t),e),t,{ease:Array.isArray(i)?i:XPe(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var ZPe=e=>{let t=({timestamp:t})=>e(t);return{start:()=>Ik.update(t,!0),stop:()=>Lk(t),now:()=>Rk.isProcessing?Rk.timestamp:YA.now()}},QPe={decay:NM,inertia:NM,tween:LM,keyframes:LM,spring:MM},$Pe=e=>e/100,RM=class extends mM{constructor(e){super(e),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState=`running`,this.startTime=null,this.state=`idle`,this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state===`idle`)return;this.teardown();let{onStop:e}=this.options;e&&e()};let{name:t,motionValue:n,element:r,keyframes:i}=this.options;this.resolver=new(r?.KeyframeResolver||aM)(i,(e,t)=>this.onKeyframesResolved(e,t),t,n,r),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(e){let{type:t=`keyframes`,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=this.options,o=lj(t)?t:QPe[t]||LM,s,c;o!==LM&&typeof e[0]!=`number`&&(s=SM($Pe,EM(e[0],e[1])),e=[0,100]);let l=o({...this.options,keyframes:e});i===`mirror`&&(c=o({...this.options,keyframes:[...e].reverse(),velocity:-a})),l.calculatedDuration===null&&(l.calculatedDuration=hM(l));let{calculatedDuration:u}=l,d=u+r,f=d*(n+1)-r;return{generator:l,mirroredGenerator:c,mapPercentToKeyframes:s,calculatedDuration:u,resolvedDuration:d,totalDuration:f}}onPostResolved(){let{autoplay:e=!0}=this.options;this.play(),this.pendingPlayState===`paused`||!e?this.pause():this.state=this.pendingPlayState}tick(e,t=!1){let{resolved:n}=this;if(!n){let{keyframes:e}=this.options;return{done:!0,value:e[e.length-1]}}let{finalKeyframe:r,generator:i,mirroredGenerator:a,mapPercentToKeyframes:o,keyframes:s,calculatedDuration:c,totalDuration:l,resolvedDuration:u}=n;if(this.startTime===null)return i.next(0);let{delay:d,repeat:f,repeatType:p,repeatDelay:m,onUpdate:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-l/this.speed,this.startTime)),t?this.currentTime=e:this.holdTime===null?this.currentTime=Math.round(e-this.startTime)*this.speed:this.currentTime=this.holdTime;let g=this.currentTime-d*(this.speed>=0?1:-1),_=this.speed>=0?g<0:g>l;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=l);let v=this.currentTime,y=i;if(f){let e=Math.min(this.currentTime,l)/u,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,f+1),t%2&&(p===`reverse`?(n=1-n,m&&(n-=m/u)):p===`mirror`&&(y=a)),v=vA(0,1,n)*u}let b=_?{done:!1,value:s[0]}:y.next(v);o&&(b.value=o(b.value));let{done:x}=b;!_&&c!==null&&(x=this.speed>=0?this.currentTime>=l:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&r!==void 0&&(b.value=pM(s,this.options,r)),h&&h(b.value),S&&this.finish(),b}get duration(){let{resolved:e}=this;return e?sj(e.calculatedDuration):0}get time(){return sj(this.currentTime)}set time(e){e=oj(e),this.currentTime=e,this.holdTime!==null||this.speed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.speed)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=sj(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState=`running`;return}if(this.isStopped)return;let{driver:e=ZPe,onPlay:t,startTime:n}=this.options;this.driver||=e(e=>this.tick(e)),t&&t();let r=this.driver.now();this.holdTime===null?this.startTime?this.state===`finished`&&(this.startTime=r):this.startTime=n??this.calcStartTime():this.startTime=r-this.holdTime,this.state===`finished`&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state=`running`,this.driver.start()}pause(){if(!this._resolved){this.pendingPlayState=`paused`;return}this.state=`paused`,this.holdTime=this.currentTime??0}complete(){this.state!==`running`&&this.play(),this.pendingPlayState=this.state=`finished`,this.holdTime=null}finish(){this.teardown(),this.state=`finished`;let{onComplete:e}=this.options;e&&e()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state=`idle`,this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}},eFe=new Set([`opacity`,`clipPath`,`filter`,`transform`]);function tFe(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeInOut`,times:c}={}){let l={[t]:n};c&&(l.offset=c);let u=vj(s,i);return Array.isArray(u)&&(l.easing=u),e.animate(l,{delay:r,duration:i,easing:Array.isArray(u)?`linear`:u,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`})}var nFe=aj(()=>Object.hasOwnProperty.call(Element.prototype,`animate`)),zM=10,rFe=2e4;function iFe(e){return lj(e.type)||e.type===`spring`||!hj(e.ease)}function aFe(e,t){let n=new RM({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0}),r={done:!1,value:e[0]},i=[],a=0;for(;!r.done&&a<rFe;)r=n.sample(a),i.push(r.value),a+=zM;return{times:void 0,keyframes:i,duration:a-zM,ease:`linear`}}var BM={anticipate:Ej,backInOut:Tj,circInOut:kj};function oFe(e){return e in BM}var VM=class extends mM{constructor(e){super(e);let{name:t,motionValue:n,element:r,keyframes:i}=this.options;this.resolver=new dM(i,(e,t)=>this.onKeyframesResolved(e,t),t,n,r),this.resolver.scheduleResolve()}initPlayback(e,t){let{duration:n=300,times:r,ease:i,type:a,motionValue:o,name:s,startTime:c}=this.options;if(!o.owner||!o.owner.current)return!1;if(typeof i==`string`&&fj()&&oFe(i)&&(i=BM[i]),iFe(this.options)){let{onComplete:t,onUpdate:o,motionValue:s,element:c,...l}=this.options,u=aFe(e,l);e=u.keyframes,e.length===1&&(e[1]=e[0]),n=u.duration,r=u.times,i=u.ease,a=`keyframes`}let l=tFe(o.owner.current,s,e,{...this.options,duration:n,times:r,ease:i});return l.startTime=c??this.calcStartTime(),this.pendingTimeline?(uj(l,this.pendingTimeline),this.pendingTimeline=void 0):l.onfinish=()=>{let{onComplete:n}=this.options;o.set(pM(e,this.options,t)),n&&n(),this.cancel(),this.resolveFinishedPromise()},{animation:l,duration:n,times:r,type:a,ease:i,keyframes:e}}get duration(){let{resolved:e}=this;if(!e)return 0;let{duration:t}=e;return sj(t)}get time(){let{resolved:e}=this;if(!e)return 0;let{animation:t}=e;return sj(t.currentTime||0)}set time(e){let{resolved:t}=this;if(!t)return;let{animation:n}=t;n.currentTime=oj(e)}get speed(){let{resolved:e}=this;if(!e)return 1;let{animation:t}=e;return t.playbackRate}set speed(e){let{resolved:t}=this;if(!t)return;let{animation:n}=t;n.playbackRate=e}get state(){let{resolved:e}=this;if(!e)return`idle`;let{animation:t}=e;return t.playState}get startTime(){let{resolved:e}=this;if(!e)return null;let{animation:t}=e;return t.startTime}attachTimeline(e){if(!this._resolved)this.pendingTimeline=e;else{let{resolved:t}=this;if(!t)return Ak;let{animation:n}=t;uj(n,e)}return Ak}play(){if(this.isStopped)return;let{resolved:e}=this;if(!e)return;let{animation:t}=e;t.playState===`finished`&&this.updateFinishedPromise(),t.play()}pause(){let{resolved:e}=this;if(!e)return;let{animation:t}=e;t.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state===`idle`)return;this.resolveFinishedPromise(),this.updateFinishedPromise();let{resolved:e}=this;if(!e)return;let{animation:t,keyframes:n,duration:r,type:i,ease:a,times:o}=e;if(t.playState===`idle`||t.playState===`finished`)return;if(this.time){let{motionValue:e,onUpdate:t,onComplete:s,element:c,...l}=this.options,u=new RM({...l,keyframes:n,duration:r,type:i,ease:a,times:o,isGenerator:!0}),d=oj(this.time);e.setWithVelocity(u.sample(d-zM).value,u.sample(d).value,zM)}let{onStop:s}=this.options;s&&s(),this.cancel()}complete(){let{resolved:e}=this;e&&e.animation.finish()}cancel(){let{resolved:e}=this;e&&e.animation.cancel()}static supports(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o}=e;if(!t||!t.owner||!(t.owner.current instanceof HTMLElement))return!1;let{onUpdate:s,transformTemplate:c}=t.owner.getProps();return nFe()&&n&&eFe.has(n)&&!s&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}},sFe={type:`spring`,stiffness:500,damping:25,restSpeed:10},cFe=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),lFe={type:`keyframes`,duration:.8},uFe={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},dFe=(e,{keyframes:t})=>t.length>2?lFe:pA.has(e)?e.startsWith(`scale`)?cFe(t[1]):sFe:uFe;function fFe({when:e,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:i,repeat:a,repeatType:o,repeatDelay:s,from:c,elapsed:l,...u}){return!!Object.keys(u).length}var HM=(e,t,n,r={},i,a)=>o=>{let s=KA(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=oj(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};fFe(s)||(u={...u,...dFe(e,u)}),u.duration&&=oj(u.duration),u.repeatDelay&&=oj(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(u.duration=0,u.delay===0&&(d=!0)),(cj.current||Nk.skipAnimations)&&(d=!0,u.duration=0,u.delay=0),d&&!a&&t.get()!==void 0){let e=pM(u.keyframes,s);if(e!==void 0)return Ik.update(()=>{u.onUpdate(e),u.onComplete()}),new WNe([])}return!a&&VM.supports(u)?new VM(u):new RM(u)};function pFe({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function UM(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a=e.getDefaultTransition(),transitionEnd:o,...s}=t;r&&(a=r);let c=[],l=i&&e.animationState&&e.animationState.getState()[i];for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||l&&pFe(l,t))continue;let o={delay:n,...KA(a||{},t)},u=!1;if(window.MotionHandoffAnimation){let n=ij(e);if(n){let e=window.MotionHandoffAnimation(n,t,Ik);e!==null&&(o.startTime=e,u=!0)}}rj(e,t),r.start(HM(t,r,i,e.shouldReduceMotion&&qA.has(t)?{type:!1}:o,e,u));let d=r.animation;d&&c.push(d)}return o&&Promise.all(c).then(()=>{Ik.update(()=>{o&&BNe(e,o)})}),c}function WM(e,t,n={}){let r=GA(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(UM(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return mFe(e,t,a+r,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function mFe(e,t,n=0,r=0,i=1,a){let o=[],s=(e.variantChildren.size-1)*r,c=i===1?(e=0)=>e*r:(e=0)=>s-e*r;return Array.from(e.variantChildren).sort(hFe).forEach((e,r)=>{e.notify(`AnimationStart`,t),o.push(WM(e,t,{...a,delay:n+c(r)}).then(()=>e.notify(`AnimationComplete`,t)))}),Promise.all(o)}function hFe(e,t){return e.sortNodePosition(t)}function gFe(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>WM(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=WM(e,t,n);else{let i=typeof t==`function`?GA(e,t,n.custom):t;r=Promise.all(UM(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var _Fe=Yk.length;function GM(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&GM(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<_Fe;n++){let r=Yk[n],i=e.props[r];(Kk(i)||i===!1)&&(t[r]=i)}return t}var vFe=[...Jk].reverse(),yFe=Jk.length;function bFe(e){return t=>Promise.all(t.map(({animation:t,options:n})=>gFe(e,t,n)))}function xFe(e){let t=bFe(e),n=qM(),r=!0,i=t=>(n,r)=>{let i=GA(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function a(n){t=n(e)}function o(a){let{props:o}=e,s=GM(e.parent)||{},c=[],l=new Set,u={},d=1/0;for(let t=0;t<yFe;t++){let f=vFe[t],p=n[f],m=o[f]===void 0?s[f]:o[f],h=Kk(m),g=f===a?p.isActive:null;g===!1&&(d=t);let _=m===s[f]&&m!==o[f]&&h;if(_&&r&&e.manuallyAnimateOnMount&&(_=!1),p.protectedKeys={...u},!p.isActive&&g===null||!m&&!p.prevProp||qk(m)||typeof m==`boolean`)continue;let v=SFe(p.prevProp,m),y=v||f===a&&p.isActive&&!_&&h||t>d&&h,b=!1,x=Array.isArray(m)?m:[m],S=x.reduce(i(f),{});g===!1&&(S={});let{prevResolvedValues:C={}}=p,w={...C,...S},T=t=>{y=!0,l.has(t)&&(b=!0,l.delete(t)),p.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in w){let t=S[e],n=C[e];if(u.hasOwnProperty(e))continue;let r=!1;r=cA(t)&&cA(n)?!WA(t,n):t!==n,r?t==null?l.add(e):T(e):t!==void 0&&l.has(e)?T(e):p.protectedKeys[e]=!0}p.prevProp=m,p.prevResolvedValues=S,p.isActive&&(u={...u,...S}),r&&e.blockInitialAnimation&&(y=!1),y&&(!(_&&v)||b)&&c.push(...x.map(e=>({animation:e,options:{type:f}})))}if(l.size){let t={};l.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),c.push({animation:t})}let f=!!c.length;return r&&(o.initial===!1||o.initial===o.animate)&&!e.manuallyAnimateOnMount&&(f=!1),r=!1,f?t(c):Promise.resolve()}function s(t,r){var i;if(n[t].isActive===r)return Promise.resolve();(i=e.variantChildren)==null||i.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let a=o(t);for(let e in n)n[e].protectedKeys={};return a}return{animateChanges:o,setActive:s,setAnimateFunction:a,getState:()=>n,reset:()=>{n=qM(),r=!0}}}function SFe(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!WA(t,e):!1}function KM(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function qM(){return{animate:KM(!0),whileInView:KM(),whileHover:KM(),whileTap:KM(),whileDrag:KM(),whileFocus:KM(),exit:KM()}}var JM=class{constructor(e){this.isMounted=!1,this.node=e}update(){}},CFe=class extends JM{constructor(e){super(e),e.animationState||=xFe(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();qk(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}},wFe=0,TFe={animation:{Feature:CFe},exit:{Feature:class extends JM{constructor(){super(...arguments),this.id=wFe++}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>t(this.id))}mount(){let{register:e}=this.node.presenceContext||{};e&&(this.unmount=e(this.id))}unmount(){}}}},YM={x:!1,y:!1};function XM(){return YM.x||YM.y}function EFe(e){return e===`x`||e===`y`?YM[e]?null:(YM[e]=!0,()=>{YM[e]=!1}):YM.x||YM.y?null:(YM.x=YM.y=!0,()=>{YM.x=YM.y=!1})}var ZM=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1;function QM(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}function $M(e){return{point:{x:e.pageX,y:e.pageY}}}var DFe=e=>t=>ZM(t)&&e(t,$M(t));function eN(e,t,n,r){return QM(e,t,DFe(n),r)}var tN=(e,t)=>Math.abs(e-t);function OFe(e,t){let n=tN(e.x,t.x),r=tN(e.y,t.y);return Math.sqrt(n**2+r**2)}var nN=class{constructor(e,t,{transformPagePoint:n,contextWindow:r,dragSnapToOrigin:i=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let e=aN(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=OFe(e.offset,{x:0,y:0})>=3;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Rk;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastMoveEventInfo=rN(t,this.transformPagePoint),Ik.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if(this.dragSnapToOrigin&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=aN(e.type===`pointercancel`?this.lastMoveEventInfo:rN(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!ZM(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.contextWindow=r||window;let a=rN($M(e),this.transformPagePoint),{point:o}=a,{timestamp:s}=Rk;this.history=[{...o,timestamp:s}];let{onSessionStart:c}=t;c&&c(e,aN(a,this.history)),this.removeListeners=SM(eN(this.contextWindow,`pointermove`,this.handlePointerMove),eN(this.contextWindow,`pointerup`,this.handlePointerUp),eN(this.contextWindow,`pointercancel`,this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Lk(this.updatePoint)}};function rN(e,t){return t?{point:t(e.point)}:e}function iN(e,t){return{x:e.x-t.x,y:e.y-t.y}}function aN({point:e},t){return{point:e,delta:iN(e,oN(t)),offset:iN(e,kFe(t)),velocity:AFe(t,.1)}}function kFe(e){return e[0]}function oN(e){return e[e.length-1]}function AFe(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=oN(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>oj(t)));)n--;if(!r)return{x:0,y:0};let a=sj(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}var sN=1e-4,jFe=1-sN,MFe=1+sN,cN=.01,NFe=0-cN,PFe=0+cN;function lN(e){return e.max-e.min}function FFe(e,t,n){return Math.abs(e-t)<=n}function uN(e,t,n,r=.5){e.origin=r,e.originPoint=gM(t.min,t.max,e.origin),e.scale=lN(n)/lN(t),e.translate=gM(n.min,n.max,e.origin)-e.originPoint,(e.scale>=jFe&&e.scale<=MFe||isNaN(e.scale))&&(e.scale=1),(e.translate>=NFe&&e.translate<=PFe||isNaN(e.translate))&&(e.translate=0)}function dN(e,t,n,r){uN(e.x,t.x,n.x,r?r.originX:void 0),uN(e.y,t.y,n.y,r?r.originY:void 0)}function fN(e,t,n){e.min=n.min+t.min,e.max=e.min+lN(t)}function IFe(e,t,n){fN(e.x,t.x,n.x),fN(e.y,t.y,n.y)}function pN(e,t,n){e.min=t.min-n.min,e.max=e.min+lN(t)}function mN(e,t,n){pN(e.x,t.x,n.x),pN(e.y,t.y,n.y)}function LFe(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?gM(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?gM(n,e,r.max):Math.min(e,n)),e}function hN(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function RFe(e,{top:t,left:n,bottom:r,right:i}){return{x:hN(e.x,n,i),y:hN(e.y,t,r)}}function gN(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function zFe(e,t){return{x:gN(e.x,t.x),y:gN(e.y,t.y)}}function BFe(e,t){let n=.5,r=lN(e),i=lN(t);return i>r?n=pj(t.min,t.max-r,e.min):r>i&&(n=pj(e.min,e.max-i,t.min)),vA(0,1,n)}function VFe(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var _N=.35;function HFe(e=_N){return e===!1?e=0:e===!0&&(e=_N),{x:vN(e,`left`,`right`),y:vN(e,`top`,`bottom`)}}function vN(e,t,n){return{min:yN(e,t),max:yN(e,n)}}function yN(e,t){return typeof e==`number`?e:e[t]||0}var bN=()=>({translate:0,scale:1,origin:0,originPoint:0}),xN=()=>({x:bN(),y:bN()}),SN=()=>({min:0,max:0}),CN=()=>({x:SN(),y:SN()});function wN(e){return[e(`x`),e(`y`)]}function TN({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function UFe({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function WFe(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function EN(e){return e===void 0||e===1}function DN({scale:e,scaleX:t,scaleY:n}){return!EN(e)||!EN(t)||!EN(n)}function ON(e){return DN(e)||kN(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function kN(e){return AN(e.x)||AN(e.y)}function AN(e){return e&&e!==`0%`}function jN(e,t,n){return n+t*(e-n)}function MN(e,t,n,r,i){return i!==void 0&&(e=jN(e,i,r)),jN(e,n,r)+t}function NN(e,t=0,n=1,r,i){e.min=MN(e.min,t,n,r,i),e.max=MN(e.max,t,n,r,i)}function PN(e,{x:t,y:n}){NN(e.x,t.translate,t.scale,t.originPoint),NN(e.y,n.translate,n.scale,n.originPoint)}var FN=.999999999999,IN=1.0000000000001;function GFe(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&zN(e,{x:-a.scroll.offset.x,y:-a.scroll.offset.y}),o&&(t.x*=o.x.scale,t.y*=o.y.scale,PN(e,o)),r&&ON(a.latestValues)&&zN(e,a.latestValues))}t.x<IN&&t.x>FN&&(t.x=1),t.y<IN&&t.y>FN&&(t.y=1)}function LN(e,t){e.min+=t,e.max+=t}function RN(e,t,n,r,i=.5){NN(e,t,n,gM(e.min,e.max,i),r)}function zN(e,t){RN(e.x,t.x,t.scaleX,t.scale,t.originX),RN(e.y,t.y,t.scaleY,t.scale,t.originY)}function BN(e,t){return TN(WFe(e.getBoundingClientRect(),t))}function KFe(e,t,n){let r=BN(e,n),{scroll:i}=t;return i&&(LN(r.x,i.offset.x),LN(r.y,i.offset.y)),r}var VN=({current:e})=>e?e.ownerDocument.defaultView:null,qFe=new WeakMap,JFe=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=CN(),this.visualElement=e}start(e,{snapToCursor:t=!1}={}){let{presenceContext:n}=this.visualElement;if(n&&n.isPresent===!1)return;let r=e=>{let{dragSnapToOrigin:n}=this.getProps();n?this.pauseAnimation():this.stopAnimation(),t&&this.snapToCursor($M(e).point)},i=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=EFe(n),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),wN(e=>{let t=this.getAxisMotionValue(e).get()||0;if(wA.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=lN(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&Ik.postRender(()=>i(e,t)),rj(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},a=(e,t)=>{let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=YFe(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&a(e,t)},o=(e,t)=>this.stop(e,t),s=()=>wN(e=>this.getAnimationState(e)===`paused`&&this.getAxisMotionValue(e).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new nN(e,{onSessionStart:r,onStart:i,onMove:a,onSessionEnd:o,resumeAnimation:s},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,contextWindow:VN(this.visualElement)})}stop(e,t){let n=this.isDragging;if(this.cancel(),!n)return;let{velocity:r}=t;this.startAnimation(r);let{onDragEnd:i}=this.getProps();i&&Ik.postRender(()=>i(e,t))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!HN(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=LFe(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&$k(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=RFe(n.layoutBox,e):this.constraints=!1,this.elastic=HFe(t),r!==this.constraints&&n&&this.constraints&&!this.hasMutatedConstraints&&wN(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=VFe(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!$k(e))return!1;let n=e.current;Mk(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");let{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=KFe(n,r.root,this.visualElement.getTransformPagePoint()),a=zFe(r.layout.layoutBox,i);if(t){let e=t(UFe(a));this.hasMutatedConstraints=!!e,e&&(a=TN(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=wN(o=>{if(!HN(o,t,this.currentDirection))return;let c=s&&s[o]||{};a&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return rj(this.visualElement,e),n.start(HM(e,n,0,t,this.visualElement,!1))}stopAnimation(){wN(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){wN(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps();return n[t]||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){wN(t=>{let{drag:n}=this.getProps();if(!HN(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t];i.set(e[t]-gM(n,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!$k(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};wN(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=BFe({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),wN(t=>{if(!HN(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(gM(i,a,r[t]))})}addListeners(){if(!this.visualElement.current)return;qFe.set(this.visualElement,this);let e=this.visualElement.current,t=eN(e,`pointerdown`,e=>{let{drag:t,dragListener:n=!0}=this.getProps();t&&n&&this.start(e)}),n=()=>{let{dragConstraints:e}=this.getProps();$k(e)&&e.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,i=r.addEventListener(`measure`,n);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),Ik.read(n);let a=QM(window,`resize`,()=>this.scalePositionWithinConstraints()),o=r.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(wN(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{a(),t(),i(),o&&o()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=_N,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function HN(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function YFe(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var XFe=class extends JM{constructor(e){super(e),this.removeGroupControls=Ak,this.removeListeners=Ak,this.controls=new JFe(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ak}unmount(){this.removeGroupControls(),this.removeListeners()}},UN=e=>(t,n)=>{e&&Ik.postRender(()=>e(t,n))},ZFe=class extends JM{constructor(){super(...arguments),this.removePointerDownListener=Ak}onPointerDown(e){this.session=new nN(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:VN(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:UN(e),onStart:UN(t),onMove:n,onEnd:(e,t)=>{delete this.session,r&&Ik.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=eN(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},WN={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function GN(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var KN={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(TA.test(e))e=parseFloat(e);else return e;return`${GN(e,t.target.x)}% ${GN(e,t.target.y)}%`}},QFe={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Kj.parse(e);if(i.length>5)return r;let a=Kj.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=gM(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},$Fe=class extends H.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;ENe(eIe),i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),WN.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,a=n.projection;return a?(a.isPresent=i,r||e.layoutDependency!==t||t===void 0?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||Ik.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),nA.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function qN(e){let[t,n]=HMe(),r=(0,H.useContext)(Ek);return(0,U.jsx)($Fe,{...e,layoutGroup:r,switchLayoutGroup:(0,H.useContext)(rA),isPresent:t,safeToRemove:n})}var eIe={borderRadius:{...KN,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:KN,borderTopRightRadius:KN,borderBottomLeftRadius:KN,borderBottomRightRadius:KN,boxShadow:QFe};function tIe(e,t,n){let r=lA(e)?e:nj(e);return r.start(HM(``,r,t,n)),r.animation}function nIe(e){return e instanceof SVGElement&&e.tagName!==`svg`}var rIe=(e,t)=>e.depth-t.depth,iIe=class{constructor(){this.children=[],this.isDirty=!1}add(e){XA(this.children,e),this.isDirty=!0}remove(e){ZA(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(rIe),this.isDirty=!1,this.children.forEach(e)}};function aIe(e,t){let n=YA.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Lk(r),e(a-t))};return Ik.read(r,!0),()=>Lk(r)}var JN=[`TopLeft`,`TopRight`,`BottomLeft`,`BottomRight`],oIe=JN.length,YN=e=>typeof e==`string`?parseFloat(e):e,XN=e=>typeof e==`number`||TA.test(e);function sIe(e,t,n,r,i,a){i?(e.opacity=gM(0,n.opacity===void 0?1:n.opacity,cIe(r)),e.opacityExit=gM(t.opacity===void 0?1:t.opacity,0,lIe(r))):a&&(e.opacity=gM(t.opacity===void 0?1:t.opacity,n.opacity===void 0?1:n.opacity,r));for(let i=0;i<oIe;i++){let a=`border${JN[i]}Radius`,o=ZN(t,a),s=ZN(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||XN(o)===XN(s)?(e[a]=Math.max(gM(YN(o),YN(s),r),0),(wA.test(s)||wA.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=gM(t.rotate||0,n.rotate||0,r))}function ZN(e,t){return e[t]===void 0?e.borderRadius:e[t]}var cIe=QN(0,.5,Oj),lIe=QN(.5,.95,Ak);function QN(e,t,n){return r=>r<e?0:r>t?1:n(pj(e,t,r))}function $N(e,t){e.min=t.min,e.max=t.max}function eP(e,t){$N(e.x,t.x),$N(e.y,t.y)}function tP(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function nP(e,t,n,r,i){return e-=t,e=jN(e,1/n,r),i!==void 0&&(e=jN(e,1/i,r)),e}function uIe(e,t=0,n=1,r=.5,i,a=e,o=e){if(wA.test(t)&&(t=parseFloat(t),t=gM(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=gM(a.min,a.max,r);e===a&&(s-=t),e.min=nP(e.min,t,n,s,i),e.max=nP(e.max,t,n,s,i)}function rP(e,t,[n,r,i],a,o){uIe(e,t[n],t[r],t[i],t.scale,a,o)}var dIe=[`x`,`scaleX`,`originX`],fIe=[`y`,`scaleY`,`originY`];function iP(e,t,n,r){rP(e.x,t,dIe,n?n.x:void 0,r?r.x:void 0),rP(e.y,t,fIe,n?n.y:void 0,r?r.y:void 0)}function aP(e){return e.translate===0&&e.scale===1}function oP(e){return aP(e.x)&&aP(e.y)}function sP(e,t){return e.min===t.min&&e.max===t.max}function pIe(e,t){return sP(e.x,t.x)&&sP(e.y,t.y)}function cP(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function lP(e,t){return cP(e.x,t.x)&&cP(e.y,t.y)}function uP(e){return lN(e.x)/lN(e.y)}function dP(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}var mIe=class{constructor(){this.members=[]}add(e){XA(this.members,e),e.scheduleRender()}remove(e){if(ZA(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){let t=this.members.findIndex(t=>e===t);if(t===0)return!1;let n;for(let e=t;e>=0;e--){let t=this.members[e];if(t.isPresent!==!1){n=t;break}}return n?(this.promote(n),!0):!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.instance&&n.scheduleRender(),e.scheduleRender(),e.resumeFrom=n,t&&(e.resumeFrom.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);let{crossfade:r}=e.options;r===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{let{options:t,resumingFrom:n}=e;t.onExitComplete&&t.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}};function hIe(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,rotateX:i,rotateY:a,skewX:o,skewY:s}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotateX(${i}deg) `),a&&(r+=`rotateY(${a}deg) `),o&&(r+=`skewX(${o}deg) `),s&&(r+=`skewY(${s}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var fP={type:`projectionFrame`,totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},pP=typeof window<`u`&&window.MotionDebug!==void 0,mP=[``,`X`,`Y`,`Z`],gIe={visibility:`hidden`},hP=1e3,_Ie=0;function gP(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function _P(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=ij(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Ik,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&_P(r)}function vP({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=_Ie++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,pP&&(fP.totalNodes=fP.resolvedTargetDeltas=fP.recalculatedProjection=0),this.nodes.forEach(bIe),this.nodes.forEach(TIe),this.nodes.forEach(EIe),this.nodes.forEach(xIe),pP&&window.MotionDebug.record(fP)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new iIe)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new QA),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t,n=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=nIe(t),this.instance=t;let{layoutId:r,layout:i,visualElement:a}=this.options;if(a&&!a.current&&a.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),n&&(i||r)&&(this.isLayoutDirty=!0),e){let n,r=()=>this.root.updateBlockedByResize=!1;e(t,()=>{this.root.updateBlockedByResize=!0,n&&n(),n=aIe(r,250),WN.hasAnimatedSinceResize&&(WN.hasAnimatedSinceResize=!1,this.nodes.forEach(bP))})}r&&this.root.registerSharedNode(r,this),this.options.animate!==!1&&a&&(r||i)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeTargetChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let i=this.options.transition||a.getDefaultTransition()||jIe,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=a.getProps(),c=!this.targetLayout||!lP(this.targetLayout,r)||n,l=!t&&n;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(e,l);let t={...KA(i,`layout`),onPlay:o,onComplete:s};(a.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t)}else t||bP(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Lk(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(DIe),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&_P(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(yP);return}this.isUpdating||this.nodes.forEach(CIe),this.isUpdating=!1,this.nodes.forEach(wIe),this.nodes.forEach(vIe),this.nodes.forEach(yIe),this.clearAllSnapshots();let e=YA.now();Rk.delta=vA(0,1e3/60,e-Rk.timestamp),Rk.timestamp=e,Rk.isProcessing=!0,zk.update.process(Rk),zk.preRender.process(Rk),zk.render.process(Rk),Rk.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,nA.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(SIe),this.sharedNodes.forEach(OIe)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ik.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ik.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutCorrected=CN(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!oP(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&(t||ON(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),MIe(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return CN();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(NIe))){let{scroll:e}=this.root;e&&(LN(t.x,e.offset.x),LN(t.y,e.offset.y))}return t}removeElementScroll(e){let t=CN();if(eP(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&eP(t,e),LN(t.x,i.offset.x),LN(t.y,i.offset.y))}return t}applyTransform(e,t=!1){let n=CN();eP(n,e);for(let e=0;e<this.path.length;e++){let r=this.path[e];!t&&r.options.layoutScroll&&r.scroll&&r!==r.root&&zN(n,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),ON(r.latestValues)&&zN(n,r.latestValues)}return ON(this.latestValues)&&zN(n,this.latestValues),n}removeTransform(e){let t=CN();eP(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!n.instance||!ON(n.latestValues))continue;DN(n.latestValues)&&n.updateSnapshot();let r=CN();eP(r,n.measurePageBox()),iP(t,n.latestValues,n.snapshot?n.snapshot.layoutBox:void 0,r)}return ON(this.latestValues)&&iP(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0?!0:e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Rk.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!(!this.layout||!(r||i))){if(this.resolvedRelativeTargetAt=Rk.timestamp,!this.targetDelta&&!this.relativeTarget){let e=this.getClosestProjectingParent();e&&e.layout&&this.animationProgress!==1?(this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget=CN(),this.relativeTargetOrigin=CN(),mN(this.relativeTargetOrigin,this.layout.layoutBox,e.layout.layoutBox),eP(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=CN(),this.targetWithTransforms=CN()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),IFe(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):eP(this.target,this.layout.layoutBox),PN(this.target,this.targetDelta)):eP(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;let e=this.getClosestProjectingParent();e&&!!e.resumingFrom==!!this.resumingFrom&&!e.options.layoutScroll&&e.target&&this.animationProgress!==1?(this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget=CN(),this.relativeTargetOrigin=CN(),mN(this.relativeTargetOrigin,this.target,e.target),eP(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}pP&&fP.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||DN(this.parent.latestValues)||kN(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Rk.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;eP(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;GFe(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=CN());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(tP(this.prevProjectionDelta.x,this.projectionDelta.x),tP(this.prevProjectionDelta.y,this.projectionDelta.y)),dN(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!dP(this.projectionDelta.x,this.prevProjectionDelta.x)||!dP(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),pP&&fP.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){var t;if((t=this.options.visualElement)==null||t.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=xN(),this.projectionDelta=xN(),this.projectionDeltaWithTransform=xN()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=xN();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=CN(),s=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),c=this.getStack(),l=!c||c.members.length<=1,u=!!(s&&!l&&this.options.crossfade===!0&&!this.path.some(AIe));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;xP(a.x,e.x,n),xP(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(mN(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox),kIe(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&pIe(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=CN(),eP(d,this.relativeTarget)),s&&(this.animationValues=i,sIe(i,r,this.latestValues,n,u,l)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&=(Lk(this.pendingAnimation),void 0),this.pendingAnimation=Ik.update(()=>{WN.hasAnimatedSinceResize=!0,this.currentAnimation=tIe(0,hP,{...e,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(hP),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&EP(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||CN();let t=lN(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=lN(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}eP(t,n),zN(t,i),dN(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new mIe),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return e?e.lead===this:!0}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&gP(`z`,e,r,this.animationValues);for(let t=0;t<mP.length;t++)gP(`rotate${mP[t]}`,e,r,this.animationValues),gP(`skew${mP[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}getProjectionStyles(e){if(!this.instance||this.isSVG)return;if(!this.isVisible)return gIe;let t={visibility:``},n=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,t.opacity=``,t.pointerEvents=uA(e?.pointerEvents)||``,t.transform=n?n(this.latestValues,``):`none`,t;let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){let t={};return this.options.layoutId&&(t.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,t.pointerEvents=uA(e?.pointerEvents)||``),this.hasProjected&&!ON(this.latestValues)&&(t.transform=n?n({},``):`none`,this.hasProjected=!1),t}let i=r.animationValues||r.latestValues;this.applyTransformsToTarget(),t.transform=hIe(this.projectionDeltaWithTransform,this.treeScale,i),n&&(t.transform=n(i,t.transform));let{x:a,y:o}=this.projectionDelta;t.transformOrigin=`${a.origin*100}% ${o.origin*100}% 0`,r.animationValues?t.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:t.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let e in RA){if(i[e]===void 0)continue;let{correct:n,applyTo:a}=RA[e],o=t.transform===`none`?i[e]:n(i[e],r);if(a){let e=a.length;for(let n=0;n<e;n++)t[a[n]]=o}else t[e]=o}return this.options.layoutId&&(t.pointerEvents=r===this?uA(e?.pointerEvents)||``:`none`),t}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(yP),this.root.sharedNodes.clear()}}}function vIe(e){e.updateLayout()}function yIe(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;i===`size`?wN(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=lN(r);r.min=n[e].min,r.max=r.min+i}):EP(i,t.layoutBox,n)&&wN(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=lN(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=xN();dN(o,n,t.layoutBox);let s=xN();a?dN(s,e.applyTransform(r,!0),t.measuredBox):dN(s,n,t.layoutBox);let c=!oP(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=CN();mN(o,t.layoutBox,i.layoutBox);let s=CN();mN(s,n,a.layoutBox),lP(o,s)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=s,e.relativeTargetOrigin=o,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeTargetChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function bIe(e){pP&&fP.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function xIe(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function SIe(e){e.clearSnapshot()}function yP(e){e.clearMeasurements()}function CIe(e){e.isLayoutDirty=!1}function wIe(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function bP(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function TIe(e){e.resolveTargetDelta()}function EIe(e){e.calcProjection()}function DIe(e){e.resetSkewAndRotation()}function OIe(e){e.removeLeadSnapshot()}function xP(e,t,n){e.translate=gM(t.translate,0,n),e.scale=gM(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function SP(e,t,n,r){e.min=gM(t.min,n.min,r),e.max=gM(t.max,n.max,r)}function kIe(e,t,n,r){SP(e.x,t.x,n.x,r),SP(e.y,t.y,n.y,r)}function AIe(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var jIe={duration:.45,ease:[.4,0,.1,1]},CP=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),wP=CP(`applewebkit/`)&&!CP(`chrome/`)?Math.round:Ak;function TP(e){e.min=wP(e.min),e.max=wP(e.max)}function MIe(e){TP(e.x),TP(e.y)}function EP(e,t,n){return e===`position`||e===`preserve-aspect`&&!FFe(uP(t),uP(n),.2)}function NIe(e){return e!==e.root&&e.scroll?.wasRoot}var PIe=vP({attachResizeListener:(e,t)=>QM(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),DP={current:void 0},OP=vP({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!DP.current){let e=new PIe({});e.mount(window),e.setOptions({layoutScroll:!0}),DP.current=e}return DP.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),FIe={pan:{Feature:ZFe},drag:{Feature:XFe,ProjectionNode:OP,MeasureLayout:qN}};function IIe(e,t,n){if(e instanceof Element)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e)}function kP(e,t){let n=IIe(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function AP(e){return t=>{t.pointerType===`touch`||XM()||e(t)}}function LIe(e,t,n={}){let[r,i,a]=kP(e,n),o=AP(e=>{let{target:n}=e,r=t(e);if(typeof r!=`function`||!n)return;let a=AP(e=>{r(e),n.removeEventListener(`pointerleave`,a)});n.addEventListener(`pointerleave`,a,i)});return r.forEach(e=>{e.addEventListener(`pointerenter`,o,i)}),a}function jP(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&Ik.postRender(()=>i(t,$M(t)))}var RIe=class extends JM{mount(){let{current:e}=this.node;e&&(this.unmount=LIe(e,e=>(jP(this.node,e,`Start`),e=>jP(this.node,e,`End`))))}unmount(){}},zIe=class extends JM{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=SM(QM(this.node.current,`focus`,()=>this.onFocus()),QM(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}},MP=(e,t)=>t?e===t?!0:MP(e,t.parentElement):!1,BIe=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function VIe(e){return BIe.has(e.tagName)||e.tabIndex!==-1}var NP=new WeakSet;function PP(e){return t=>{t.key===`Enter`&&e(t)}}function FP(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var HIe=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=PP(()=>{if(NP.has(n))return;FP(n,`down`);let e=PP(()=>{FP(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>FP(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function IP(e){return ZM(e)&&!XM()}function UIe(e,t,n={}){let[r,i,a]=kP(e,n),o=e=>{let r=e.currentTarget;if(!IP(e)||NP.has(r))return;NP.add(r);let a=t(e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),!(!IP(e)||!NP.has(r))&&(NP.delete(r),typeof a==`function`&&a(e,{success:t}))},s=e=>{o(e,n.useGlobalTarget||MP(r,e.target))},c=e=>{o(e,!1)};window.addEventListener(`pointerup`,s,i),window.addEventListener(`pointercancel`,c,i)};return r.forEach(e=>{!VIe(e)&&e.getAttribute(`tabindex`)===null&&(e.tabIndex=0),(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),e.addEventListener(`focus`,e=>HIe(e,i),i)}),a}function LP(e,t,n){let{props:r}=e;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&Ik.postRender(()=>i(t,$M(t)))}var WIe=class extends JM{mount(){let{current:e}=this.node;e&&(this.unmount=UIe(e,e=>(LP(this.node,e,`Start`),(e,{success:t})=>LP(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}},RP=new WeakMap,zP=new WeakMap,GIe=e=>{let t=RP.get(e.target);t&&t(e)},KIe=e=>{e.forEach(GIe)};function qIe({root:e,...t}){let n=e||document;zP.has(n)||zP.set(n,{});let r=zP.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(KIe,{root:e,...t})),r[i]}function JIe(e,t,n){let r=qIe(t);return RP.set(e,n),r.observe(e),()=>{RP.delete(e),r.unobserve(e)}}var YIe={some:0,all:1},XIe=class extends JM{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:YIe[r]};return JIe(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(ZIe(e,t))&&this.startObserver()}unmount(){}};function ZIe({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var QIe={inView:{Feature:XIe},tap:{Feature:WIe},focus:{Feature:zIe},hover:{Feature:RIe}},$Ie={layout:{ProjectionNode:OP,MeasureLayout:qN}},BP={current:null},VP={current:!1};function eLe(){if(VP.current=!0,kk)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>BP.current=e.matches;e.addListener(t),t()}else BP.current=!1}var tLe=[...lM,zj,Kj],nLe=e=>tLe.find(cM(e)),HP=new WeakMap;function rLe(e,t,n){for(let r in t){let i=t[r],a=n[r];if(lA(i))e.addValue(r,i);else if(lA(a))e.addValue(r,nj(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,nj(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var UP=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],iLe=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,blockInitialAnimation:i,visualState:a},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=aM,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=YA.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Ik.render(this.render,!1,!0))};let{latestValues:s,renderState:c,onUpdate:l}=a;this.onUpdate=l,this.latestValues=s,this.baseTarget={...s},this.initialValues=t.initial?{...s}:{},this.renderState=c,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.options=o,this.blockInitialAnimation=!!i,this.isControllingVariants=Xk(t),this.isVariantNode=Zk(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];s[e]!==void 0&&lA(t)&&t.set(s[e],!1)}}mount(e){this.current=e,HP.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),VP.current||eLe(),this.shouldReduceMotion=this.reducedMotionConfig===`never`?!1:this.reducedMotionConfig===`always`?!0:BP.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){HP.delete(this.current),this.projection&&this.projection.unmount(),Lk(this.notifyUpdate),Lk(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}bindToMotionValue(e,t){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();let n=pA.has(e),r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Ik.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0)}),i=t.on(`renderRequest`,this.scheduleRender),a;window.MotionCheckAppearSync&&(a=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i(),a&&a(),t.owner&&t.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Hk){let t=Hk[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):CN()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<UP.length;t++){let n=UP[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=rLe(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=nj(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(oM(n)||Aj(n))?n=parseFloat(n):!nLe(n)&&Kj.test(t)&&(n=Yj(e,t)),this.setBaseTarget(e,lA(n)?n.get():n)),lA(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=sA(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!lA(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new QA),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}},WP=class extends iLe{constructor(){super(...arguments),this.KeyframeResolver=dM}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){return e.style?e.style[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;lA(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}};function aLe(e){return window.getComputedStyle(e)}var oLe=class extends WP{constructor(){super(...arguments),this.type=`html`,this.renderInstance=FA}readValueFromInstance(e,t){if(pA.has(t)){let e=Jj(t);return e&&e.default||0}else{let n=aLe(e),r=(hA(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return BN(e,t)}build(e,t,n){kA(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return BA(e,t,n)}},sLe=class extends WP{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=CN}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(pA.has(t)){let e=Jj(t);return e&&e.default||0}return t=IA.has(t)?t:eA(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return VA(e,t,n)}build(e,t,n){jA(e,t,this.isSVGTag,n.transformTemplate)}renderInstance(e,t,n,r){LA(e,t,n,r)}mount(e){this.isSVGTag=PA(e.tagName),super.mount(e)}},cLe=(e,t)=>aA(e)?new sLe(t):new oLe(t,{allowProjection:e!==H.Fragment}),GP=XMe(FNe({...TFe,...QIe,...FIe,...$Ie},cLe)),KP=r(BMe()),qP={width:5,height:5,borderRadius:`50%`},JP=({className:e,color:t=`white`})=>{let n=t===`white`?`bg-white/60`:t===`current`?`bg-current/60`:`bg-zuplo-600/60`;return(0,U.jsxs)(GP.div,{className:`flex items-center gap-1`,initial:`hidden`,animate:`visible`,variants:{visible:{transition:{staggerChildren:.2}}},children:[(0,U.jsx)(GP.div,{className:W(n,e),variants:{hidden:{opacity:0,y:3},visible:{opacity:1,y:0,transition:{y:{type:`spring`,stiffness:300,damping:10,repeat:1/0,repeatType:`reverse`}}}},style:qP}),(0,U.jsx)(GP.div,{className:W(n,e),variants:{hidden:{opacity:0,y:3},visible:{opacity:1,y:0,transition:{y:{type:`spring`,stiffness:300,damping:10,repeat:1/0,repeatType:`reverse`}}}},style:qP}),(0,U.jsx)(GP.div,{className:W(n,e),variants:{hidden:{opacity:0,y:3},visible:{opacity:1,y:0,transition:{y:{type:`spring`,stiffness:300,damping:10,repeat:1/0,repeatType:`reverse`}}}},style:qP})]})},YP=({children:e,className:t,loading:n,alternative:r})=>(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`div`,{className:W(t,`transition-opacity`,n&&`opacity-0`),children:e}),(0,U.jsx)(`div`,{className:W(`absolute top-1/2 left-1/2 opacity-0 transform -translate-x-1/2 -translate-y-1/2`,n&&`opacity-100`),children:r??(0,U.jsx)(JP,{color:`current`})})]}),lLe=Ou([`file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-background px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,`read-only:cursor-not-allowed read-only:opacity-50`],{variants:{size:{sm:`px-2 h-7.5`,default:``},hideNumberArrows:{true:`[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}},defaultVariants:{hideNumberArrows:!1,size:`default`}}),XP=({className:e,hideNumberArrows:t,size:n,selectOnFocus:r,...i})=>(0,U.jsx)(`input`,{className:W(lLe({hideNumberArrows:t,size:n}),e),...i,onFocus:e=>{r&&e.target.select(),i.onFocus?.(e)}}),ZP=`ph-no-capture`,uLe=`session-replay-unmask`,QP=({borderPositionAndSize:e,className:t})=>(0,U.jsx)(`div`,{style:{borderTopColor:`transparent`},className:W(`border-zuplo-pink`,{"border-4":!e,[`${e}`]:e},`border-solid rounded-full animate-spin`,t)}),dLe=({success:e,className:t})=>e?(0,U.jsx)(td,{className:W(`w-5 h-5 text-green-600`,t)}):(0,U.jsx)(xd,{className:W(`w-5 h-5 rotate-90`,t),"aria-hidden":`true`}),$P=({textToCopy:e,onClick:t,title:n,className:r,iconClassName:i})=>{let a=jC(e??``);return(0,U.jsx)(`button`,{disabled:a.state===`copied`,onClick:e=>{t?.(e),a.copyToClipboard()},type:`button`,title:n??`Copy`,className:(0,KP.default)(r,`ml-1 hover:text-gray-800 text-gray-400 cursor-pointer`),children:a.state===`loading`?(0,U.jsx)(QP,{className:`h-4 w-4 border-2`}):(0,U.jsx)(dLe,{success:a.state===`copied`,className:W(`w-3.5 h-3.5`,i)})})},eF=null,tF=null;function fLe(){return tF??=gn(()=>import(`./editor.main-B7ZQNwu9.js`).then(e=>(eF=e,e)),__vite__mapDeps([0,1,2,3,4,5,6])),tF}function nF(){let[e,t]=(0,H.useState)(eF);return(0,H.useEffect)(()=>{if(eF){t(eF);return}let e=!0;return fLe().then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}var rF=null;function iF(e,t,n){let r=(0,H.useRef)(!1);(0,H.useEffect)(()=>{if(!e)return;if(!r.current){r.current=!0;return}let i=requestAnimationFrame(()=>{if(n.current&&t!==rF)try{e.editor.setTheme(t),rF=t}catch{}});return()=>cancelAnimationFrame(i)},[e,t,n])}var aF={display:`flex`,position:`relative`,textAlign:`initial`};function pLe({value:e,defaultValue:t,language:n,defaultLanguage:r,path:i,theme:a=`vs`,line:o,options:s={},overrideServices:c,onChange:l,onMount:u,beforeMount:d,className:f,width:p=`100%`,height:m=`100%`,keepCurrentModel:h=!1,wrapperProps:g}){let _=nF(),v=(0,H.useRef)(null),y=(0,H.useRef)(null),b=(0,H.useRef)(l);b.current=l;let x=(0,H.useRef)(h);x.current=h;let S=(0,H.useRef)(!1);return(0,H.useEffect)(()=>{if(!_)return;let l=v.current;if(!l)return;d?.(_);let f=i?_.Uri.parse(i):void 0,p=f&&_.editor.getModel(f)||_.editor.createModel(e??t??``,n??r,f),m=_.editor.create(l,{...s,model:p,theme:a},c);y.current=m,o!=null&&m.revealLine(o);let h=m.onDidChangeModelContent(e=>{S.current||b.current?.(m.getValue(),e)});return u?.(m,_),()=>{h.dispose();let e=m.getModel();m.dispose(),x.current||e?.dispose(),y.current=null}},[_]),(0,H.useEffect)(()=>{let t=y.current;if(!t||e===void 0)return;let n=t.getModel();!n||e===n.getValue()||(S.current=!0,t.executeEdits(``,[{range:n.getFullModelRange(),text:e,forceMoveMarkers:!0}]),t.pushUndoStop(),S.current=!1)},[e]),(0,H.useEffect)(()=>{let e=y.current?.getModel();_&&e&&n&&_.editor.setModelLanguage(e,n)},[_,n]),iF(_,a,y),(0,H.useEffect)(()=>{y.current?.updateOptions(s)},[s]),(0,H.useEffect)(()=>{o!=null&&y.current?.revealLine(o)},[o]),(0,U.jsx)(`section`,{...g,style:{...aF,width:p,height:m},children:(0,U.jsx)(`div`,{ref:v,className:f,style:{width:`100%`}})})}function mLe({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,theme:a=`vs`,options:o={},onMount:s,beforeMount:c,className:l,width:u=`100%`,height:d=`100%`,keepCurrentOriginalModel:f=!1,keepCurrentModifiedModel:p=!1,wrapperProps:m}){let h=nF(),g=(0,H.useRef)(null),_=(0,H.useRef)(null),v=(0,H.useRef)(f);v.current=f;let y=(0,H.useRef)(p);return y.current=p,(0,H.useEffect)(()=>{if(!h)return;let l=g.current;if(!l)return;c?.(h);let u=h.editor.createDiffEditor(l,{...o,theme:a});return _.current=u,u.setModel({original:h.editor.createModel(e??``,r??n),modified:h.editor.createModel(t??``,i??n)}),s?.(u,h),()=>{let e=u.getModel();u.dispose(),v.current||e?.original.dispose(),y.current||e?.modified.dispose(),_.current=null}},[h]),(0,H.useEffect)(()=>{let t=_.current?.getModel();t&&e!=null&&e!==t.original.getValue()&&t.original.setValue(e)},[e]),(0,H.useEffect)(()=>{let e=_.current?.getModel();e&&t!=null&&t!==e.modified.getValue()&&e.modified.setValue(t)},[t]),iF(h,a,_),(0,U.jsx)(`section`,{...m,style:{...aF,width:u,height:d},children:(0,U.jsx)(`div`,{ref:g,className:l,style:{width:`100%`}})})}var oF=`zuplo-light`,sF=`zuplo-dark`,cF=`#191918`,lF=e=>{e.editor.defineTheme(oF,{base:`vs`,inherit:!0,rules:[],colors:{}}),e.editor.defineTheme(sF,{base:`vs-dark`,inherit:!0,rules:[],colors:{"editor.background":cF,"editorGutter.background":cF,"minimap.background":cF,"editorStickyScroll.background":cF,"editorStickyScrollHover.background":`#262626`,"breadcrumb.background":cF,"editorWidget.background":cF}})},hLe=e=>e===`dark`?sF:oF,uF=()=>{let{colorScheme:e}=Xe();return hLe(e)},dF=({beforeMount:e,theme:t,...n})=>{let r=uF(),i=t=>{lF(t),e?.(t)};return(0,U.jsx)(pLe,{...n,beforeMount:i,theme:r})},fF=({beforeMount:e,theme:t,...n})=>{let r=uF(),i=t=>{lF(t),e?.(t)};return(0,U.jsx)(mLe,{...n,beforeMount:i,theme:r})},pF=`AlertDialog`,[gLe,_Le]=T(pF,[b]),mF=b(),hF=e=>{let{__scopeAlertDialog:t,...n}=e,r=mF(t);return(0,U.jsx)(_,{...r,...n,modal:!0})};hF.displayName=pF;var vLe=`AlertDialogTrigger`,yLe=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=mF(n);return(0,U.jsx)(Te,{...i,...r,ref:t})});yLe.displayName=vLe;var bLe=`AlertDialogPortal`,gF=e=>{let{__scopeAlertDialog:t,...n}=e,r=mF(t);return(0,U.jsx)(Se,{...r,...n})};gF.displayName=bLe;var xLe=`AlertDialogOverlay`,_F=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=mF(n);return(0,U.jsx)(un,{...i,...r,ref:t})});_F.displayName=xLe;var vF=`AlertDialogContent`,[SLe,CLe]=gLe(vF),wLe=F(`AlertDialogContent`),yF=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:r,...i}=e,a=mF(n),o=H.useRef(null),s=ve(t,o),c=H.useRef(null);return(0,U.jsx)(C,{contentName:vF,titleName:bF,docsSlug:`alert-dialog`,children:(0,U.jsx)(SLe,{scope:n,cancelRef:c,children:(0,U.jsxs)(fn,{role:`alertdialog`,...a,...i,ref:s,onOpenAutoFocus:hn(i.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,U.jsx)(wLe,{children:r}),(0,U.jsx)(ELe,{contentRef:o})]})})})});yF.displayName=vF;var bF=`AlertDialogTitle`,xF=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=mF(n);return(0,U.jsx)(sn,{...i,...r,ref:t})});xF.displayName=bF;var SF=`AlertDialogDescription`,CF=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=mF(n);return(0,U.jsx)(Qe,{...i,...r,ref:t})});CF.displayName=SF;var TLe=`AlertDialogAction`,wF=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=mF(n);return(0,U.jsx)(rn,{...i,...r,ref:t})});wF.displayName=TLe;var TF=`AlertDialogCancel`,EF=H.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=CLe(TF,n),a=mF(n),o=ve(t,i);return(0,U.jsx)(rn,{...a,...r,ref:o})});EF.displayName=TF;var ELe=({contentRef:e})=>{let t=`\`${vF}\` requires a description for the component to be accessible for screen reader users.
|
|
244
244
|
|
|
245
245
|
You can add a description to the \`${vF}\` by passing a \`${SF}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
246
246
|
|
|
@@ -350,7 +350,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
350
350
|
`+e.slice(o+1):c+=e.slice(i),c.slice(1)}function mut(e){for(var t=``,n=0,r,i=0;i<e.length;n>=65536?i+=2:i++)n=gZ(e,i),r=dZ[n],!r&&hZ(n)?(t+=e[i],n>=65536&&(t+=e[i+1])):t+=r||Ylt(n);return t}function hut(e,t,n){var r=``,i=e.tag,a,o,s;for(a=0,o=n.length;a<o;a+=1)s=n[a],e.replacer&&(s=e.replacer.call(n,String(a),s)),(yZ(e,t,s,!1,!1)||s===void 0&&yZ(e,t,null,!1,!1))&&(r!==``&&(r+=`,`+(e.condenseFlow?``:` `)),r+=e.dump);e.tag=i,e.dump=`[`+r+`]`}function gut(e,t,n,r){var i=``,a=e.tag,o,s,c;for(o=0,s=n.length;o<s;o+=1)c=n[o],e.replacer&&(c=e.replacer.call(n,String(o),c)),(yZ(e,t+1,c,!0,!0,!1,!0)||c===void 0&&yZ(e,t+1,null,!0,!0,!1,!0))&&((!r||i!==``)&&(i+=pZ(e,t)),e.dump&&cZ===e.dump.charCodeAt(0)?i+=`-`:i+=`- `,i+=e.dump);e.tag=a,e.dump=i||`[]`}function _ut(e,t,n){var r=``,i=e.tag,a=Object.keys(n),o,s,c,l,u;for(o=0,s=a.length;o<s;o+=1)u=``,r!==``&&(u+=`, `),e.condenseFlow&&(u+=`"`),c=a[o],l=n[c],e.replacer&&(l=e.replacer.call(n,c,l)),yZ(e,t,c,!1,!1)&&(e.dump.length>1024&&(u+=`? `),u+=e.dump+(e.condenseFlow?`"`:``)+`:`+(e.condenseFlow?``:` `),yZ(e,t,l,!1,!1)&&(u+=e.dump,r+=u));e.tag=i,e.dump=`{`+r+`}`}function vut(e,t,n,r){var i=``,a=e.tag,o=Object.keys(n),s,c,l,u,d,f;if(e.sortKeys===!0)o.sort();else if(typeof e.sortKeys==`function`)o.sort(e.sortKeys);else if(e.sortKeys)throw new IX(`sortKeys must be a boolean or a function`);for(s=0,c=o.length;s<c;s+=1)f=``,(!r||i!==``)&&(f+=pZ(e,t)),l=o[s],u=n[l],e.replacer&&(u=e.replacer.call(n,l,u)),yZ(e,t+1,l,!0,!0,!0)&&(d=e.tag!==null&&e.tag!==`?`||e.dump&&e.dump.length>1024,d&&(e.dump&&cZ===e.dump.charCodeAt(0)?f+=`?`:f+=`? `),f+=e.dump,d&&(f+=pZ(e,t)),yZ(e,t+1,u,!0,d)&&(e.dump&&cZ===e.dump.charCodeAt(0)?f+=`:`:f+=`: `,f+=e.dump,i+=f));e.tag=a,e.dump=i||`{}`}function yut(e,t,n){var r,i=n?e.explicitTypes:e.implicitTypes,a,o,s,c;for(a=0,o=i.length;a<o;a+=1)if(s=i[a],(s.instanceOf||s.predicate)&&(!s.instanceOf||typeof t==`object`&&t instanceof s.instanceOf)&&(!s.predicate||s.predicate(t))){if(n?s.multi&&s.representName?e.tag=s.representName(t):e.tag=s.tag:e.tag=`?`,s.represent){if(c=e.styleMap[s.tag]||s.defaultStyle,Clt.call(s.represent)===`[object Function]`)r=s.represent(t,c);else if(wlt.call(s.represent,c))r=s.represent[c](t,c);else throw new IX(`!<`+s.tag+`> tag resolver accepts not "`+c+`" style`);e.dump=r}return!0}return!1}function yZ(e,t,n,r,i,a,o){e.tag=null,e.dump=n,yut(e,n,!1)||yut(e,n,!0);var s=Clt.call(e.dump),c=r,l;r&&=e.flowLevel<0||e.flowLevel>t;var u=s===`[object Object]`||s===`[object Array]`,d,f;if(u&&(d=e.duplicates.indexOf(n),f=d!==-1),(e.tag!==null&&e.tag!==`?`||f||e.indent!==2&&t>0)&&(i=!1),f&&e.usedDuplicates[d])e.dump=`*ref_`+d;else{if(u&&f&&!e.usedDuplicates[d]&&(e.usedDuplicates[d]=!0),s===`[object Object]`)r&&Object.keys(e.dump).length!==0?(vut(e,t,e.dump,i),f&&(e.dump=`&ref_`+d+e.dump)):(_ut(e,t,e.dump),f&&(e.dump=`&ref_`+d+` `+e.dump));else if(s===`[object Array]`)r&&e.dump.length!==0?(e.noArrayIndent&&!o&&t>0?gut(e,t-1,e.dump,i):gut(e,t,e.dump,i),f&&(e.dump=`&ref_`+d+e.dump)):(hut(e,t,e.dump),f&&(e.dump=`&ref_`+d+` `+e.dump));else if(s===`[object String]`)e.tag!==`?`&&lut(e,e.dump,t,a,c);else if(s===`[object Undefined]`)return!1;else{if(e.skipInvalid)return!1;throw new IX(`unacceptable kind of an object to dump `+s)}e.tag!==null&&e.tag!==`?`&&(l=encodeURI(e.tag[0]===`!`?e.tag.slice(1):e.tag).replace(/!/g,`%21`),l=e.tag[0]===`!`?`!`+l:l.slice(0,18)===`tag:yaml.org,2002:`?`!!`+l.slice(18):`!<`+l+`>`,e.dump=l+` `+e.dump)}return!0}function but(e,t){var n=[],r=[],i,a;for(bZ(e,n,r),i=0,a=r.length;i<a;i+=1)t.duplicates.push(n[r[i]]);t.usedDuplicates=Array(a)}function bZ(e,t,n){var r,i,a;if(typeof e==`object`&&e)if(i=t.indexOf(e),i!==-1)n.indexOf(i)===-1&&n.push(i);else if(t.push(e),Array.isArray(e))for(i=0,a=e.length;i<a;i+=1)bZ(e[i],t,n);else for(r=Object.keys(e),i=0,a=r.length;i<a;i+=1)bZ(e[r[i]],t,n)}function xut(e,t){t||={};var n=new Zlt(t);n.noRefs||but(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},``,r)),yZ(n,0,r,!0,!0)?n.dump+`
|
|
351
351
|
`:``}var Sut={dump:xut};function xZ(e,t){return function(){throw Error(`Function yaml.`+e+` is removed in js-yaml 4. Use yaml.`+t+` instead, which is now safe by default.`)}}var Cut={Type:zX,Schema:zst,FAILSAFE_SCHEMA:Ust,JSON_SCHEMA:fct,CORE_SCHEMA:pct,DEFAULT_SCHEMA:HX,load:Slt.load,loadAll:Slt.loadAll,dump:Sut.dump,YAMLException:IX,types:{binary:Ect,float:dct,map:Hst,null:qst,pairs:Fct,set:zct,timestamp:yct,bool:Zst,int:ict,merge:xct,omap:jct,seq:Vst,str:Bst},safeLoad:xZ(`safeLoad`,`load`),safeLoadAll:xZ(`safeLoadAll`,`loadAll`),safeDump:xZ(`safeDump`,`dump`)},wut=[`get`,`put`,`post`,`delete`,`options`,`head`,`patch`,`trace`],Tut=async e=>{let t=await e.text();return e.name.endsWith(`.json`)?JSON.parse(t):Cut.load(t)},Eut=(e,t)=>Dut(e,t),Dut=(e,t)=>{let n=new Set(Object.values(e.paths??{}).flatMap(e=>e?wut.flatMap(t=>e[t]?.operationId??[]):[])),r=e.paths;return t.paths&&(r=Object.entries(t.paths).reduce((e,[t,r])=>{let i=e[t];return e[t]=Aut(i??{},r,t,n),e},e.paths??{})),{info:t.info,openapi:kut(e.openapi,t.openapi),components:Out(e.components,t.components),jsonSchemaDialect:t.jsonSchemaDialect??e.jsonSchemaDialect,servers:t.servers??e.servers,security:t.security??e.security,tags:t.tags??e.tags,externalDocs:t.externalDocs??e.externalDocs,paths:r}},Out=(e,t)=>{if(!e)return t;if(!t)return e;let{schemas:n,responses:r,parameters:i,examples:a,requestBodies:o,headers:s,securitySchemes:c,links:l,callbacks:u,pathItems:d}=e,{schemas:f,responses:p,parameters:m,examples:h,requestBodies:g,headers:_,securitySchemes:v,links:y,callbacks:b,pathItems:x}=t;return{schemas:n?{...n,...f}:f,responses:r?{...r,...p}:p,parameters:i?{...i,...m}:m,examples:a?{...a,...h}:h,requestBodies:o?{...o,...g}:g,headers:s?{...s,..._}:_,securitySchemes:c?{...c,...v}:v,links:l?{...l,...y}:y,callbacks:u?{...u,...b}:b,pathItems:d?{...d,...x}:x}},kut=(e,t)=>e===`3.1.0`?e:t===`3.1.0`?t:e,Aut=(e,t,n,r)=>{let{summary:i,description:a,get:o,put:s,post:c,delete:l,options:u,head:d,patch:f,trace:p,servers:m,parameters:h}=e,g=e[kX],_=typeof t==`object`&&t&&kX in t?t[kX]:void 0;return{summary:t.summary??i,description:t.description??a,[kX]:_??g,servers:t.servers??m,parameters:t.parameters??h,get:SZ(o,t.get,`get`,n,r),put:SZ(s,t.put,`put`,n,r),post:SZ(c,t.post,`post`,n,r),delete:SZ(l,t.delete,`delete`,n,r),options:SZ(u,t.options,`options`,n,r),head:SZ(d,t.head,`head`,n,r),patch:SZ(f,t.patch,`patch`,n,r),trace:SZ(p,t.trace,`trace`,n,r)}},SZ=(e,t,n,r,i)=>{if(!t)return e;let a=e?.operationId??t.operationId??EX(t,{method:n,path:r,existingOperationIds:i});i&&i.add(a);let o=e?.[AX];return{...t,operationId:a,[AX]:o}},jut=(e,t)=>Mut(e,t),Mut=(e,t)=>{let n=new Set,r=new Set,i=new Set,a=e.paths,o=t.paths;if(!a&&!o)return{created:n,merged:r,retained:i};if(!a&&o)return n=new Set(CZ(o)),{created:n,merged:r,retained:i};if(!o&&a)return i=new Set(CZ(a)),{created:n,merged:r,retained:i};if(o&&a){let e=CZ(a),t=CZ(o),s=new Set(e),c=new Set(t);t.forEach(e=>{s.has(e)?r.add(e):n.add(e)}),e.forEach(e=>{c.has(e)||i.add(e)})}return{created:n,merged:r,retained:i}},CZ=e=>Object.entries(e).flatMap(([e,t])=>Object.keys(t).filter(e=>wut.includes(e)).map(t=>`${t}>${e}`)),wZ=[`get`,`post`,`put`,`patch`,`delete`,`options`,`head`,`trace`],Nut=`$import(@zuplo/runtime)`,Put=e=>{if(!e)return;let t=/^\$import\((.+)\)$/.exec(e);return t?t[1]:e},Fut=e=>{try{return new URL(e).hostname}catch{return e}},Iut=e=>{let t=e.options??{};if(e.module===Nut)switch(e.export){case`urlForwardHandler`:{let e=typeof t.baseUrl==`string`?t.baseUrl:``;return{name:e?Fut(e):`URL Forward`,detail:e?`URL Forward · ${e}`:`URL Forward`,kind:`url-forward`}}case`urlRewriteHandler`:{let e=typeof t.rewritePattern==`string`?t.rewritePattern:``;return{name:e?Fut(e):`URL Rewrite`,detail:e?`URL Rewrite · ${e}`:`URL Rewrite`,kind:`url-rewrite`}}case`redirectHandler`:return{name:`Redirect`,detail:(typeof t.location==`string`?t.location:``)||void 0,kind:`redirect`};case`awsLambdaHandler`:{let e=typeof t.functionName==`string`?t.functionName:``;return{name:e||`AWS Lambda`,detail:e?`AWS Lambda`:void 0,kind:`aws-lambda`}}case`mcpServerHandler`:return{name:`MCP Server`,detail:`Dynamic`,kind:`mcp`};case`McpProxyHandler`:case`McpVirtualServerHandler`:case`mcpVirtualServerHandler`:return{name:`MCP Server`,detail:`Proxy`,kind:`mcp`};case`mockApiHandler`:return{name:`Mock API`,kind:`mock`};default:return{name:e.export,detail:`Built-in handler`,kind:`other`}}return{name:e.export,detail:Put(e.module),kind:`function`}},Lut=e=>JSON.stringify([e.export,e.module,e.options??null]),Rut=(e,t)=>{let n=[],r=[],i=new Map,a=new Set;for(let t of e){for(let e of t.doc?.tags??[])typeof e?.name==`string`&&a.add(e.name);let e=t.doc?.paths??{};for(let[o,s]of Object.entries(e))if(s)for(let e of wZ){let c=s[e];if(!c)continue;let l=c[AX],u,d=l?.handler;if(d&&(u=Lut(d),!i.has(u))){let e={key:u,definition:d,...Iut(d)};i.set(u,e),r.push(e)}let f=c.tags??[];for(let e of f)a.add(e);n.push({id:`${t.path}#${c.operationId||`${e} ${o}`}`,method:e.toUpperCase(),path:o,summary:c.summary,operationId:c.operationId,filePath:t.path,inboundPolicies:l?.policies?.inbound??[],outboundPolicies:l?.policies?.outbound??[],tags:f,isGraphql:c[OX]===!0,handlerKey:u})}}let o={};for(let e of t)o[e.name]=e;return{routes:n,handlers:r,files:e.map(e=>e.path),policyConfigs:o,allTags:[...a]}},zut=`/config/policies.json`,But=e=>[`api-flow-model`,e],Vut=(e,t)=>{let n=Object.keys(e).sort().map(t=>{try{return{path:t,doc:JSON.parse(e[t].content)}}catch{return{path:t,doc:void 0}}}),r=[],i=[];try{let e=JSON.parse(t?.content??`{}`);r=Array.isArray(e.policies)?e.policies:[],i=Array.isArray(e.corsPolicies)?e.corsPolicies:[]}catch{}return{model:Rut(n,r),rawFiles:e,policiesFile:t,corsPolicies:i}},Hut=(e,t)=>Oe({enabled:t?.enabled,queryKey:But(e),queryFn:async()=>{let t=(await Ys(e,`/`)).filter(e=>e.type===Us.File&&_p.test(e.path)).map(e=>e.path),n={},[,r]=await Promise.all([Promise.all(t.map(async t=>{try{let r=await Js(e,t);n[t]={content:r.content??``,lastModified:r.lastModified}}catch{}})),Js(e,zut).catch(()=>void 0)]);return Vut(n,r?{content:r.content??``,lastModified:r.lastModified}:void 0)}});function Uut(e){if(typeof e!=`object`||!e)return{};let t=e;return{message:typeof t.message==`string`?t.message:void 0}}var Wut=e=>e.replace(/\.(oas\.)?(json|yaml|yml)$/i,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`imported`;function Gut({data:e,onSend:t,disabled:n,primaryProject:r}){let{account:i,project:a}=Wb([]),{logEvent:o}=on(),s=at(),c=r??a,l=xR(i??``,c??``,{enabled:!!(i&&c)}),u=l.data?.find(e=>e.urlParameter===wR)?.name,[d,f]=(0,H.useState)(`idle`),[p,m]=(0,H.useState)(),[h,g]=(0,H.useState)(),_=!!(i&&c&&u),v=i?c?l.isError?`Couldn't load this project's environments — try again in a moment.`:!u&&!l.isLoading?`This project has no working copy to import into yet.`:void 0:`Open a project to import an OpenAPI file.`:void 0,y=async e=>{if(u){f(`saving`),m(e.name),g(void 0),o(`agent-z-openapi-import-started`,{account:i,project:c});try{let n=await Tut(e);if(typeof n!=`object`||!n||!(`openapi`in n))throw Error(`That file doesn't look like an OpenAPI document (missing the "openapi" field).`);let r=yst(n),a=JSON.stringify(r,null,2),l=await Ys(u,`/config`).catch(()=>[]),d=new Set(l.map(e=>`/${e.path.replace(/^\/+/,``)}`)),p=Wut(e.name),m=`/config/${p}.oas.json`;for(let e=2;d.has(m);e++)m=`/config/${p}-${e}.oas.json`;await Xs(u,{path:m,content:a}),s.invalidateQueries({queryKey:[`reloadFiles`],exact:!1}),s.invalidateQueries({queryKey:But(u)}),s.invalidateQueries({predicate:e=>{let t=e.queryKey[0];if(typeof t!=`string`)return!1;let n=t.split(`?`)[0];return n.includes(`/fs/file`)||/\/deployments\/[^/]+\/versions$/.test(n)}}),s.invalidateQueries({queryKey:[`get`,`/v1/deployments/{deploymentName}/versions`]}),f(`done`),o(`agent-z-openapi-import-succeeded`,{account:i,project:c}),t(`I've uploaded the OpenAPI file "${e.name}". It's been saved to ${m} in the working copy.`)}catch(e){f(`error`),g(e instanceof Error?e.message:`Something went wrong importing that file.`),o(`agent-z-openapi-import-failed`,{account:i,project:c})}}};return(0,U.jsx)(Aje,{data:e,status:d,fileName:p,errorText:h??v,disabled:n||!_||d===`saving`,onFileSelected:e=>void y(e)})}var Kut=[{id:`explain-project`,prompt:`What does this project do?`,category:`orientation`},{id:`tour-project`,prompt:`Give me a tour of this project.`,category:`orientation`},{id:`explain-routes`,prompt:`What routes are defined in this project?`,category:`orientation`},{id:`explain-policies-configured`,prompt:`Which policies are configured here, and what do they do?`,category:`orientation`},{id:`whats-new`,prompt:`What can Zuplo AI help me with?`,category:`orientation`},{id:`build-first-api`,prompt:`Help me build my first API.`,category:`getting-started`},{id:`add-route`,prompt:`How do I add a new route?`,category:`getting-started`},{id:`proxy-existing-api`,prompt:`I want to put a gateway in front of my existing API.`,category:`getting-started`},{id:`import-openapi`,prompt:`How do I import an OpenAPI spec?`,category:`getting-started`},{id:`connect-source-control`,prompt:`How do I connect this project to GitHub?`,category:`getting-started`},{id:`setup-rate-limiting`,prompt:`Walk me through setting up rate limiting.`,category:`rate-limiting`},{id:`rate-limit-per-user`,prompt:`How do I rate limit per API key?`,category:`rate-limiting`},{id:`rate-limit-tiers`,prompt:`Set up different rate limits for free and paid tiers.`,category:`rate-limiting`},{id:`add-api-key-auth`,prompt:`Add API key authentication to my routes.`,category:`auth`},{id:`add-jwt-auth`,prompt:`How do I validate JWTs from my auth provider?`,category:`auth`},{id:`secure-all-routes`,prompt:`How do I require authentication on every route?`,category:`auth`},{id:`role-based-access`,prompt:`Set up role-based access control for my API.`,category:`auth`},{id:`check-build-status`,prompt:`Check the latest build status.`,category:`deployments`},{id:`deploy-to-production`,prompt:`How do I deploy this to production?`,category:`deployments`},{id:`explain-environments`,prompt:`Explain how environments and preview deployments work.`,category:`deployments`},{id:`set-env-variable`,prompt:`How do I add an environment variable or secret?`,category:`deployments`},{id:`debug-build-failure`,prompt:`Why did my last build fail?`,category:`debugging`},{id:`debug-500`,prompt:`My API is returning 500 errors — help me debug.`,category:`debugging`},{id:`debug-cors`,prompt:`I'm getting CORS errors. How do I fix them?`,category:`debugging`},{id:`read-logs`,prompt:`Show me recent errors in the logs.`,category:`debugging`},{id:`transform-response`,prompt:`How do I transform a response before it's returned?`,category:`policies`},{id:`add-caching`,prompt:`Add caching to one of my routes.`,category:`policies`},{id:`validate-request-body`,prompt:`Validate incoming request bodies against a schema.`,category:`policies`},{id:`custom-policy`,prompt:`How do I write a custom policy?`,category:`policies`},{id:`aggregate-apis`,prompt:`Combine responses from two backends into one.`,category:`policies`},{id:`monitor-traffic`,prompt:`How can I see traffic and latency for my API?`,category:`monitoring`},{id:`set-up-alerts`,prompt:`Can I get alerted when error rates spike?`,category:`monitoring`},{id:`ai-gateway-intro`,prompt:`What is the AI Gateway and what can it do?`,category:`ai-gateway`},{id:`ai-gateway-add-provider`,prompt:`How do I route requests to an LLM provider?`,category:`ai-gateway`},{id:`generate-docs`,prompt:`Generate API documentation for my project.`,category:`developer-experience`},{id:`create-dev-portal`,prompt:`How do I publish a developer portal for my API?`,category:`developer-experience`}];function qut(e=4,t=Math.random){let n=[...Kut],r=Math.max(0,Math.min(e,n.length));for(let e=0;e<r;e++){let r=Math.min(n.length-1,e+Math.floor(t()*(n.length-e)));[n[e],n[r]]=[n[r],n[e]]}return n.slice(0,r)}function Jut(e){if(typeof e!=`object`||!e)return null;let t=e;return{description:typeof t.description==`string`?t.description:void 0}}function Yut({data:e}){let t=Qa(),{account:n,project:r}=Wb([]),{logEvent:i}=on(),a=!!(n&&r);return(0,U.jsx)(Eje,{description:e.description,disabled:!a,onOpen:()=>{!n||!r||(i(`agent-z-update-working-copy-card-clicked`,{account:n,project:r}),t(`${$r(Yb.Code,{account:n,project:r,environment:wR})}?${zme}=${Bme}`))}})}function Xut(e,t,n){let[r,i]=(0,H.useState)(void 0),a=r&&r.account===e?r.name:void 0,o=(0,H.useCallback)(t=>{let n=t.trim();n&&i({account:e,name:n})},[e]),s=(0,H.useCallback)(e=>e===a,[a]),c=(0,H.useRef)(void 0);return(0,H.useEffect)(()=>{let r=t?`${e??``}/${t}`:void 0;n&&t&&r!==c.current&&(o(t),c.current=r)},[n,e,t,o]),(0,H.useMemo)(()=>({name:a,select:o,isActive:s}),[a,o,s])}var Zut=new Set([`create-ai-team`,`create-ai-app`]);function Qut(e){let t=at(),n=(0,H.useRef)(new Set);(0,H.useEffect)(()=>{let r=!1;for(let t of e)if(t.role===`assistant`)for(let e of t.parts){if(!jx(e)||!Zut.has(Nx(e))||e.state!==`output-available`)continue;let t=e.toolCallId;!t||n.current.has(t)||(n.current.add(t),r=!0)}r&&t.invalidateQueries()},[e,t])}var $ut=`save-file`;function edt(e){let t=at(),n=(0,H.useRef)(new Set);(0,H.useEffect)(()=>{let r=!1;for(let t of e)if(t.role===`assistant`)for(let e of t.parts){if(!jx(e)||Nx(e)!==$ut||e.state!==`output-available`)continue;let t=e.toolCallId;!t||n.current.has(t)||(n.current.add(t),r=!0)}r&&(t.invalidateQueries({queryKey:[`reloadFiles`],exact:!1}),t.invalidateQueries({predicate:e=>{let t=e.queryKey[0];if(typeof t!=`string`)return!1;let n=t.split(`?`)[0];return n.includes(`/fs/file`)||/\/deployments\/[^/]+\/versions$/.test(n)}}),t.invalidateQueries({queryKey:[`get`,`/v1/deployments/{deploymentName}/versions`]}))},[e,t])}var tdt=`create-working-copy`;function ndt(e){let t=at(),n=(0,H.useRef)(new Set);(0,H.useEffect)(()=>{let r=!1;for(let t of e)if(t.role===`assistant`)for(let e of t.parts){if(!jx(e)||Nx(e)!==tdt||e.state!==`output-available`)continue;let t=e.toolCallId;!t||n.current.has(t)||(n.current.add(t),r=!0)}r&&t.invalidateQueries()},[e,t])}function rdt(e){if(typeof e!=`object`||!e)return null;let t=e;if(!Array.isArray(t.options))return null;let n=[];for(let e of t.options){if(typeof e!=`object`||!e)continue;let t=e,r=typeof t.label==`string`?t.label:void 0;r&&n.push({id:typeof t.id==`string`?t.id:r,label:r,description:typeof t.description==`string`?t.description:void 0})}return n.length===0?null:{prompt:typeof t.prompt==`string`?t.prompt:void 0,options:n}}function idt(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.url==`string`?t.url:void 0,r=typeof t.label==`string`?t.label:void 0;if(!n||!r)return null;let i;try{i=new URL(n)}catch{return null}return i.protocol!==`https:`&&i.protocol!==`http:`?null:{url:i.href,label:r,description:typeof t.description==`string`?t.description:void 0}}function adt(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.projectName==`string`?t.projectName.trim():``;return n?{projectName:n,reason:typeof t.reason==`string`?t.reason:void 0}:null}var odt=`https://zuplo.com/docs`;function sdt(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.url==`string`?t.url.trim():void 0;if(!n)return null;let r=typeof t.title==`string`?t.title:void 0,i=n.replace(/\.mdx?(?=$|[?#])/i,``);if(/^[a-z][a-z0-9+.-]*:/i.test(i)){let e;try{e=new URL(i)}catch{return null}return e.protocol!==`https:`&&e.protocol!==`http:`?null:{url:e.href,title:r}}return{url:`${odt}/${i.replace(/^\/?(docs\/)?/,``)}`,title:r}}function cdt({active:e}){let t=Ze(),{logEvent:n}=on(),{account:r,project:i}=Wb([]),a=Xut(r,i,e),{pendingPrompt:o,clearPendingPrompt:s}=EZ(),c=(0,H.useMemo)(()=>crypto.randomUUID(),[]),{messages:l,sendMessage:u,status:d,error:f,stop:p,addToolApprovalResponse:m}=I_e({transport:(0,H.useMemo)(()=>new T_e({api:O}),[]),sendAutomaticallyWhen:D_e});edt(l),ndt(l),Qut(l);let[h,g]=(0,H.useState)(``),_=d===`submitted`||d===`streaming`,v=_&&l[l.length-1]?.role!==`assistant`,y=(0,H.useRef)(null),b=(0,H.useRef)(null),[x,S]=(0,H.useState)(!0),C=(0,H.useRef)(null),w=(0,H.useRef)(void 0),T=(0,H.useRef)(!1),E=(0,H.useRef)(!1),D=(0,H.useRef)(!1);(0,H.useEffect)(()=>{if(!x)return;let e=y.current;e&&e.scrollTo({top:e.scrollHeight})},[l,d]);let k=()=>{let e=y.current;e&&S(e.scrollHeight-e.scrollTop-e.clientHeight<=32)},A=()=>{let e=y.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`}),S(!0)};(0,H.useEffect)(()=>{e&&b.current?.focus()},[e]);let j=async(e,o,s,d)=>{let f=e.trim();if(!f||_)return;let p=d??a.name;n(`agent-z-message-sent`,{source:o,ctaId:s,messageLength:f.length,isFirstMessage:l.length===0,account:r,project:i,hasProject:!!i,activeProject:p}),g(``),w.current=p,S(!0);try{let e=await t();await u({text:f},{headers:{Authorization:`Bearer ${e}`},body:{accountName:r,projectName:p,sessionId:c}})}catch{g(e=>e.length===0?f:e)}},M=async(e,o)=>{n(`agent-z-tool-approval-responded`,{approved:o,account:r,project:i});try{await m({id:e,approved:o,options:{headers:{Authorization:`Bearer ${await t()}`},body:{accountName:r,projectName:w.current??a.name,sessionId:c}}})}catch{}},N=e=>{a.isActive(e)||(a.select(e),n(`agent-z-active-project-changed`,{source:`suggestion`,account:r,project:e}),j(`Switched to ${e} — go ahead.`,`context-suggestion`,void 0,e))};(0,H.useEffect)(()=>{if(o&&!_){let e=i??a.name;i&&!a.isActive(i)&&a.select(i),j(o,`resolve-handoff`,void 0,e),s()}},[o,_,s]),(0,H.useEffect)(()=>{if(_&&C.current===null&&(C.current=performance.now()),T.current&&!_){let e=C.current,t=e===null?void 0:Math.round(performance.now()-e);C.current=null,E.current?E.current=!1:f||n(`agent-z-response-completed`,{durationMs:t,toolCallCount:[...l].reverse().find(e=>e.role===`assistant`)?.parts.filter(jx).length??0})}T.current=_},[_,f,n]),(0,H.useEffect)(()=>{f&&!D.current?(D.current=!0,n(`agent-z-response-error`,{message:f.message})):f||(D.current=!1)},[f,n]);let P=e=>{e.preventDefault(),j(h,`composer`)},F=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),j(h,`composer`))};return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-sunken`,children:[(0,U.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,U.jsx)(`div`,{ref:y,onScroll:k,className:`h-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`flex w-full flex-col gap-4 px-4 py-4`,children:[l.length===0?(0,U.jsx)(fdt,{active:e,onPick:e=>void j(e.prompt,`suggested-prompt`,e.id)}):l.map((e,t)=>(0,U.jsx)(ldt,{message:e,onSend:e=>void j(e,`option`),onApproval:(e,t)=>void M(e,t),onSwitchProject:N,isActiveProject:a.isActive,primaryProject:a.name,disabled:_,isStreaming:_&&t===l.length-1},e.id)),v?(0,U.jsx)(YE,{children:(0,U.jsx)(eD,{})}):null,f?(0,U.jsx)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/5 px-4 py-3 text-sm text-destructive-foreground`,children:`Something went wrong talking to Zuplo AI. Please try again.`}):null]})}),x?null:(0,U.jsx)(X,{type:`button`,variant:`outline`,size:`icon`,onClick:A,"aria-label":`Scroll to latest messages`,className:`-translate-x-1/2 absolute bottom-4 left-1/2 rounded-full shadow-md`,children:(0,U.jsx)(Iu,{})})]}),(0,U.jsxs)(`div`,{className:`border-t bg-background`,children:[r?(0,U.jsx)(UOe,{accountName:r,active:a}):null,(0,U.jsxs)(`form`,{onSubmit:P,className:`flex w-full items-end gap-2 px-4 py-3`,children:[(0,U.jsx)(AC,{ref:b,value:h,onChange:e=>g(e.target.value),onKeyDown:F,placeholder:`Ask Zuplo AI…`,rows:1,className:`max-h-48 min-h-9 resize-none py-1`}),_?(0,U.jsx)(X,{type:`button`,variant:`outline`,size:`icon-lg`,onClick:()=>{E.current=!0,n(`agent-z-generation-stopped`),p()},"aria-label":`Stop generating`,children:(0,U.jsx)(Nf,{})}):(0,U.jsx)(X,{type:`submit`,size:`icon-lg`,disabled:h.trim().length===0,"aria-label":`Send message`,children:(0,U.jsx)(zu,{})})]})]})]})}function ldt({message:e,onSend:t,onApproval:n,onSwitchProject:r,isActiveProject:i,primaryProject:a,disabled:o,isStreaming:s}){let c=e.role===`user`,l=oje(aje(e.parts)),u=c?``:e.parts.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
|
|
352
352
|
|
|
353
|
-
`).trim();return(0,U.jsx)(YE,{isUser:c,footer:!s&&u?(0,U.jsx)(udt,{text:u}):null,children:!c&&l.length===0?(0,U.jsx)(eD,{}):l.map(s=>s.kind===`tools`?(0,U.jsx)(ZE,{tools:s.tools},`${e.id}-${s.index}`):(0,U.jsx)(ddt,{part:s.part,isUser:c,onSend:t,onApproval:n,onSwitchProject:r,isActiveProject:i,primaryProject:a,disabled:o},`${e.id}-${s.index}`))})}function udt({text:e}){let{logEvent:t}=on(),{copyToClipboard:n,state:r}=jC(e,{showToast:!1,onCopy:()=>t(`agent-z-response-copied`,{messageLength:e.length})}),i=r===`copied`;return(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>void n(),"aria-label":`Copy response`,title:`Copy response`,className:W(`mt-1 self-start text-muted-foreground hover:text-foreground`,`opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100 pointer-coarse:opacity-100`,i&&`opacity-100`),children:i?(0,U.jsx)(td,{className:`size-3.5`}):(0,U.jsx)(xd,{className:`size-3.5`})})}function ddt({part:e,isUser:t,onSend:n,onApproval:r,onSwitchProject:i,isActiveProject:a,primaryProject:o,disabled:s}){if(e.type===`text`)return t?(0,U.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.text}):(0,U.jsx)(kC,{content:e.text});if(e.type===`reasoning`)return e.text?(0,U.jsx)(gje,{text:e.text}):null;if(jx(e)){let t=Nx(e);if(KE(e)){let n=e.state===`approval-requested`?{kind:`requested`}:e.state===`approval-responded`?{kind:`responded`,approved:e.approval.approved===!0}:{kind:`denied`};return(0,U.jsx)(jje,{toolLabel:JE(t),input:`input`in e?e.input:void 0,status:n,onRespond:t=>{e.state===`approval-requested`&&r(e.approval.id,t)}})}if(t===`present-options`){let t=rdt(`input`in e?e.input:void 0);return t?(0,U.jsx)(_je,{data:t,onSend:n,disabled:s}):null}if(t===`present-link`){let t=idt(`input`in e?e.input:void 0);return t?(0,U.jsx)(vje,{data:t}):null}if(t===`present-consumer`){let t=rRe(`input`in e?e.input:void 0);return t?(0,U.jsx)(iRe,{data:t}):null}if(t===`present-environment-variable`){let t=QBe(`input`in e?e.input:void 0);return t?(0,U.jsx)($Be,{data:t}):null}if(t===`present-source`){let t=sdt(`input`in e?e.input:void 0);return t?(0,U.jsx)(yje,{data:t}):null}if(t===`celebrate`){let t=Mje(`input`in e?e.input:void 0);return t?(0,U.jsx)(Pje,{data:t}):null}if(t===`present-file`){let t=eVe(`input`in e?e.input:void 0);return t?(0,U.jsx)(tVe,{data:t}):null}if(t===`show-test-console`){let t=Bit(`input`in e?e.input:void 0);return t?(0,U.jsx)(Vit,{data:t}):null}if(t===`switch-project`){let t=adt(`input`in e?e.input:void 0);return t?(0,U.jsx)(Tje,{projectName:t.projectName,reason:t.reason,isActive:a(t.projectName),disabled:s,onSwitch:()=>i(t.projectName)}):null}if(t===`update-working-copy`){let t=Jut(`input`in e?e.input:void 0);return t?(0,U.jsx)(Yut,{data:t}):null}if(t===`request-ai-provider`){let t=qOe(`input`in e?e.input:void 0);return t?(0,U.jsx)(fot,{data:t}):null}if(t===`request-ai-team`){let t=JOe(`input`in e?e.input:void 0);return t?(0,U.jsx)(gst,{data:t}):null}if(t===`request-ai-app`){let t=YOe(`input`in e?e.input:void 0);return t?(0,U.jsx)(Hit,{data:t}):null}return t===`request-openapi-import`?(0,U.jsx)(Gut,{data:Uut(`input`in e?e.input:void 0),onSend:n,disabled:s,primaryProject:o}):(0,U.jsx)(ZE,{tools:[{name:t,pending:GE(e)}]})}return null}function fdt({active:e,onPick:t}){let{logEvent:n}=on(),r=(0,H.useMemo)(()=>qut(),[]);return(0,H.useEffect)(()=>{e&&r.forEach((e,t)=>{n(`agent-z-cta-shown`,{ctaId:e.id,ctaCategory:e.category,position:t,batchSize:r.length})})},[e,r,n]),(0,U.jsxs)(`div`,{className:`mt-8 flex flex-col items-center text-center`,children:[(0,U.jsx)(Rme,{"aria-hidden":!0,className:`size-14`}),(0,U.jsx)(`h2`,{className:`mt-4 text-lg font-medium`,children:`Ask Zuplo AI`}),(0,U.jsx)(`p`,{className:`mt-1 max-w-md text-sm text-muted-foreground`,children:`Your AI assistant — ask about your APIs, policies, deployments, and more, right where you’re working.`}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-wrap justify-center gap-2`,children:r.map((e,i)=>(0,U.jsx)(X,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{n(`agent-z-cta-clicked`,{ctaId:e.id,ctaCategory:e.category,position:i,batchSize:r.length}),t(e)},children:e.prompt},e.id))})]})}var pdt=`w-full max-w-[440px]`;function mdt(){let{isOpen:e,close:t}=EZ(),{logEvent:n}=on(),[r,i]=(0,H.useState)(0),{account:a}=Wb([]),o=$b({enabled:!!a}),s=a?o.data?.find(e=>e.name===a):void 0,c=s?ahe(s):void 0,l=c?.status===`suspended`,u=c?.isAiEnabled===!1,d=e=>{e.key===`Escape`&&(n(`agent-z-panel-closed`,{source:`escape`}),t())};return(0,U.jsxs)(`aside`,{"aria-label":`Zuplo AI assistant`,inert:!e,onKeyDown:d,className:W(`fixed inset-y-0 right-0 z-40 flex flex-col border-l bg-background shadow-2xl`,pdt,`transition-transform duration-200 ease-in-out will-change-transform`,e?`translate-x-0`:`pointer-events-none translate-x-full`),children:[(0,U.jsxs)(`header`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,U.jsx)(Rme,{"aria-hidden":!0,className:`size-5`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Zuplo AI`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u||l?null:(0,U.jsxs)(X,{variant:`ghost`,size:`sm`,className:`text-sm font-normal text-muted-foreground`,onClick:()=>{n(`agent-z-new-chat-clicked`),i(e=>e+1)},children:[(0,U.jsx)(hf,{className:`size-4`}),`New chat`]}),(0,U.jsx)(X,{variant:`ghost`,size:`icon-sm`,onClick:()=>{n(`agent-z-panel-closed`,{source:`close-button`}),t()},"aria-label":`Close Zuplo AI`,children:(0,U.jsx)(Kf,{className:`size-4`})})]})]}),l?(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col justify-center overflow-y-auto bg-surface-sunken`,children:(0,U.jsx)(kme,{})}):u?(0,U.jsx)(hdt,{active:e}):(0,U.jsx)(cdt,{active:e},r)]})}function hdt({active:e}){let{openChat:t}=Lme(),{logEvent:n}=on(),{account:r}=Wb([]);(0,H.useEffect)(()=>{e&&n(`agent-z-disabled-state-shown`)},[e,n]);let{isAdmin:i}=Gme(r??``);return(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col justify-center overflow-y-auto bg-surface-sunken`,children:(0,U.jsx)(Ome,{title:`AI features are disabled`,description:`Zuplo AI is turned off for this account. Need a hand? Chat with our support team instead.`,action:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,U.jsxs)(X,{type:`button`,onClick:()=>{n(`agent-z-disabled-support-clicked`),t()},children:[(0,U.jsx)(sf,{"aria-hidden":!0,className:`size-4`}),`Chat with support`]}),i&&r?(0,U.jsx)(X,{type:`button`,variant:`outline`,size:`sm`,asChild:!0,children:(0,U.jsxs)(ws,{to:$r(Yb.AccountSettings,{account:r}),children:[(0,U.jsx)(rb,{weight:`fill`,"aria-hidden":!0,className:`size-4`}),`Enable AI features`]})}):null]})})})}var gdt=null,TZ=new Set,_dt=e=>{gdt=e;for(let e of TZ)e()},vdt=e=>(TZ.add(e),()=>{TZ.delete(e)}),ydt=()=>gdt,bdt=()=>(0,H.useSyncExternalStore)(vdt,ydt,ydt),xdt=(0,H.createContext)(void 0);function EZ(){let e=(0,H.useContext)(xdt);if(!e)throw Error(`useAgentZPanel must be used within AgentZPanelProvider`);return e}function Sdt({children:e}){let{variant:t}=Hy(wue),n=t===Tue,[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(null),s=(0,H.useCallback)(()=>i(!0),[]),c=(0,H.useCallback)(()=>i(!1),[]),l=(0,H.useCallback)(()=>i(e=>!e),[]),u=(0,H.useCallback)(e=>{o(e),i(!0)},[]),d=(0,H.useCallback)(()=>o(null),[]),f=(0,H.useMemo)(()=>({isOpen:n&&r,open:s,close:c,toggle:l,enabled:n,openWithPrompt:u,pendingPrompt:n?a:null,clearPendingPrompt:d}),[n,r,a,s,c,l,u,d]);return(0,H.useEffect)(()=>(_dt({enabled:n,openWithPrompt:u}),()=>_dt(null)),[n,u]),(0,U.jsxs)(xdt.Provider,{value:f,children:[(0,U.jsx)(`div`,{className:W(`transition-[padding] duration-200 ease-in-out`,f.isOpen&&`xl:pr-[440px]`),children:e}),n?(0,U.jsx)(mdt,{}):null]})}var Cdt=e=>(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 127.14 96.36`,...e,children:(0,U.jsx)(`path`,{d:`M107.7 8.07A105.15 105.15 0 0 0 81.47 0a72.06 72.06 0 0 0-3.36 6.83 97.68 97.68 0 0 0-29.11 0A72.37 72.37 0 0 0 45.64 0a105.89 105.89 0 0 0-26.25 8.09C2.79 32.65-1.71 56.6.54 80.21a105.73 105.73 0 0 0 32.17 16.15 77.7 77.7 0 0 0 6.89-11.11 68.42 68.42 0 0 1-10.85-5.18c.91-.66 1.8-1.34 2.66-2a75.57 75.57 0 0 0 64.32 0c.87.71 1.76 1.39 2.66 2a68.68 68.68 0 0 1-10.87 5.19 77 77 0 0 0 6.89 11.1 105.25 105.25 0 0 0 32.19-16.14c2.64-27.38-4.51-51.11-18.9-72.15ZM42.45 65.69C36.18 65.69 31 60 31 53s5-12.74 11.43-12.74S54 46 53.89 53s-5.05 12.69-11.44 12.69Zm42.24 0C78.41 65.69 73.25 60 73.25 53s5-12.74 11.44-12.74S96.23 46 96.12 53s-5.04 12.69-11.43 12.69Z`,style:{fill:`#fff`}})}),DZ=({text:e,onClick:t,className:n})=>(0,U.jsx)(X,{onClick:t,className:W(`bg-[#5865f2] hover:bg-[#464ec7] text-white`,n),asChild:!0,children:(0,U.jsxs)(`a`,{href:Mb,target:`_blank`,rel:`noreferrer`,children:[(0,U.jsx)(Cdt,{className:`w-6`}),e]})}),wdt=({goBack:e,hasGoHome:t})=>(0,U.jsxs)(`div`,{className:`flex gap-2 border-t pt-4 mt-2`,children:[t&&(0,U.jsx)(X,{asChild:!0,children:(0,U.jsxs)(`a`,{href:`/`,children:[(0,U.jsx)(Jd,{size:22}),`Go Home`]})}),(0,U.jsx)(DZ,{text:`Chat with us`}),e&&(0,U.jsx)(X,{onClick:()=>{e()},children:`Try again`})]}),Tdt=({isReconnecting:e=!1,onRetry:t})=>(0,U.jsx)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`You are offline`,className:`fixed inset-0 z-9999 flex items-center justify-center backdrop-blur-xs bg-black/60`,style:{pointerEvents:`auto`},children:(0,U.jsx)(`div`,{className:`relative max-w-md mx-4`,children:(0,U.jsxs)(`div`,{className:`relative bg-card rounded-xl shadow-2xl overflow-hidden border border-border`,children:[(0,U.jsx)(`div`,{className:`bg-muted border-b border-border p-6`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,U.jsx)(`div`,{className:`shrink-0`,children:(0,U.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-red-100 dark:bg-red-500/15 flex items-center justify-center`,children:(0,U.jsx)(Gf,{className:`w-6 h-6 text-red-600 dark:text-red-400`})})}),(0,U.jsxs)(`div`,{className:`flex-1`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-1`,children:`You're offline`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`We can't reach Zuplo right now`})]})]})}),(0,U.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,U.jsx)(`div`,{className:`bg-muted rounded-lg p-4 border border-border`,children:(0,U.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,U.jsx)(ud,{className:`w-5 h-5 text-green-600 dark:text-green-400 shrink-0 mt-0.5`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-foreground mb-1`,children:`Your work is safe`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Nothing on this page was lost. It will reconnect and refresh automatically as soon as you're back online.`})]})]})}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(vf,{className:`w-3.5 h-3.5 ${e?`animate-spin`:``}`}),e?`Checking connection…`:`Waiting for connection…`]}),t&&(0,U.jsx)(X,{variant:`outline`,size:`sm`,onClick:t,disabled:e,children:`Try now`})]})]})]})})}),Edt=e=>e instanceof he||e instanceof He?{type:e.type,title:e.message,status:e.status,detail:e.detail,instance:e.instance,traceId:e.traceId}:{title:`Oh zup! Something went wrong.`,detail:e instanceof Error?e.message:String(e)};function Ddt(e){return e===`root`?`app-dead`:`page-dead`}function Odt({id:e}){let t=vo(),n=s(t);if((0,H.useEffect)(()=>{if(n)return qe.subscribe(e=>{e&&window.location.reload()})},[n]),(0,H.useEffect)(()=>{!t||n||Kit(`Portal route error boundary rendered`,t,Ddt(e),{routeBoundaryId:e??`unknown`})},[t,n,e]),n)return(0,U.jsx)(Tdt,{onRetry:()=>window.location.reload()});let r=Edt(t);return(0,U.jsx)(`div`,{className:`m-auto`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 my-5 max-w-(--breakpoint-sm) m-6`,children:[(0,U.jsx)(`div`,{children:(0,U.jsxs)(OO,{variant:`outline`,children:[e,` Error`]})}),(0,U.jsx)(`span`,{className:`text-2xl font-medium`,children:r.title}),(0,U.jsxs)(`span`,{children:[`Unfortunately, we encountered an error while trying to load this page. But there are good news: We informed the team and someone will go and fix it.`,(0,U.jsx)(`br`,{}),` In the meantime, try again or reach out and chat with us.`]}),r.detail&&(0,U.jsx)(Sb,{variant:`destructive`,children:(0,U.jsxs)(wb,{children:[r.type&&`${r.type}:`,` `,r.detail]})}),(0,U.jsxs)(`span`,{className:`font-mono text-sm`,children:[`Version `,``,` `,r.traceId&&`| Trace ID ${r.traceId}`]}),(0,U.jsx)(wdt,{hasGoHome:!0})]})})}var kdt={"in-progress":`Build in progress`,failed:`Last build failed`,success:`Gateway deployed`,idle:`No deployment yet`},Adt=({status:e,className:t})=>e===`in-progress`?(0,U.jsx)(nf,{size:14,"aria-label":kdt[e],className:W(`animate-spin text-yellow-500`,t)}):(0,U.jsx)(`span`,{role:`img`,"aria-label":kdt[e],className:W(`w-2 h-2 shrink-0 rounded-full`,{"bg-green-500":e===`success`,"bg-red-500":e===`failed`,"bg-neutral-400":e===`idle`},t)}),jdt=({children:e,className:t,...n})=>(0,U.jsx)(`div`,{className:W(`sticky flex flex-col w-full border-b px-4 py-3 bg-white dark:bg-[#141412] z-10`,t),style:{top:`var(--banner-height, 0px)`},...n,children:e}),Mdt=({count:e})=>!e||e===0?null:(0,U.jsx)(`span`,{className:`absolute top-1 right-0 h-2 w-2 rounded-full bg-blue-400`}),Ndt=({children:e,to:t,badgeCount:n,end:r})=>(0,U.jsx)(Ts,{end:r,to:t,className:({isActive:e,isPending:t})=>W(`font-medium relative items-center px-2 py-1 rounded-md text-neutral-900 dark:text-white text-sm transition-colors`,`rounded-md hover:text-zuplo-600`,e&&`text-zuplo-700`,t&&`text-zuplo-700 animate-pulse`),children:({isActive:t})=>(0,U.jsxs)(U.Fragment,{children:[t&&(0,U.jsx)(GP.div,{layoutId:`local-navigation-item-background`,transition:{type:`spring`,bounce:.1,duration:.4},className:`absolute inset-0 rounded-md -z-10 bg-zuplo-100`}),e,(0,U.jsx)(Mdt,{count:n})]})}),Pdt=()=>{let e=op(),[t,n]=(0,H.useState)(!1),r=UR(e.environment),{copyToClipboard:i,state:a}=jC(r??``);return(0,U.jsxs)(aJ,{open:t,onOpenChange:n,children:[(0,U.jsx)(oJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`gap-2 flex justify-between h-8 mt-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Adt,{status:`success`}),`Deployment URLs`]}),(0,U.jsx)(nd,{size:16})]})}),(0,U.jsx)(sJ,{className:`divide-y p-0`,align:`end`,children:r?(0,U.jsxs)(`div`,{className:`p-4`,children:[(0,U.jsx)(`div`,{className:`font-medium text-lg`,children:`Local Development`}),(0,U.jsx)(`div`,{className:`h-2`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`uppercase text-muted-foreground font-semibold text-xs`,children:`Gateway`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Adt,{status:`success`}),(0,U.jsx)(`div`,{className:`text-sm max-w-52 truncate break-all`,children:(0,U.jsx)(Rw,{href:r,target:`_blank`,variant:`ghost`,rel:`noopener noreferrer`,className:`hover:underline`,children:r})}),(0,U.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-muted rounded-md transition-colors`,onClick:()=>{i(),n(!1)},children:a===`copied`?(0,U.jsx)(td,{size:16,className:`text-green-500`}):(0,U.jsx)(xd,{size:16})})]})]})]}):(0,U.jsxs)(`div`,{className:`w-60 p-5 text-center`,children:[(0,U.jsx)(`div`,{className:`text-2xl font-medium`,children:`🙈`}),(0,U.jsx)(`div`,{className:`text-md mt-4`,children:`Deployment URL not configured. Make sure your local gateway is running.`})]})})]})},Fdt=()=>(0,U.jsxs)(jdt,{className:`flex-row justify-between`,children:[(0,U.jsxs)(`nav`,{"aria-label":`Sidebar`,className:`flex gap-2 items-center`,children:[(0,U.jsx)(Ndt,{end:!0,to:`/dev/project/local`,children:`Project`}),(0,U.jsx)(Ndt,{to:`/dev/project/local/edit`,children:`Code`})]}),(0,U.jsx)(Pdt,{})]}),OZ=(0,H.createContext)({chromeBottom:0});function Idt({height:e,children:t}){let n={chromeBottom:(0,H.useContext)(OZ).chromeBottom+e};return(0,U.jsx)(OZ.Provider,{value:n,children:t})}function Ldt(){return(0,H.useContext)(OZ).chromeBottom}function Rdt(e=0){let t=Ldt()+e;return{top:`calc(${t}px + var(--banner-height, 0px))`,fillHeight:`calc(100vh - ${t}px - var(--banner-height, 0px))`}}var zdt=({children:e,className:t,offset:n=0})=>{let{fillHeight:r}=Rdt(n);return(0,U.jsx)(`div`,{className:W(t),style:{height:r},children:e})};function Bdt({open:e,editors:t,onSelect:n,onCancel:r}){let[i,a]=(0,H.useState)(null);return(0,U.jsx)(Ib,{open:e,onOpenChange:e=>!e&&r(),children:(0,U.jsxs)(zb,{className:`sm:max-w-md`,children:[(0,U.jsxs)(Bb,{children:[(0,U.jsx)(Hb,{children:`Choose Your Editor`}),(0,U.jsx)(Ub,{children:`Select which editor you'd like to use for opening files. This preference will be saved for future use.`})]}),(0,U.jsx)(`div`,{className:`space-y-2 py-4`,children:t.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`w-full text-left px-4 py-3 rounded-md border transition-colors ${i===e.id?`border-blue-500 bg-blue-50 dark:bg-blue-950/40`:`border-gray-200 dark:border-neutral-700 hover:border-gray-300 dark:hover:border-neutral-600 hover:bg-gray-50 dark:hover:bg-neutral-800/60`}`,onClick:()=>a(e.id),children:(0,U.jsx)(`div`,{className:`font-medium`,children:e.name})},e.id))}),(0,U.jsxs)(Vb,{children:[(0,U.jsx)(X,{variant:`ghost`,onClick:r,children:`Cancel`}),(0,U.jsx)(X,{variant:`default`,onClick:()=>{i&&n(i)},disabled:!i,children:`Save Preference`})]})]})})}var kZ=`/api/v1/editor`;function Vdt(){let[e]=Ms(),[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)([]),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!0);(0,H.useEffect)(()=>{(async()=>{try{let e=await fetch(`${kZ}/list`);if(!e.ok)throw Error(`Failed to fetch editors: ${e.status}`);o((await e.json()).editors);let t=await fetch(`${kZ}/detect`);if(!t.ok)throw Error(`Failed to detect editor: ${t.status}`);let r=await t.json();r.editor&&r.name&&(n(r.editor),i(r.name))}catch(e){ot.error(`Failed to load editor preference`,{error:e})}finally{u(!1)}})()},[]);let d=(0,H.useCallback)(async e=>{try{if((await fetch(`${kZ}/preference`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({editor:e})})).ok){let t=a.find(t=>t.id===e);t&&(n(e),i(t.name)),c(!1)}}catch(e){ot.error(`Failed to save editor preference`,{error:e})}},[a]),f=(0,H.useCallback)(async()=>{let n=e.get(`path`);if(!n){ot.warn(`No file path in URL`);return}if(!t){c(!0);return}try{let e=await fetch(`${kZ}/open`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({file:n})});if(!e.ok){let t=await e.json();ot.error(`Failed to open file in editor`,{error:t.message});return}let t=await e.json();t.url&&window.open(t.url,`_blank`)}catch(e){ot.error(`Failed to open file in editor`,{error:e})}},[e,t]);return{hasEditor:!!t,editorName:r,isLoading:l,showPreferenceDialog:s,setShowPreferenceDialog:c,availableEditors:a,savePreference:d,openInEditor:f}}var Hdt=e=>new Promise(t=>setTimeout(t,e)),AZ=e=>{let[t,n]=(0,H.useState)(`idle`),[r,i]=(0,H.useState)(),[a,o]=(0,H.useState)(null);return{state:t,error:r,execute:(0,H.useCallback)(async(...t)=>{n(`loading`),o(null),i(void 0);try{let r=await e(...t);return n(`hasValue`),o(r),r}catch(e){throw i(e instanceof Error?e:Error(e)),n(`hasError`),e}},[e]),value:a}},jZ=()=>({isReadOnly:op().environment.environmentType!==LF.WORKING_COPY}),Udt=a(((e,t)=>{t.exports=n;function n(e,t,n){e instanceof RegExp&&(e=r(e,n)),t instanceof RegExp&&(t=r(t,n));var a=i(e,t,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+e.length,a[1]),post:n.slice(a[1]+t.length)}}function r(e,t){var n=t.match(e);return n?n[0]:null}n.range=i;function i(e,t,n){var r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;)u==c?(r.push(u),c=n.indexOf(e,u+1)):r.length==1?s=[r.pop(),l]:(i=r.pop(),i<a&&(a=i,o=l),l=n.indexOf(t,u+1)),u=c<l&&c>=0?c:l;r.length&&(s=[a,o])}return s}})),Wdt=r(a(((e,t)=>{var n=Udt();t.exports=f;var r=`\0SLASH`+Math.random()+`\0`,i=`\0OPEN`+Math.random()+`\0`,a=`\0CLOSE`+Math.random()+`\0`,o=`\0COMMA`+Math.random()+`\0`,s=`\0PERIOD`+Math.random()+`\0`;function c(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function l(e){return e.split(`\\\\`).join(r).split(`\\{`).join(i).split(`\\}`).join(a).split(`\\,`).join(o).split(`\\.`).join(s)}function u(e){return e.split(r).join(`\\`).split(i).join(`{`).split(a).join(`}`).split(o).join(`,`).split(s).join(`.`)}function d(e){if(!e)return[``];var t=[],r=n(`{`,`}`,e);if(!r)return e.split(`,`);var i=r.pre,a=r.body,o=r.post,s=i.split(`,`);s[s.length-1]+=`{`+a+`}`;var c=d(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),t.push.apply(t,s),t}function f(e){return e?(e.substr(0,2)===`{}`&&(e=`\\{\\}`+e.substr(2)),_(l(e),!0).map(u)):[]}function p(e){return`{`+e+`}`}function m(e){return/^-?0\d/.test(e)}function h(e,t){return e<=t}function g(e,t){return e>=t}function _(e,t){var r=[],i=n(`{`,`}`,e);if(!i)return[e];var o=i.pre,s=i.post.length?_(i.post,!1):[``];if(/\$$/.test(i.pre))for(var l=0;l<s.length;l++){var u=o+`{`+i.body+`}`+s[l];r.push(u)}else{var f=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),v=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),y=f||v,b=i.body.indexOf(`,`)>=0;if(!y&&!b)return i.post.match(/,(?!,).*\}/)?(e=i.pre+`{`+i.body+a+i.post,_(e)):[e];var x;if(y)x=i.body.split(/\.\./);else if(x=d(i.body),x.length===1&&(x=_(x[0],!1).map(p),x.length===1))return s.map(function(e){return i.pre+x[0]+e});var S;if(y){var C=c(x[0]),w=c(x[1]),T=Math.max(x[0].length,x[1].length),E=x.length==3?Math.abs(c(x[2])):1,D=h;w<C&&(E*=-1,D=g);var O=x.some(m);S=[];for(var k=C;D(k,w);k+=E){var A;if(v)A=String.fromCharCode(k),A===`\\`&&(A=``);else if(A=String(k),O){var j=T-A.length;if(j>0){var M=Array(j+1).join(`0`);A=k<0?`-`+M+A.slice(1):M+A}}S.push(A)}}else{S=[];for(var N=0;N<x.length;N++)S.push.apply(S,_(x[N],!1))}for(var N=0;N<S.length;N++)for(var l=0;l<s.length;l++){var u=o+S[N]+s[l];(!t||y||u)&&r.push(u)}}return r}}))()),Gdt=1024*64,MZ=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>Gdt)throw TypeError(`pattern is too long`)},Kdt={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},NZ=e=>e.replace(/[[\]\\-]/g,`\\$&`),qdt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),Jdt=e=>e.join(``),Ydt=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(Kdt))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(NZ(d)+`-`+NZ(t)):t===d&&r.push(NZ(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(NZ(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(NZ(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l)return[qdt(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+Jdt(r)+`]`,p=`[`+(l?``:`^`)+Jdt(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},PZ=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/\[([^\/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,`$1$2`).replace(/\\([^\/])/g,`$1`),Xdt=new Set([`!`,`?`,`+`,`*`,`@`]),FZ=e=>Xdt.has(e),Zdt=e=>FZ(e.type),Qdt=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),$dt=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),eft=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),tft=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),nft=`(?!\\.\\.?(?:$|/))`,IZ=`(?!\\.)`,rft=new Set([`[`,`.`]),ift=new Set([`..`,`.`]),aft=new Set(`().*{}+?[]^$\\!`),oft=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),LZ=`[^/]`,sft=LZ+`*?`,cft=LZ+`+?`,lft=class e{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.type?this.#l=this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#l=this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...t){for(let n of t)if(n!==``){if(typeof n!=`string`&&!(n instanceof e&&n.#i===this))throw Error(`invalid part: `+n);this.#r.push(n)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let t=this.#i;for(let n=0;n<this.#a;n++){let r=t.#r[n];if(!(r instanceof e&&r.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(t){let n=new e(this.type,t);for(let e of this.#r)n.copyIn(e);return n}static#f(t,n,r,i,a){let o=i.maxExtglobRecursion??2,s=!1,c=!1,l=-1,u=!1;if(n.type===null){let d=r,f=``;for(;d<t.length;){let r=t.charAt(d++);if(s||r===`\\`){s=!s,f+=r;continue}if(c){d===l+1?(r===`^`||r===`!`)&&(u=!0):r===`]`&&!(d===l+2&&u)&&(c=!1),f+=r;continue}else if(r===`[`){c=!0,l=d,u=!1,f+=r;continue}if(!i.noext&&FZ(r)&&t.charAt(d)===`(`&&a<=o){n.push(f),f=``;let o=new e(r,n);d=e.#f(t,o,d,i,a+1),n.push(o);continue}f+=r}return n.push(f),d}let d=r+1,f=new e(null,n),p=[],m=``;for(;d<t.length;){let r=t.charAt(d++);if(s||r===`\\`){s=!s,m+=r;continue}if(c){d===l+1?(r===`^`||r===`!`)&&(u=!0):r===`]`&&!(d===l+2&&u)&&(c=!1),m+=r;continue}else if(r===`[`){c=!0,l=d,u=!1,m+=r;continue}if(FZ(r)&&t.charAt(d)===`(`&&(a<=o||n&&n.#h(r))){let o=n&&n.#h(r)?0:1;f.push(m),m=``;let s=new e(r,f);f.push(s),d=e.#f(t,s,d,i,a+o);continue}if(r===`|`){f.push(m),m=``,p.push(f),f=new e(null,n);continue}if(r===`)`)return m===``&&n.#r.length===0&&(n.#u=!0),f.push(m),m=``,n.push(...p,f),d;m+=r}return n.type=null,n.#t=void 0,n.#r=[t.substring(r-1)],d}#p(e){return this.#m(e,$dt)}#m(e,t=Qdt){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!=`object`||n.type===null?!1:this.#h(n.type,t)}#h(e,t=eft){return!!t.get(this.type)?.includes(e)}#g(t,n){let r=t.#r[0],i=new e(null,r,this.options);i.#r.push(``),r.push(i),this.#_(t,n)}#_(e,t){let n=e.#r[0];this.#r.splice(t,1,...n.#r);for(let e of n.#r)typeof e==`object`&&(e.#i=this);this.#l=void 0}#v(e){return!!tft.get(this.type)?.has(e)}#y(e){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!=`object`||t.type===null?!1:this.#v(t.type)}#b(e){let t=tft.get(this.type),n=e.#r[0],r=t?.get(n.type);if(!r)return!1;this.#r=n.#r;for(let e of this.#r)typeof e==`object`&&(e.#i=this);this.type=r,this.#l=void 0,this.#u=!1}#x(){if(Zdt(this)){let e=0,t=!1;do{t=!0;for(let e=0;e<this.#r.length;e++){let n=this.#r[e];typeof n==`object`&&(n.#x(),this.#m(n)?(t=!1,this.#_(n,e)):this.#p(n)?(t=!1,this.#g(n,e)):this.#y(n)&&(t=!1,this.#b(n)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e==`object`&&e.#x();this.#l=void 0}static fromGlob(t,n={}){let r=new e(null,void 0,n);return e.#f(t,r,0,n,0),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(){if(this.#e===this&&(this.#x(),this.#d()),!Zdt(this)){let t=this.isStart()&&this.isEnd(),n=this.#r.map(n=>{let[r,i,a,o]=typeof n==`string`?e.#S(n,this.#t,t):n.toRegExpSource();return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),r=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&ift.has(this.#r[0]))){let e=rft,t=this.#c.dot&&e.has(n.charAt(0))||n.startsWith(`\\.`)&&e.has(n.charAt(2))||n.startsWith(`\\.\\.`)&&e.has(n.charAt(4)),i=!this.#c.dot&&e.has(n.charAt(0));r=t?nft:i?IZ:``}let i=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(i=`(?:$|\\/)`),[r+n+i,PZ(n),this.#t=!!this.#t,this.#n]}let t=this.type===`!`?`(?:(?!(?:`:`(?:`,n=this.#r.map(e=>{if(typeof e==`string`)throw Error(`string type in extglob ast??`);let[t,n,r,i]=e.toRegExpSource();return this.#n=this.#n||i,t}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`);if(this.isStart()&&this.isEnd()&&!n&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,PZ(this.toString()),!1,!1]}let r=``;if(this.type===`!`&&this.#u)r=(this.isStart()&&!this.#c.dot?IZ:``)+cft;else{let e=this.type===`!`?`))`+(this.isStart()&&!this.#c.dot?IZ:``)+sft+`)`:this.type===`@`?`)`:`)${this.type}`;r=t+n+e}return[r,PZ(n),this.#t=!!this.#t,this.#n]}static#S(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(c!==`*`&&(o=!1),r){r=!1,i+=(aft.has(c)?`\\`:``)+c;continue}if(c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=Ydt(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?cft:sft,t=!0;continue}if(c===`?`){i+=LZ,t=!0;continue}i+=oft(c)}return[i,PZ(e),!!t,a]}},uft=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),RZ=(e,t,n={})=>(MZ(t),!n.nocomment&&t.charAt(0)===`#`?!1:new VZ(t,n).match(e)),dft=/^\*+([^+@!?\*\[\(]*)$/,fft=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),pft=e=>t=>t.endsWith(e),mft=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),hft=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),gft=/^\*+\.\*+$/,_ft=e=>!e.startsWith(`.`)&&e.includes(`.`),vft=e=>e!==`.`&&e!==`..`&&e.includes(`.`),yft=/^\.\*+$/,bft=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),xft=/^\*+$/,Sft=e=>e.length!==0&&!e.startsWith(`.`),Cft=e=>e.length!==0&&e!==`.`&&e!==`..`,wft=/^\?+([^+@!?\*\[\(]*)?$/,Tft=([e,t=``])=>{let n=kft([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Eft=([e,t=``])=>{let n=Aft([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Dft=([e,t=``])=>{let n=Aft([e]);return t?e=>n(e)&&e.endsWith(t):n},Oft=([e,t=``])=>{let n=kft([e]);return t?e=>n(e)&&e.endsWith(t):n},kft=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},Aft=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},jft=typeof process==`object`&&process?{}.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Mft={win32:{sep:`\\`},posix:{sep:`/`}};RZ.sep=jft===`win32`?Mft.win32.sep:Mft.posix.sep;var zZ=Symbol(`globstar **`);RZ.GLOBSTAR=zZ;var Nft=`[^/]*?`,Pft=`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`,Fft=`(?:(?!(?:\\/|^)\\.).)*?`;RZ.filter=(e,t={})=>n=>RZ(n,e,t);var BZ=(e,t={})=>Object.assign({},e,t);RZ.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return RZ;let t=RZ;return Object.assign((n,r,i={})=>t(n,r,BZ(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,BZ(e,n))}static defaults(n){return t.defaults(BZ(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,BZ(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,BZ(e,r))}},unescape:(n,r={})=>t.unescape(n,BZ(e,r)),escape:(n,r={})=>t.escape(n,BZ(e,r)),filter:(n,r={})=>t.filter(n,BZ(e,r)),defaults:n=>t.defaults(BZ(e,n)),makeRe:(n,r={})=>t.makeRe(n,BZ(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,BZ(e,r)),match:(n,r,i={})=>t.match(n,r,BZ(e,i)),sep:t.sep,GLOBSTAR:zZ})};var Ift=(e,t={})=>(MZ(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:(0,Wdt.default)(e));RZ.braceExpand=Ift,RZ.makeRe=(e,t={})=>new VZ(e,t).makeRe(),RZ.match=(e,t,n={})=>{let r=new VZ(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};var Lft=/[?*]|[+@!]\(.*?\)|\[|\]/,Rft=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),VZ=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){MZ(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||jft,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!Lft.test(e[2]))&&!Lft.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)e[t][n]===`**`&&(e[t][n]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];n===1&&r===``&&e[0]===``||(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];e===1&&r===``&&n[0]===``||(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);r&&(e[t]=r,e[n]=[])}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=0,i=0;if(this.isWindows){let n=e[0]===``&&e[1]===``&&e[2]===`?`&&typeof e[3]==`string`&&/^[a-z]:$/i.test(e[3]),a=t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]);if(n&&a){let n=e[3],a=t[3];n.toLowerCase()===a.toLowerCase()&&(e[3]=a,r=3,i=3)}else if(a&&typeof e[0]==`string`){let n=t[3],r=e[0];n.toLowerCase()===r.toLowerCase()&&(t[3]=r,i=3)}else if(n&&typeof t[0]==`string`){let n=e[3];n.toLowerCase()===t[0].toLowerCase()&&(t[0]=n,r=3)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(zZ)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(zZ,i),o=t.lastIndexOf(zZ),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n<e.length-u;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}let d=[[[],0]],f=d[0],p=0,m=[0];for(let e of c)e===zZ?(m.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);let h=d.length-1,g=e.length-u;for(let e of d)e[1]=g-(m[h--]+e[0].length);return!!this.#t(e,d,r,0,n,0,!!u)}#t(e,t,n,r,i,a,o){let s=t[r];if(!s){for(let t=n;t<e.length;t++){o=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return o}let[c,l]=s;for(;n<=l;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&a<this.maxGlobstarRecursion){let s=this.#t(e,t,n+c.length,r+1,i,a+1,o);if(s!==!1)return s}let s=e[n];if(s===`.`||s===`..`||!this.options.dot&&s.startsWith(`.`))return!1;n++}return i||null}#n(e,t,n,r,i){let a,o,s,c;for(a=r,o=i,c=e.length,s=t.length;a<c&&o<s;a++,o++){this.debug(`matchOne loop`);let n=t[o],r=e[a];if(this.debug(t,n,r),n===!1||n===zZ)return!1;let i;if(typeof n==`string`?(i=r===n,this.debug(`string match`,n,r,i)):(i=n.test(r),this.debug(`pattern match`,n,r,i)),!i)return!1}if(a===c&&o===s)return!0;if(a===c)return n;if(o===s)return a===c-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return Ift(this.pattern,this.options)}parse(e){MZ(e);let t=this.options;if(e===`**`)return zZ;if(e===``)return``;let n,r=null;(n=e.match(xft))?r=t.dot?Cft:Sft:(n=e.match(dft))?r=(t.nocase?t.dot?hft:mft:t.dot?pft:fft)(n[1]):(n=e.match(wft))?r=(t.nocase?t.dot?Eft:Tft:t.dot?Dft:Oft)(n):(n=e.match(gft))?r=t.dot?vft:_ft:(n=e.match(yft))&&(r=bft);let i=lft.fromGlob(e,this.options).toMMPattern();return r?Object.assign(i,{test:r}):i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?Nft:t.dot?Pft:Fft,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?Rft(e):e===zZ?zZ:e._src});return t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==zZ||a===zZ||(a===void 0?i!==void 0&&i!==zZ?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|`+n+`)?`:i!==zZ&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=zZ))}),t.filter(e=>e!==zZ).join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^\/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e=0;e<i.length;e++){let o=i[e],s=r;if(n.matchBase&&o.length===1&&(s=[a]),this.matchOne(s,o,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return RZ.defaults(e).Minimatch}};RZ.AST=lft,RZ.Minimatch=VZ,RZ.escape=uft,RZ.unescape=PZ;var zft=()=>{let e=Dt();return je({mutationFn:async t=>await e.fetch(tn.directories.createDirectory(t))})},Bft=[`saveStatus`],HZ={".ts":`typescript`,".tsx":`typescript`,".js":`javascript`,".jsx":`javascript`,".mjs":`javascript`,".cjs":`javascript`,".json":`json`,".html":`html`,".htm":`html`,".xml":`xml`,".svg":`xml`,".yaml":`yaml`,".yml":`yaml`,".md":`markdown`,".mdx":`markdown`,".css":`css`,".scss":`scss`,".sass":`sass`,".less":`less`,".py":`python`,".rs":`rust`,".go":`go`,".java":`java`,".c":`c`,".cpp":`cpp`,".cs":`csharp`,".php":`php`,".rb":`ruby`,".sh":`shell`,".bash":`shell`,".zsh":`shell`,".sql":`sql`,".graphql":`graphql`,".gql":`graphql`,".env":`plaintext`,".toml":`toml`,".ini":`ini`,".properties":`properties`,".dockerfile":`dockerfile`,Dockerfile:`dockerfile`,".makefile":`makefile`,Makefile:`makefile`};function Vft(e){let t=e.split(`/`).pop()||``;if(HZ[t])return HZ[t];let n=t.lastIndexOf(`.`);return n===-1?`plaintext`:HZ[t.slice(n)]||`plaintext`}var Hft=(e,t,n)=>Jb(mt.file(e,t),{...n,text:!0,select:e=>({content:e,contentType:`text/plain`,language:Vft(t),path:t})}),Uft=(e,t)=>Jb(mt.fsStats(e),{...t,refetchInterval:1e4,refetchOnWindowFocus:!0}),UZ=()=>{let e=Dt();return je({mutationFn:async t=>{let n=await e.fetch({...tn.fileTransactions.saveFile(t),parseResponse:!1}),r=n.headers.get(`Last-Modified`),i=r?new Date(r).getTime():void 0;return{...await n.json(),lastModified:i}}})},WZ=e=>{let t=Dt();return je({mutationFn:async e=>{if(!e.environmentName||!e.files)throw Error(`No environment name or files provided`);return await(await t.fetch(await tn.fileTransactions.saveMultipleFiles(e))).json()},mutationKey:WZ.mutationKey,...e})};WZ.mutationKey=Bft;var Wft=()=>{let e=Dt();return je({mutationFn:async t=>await e.fetch(tn.fileTransactions.deleteFile(t))})},Gft=()=>{let e=Dt();return je({mutationFn:async t=>await e.fetch(tn.fileTransactions.renameFile(t))})};function Kft(e,t){let n=t.map(e=>e.fileGlob),r=t.flatMap(e=>{let t=[e.folderName];return e.subdirectoryGlob?t.concat(e.subdirectoryGlob):t});return e.filter(e=>e.type===Us.Directory&&r.some(t=>RZ(e.path,t))?!0:n.find(t=>RZ(e.path,t))!==void 0)}function qft(e,t){return(0,H.useCallback)(async()=>Kft(await Ys(t,`/`),e),[t,e])}function GZ(){let{logEvent:e}=on(),t=XZ(),n=gp(),r=hp(e=>e.showSaveConflict);return WZ({onMutate:({files:e})=>{e.forEach(e=>{t({...e,saveState:Ws.saving})})},onSuccess:async(e,{files:n,environmentName:r})=>{e.buildId&&r&&Ke(r,e.buildId),n.forEach(n=>{let r=e.files?.[n.path];ot.debug(`Updated ${n.path} after save - lastModified: ${r}`),t({...n,lastModified:r,saveState:Ws.unmodified})})},onError:(i,{files:a})=>{if(i instanceof Error&&`status`in i&&i.status===412){let e=i;if(e.instance)try{let t=JSON.parse(e.instance).conflictedFiles;t&&t.length>0&&r(t[0])}catch(e){ot.error(`Failed to parse conflict error instance data`,{error:e})}return}a.forEach(e=>{t({...e,saveState:Ws.modified})}),e(`file-save-failed`,{fileNames:n.map(e=>e.path).join(`, `)})}})}function Jft(){let e=op(),{logEvent:t,captureException:n}=on(),r=$ft(),i=XZ(),a=Wft(),{isReadOnly:o}=jZ(),{execute:s}=AZ(async s=>{if(o)return{success:!1,error:Error(`Unable to delete file - environment is read-only`)};let c=s.saveState;i({...s,saveState:Ws.removing});try{return await a.mutateAsync({environmentName:e.environment.name,filePath:s.path}),r(s.path),t(`file-deleted`,{fileName:s.path,account:e.account.name,project:e.project.name,environment:e.environment.name}),{success:!0}}catch(r){return t(`file-deletion-failed`,{account:e.account.name,project:e.project.name,environment:e.environment.name}),n(r),i({...s,saveState:c}),{success:!1,error:r}}});return s}function KZ(){let e=nF(),{logEvent:t,captureException:n}=on(),r=XZ(),i=hp(e=>e.projectTreeNodes),a=UZ(),o=op([`account`,`project`,`environment`]),{execute:s}=AZ(async(s,c,l,u,d)=>{if(!e)return;let f=l??u.defaultFileTemplate,p=u.createExtensions[f],m=`${c}/${!p||s.toLowerCase().endsWith(`.${p}`)||s===u.predefinedTemplateFilename?.[f]?s:`${s}.${p}`}`,h=(l&&u.newFileTemplates[l]?.trimStart())??d??``,g=i.find(e=>e.path===m);if(g)return g;if(i.length===0){let e=(await Ys(o.environment.name,c).catch(()=>[])).find(e=>e.path===m);if(e)return e}let _={content:h,path:m},v={saveState:Ws.new,type:Us.File,..._};try{r(v),e.editor.createModel(_.content??``,void 0,e.Uri.file(m));let n=await a.mutateAsync({environmentName:o.environment.name,file:_,accountName:o.account.name,projectName:o.project.name});return n.buildId&&Ke(o.environment.name,n.buildId),r({...v,lastModified:n.lastModified,saveState:Ws.unmodified}),t(`file-added`,{account:o.account.name,project:o.project.name,environment:o.environment.name,fileName:v.path,strategy:u.name}),_}catch(e){t(`file-creation-failed`,{environment:o.environment.name}),n(e),r({...v,saveState:Ws.modified});return}});return s}function Yft(e){let t=nF(),{logEvent:n,captureException:r}=on(),i=Wb([`account`,`project`]),a=XZ(),o=$ft(),s=Gft(),{execute:c}=AZ(async(c,l)=>{if(t)try{a({...c,saveState:Ws.removing}),await s.mutateAsync({environmentName:e,path:c.path,newPath:l}),a({...c,saveState:Ws.new,path:l}),t.editor.createModel(c.content??``,void 0,t.Uri.file(l));let r=t.editor.getModel(t.Uri.file(c.path));a({...c,path:l}),r?.dispose(),o(c.path),n(`file-renamed`,{fileName:c.path,environment:e})}catch(t){n(`file-rename-failed`,{account:i.account,project:i.project,environment:e}),r(t),a({...c,saveState:Ws.unmodified});return}});return c}function Xft(e){let t=nF(),{logEvent:n,captureException:r}=on(),i=XZ(),a=zft(),{execute:o}=AZ(async(o,s,c)=>{if(!t)return Error(`Failed to acquire monaco instance. Please refresh the page.`);let l=`${s}/${o}`,u={path:l},d={saveState:Ws.new,type:Us.Directory,...u};try{return i(d),await a.mutateAsync({environmentName:e,path:l}),i({...d,saveState:Ws.unmodified}),n(`directory-added`,{fileName:d.path,strategy:c.name,environment:e}),u}catch(t){return n(`directory-creation-failed`,{environment:e}),r(t),i({...d,saveState:Ws.modified}),t}});return o}function qZ(){return YZ(Irt().get(`path`))}function JZ(){let e=nF(),t=XZ();return(0,H.useCallback)((n,r=!1,i=Ws.modified)=>{if(t({...n,saveState:i}),r&&e){let t=e.editor.getModel(e.Uri.file(n.path));t&&t.setValue(n.content??``)}},[e,t])}function YZ(e){return hp(t=>e?t.filesByPath[e]:void 0)}function Zft(e){let t=hp(e=>e.projectTreeNodes),n=[],r=Object.values(e);return t.filter(e=>e.type===Us.Directory).forEach(e=>{let t=r.find(t=>t.folderName===e.path);if(t)return n.push(t)}),r.sort((e,t)=>e.order-t.order)}function Qft(e){return hp(e=>e.projectTreeNodes).filter(t=>!t.path&&!e.fileGlob?!1:t.type===Us.Directory&&e.subdirectoryGlob?RZ(t.path,e.subdirectoryGlob):RZ(t.path,e.fileGlob))}function $ft(){let e=nF(),t=hp(e=>e.removeFile),n=hp(e=>e.filterProjectTreeNodes);return r=>{e&&e.editor.getModel(e.Uri.file(r))?.dispose(),t(r),n(e=>e.path!==r)}}function XZ(){return hp(e=>e.updateFile)}var ept=e=>{let t=JZ(),n=YZ(e);return e=>{n&&t(n,!0,e)}},tpt=()=>{let e=op(),t=GZ(),n=gp();return CR(e.environment.name),{isPending:t.isPending,isSuccess:t.isSuccess,saveAndDeploy:(0,H.useCallback)(async()=>t.mutateAsync({environmentName:e.environment.name,accountName:e.account.name,projectName:e.project.name,files:n}).catch(e=>{if(!(e instanceof Error&&`status`in e&&e.status===409))throw e}),[t,n,!1,e.environment.name,e.account.name,e.project.name])}},npt=(e={})=>{let{isReadOnly:t=!1,onSave:n}=e,{saveAndDeploy:r,isPending:i,isSuccess:a}=tpt(),[o,s]=(0,H.useState)(null),c=hp(e=>{let t=0;for(let n of e.projectTreeNodes){let r=n.path?e.filesByPath[n.path]:void 0;r&&r.saveState===Ws.modified&&t++}return t}),l=hp(e=>{let t=0;for(let n of e.projectTreeNodes){let r=n.path?e.filesByPath[n.path]:void 0;r&&(r.saveState===Ws.modified||r.saveState===Ws.saving)&&t++}return t}),u=(0,H.useRef)(null),d=e=>{s(e),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{s(null)},1600)},f=Gb(r),p=Gb(n),m=rp(e=>e.addToast),h=(0,H.useRef)(!1),g=(0,H.useRef)(!1);return(0,H.useEffect)(()=>{let e=h.current;!e&&i?g.current=l>0:e&&!i&&a&&g.current&&(m({message:`Changes saved`,icon:(0,H.createElement)(td,{size:18}),duration:2e3}),g.current=!1),h.current=i},[i,a,l,m]),(0,H.useEffect)(()=>{let e=async e=>{try{if(e.code===`KeyS`&&(e.metaKey||e.ctrlKey)){if(e.preventDefault(),t){d(`Read only environment`);return}let n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){let e=n.selectionEnd;n.blur(),n.focus(),(n instanceof HTMLInputElement&&n.type!==`checkbox`||n instanceof HTMLTextAreaElement)&&n.setSelectionRange(e,e),await Hdt(100)}if(c===0){d(`No unsaved changes`);return}p.current?.(),await f.current()}}catch(e){ot.error(`Error saving files`,{error:e}),s(`Error saving files`)}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[t,c,f,p]),{showTooltip:o,isSaving:i,unsavedChangesCount:c,saveAll:r}},rpt=()=>{let{showTooltip:e,saveAll:t,isSaving:n,unsavedChangesCount:r}=npt(),{hasEditor:i,editorName:a,isLoading:o,showPreferenceDialog:s,setShowPreferenceDialog:c,availableEditors:l,savePreference:u,openInEditor:d}=Vdt();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`sticky bottom-0 h-12 border-t bg-surface-sunken items-center flex px-2 gap-x-2`,children:[(0,U.jsx)(cR,{open:!!e,content:e??``,children:(0,U.jsx)(X,{variant:r>0||n?`default`:`ghost`,size:`sm`,className:`text-xs`,"data-test":`save`,disabled:n,onClick:async()=>{await t()},children:(0,U.jsxs)(YP,{className:`flex items-center gap-1 text-xs relative`,loading:n,children:[`Save`,(0,U.jsx)(`span`,{className:r>0?`text-white`:`text-muted-foreground`,children:`[⌘+S]`})]})})}),!o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`h-6 w-px bg-border`}),(0,U.jsx)(cR,{content:i?`Open in ${a}`:`Choose editor to open files`,children:(0,U.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:d,className:`text-xs`,children:[(0,U.jsx)(Td,{size:14}),`Open in Editor`]})})]})]}),(0,U.jsx)(Bdt,{open:s,editors:l,onSelect:u,onCancel:()=>c(!1)})]})},ipt=({className:e})=>(0,U.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,children:[(0,U.jsx)(`title`,{children:`route`}),(0,U.jsx)(`g`,{id:`Page-1`,stroke:`none`,strokeWidth:`1`,fill:`none`,fillRule:`evenodd`,children:(0,U.jsxs)(`g`,{id:`route`,transform:`translate(0.393398, 0.686292)`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,U.jsx)(`rect`,{id:`Rectangle`,transform:`translate(10.606602, 10.606602) rotate(-315.000000) translate(-10.606602, -10.606602) `,x:`4.10660172`,y:`4.10660172`,width:`13`,height:`13`,rx:`2`}),(0,U.jsxs)(`g`,{id:`arrow`,transform:`translate(7.616869, 7.313708)`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`polyline`,{id:`Path-2`,points:`3.71305334 5.62451673 6 2.81225836 3.71305334 2.8356215e-17`}),(0,U.jsx)(`path`,{d:`M0,5.82380758 C0,3.25305906 1.05990598,2.81225836 2.58824265,2.81225836 C3.60713376,2.81225836 4.70470328,2.81225836 5.88095119,2.81225836`,id:`Path-3`})]})]})})]}),apt=[`@zuplo/runtime`,`@zuplo/graphql`,`@zuplo/otel`];function opt(e){return e===`.`?`index.d.ts`:`${e.replace(/^\.\//,``)}/index.d.ts`}var spt=[{name:`@zuplo/test`,version:`0.0.0`,types:`types/@zuplo/test/latest/types.d.ts`},{name:`chai`,version:`0.0.0`,types:`types/@types/chai/latest/index.d.ts`},{name:`openapi-types`,version:`0.0.0`,types:`types/openapi-types/latest/index.d.ts`}],cpt=[{types:`types/@zuplo/runtime/types/environment.d.ts`,name:`@app/environment`},{types:`types/@zuplo/runtime/types/custom.d.ts`,name:`lib.custom.ts`},{types:`types/@zuplo/runtime/latest/global.d.ts`,name:`global.d.ts`}];async function lpt(){try{return await(await fetch(`https://cdn.zuplo.com/types/remote-modules.d.ts`)).text()}catch(e){Zt.captureException(e)}}async function upt(e,t){try{let n=await fetch(`${B}/types/${e}/${t}/package.json`);if(!n.ok)throw Error(`Error loading package.json for ${e}`);return await n.json()}catch(e){Zt.captureException(e)}}async function dpt(){try{let e=await fetch(`${B}/types/@zuplo/bundled/bundles.json`);if(!e.ok)throw Error(`Error loading bundles from CDN`);let t=await e.json();return[...spt,...t.bundles]}catch(e){Zt.captureException(e)}return[...spt]}async function ZZ(e){try{let t=await fetch(`${B}/${e}`);if(!t.ok)throw Error(`Error loading type definition: ${e}`);return await t.text()}catch(e){Zt.captureException(e)}}var fpt=async(e,t,n)=>{let r=`https://cdn.jsdelivr.net/npm/${e}@${t}${n}`,i=await fetch(r);return i.ok?i.text():Error(`OK`)};async function ppt(e){await Promise.all(apt.map(async t=>{let n=await upt(t,`latest`);n&&(e.typescript.typescriptDefaults.addExtraLib(JSON.stringify(n),`file:///node_modules/${t}/package.json`),await Promise.all(Object.entries(n.exports).map(async([n,r])=>{let i=await ZZ(`types/${t}/latest/${r.types.substring(2)}`);if(i){let r=opt(n);e.typescript.typescriptDefaults.addExtraLib(i,`file:///node_modules/${t}/${r}`)}})))}))}async function mpt(e){let t=Object.keys(e.typescript.typescriptDefaults.getExtraLibs()),n=await dpt();await Promise.allSettled([...cpt.map(async({types:t,name:n})=>{let r=await ZZ(t);r&&e.typescript.typescriptDefaults.addExtraLib(r,n)}),...n.map(async n=>{if(t.includes(n.name))return;let r={name:n.name,version:n.version,types:`./index.d.ts`},i=await ZZ(n.types);i&&(e.typescript.typescriptDefaults.addExtraLib(JSON.stringify(r),`file:///node_modules/${n.name}/package.json`),e.typescript.typescriptDefaults.addExtraLib(i,`file:///node_modules/${n.name}/index.d.ts`))})])}var hpt=null,gpt=`
|
|
353
|
+
`).trim();return(0,U.jsx)(YE,{isUser:c,footer:!s&&u?(0,U.jsx)(udt,{text:u}):null,children:!c&&l.length===0?(0,U.jsx)(eD,{}):l.map(s=>s.kind===`tools`?(0,U.jsx)(ZE,{tools:s.tools},`${e.id}-${s.index}`):(0,U.jsx)(ddt,{part:s.part,isUser:c,onSend:t,onApproval:n,onSwitchProject:r,isActiveProject:i,primaryProject:a,disabled:o},`${e.id}-${s.index}`))})}function udt({text:e}){let{logEvent:t}=on(),{copyToClipboard:n,state:r}=jC(e,{showToast:!1,onCopy:()=>t(`agent-z-response-copied`,{messageLength:e.length})}),i=r===`copied`;return(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>void n(),"aria-label":`Copy response`,title:`Copy response`,className:W(`mt-1 self-start text-muted-foreground hover:text-foreground`,`opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100 pointer-coarse:opacity-100`,i&&`opacity-100`),children:i?(0,U.jsx)(td,{className:`size-3.5`}):(0,U.jsx)(xd,{className:`size-3.5`})})}function ddt({part:e,isUser:t,onSend:n,onApproval:r,onSwitchProject:i,isActiveProject:a,primaryProject:o,disabled:s}){if(e.type===`text`)return t?(0,U.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.text}):(0,U.jsx)(kC,{content:e.text});if(e.type===`reasoning`)return e.text?(0,U.jsx)(gje,{text:e.text}):null;if(jx(e)){let t=Nx(e);if(KE(e)){let n=e.state===`approval-requested`?{kind:`requested`}:e.state===`approval-responded`?{kind:`responded`,approved:e.approval.approved===!0}:{kind:`denied`};return(0,U.jsx)(jje,{toolLabel:JE(t),input:`input`in e?e.input:void 0,status:n,onRespond:t=>{e.state===`approval-requested`&&r(e.approval.id,t)}})}if(t===`present-options`){let t=rdt(`input`in e?e.input:void 0);return t?(0,U.jsx)(_je,{data:t,onSend:n,disabled:s}):null}if(t===`present-link`){let t=idt(`input`in e?e.input:void 0);return t?(0,U.jsx)(vje,{data:t}):null}if(t===`present-consumer`){let t=rRe(`input`in e?e.input:void 0);return t?(0,U.jsx)(iRe,{data:t}):null}if(t===`present-environment-variable`){let t=QBe(`input`in e?e.input:void 0);return t?(0,U.jsx)($Be,{data:t}):null}if(t===`present-source`){let t=sdt(`input`in e?e.input:void 0);return t?(0,U.jsx)(yje,{data:t}):null}if(t===`celebrate`){let t=Mje(`input`in e?e.input:void 0);return t?(0,U.jsx)(Pje,{data:t}):null}if(t===`present-file`){let t=eVe(`input`in e?e.input:void 0);return t?(0,U.jsx)(tVe,{data:t}):null}if(t===`show-test-console`){let t=Bit(`input`in e?e.input:void 0);return t?(0,U.jsx)(Vit,{data:t}):null}if(t===`switch-project`){let t=adt(`input`in e?e.input:void 0);return t?(0,U.jsx)(Tje,{projectName:t.projectName,reason:t.reason,isActive:a(t.projectName),disabled:s,onSwitch:()=>i(t.projectName)}):null}if(t===`update-working-copy`){let t=Jut(`input`in e?e.input:void 0);return t?(0,U.jsx)(Yut,{data:t}):null}if(t===`request-ai-provider`){let t=qOe(`input`in e?e.input:void 0);return t?(0,U.jsx)(fot,{data:t}):null}if(t===`request-ai-team`){let t=JOe(`input`in e?e.input:void 0);return t?(0,U.jsx)(gst,{data:t}):null}if(t===`request-ai-app`){let t=YOe(`input`in e?e.input:void 0);return t?(0,U.jsx)(Hit,{data:t}):null}return t===`request-openapi-import`?(0,U.jsx)(Gut,{data:Uut(`input`in e?e.input:void 0),onSend:n,disabled:s,primaryProject:o}):(0,U.jsx)(ZE,{tools:[{name:t,pending:GE(e)}]})}return null}function fdt({active:e,onPick:t}){let{logEvent:n}=on(),r=(0,H.useMemo)(()=>qut(),[]);return(0,H.useEffect)(()=>{e&&r.forEach((e,t)=>{n(`agent-z-cta-shown`,{ctaId:e.id,ctaCategory:e.category,position:t,batchSize:r.length})})},[e,r,n]),(0,U.jsxs)(`div`,{className:`mt-8 flex flex-col items-center text-center`,children:[(0,U.jsx)(Rme,{"aria-hidden":!0,className:`size-14`}),(0,U.jsx)(`h2`,{className:`mt-4 text-lg font-medium`,children:`Ask Zuplo AI`}),(0,U.jsx)(`p`,{className:`mt-1 max-w-md text-sm text-muted-foreground`,children:`Your AI assistant — ask about your APIs, policies, deployments, and more, right where you’re working.`}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-wrap justify-center gap-2`,children:r.map((e,i)=>(0,U.jsx)(X,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{n(`agent-z-cta-clicked`,{ctaId:e.id,ctaCategory:e.category,position:i,batchSize:r.length}),t(e)},children:e.prompt},e.id))})]})}var pdt=`w-full max-w-[440px]`;function mdt(){let{isOpen:e,close:t}=EZ(),{logEvent:n}=on(),[r,i]=(0,H.useState)(0),{account:a}=Wb([]),o=$b({enabled:!!a}),s=a?o.data?.find(e=>e.name===a):void 0,c=s?ahe(s):void 0,l=c?.status===`suspended`,u=c?.isAiEnabled===!1,d=e=>{e.key===`Escape`&&(n(`agent-z-panel-closed`,{source:`escape`}),t())};return(0,U.jsxs)(`aside`,{"aria-label":`Zuplo AI assistant`,inert:!e,onKeyDown:d,className:W(`fixed inset-y-0 right-0 z-40 flex flex-col border-l bg-background shadow-2xl`,pdt,`transition-transform duration-200 ease-in-out will-change-transform`,e?`translate-x-0`:`pointer-events-none translate-x-full`),children:[(0,U.jsxs)(`header`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,U.jsx)(Rme,{"aria-hidden":!0,className:`size-5`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Zuplo AI`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u||l?null:(0,U.jsxs)(X,{variant:`ghost`,size:`sm`,className:`text-sm font-normal text-muted-foreground`,onClick:()=>{n(`agent-z-new-chat-clicked`),i(e=>e+1)},children:[(0,U.jsx)(hf,{className:`size-4`}),`New chat`]}),(0,U.jsx)(X,{variant:`ghost`,size:`icon-sm`,onClick:()=>{n(`agent-z-panel-closed`,{source:`close-button`}),t()},"aria-label":`Close Zuplo AI`,children:(0,U.jsx)(Kf,{className:`size-4`})})]})]}),l?(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col justify-center overflow-y-auto bg-surface-sunken`,children:(0,U.jsx)(kme,{})}):u?(0,U.jsx)(hdt,{active:e}):(0,U.jsx)(cdt,{active:e},r)]})}function hdt({active:e}){let{openChat:t}=Lme(),{logEvent:n}=on(),{account:r}=Wb([]);(0,H.useEffect)(()=>{e&&n(`agent-z-disabled-state-shown`)},[e,n]);let{isAdmin:i}=Gme(r??``);return(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col justify-center overflow-y-auto bg-surface-sunken`,children:(0,U.jsx)(Ome,{title:`AI features are disabled`,description:`Zuplo AI is turned off for this account. Need a hand? Chat with our support team instead.`,action:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,U.jsxs)(X,{type:`button`,onClick:()=>{n(`agent-z-disabled-support-clicked`),t()},children:[(0,U.jsx)(sf,{"aria-hidden":!0,className:`size-4`}),`Chat with support`]}),i&&r?(0,U.jsx)(X,{type:`button`,variant:`outline`,size:`sm`,asChild:!0,children:(0,U.jsxs)(ws,{to:$r(Yb.AccountSettings,{account:r}),children:[(0,U.jsx)(rb,{weight:`fill`,"aria-hidden":!0,className:`size-4`}),`Enable AI features`]})}):null]})})})}var gdt=null,TZ=new Set,_dt=e=>{gdt=e;for(let e of TZ)e()},vdt=e=>(TZ.add(e),()=>{TZ.delete(e)}),ydt=()=>gdt,bdt=()=>(0,H.useSyncExternalStore)(vdt,ydt,ydt),xdt=(0,H.createContext)(void 0);function EZ(){let e=(0,H.useContext)(xdt);if(!e)throw Error(`useAgentZPanel must be used within AgentZPanelProvider`);return e}function Sdt({children:e}){let{variant:t}=Hy(wue),n=t===Tue,[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(null),s=(0,H.useCallback)(()=>i(!0),[]),c=(0,H.useCallback)(()=>i(!1),[]),l=(0,H.useCallback)(()=>i(e=>!e),[]),u=(0,H.useCallback)(e=>{o(e),i(!0)},[]),d=(0,H.useCallback)(()=>o(null),[]),f=(0,H.useMemo)(()=>({isOpen:n&&r,open:s,close:c,toggle:l,enabled:n,openWithPrompt:u,pendingPrompt:n?a:null,clearPendingPrompt:d}),[n,r,a,s,c,l,u,d]);return(0,H.useEffect)(()=>(_dt({enabled:n,openWithPrompt:u}),()=>_dt(null)),[n,u]),(0,U.jsxs)(xdt.Provider,{value:f,children:[(0,U.jsx)(`div`,{className:W(`transition-[padding] duration-200 ease-in-out`,f.isOpen&&`xl:pr-[440px]`),children:e}),n?(0,U.jsx)(mdt,{}):null]})}var Cdt=e=>(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 127.14 96.36`,...e,children:(0,U.jsx)(`path`,{d:`M107.7 8.07A105.15 105.15 0 0 0 81.47 0a72.06 72.06 0 0 0-3.36 6.83 97.68 97.68 0 0 0-29.11 0A72.37 72.37 0 0 0 45.64 0a105.89 105.89 0 0 0-26.25 8.09C2.79 32.65-1.71 56.6.54 80.21a105.73 105.73 0 0 0 32.17 16.15 77.7 77.7 0 0 0 6.89-11.11 68.42 68.42 0 0 1-10.85-5.18c.91-.66 1.8-1.34 2.66-2a75.57 75.57 0 0 0 64.32 0c.87.71 1.76 1.39 2.66 2a68.68 68.68 0 0 1-10.87 5.19 77 77 0 0 0 6.89 11.1 105.25 105.25 0 0 0 32.19-16.14c2.64-27.38-4.51-51.11-18.9-72.15ZM42.45 65.69C36.18 65.69 31 60 31 53s5-12.74 11.43-12.74S54 46 53.89 53s-5.05 12.69-11.44 12.69Zm42.24 0C78.41 65.69 73.25 60 73.25 53s5-12.74 11.44-12.74S96.23 46 96.12 53s-5.04 12.69-11.43 12.69Z`,style:{fill:`#fff`}})}),DZ=({text:e,onClick:t,className:n})=>(0,U.jsx)(X,{onClick:t,className:W(`bg-[#5865f2] hover:bg-[#464ec7] text-white`,n),asChild:!0,children:(0,U.jsxs)(`a`,{href:Mb,target:`_blank`,rel:`noreferrer`,children:[(0,U.jsx)(Cdt,{className:`w-6`}),e]})}),wdt=({goBack:e,hasGoHome:t})=>(0,U.jsxs)(`div`,{className:`flex gap-2 border-t pt-4 mt-2`,children:[t&&(0,U.jsx)(X,{asChild:!0,children:(0,U.jsxs)(`a`,{href:`/`,children:[(0,U.jsx)(Jd,{size:22}),`Go Home`]})}),(0,U.jsx)(DZ,{text:`Chat with us`}),e&&(0,U.jsx)(X,{onClick:()=>{e()},children:`Try again`})]}),Tdt=({isReconnecting:e=!1,onRetry:t})=>(0,U.jsx)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`You are offline`,className:`fixed inset-0 z-9999 flex items-center justify-center backdrop-blur-xs bg-black/60`,style:{pointerEvents:`auto`},children:(0,U.jsx)(`div`,{className:`relative max-w-md mx-4`,children:(0,U.jsxs)(`div`,{className:`relative bg-card rounded-xl shadow-2xl overflow-hidden border border-border`,children:[(0,U.jsx)(`div`,{className:`bg-muted border-b border-border p-6`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,U.jsx)(`div`,{className:`shrink-0`,children:(0,U.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-red-100 dark:bg-red-500/15 flex items-center justify-center`,children:(0,U.jsx)(Gf,{className:`w-6 h-6 text-red-600 dark:text-red-400`})})}),(0,U.jsxs)(`div`,{className:`flex-1`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-1`,children:`You're offline`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`We can't reach Zuplo right now`})]})]})}),(0,U.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,U.jsx)(`div`,{className:`bg-muted rounded-lg p-4 border border-border`,children:(0,U.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,U.jsx)(ud,{className:`w-5 h-5 text-green-600 dark:text-green-400 shrink-0 mt-0.5`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-foreground mb-1`,children:`Your work is safe`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Nothing on this page was lost. It will reconnect and refresh automatically as soon as you're back online.`})]})]})}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(vf,{className:`w-3.5 h-3.5 ${e?`animate-spin`:``}`}),e?`Checking connection…`:`Waiting for connection…`]}),t&&(0,U.jsx)(X,{variant:`outline`,size:`sm`,onClick:t,disabled:e,children:`Try now`})]})]})]})})}),Edt=e=>e instanceof he||e instanceof He?{type:e.type,title:e.message,status:e.status,detail:e.detail,instance:e.instance,traceId:e.traceId}:{title:`Oh zup! Something went wrong.`,detail:e instanceof Error?e.message:String(e)};function Ddt(e){return e===`root`?`app-dead`:`page-dead`}function Odt({id:e}){let t=vo(),n=s(t);if((0,H.useEffect)(()=>{if(n)return qe.subscribe(e=>{e&&window.location.reload()})},[n]),(0,H.useEffect)(()=>{!t||n||Kit(`Portal route error boundary rendered`,t,Ddt(e),{routeBoundaryId:e??`unknown`})},[t,n,e]),n)return(0,U.jsx)(Tdt,{onRetry:()=>window.location.reload()});let r=Edt(t);return(0,U.jsx)(`div`,{className:`m-auto`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 my-5 max-w-(--breakpoint-sm) m-6`,children:[(0,U.jsx)(`div`,{children:(0,U.jsxs)(OO,{variant:`outline`,children:[e,` Error`]})}),(0,U.jsx)(`span`,{className:`text-2xl font-medium`,children:r.title}),(0,U.jsxs)(`span`,{children:[`Unfortunately, we encountered an error while trying to load this page. But there are good news: We informed the team and someone will go and fix it.`,(0,U.jsx)(`br`,{}),` In the meantime, try again or reach out and chat with us.`]}),r.detail&&(0,U.jsx)(Sb,{variant:`destructive`,children:(0,U.jsxs)(wb,{children:[r.type&&`${r.type}:`,` `,r.detail]})}),(0,U.jsxs)(`span`,{className:`font-mono text-sm`,children:[`Version `,``,` `,r.traceId&&`| Trace ID ${r.traceId}`]}),(0,U.jsx)(wdt,{hasGoHome:!0})]})})}var kdt={"in-progress":`Build in progress`,failed:`Last build failed`,success:`Gateway deployed`,idle:`No deployment yet`},Adt=({status:e,className:t})=>e===`in-progress`?(0,U.jsx)(nf,{size:14,"aria-label":kdt[e],className:W(`animate-spin text-yellow-500`,t)}):(0,U.jsx)(`span`,{role:`img`,"aria-label":kdt[e],className:W(`w-2 h-2 shrink-0 rounded-full`,{"bg-green-500":e===`success`,"bg-red-500":e===`failed`,"bg-neutral-400":e===`idle`},t)}),jdt=({children:e,className:t,...n})=>(0,U.jsx)(`div`,{className:W(`sticky flex flex-col w-full border-b px-4 py-3 bg-white dark:bg-[#141412] z-10`,t),style:{top:`var(--banner-height, 0px)`},...n,children:e}),Mdt=({count:e})=>!e||e===0?null:(0,U.jsx)(`span`,{className:`absolute top-1 right-0 h-2 w-2 rounded-full bg-blue-400`}),Ndt=({children:e,to:t,badgeCount:n,end:r})=>(0,U.jsx)(Ts,{end:r,to:t,className:({isActive:e,isPending:t})=>W(`font-medium relative items-center px-2 py-1 rounded-md text-neutral-900 dark:text-white text-sm transition-colors`,`rounded-md hover:text-zuplo-600`,e&&`text-zuplo-700`,t&&`text-zuplo-700 animate-pulse`),children:({isActive:t})=>(0,U.jsxs)(U.Fragment,{children:[t&&(0,U.jsx)(GP.div,{layoutId:`local-navigation-item-background`,transition:{type:`spring`,bounce:.1,duration:.4},className:`absolute inset-0 rounded-md -z-10 bg-zuplo-100`}),e,(0,U.jsx)(Mdt,{count:n})]})}),Pdt=()=>{let e=op(),[t,n]=(0,H.useState)(!1),r=UR(e.environment),{copyToClipboard:i,state:a}=jC(r??``);return(0,U.jsxs)(aJ,{open:t,onOpenChange:n,children:[(0,U.jsx)(oJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`gap-2 flex justify-between h-8 mt-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Adt,{status:`success`}),`Deployment URLs`]}),(0,U.jsx)(nd,{size:16})]})}),(0,U.jsx)(sJ,{className:`divide-y p-0`,align:`end`,children:r?(0,U.jsxs)(`div`,{className:`p-4`,children:[(0,U.jsx)(`div`,{className:`font-medium text-lg`,children:`Local Development`}),(0,U.jsx)(`div`,{className:`h-2`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`uppercase text-muted-foreground font-semibold text-xs`,children:`Gateway`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Adt,{status:`success`}),(0,U.jsx)(`div`,{className:`text-sm max-w-52 truncate break-all`,children:(0,U.jsx)(Rw,{href:r,target:`_blank`,variant:`ghost`,rel:`noopener noreferrer`,className:`hover:underline`,children:r})}),(0,U.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-muted rounded-md transition-colors`,onClick:()=>{i(),n(!1)},children:a===`copied`?(0,U.jsx)(td,{size:16,className:`text-green-500`}):(0,U.jsx)(xd,{size:16})})]})]})]}):(0,U.jsxs)(`div`,{className:`w-60 p-5 text-center`,children:[(0,U.jsx)(`div`,{className:`text-2xl font-medium`,children:`🙈`}),(0,U.jsx)(`div`,{className:`text-md mt-4`,children:`Deployment URL not configured. Make sure your local gateway is running.`})]})})]})},Fdt=()=>(0,U.jsxs)(jdt,{className:`flex-row justify-between`,children:[(0,U.jsxs)(`nav`,{"aria-label":`Sidebar`,className:`flex gap-2 items-center`,children:[(0,U.jsx)(Ndt,{end:!0,to:`/dev/project/local`,children:`Project`}),(0,U.jsx)(Ndt,{to:`/dev/project/local/edit`,children:`Code`})]}),(0,U.jsx)(Pdt,{})]}),OZ=(0,H.createContext)({chromeBottom:0});function Idt({height:e,children:t}){let n={chromeBottom:(0,H.useContext)(OZ).chromeBottom+e};return(0,U.jsx)(OZ.Provider,{value:n,children:t})}function Ldt(){return(0,H.useContext)(OZ).chromeBottom}function Rdt(e=0){let t=Ldt()+e;return{top:`calc(${t}px + var(--banner-height, 0px))`,fillHeight:`calc(100vh - ${t}px - var(--banner-height, 0px))`}}var zdt=({children:e,className:t,offset:n=0})=>{let{fillHeight:r}=Rdt(n);return(0,U.jsx)(`div`,{className:W(t),style:{height:r},children:e})};function Bdt({open:e,editors:t,onSelect:n,onCancel:r}){let[i,a]=(0,H.useState)(null);return(0,U.jsx)(Ib,{open:e,onOpenChange:e=>!e&&r(),children:(0,U.jsxs)(zb,{className:`sm:max-w-md`,children:[(0,U.jsxs)(Bb,{children:[(0,U.jsx)(Hb,{children:`Choose Your Editor`}),(0,U.jsx)(Ub,{children:`Select which editor you'd like to use for opening files. This preference will be saved for future use.`})]}),(0,U.jsx)(`div`,{className:`space-y-2 py-4`,children:t.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`w-full text-left px-4 py-3 rounded-md border transition-colors ${i===e.id?`border-blue-500 bg-blue-50 dark:bg-blue-950/40`:`border-gray-200 dark:border-neutral-700 hover:border-gray-300 dark:hover:border-neutral-600 hover:bg-gray-50 dark:hover:bg-neutral-800/60`}`,onClick:()=>a(e.id),children:(0,U.jsx)(`div`,{className:`font-medium`,children:e.name})},e.id))}),(0,U.jsxs)(Vb,{children:[(0,U.jsx)(X,{variant:`ghost`,onClick:r,children:`Cancel`}),(0,U.jsx)(X,{variant:`default`,onClick:()=>{i&&n(i)},disabled:!i,children:`Save Preference`})]})]})})}var kZ=`/api/v1/editor`;function Vdt(){let[e]=Ms(),[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)([]),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!0);(0,H.useEffect)(()=>{(async()=>{try{let e=await fetch(`${kZ}/list`);if(!e.ok)throw Error(`Failed to fetch editors: ${e.status}`);o((await e.json()).editors);let t=await fetch(`${kZ}/detect`);if(!t.ok)throw Error(`Failed to detect editor: ${t.status}`);let r=await t.json();r.editor&&r.name&&(n(r.editor),i(r.name))}catch(e){ot.error(`Failed to load editor preference`,{error:e})}finally{u(!1)}})()},[]);let d=(0,H.useCallback)(async e=>{try{if((await fetch(`${kZ}/preference`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({editor:e})})).ok){let t=a.find(t=>t.id===e);t&&(n(e),i(t.name)),c(!1)}}catch(e){ot.error(`Failed to save editor preference`,{error:e})}},[a]),f=(0,H.useCallback)(async()=>{let n=e.get(`path`);if(!n){ot.warn(`No file path in URL`);return}if(!t){c(!0);return}try{let e=await fetch(`${kZ}/open`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({file:n})});if(!e.ok){let t=await e.json();ot.error(`Failed to open file in editor`,{error:t.message});return}let t=await e.json();t.url&&window.open(t.url,`_blank`)}catch(e){ot.error(`Failed to open file in editor`,{error:e})}},[e,t]);return{hasEditor:!!t,editorName:r,isLoading:l,showPreferenceDialog:s,setShowPreferenceDialog:c,availableEditors:a,savePreference:d,openInEditor:f}}var Hdt=e=>new Promise(t=>setTimeout(t,e)),AZ=e=>{let[t,n]=(0,H.useState)(`idle`),[r,i]=(0,H.useState)(),[a,o]=(0,H.useState)(null);return{state:t,error:r,execute:(0,H.useCallback)(async(...t)=>{n(`loading`),o(null),i(void 0);try{let r=await e(...t);return n(`hasValue`),o(r),r}catch(e){throw i(e instanceof Error?e:Error(e)),n(`hasError`),e}},[e]),value:a}},jZ=()=>({isReadOnly:op().environment.environmentType!==LF.WORKING_COPY}),Udt=a(((e,t)=>{t.exports=n;function n(e,t,n){e instanceof RegExp&&(e=r(e,n)),t instanceof RegExp&&(t=r(t,n));var a=i(e,t,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+e.length,a[1]),post:n.slice(a[1]+t.length)}}function r(e,t){var n=t.match(e);return n?n[0]:null}n.range=i;function i(e,t,n){var r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;)u==c?(r.push(u),c=n.indexOf(e,u+1)):r.length==1?s=[r.pop(),l]:(i=r.pop(),i<a&&(a=i,o=l),l=n.indexOf(t,u+1)),u=c<l&&c>=0?c:l;r.length&&(s=[a,o])}return s}})),Wdt=r(a(((e,t)=>{var n=Udt();t.exports=f;var r=`\0SLASH`+Math.random()+`\0`,i=`\0OPEN`+Math.random()+`\0`,a=`\0CLOSE`+Math.random()+`\0`,o=`\0COMMA`+Math.random()+`\0`,s=`\0PERIOD`+Math.random()+`\0`;function c(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function l(e){return e.split(`\\\\`).join(r).split(`\\{`).join(i).split(`\\}`).join(a).split(`\\,`).join(o).split(`\\.`).join(s)}function u(e){return e.split(r).join(`\\`).split(i).join(`{`).split(a).join(`}`).split(o).join(`,`).split(s).join(`.`)}function d(e){if(!e)return[``];var t=[],r=n(`{`,`}`,e);if(!r)return e.split(`,`);var i=r.pre,a=r.body,o=r.post,s=i.split(`,`);s[s.length-1]+=`{`+a+`}`;var c=d(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),t.push.apply(t,s),t}function f(e){return e?(e.substr(0,2)===`{}`&&(e=`\\{\\}`+e.substr(2)),_(l(e),!0).map(u)):[]}function p(e){return`{`+e+`}`}function m(e){return/^-?0\d/.test(e)}function h(e,t){return e<=t}function g(e,t){return e>=t}function _(e,t){var r=[],i=n(`{`,`}`,e);if(!i)return[e];var o=i.pre,s=i.post.length?_(i.post,!1):[``];if(/\$$/.test(i.pre))for(var l=0;l<s.length;l++){var u=o+`{`+i.body+`}`+s[l];r.push(u)}else{var f=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),v=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),y=f||v,b=i.body.indexOf(`,`)>=0;if(!y&&!b)return i.post.match(/,(?!,).*\}/)?(e=i.pre+`{`+i.body+a+i.post,_(e)):[e];var x;if(y)x=i.body.split(/\.\./);else if(x=d(i.body),x.length===1&&(x=_(x[0],!1).map(p),x.length===1))return s.map(function(e){return i.pre+x[0]+e});var S;if(y){var C=c(x[0]),w=c(x[1]),T=Math.max(x[0].length,x[1].length),E=x.length==3?Math.abs(c(x[2])):1,D=h;w<C&&(E*=-1,D=g);var O=x.some(m);S=[];for(var k=C;D(k,w);k+=E){var A;if(v)A=String.fromCharCode(k),A===`\\`&&(A=``);else if(A=String(k),O){var j=T-A.length;if(j>0){var M=Array(j+1).join(`0`);A=k<0?`-`+M+A.slice(1):M+A}}S.push(A)}}else{S=[];for(var N=0;N<x.length;N++)S.push.apply(S,_(x[N],!1))}for(var N=0;N<S.length;N++)for(var l=0;l<s.length;l++){var u=o+S[N]+s[l];(!t||y||u)&&r.push(u)}}return r}}))()),Gdt=1024*64,MZ=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>Gdt)throw TypeError(`pattern is too long`)},Kdt={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},NZ=e=>e.replace(/[[\]\\-]/g,`\\$&`),qdt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),Jdt=e=>e.join(``),Ydt=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(Kdt))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(NZ(d)+`-`+NZ(t)):t===d&&r.push(NZ(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(NZ(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(NZ(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l)return[qdt(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+Jdt(r)+`]`,p=`[`+(l?``:`^`)+Jdt(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},PZ=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/\[([^\/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,`$1$2`).replace(/\\([^\/])/g,`$1`),Xdt=new Set([`!`,`?`,`+`,`*`,`@`]),FZ=e=>Xdt.has(e),Zdt=e=>FZ(e.type),Qdt=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),$dt=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),eft=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),tft=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),nft=`(?!\\.\\.?(?:$|/))`,IZ=`(?!\\.)`,rft=new Set([`[`,`.`]),ift=new Set([`..`,`.`]),aft=new Set(`().*{}+?[]^$\\!`),oft=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),LZ=`[^/]`,sft=LZ+`*?`,cft=LZ+`+?`,lft=class e{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.type?this.#l=this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#l=this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...t){for(let n of t)if(n!==``){if(typeof n!=`string`&&!(n instanceof e&&n.#i===this))throw Error(`invalid part: `+n);this.#r.push(n)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let t=this.#i;for(let n=0;n<this.#a;n++){let r=t.#r[n];if(!(r instanceof e&&r.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(t){let n=new e(this.type,t);for(let e of this.#r)n.copyIn(e);return n}static#f(t,n,r,i,a){let o=i.maxExtglobRecursion??2,s=!1,c=!1,l=-1,u=!1;if(n.type===null){let d=r,f=``;for(;d<t.length;){let r=t.charAt(d++);if(s||r===`\\`){s=!s,f+=r;continue}if(c){d===l+1?(r===`^`||r===`!`)&&(u=!0):r===`]`&&!(d===l+2&&u)&&(c=!1),f+=r;continue}else if(r===`[`){c=!0,l=d,u=!1,f+=r;continue}if(!i.noext&&FZ(r)&&t.charAt(d)===`(`&&a<=o){n.push(f),f=``;let o=new e(r,n);d=e.#f(t,o,d,i,a+1),n.push(o);continue}f+=r}return n.push(f),d}let d=r+1,f=new e(null,n),p=[],m=``;for(;d<t.length;){let r=t.charAt(d++);if(s||r===`\\`){s=!s,m+=r;continue}if(c){d===l+1?(r===`^`||r===`!`)&&(u=!0):r===`]`&&!(d===l+2&&u)&&(c=!1),m+=r;continue}else if(r===`[`){c=!0,l=d,u=!1,m+=r;continue}if(FZ(r)&&t.charAt(d)===`(`&&(a<=o||n&&n.#h(r))){let o=n&&n.#h(r)?0:1;f.push(m),m=``;let s=new e(r,f);f.push(s),d=e.#f(t,s,d,i,a+o);continue}if(r===`|`){f.push(m),m=``,p.push(f),f=new e(null,n);continue}if(r===`)`)return m===``&&n.#r.length===0&&(n.#u=!0),f.push(m),m=``,n.push(...p,f),d;m+=r}return n.type=null,n.#t=void 0,n.#r=[t.substring(r-1)],d}#p(e){return this.#m(e,$dt)}#m(e,t=Qdt){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!=`object`||n.type===null?!1:this.#h(n.type,t)}#h(e,t=eft){return!!t.get(this.type)?.includes(e)}#g(t,n){let r=t.#r[0],i=new e(null,r,this.options);i.#r.push(``),r.push(i),this.#_(t,n)}#_(e,t){let n=e.#r[0];this.#r.splice(t,1,...n.#r);for(let e of n.#r)typeof e==`object`&&(e.#i=this);this.#l=void 0}#v(e){return!!tft.get(this.type)?.has(e)}#y(e){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!=`object`||t.type===null?!1:this.#v(t.type)}#b(e){let t=tft.get(this.type),n=e.#r[0],r=t?.get(n.type);if(!r)return!1;this.#r=n.#r;for(let e of this.#r)typeof e==`object`&&(e.#i=this);this.type=r,this.#l=void 0,this.#u=!1}#x(){if(Zdt(this)){let e=0,t=!1;do{t=!0;for(let e=0;e<this.#r.length;e++){let n=this.#r[e];typeof n==`object`&&(n.#x(),this.#m(n)?(t=!1,this.#_(n,e)):this.#p(n)?(t=!1,this.#g(n,e)):this.#y(n)&&(t=!1,this.#b(n)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e==`object`&&e.#x();this.#l=void 0}static fromGlob(t,n={}){let r=new e(null,void 0,n);return e.#f(t,r,0,n,0),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(){if(this.#e===this&&(this.#x(),this.#d()),!Zdt(this)){let t=this.isStart()&&this.isEnd(),n=this.#r.map(n=>{let[r,i,a,o]=typeof n==`string`?e.#S(n,this.#t,t):n.toRegExpSource();return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),r=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&ift.has(this.#r[0]))){let e=rft,t=this.#c.dot&&e.has(n.charAt(0))||n.startsWith(`\\.`)&&e.has(n.charAt(2))||n.startsWith(`\\.\\.`)&&e.has(n.charAt(4)),i=!this.#c.dot&&e.has(n.charAt(0));r=t?nft:i?IZ:``}let i=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(i=`(?:$|\\/)`),[r+n+i,PZ(n),this.#t=!!this.#t,this.#n]}let t=this.type===`!`?`(?:(?!(?:`:`(?:`,n=this.#r.map(e=>{if(typeof e==`string`)throw Error(`string type in extglob ast??`);let[t,n,r,i]=e.toRegExpSource();return this.#n=this.#n||i,t}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`);if(this.isStart()&&this.isEnd()&&!n&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,PZ(this.toString()),!1,!1]}let r=``;if(this.type===`!`&&this.#u)r=(this.isStart()&&!this.#c.dot?IZ:``)+cft;else{let e=this.type===`!`?`))`+(this.isStart()&&!this.#c.dot?IZ:``)+sft+`)`:this.type===`@`?`)`:`)${this.type}`;r=t+n+e}return[r,PZ(n),this.#t=!!this.#t,this.#n]}static#S(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(c!==`*`&&(o=!1),r){r=!1,i+=(aft.has(c)?`\\`:``)+c;continue}if(c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=Ydt(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?cft:sft,t=!0;continue}if(c===`?`){i+=LZ,t=!0;continue}i+=oft(c)}return[i,PZ(e),!!t,a]}},uft=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),RZ=(e,t,n={})=>(MZ(t),!n.nocomment&&t.charAt(0)===`#`?!1:new VZ(t,n).match(e)),dft=/^\*+([^+@!?\*\[\(]*)$/,fft=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),pft=e=>t=>t.endsWith(e),mft=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),hft=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),gft=/^\*+\.\*+$/,_ft=e=>!e.startsWith(`.`)&&e.includes(`.`),vft=e=>e!==`.`&&e!==`..`&&e.includes(`.`),yft=/^\.\*+$/,bft=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),xft=/^\*+$/,Sft=e=>e.length!==0&&!e.startsWith(`.`),Cft=e=>e.length!==0&&e!==`.`&&e!==`..`,wft=/^\?+([^+@!?\*\[\(]*)?$/,Tft=([e,t=``])=>{let n=kft([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Eft=([e,t=``])=>{let n=Aft([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Dft=([e,t=``])=>{let n=Aft([e]);return t?e=>n(e)&&e.endsWith(t):n},Oft=([e,t=``])=>{let n=kft([e]);return t?e=>n(e)&&e.endsWith(t):n},kft=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},Aft=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},jft=typeof process==`object`&&process?{}.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Mft={win32:{sep:`\\`},posix:{sep:`/`}};RZ.sep=jft===`win32`?Mft.win32.sep:Mft.posix.sep;var zZ=Symbol(`globstar **`);RZ.GLOBSTAR=zZ;var Nft=`[^/]*?`,Pft=`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`,Fft=`(?:(?!(?:\\/|^)\\.).)*?`;RZ.filter=(e,t={})=>n=>RZ(n,e,t);var BZ=(e,t={})=>Object.assign({},e,t);RZ.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return RZ;let t=RZ;return Object.assign((n,r,i={})=>t(n,r,BZ(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,BZ(e,n))}static defaults(n){return t.defaults(BZ(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,BZ(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,BZ(e,r))}},unescape:(n,r={})=>t.unescape(n,BZ(e,r)),escape:(n,r={})=>t.escape(n,BZ(e,r)),filter:(n,r={})=>t.filter(n,BZ(e,r)),defaults:n=>t.defaults(BZ(e,n)),makeRe:(n,r={})=>t.makeRe(n,BZ(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,BZ(e,r)),match:(n,r,i={})=>t.match(n,r,BZ(e,i)),sep:t.sep,GLOBSTAR:zZ})};var Ift=(e,t={})=>(MZ(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:(0,Wdt.default)(e));RZ.braceExpand=Ift,RZ.makeRe=(e,t={})=>new VZ(e,t).makeRe(),RZ.match=(e,t,n={})=>{let r=new VZ(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};var Lft=/[?*]|[+@!]\(.*?\)|\[|\]/,Rft=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),VZ=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){MZ(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||jft,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!Lft.test(e[2]))&&!Lft.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)e[t][n]===`**`&&(e[t][n]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];n===1&&r===``&&e[0]===``||(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];e===1&&r===``&&n[0]===``||(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);r&&(e[t]=r,e[n]=[])}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=0,i=0;if(this.isWindows){let n=e[0]===``&&e[1]===``&&e[2]===`?`&&typeof e[3]==`string`&&/^[a-z]:$/i.test(e[3]),a=t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]);if(n&&a){let n=e[3],a=t[3];n.toLowerCase()===a.toLowerCase()&&(e[3]=a,r=3,i=3)}else if(a&&typeof e[0]==`string`){let n=t[3],r=e[0];n.toLowerCase()===r.toLowerCase()&&(t[3]=r,i=3)}else if(n&&typeof t[0]==`string`){let n=e[3];n.toLowerCase()===t[0].toLowerCase()&&(t[0]=n,r=3)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(zZ)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(zZ,i),o=t.lastIndexOf(zZ),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n<e.length-u;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}let d=[[[],0]],f=d[0],p=0,m=[0];for(let e of c)e===zZ?(m.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);let h=d.length-1,g=e.length-u;for(let e of d)e[1]=g-(m[h--]+e[0].length);return!!this.#t(e,d,r,0,n,0,!!u)}#t(e,t,n,r,i,a,o){let s=t[r];if(!s){for(let t=n;t<e.length;t++){o=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return o}let[c,l]=s;for(;n<=l;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&a<this.maxGlobstarRecursion){let s=this.#t(e,t,n+c.length,r+1,i,a+1,o);if(s!==!1)return s}let s=e[n];if(s===`.`||s===`..`||!this.options.dot&&s.startsWith(`.`))return!1;n++}return i||null}#n(e,t,n,r,i){let a,o,s,c;for(a=r,o=i,c=e.length,s=t.length;a<c&&o<s;a++,o++){this.debug(`matchOne loop`);let n=t[o],r=e[a];if(this.debug(t,n,r),n===!1||n===zZ)return!1;let i;if(typeof n==`string`?(i=r===n,this.debug(`string match`,n,r,i)):(i=n.test(r),this.debug(`pattern match`,n,r,i)),!i)return!1}if(a===c&&o===s)return!0;if(a===c)return n;if(o===s)return a===c-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return Ift(this.pattern,this.options)}parse(e){MZ(e);let t=this.options;if(e===`**`)return zZ;if(e===``)return``;let n,r=null;(n=e.match(xft))?r=t.dot?Cft:Sft:(n=e.match(dft))?r=(t.nocase?t.dot?hft:mft:t.dot?pft:fft)(n[1]):(n=e.match(wft))?r=(t.nocase?t.dot?Eft:Tft:t.dot?Dft:Oft)(n):(n=e.match(gft))?r=t.dot?vft:_ft:(n=e.match(yft))&&(r=bft);let i=lft.fromGlob(e,this.options).toMMPattern();return r?Object.assign(i,{test:r}):i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?Nft:t.dot?Pft:Fft,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?Rft(e):e===zZ?zZ:e._src});return t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==zZ||a===zZ||(a===void 0?i!==void 0&&i!==zZ?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|`+n+`)?`:i!==zZ&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=zZ))}),t.filter(e=>e!==zZ).join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^\/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e=0;e<i.length;e++){let o=i[e],s=r;if(n.matchBase&&o.length===1&&(s=[a]),this.matchOne(s,o,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return RZ.defaults(e).Minimatch}};RZ.AST=lft,RZ.Minimatch=VZ,RZ.escape=uft,RZ.unescape=PZ;var zft=()=>{let e=Dt();return je({mutationFn:async t=>await e.fetch(tn.directories.createDirectory(t))})},Bft=[`saveStatus`],HZ={".ts":`typescript`,".tsx":`typescript`,".js":`javascript`,".jsx":`javascript`,".mjs":`javascript`,".cjs":`javascript`,".json":`json`,".html":`html`,".htm":`html`,".xml":`xml`,".svg":`xml`,".yaml":`yaml`,".yml":`yaml`,".md":`markdown`,".mdx":`markdown`,".css":`css`,".scss":`scss`,".sass":`sass`,".less":`less`,".py":`python`,".rs":`rust`,".go":`go`,".java":`java`,".c":`c`,".cpp":`cpp`,".cs":`csharp`,".php":`php`,".rb":`ruby`,".sh":`shell`,".bash":`shell`,".zsh":`shell`,".sql":`sql`,".graphql":`graphql`,".gql":`graphql`,".env":`plaintext`,".toml":`toml`,".ini":`ini`,".properties":`properties`,".dockerfile":`dockerfile`,Dockerfile:`dockerfile`,".makefile":`makefile`,Makefile:`makefile`};function Vft(e){let t=e.split(`/`).pop()||``;if(HZ[t])return HZ[t];let n=t.lastIndexOf(`.`);return n===-1?`plaintext`:HZ[t.slice(n)]||`plaintext`}var Hft=(e,t,n)=>Jb(mt.file(e,t),{...n,text:!0,select:e=>({content:e,contentType:`text/plain`,language:Vft(t),path:t})}),Uft=(e,t)=>Jb(mt.fsStats(e),{...t,refetchInterval:1e4,refetchOnWindowFocus:!0}),UZ=()=>{let e=Dt();return je({mutationFn:async t=>{let n=await e.fetch({...tn.fileTransactions.saveFile(t),parseResponse:!1}),r=n.headers.get(`Last-Modified`),i=r?new Date(r).getTime():void 0;return{...await n.json(),lastModified:i}}})},WZ=e=>{let t=Dt();return je({mutationFn:async e=>{if(!e.environmentName||!e.files)throw Error(`No environment name or files provided`);return await(await t.fetch(await tn.fileTransactions.saveMultipleFiles(e))).json()},mutationKey:WZ.mutationKey,...e})};WZ.mutationKey=Bft;var Wft=()=>{let e=Dt();return je({mutationFn:async t=>await e.fetch(tn.fileTransactions.deleteFile(t))})},Gft=()=>{let e=Dt();return je({mutationFn:async t=>await e.fetch(tn.fileTransactions.renameFile(t))})};function Kft(e,t){let n=t.map(e=>e.fileGlob),r=t.flatMap(e=>{let t=[e.folderName];return e.subdirectoryGlob?t.concat(e.subdirectoryGlob):t});return e.filter(e=>e.type===Us.Directory&&r.some(t=>RZ(e.path,t))?!0:n.find(t=>RZ(e.path,t))!==void 0)}function qft(e,t){return(0,H.useCallback)(async()=>Kft(await Ys(t,`/`),e),[t,e])}function GZ(){let{logEvent:e}=on(),t=XZ(),n=gp(),r=hp(e=>e.showSaveConflict);return WZ({onMutate:({files:e})=>{e.forEach(e=>{t({...e,saveState:Ws.saving})})},onSuccess:async(e,{files:n,environmentName:r})=>{e.buildId&&r&&Ke(r,e.buildId),n.forEach(n=>{let r=e.files?.[n.path];ot.debug(`Updated ${n.path} after save - lastModified: ${r}`),t({...n,lastModified:r,saveState:Ws.unmodified})})},onError:(i,{files:a})=>{if(i instanceof Error&&`status`in i&&i.status===412){let e=i;if(e.instance)try{let t=JSON.parse(e.instance).conflictedFiles;t&&t.length>0&&r(t[0])}catch(e){ot.error(`Failed to parse conflict error instance data`,{error:e})}return}a.forEach(e=>{t({...e,saveState:Ws.modified})}),e(`file-save-failed`,{fileNames:n.map(e=>e.path).join(`, `)})}})}function Jft(){let e=op(),{logEvent:t,captureException:n}=on(),r=$ft(),i=XZ(),a=Wft(),{isReadOnly:o}=jZ(),{execute:s}=AZ(async s=>{if(o)return{success:!1,error:Error(`Unable to delete file - environment is read-only`)};let c=s.saveState;i({...s,saveState:Ws.removing});try{return await a.mutateAsync({environmentName:e.environment.name,filePath:s.path}),r(s.path),t(`file-deleted`,{fileName:s.path,account:e.account.name,project:e.project.name,environment:e.environment.name}),{success:!0}}catch(r){return t(`file-deletion-failed`,{account:e.account.name,project:e.project.name,environment:e.environment.name}),n(r),i({...s,saveState:c}),{success:!1,error:r}}});return s}function KZ(){let e=nF(),{logEvent:t,captureException:n}=on(),r=XZ(),i=hp(e=>e.projectTreeNodes),a=UZ(),o=op([`account`,`project`,`environment`]),{execute:s}=AZ(async(s,c,l,u,d)=>{if(!e)return;let f=l??u.defaultFileTemplate,p=u.createExtensions[f],m=`${c}/${!p||s.toLowerCase().endsWith(`.${p}`)||s===u.predefinedTemplateFilename?.[f]?s:`${s}.${p}`}`,h=(l&&u.newFileTemplates[l]?.trimStart())??d??``,g=i.find(e=>e.path===m);if(g)return g;if(i.length===0){let e=(await Ys(o.environment.name,c).catch(()=>[])).find(e=>e.path===m);if(e)return e}let _={content:h,path:m},v={saveState:Ws.new,type:Us.File,..._};try{r(v);let n=e.Uri.file(m),i=e.editor.getModel(n);i?i.setValue(_.content??``):e.editor.createModel(_.content??``,void 0,n);let s=await a.mutateAsync({environmentName:o.environment.name,file:_,accountName:o.account.name,projectName:o.project.name});return s.buildId&&Ke(o.environment.name,s.buildId),r({...v,lastModified:s.lastModified,saveState:Ws.unmodified}),t(`file-added`,{account:o.account.name,project:o.project.name,environment:o.environment.name,fileName:v.path,strategy:u.name}),_}catch(e){t(`file-creation-failed`,{environment:o.environment.name}),n(e),r({...v,saveState:Ws.modified});return}});return s}function Yft(e){let t=nF(),{logEvent:n,captureException:r}=on(),i=Wb([`account`,`project`]),a=XZ(),o=$ft(),s=Gft(),{execute:c}=AZ(async(c,l)=>{if(t)try{a({...c,saveState:Ws.removing}),await s.mutateAsync({environmentName:e,path:c.path,newPath:l}),a({...c,saveState:Ws.new,path:l});let r=t.Uri.file(l),i=t.editor.getModel(r);i?i.setValue(c.content??``):t.editor.createModel(c.content??``,void 0,r);let u=t.editor.getModel(t.Uri.file(c.path));a({...c,path:l}),u?.dispose(),o(c.path),n(`file-renamed`,{fileName:c.path,environment:e})}catch(t){n(`file-rename-failed`,{account:i.account,project:i.project,environment:e}),r(t),a({...c,saveState:Ws.unmodified});return}});return c}function Xft(e){let t=nF(),{logEvent:n,captureException:r}=on(),i=XZ(),a=zft(),{execute:o}=AZ(async(o,s,c)=>{if(!t)return Error(`Failed to acquire monaco instance. Please refresh the page.`);let l=`${s}/${o}`,u={path:l},d={saveState:Ws.new,type:Us.Directory,...u};try{return i(d),await a.mutateAsync({environmentName:e,path:l}),i({...d,saveState:Ws.unmodified}),n(`directory-added`,{fileName:d.path,strategy:c.name,environment:e}),u}catch(t){return n(`directory-creation-failed`,{environment:e}),r(t),i({...d,saveState:Ws.modified}),t}});return o}function qZ(){return YZ(Irt().get(`path`))}function JZ(){let e=nF(),t=XZ();return(0,H.useCallback)((n,r=!1,i=Ws.modified)=>{if(t({...n,saveState:i}),r&&e){let t=e.editor.getModel(e.Uri.file(n.path));t&&t.setValue(n.content??``)}},[e,t])}function YZ(e){return hp(t=>e?t.filesByPath[e]:void 0)}function Zft(e){let t=hp(e=>e.projectTreeNodes),n=[],r=Object.values(e);return t.filter(e=>e.type===Us.Directory).forEach(e=>{let t=r.find(t=>t.folderName===e.path);if(t)return n.push(t)}),r.sort((e,t)=>e.order-t.order)}function Qft(e){return hp(e=>e.projectTreeNodes).filter(t=>!t.path&&!e.fileGlob?!1:t.type===Us.Directory&&e.subdirectoryGlob?RZ(t.path,e.subdirectoryGlob):RZ(t.path,e.fileGlob))}function $ft(){let e=nF(),t=hp(e=>e.removeFile),n=hp(e=>e.filterProjectTreeNodes);return r=>{e&&e.editor.getModel(e.Uri.file(r))?.dispose(),t(r),n(e=>e.path!==r)}}function XZ(){return hp(e=>e.updateFile)}var ept=e=>{let t=JZ(),n=YZ(e);return e=>{n&&t(n,!0,e)}},tpt=()=>{let e=op(),t=GZ(),n=gp();return CR(e.environment.name),{isPending:t.isPending,isSuccess:t.isSuccess,saveAndDeploy:(0,H.useCallback)(async()=>t.mutateAsync({environmentName:e.environment.name,accountName:e.account.name,projectName:e.project.name,files:n}).catch(e=>{if(!(e instanceof Error&&`status`in e&&e.status===409))throw e}),[t,n,!1,e.environment.name,e.account.name,e.project.name])}},npt=(e={})=>{let{isReadOnly:t=!1,onSave:n}=e,{saveAndDeploy:r,isPending:i,isSuccess:a}=tpt(),[o,s]=(0,H.useState)(null),c=hp(e=>{let t=0;for(let n of e.projectTreeNodes){let r=n.path?e.filesByPath[n.path]:void 0;r&&r.saveState===Ws.modified&&t++}return t}),l=hp(e=>{let t=0;for(let n of e.projectTreeNodes){let r=n.path?e.filesByPath[n.path]:void 0;r&&(r.saveState===Ws.modified||r.saveState===Ws.saving)&&t++}return t}),u=(0,H.useRef)(null),d=e=>{s(e),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{s(null)},1600)},f=Gb(r),p=Gb(n),m=rp(e=>e.addToast),h=(0,H.useRef)(!1),g=(0,H.useRef)(!1);return(0,H.useEffect)(()=>{let e=h.current;!e&&i?g.current=l>0:e&&!i&&a&&g.current&&(m({message:`Changes saved`,icon:(0,H.createElement)(td,{size:18}),duration:2e3}),g.current=!1),h.current=i},[i,a,l,m]),(0,H.useEffect)(()=>{let e=async e=>{try{if(e.code===`KeyS`&&(e.metaKey||e.ctrlKey)){if(e.preventDefault(),t){d(`Read only environment`);return}let n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){let e=n.selectionEnd;n.blur(),n.focus(),(n instanceof HTMLInputElement&&n.type!==`checkbox`||n instanceof HTMLTextAreaElement)&&n.setSelectionRange(e,e),await Hdt(100)}if(c===0){d(`No unsaved changes`);return}p.current?.(),await f.current()}}catch(e){ot.error(`Error saving files`,{error:e}),s(`Error saving files`)}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[t,c,f,p]),{showTooltip:o,isSaving:i,unsavedChangesCount:c,saveAll:r}},rpt=()=>{let{showTooltip:e,saveAll:t,isSaving:n,unsavedChangesCount:r}=npt(),{hasEditor:i,editorName:a,isLoading:o,showPreferenceDialog:s,setShowPreferenceDialog:c,availableEditors:l,savePreference:u,openInEditor:d}=Vdt();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`sticky bottom-0 h-12 border-t bg-surface-sunken items-center flex px-2 gap-x-2`,children:[(0,U.jsx)(cR,{open:!!e,content:e??``,children:(0,U.jsx)(X,{variant:r>0||n?`default`:`ghost`,size:`sm`,className:`text-xs`,"data-test":`save`,disabled:n,onClick:async()=>{await t()},children:(0,U.jsxs)(YP,{className:`flex items-center gap-1 text-xs relative`,loading:n,children:[`Save`,(0,U.jsx)(`span`,{className:r>0?`text-white`:`text-muted-foreground`,children:`[⌘+S]`})]})})}),!o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`h-6 w-px bg-border`}),(0,U.jsx)(cR,{content:i?`Open in ${a}`:`Choose editor to open files`,children:(0,U.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:d,className:`text-xs`,children:[(0,U.jsx)(Td,{size:14}),`Open in Editor`]})})]})]}),(0,U.jsx)(Bdt,{open:s,editors:l,onSelect:u,onCancel:()=>c(!1)})]})},ipt=({className:e})=>(0,U.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,children:[(0,U.jsx)(`title`,{children:`route`}),(0,U.jsx)(`g`,{id:`Page-1`,stroke:`none`,strokeWidth:`1`,fill:`none`,fillRule:`evenodd`,children:(0,U.jsxs)(`g`,{id:`route`,transform:`translate(0.393398, 0.686292)`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,U.jsx)(`rect`,{id:`Rectangle`,transform:`translate(10.606602, 10.606602) rotate(-315.000000) translate(-10.606602, -10.606602) `,x:`4.10660172`,y:`4.10660172`,width:`13`,height:`13`,rx:`2`}),(0,U.jsxs)(`g`,{id:`arrow`,transform:`translate(7.616869, 7.313708)`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`polyline`,{id:`Path-2`,points:`3.71305334 5.62451673 6 2.81225836 3.71305334 2.8356215e-17`}),(0,U.jsx)(`path`,{d:`M0,5.82380758 C0,3.25305906 1.05990598,2.81225836 2.58824265,2.81225836 C3.60713376,2.81225836 4.70470328,2.81225836 5.88095119,2.81225836`,id:`Path-3`})]})]})})]}),apt=[`@zuplo/runtime`,`@zuplo/graphql`,`@zuplo/otel`];function opt(e){return e===`.`?`index.d.ts`:`${e.replace(/^\.\//,``)}/index.d.ts`}var spt=[{name:`@zuplo/test`,version:`0.0.0`,types:`types/@zuplo/test/latest/types.d.ts`},{name:`chai`,version:`0.0.0`,types:`types/@types/chai/latest/index.d.ts`},{name:`openapi-types`,version:`0.0.0`,types:`types/openapi-types/latest/index.d.ts`}],cpt=[{types:`types/@zuplo/runtime/types/environment.d.ts`,name:`@app/environment`},{types:`types/@zuplo/runtime/types/custom.d.ts`,name:`lib.custom.ts`},{types:`types/@zuplo/runtime/latest/global.d.ts`,name:`global.d.ts`}];async function lpt(){try{return await(await fetch(`https://cdn.zuplo.com/types/remote-modules.d.ts`)).text()}catch(e){Zt.captureException(e)}}async function upt(e,t){try{let n=await fetch(`${B}/types/${e}/${t}/package.json`);if(!n.ok)throw Error(`Error loading package.json for ${e}`);return await n.json()}catch(e){Zt.captureException(e)}}async function dpt(){try{let e=await fetch(`${B}/types/@zuplo/bundled/bundles.json`);if(!e.ok)throw Error(`Error loading bundles from CDN`);let t=await e.json();return[...spt,...t.bundles]}catch(e){Zt.captureException(e)}return[...spt]}async function ZZ(e){try{let t=await fetch(`${B}/${e}`);if(!t.ok)throw Error(`Error loading type definition: ${e}`);return await t.text()}catch(e){Zt.captureException(e)}}var fpt=async(e,t,n)=>{let r=`https://cdn.jsdelivr.net/npm/${e}@${t}${n}`,i=await fetch(r);return i.ok?i.text():Error(`OK`)};async function ppt(e){await Promise.all(apt.map(async t=>{let n=await upt(t,`latest`);n&&(e.typescript.typescriptDefaults.addExtraLib(JSON.stringify(n),`file:///node_modules/${t}/package.json`),await Promise.all(Object.entries(n.exports).map(async([n,r])=>{let i=await ZZ(`types/${t}/latest/${r.types.substring(2)}`);if(i){let r=opt(n);e.typescript.typescriptDefaults.addExtraLib(i,`file:///node_modules/${t}/${r}`)}})))}))}async function mpt(e){let t=Object.keys(e.typescript.typescriptDefaults.getExtraLibs()),n=await dpt();await Promise.allSettled([...cpt.map(async({types:t,name:n})=>{let r=await ZZ(t);r&&e.typescript.typescriptDefaults.addExtraLib(r,n)}),...n.map(async n=>{if(t.includes(n.name))return;let r={name:n.name,version:n.version,types:`./index.d.ts`},i=await ZZ(n.types);i&&(e.typescript.typescriptDefaults.addExtraLib(JSON.stringify(r),`file:///node_modules/${n.name}/package.json`),e.typescript.typescriptDefaults.addExtraLib(i,`file:///node_modules/${n.name}/index.d.ts`))})])}var hpt=null,gpt=`
|
|
354
354
|
declare module "@zuplo/zudoku-plugin-monetization" {
|
|
355
355
|
export interface ZuploMonetizationPluginOptions {
|
|
356
356
|
pricing?: {
|
|
@@ -482,7 +482,7 @@ export function runtimeInit(runtime: RuntimeExtensions) {
|
|
|
482
482
|
`,`
|
|
483
483
|
+`).split(`
|
|
484
484
|
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,H.useEffect)(()=>{let n=t?.target??wOt,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&OEt(e))return!1;let n=EOt(e.code,s);if(a.current.add(e[n]),TOt(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=EOt(e.code,s);TOt(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function TOt(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function EOt(e,t){return t.includes(e)?`code`:`key`}var DOt=()=>{let e=t4();return(0,H.useMemo)(()=>({zoomIn:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[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)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=T2(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return S2(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=C2(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function OOt(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)kOt(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function kOt(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(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 AOt(e,t){return OOt(e,t)}function jOt(e,t){return OOt(e,t)}function o4(e,t){return{id:e,type:`select`,selected:t}}function s4(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(o4(a.id,e)))}return r}function MOt({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function NOt(e){return{id:e.id,type:`remove`}}var POt=e=>oEt(e),FOt=e=>aEt(e);function IOt(e){return(0,H.forwardRef)(e)}function LOt(e){let[t,n]=(0,H.useState)(BigInt(0)),[r]=(0,H.useState)(()=>ROt(()=>n(e=>e+BigInt(1))));return i4(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function ROt(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var zOt=(0,H.createContext)(null);function BOt({children:e}){let t=t4(),n=LOt((0,H.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=MOt({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=LOt((0,H.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(MOt({items:s,lookup:o}))},[])),i=(0,H.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,U.jsx)(zOt.Provider,{value:i,children:e})}function VOt(){let e=(0,H.useContext)(zOt);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var HOt=e=>!!e.panZoom;function c4(){let e=DOt(),t=t4(),n=VOt(),r=e4(HOt),i=(0,H.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=POt(e)?e:n.get(e.id),a=i.parentId?SEt(i.position,i.measured,i.parentId,n,r):i.position;return _2({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&POt(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&FOt(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await fEt({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(NOt);o?.(f),c(e)}if(m){let e=d.map(NOt);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=_Et(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=_2(s?r:a),l=y2(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=_Et(e)?e:a(e);if(!r)return!1;let i=y2(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return sEt(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??wEt();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,H.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var UOt=e=>e.selected,WOt=typeof window<`u`?window:void 0;function GOt({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=t4(),{deleteElements:r}=c4(),i=a4(e,{actInsideInputWithModifier:!1}),a=a4(t,{target:WOt});(0,H.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(UOt),edges:e.filter(UOt)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,H.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function KOt(e){let t=t4();(0,H.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=A2(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,e2.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var l4={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},qOt=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function JOt({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=r2.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=t4(),S=(0,H.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=e4(qOt,Q2),E=a4(f),D=(0,H.useRef)();KOt(S);let O=(0,H.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,H.useEffect)(()=>{if(S.current){D.current=NDt({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,H.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,U.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:l4,children:m})}var YOt=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function XOt(){let{userSelectionActive:e,userSelectionRect:t}=e4(YOt,Q2);return e&&t?(0,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}var u4=(e,t)=>n=>{n.target===t.current&&e?.(n)},ZOt=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function QOt({isSelecting:e,selectionKeyPressed:t,selectionMode:n=i2.Full,panOnDrag:r,paneClickDistance:i,selectionOnDrag:a,onSelectionStart:o,onSelectionEnd:s,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:p,children:m}){let h=t4(),{userSelectionActive:g,elementsSelectable:_,dragging:v,connectionInProgress:y}=e4(ZOt,Q2),b=_&&(e||g),x=(0,H.useRef)(null),S=(0,H.useRef)(),C=(0,H.useRef)(new Set),w=(0,H.useRef)(new Set),T=(0,H.useRef)(!1),E=e=>{if(T.current||y){T.current=!1;return}c?.(e),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},D=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}l?.(e)},O=u?e=>u(e):void 0;return(0,U.jsxs)(`div`,{className:J1([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:v,selection:e}]),onClick:b?void 0:u4(E,x),onContextMenu:u4(D,x),onWheel:u4(O,x),onPointerEnter:b?void 0:d,onPointerMove:b?e=>{let{userSelectionRect:r,transform:a,nodeLookup:s,edgeLookup:c,connectionLookup:l,triggerNodeChanges:u,triggerEdgeChanges:d,defaultEdgeOptions:f,resetSelectedElements:p}=h.getState();if(!S.current||!r)return;let{x:m,y:g}=j2(e.nativeEvent,S.current),{startX:_,startY:v}=r;if(!T.current){let n=t?0:i;if(Math.hypot(m-_,g-v)<=n)return;p(),o?.(e)}T.current=!0;let y={startX:_,startY:v,x:m<_?m:_,y:g<v?g:v,width:Math.abs(m-_),height:Math.abs(g-v)},b=C.current,x=w.current;C.current=new Set(d2(s,y,a,n===i2.Partial,!0).map(e=>e.id)),w.current=new Set;let E=f?.selectable??!0;for(let e of C.current){let t=l.get(e);if(t)for(let{edgeId:e}of t.values()){let t=c.get(e);t&&(t.selectable??E)&&w.current.add(e)}}CEt(b,C.current)||u(s4(s,C.current,!0)),CEt(x,w.current)||d(s4(c,w.current)),h.setState({userSelectionRect:y,userSelectionActive:!0,nodesSelectionActive:!1})}:f,onPointerUp:b?e=>{e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!g&&e.target===x.current&&h.getState().userSelectionRect&&E?.(e),h.setState({userSelectionActive:!1,userSelectionRect:null}),T.current&&(s?.(e),h.setState({nodesSelectionActive:C.current.size>0})))}:void 0,onPointerDownCapture:b?n=>{let{domNode:r}=h.getState();if(S.current=r?.getBoundingClientRect(),!S.current)return;let i=n.target===x.current;if(!i&&n.target.closest(`.nokey`)||!e||!(a&&i||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),T.current=!1;let{x:o,y:s}=j2(n.nativeEvent,S.current);h.setState({userSelectionRect:{width:0,height:0,startX:o,startY:s,x:o,y:s}}),i||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:b?e=>{T.current&&=(e.stopPropagation(),!1)}:void 0,onPointerLeave:p,ref:x,style:l4,children:[m,(0,U.jsx)(XOt,{})]})}function d4({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,e2.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function $Ot({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=t4(),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)();return(0,H.useEffect)(()=>{u.current=pDt({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{d4({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,H.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var ekt=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function tkt(){let e=t4();return(0,H.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=ekt(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=x2(t,i));let{position:a,positionAbsolute:s}=dEt({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var f4=(0,H.createContext)(null),nkt=f4.Provider;f4.Consumer;var rkt=()=>(0,H.useContext)(f4),ikt=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),akt=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o,u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===n2.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function okt({type:e=`source`,position:t=s2.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=t4(),_=rkt(),{connectOnClick:v,noPanClassName:y,rfId:b}=e4(ikt,Q2),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=e4(akt(_,m,e),Q2);_||g.getState().onError?.(`010`,e2.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t}=g.getState();t(zEt(i,e))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=kEt(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();U2.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)},A=t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=EEt(t.target),h=n||c,{connection:v,isValid:y}=U2.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})};return(0,U.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:J1([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?A:void 0,ref:p,...f,children:c})}var p4=(0,H.memo)(IOt(okt));function skt({data:e,isConnectable:t,sourcePosition:n=s2.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[e?.label,(0,U.jsx)(p4,{type:`source`,position:n,isConnectable:t})]})}function ckt({data:e,isConnectable:t,targetPosition:n=s2.Top,sourcePosition:r=s2.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(p4,{type:`target`,position:n,isConnectable:t}),e?.label,(0,U.jsx)(p4,{type:`source`,position:r,isConnectable:t})]})}function lkt(){return null}function ukt({data:e,isConnectable:t,targetPosition:n=s2.Top}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(p4,{type:`target`,position:n,isConnectable:t}),e?.label]})}var m4={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},dkt={input:skt,default:ckt,output:ukt,group:lkt};function fkt(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var pkt=e=>{let{width:t,height:n,x:r,y:i}=u2(e.nodeLookup,{filter:e=>!!e.selected});return{width:b2(t)?t:null,height:b2(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function mkt({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=t4(),{width:i,height:a,transformString:o,userSelectionActive:s}=e4(pkt,Q2),c=tkt(),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if($Ot({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,U.jsx)(`div`,{className:J1([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,U.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(m4,e.key)&&(e.preventDefault(),c({direction:m4[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var hkt=typeof window<`u`?window:void 0,gkt=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function _kt({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,preventScrolling:k,onSelectionContextMenu:A,noWheelClassName:j,noPanClassName:M,disableKeyboardA11y:N,onViewportChange:P,isControlledViewport:F}){let{nodesSelectionActive:I,userSelectionActive:L}=e4(gkt,Q2),R=a4(l,{target:hkt}),z=a4(h,{target:hkt}),B=z||w,ee=z||b,V=u&&B!==!0,te=R||L||V;return GOt({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,U.jsx)(JOt,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:ee,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!R&&B,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,zoomActivationKeyCode:g,preventScrolling:k,noWheelClassName:j,noPanClassName:M,onViewportChange:P,isControlledViewport:F,paneClickDistance:s,selectionOnDrag:V,children:(0,U.jsxs)(QOt,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:B,isSelecting:!!te,selectionMode:d,selectionKeyPressed:R,paneClickDistance:s,selectionOnDrag:V,children:[e,I&&(0,U.jsx)(mkt,{onSelectionContextMenu:A,noPanClassName:M,disableKeyboardA11y:N})]})})}_kt.displayName=`FlowRenderer`;var vkt=(0,H.memo)(_kt),ykt=e=>t=>e?d2(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function bkt(e){return e4((0,H.useCallback)(ykt(e),[e]),Q2)}var xkt=e=>e.updateNodeInternals;function Skt(){let e=e4(xkt),[t]=(0,H.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,H.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Ckt({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=t4(),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(e.sourcePosition),c=(0,H.useRef)(e.targetPosition),l=(0,H.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,H.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,H.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,H.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function wkt({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=e4(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},Q2),S=y.type||`default`,C=g?.[S]||dkt[S];C===void 0&&(v?.(`003`,e2.error003(S)),S=`default`,C=g?.default||dkt.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=t4(),k=xEt(y),A=Ckt({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=$Ot({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=tkt();if(y.hidden)return null;let N=O2(y),P=fkt(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,ee=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&d4({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},V=t=>{if(!(OEt(t.nativeEvent)||m)){if(eEt.includes(t.key)&&T)d4({id:e,store:O,unselect:t.key===`Escape`,nodeRef:A});else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(m4,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:m4[t.key],factor:t.shiftKey?4:1})}}},te=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(d2(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,U.jsx)(`div`,{className:J1([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:ee,onDoubleClick:B,onKeyDown:D?V:void 0,tabIndex:D?0:void 0,onFocus:D?te:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${rOt}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,U.jsx)(nkt,{value:e,children:(0,U.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var Tkt=(0,H.memo)(wkt),Ekt=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Dkt(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=e4(Ekt,Q2),o=bkt(e.onlyRenderVisibleElements),s=Skt();return(0,U.jsx)(`div`,{className:`react-flow__nodes`,style:l4,children:o.map(o=>(0,U.jsx)(Tkt,{id:o,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:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:a},o))})}Dkt.displayName=`NodeRenderer`;var Okt=(0,H.memo)(Dkt);function kkt(e){return e4((0,H.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&IEt({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),Q2)}var Akt=({color:e=`none`,strokeWidth:t=1})=>(0,U.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),jkt=({color:e=`none`,strokeWidth:t=1})=>(0,U.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),Mkt={[o2.Arrow]:Akt,[o2.ArrowClosed]:jkt};function Nkt(e){let t=t4();return(0,H.useMemo)(()=>Object.prototype.hasOwnProperty.call(Mkt,e)?Mkt[e]:(t.getState().onError?.(`009`,e2.error009(e)),null),[e])}var Pkt=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=Nkt(t);return c?(0,U.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,U.jsx)(c,{color:n,strokeWidth:o})}):null},Fkt=({defaultColor:e,rfId:t})=>{let n=e4(e=>e.edges),r=e4(e=>e.defaultEdgeOptions),i=(0,H.useMemo)(()=>XEt(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,U.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,U.jsx)(`defs`,{children:i.map(e=>(0,U.jsx)(Pkt,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};Fkt.displayName=`MarkerDefinitions`;var Ikt=(0,H.memo)(Fkt);function Lkt({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,H.useState)({x:1,y:0,width:0,height:0}),p=J1([`react-flow__edge-textwrapper`,l]),m=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,U.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,U.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,U.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}Lkt.displayName=`EdgeText`;var Rkt=(0,H.memo)(Lkt);function h4({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{...u,d:e,fill:`none`,className:J1([`react-flow__edge-path`,u.className])}),l?(0,U.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&b2(t)&&b2(n)?(0,U.jsx)(Rkt,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function zkt({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===s2.Left||e===s2.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function Bkt({sourceX:e,sourceY:t,sourcePosition:n=s2.Bottom,targetX:r,targetY:i,targetPosition:a=s2.Top}){let[o,s]=zkt({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=zkt({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=jEt({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function Vkt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=Bkt({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,U.jsx)(h4,{id:e.isInternal?void 0:t,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var Hkt=Vkt({isInternal:!1}),Ukt=Vkt({isInternal:!0});Hkt.displayName=`SimpleBezierEdge`,Ukt.displayName=`SimpleBezierEdgeInternal`;function Wkt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=s2.Bottom,targetPosition:m=s2.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=N2({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,U.jsx)(h4,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var Gkt=Wkt({isInternal:!1}),Kkt=Wkt({isInternal:!0});Gkt.displayName=`SmoothStepEdge`,Kkt.displayName=`SmoothStepEdgeInternal`;function qkt(e){return(0,H.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,U.jsx)(Gkt,{...n,id:r,pathOptions:(0,H.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var Jkt=qkt({isInternal:!1}),Ykt=qkt({isInternal:!0});Jkt.displayName=`StepEdge`,Ykt.displayName=`StepEdgeInternal`;function Xkt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=BEt({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,U.jsx)(h4,{id:e.isInternal?void 0:t,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var Zkt=Xkt({isInternal:!1}),Qkt=Xkt({isInternal:!0});Zkt.displayName=`StraightEdge`,Qkt.displayName=`StraightEdgeInternal`;function $kt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=s2.Bottom,targetPosition:s=s2.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=NEt({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,U.jsx)(h4,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var eAt=$kt({isInternal:!1}),tAt=$kt({isInternal:!0});eAt.displayName=`BezierEdge`,tAt.displayName=`BezierEdgeInternal`;var nAt={default:tAt,straight:Qkt,step:Ykt,smoothstep:Kkt,simplebezier:Ukt},rAt={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},iAt=(e,t,n)=>n===s2.Left?e-t:n===s2.Right?e+t:e,aAt=(e,t,n)=>n===s2.Top?e-t:n===s2.Bottom?e+t:e,oAt=`react-flow__edgeupdater`;function sAt({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,U.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:J1([oAt,`${oAt}-${s}`]),cx:iAt(t,r,e),cy:aAt(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function cAt({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=t4(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;U2.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,U.jsxs)(U.Fragment,{children:[(e===!0||e===`source`)&&(0,U.jsx)(sAt,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,U.jsx)(sAt,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function lAt({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=e4(t=>t.edgeLookup.get(e)),b=e4(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||nAt[x];S===void 0&&(_?.(`011`,e2.error011(x)),x=`default`,S=h?.default||nAt.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,H.useRef)(null),[D,O]=(0,H.useState)(!1),[k,A]=(0,H.useState)(!1),j=t4(),{zIndex:M,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=e4((0,H.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return{zIndex:y.zIndex,...rAt};let i=qEt({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_});return{zIndex:FEt({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...i||rAt}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),Q2),z=(0,H.useMemo)(()=>y.markerStart?`url('#${F2(y.markerStart,m)}')`:void 0,[y.markerStart,m]),B=(0,H.useMemo)(()=>y.markerEnd?`url('#${F2(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let ee=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},V=a?e=>{a(e,{...y})}:void 0,te=o?e=>{o(e,{...y})}:void 0,ne=s?e=>{s(e,{...y})}:void 0,re=c?e=>{c(e,{...y})}:void 0,ie=l?e=>{l(e,{...y})}:void 0;return(0,U.jsx)(`svg`,{style:{zIndex:M},children:(0,U.jsxs)(`g`,{className:J1([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:ee,onDoubleClick:V,onContextMenu:te,onMouseEnter:ne,onMouseMove:re,onMouseLeave:ie,onKeyDown:C?t=>{if(!v&&eEt.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${iOt}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,U.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:z,markerEnd:B,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,U.jsx)(cAt,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var uAt=(0,H.memo)(lAt),dAt=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function fAt({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=e4(dAt,Q2),b=kkt(t);return(0,U.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,U.jsx)(Ikt,{defaultColor:e,rfId:n}),b.map(e=>(0,U.jsx)(uAt,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}fAt.displayName=`EdgeRenderer`;var pAt=(0,H.memo)(fAt),mAt=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function hAt({children:e}){return(0,U.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:e4(mAt)},children:e})}function gAt(e){let t=c4(),n=(0,H.useRef)(!1);(0,H.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var _At=e=>e.panZoom?.syncViewport;function vAt(e){let t=e4(_At),n=t4();return(0,H.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function yAt(e){return e.connection.inProgress?{...e.connection,to:S2(e.connection.to,e.transform)}:{...e.connection}}function bAt(e){return e?t=>e(yAt(t)):yAt}function xAt(e){return e4(bAt(e),Q2)}var SAt=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function CAt({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=e4(SAt,Q2);return a&&i&&c?(0,U.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,U.jsx)(`g`,{className:J1([`react-flow__connection`,iEt(s)]),children:(0,U.jsx)(wAt,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var wAt=({style:e,type:t=a2.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=xAt();if(!i)return;if(n)return(0,U.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:iEt(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case a2.Bezier:[m]=NEt(h);break;case a2.SimpleBezier:[m]=Bkt(h);break;case a2.Step:[m]=N2({...h,borderRadius:0});break;case a2.SmoothStep:[m]=N2(h);break;default:[m]=BEt(h)}return(0,U.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};wAt.displayName=`ConnectionLine`;var TAt={};function EAt(e=TAt){(0,H.useRef)(e),t4(),(0,H.useEffect)(()=>{},[e])}function DAt(){t4(),(0,H.useRef)(!1),(0,H.useEffect)(()=>{},[])}function OAt({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,onPaneClick:B,onPaneMouseEnter:ee,onPaneMouseMove:V,onPaneMouseLeave:te,onPaneScroll:ne,onPaneContextMenu:re,paneClickDistance:ie,nodeClickDistance:ae,onEdgeContextMenu:oe,onEdgeMouseEnter:se,onEdgeMouseMove:ce,onEdgeMouseLeave:le,reconnectRadius:ue,onReconnect:de,onReconnectStart:fe,onReconnectEnd:pe,noDragClassName:me,noWheelClassName:he,noPanClassName:ge,disableKeyboardA11y:_e,nodeExtent:ve,rfId:ye,viewport:be,onViewportChange:xe}){return EAt(e),EAt(t),DAt(),gAt(n),vAt(be),(0,U.jsx)(vkt,{onPaneClick:B,onPaneMouseEnter:ee,onPaneMouseMove:V,onPaneMouseLeave:te,onPaneContextMenu:re,onPaneScroll:ne,paneClickDistance:ie,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:me,noWheelClassName:he,noPanClassName:ge,disableKeyboardA11y:_e,onViewportChange:xe,isControlledViewport:!!be,children:(0,U.jsxs)(hAt,{children:[(0,U.jsx)(pAt,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:de,onReconnectStart:fe,onReconnectEnd:pe,onlyRenderVisibleElements:T,onEdgeContextMenu:oe,onEdgeMouseEnter:se,onEdgeMouseMove:ce,onEdgeMouseLeave:le,reconnectRadius:ue,defaultMarkerColor:M,noPanClassName:ge,disableKeyboardA11y:_e,rfId:ye}),(0,U.jsx)(CAt,{style:h,type:m,component:g,containerStyle:_}),(0,U.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,U.jsx)(Okt,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:ae,onlyRenderVisibleElements:T,noPanClassName:ge,noDragClassName:me,disableKeyboardA11y:_e,nodeExtent:ve,rfId:ye}),(0,U.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}OAt.displayName=`GraphView`;var kAt=(0,H.memo)(OAt),AAt=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??t2;cDt(h,g,_);let{nodesInitialized:x}=z2(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=T2(u2(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:t2,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:n2.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,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:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...nEt},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:vEt,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:tEt,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},jAt=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>QDt((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await uEt({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...AAt({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=z2(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();cDt(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=aDt(e,n,r,i,a,o,l);d&&(eDt(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=P2(e,o.fromHandle,s2.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=V2(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(AOt(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(jOt(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>o4(e,!0)));return}i(s4(r,new Set([...e]),!0)),a(s4(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>o4(e,!0)));return}a(s4(n,new Set([...e]))),i(s4(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(o4(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(o4(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,o4(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,o4(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();e[0][0]===o[0][0]&&e[0][1]===o[0][1]&&e[1][0]===o[1][0]&&e[1][1]===o[1][1]||(z2(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return oDt({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return Promise.resolve(!1);let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...nEt}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...AAt()})}},Object.is);function MAt({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,H.useState)(()=>jAt({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,U.jsx)($Dt,{value:m,children:(0,U.jsx)(BOt,{children:p})})}function NAt({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,H.useContext)($2)?(0,U.jsx)(U.Fragment,{children:e}):(0,U.jsx)(MAt,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var PAt={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function FAt({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=a2.Bezier,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:ee,deleteKeyCode:V=`Backspace`,selectionKeyCode:te=`Shift`,selectionOnDrag:ne=!1,selectionMode:re=i2.Full,panActivationKeyCode:ie=`Space`,multiSelectionKeyCode:ae=E2()?`Meta`:`Control`,zoomActivationKeyCode:oe=E2()?`Meta`:`Control`,snapToGrid:se,snapGrid:ce,onlyRenderVisibleElements:le=!1,selectNodesOnDrag:ue,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,nodeOrigin:he=gOt,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve=!0,defaultViewport:ye=_Ot,minZoom:be=.5,maxZoom:xe=2,translateExtent:Se=t2,preventScrolling:Ce=!0,nodeExtent:we,defaultMarkerColor:Te=`#b1b1b7`,zoomOnScroll:Ee=!0,zoomOnPinch:De=!0,panOnScroll:Oe=!1,panOnScrollSpeed:ke=.5,panOnScrollMode:Ae=r2.Free,zoomOnDoubleClick:je=!0,panOnDrag:Me=!0,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze=1,nodeClickDistance:Be=0,children:Ve,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe=10,onNodesChange:Ze,onEdgesChange:Qe,noDragClassName:$e=`nodrag`,noWheelClassName:et=`nowheel`,noPanClassName:tt=`nopan`,fitView:nt,fitViewOptions:rt,connectOnClick:it,attributionPosition:at,proOptions:ot,defaultEdgeOptions:st,elevateNodesOnSelect:ct=!0,elevateEdgesOnSelect:lt=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:pt,connectionRadius:mt,isValidConnection:ht,onError:gt,style:_t,id:vt,nodeDragThreshold:yt,connectionDragThreshold:bt,viewport:xt,onViewportChange:St,width:Ct,height:wt,colorMode:Tt=`light`,debug:Et,onScroll:Dt,ariaLabelConfig:Ot,zIndexMode:kt=`basic`,...At},jt){let Mt=vt||`1`,Nt=COt(Tt),Pt=(0,H.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Dt?.(e)},[Dt]);return(0,U.jsx)(`div`,{"data-testid":`rf__wrapper`,...At,onScroll:Pt,style:{..._t,...PAt},ref:jt,className:J1([`react-flow`,i,Nt]),id:vt,role:`application`,children:(0,U.jsxs)(NAt,{nodes:e,edges:t,width:Ct,height:wt,fitView:nt,fitViewOptions:rt,minZoom:be,maxZoom:xe,nodeOrigin:he,nodeExtent:we,zIndexMode:kt,children:[(0,U.jsx)(xOt,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve,elevateNodesOnSelect:ct,elevateEdgesOnSelect:lt,minZoom:be,maxZoom:xe,nodeExtent:we,onNodesChange:Ze,onEdgesChange:Qe,snapToGrid:se,snapGrid:ce,connectionMode:L,translateExtent:Se,connectOnClick:it,defaultEdgeOptions:st,fitView:nt,fitViewOptions:rt,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:tt,nodeOrigin:he,rfId:Mt,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:pt,onError:gt,connectionRadius:mt,isValidConnection:ht,selectNodesOnDrag:ue,nodeDragThreshold:yt,connectionDragThreshold:bt,onBeforeDelete:I,debug:Et,ariaLabelConfig:Ot,zIndexMode:kt}),(0,U.jsx)(kAt,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:ee,selectionKeyCode:te,selectionOnDrag:ne,selectionMode:re,deleteKeyCode:V,multiSelectionKeyCode:ae,panActivationKeyCode:ie,zoomActivationKeyCode:oe,onlyRenderVisibleElements:le,defaultViewport:ye,translateExtent:Se,minZoom:be,maxZoom:xe,preventScrolling:Ce,zoomOnScroll:Ee,zoomOnPinch:De,zoomOnDoubleClick:je,panOnScroll:Oe,panOnScrollSpeed:ke,panOnScrollMode:Ae,panOnDrag:Me,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze,nodeClickDistance:Be,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe,defaultMarkerColor:Te,noDragClassName:$e,noWheelClassName:et,noPanClassName:tt,rfId:Mt,disableKeyboardA11y:ut,nodeExtent:we,viewport:xt,onViewportChange:St}),(0,U.jsx)(hOt,{onSelectionChange:k}),Ve,(0,U.jsx)(uOt,{proOptions:ot,position:at}),(0,U.jsx)(lOt,{rfId:Mt,disableKeyboardA11y:ut})]})})}var IAt=IOt(FAt);e2.error014();function LAt({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,U.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:J1([`react-flow__background-pattern`,n,r])})}function RAt({radius:e,className:t}){return(0,U.jsx)(`circle`,{cx:e,cy:e,r:e,className:J1([`react-flow__background-pattern`,`dots`,t])})}var g4;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(g4||={});var zAt={[g4.Dots]:1,[g4.Lines]:1,[g4.Cross]:6},BAt=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function VAt({id:e,variant:t=g4.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,H.useRef)(null),{transform:f,patternId:p}=e4(BAt,Q2),m=r||zAt[t],h=t===g4.Dots,g=t===g4.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,U.jsxs)(`svg`,{className:J1([`react-flow__background`,l]),style:{...c,...l4,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,U.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,U.jsx)(RAt,{radius:y/2,className:u}):(0,U.jsx)(LAt,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,U.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}VAt.displayName=`Background`;var HAt=(0,H.memo)(VAt);function UAt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,U.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function WAt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,U.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function GAt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,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 KAt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,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 qAt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,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 _4({children:e,className:t,...n}){return(0,U.jsx)(`button`,{type:`button`,className:J1([`react-flow__controls-button`,t]),...n,children:e})}var JAt=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function YAt({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=t4(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=e4(JAt,Q2),{zoomIn:y,zoomOut:b,fitView:x}=c4(),S=()=>{y(),a?.()},C=()=>{b(),o?.()},w=()=>{x(i),s?.()},T=()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)};return(0,U.jsxs)(n4,{className:J1([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(_4,{onClick:S,className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,U.jsx)(UAt,{})}),(0,U.jsx)(_4,{onClick:C,className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,U.jsx)(WAt,{})})]}),n&&(0,U.jsx)(_4,{className:`react-flow__controls-fitview`,onClick:w,title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,U.jsx)(GAt,{})}),r&&(0,U.jsx)(_4,{className:`react-flow__controls-interactive`,onClick:T,title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,U.jsx)(qAt,{}):(0,U.jsx)(KAt,{})}),u]})}YAt.displayName=`Controls`,(0,H.memo)(YAt);function XAt({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,U.jsx)(`rect`,{className:J1([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var ZAt=(0,H.memo)(XAt),QAt=e=>e.nodes.map(e=>e.id),v4=e=>e instanceof Function?e:()=>e;function $At({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=ZAt,onClick:o}){let s=e4(QAt,Q2),c=v4(t),l=v4(e),u=v4(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,U.jsx)(U.Fragment,{children:s.map(e=>(0,U.jsx)(tjt,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function ejt({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=e4(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=O2(r);return{node:r,x:i,y:a,width:o,height:s}},Q2);return!l||l.hidden||!xEt(l)?null:(0,U.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var tjt=(0,H.memo)(ejt),njt=(0,H.memo)($At),rjt=200,ijt=150,ajt=e=>!e.hidden,ojt=e=>{let 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?gEt(u2(e.nodeLookup,{filter:ajt}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},sjt=`react-flow__minimap-desc`;function cjt({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=t4(),S=(0,H.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=e4(ojt,Q2),j=e?.width??rjt,M=e?.height??ijt,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,z=C.x-(I-C.width)/2-R,B=C.y-(L-C.height)/2-R,ee=I+R*2,V=L+R*2,te=`${sjt}-${T}`,ne=(0,H.useRef)(0),re=(0,H.useRef)();ne.current=F,(0,H.useEffect)(()=>{if(S.current&&E)return re.current=CDt({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>ne.current}),()=>{re.current?.destroy()}},[E]),(0,H.useEffect)(()=>{re.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let ie=p?e=>{let[t,n]=re.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ae=m?(0,H.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,oe=_??A[`minimap.ariaLabel`];return(0,U.jsx)(n4,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F: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 o==`number`?o:void 0},className:J1([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,U.jsxs)(`svg`,{width:j,height:M,viewBox:`${z} ${B} ${ee} ${V}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":te,ref:S,onClick:ie,children:[oe&&(0,U.jsx)(`title`,{id:te,children:oe}),(0,U.jsx)(njt,{onClick:ae,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,U.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${z-R},${B-R}h${ee+R*2}v${V+R*2}h${-ee-R*2}z
|
|
485
|
-
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}cjt.displayName=`MiniMap`,(0,H.memo)(cjt);var ljt=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,ujt={[J2.Line]:`right`,[J2.Handle]:`bottom-right`};function djt({nodeId:e,position:t,variant:n=J2.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=rkt(),y=typeof e==`string`?e:v,b=t4(),x=(0,H.useRef)(null),S=n===J2.Handle,C=e4((0,H.useCallback)(ljt(S&&p),[S,p]),Q2),w=(0,H.useRef)(null),T=t??ujt[n];return(0,H.useEffect)(()=>{if(!(!x.current||!y))return w.current||=HDt({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=V2([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...SEt({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,U.jsx)(`div`,{className:J1([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,H.memo)(djt);function y4({value:e,onValueChange:t,options:n,columns:r=2,layout:i=`cards`,idPrefix:a=`wizard-choice`,ariaLabel:o,className:s}){return(0,U.jsx)(Rxt,{value:e,onValueChange:e=>t(e),"aria-label":o,className:W(i===`list`?`flex flex-col gap-2`:[`grid gap-3`,r===1&&`grid-cols-1`,r===2&&`grid-cols-2`,r===3&&`grid-cols-3`],s),children:n.map(t=>{let n=`${a}-${t.value}`,r=e===t.value,o=W(`rounded-md border transition-colors`,t.disabled?`cursor-not-allowed opacity-60`:`cursor-pointer`,r?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`bg-card hover:bg-neutral-50 dark:hover:bg-neutral-800/60`);return i===`list`?(0,U.jsxs)(GY,{htmlFor:n,className:W(`flex items-center gap-3 px-3 py-2.5`,o),children:[(0,U.jsx)(q1,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium sm:w-56 sm:shrink-0`,children:t.title}),t.description&&(0,U.jsx)(`div`,{className:`min-w-0 flex-1 text-xs leading-snug text-muted-foreground`,children:t.description})]})]},t.value):(0,U.jsxs)(GY,{htmlFor:n,className:W(`flex flex-col gap-1.5 p-3`,o),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(q1,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:t.title})]}),t.description&&(0,U.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t.description})]},t.value)})})}var b4=({tiles:e,selectedId:t,onSelect:n,fallbackIcon:r,columns:i=4,emptyState:a,className:o})=>{let[s,c]=(0,H.useState)(()=>new Set);return(0,U.jsxs)(`div`,{className:W(`grid auto-rows-min gap-2 p-0.5`,i===4?`grid-cols-4`:`grid-cols-3`,o),children:[e.map(e=>{let i=t===e.id,a=s.has(e.id)||!e.iconUrl;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-pressed":i,className:W(`flex flex-col items-center justify-center gap-1.5 rounded-md border bg-card p-2 text-center transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-800/60`,i?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`border-border`),children:[a?r:(0,U.jsx)(`img`,{src:e.iconUrl,alt:``,className:`size-7 object-contain brightness-0 dark:invert`,onError:()=>c(t=>new Set(t).add(e.id))}),(0,U.jsx)(`span`,{className:`w-full truncate text-xs leading-tight`,children:e.name})]},e.id)}),e.length===0&&a&&(0,U.jsx)(`div`,{className:`col-span-full py-6 text-center text-sm text-muted-foreground`,children:a})]})},fjt=`#ff00bd`,pjt=`#98036a`,mjt=`#fff0fc`,hjt=`#9ca3af`,gjt=`#6b7280`,_jt=`#f7f9fb`,x4=152,S4=60,vjt={client:Ku,gateway:Wf,origin:wf},yjt=`!h-0 !min-h-0 !w-0 !min-w-0 !border-0 !bg-transparent`,bjt={box:({data:e})=>{let{label:t,kind:n,emphasis:r}=e,i=vjt[n];return(0,U.jsxs)(`div`,{className:W(`flex flex-col items-center justify-center gap-1.5 rounded-lg border bg-card px-2 text-center shadow-xs`,r?`border-zuplo-600`:`border-neutral-300 dark:border-neutral-600`),style:{width:x4,height:S4},children:[(0,U.jsx)(p4,{type:`target`,position:s2.Left,isConnectable:!1,className:yjt}),(0,U.jsx)(i,{"aria-hidden":`true`,strokeWidth:1.75,className:W(`size-[18px] shrink-0`,r?`text-zuplo-600`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:`text-xs font-medium leading-tight text-muted-foreground`,children:t}),(0,U.jsx)(p4,{type:`source`,position:s2.Right,isConnectable:!1,className:yjt})]})}},C4=[{id:`client`,type:`box`,position:{x:0,y:0},width:x4,height:S4,initialWidth:x4,initialHeight:S4,data:{label:`MCP Client`,kind:`client`,emphasis:!1},draggable:!1,selectable:!1},{id:`gateway`,type:`box`,position:{x:270,y:0},width:x4,height:S4,initialWidth:x4,initialHeight:S4,data:{label:`Zuplo MCP Gateway`,kind:`gateway`,emphasis:!0},draggable:!1,selectable:!1},{id:`origin`,type:`box`,position:{x:540,y:0},width:x4,height:S4,initialWidth:x4,initialHeight:S4,data:{label:`Origin MCP Server`,kind:`origin`,emphasis:!1},draggable:!1,selectable:!1}],xjt=e=>{let t=(e,t,n,r,i)=>({id:e,source:t,target:n,type:`smoothstep`,label:r,animated:!1,style:{stroke:i?fjt:hjt,strokeWidth:i?2:1.5},labelStyle:{fill:i?pjt:gjt,fontWeight:i?600:500,fontSize:11},labelBgStyle:{fill:i?mjt:_jt,fillOpacity:.95},labelBgPadding:[6,3],labelBgBorderRadius:4,markerEnd:{type:o2.ArrowClosed,width:14,height:14,color:i?fjt:hjt}});return[t(`inbound`,`client`,`gateway`,`Inbound auth`,e===`inbound`),t(`outbound`,`gateway`,`origin`,`Outbound auth`,e===`outbound`)]},w4={minX:Math.min(...C4.map(e=>e.position.x)),minY:Math.min(...C4.map(e=>e.position.y)),maxX:Math.max(...C4.map(e=>e.position.x+(e.width??x4))),maxY:Math.max(...C4.map(e=>e.position.y+(e.height??S4)))},Sjt=w4.maxX-w4.minX,Cjt=w4.maxY-w4.minY,wjt=.5,Tjt=1.2,Ejt=.12;function Djt(e,t){let n=Math.min(e/Sjt,t/Cjt),r=Math.min(Tjt,Math.max(wjt,n*(1-Ejt*2)));return{x:(e-Sjt*r)/2-w4.minX*r,y:(t-Cjt*r)/2-w4.minY*r,zoom:r}}var Ojt=({active:e})=>{let t=(0,H.useMemo)(()=>xjt(e),[e]),n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useCallback)(()=>{let e=n.current,t=e?.clientWidth??0,i=e?.clientHeight??0;t>0&&i>0&&r.current?.setViewport(Djt(t,i))},[]),a=(0,H.useCallback)(e=>{r.current=e,i()},[i]);return(0,H.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=requestAnimationFrame(i)});return r.observe(e),()=>{cancelAnimationFrame(t),r.disconnect()}},[i]),(0,U.jsx)(`div`,{ref:n,role:`img`,"aria-label":`MCP request flow, configuring ${e} authentication`,className:`h-36 w-full overflow-hidden rounded-md border border-border`,children:(0,U.jsx)(IAt,{nodes:C4,edges:t,nodeTypes:bjt,onInit:a,minZoom:wjt,maxZoom:Tjt,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,edgesFocusable:!1,nodesFocusable:!1,panOnDrag:!1,panOnScroll:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0},style:{backgroundColor:_jt},children:(0,U.jsx)(HAt,{variant:g4.Dots,gap:16,size:1,color:`#dbe1e8`})})})};function T4(e){return e&&e.length>0?e:void 0}function E4(e){return e&&Object.keys(e).length>0?e:void 0}function kjt(e){let t=new Set;for(let n of e??[]){let e=n.trim();e&&t.add(e)}return[...t]}function D4(e,t){if(t!==`rolesAndGroups`)return{};if(e.public===!0)return{public:!0};let n=kjt(e.roles),r=kjt(e.groups);return{...n.length>0?{roles:n}:{},...r.length>0?{groups:r}:{}}}function Ajt(e){let t=e&&typeof e==`object`?e:{};return{accessControlMode:t.accessControl?.mode===`rolesAndGroups`?`rolesAndGroups`:`allPublic`,catalog:{tools:O4(t.tools,`name`,e=>({name:e})),prompts:O4(t.prompts,`name`,e=>({name:e})),resources:O4(t.resources,`uri`,e=>({uri:e,name:e})),resourceTemplates:O4(t.resourceTemplates,`uriTemplate`,e=>({uriTemplate:e,name:e}))}}}function O4(e,t,n){return Array.isArray(e)?e.flatMap(e=>{if(typeof e==`string`)return e.length>0?[n(e)]:[];if(!e||typeof e!=`object`)return[];let{public:r,...i}=e,a=i[t];if(typeof a!=`string`||a.length===0)return[];let o=i.name;return[{...i,...t!==`name`&&typeof o!=`string`?{name:a}:{},...r===!0?{public:!0}:{}}]}):[]}function k4(e){return jjt(e.catalog,e.accessControlMode)}function jjt(e,t=`allPublic`){return{...t===`rolesAndGroups`?{accessControl:{mode:t}}:{},tools:e.tools.flatMap(e=>{let n=T4(e.name);if(!n)return[];let r=T4(e.description),i=E4(e.annotations),a=E4(e._meta);return[{name:n,...r?{description:r}:{},...i?{annotations:i}:{},...a?{_meta:a}:{},...D4(e,t)}]}),prompts:e.prompts.flatMap(e=>{let n=T4(e.name);if(!n)return[];let r=T4(e.description),i=E4(e._meta);return[{name:n,...r?{description:r}:{},...i?{_meta:i}:{},...D4(e,t)}]}),resources:e.resources.flatMap(e=>{let n=T4(e.uri);if(!n)return[];let r=T4(e.name),i=T4(e.description),a=T4(e.mimeType),o=E4(e._meta);return[{uri:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...D4(e,t)}]}),resourceTemplates:e.resourceTemplates.flatMap(e=>{let n=T4(e.uriTemplate);if(!n)return[];let r=T4(e.name),i=T4(e.description),a=T4(e.mimeType),o=E4(e._meta);return[{uriTemplate:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...D4(e,t)}]})}}var A4=e=>`/mcp-idp-icons/${e}.svg`,j4=[{id:`auth0`,label:`Auth0`,description:`Auth0 by Okta`,iconUrl:A4(`auth0`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-auth0-oauth-inbound`,policyExport:`McpAuth0OAuthInboundPolicy`,suggestedPolicyName:`mcp-auth0-inbound`,fields:[{key:`auth0Domain`,label:`Auth0 Domain`,defaultValue:`$env(MCP_AUTH0_DOMAIN)`,helpText:`Auth0 tenant domain, for example acme.us.auth0.com.`,required:!0},{key:`audience`,label:`Audience`,defaultValue:``,helpText:`Optional Auth0 API audience.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(MCP_AUTH0_CLIENT_ID)`,helpText:`Use an environment variable for deployable configs.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(MCP_AUTH0_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`workos`,label:`WorkOS`,description:`WorkOS User Management`,iconUrl:A4(`workos`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-workos-oauth-inbound`,policyExport:`McpWorkosOAuthInboundPolicy`,suggestedPolicyName:`mcp-workos-inbound`,fields:[{key:`clientId`,label:`Client ID`,defaultValue:`$env(WORKOS_CLIENT_ID)`,helpText:`WorkOS User Management client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(WORKOS_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`google`,label:`Google`,description:`Google OAuth`,iconUrl:A4(`google`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-google-oauth-inbound`,policyExport:`McpGoogleOAuthInboundPolicy`,suggestedPolicyName:`mcp-google-inbound`,fields:[{key:`clientId`,label:`Client ID`,defaultValue:`$env(GOOGLE_CLIENT_ID)`,helpText:`Google OAuth client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(GOOGLE_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`okta`,label:`Okta`,description:`Okta OIDC`,iconUrl:A4(`okta`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-okta-oauth-inbound`,policyExport:`McpOktaOAuthInboundPolicy`,suggestedPolicyName:`mcp-okta-inbound`,fields:[{key:`oktaDomain`,label:`Okta Domain`,defaultValue:`$env(OKTA_DOMAIN)`,helpText:`Okta org domain, for example acme.okta.com.`,required:!0},{key:`authorizationServerId`,label:`Authorization Server ID`,defaultValue:``,helpText:`Optional. Use default for Okta's default custom authorization server.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(OKTA_CLIENT_ID)`,helpText:`Okta OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(OKTA_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`entra`,label:`Microsoft Entra`,description:`Microsoft Entra ID`,iconUrl:A4(`entra`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-entra-oauth-inbound`,policyExport:`McpEntraOAuthInboundPolicy`,suggestedPolicyName:`mcp-entra-inbound`,fields:[{key:`tenantId`,label:`Tenant ID`,defaultValue:`$env(ENTRA_TENANT_ID)`,helpText:`Microsoft Entra tenant UUID.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(ENTRA_CLIENT_ID)`,helpText:`Microsoft Entra application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(ENTRA_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`cognito`,label:`Cognito`,description:`Amazon Cognito`,iconUrl:A4(`cognito`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-cognito-oauth-inbound`,policyExport:`McpCognitoOAuthInboundPolicy`,suggestedPolicyName:`mcp-cognito-inbound`,fields:[{key:`awsRegion`,label:`AWS Region`,defaultValue:`$env(COGNITO_AWS_REGION)`,helpText:`AWS region containing the Cognito user pool.`,required:!0},{key:`userPoolId`,label:`User Pool ID`,defaultValue:`$env(COGNITO_USER_POOL_ID)`,helpText:`Cognito user pool ID, for example us-east-1_AbCdEf123.`,required:!0},{key:`userPoolDomain`,label:`User Pool Domain`,defaultValue:`$env(COGNITO_USER_POOL_DOMAIN)`,helpText:`Hosted UI domain without https:// or a path.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(COGNITO_CLIENT_ID)`,helpText:`Cognito app client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(COGNITO_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`clerk`,label:`Clerk`,description:`Clerk OAuth`,iconUrl:A4(`clerk`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-clerk-oauth-inbound`,policyExport:`McpClerkOAuthInboundPolicy`,suggestedPolicyName:`mcp-clerk-inbound`,fields:[{key:`frontendApiUrl`,label:`Frontend API URL`,defaultValue:`$env(CLERK_FRONTEND_API_URL)`,helpText:`Clerk Frontend API URL origin, without a path.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(CLERK_CLIENT_ID)`,helpText:`Clerk OAuth application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(CLERK_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`keycloak`,label:`Keycloak`,description:`Keycloak OIDC`,iconUrl:A4(`keycloak`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-keycloak-oauth-inbound`,policyExport:`McpKeycloakOAuthInboundPolicy`,suggestedPolicyName:`mcp-keycloak-inbound`,fields:[{key:`keycloakBaseUrl`,label:`Keycloak Base URL`,defaultValue:`$env(KEYCLOAK_BASE_URL)`,helpText:`Server root URL, without /realms/{realm}.`,required:!0},{key:`realm`,label:`Realm`,defaultValue:`$env(KEYCLOAK_REALM)`,helpText:`Keycloak realm name.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(KEYCLOAK_CLIENT_ID)`,helpText:`Keycloak OIDC client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(KEYCLOAK_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`logto`,label:`Logto`,description:`Logto OIDC`,iconUrl:A4(`logto`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-logto-oauth-inbound`,policyExport:`McpLogtoOAuthInboundPolicy`,suggestedPolicyName:`mcp-logto-inbound`,fields:[{key:`logtoEndpoint`,label:`Logto Endpoint`,defaultValue:`$env(LOGTO_ENDPOINT)`,helpText:`Logto tenant endpoint or custom domain, without /oidc.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(LOGTO_CLIENT_ID)`,helpText:`Logto application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(LOGTO_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`onelogin`,label:`OneLogin`,description:`OneLogin OIDC`,iconUrl:A4(`onelogin`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-onelogin-oauth-inbound`,policyExport:`McpOneLoginOAuthInboundPolicy`,suggestedPolicyName:`mcp-onelogin-inbound`,fields:[{key:`oneLoginSubdomain`,label:`OneLogin Subdomain`,defaultValue:`$env(ONELOGIN_SUBDOMAIN)`,helpText:`Account subdomain, without .onelogin.com.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(ONELOGIN_CLIENT_ID)`,helpText:`OneLogin OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(ONELOGIN_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`ping`,label:`Ping`,description:`PingOne OIDC`,iconUrl:A4(`ping`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-ping-oauth-inbound`,policyExport:`McpPingOAuthInboundPolicy`,suggestedPolicyName:`mcp-ping-inbound`,fields:[{key:`environmentId`,label:`Environment ID`,defaultValue:`$env(PING_ENVIRONMENT_ID)`,helpText:`PingOne environment ID. Not used when custom domain is set.`,required:!1},{key:`region`,label:`Region`,defaultValue:`north-america`,helpText:`PingOne geography. Ignored when custom domain is set.`,required:!1},{key:`customDomain`,label:`Custom Domain`,defaultValue:``,helpText:`Optional PingOne custom domain without https://.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(PING_CLIENT_ID)`,helpText:`PingOne OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(PING_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`custom-oauth`,label:`Custom OAuth`,description:`Any OAuth 2.0 / OIDC identity provider`,iconUrl:`https://cdn.zuplo.com/portal/policy-icons/mcp-oauth-inbound.svg`,policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-oauth-inbound`,policyExport:`McpOAuthInboundPolicy`,suggestedPolicyName:`mcp-oauth-inbound`,fields:[],defaultOptions:{oidc:{issuer:`https://my-tenant.us.auth0.com/`,jwksUrl:`https://my-tenant.us.auth0.com/.well-known/jwks.json`,audience:`https://gateway.example.com`},browserLogin:{url:`https://my-tenant.us.auth0.com/authorize`,tokenUrl:`https://my-tenant.us.auth0.com/oauth/token`,clientId:`$env(MCP_OAUTH_CLIENT_ID)`,clientSecret:`$env(MCP_OAUTH_CLIENT_SECRET)`,scope:`openid profile email`,pkce:`none`}}}];function M4(e){return j4.find(t=>t.id===e)}function Mjt(e){return Object.fromEntries(e.fields.map(e=>[e.key,e.defaultValue]))}var Njt=`Most Used`,Pjt=`Other`,Fjt=[`rate-limit`,`api-key`],Ijt=[{name:`Rate Limiting & Quotas`,baseIds:[`rate-limit`,`complex-rate-limit`,`quota`]},{name:`Authentication`,baseIds:[`api-key`,`basic-auth`,`mtls-auth`,`ldap-auth`,`open-id-jwt-auth`,`okta-jwt-auth`,`auth0-jwt-auth`,`clerk-jwt-auth`,`cognito-jwt-auth`,`firebase-jwt`,`supabase-jwt-auth`,`propel-auth-jwt`,`curity-phantom-token`,`stripe-webhook-verification`,`web-bot-auth`]},{name:`Authorization`,baseIds:[`jwt-scopes`,`openfga-authz`,`okta-fga-authz`,`axiomatics-authz`,`authzen`,`geo-filter`,`require-origin`]},{name:`MCP Authentication`,baseIds:[`mcp-oauth`,`mcp-auth0-oauth`,`mcp-clerk-oauth`,`mcp-cognito-oauth`,`mcp-entra-oauth`,`mcp-google-oauth`,`mcp-keycloak-oauth`,`mcp-logto-oauth`,`mcp-okta-oauth`,`mcp-onelogin-oauth`,`mcp-ping-oauth`,`mcp-workos-oauth`,`mcp-token-exchange`,`mcp-capability-filter`]},{name:`AI Gateway`,baseIds:[`ai-gateway-model-filtering-v2`,`ai-gateway-fallback-model-v2`,`ai-gateway-metering-v2`,`ai-gateway-semantic-cache-v2`,`ai-gateway-dlp`,`akamai-ai-firewall-v2`,`comet-opik-tracing-v2`,`galileo-tracing-v2`]},{name:`AI & Security`,baseIds:[`prompt-injection`,`bot-detection`,`akamai-firewall-for-ai`,`secret-masking`]},{name:`Caching`,baseIds:[`caching`,`semantic-cache`]},{name:`Transformations`,baseIds:[`xml-to-json`,`formdata-to-json`,`set-body`,`set-headers`,`set-query-params`,`set-status`,`remove-headers`,`remove-query-params`,`clear-headers`,`query-param-to-header`,`replace-string`,`change-method`]},{name:`Validation`,baseIds:[`validate-json-schema`,`request-validation`,`request-size-limit`]},{name:`Traffic Management`,baseIds:[`traffic-splitting`,`brownout`,`sleep`,`mock-api`,`http-deprecation`]},{name:`GraphQL`,baseIds:[`graphql-complexity-limit`,`graphql-disable-introspection`,`graphql-introspection-filter`]},{name:`Monetization & Metering`,baseIds:[`monetization`,`openmeter`,`amberflo-metering`,`moesif`,`readme-metrics`]},{name:`Logging & Tracing`,baseIds:[`audit-log`]},{name:`Upstream Auth`,baseIds:[`set-upstream-api-key`,`upstream-azure-ad-service-auth`,`upstream-firebase-admin-auth`,`upstream-firebase-user-auth`,`upstream-gcp-federated-auth`,`upstream-gcp-jwt`,`upstream-gcp-service-auth`,`upstream-zuplo-jwt-auth`]},{name:`Custom & Composite`,baseIds:[`custom-code`,`composite`]}],Ljt=/-(inbound|outbound|internal)$/,N4=e=>e.replace(Ljt,``),P4=new Map;for(let e of Ijt)for(let t of e.baseIds)P4.has(t)||P4.set(t,e.name);var Rjt=e=>P4.get(N4(e.id))??`Other`,zjt=e=>P4.get(N4(e))===`Authentication`,Bjt=e=>Fjt.includes(N4(e.id)),Vjt=e=>{let t=new Map,n=[];for(let r of e){Bjt(r)&&n.push(r);let e=Rjt(r),i=t.get(e);i?i.push(r):t.set(e,[r])}let r=[];n.length>0&&r.push({name:Njt,policies:n});for(let{name:e}of Ijt){let n=t.get(e);n&&n.length>0&&r.push({name:e,policies:n})}let i=t.get(Pjt);return i&&i.length>0&&r.push({name:Pjt,policies:i}),r},Hjt=[...j4.map(e=>e.policyType)];function Ujt(e){return Hjt.includes(e)||zjt(e)}var F4=`mcp-token-exchange-inbound`,I4=`mcp-capability-filter-inbound`,Wjt=`set-upstream-api-key-inbound`,Gjt=`remove-headers-inbound`;function L4(e){if(!e||typeof e!=`object`)return!1;let t=e.headers;if(!Array.isArray(t)||t.length!==1)return!1;let[n]=t;return typeof n==`string`&&n.toLowerCase()===`authorization`}var Kjt=e=>e.toLowerCase().replaceAll(` `,`-`),R4=({name:e,onChangeName:t,disabled:n,policies:r})=>{let[i,a]=(0,H.useState)(null);return(0,U.jsxs)(`div`,{className:`grid grid-cols-12 text-sm gap-2 items-center pt-1`,children:[(0,U.jsx)(`label`,{className:`col-span-1`,children:`Name`}),(0,U.jsx)(`div`,{className:`col-span-11`,children:(0,U.jsx)(XP,{type:`text`,id:`route-handler`,"data-test":`policy-picker-name-input`,name:`route-handler`,value:e??``,disabled:n,onChange:e=>{let n=e.currentTarget.value,i=Kjt(n.toLowerCase());a(hbt(i,r)),t(i)},"aria-describedby":`email-description`})}),i&&(0,U.jsx)(`div`,{className:`col-span-11 col-start-2 mt-1 text-red-600`,children:i})]})},qjt=`Toggle`,Jjt=H.forwardRef((e,t)=>{let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=Ct({prop:n,onChange:i,defaultProp:r??!1,caller:qjt});return(0,U.jsx)(sc.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:Qs(e.onClick,()=>{e.disabled||s(!o)})})});Jjt.displayName=qjt;var z4=`ToggleGroup`,[Yjt,Xjt]=T(z4,[Mq]),Zjt=Mq(),B4=H.forwardRef((e,t)=>{let{type:n,...r}=e;if(n===`single`)return(0,U.jsx)(eMt,{...r,ref:t});if(n===`multiple`)return(0,U.jsx)(tMt,{...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${z4}\``)});B4.displayName=z4;var[Qjt,$jt]=Yjt(z4),eMt=H.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=Ct({prop:n,defaultProp:r??``,onChange:i,caller:z4});return(0,U.jsx)(Qjt,{scope:e.__scopeToggleGroup,type:`single`,value:H.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:H.useCallback(()=>s(``),[s]),children:(0,U.jsx)(iMt,{...a,ref:t})})}),tMt=H.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=Ct({prop:n,defaultProp:r??[],onChange:i,caller:z4}),c=H.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=H.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,U.jsx)(Qjt,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,U.jsx)(iMt,{...a,ref:t})})});B4.displayName=z4;var[nMt,rMt]=Yjt(z4),iMt=H.forwardRef((e,t)=>{let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=Zjt(n),u=At(o),d={role:`group`,dir:u,...c};return(0,U.jsx)(nMt,{scope:n,rovingFocus:i,disabled:r,children:i?(0,U.jsx)(Nq,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,U.jsx)(sc.div,{...d,ref:t})}):(0,U.jsx)(sc.div,{...d,ref:t})})}),V4=`ToggleGroupItem`,aMt=H.forwardRef((e,t)=>{let n=$jt(V4,e.__scopeToggleGroup),r=rMt(V4,e.__scopeToggleGroup),i=Zjt(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=H.useRef(null);return r.rovingFocus?(0,U.jsx)(Pq,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,U.jsx)(oMt,{...s,ref:t})}):(0,U.jsx)(oMt,{...s,ref:t})});aMt.displayName=V4;var oMt=H.forwardRef((e,t)=>{let{__scopeToggleGroup:n,value:r,...i}=e,a=$jt(V4,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0};return(0,U.jsx)(Jjt,{...a.type===`single`?o:void 0,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})}),sMt=B4,cMt=aMt,lMt=Ou(`inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground`},size:{default:`h-9 px-2 min-w-9`,xs:`h-6 px-1.5 min-w-6 text-xs [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 px-1.5 min-w-8`,lg:`h-10 px-2.5 min-w-10`}},defaultVariants:{variant:`default`,size:`default`}}),uMt=H.createContext({size:`default`,variant:`default`,spacing:0});function H4({className:e,variant:t,size:n,spacing:r=0,children:i,...a}){return(0,U.jsx)(sMt,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,style:{"--gap":r},className:W(`group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs`,e),...a,children:(0,U.jsx)(uMt.Provider,{value:{variant:t,size:n,spacing:r},children:i})})}function U4({className:e,children:t,variant:n,size:r,...i}){let a=H.useContext(uMt);return(0,U.jsx)(cMt,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:W(lMt({variant:a.variant||n,size:a.size||r}),`w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10`,`data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l`,e),...i,children:t})}var dMt=({documentationSrc:e,className:t})=>(0,U.jsx)(`div`,{className:W(`prose prose-neutral prose-sm dark:prose-invert z-10 prose-headings:mt-2 prose-headings:text-sm max-w-full [&_li>div]:inline [&_li>div>p]:inline [&_code::before]:content-none [&_code::after]:content-none`,t),dangerouslySetInnerHTML:{__html:e}}),fMt=({documentationSrc:e})=>(0,U.jsxs)(`div`,{className:`px-4 py-2 border-t h-full overflow-y-auto h-[stretch]`,children:[(0,U.jsx)(`h3`,{className:`text-lg font-medium text-foreground`,children:`Documentation`}),(0,U.jsx)(dMt,{documentationSrc:e})]}),pMt={[I4]:(0,H.lazy)(()=>gn(()=>import(`./McpCapabilityFilterDesigner-CE9HGiq3.js`),__vite__mapDeps([7,1,8,2])))};function mMt(e){return e?pMt[e]:void 0}var hMt=(e=!1)=>async({queryKey:t})=>{let[n]=t;if(typeof n!=`string`)throw new he({type:`https://zup.fail/invalid-query-key`,title:`Invalid query key`});let r=new Request(n),i;try{i=await fetch(r)}catch(e){throw e instanceof TypeError?new he({type:`https://zup.fail/api-request-failed`,title:`API request failed`,status:500,instance:n}):e}if(!i.ok){let e=new He(`Error while making request. Please try again or contact support if the problem persists.`);throw await e.tryReadResponse(i),e}try{return await(e?i.clone().json():i.clone().text())}catch(e){let t=await i.clone().text();throw Zt.captureException(e,{message:`Failed to parse response of ${n} to JSON`,responseText:t,status:i.status,requestUrl:n}),e}};function W4(e,{json:t,...n}={}){return Oe({queryKey:[e.url],queryFn:hMt(t),...n})}var G4=(e={})=>W4(mt.cdnContent(`/portal/policies.v6.json`),{...e,json:!0}),gMt=(e,t={})=>W4({url:e??``},{...t,enabled:!!e&&t.enabled!==!1,json:!0});function _Mt(e){let t=e?.properties?.handler?.properties?.options;if(!(!t||t.type!==`object`||!t.properties||Object.keys(t.properties).length===0))return t}function vMt(e){if(e.oneOf||e.anyOf||e.allOf||e.const)return`json`;if(e.enum)return e.enum.every(e=>typeof e==`string`)?`select`:`json`;if(typeof e.type!=`string`)return`json`;switch(e.type){case`boolean`:return`boolean`;case`number`:case`integer`:return`number`;case`string`:return`text`;case`array`:{let t=e.items;if(t&&!Array.isArray(t)){if(t.type===`string`&&!t.oneOf&&!t.anyOf&&!t.allOf)return`string-array`;if(t.type===`object`&&t.properties&&Object.keys(t.properties).length>0)return`object-array`}return`json`}case`object`:{if(e.properties&&Object.keys(e.properties).length>0)return`object`;let t=e.additionalProperties;return t&&typeof t==`object`&&(t.type===`string`||t.type===`number`||t.type===`integer`)?`record`:`json`}default:return`json`}}function K4(e,t){return e.required?.includes(t)??!1}function yMt(e){return e[`x-advanced`]===!0||e[`x-show-example`]===!1}var bMt=()=>{let e=(0,H.useContext)(ap);return!!(e?.account&&e?.project)},xMt=({children:e,onInject:t,isEnabled:n=!0})=>{let r=bMt();return!n||!r?(0,U.jsx)(`div`,{className:`relative w-full`,children:e}):(0,U.jsx)(SMt,{onInject:t,children:e})},SMt=({children:e,onInject:t})=>{let n=op(),r=hR(n.account.name,n.project.name);return(0,U.jsxs)(Ib,{children:[(0,U.jsxs)(`div`,{className:`relative w-full`,children:[e,(0,U.jsx)(Lb,{asChild:!0,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`flex-none ml-1 absolute top-1 right-1 bg-card`,title:`Select environment variable`,children:(0,U.jsx)(Cee,{className:`w-4`})})})]}),(0,U.jsxs)(zb,{children:[(0,U.jsxs)(Bb,{children:[(0,U.jsx)(Hb,{children:`Environment Variables`}),(0,U.jsx)(Ub,{asChild:!0,children:(0,U.jsxs)(kO,{className:`mt-4 divide-y divide-double bg-gray-50 dark:bg-neutral-900 max-h-96 overflow-y-auto`,children:[r.isPending?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(FO,{className:`h-6 w-2/3 m-1`}),(0,U.jsx)(FO,{className:`h-6 w-2/3 m-1`}),(0,U.jsx)(FO,{className:`h-6 w-2/3 m-1`})]}):r.data?.length===0&&(0,U.jsx)(`div`,{className:`p-2`,children:`No environment variables`}),r.data?.map(e=>(0,U.jsxs)(`div`,{className:`p-2 py-3 flex justify-between items-center`,children:[(0,U.jsx)(`div`,{children:e.name}),(0,U.jsx)(Rb,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,size:`xs`,className:`flex-none`,onClick:()=>t(e,`$env(${e.name})`),children:`Use`})})]},e.id))]})})]}),(0,U.jsx)(Vb,{children:(0,U.jsx)(Rb,{children:(0,U.jsx)(X,{type:`submit`,variant:`outline`,children:`Close`})})})]})]})},CMt=(0,H.createContext)(!0),q4=({schema:e,value:t,onChange:n,disabled:r,allowEnvVariables:i=!0})=>{let a=(e,r)=>{if(r===void 0){let{[e]:r,...i}=t;n(i)}else n({...t,[e]:r})},o=(n,i)=>(0,U.jsx)(TMt,{name:n,schema:i,required:K4(e,n),value:t[n],onChange:e=>a(n,e),disabled:r},n),s=Object.entries(e.properties??{}),c=(t,n)=>yMt(n)&&!K4(e,t),l=s.filter(([e,t])=>c(e,t)),u=s.filter(([e,t])=>!c(e,t)),d=[...u.filter(([t])=>K4(e,t)),...u.filter(([t])=>!K4(e,t))];return(0,U.jsx)(CMt.Provider,{value:i,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[d.map(([e,t])=>o(e,t)),l.length>0&&(0,U.jsx)(wMt,{defaultOpen:l.some(([e])=>t[e]!==void 0),children:l.map(([e,t])=>o(e,t))})]})})},wMt=({defaultOpen:e,children:t})=>{let[n,r]=(0,H.useState)(e);return(0,U.jsxs)(Fw,{open:n,onOpenChange:r,children:[(0,U.jsxs)(Iw,{className:`flex items-center gap-1 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground`,children:[(0,U.jsx)(rd,{className:W(`size-4 transition-transform`,n&&`rotate-90`)}),n?`Hide advanced options`:`Show advanced options`]}),(0,U.jsx)(Lw,{className:`flex flex-col gap-5 pt-5`,children:t})]})},TMt=({name:e,schema:t,required:n,value:r,onChange:i,disabled:a})=>{let o=(0,H.useId)(),s=vMt(t);return s===`boolean`?(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsx)(EMt,{htmlFor:o,name:e,schema:t,required:n}),(0,U.jsx)(T1,{id:o,checked:r===!0,onCheckedChange:e=>i(e),disabled:a})]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(EMt,{htmlFor:o,name:e,schema:t,required:n}),(0,U.jsx)(DMt,{id:o,kind:s,schema:t,required:n,value:r,onChange:i,disabled:a})]})},EMt=({htmlFor:e,name:t,schema:n,required:r})=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,U.jsxs)(GY,{htmlFor:e,className:`capitalize`,children:[t,r?(0,U.jsx)(`span`,{className:`text-destructive`,children:` *`}):(0,U.jsx)(`span`,{className:`ml-1 font-normal normal-case text-muted-foreground`,children:`(optional)`})]}),n.description&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.description})]}),DMt=({id:e,kind:t,schema:n,required:r,value:i,onChange:a,disabled:o})=>{switch(t){case`text`:return(0,U.jsx)(J4,{id:e,value:typeof i==`string`?i:``,placeholder:typeof n.default==`string`?n.default:void 0,onValueChange:e=>a(e===``?void 0:e),disabled:o});case`number`:return(0,U.jsx)(XP,{id:e,type:`number`,step:n.type===`integer`?1:void 0,value:typeof i==`number`?i:``,placeholder:typeof n.default==`number`?String(n.default):void 0,onChange:e=>{let t=e.target.value===``?NaN:Number(e.target.value);a(Number.isNaN(t)?void 0:t)},disabled:o});case`select`:return(0,U.jsxs)(vY,{value:typeof i==`string`?i:Ert,onValueChange:e=>a(e===`__UNSET`?void 0:e),disabled:o,children:[(0,U.jsx)(bY,{id:e,className:`w-full`,children:(0,U.jsx)(yY,{placeholder:`Select an option`})}),(0,U.jsxs)(xY,{children:[!r&&(0,U.jsx)(SY,{value:`__UNSET`,children:(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`Not set`})}),(n.enum??[]).filter(e=>typeof e==`string`).map(e=>(0,U.jsx)(SY,{value:e,children:e},e))]})]});case`string-array`:return(0,U.jsx)(OMt,{value:i,onChange:a,disabled:o});case`object-array`:return(0,U.jsx)(kMt,{schema:n,value:i,onChange:a,disabled:o});case`record`:return(0,U.jsx)(AMt,{schema:n,value:i,onChange:a,disabled:o});case`object`:return(0,U.jsx)(`div`,{className:`border rounded-md p-3 ml-1`,children:(0,U.jsx)(q4,{schema:n,value:Y4(i)?i:{},onChange:e=>a(Object.keys(e).length===0?void 0:e),disabled:o})});case`json`:return(0,U.jsx)(jMt,{id:e,value:i,onChange:a,disabled:o})}},J4=({id:e,value:t,placeholder:n,onValueChange:r,disabled:i})=>{let a=(0,H.useContext)(CMt),o=bMt(),s=a&&o&&!i;return(0,U.jsx)(xMt,{isEnabled:s,onInject:(e,t)=>r(t),children:(0,U.jsx)(XP,{id:e,value:t,placeholder:n,onChange:e=>r(e.target.value),disabled:i,className:W(s&&`pr-10`)})})},OMt=({value:e,onChange:t,disabled:n})=>{let r=Array.isArray(e)?e.map(e=>typeof e==`string`?e:String(e)):[],i=e=>{t(e.length===0?void 0:e)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(J4,{value:e,onValueChange:e=>{let n=[...r];n[t]=e,i(n)},disabled:n}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove item`,onClick:()=>i(r.filter((e,n)=>n!==t)),disabled:n,children:(0,U.jsx)(Kf,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>i([...r,``]),disabled:n,children:[(0,U.jsx)(hf,{className:`size-4`}),`Add item`]})]})},kMt=({schema:e,value:t,onChange:n,disabled:r})=>{let i=Array.isArray(e.items)?void 0:e.items,a=Array.isArray(t)?t:[],o=e=>{n(e.length===0?void 0:e)};return i?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a.map((e,t)=>(0,U.jsxs)(`div`,{className:`relative border rounded-md p-3 pr-10`,children:[(0,U.jsx)(q4,{schema:i,value:Y4(e)?e:{},onChange:e=>{let n=[...a];n[t]=e,o(n)},disabled:r}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove item`,className:`absolute top-2 right-2`,onClick:()=>o(a.filter((e,n)=>n!==t)),disabled:r,children:(0,U.jsx)(Kf,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>o([...a,{}]),disabled:r,children:[(0,U.jsx)(hf,{className:`size-4`}),`Add item`]})]}):null},AMt=({schema:e,value:t,onChange:n,disabled:r})=>{let i=typeof e.additionalProperties==`object`?e.additionalProperties.type:`string`,a=i===`number`||i===`integer`,[o,s]=(0,H.useState)(()=>Y4(t)?Object.entries(t).map(([e,t])=>({key:e,value:String(t)})):[]),c=e=>{s(e);let t={};for(let n of e)if(n.key!==``)if(a){if(n.value.trim()===``)continue;let e=Number(n.value);if(Number.isNaN(e))continue;t[n.key]=e}else t[n.key]=n.value;n(Object.keys(t).length===0?void 0:t)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(XP,{value:e.key,placeholder:`Key`,onChange:n=>{let r=[...o];r[t]={...e,key:n.target.value},c(r)},disabled:r}),a?(0,U.jsx)(XP,{value:e.value,placeholder:`Value`,type:`number`,onChange:n=>{let r=[...o];r[t]={...e,value:n.target.value},c(r)},disabled:r}):(0,U.jsx)(J4,{value:e.value,placeholder:`Value`,onValueChange:n=>{let r=[...o];r[t]={...e,value:n},c(r)},disabled:r}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove entry`,onClick:()=>c(o.filter((e,n)=>n!==t)),disabled:r,children:(0,U.jsx)(Kf,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>c([...o,{key:``,value:``}]),disabled:r,children:[(0,U.jsx)(hf,{className:`size-4`}),`Add entry`]})]})},jMt=({id:e,value:t,onChange:n,disabled:r})=>{let[i,a]=(0,H.useState)(()=>t===void 0?``:JSON.stringify(t,void 0,2)),[o,s]=(0,H.useState)(!1);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(AC,{id:e,className:W(`font-mono text-xs`,o&&`border-destructive`),value:i,placeholder:`JSON value`,onChange:e=>{let t=e.target.value;if(a(t),t.trim()===``){s(!1),n(void 0);return}try{n(JSON.parse(t)),s(!1)}catch{s(!0)}},disabled:r}),o&&(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`Invalid JSON — the last valid value will be saved.`})]})};function Y4(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var MMt=({designConfig:e,policyType:t,defaultHandler:n,isReadOnly:r,hasError:i,codeTabLabel:a,documentationSrc:o,designerContext:s,alwaysShowForm:c=!1,ref:l})=>{let{logEvent:u}=on(),{variant:d,isResolved:f}=Hy(`policy-form-editor`),p=c||d===`test`,m=gMt(p?e?.optionsSchemaUrl:void 0),h=p?_Mt(m.data):void 0,g=!!h,_=!!o,v=mMt(t),y=!!v,[b,x]=(0,H.useState)(n),[S,C]=(0,H.useState)(),[w,T]=(0,H.useState)(null),E=(0,H.useRef)(void 0),D=S??(y?`designer`:g?`form`:`code`),O=()=>{let e=E.current?.getValue();if(!e)throw Error(`The policy configuration is empty`);return JSON.parse(e)};(0,H.useImperativeHandle)(l,()=>({getHandler:()=>D===`code`?O():b}));let k=t=>{if(t!==D){if(D===`code`)try{x(O())}catch(e){T(`Fix the JSON before switching: ${e instanceof Error?e.message:`Unknown error`}`);return}t===`code`&&E.current?.setValue(JSON.stringify(b,void 0,2)),T(null),C(t),u(`policy-form-editor-mode-switched`,{policy:e?.id,mode:t})}};if(!f&&!c||m.isLoading)return(0,U.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,U.jsx)(QP,{className:`w-5 h-5 border-2`})});let A=y||g;return(0,U.jsxs)(`div`,{className:`flex flex-col min-h-0 min-w-0 h-full`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 border-b p-2`,children:(0,U.jsx)(H4,{variant:`outline`,type:`single`,value:D,onValueChange:e=>{e&&k(e)},children:[...y?[{value:`designer`,label:`Designer`}]:[],...g?[{value:`form`,label:`Form`}]:[],{value:`code`,label:A?`Code`:a},..._?[{value:`docs`,label:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Uu,{}),`Docs`]})}]:[]].map(({value:e,label:t})=>(0,U.jsx)(U4,{value:e,variant:`outline`,size:`xs`,className:`gap-1 px-2`,children:t},e))})}),w&&(0,U.jsx)(`p`,{className:`text-sm text-red-500 mx-3 mt-2`,children:w}),v&&(0,U.jsx)(`div`,{className:W(`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,D!==`designer`&&`hidden`),children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,U.jsx)(QP,{className:`w-5 h-5 border-2`})}),children:(0,U.jsx)(v,{options:b.options,onChange:e=>x({...b,options:e}),isReadOnly:r,operation:s?.operation,policyManager:s?.policyManager})})}),g&&D===`form`&&h&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,U.jsx)(q4,{schema:h,value:NMt(b.options)?b.options:{},onChange:e=>x({...b,options:e}),disabled:r})}),(0,U.jsx)(`div`,{className:W(`flex-1 min-h-0 min-w-0`,D!==`code`&&`hidden`),children:(0,U.jsx)(dF,{options:{...QZ,readOnly:r,automaticLayout:!0},className:W({"border border-red-500":i}),width:`100%`,height:`100%`,language:`json`,onMount:e=>{E.current=e},defaultValue:JSON.stringify(b,void 0,2)})}),_&&D===`docs`&&o&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,U.jsx)(dMt,{documentationSrc:o})})]})};function NMt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var X4=({designConfig:e,policyType:t,defaultHandler:n,initialName:r,policies:i,isReadOnly:a=!1,nameDisabled:o=!1,codeTabLabel:s=`Configuration`,alwaysShowForm:c=!1,designerContext:l,ref:u})=>{let[d,f]=(0,H.useState)(r),[p,m]=(0,H.useState)(null),h=(0,H.useRef)(null);return(0,H.useImperativeHandle)(u,()=>({getPolicyConfig:()=>{let e=hbt(d,i);if(e)throw m(e),Error(e);if(!h.current)throw Error(`The policy editor is not ready`);try{let e=h.current.getHandler();return m(null),{name:d,handler:e}}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw m(t),Error(t)}}})),(0,U.jsxs)(`div`,{className:`flex flex-col w-full h-full min-h-0`,children:[(0,U.jsx)(R4,{name:d,onChangeName:f,disabled:o,policies:i}),(0,U.jsx)(`div`,{className:`border rounded overflow-hidden mt-4 flex-1 min-h-0 min-w-0`,children:(0,U.jsx)(MMt,{ref:h,designConfig:e,policyType:t,defaultHandler:n,isReadOnly:a,hasError:!!p,codeTabLabel:s,documentationSrc:e?.exampleHtml,alwaysShowForm:c,designerContext:l})}),p&&(0,U.jsx)(`p`,{className:`text-red-500 ml-2 mt-1`,children:p})]})},PMt=`Invalid Rewrite URL provided`,FMt=`Tip: Use the API Test Console to test the behavior of request properties and environment variables.`,IMt=e=>`${e} is not a valid pattern`,LMt=e=>`Failed to parse component(s), rewrite result: ${e}`,RMt=e=>`${e} is not a valid URL`,Z4=new Proxy({},{get(e,t){return typeof t==`symbol`?()=>`superProxy.toString()`:Z4}}),zMt=e=>{if(e===``)return{errorType:`Error`,message:PMt};let t={url:new URL(`https://www.zuplo.com`),host:``,hostname:``,origin:``,port:``,protocol:``,headers:new Headers({}),params:{},pathname:``,method:``,query:{},search:``,env:Z4,request:Z4,e:encodeURIComponent,context:Z4},n=(e,t={})=>Function(`vars`,[`const tagged = ( ${Object.keys(t).join(`, `)} ) =>`,`\`${e}\``,`return tagged(...Object.values(vars))`].join(`
|
|
485
|
+
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}cjt.displayName=`MiniMap`,(0,H.memo)(cjt);var ljt=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,ujt={[J2.Line]:`right`,[J2.Handle]:`bottom-right`};function djt({nodeId:e,position:t,variant:n=J2.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=rkt(),y=typeof e==`string`?e:v,b=t4(),x=(0,H.useRef)(null),S=n===J2.Handle,C=e4((0,H.useCallback)(ljt(S&&p),[S,p]),Q2),w=(0,H.useRef)(null),T=t??ujt[n];return(0,H.useEffect)(()=>{if(!(!x.current||!y))return w.current||=HDt({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=V2([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...SEt({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,U.jsx)(`div`,{className:J1([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,H.memo)(djt);function y4({value:e,onValueChange:t,options:n,columns:r=2,layout:i=`cards`,idPrefix:a=`wizard-choice`,ariaLabel:o,className:s}){return(0,U.jsx)(Rxt,{value:e,onValueChange:e=>t(e),"aria-label":o,className:W(i===`list`?`flex flex-col gap-2`:[`grid gap-3`,r===1&&`grid-cols-1`,r===2&&`grid-cols-2`,r===3&&`grid-cols-3`],s),children:n.map(t=>{let n=`${a}-${t.value}`,r=e===t.value,o=W(`rounded-md border transition-colors`,t.disabled?`cursor-not-allowed opacity-60`:`cursor-pointer`,r?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`bg-card hover:bg-neutral-50 dark:hover:bg-neutral-800/60`);return i===`list`?(0,U.jsxs)(GY,{htmlFor:n,className:W(`flex items-center gap-3 px-3 py-2.5`,o),children:[(0,U.jsx)(q1,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium sm:w-56 sm:shrink-0`,children:t.title}),t.description&&(0,U.jsx)(`div`,{className:`min-w-0 flex-1 text-xs leading-snug text-muted-foreground`,children:t.description})]})]},t.value):(0,U.jsxs)(GY,{htmlFor:n,className:W(`flex flex-col gap-1.5 p-3`,o),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(q1,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:t.title})]}),t.description&&(0,U.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t.description})]},t.value)})})}var b4=({tiles:e,selectedId:t,onSelect:n,fallbackIcon:r,columns:i=4,emptyState:a,className:o})=>{let[s,c]=(0,H.useState)(()=>new Set);return(0,U.jsxs)(`div`,{className:W(`grid auto-rows-min gap-2 p-0.5`,i===4?`grid-cols-4`:`grid-cols-3`,o),children:[e.map(e=>{let i=t===e.id,a=s.has(e.id)||!e.iconUrl;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-pressed":i,className:W(`flex flex-col items-center justify-center gap-1.5 rounded-md border bg-card p-2 text-center transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-800/60`,i?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`border-border`),children:[a?r:(0,U.jsx)(`img`,{src:e.iconUrl,alt:``,className:`size-7 object-contain brightness-0 dark:invert`,onError:()=>c(t=>new Set(t).add(e.id))}),(0,U.jsx)(`span`,{className:`w-full truncate text-xs leading-tight`,children:e.name})]},e.id)}),e.length===0&&a&&(0,U.jsx)(`div`,{className:`col-span-full py-6 text-center text-sm text-muted-foreground`,children:a})]})},fjt=`#ff00bd`,pjt=`#98036a`,mjt=`#fff0fc`,hjt=`#9ca3af`,gjt=`#6b7280`,_jt=`#f7f9fb`,x4=152,S4=60,vjt={client:Ku,gateway:Wf,origin:wf},yjt=`!h-0 !min-h-0 !w-0 !min-w-0 !border-0 !bg-transparent`,bjt={box:({data:e})=>{let{label:t,kind:n,emphasis:r}=e,i=vjt[n];return(0,U.jsxs)(`div`,{className:W(`flex flex-col items-center justify-center gap-1.5 rounded-lg border bg-card px-2 text-center shadow-xs`,r?`border-zuplo-600`:`border-neutral-300 dark:border-neutral-600`),style:{width:x4,height:S4},children:[(0,U.jsx)(p4,{type:`target`,position:s2.Left,isConnectable:!1,className:yjt}),(0,U.jsx)(i,{"aria-hidden":`true`,strokeWidth:1.75,className:W(`size-[18px] shrink-0`,r?`text-zuplo-600`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:`text-xs font-medium leading-tight text-muted-foreground`,children:t}),(0,U.jsx)(p4,{type:`source`,position:s2.Right,isConnectable:!1,className:yjt})]})}},C4=[{id:`client`,type:`box`,position:{x:0,y:0},width:x4,height:S4,initialWidth:x4,initialHeight:S4,data:{label:`MCP Client`,kind:`client`,emphasis:!1},draggable:!1,selectable:!1},{id:`gateway`,type:`box`,position:{x:270,y:0},width:x4,height:S4,initialWidth:x4,initialHeight:S4,data:{label:`Zuplo MCP Gateway`,kind:`gateway`,emphasis:!0},draggable:!1,selectable:!1},{id:`origin`,type:`box`,position:{x:540,y:0},width:x4,height:S4,initialWidth:x4,initialHeight:S4,data:{label:`Origin MCP Server`,kind:`origin`,emphasis:!1},draggable:!1,selectable:!1}],xjt=e=>{let t=(e,t,n,r,i)=>({id:e,source:t,target:n,type:`smoothstep`,label:r,animated:!1,style:{stroke:i?fjt:hjt,strokeWidth:i?2:1.5},labelStyle:{fill:i?pjt:gjt,fontWeight:i?600:500,fontSize:11},labelBgStyle:{fill:i?mjt:_jt,fillOpacity:.95},labelBgPadding:[6,3],labelBgBorderRadius:4,markerEnd:{type:o2.ArrowClosed,width:14,height:14,color:i?fjt:hjt}});return[t(`inbound`,`client`,`gateway`,`Inbound auth`,e===`inbound`),t(`outbound`,`gateway`,`origin`,`Outbound auth`,e===`outbound`)]},w4={minX:Math.min(...C4.map(e=>e.position.x)),minY:Math.min(...C4.map(e=>e.position.y)),maxX:Math.max(...C4.map(e=>e.position.x+(e.width??x4))),maxY:Math.max(...C4.map(e=>e.position.y+(e.height??S4)))},Sjt=w4.maxX-w4.minX,Cjt=w4.maxY-w4.minY,wjt=.5,Tjt=1.2,Ejt=.12;function Djt(e,t){let n=Math.min(e/Sjt,t/Cjt),r=Math.min(Tjt,Math.max(wjt,n*(1-Ejt*2)));return{x:(e-Sjt*r)/2-w4.minX*r,y:(t-Cjt*r)/2-w4.minY*r,zoom:r}}var Ojt=({active:e})=>{let t=(0,H.useMemo)(()=>xjt(e),[e]),n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useCallback)(()=>{let e=n.current,t=e?.clientWidth??0,i=e?.clientHeight??0;t>0&&i>0&&r.current?.setViewport(Djt(t,i))},[]),a=(0,H.useCallback)(e=>{r.current=e,i()},[i]);return(0,H.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=requestAnimationFrame(i)});return r.observe(e),()=>{cancelAnimationFrame(t),r.disconnect()}},[i]),(0,U.jsx)(`div`,{ref:n,role:`img`,"aria-label":`MCP request flow, configuring ${e} authentication`,className:`h-36 w-full overflow-hidden rounded-md border border-border`,children:(0,U.jsx)(IAt,{nodes:C4,edges:t,nodeTypes:bjt,onInit:a,minZoom:wjt,maxZoom:Tjt,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,edgesFocusable:!1,nodesFocusable:!1,panOnDrag:!1,panOnScroll:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0},style:{backgroundColor:_jt},children:(0,U.jsx)(HAt,{variant:g4.Dots,gap:16,size:1,color:`#dbe1e8`})})})};function T4(e){return e&&e.length>0?e:void 0}function E4(e){return e&&Object.keys(e).length>0?e:void 0}function kjt(e){let t=new Set;for(let n of e??[]){let e=n.trim();e&&t.add(e)}return[...t]}function D4(e,t){if(t!==`rolesAndGroups`)return{};if(e.public===!0)return{public:!0};let n=kjt(e.roles),r=kjt(e.groups);return{...n.length>0?{roles:n}:{},...r.length>0?{groups:r}:{}}}function Ajt(e){let t=e&&typeof e==`object`?e:{};return{accessControlMode:t.accessControl?.mode===`rolesAndGroups`?`rolesAndGroups`:`allPublic`,catalog:{tools:O4(t.tools,`name`,e=>({name:e})),prompts:O4(t.prompts,`name`,e=>({name:e})),resources:O4(t.resources,`uri`,e=>({uri:e,name:e})),resourceTemplates:O4(t.resourceTemplates,`uriTemplate`,e=>({uriTemplate:e,name:e}))}}}function O4(e,t,n){return Array.isArray(e)?e.flatMap(e=>{if(typeof e==`string`)return e.length>0?[n(e)]:[];if(!e||typeof e!=`object`)return[];let{public:r,...i}=e,a=i[t];if(typeof a!=`string`||a.length===0)return[];let o=i.name;return[{...i,...t!==`name`&&typeof o!=`string`?{name:a}:{},...r===!0?{public:!0}:{}}]}):[]}function k4(e){return jjt(e.catalog,e.accessControlMode)}function jjt(e,t=`allPublic`){return{...t===`rolesAndGroups`?{accessControl:{mode:t}}:{},tools:e.tools.flatMap(e=>{let n=T4(e.name);if(!n)return[];let r=T4(e.description),i=E4(e.annotations),a=E4(e._meta);return[{name:n,...r?{description:r}:{},...i?{annotations:i}:{},...a?{_meta:a}:{},...D4(e,t)}]}),prompts:e.prompts.flatMap(e=>{let n=T4(e.name);if(!n)return[];let r=T4(e.description),i=E4(e._meta);return[{name:n,...r?{description:r}:{},...i?{_meta:i}:{},...D4(e,t)}]}),resources:e.resources.flatMap(e=>{let n=T4(e.uri);if(!n)return[];let r=T4(e.name),i=T4(e.description),a=T4(e.mimeType),o=E4(e._meta);return[{uri:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...D4(e,t)}]}),resourceTemplates:e.resourceTemplates.flatMap(e=>{let n=T4(e.uriTemplate);if(!n)return[];let r=T4(e.name),i=T4(e.description),a=T4(e.mimeType),o=E4(e._meta);return[{uriTemplate:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...D4(e,t)}]})}}var A4=e=>`/mcp-idp-icons/${e}.svg`,j4=[{id:`auth0`,label:`Auth0`,description:`Auth0 by Okta`,iconUrl:A4(`auth0`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-auth0-oauth-inbound`,policyExport:`McpAuth0OAuthInboundPolicy`,suggestedPolicyName:`mcp-auth0-inbound`,fields:[{key:`auth0Domain`,label:`Auth0 Domain`,defaultValue:`$env(MCP_AUTH0_DOMAIN)`,helpText:`Auth0 tenant domain, for example acme.us.auth0.com.`,required:!0},{key:`audience`,label:`Audience`,defaultValue:``,helpText:`Optional Auth0 API audience.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(MCP_AUTH0_CLIENT_ID)`,helpText:`Use an environment variable for deployable configs.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(MCP_AUTH0_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`workos`,label:`WorkOS`,description:`WorkOS User Management`,iconUrl:A4(`workos`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-workos-oauth-inbound`,policyExport:`McpWorkosOAuthInboundPolicy`,suggestedPolicyName:`mcp-workos-inbound`,fields:[{key:`clientId`,label:`Client ID`,defaultValue:`$env(WORKOS_CLIENT_ID)`,helpText:`WorkOS User Management client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(WORKOS_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`google`,label:`Google`,description:`Google OAuth`,iconUrl:A4(`google`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-google-oauth-inbound`,policyExport:`McpGoogleOAuthInboundPolicy`,suggestedPolicyName:`mcp-google-inbound`,fields:[{key:`clientId`,label:`Client ID`,defaultValue:`$env(GOOGLE_CLIENT_ID)`,helpText:`Google OAuth client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(GOOGLE_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`okta`,label:`Okta`,description:`Okta OIDC`,iconUrl:A4(`okta`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-okta-oauth-inbound`,policyExport:`McpOktaOAuthInboundPolicy`,suggestedPolicyName:`mcp-okta-inbound`,fields:[{key:`oktaDomain`,label:`Okta Domain`,defaultValue:`$env(OKTA_DOMAIN)`,helpText:`Okta org domain, for example acme.okta.com.`,required:!0},{key:`authorizationServerId`,label:`Authorization Server ID`,defaultValue:``,helpText:`Optional. Use default for Okta's default custom authorization server.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(OKTA_CLIENT_ID)`,helpText:`Okta OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(OKTA_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`entra`,label:`Microsoft Entra`,description:`Microsoft Entra ID`,iconUrl:A4(`entra`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-entra-oauth-inbound`,policyExport:`McpEntraOAuthInboundPolicy`,suggestedPolicyName:`mcp-entra-inbound`,fields:[{key:`tenantId`,label:`Tenant ID`,defaultValue:`$env(ENTRA_TENANT_ID)`,helpText:`Microsoft Entra tenant UUID.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(ENTRA_CLIENT_ID)`,helpText:`Microsoft Entra application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(ENTRA_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`cognito`,label:`Cognito`,description:`Amazon Cognito`,iconUrl:A4(`cognito`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-cognito-oauth-inbound`,policyExport:`McpCognitoOAuthInboundPolicy`,suggestedPolicyName:`mcp-cognito-inbound`,fields:[{key:`awsRegion`,label:`AWS Region`,defaultValue:`$env(COGNITO_AWS_REGION)`,helpText:`AWS region containing the Cognito user pool.`,required:!0},{key:`userPoolId`,label:`User Pool ID`,defaultValue:`$env(COGNITO_USER_POOL_ID)`,helpText:`Cognito user pool ID, for example us-east-1_AbCdEf123.`,required:!0},{key:`userPoolDomain`,label:`User Pool Domain`,defaultValue:`$env(COGNITO_USER_POOL_DOMAIN)`,helpText:`Hosted UI domain without https:// or a path.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(COGNITO_CLIENT_ID)`,helpText:`Cognito app client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(COGNITO_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`clerk`,label:`Clerk`,description:`Clerk OAuth`,iconUrl:A4(`clerk`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-clerk-oauth-inbound`,policyExport:`McpClerkOAuthInboundPolicy`,suggestedPolicyName:`mcp-clerk-inbound`,fields:[{key:`frontendApiUrl`,label:`Frontend API URL`,defaultValue:`$env(CLERK_FRONTEND_API_URL)`,helpText:`Clerk Frontend API URL origin, without a path.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(CLERK_CLIENT_ID)`,helpText:`Clerk OAuth application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(CLERK_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`keycloak`,label:`Keycloak`,description:`Keycloak OIDC`,iconUrl:A4(`keycloak`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-keycloak-oauth-inbound`,policyExport:`McpKeycloakOAuthInboundPolicy`,suggestedPolicyName:`mcp-keycloak-inbound`,fields:[{key:`keycloakBaseUrl`,label:`Keycloak Base URL`,defaultValue:`$env(KEYCLOAK_BASE_URL)`,helpText:`Server root URL, without /realms/{realm}.`,required:!0},{key:`realm`,label:`Realm`,defaultValue:`$env(KEYCLOAK_REALM)`,helpText:`Keycloak realm name.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(KEYCLOAK_CLIENT_ID)`,helpText:`Keycloak OIDC client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(KEYCLOAK_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`logto`,label:`Logto`,description:`Logto OIDC`,iconUrl:A4(`logto`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-logto-oauth-inbound`,policyExport:`McpLogtoOAuthInboundPolicy`,suggestedPolicyName:`mcp-logto-inbound`,fields:[{key:`logtoEndpoint`,label:`Logto Endpoint`,defaultValue:`$env(LOGTO_ENDPOINT)`,helpText:`Logto tenant endpoint or custom domain, without /oidc.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(LOGTO_CLIENT_ID)`,helpText:`Logto application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(LOGTO_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`onelogin`,label:`OneLogin`,description:`OneLogin OIDC`,iconUrl:A4(`onelogin`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-onelogin-oauth-inbound`,policyExport:`McpOneLoginOAuthInboundPolicy`,suggestedPolicyName:`mcp-onelogin-inbound`,fields:[{key:`oneLoginSubdomain`,label:`OneLogin Subdomain`,defaultValue:`$env(ONELOGIN_SUBDOMAIN)`,helpText:`Account subdomain, without .onelogin.com.`,required:!0},{key:`clientId`,label:`Client ID`,defaultValue:`$env(ONELOGIN_CLIENT_ID)`,helpText:`OneLogin OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(ONELOGIN_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`ping`,label:`Ping`,description:`PingOne OIDC`,iconUrl:A4(`ping`),policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-ping-oauth-inbound`,policyExport:`McpPingOAuthInboundPolicy`,suggestedPolicyName:`mcp-ping-inbound`,fields:[{key:`environmentId`,label:`Environment ID`,defaultValue:`$env(PING_ENVIRONMENT_ID)`,helpText:`PingOne environment ID. Not used when custom domain is set.`,required:!1},{key:`region`,label:`Region`,defaultValue:`north-america`,helpText:`PingOne geography. Ignored when custom domain is set.`,required:!1},{key:`customDomain`,label:`Custom Domain`,defaultValue:``,helpText:`Optional PingOne custom domain without https://.`,required:!1},{key:`clientId`,label:`Client ID`,defaultValue:`$env(PING_CLIENT_ID)`,helpText:`PingOne OIDC application client ID.`,required:!0},{key:`clientSecret`,label:`Client Secret`,defaultValue:`$env(PING_CLIENT_SECRET)`,helpText:`Use an environment variable; do not commit secrets.`,required:!0}]},{id:`custom-oauth`,label:`Custom OAuth`,description:`Any OAuth 2.0 / OIDC identity provider`,iconUrl:`https://cdn.zuplo.com/portal/policy-icons/mcp-oauth-inbound.svg`,policyModule:`$import(@zuplo/runtime/mcp-gateway)`,policyType:`mcp-oauth-inbound`,policyExport:`McpOAuthInboundPolicy`,suggestedPolicyName:`mcp-oauth-inbound`,fields:[],defaultOptions:{oidc:{issuer:`https://my-tenant.us.auth0.com/`,jwksUrl:`https://my-tenant.us.auth0.com/.well-known/jwks.json`,audience:`https://gateway.example.com`},browserLogin:{url:`https://my-tenant.us.auth0.com/authorize`,tokenUrl:`https://my-tenant.us.auth0.com/oauth/token`,clientId:`$env(MCP_OAUTH_CLIENT_ID)`,clientSecret:`$env(MCP_OAUTH_CLIENT_SECRET)`,scope:`openid profile email`,pkce:`none`}}}];function M4(e){return j4.find(t=>t.id===e)}function Mjt(e){return Object.fromEntries(e.fields.map(e=>[e.key,e.defaultValue]))}var Njt=`Most Used`,Pjt=`Other`,Fjt=[`rate-limit`,`api-key`],Ijt=[{name:`Rate Limiting & Quotas`,baseIds:[`rate-limit`,`complex-rate-limit`,`quota`]},{name:`Authentication`,baseIds:[`api-key`,`basic-auth`,`mtls-auth`,`ldap-auth`,`open-id-jwt-auth`,`okta-jwt-auth`,`auth0-jwt-auth`,`clerk-jwt-auth`,`cognito-jwt-auth`,`firebase-jwt`,`supabase-jwt-auth`,`propel-auth-jwt`,`curity-phantom-token`,`stripe-webhook-verification`,`web-bot-auth`]},{name:`Authorization`,baseIds:[`jwt-scopes`,`openfga-authz`,`okta-fga-authz`,`axiomatics-authz`,`authzen`,`geo-filter`,`require-origin`]},{name:`MCP Authentication`,baseIds:[`mcp-oauth`,`mcp-auth0-oauth`,`mcp-clerk-oauth`,`mcp-cognito-oauth`,`mcp-entra-oauth`,`mcp-google-oauth`,`mcp-keycloak-oauth`,`mcp-logto-oauth`,`mcp-okta-oauth`,`mcp-onelogin-oauth`,`mcp-ping-oauth`,`mcp-workos-oauth`,`mcp-token-exchange`,`mcp-capability-filter`]},{name:`AI Gateway`,baseIds:[`ai-gateway-model-filtering-v2`,`ai-gateway-fallback-model-v2`,`ai-gateway-metering-v2`,`ai-gateway-semantic-cache-v2`,`ai-gateway-dlp`,`akamai-ai-firewall-v2`,`comet-opik-tracing-v2`,`galileo-tracing-v2`]},{name:`AI & Security`,baseIds:[`prompt-injection`,`bot-detection`,`akamai-firewall-for-ai`,`secret-masking`]},{name:`Caching`,baseIds:[`caching`,`semantic-cache`]},{name:`Transformations`,baseIds:[`xml-to-json`,`formdata-to-json`,`set-body`,`set-headers`,`set-query-params`,`set-status`,`remove-headers`,`remove-query-params`,`clear-headers`,`query-param-to-header`,`replace-string`,`change-method`]},{name:`Validation`,baseIds:[`validate-json-schema`,`request-validation`,`request-size-limit`]},{name:`Traffic Management`,baseIds:[`traffic-splitting`,`brownout`,`sleep`,`mock-api`,`http-deprecation`]},{name:`GraphQL`,baseIds:[`graphql-complexity-limit`,`graphql-disable-introspection`,`graphql-introspection-filter`]},{name:`Monetization & Metering`,baseIds:[`monetization`,`openmeter`,`amberflo-metering`,`moesif`,`readme-metrics`]},{name:`Logging & Tracing`,baseIds:[`audit-log`]},{name:`Upstream Auth`,baseIds:[`set-upstream-api-key`,`upstream-azure-ad-service-auth`,`upstream-firebase-admin-auth`,`upstream-firebase-user-auth`,`upstream-gcp-federated-auth`,`upstream-gcp-jwt`,`upstream-gcp-service-auth`,`upstream-zuplo-jwt-auth`]},{name:`Custom & Composite`,baseIds:[`custom-code`,`composite`]}],Ljt=/-(inbound|outbound|internal)$/,N4=e=>e.replace(Ljt,``),P4=new Map;for(let e of Ijt)for(let t of e.baseIds)P4.has(t)||P4.set(t,e.name);var Rjt=e=>P4.get(N4(e.id))??`Other`,zjt=e=>P4.get(N4(e))===`Authentication`,Bjt=e=>Fjt.includes(N4(e.id)),Vjt=e=>{let t=new Map,n=[];for(let r of e){Bjt(r)&&n.push(r);let e=Rjt(r),i=t.get(e);i?i.push(r):t.set(e,[r])}let r=[];n.length>0&&r.push({name:Njt,policies:n});for(let{name:e}of Ijt){let n=t.get(e);n&&n.length>0&&r.push({name:e,policies:n})}let i=t.get(Pjt);return i&&i.length>0&&r.push({name:Pjt,policies:i}),r},Hjt=[...j4.map(e=>e.policyType)];function Ujt(e){return Hjt.includes(e)||zjt(e)}var F4=`mcp-token-exchange-inbound`,I4=`mcp-capability-filter-inbound`,Wjt=`set-upstream-api-key-inbound`,Gjt=`remove-headers-inbound`;function L4(e){if(!e||typeof e!=`object`)return!1;let t=e.headers;if(!Array.isArray(t)||t.length!==1)return!1;let[n]=t;return typeof n==`string`&&n.toLowerCase()===`authorization`}var Kjt=e=>e.toLowerCase().replaceAll(` `,`-`),R4=({name:e,onChangeName:t,disabled:n,policies:r})=>{let[i,a]=(0,H.useState)(null);return(0,U.jsxs)(`div`,{className:`grid grid-cols-12 text-sm gap-2 items-center pt-1`,children:[(0,U.jsx)(`label`,{className:`col-span-1`,children:`Name`}),(0,U.jsx)(`div`,{className:`col-span-11`,children:(0,U.jsx)(XP,{type:`text`,id:`route-handler`,"data-test":`policy-picker-name-input`,name:`route-handler`,value:e??``,disabled:n,onChange:e=>{let n=e.currentTarget.value,i=Kjt(n.toLowerCase());a(hbt(i,r)),t(i)},"aria-describedby":`email-description`})}),i&&(0,U.jsx)(`div`,{className:`col-span-11 col-start-2 mt-1 text-red-600`,children:i})]})},qjt=`Toggle`,Jjt=H.forwardRef((e,t)=>{let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=Ct({prop:n,onChange:i,defaultProp:r??!1,caller:qjt});return(0,U.jsx)(sc.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:Qs(e.onClick,()=>{e.disabled||s(!o)})})});Jjt.displayName=qjt;var z4=`ToggleGroup`,[Yjt,Xjt]=T(z4,[Mq]),Zjt=Mq(),B4=H.forwardRef((e,t)=>{let{type:n,...r}=e;if(n===`single`)return(0,U.jsx)(eMt,{...r,ref:t});if(n===`multiple`)return(0,U.jsx)(tMt,{...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${z4}\``)});B4.displayName=z4;var[Qjt,$jt]=Yjt(z4),eMt=H.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=Ct({prop:n,defaultProp:r??``,onChange:i,caller:z4});return(0,U.jsx)(Qjt,{scope:e.__scopeToggleGroup,type:`single`,value:H.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:H.useCallback(()=>s(``),[s]),children:(0,U.jsx)(iMt,{...a,ref:t})})}),tMt=H.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=Ct({prop:n,defaultProp:r??[],onChange:i,caller:z4}),c=H.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=H.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,U.jsx)(Qjt,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,U.jsx)(iMt,{...a,ref:t})})});B4.displayName=z4;var[nMt,rMt]=Yjt(z4),iMt=H.forwardRef((e,t)=>{let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=Zjt(n),u=At(o),d={role:`group`,dir:u,...c};return(0,U.jsx)(nMt,{scope:n,rovingFocus:i,disabled:r,children:i?(0,U.jsx)(Nq,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,U.jsx)(sc.div,{...d,ref:t})}):(0,U.jsx)(sc.div,{...d,ref:t})})}),V4=`ToggleGroupItem`,aMt=H.forwardRef((e,t)=>{let n=$jt(V4,e.__scopeToggleGroup),r=rMt(V4,e.__scopeToggleGroup),i=Zjt(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=H.useRef(null);return r.rovingFocus?(0,U.jsx)(Pq,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,U.jsx)(oMt,{...s,ref:t})}):(0,U.jsx)(oMt,{...s,ref:t})});aMt.displayName=V4;var oMt=H.forwardRef((e,t)=>{let{__scopeToggleGroup:n,value:r,...i}=e,a=$jt(V4,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0};return(0,U.jsx)(Jjt,{...a.type===`single`?o:void 0,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})}),sMt=B4,cMt=aMt,lMt=Ou(`inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground`},size:{default:`h-9 px-2 min-w-9`,xs:`h-6 px-1.5 min-w-6 text-xs [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 px-1.5 min-w-8`,lg:`h-10 px-2.5 min-w-10`}},defaultVariants:{variant:`default`,size:`default`}}),uMt=H.createContext({size:`default`,variant:`default`,spacing:0});function H4({className:e,variant:t,size:n,spacing:r=0,children:i,...a}){return(0,U.jsx)(sMt,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,style:{"--gap":r},className:W(`group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs`,e),...a,children:(0,U.jsx)(uMt.Provider,{value:{variant:t,size:n,spacing:r},children:i})})}function U4({className:e,children:t,variant:n,size:r,...i}){let a=H.useContext(uMt);return(0,U.jsx)(cMt,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:W(lMt({variant:a.variant||n,size:a.size||r}),`w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10`,`data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l`,e),...i,children:t})}var dMt=({documentationSrc:e,className:t})=>(0,U.jsx)(`div`,{className:W(`prose prose-neutral prose-sm dark:prose-invert z-10 prose-headings:mt-2 prose-headings:text-sm max-w-full [&_li>div]:inline [&_li>div>p]:inline [&_code::before]:content-none [&_code::after]:content-none`,t),dangerouslySetInnerHTML:{__html:e}}),fMt=({documentationSrc:e})=>(0,U.jsxs)(`div`,{className:`px-4 py-2 border-t h-full overflow-y-auto h-[stretch]`,children:[(0,U.jsx)(`h3`,{className:`text-lg font-medium text-foreground`,children:`Documentation`}),(0,U.jsx)(dMt,{documentationSrc:e})]}),pMt={[I4]:(0,H.lazy)(()=>gn(()=>import(`./McpCapabilityFilterDesigner-CG8ZVkh4.js`),__vite__mapDeps([7,1,8,2])))};function mMt(e){return e?pMt[e]:void 0}var hMt=(e=!1)=>async({queryKey:t})=>{let[n]=t;if(typeof n!=`string`)throw new he({type:`https://zup.fail/invalid-query-key`,title:`Invalid query key`});let r=new Request(n),i;try{i=await fetch(r)}catch(e){throw e instanceof TypeError?new he({type:`https://zup.fail/api-request-failed`,title:`API request failed`,status:500,instance:n}):e}if(!i.ok){let e=new He(`Error while making request. Please try again or contact support if the problem persists.`);throw await e.tryReadResponse(i),e}try{return await(e?i.clone().json():i.clone().text())}catch(e){let t=await i.clone().text();throw Zt.captureException(e,{message:`Failed to parse response of ${n} to JSON`,responseText:t,status:i.status,requestUrl:n}),e}};function W4(e,{json:t,...n}={}){return Oe({queryKey:[e.url],queryFn:hMt(t),...n})}var G4=(e={})=>W4(mt.cdnContent(`/portal/policies.v6.json`),{...e,json:!0}),gMt=(e,t={})=>W4({url:e??``},{...t,enabled:!!e&&t.enabled!==!1,json:!0});function _Mt(e){let t=e?.properties?.handler?.properties?.options;if(!(!t||t.type!==`object`||!t.properties||Object.keys(t.properties).length===0))return t}function vMt(e){if(e.oneOf||e.anyOf||e.allOf||e.const)return`json`;if(e.enum)return e.enum.every(e=>typeof e==`string`)?`select`:`json`;if(typeof e.type!=`string`)return`json`;switch(e.type){case`boolean`:return`boolean`;case`number`:case`integer`:return`number`;case`string`:return`text`;case`array`:{let t=e.items;if(t&&!Array.isArray(t)){if(t.type===`string`&&!t.oneOf&&!t.anyOf&&!t.allOf)return`string-array`;if(t.type===`object`&&t.properties&&Object.keys(t.properties).length>0)return`object-array`}return`json`}case`object`:{if(e.properties&&Object.keys(e.properties).length>0)return`object`;let t=e.additionalProperties;return t&&typeof t==`object`&&(t.type===`string`||t.type===`number`||t.type===`integer`)?`record`:`json`}default:return`json`}}function K4(e,t){return e.required?.includes(t)??!1}function yMt(e){return e[`x-advanced`]===!0||e[`x-show-example`]===!1}var bMt=()=>{let e=(0,H.useContext)(ap);return!!(e?.account&&e?.project)},xMt=({children:e,onInject:t,isEnabled:n=!0})=>{let r=bMt();return!n||!r?(0,U.jsx)(`div`,{className:`relative w-full`,children:e}):(0,U.jsx)(SMt,{onInject:t,children:e})},SMt=({children:e,onInject:t})=>{let n=op(),r=hR(n.account.name,n.project.name);return(0,U.jsxs)(Ib,{children:[(0,U.jsxs)(`div`,{className:`relative w-full`,children:[e,(0,U.jsx)(Lb,{asChild:!0,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`flex-none ml-1 absolute top-1 right-1 bg-card`,title:`Select environment variable`,children:(0,U.jsx)(Cee,{className:`w-4`})})})]}),(0,U.jsxs)(zb,{children:[(0,U.jsxs)(Bb,{children:[(0,U.jsx)(Hb,{children:`Environment Variables`}),(0,U.jsx)(Ub,{asChild:!0,children:(0,U.jsxs)(kO,{className:`mt-4 divide-y divide-double bg-gray-50 dark:bg-neutral-900 max-h-96 overflow-y-auto`,children:[r.isPending?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(FO,{className:`h-6 w-2/3 m-1`}),(0,U.jsx)(FO,{className:`h-6 w-2/3 m-1`}),(0,U.jsx)(FO,{className:`h-6 w-2/3 m-1`})]}):r.data?.length===0&&(0,U.jsx)(`div`,{className:`p-2`,children:`No environment variables`}),r.data?.map(e=>(0,U.jsxs)(`div`,{className:`p-2 py-3 flex justify-between items-center`,children:[(0,U.jsx)(`div`,{children:e.name}),(0,U.jsx)(Rb,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,size:`xs`,className:`flex-none`,onClick:()=>t(e,`$env(${e.name})`),children:`Use`})})]},e.id))]})})]}),(0,U.jsx)(Vb,{children:(0,U.jsx)(Rb,{children:(0,U.jsx)(X,{type:`submit`,variant:`outline`,children:`Close`})})})]})]})},CMt=(0,H.createContext)(!0),q4=({schema:e,value:t,onChange:n,disabled:r,allowEnvVariables:i=!0})=>{let a=(e,r)=>{if(r===void 0){let{[e]:r,...i}=t;n(i)}else n({...t,[e]:r})},o=(n,i)=>(0,U.jsx)(TMt,{name:n,schema:i,required:K4(e,n),value:t[n],onChange:e=>a(n,e),disabled:r},n),s=Object.entries(e.properties??{}),c=(t,n)=>yMt(n)&&!K4(e,t),l=s.filter(([e,t])=>c(e,t)),u=s.filter(([e,t])=>!c(e,t)),d=[...u.filter(([t])=>K4(e,t)),...u.filter(([t])=>!K4(e,t))];return(0,U.jsx)(CMt.Provider,{value:i,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[d.map(([e,t])=>o(e,t)),l.length>0&&(0,U.jsx)(wMt,{defaultOpen:l.some(([e])=>t[e]!==void 0),children:l.map(([e,t])=>o(e,t))})]})})},wMt=({defaultOpen:e,children:t})=>{let[n,r]=(0,H.useState)(e);return(0,U.jsxs)(Fw,{open:n,onOpenChange:r,children:[(0,U.jsxs)(Iw,{className:`flex items-center gap-1 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground`,children:[(0,U.jsx)(rd,{className:W(`size-4 transition-transform`,n&&`rotate-90`)}),n?`Hide advanced options`:`Show advanced options`]}),(0,U.jsx)(Lw,{className:`flex flex-col gap-5 pt-5`,children:t})]})},TMt=({name:e,schema:t,required:n,value:r,onChange:i,disabled:a})=>{let o=(0,H.useId)(),s=vMt(t);return s===`boolean`?(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsx)(EMt,{htmlFor:o,name:e,schema:t,required:n}),(0,U.jsx)(T1,{id:o,checked:r===!0,onCheckedChange:e=>i(e),disabled:a})]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(EMt,{htmlFor:o,name:e,schema:t,required:n}),(0,U.jsx)(DMt,{id:o,kind:s,schema:t,required:n,value:r,onChange:i,disabled:a})]})},EMt=({htmlFor:e,name:t,schema:n,required:r})=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,U.jsxs)(GY,{htmlFor:e,className:`capitalize`,children:[t,r?(0,U.jsx)(`span`,{className:`text-destructive`,children:` *`}):(0,U.jsx)(`span`,{className:`ml-1 font-normal normal-case text-muted-foreground`,children:`(optional)`})]}),n.description&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.description})]}),DMt=({id:e,kind:t,schema:n,required:r,value:i,onChange:a,disabled:o})=>{switch(t){case`text`:return(0,U.jsx)(J4,{id:e,value:typeof i==`string`?i:``,placeholder:typeof n.default==`string`?n.default:void 0,onValueChange:e=>a(e===``?void 0:e),disabled:o});case`number`:return(0,U.jsx)(XP,{id:e,type:`number`,step:n.type===`integer`?1:void 0,value:typeof i==`number`?i:``,placeholder:typeof n.default==`number`?String(n.default):void 0,onChange:e=>{let t=e.target.value===``?NaN:Number(e.target.value);a(Number.isNaN(t)?void 0:t)},disabled:o});case`select`:return(0,U.jsxs)(vY,{value:typeof i==`string`?i:Ert,onValueChange:e=>a(e===`__UNSET`?void 0:e),disabled:o,children:[(0,U.jsx)(bY,{id:e,className:`w-full`,children:(0,U.jsx)(yY,{placeholder:`Select an option`})}),(0,U.jsxs)(xY,{children:[!r&&(0,U.jsx)(SY,{value:`__UNSET`,children:(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`Not set`})}),(n.enum??[]).filter(e=>typeof e==`string`).map(e=>(0,U.jsx)(SY,{value:e,children:e},e))]})]});case`string-array`:return(0,U.jsx)(OMt,{value:i,onChange:a,disabled:o});case`object-array`:return(0,U.jsx)(kMt,{schema:n,value:i,onChange:a,disabled:o});case`record`:return(0,U.jsx)(AMt,{schema:n,value:i,onChange:a,disabled:o});case`object`:return(0,U.jsx)(`div`,{className:`border rounded-md p-3 ml-1`,children:(0,U.jsx)(q4,{schema:n,value:Y4(i)?i:{},onChange:e=>a(Object.keys(e).length===0?void 0:e),disabled:o})});case`json`:return(0,U.jsx)(jMt,{id:e,value:i,onChange:a,disabled:o})}},J4=({id:e,value:t,placeholder:n,onValueChange:r,disabled:i})=>{let a=(0,H.useContext)(CMt),o=bMt(),s=a&&o&&!i;return(0,U.jsx)(xMt,{isEnabled:s,onInject:(e,t)=>r(t),children:(0,U.jsx)(XP,{id:e,value:t,placeholder:n,onChange:e=>r(e.target.value),disabled:i,className:W(s&&`pr-10`)})})},OMt=({value:e,onChange:t,disabled:n})=>{let r=Array.isArray(e)?e.map(e=>typeof e==`string`?e:String(e)):[],i=e=>{t(e.length===0?void 0:e)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(J4,{value:e,onValueChange:e=>{let n=[...r];n[t]=e,i(n)},disabled:n}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove item`,onClick:()=>i(r.filter((e,n)=>n!==t)),disabled:n,children:(0,U.jsx)(Kf,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>i([...r,``]),disabled:n,children:[(0,U.jsx)(hf,{className:`size-4`}),`Add item`]})]})},kMt=({schema:e,value:t,onChange:n,disabled:r})=>{let i=Array.isArray(e.items)?void 0:e.items,a=Array.isArray(t)?t:[],o=e=>{n(e.length===0?void 0:e)};return i?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a.map((e,t)=>(0,U.jsxs)(`div`,{className:`relative border rounded-md p-3 pr-10`,children:[(0,U.jsx)(q4,{schema:i,value:Y4(e)?e:{},onChange:e=>{let n=[...a];n[t]=e,o(n)},disabled:r}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove item`,className:`absolute top-2 right-2`,onClick:()=>o(a.filter((e,n)=>n!==t)),disabled:r,children:(0,U.jsx)(Kf,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>o([...a,{}]),disabled:r,children:[(0,U.jsx)(hf,{className:`size-4`}),`Add item`]})]}):null},AMt=({schema:e,value:t,onChange:n,disabled:r})=>{let i=typeof e.additionalProperties==`object`?e.additionalProperties.type:`string`,a=i===`number`||i===`integer`,[o,s]=(0,H.useState)(()=>Y4(t)?Object.entries(t).map(([e,t])=>({key:e,value:String(t)})):[]),c=e=>{s(e);let t={};for(let n of e)if(n.key!==``)if(a){if(n.value.trim()===``)continue;let e=Number(n.value);if(Number.isNaN(e))continue;t[n.key]=e}else t[n.key]=n.value;n(Object.keys(t).length===0?void 0:t)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(XP,{value:e.key,placeholder:`Key`,onChange:n=>{let r=[...o];r[t]={...e,key:n.target.value},c(r)},disabled:r}),a?(0,U.jsx)(XP,{value:e.value,placeholder:`Value`,type:`number`,onChange:n=>{let r=[...o];r[t]={...e,value:n.target.value},c(r)},disabled:r}):(0,U.jsx)(J4,{value:e.value,placeholder:`Value`,onValueChange:n=>{let r=[...o];r[t]={...e,value:n},c(r)},disabled:r}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove entry`,onClick:()=>c(o.filter((e,n)=>n!==t)),disabled:r,children:(0,U.jsx)(Kf,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>c([...o,{key:``,value:``}]),disabled:r,children:[(0,U.jsx)(hf,{className:`size-4`}),`Add entry`]})]})},jMt=({id:e,value:t,onChange:n,disabled:r})=>{let[i,a]=(0,H.useState)(()=>t===void 0?``:JSON.stringify(t,void 0,2)),[o,s]=(0,H.useState)(!1);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(AC,{id:e,className:W(`font-mono text-xs`,o&&`border-destructive`),value:i,placeholder:`JSON value`,onChange:e=>{let t=e.target.value;if(a(t),t.trim()===``){s(!1),n(void 0);return}try{n(JSON.parse(t)),s(!1)}catch{s(!0)}},disabled:r}),o&&(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`Invalid JSON — the last valid value will be saved.`})]})};function Y4(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var MMt=({designConfig:e,policyType:t,defaultHandler:n,isReadOnly:r,hasError:i,codeTabLabel:a,documentationSrc:o,designerContext:s,alwaysShowForm:c=!1,ref:l})=>{let{logEvent:u}=on(),{variant:d,isResolved:f}=Hy(`policy-form-editor`),p=c||d===`test`,m=gMt(p?e?.optionsSchemaUrl:void 0),h=p?_Mt(m.data):void 0,g=!!h,_=!!o,v=mMt(t),y=!!v,[b,x]=(0,H.useState)(n),[S,C]=(0,H.useState)(),[w,T]=(0,H.useState)(null),E=(0,H.useRef)(void 0),D=S??(y?`designer`:g?`form`:`code`),O=()=>{let e=E.current?.getValue();if(!e)throw Error(`The policy configuration is empty`);return JSON.parse(e)};(0,H.useImperativeHandle)(l,()=>({getHandler:()=>D===`code`?O():b}));let k=t=>{if(t!==D){if(D===`code`)try{x(O())}catch(e){T(`Fix the JSON before switching: ${e instanceof Error?e.message:`Unknown error`}`);return}t===`code`&&E.current?.setValue(JSON.stringify(b,void 0,2)),T(null),C(t),u(`policy-form-editor-mode-switched`,{policy:e?.id,mode:t})}};if(!f&&!c||m.isLoading)return(0,U.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,U.jsx)(QP,{className:`w-5 h-5 border-2`})});let A=y||g;return(0,U.jsxs)(`div`,{className:`flex flex-col min-h-0 min-w-0 h-full`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 border-b p-2`,children:(0,U.jsx)(H4,{variant:`outline`,type:`single`,value:D,onValueChange:e=>{e&&k(e)},children:[...y?[{value:`designer`,label:`Designer`}]:[],...g?[{value:`form`,label:`Form`}]:[],{value:`code`,label:A?`Code`:a},..._?[{value:`docs`,label:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Uu,{}),`Docs`]})}]:[]].map(({value:e,label:t})=>(0,U.jsx)(U4,{value:e,variant:`outline`,size:`xs`,className:`gap-1 px-2`,children:t},e))})}),w&&(0,U.jsx)(`p`,{className:`text-sm text-red-500 mx-3 mt-2`,children:w}),v&&(0,U.jsx)(`div`,{className:W(`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,D!==`designer`&&`hidden`),children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,U.jsx)(QP,{className:`w-5 h-5 border-2`})}),children:(0,U.jsx)(v,{options:b.options,onChange:e=>x({...b,options:e}),isReadOnly:r,operation:s?.operation,policyManager:s?.policyManager})})}),g&&D===`form`&&h&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,U.jsx)(q4,{schema:h,value:NMt(b.options)?b.options:{},onChange:e=>x({...b,options:e}),disabled:r})}),(0,U.jsx)(`div`,{className:W(`flex-1 min-h-0 min-w-0`,D!==`code`&&`hidden`),children:(0,U.jsx)(dF,{options:{...QZ,readOnly:r,automaticLayout:!0},className:W({"border border-red-500":i}),width:`100%`,height:`100%`,language:`json`,onMount:e=>{E.current=e},defaultValue:JSON.stringify(b,void 0,2)})}),_&&D===`docs`&&o&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,U.jsx)(dMt,{documentationSrc:o})})]})};function NMt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var X4=({designConfig:e,policyType:t,defaultHandler:n,initialName:r,policies:i,isReadOnly:a=!1,nameDisabled:o=!1,codeTabLabel:s=`Configuration`,alwaysShowForm:c=!1,designerContext:l,ref:u})=>{let[d,f]=(0,H.useState)(r),[p,m]=(0,H.useState)(null),h=(0,H.useRef)(null);return(0,H.useImperativeHandle)(u,()=>({getPolicyConfig:()=>{let e=hbt(d,i);if(e)throw m(e),Error(e);if(!h.current)throw Error(`The policy editor is not ready`);try{let e=h.current.getHandler();return m(null),{name:d,handler:e}}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw m(t),Error(t)}}})),(0,U.jsxs)(`div`,{className:`flex flex-col w-full h-full min-h-0`,children:[(0,U.jsx)(R4,{name:d,onChangeName:f,disabled:o,policies:i}),(0,U.jsx)(`div`,{className:`border rounded overflow-hidden mt-4 flex-1 min-h-0 min-w-0`,children:(0,U.jsx)(MMt,{ref:h,designConfig:e,policyType:t,defaultHandler:n,isReadOnly:a,hasError:!!p,codeTabLabel:s,documentationSrc:e?.exampleHtml,alwaysShowForm:c,designerContext:l})}),p&&(0,U.jsx)(`p`,{className:`text-red-500 ml-2 mt-1`,children:p})]})},PMt=`Invalid Rewrite URL provided`,FMt=`Tip: Use the API Test Console to test the behavior of request properties and environment variables.`,IMt=e=>`${e} is not a valid pattern`,LMt=e=>`Failed to parse component(s), rewrite result: ${e}`,RMt=e=>`${e} is not a valid URL`,Z4=new Proxy({},{get(e,t){return typeof t==`symbol`?()=>`superProxy.toString()`:Z4}}),zMt=e=>{if(e===``)return{errorType:`Error`,message:PMt};let t={url:new URL(`https://www.zuplo.com`),host:``,hostname:``,origin:``,port:``,protocol:``,headers:new Headers({}),params:{},pathname:``,method:``,query:{},search:``,env:Z4,request:Z4,e:encodeURIComponent,context:Z4},n=(e,t={})=>Function(`vars`,[`const tagged = ( ${Object.keys(t).join(`, `)} ) =>`,`\`${e}\``,`return tagged(...Object.values(vars))`].join(`
|
|
486
486
|
`))(t),r=null;try{r=n(e,t)}catch(t){return t instanceof ReferenceError||t instanceof TypeError?{errorType:`Error`,message:t.message}:{errorType:`Error`,message:IMt(e)}}return r?e.includes(`env.`)||e.includes(`$env(`)||e.includes(`params.`)||e.includes(`{pathname`)||e.includes(`{method`)||e.includes(`query.`)||e.includes(`{headers`)||e.includes(`request`)||e.includes(`{context`)?{errorType:`Warning`,message:FMt}:BMt(r)?{errorType:`Error`,message:LMt(r)}:VMt(r)?{errorType:null,message:null}:{errorType:`Error`,message:RMt(r)}:{errorType:`Error`,message:`Its null`}},BMt=e=>e.includes(`undefined`)||e.includes(`[object`),VMt=e=>{try{return new URL(e),!0}catch{return!1}},HMt=[{token:"${pathname}",example:`/v1/products/:productId`},{token:"${search}",example:`?category=cars`},{token:"${params.productId}",example:`:productId`},{token:"${query.category}",example:`cars`},{token:'${headers.get("content-type")}',example:`application/json`},{token:"${method}",example:`GET`},{token:"${host}",example:`example.com:8080`},{token:"${hostname}",example:`example.com`},{token:"${origin}",example:`https://example.com`},{token:"${port}",example:`8080`},{token:"${protocol}",example:`https:`},{token:"${url}",example:`https://example.com:8080/v1/products/…`},{token:"${request.user.sub}",example:`user284787985473`},{token:"${context.route.custom}",example:`my-value`}],Q4=/\$env\(([A-Za-z_][A-Za-z0-9_]*)\)/g;function UMt(e,t,n){let r=Math.min(n.start,e.length),i=Math.min(Math.max(n.end,r),e.length);return{url:e.slice(0,r)+t+e.slice(i),caret:r+t.length}}function WMt(e){return e.replace(Q4,"${env.$1}")}function GMt(e){let t=Q4.test(e);return Q4.lastIndex=0,t}var KMt=({url:e,onUrlChange:t,isReadOnly:n})=>{let r=Q4.exec(e)?.[1];return Q4.lastIndex=0,r?(0,U.jsxs)(`div`,{"data-test":`rewrite-url-env-syntax-warning`,className:`flex flex-wrap items-center justify-between gap-2 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`code`,{className:`font-mono`,children:`$env(${r})`}),` is policy-options syntax and won't be substituted in a rewrite URL. Use`,` `,(0,U.jsx)(`code`,{className:`font-mono`,children:`\${env.${r}}`}),` here.`]}),!n&&(0,U.jsxs)(X,{type:`button`,variant:`outline`,size:`xs`,className:`shrink-0`,"data-test":`rewrite-url-fix-env-syntax`,onClick:()=>t(WMt(e)),children:[`Replace with `,`\${env.${r}}`]})]}):null},qMt=({url:e,onUrlChange:t,isReadOnly:n,label:r,environmentVariableNames:i=[],...a})=>{let o=(0,H.useId)(),s=(0,H.useRef)(null),c=(0,H.useRef)(!1),l=(0,H.useRef)(null),{errorType:u,message:d}=zMt(e),f=u===`Error`,p=n=>{let r=s.current,i=UMt(e,n,c.current&&r&&r.selectionStart!=null?{start:r.selectionStart,end:r.selectionEnd??r.selectionStart}:{start:e.length,end:e.length});l.current=i.caret,t(i.url)},m=()=>{let e=l.current;l.current=null;let t=s.current;if(t&&e!=null){t.focus();let n=Math.min(e,t.value.length);t.setSelectionRange(n,n)}};return(0,U.jsxs)(U.Fragment,{children:[r&&(0,U.jsx)(GY,{htmlFor:o,className:`self-center text-sm font-normal`,children:r}),(0,U.jsxs)(`div`,{className:W(`flex flex-col gap-1.5`,!r&&`col-span-full`),children:[(0,U.jsxs)(`div`,{className:`relative w-full`,children:[(0,U.jsx)(XP,{ref:s,disabled:n,id:o,name:`rewrite-url`,"data-test":`rewrite-url-input`,"aria-invalid":f,...a,onFocus:e=>{c.current=!0,a.onFocus?.(e)},className:W(a.className,`pr-10`),onChange:e=>{t(e.target.value)},value:e}),(0,U.jsxs)(aJ,{children:[(0,U.jsx)(oJ,{asChild:!0,children:(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:n,className:`absolute top-1 right-1 bg-card`,title:`Insert a variable`,"data-test":`rewrite-url-insert-variable`,children:(0,U.jsx)(Ju,{className:`w-4`})})}),(0,U.jsxs)(sJ,{align:`end`,className:`max-h-80 w-96 overflow-y-auto`,onCloseAutoFocus:e=>{e.preventDefault(),window.setTimeout(m,0)},children:[(0,U.jsxs)(cJ,{children:[(0,U.jsx)(dJ,{children:`Environment variables`}),i.map(e=>(0,U.jsx)(lJ,{onSelect:()=>p(`\${env.${e}}`),children:(0,U.jsx)(`span`,{className:`font-mono text-xs text-zuplo-600 dark:text-zuplo-400`,children:`\${env.${e}}`})},e)),(0,U.jsx)(lJ,{onSelect:()=>p("${env.EXAMPLE_VARIABLE}"),children:(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs text-zuplo-600 dark:text-zuplo-400`,children:"${env.EXAMPLE_VARIABLE}"}),(0,U.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-muted-foreground`,children:`example`})]})})]}),(0,U.jsx)(fJ,{}),(0,U.jsxs)(cJ,{children:[(0,U.jsx)(dJ,{children:`Request variables`}),HMt.map(({token:e,example:t})=>(0,U.jsx)(lJ,{onSelect:()=>p(e),children:(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs text-zuplo-600 dark:text-zuplo-400`,children:e}),(0,U.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-muted-foreground`,children:t})]})},e))]})]})]})]}),(0,U.jsx)(KMt,{url:e,onUrlChange:t,isReadOnly:n}),f&&(0,U.jsx)(`div`,{"data-test":`rewrite-url-input-error`,className:`text-sm text-red-500`,children:d})]})]})},$4=e=>{let t=(0,H.useContext)(ap),n=t?.account?.name,r=t?.project?.name,i=hR(n??``,r??``,{enabled:!!(n&&r),useErrorBoundary:!1});return(0,U.jsx)(qMt,{...e,environmentVariableNames:i.data?.map(e=>e.name)??[]})},e3=`Authorization`,JMt=/^[A-Za-z_][A-Za-z0-9_]*$/;function YMt(e){return e?.apiKeyAuth?{authMode:`none`,noAuthBehavior:`strip`}:e?.clientRegistration?.mode===`manual`?{authMode:`user-oauth`,clientRegistration:{mode:`manual`,clientId:``,...e.clientRegistration.tokenEndpointAuthMethod?{tokenEndpointAuthMethod:e.clientRegistration.tokenEndpointAuthMethod}:{}}}:{authMode:`user-oauth`,clientRegistration:{mode:`auto`}}}var XMt=/^\/[a-zA-Z0-9\-_/{}.]+$/,ZMt=Dm().url(),QMt=jm({name:Dm().min(1,`Name is required`).regex(/^[a-zA-Z][a-zA-Z0-9 _-]*$/,`Use letters, numbers, spaces, hyphens or underscores`),mcpUrl:Dm().min(1,`URL is required`).refine(e=>!GMt(e),"$env(NAME) is not substituted in URLs — use ${env.NAME} instead.").refine(e=>B1(e)||ZMt.safeParse(e).success,"Must be a valid URL (e.g. https://mcp.example.com/mcp) or use ${env.NAME}"),path:Dm().min(2,`Path is required`).regex(XMt,`Path must start with / and use a-z, 0-9, -, _, or /`).refine(e=>e.startsWith(`/`),`Path must start with /`)});function t3(e){let t=eNt(e);return t?`/mcp/${t}-v1`:``}function $Mt(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function eNt(e){return e.toLowerCase().trim().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).replace(/-{2,}/g,`-`)}function tNt(e){let t=eNt(e).replace(/-/g,`_`).toUpperCase();return t?`${t}_MCP_UPSTREAM_KEY`:`MCP_UPSTREAM_KEY`}var nNt={prompts:[],resources:[],resourceTemplates:[],tools:[]},n3=[{key:`upstream`,label:`Upstream`},{key:`auth`,label:`Inbound Auth`},{key:`tools`,label:`Tools`},{key:`upstream-auth`,label:`Outbound Auth`}],r3=`flex-1 min-h-0 flex flex-col gap-4`,rNt=`sm:max-w-4xl flex flex-col h-[872px] max-h-[calc(100vh-2rem)]`,iNt={authMode:`user-oauth`,clientRegistration:{mode:`auto`}},aNt={catalogMode:`curated`,catalog:nNt,accessControlMode:`allPublic`},oNt=e=>e?{name:e.step1.name,mcpUrl:e.step1.mcpUrl,path:e.step1.path}:void 0,sNt=e=>{if(!e)return iNt;let t=e.step1;switch(t.authMode){case`user-oauth`:return{authMode:`user-oauth`,clientRegistration:t.clientRegistration};case`api-key`:return{authMode:`api-key`,apiKeyHeader:t.apiKeyHeader,apiKeyEnvVar:t.apiKeyEnvVar};case`upstream-policy`:return{authMode:`upstream-policy`,policyType:t.policyType,policyName:t.policyName,handler:t.handler};default:return{authMode:`none`,noAuthBehavior:t.noAuthBehavior}}};function cNt({operationPath:e,operation:t,policyList:n}){let r=t[AX];if(!r)return;let i=r.handler;if(!MX(i))return;let a=i.options?.rewritePattern;if(!a)return;let o=r.policies?.inbound??[],s=new Map(n.map(e=>[e.name,e])),c=o.map(e=>s.get(e)).filter(e=>e!==void 0),l=c.find(e=>e.policyType===`mcp-token-exchange-inbound`)?.handler?.options??{},u=c.find(e=>Ujt(e.policyType)),d=c.find(e=>e.policyType===I4),f=c.find(e=>e.policyType===`remove-headers-inbound`&&L4(e.handler?.options)),p=c.find(e=>e.policyType===Wjt),m=p?.handler?.options??{},h=c.find(e=>e.policyType.startsWith(`upstream-`)),g={name:l.displayName??t.summary??`MCP Server`,mcpUrl:a,path:e},_;_=l.authMode===`user-oauth`&&l.clientRegistration?{...g,authMode:`user-oauth`,clientRegistration:l.clientRegistration}:p?{...g,authMode:`api-key`,apiKeyHeader:m.header??e3,apiKeyEnvVar:/^\$env\((?<name>[^)]+)\)$/u.exec(m.value??``)?.groups?.name??m.value??``}:h?{...g,authMode:`upstream-policy`,policyType:h.policyType,policyName:h.name,handler:h.handler}:{...g,authMode:`none`,noAuthBehavior:f?`strip`:`passthrough`};let{catalog:v,accessControlMode:y}=Ajt(d?.handler?.options),b=d?{catalogMode:`curated`,accessControlMode:y,catalog:v}:{catalogMode:`passthrough`},x=u?{authPolicyChoice:`existing`,existingPolicyName:u.name}:{authPolicyChoice:`none`};return{step1:_,step2:b,step3:x}}var lNt=({isOpen:e,existingPaths:t,onClose:n,onFinish:r,mode:i=`create`,initialResult:a})=>{let[o,s]=(0,H.useState)(`upstream`),[c,l]=(0,H.useState)(()=>oNt(a)),[u,d]=(0,H.useState)(()=>sNt(a)),[f,p]=(0,H.useState)(()=>a?.step2??aNt),[m,h]=(0,H.useState)(()=>a?.step3),[g,_]=(0,H.useState)(!1),v=kF(g,n);(0,H.useEffect)(()=>{if(!e||!g)return;let t=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e,g]);let{captureRaw:y}=on(),b=(0,H.useRef)(!1),x=(0,H.useRef)(!1),S=(0,H.useRef)(o);(0,H.useEffect)(()=>{S.current=o},[o]);let C=bo(()=>e&&g&&!b.current);(0,H.useEffect)(()=>{let t=x.current;!t&&e?(b.current=!1,y(`mcp-gateway-create-virtual-mcp-started`)):t&&!e&&!b.current&&y(`mcp-gateway-create-virtual-mcp-cancelled`,{lastStep:S.current}),x.current=e},[e,y]);let w=n3.findIndex(e=>e.key===o),T=e=>{y(`mcp-gateway-create-virtual-mcp-step-upstream-completed`,{upstreamHost:(()=>{try{return new URL(e.mcpUrl).hostname}catch{return}})()}),c?.mcpUrl!==e.mcpUrl&&(p(aNt),d(YMt(W1(e.mcpUrl)))),_(!0),l(e),s(`auth`)},E=()=>{c&&(y(`mcp-gateway-create-virtual-mcp-skipped`,{fromStep:S.current,upstreamHost:(()=>{try{return new URL(c.mcpUrl).hostname}catch{return}})()}),b.current=!0,r({step1:{...c,authMode:`none`,noAuthBehavior:`passthrough`},step2:{catalogMode:`passthrough`},step3:{authPolicyChoice:`none`}}),n())},D=e=>{_(!0),h(e),s(`tools`)},O=e=>{y(`mcp-gateway-create-virtual-mcp-step-tools-completed`,{loadToolsFromUpstream:e.catalogMode===`passthrough`,...e.catalogMode===`curated`?{curatedToolCount:e.catalog.tools.length,curatedPromptCount:e.catalog.prompts.length,curatedResourceCount:e.catalog.resources.length,curatedResourceTemplateCount:e.catalog.resourceTemplates.length}:{}}),_(!0),p(e),s(`upstream-auth`)},k=e=>{y(`mcp-gateway-create-virtual-mcp-step-upstream-auth-completed`,{upstreamAuthMode:e.authMode,clientRegistrationMode:e.authMode===`user-oauth`?e.clientRegistration.mode:void 0}),d(e),!(!c||!m)&&(b.current=!0,r({step1:{...c,...e},step2:f,step3:m}),n())},A=()=>{o===`auth`?s(`upstream`):o===`tools`?s(`auth`):o===`upstream-auth`&&s(`tools`)};return(0,U.jsxs)(Ib,{open:e,onOpenChange:e=>{e||v.guardedClose()},children:[(0,U.jsxs)(zb,{className:rNt,onInteractOutside:e=>e.preventDefault(),children:[(0,U.jsxs)(Bb,{children:[(0,U.jsx)(Hb,{children:i===`edit`?`Edit MCP Gateway Virtual Server`:`New MCP Gateway Virtual Server`}),(0,U.jsx)(Ub,{children:`Configure the upstream MCP server, tools, and authentication.`})]}),(0,U.jsx)(`ol`,{"aria-label":`Wizard steps`,className:`flex items-center gap-2 text-xs text-muted-foreground`,children:n3.map((e,t)=>{let n=e.key===o,r=t<w;return(0,U.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:W(`size-5 rounded-full border flex items-center justify-center text-[10px] font-semibold`,n&&`bg-zuplo-700 border-zuplo-700 text-white`,r&&`bg-zuplo-100 border-zuplo-700 text-zuplo-700`,!n&&!r&&`border-neutral-300 dark:border-neutral-600`),children:r?(0,U.jsx)(td,{size:10}):t+1}),(0,U.jsx)(`span`,{className:W(n&&`text-foreground font-medium`),children:e.label}),t<n3.length-1&&(0,U.jsx)(`span`,{className:`text-neutral-300 dark:text-neutral-600`,children:`›`})]},e.key)})}),o===`upstream`&&(0,U.jsx)(dNt,{defaultValues:c,existingPaths:t,lockPath:i===`edit`,onCancel:v.guardedClose,onNext:T}),o===`auth`&&c&&(0,U.jsx)(mNt,{defaultValues:m,onBack:A,onNext:D,onSkip:i===`create`?E:void 0}),o===`tools`&&c&&(0,U.jsx)(pNt,{defaultValues:f,mcpUrl:c.mcpUrl,upstreamAuth:u,onBack:A,onNext:O,onSkip:i===`create`?E:void 0}),o===`upstream-auth`&&(0,U.jsx)(fNt,{defaultValues:u,serverName:c?.name??``,inboundAuthChoice:m,onJumpToInboundAuth:()=>s(`auth`),onBack:A,onFinish:k,onSkip:i===`create`?E:void 0})]}),(0,U.jsx)(OF,{open:v.showConfirm,onOpenChange:v.setShowConfirm,onDiscard:v.handleDiscard}),(0,U.jsx)(OF,{open:C.state===`blocked`,onOpenChange:()=>C.reset?.(),onDiscard:()=>C.proceed?.()})]})},uNt=(e,t)=>U1.find(n=>n.name===e&&n.url===t),i3=({onSkip:e,className:t,children:n})=>(0,U.jsxs)(Vb,{className:W(`shrink-0 sm:justify-between`,t),children:[e?(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:e,title:`Create the virtual server now with no policies. You can add inbound auth, tools, and outbound auth later.`,children:`Skip`}):(0,U.jsx)(`span`,{"aria-hidden":!0,className:`hidden sm:block`}),(0,U.jsx)(`div`,{className:`flex gap-2`,children:n})]}),dNt=({defaultValues:e,existingPaths:t,lockPath:n,onCancel:r,onNext:i})=>{let{logEvent:a}=on(),o=CO({defaultValues:e??{name:``,mcpUrl:``,path:``},resolver:EO(QMt)}),s=e?uNt(e.name,e.mcpUrl):void 0,[c,l]=(0,H.useState)(e?`configure`:`browse`),[u,d]=(0,H.useState)(s||!e?`library`:`custom`),[f,p]=(0,H.useState)(s?.id),[m,h]=(0,H.useState)(``),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(()=>!!e?.path&&e.path!==t3(e.name)),b=(0,H.useMemo)(()=>{let e=m.trim().toLowerCase();return(e?U1.filter(t=>t.name.toLowerCase().includes(e)):U1).map(e=>({id:e.id,name:e.name,iconUrl:e.iconUrl}))},[m]),x=f?U1.find(e=>e.id===f):void 0,S=e=>{U1.some(t=>t.id===e)&&(p(e),_(!1))},C=()=>{let e=f?U1.find(e=>e.id===f):void 0;if(e){if(d(`library`),o.setValue(`name`,e.name,{shouldDirty:!0,shouldValidate:!0}),o.setValue(`mcpUrl`,e.url,{shouldDirty:!0,shouldValidate:!0}),!v&&!n){let n=$Mt(t3(e.name),t);o.setValue(`path`,n,{shouldDirty:!0,shouldValidate:!0})}a(`mcp-gateway-create-virtual-mcp-library-server-selected`,{id:e.id,name:e.name,url:e.url,configureMode:`library`}),l(`configure`)}},w=()=>{a(`mcp-gateway-create-virtual-mcp-custom-server-selected`),p(void 0),d(`custom`),o.setValue(`name`,``,{shouldDirty:!0}),o.setValue(`mcpUrl`,``,{shouldDirty:!0}),l(`configure`)},T=o.watch(`name`),E=o.watch(`path`);(0,H.useEffect)(()=>{if(v)return;let e=$Mt(t3(T),t);e!==E&&o.setValue(`path`,e,{shouldValidate:!1})},[v,T,t,E,o]);let D=e=>{if(t.has(e.path)){a(`mcp-gateway-create-virtual-mcp-upstream-path-conflict-failed`,{path:e.path,name:e.name}),o.setError(`path`,{type:`manual`,message:`Path "${e.path}" is already used by another route`});return}i(e)};return c===`browse`?(0,U.jsxs)(`div`,{className:r3,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed shrink-0`,children:`Choose an MCP server from the library, or set up a custom one.`}),(0,U.jsx)(XP,{placeholder:`Search servers…`,size:`sm`,value:m,onChange:e=>h(e.target.value),className:`shrink-0`}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:(0,U.jsx)(b4,{tiles:b,selectedId:f,onSelect:S,fallbackIcon:(0,U.jsx)(RY,{className:`size-7 text-muted-foreground`}),emptyState:`No servers match "${m}".`})}),(0,U.jsxs)(`button`,{type:`button`,onClick:w,className:`shrink-0 flex items-center justify-center gap-2 rounded-md border border-dashed border-neutral-300 dark:border-neutral-600 bg-card px-4 py-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-800/60`,children:[(0,U.jsx)(hf,{"aria-hidden":`true`,className:`size-4`}),`Set up a custom MCP server`]}),(0,U.jsxs)(Vb,{className:`shrink-0`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:r,children:`Cancel`}),(0,U.jsx)(X,{type:`button`,onClick:C,disabled:!f,title:f?void 0:`Select a server`,children:`Next`})]})]}):(0,U.jsx)(KY,{...o,children:(0,U.jsxs)(`form`,{onSubmit:o.handleSubmit(D),className:r3,children:[u===`library`&&x?(0,U.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border bg-surface-sunken px-4 py-3 shrink-0`,children:[g||!x.iconUrl?(0,U.jsx)(RY,{className:`size-9 shrink-0 text-muted-foreground`}):(0,U.jsx)(`img`,{src:x.iconUrl,alt:``,className:`size-9 shrink-0 object-contain brightness-0 dark:invert`,onError:()=>_(!0)}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,U.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:x.name}),x.description&&(0,U.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:x.description})]})]}):(0,U.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border bg-surface-sunken px-4 py-3 shrink-0`,children:[(0,U.jsx)(RY,{className:`size-9 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,U.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Custom MCP server`}),(0,U.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Point the gateway at any MCP-compatible server — your own first-party MCP service or one not yet covered by our Library.`})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(qY,{control:o.control,name:`name`,render:({field:e})=>(0,U.jsxs)(YY,{children:[(0,U.jsx)(XY,{children:`Name`}),(0,U.jsx)(ZY,{children:(0,U.jsx)(XP,{placeholder:`e.g. Linear, GitHub, Atlassian`,size:`sm`,...e})}),(0,U.jsx)($Y,{})]})}),(0,U.jsx)(qY,{control:o.control,name:`mcpUrl`,render:({field:e})=>{let t=u===`library`;return(0,U.jsxs)(YY,{children:[(0,U.jsx)(XY,{children:`MCP URL`}),(0,U.jsx)(ZY,{children:(0,U.jsx)(XP,{placeholder:`https://mcp.example.com/mcp`,size:`sm`,readOnly:t,"aria-readonly":t||void 0,tabIndex:t?-1:void 0,...e})}),!t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(KMt,{url:e.value,onUrlChange:e.onChange,isReadOnly:!1}),(0,U.jsxs)(QY,{children:[`Environment variable references are supported — e.g.`,` `,(0,U.jsx)(`code`,{children:"${env.LINEAR_MCP_URL}"}),`.`]})]}),(0,U.jsx)($Y,{})]})}}),(0,U.jsx)(qY,{control:o.control,name:`path`,render:({field:e})=>(0,U.jsxs)(YY,{children:[(0,U.jsx)(XY,{children:`Path`}),(0,U.jsx)(ZY,{children:(0,U.jsx)(XP,{placeholder:`/mcp/your-server`,size:`sm`,readOnly:n,"aria-readonly":n||void 0,...e,onChange:t=>{n||(y(!0),e.onChange(t))}})}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[n?`The mount path is fixed once a virtual server is created. To move it, delete and re-create the route.`:null,n?null:(0,U.jsxs)(U.Fragment,{children:[`Where this virtual server will be mounted. Defaults to`,` `,(0,U.jsx)(`code`,{children:`/mcp/<name>-v1`}),`; suffixed if that's already taken.`]})]}),(0,U.jsx)($Y,{})]})})]}),(0,U.jsxs)(Vb,{className:`mt-auto shrink-0`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:()=>l(`browse`),children:`Back`}),(0,U.jsx)(X,{type:`submit`,children:`Next`})]})]})})},fNt=({defaultValues:e,serverName:t,inboundAuthChoice:n,onJumpToInboundAuth:r,onBack:i,onFinish:a,onSkip:o})=>{let{logEvent:s,captureRaw:c}=on(),l=g1(),u=G4(),[d,f]=(0,H.useState)(`method`),[p,m]=(0,H.useState)(e.authMode),[h,g]=(0,H.useState)(e.authMode===`none`?e.noAuthBehavior:`passthrough`),[_,v]=(0,H.useState)(e.authMode===`user-oauth`?e.clientRegistration.mode:`auto`),[y,b]=(0,H.useState)(e.authMode===`user-oauth`&&e.clientRegistration.mode===`manual`?e.clientRegistration.clientId:``),[x,S]=(0,H.useState)(e.authMode===`user-oauth`&&e.clientRegistration.mode===`manual`?e.clientRegistration.clientSecret??``:``),[C,w]=(0,H.useState)(e.authMode===`user-oauth`&&e.clientRegistration.mode===`manual`?e.clientRegistration.tokenEndpointAuthMethod??`client_secret_basic`:`client_secret_basic`),T=tNt(t),[E,D]=(0,H.useState)(e.authMode===`api-key`?e.apiKeyHeader:e3),[O,k]=(0,H.useState)(e.authMode===`api-key`?e.apiKeyEnvVar:T),[A,j]=(0,H.useState)(e.authMode===`upstream-policy`?e.policyType:void 0),M=(0,H.useRef)(null),N=(0,H.useMemo)(()=>(u.data?.policies??[]).filter(e=>e.id.startsWith(`upstream-`)&&e.id.endsWith(`-inbound`)&&!e.isInternal&&!e.isDeprecated&&!e.isCustom).sort((e,t)=>e.name.localeCompare(t.name)),[u.data]),P=A?E1(u.data,A):void 0,F=e.authMode===`upstream-policy`&&e.policyType===A?e.policyName:void 0,[I,L]=(0,H.useState)(()=>e.authMode===`upstream-policy`?{[e.policyType]:{name:e.policyName,handler:e.handler}}:{}),R=A?I[A]:void 0,z=R?.handler??P?.defaultHandler,B=(0,H.useMemo)(()=>N.map(e=>({id:e.id,name:e.name,iconUrl:e.icon})),[N]),[ee,V]=(0,H.useState)(),te=y.trim(),ne=x.trim(),re=p===`user-oauth`&&(!n||n.authPolicyChoice===`none`),ie=O.trim(),ae=E.trim(),oe=re||p===`upstream-policy`&&!A,se=p===`user-oauth`&&_===`manual`&&!te||p===`api-key`&&!ie||p===`upstream-policy`&&!A,ce=p===`api-key`&&!ie?`Environment variable is required`:p===`upstream-policy`&&!A?`Pick a policy`:se?`Client ID is required`:void 0,le=()=>{if(p===`none`){a({authMode:`none`,noAuthBehavior:h});return}if(p===`upstream-policy`){if(!A)return;try{let e=M.current?.getPolicyConfig()??a3();a({authMode:`upstream-policy`,policyType:A,policyName:e.name,handler:e.handler})}catch{c(`mcp-gateway-create-virtual-mcp-outbound-service-policy-invalid-failed`,{policyType:A})}return}if(p===`api-key`){if(!JMt.test(ie)){V(`Environment variable must be a valid name (letters, numbers, underscore).`);return}a({authMode:`api-key`,apiKeyHeader:ae||e3,apiKeyEnvVar:ie});return}if(_===`auto`){a({authMode:`user-oauth`,clientRegistration:{mode:`auto`}});return}if(ne&&!/^\$env\([A-Z][A-Z0-9_]*\)$/u.test(ne)){s(`mcp-gateway-create-virtual-mcp-outbound-client-secret-invalid-failed`,{clientRegistrationMode:_,tokenEndpointAuthMethod:C}),V(`Store client secrets in an environment variable.`);return}a({authMode:`user-oauth`,clientRegistration:{mode:`manual`,clientId:te,...ne?{clientSecret:ne}:{},tokenEndpointAuthMethod:C}})};return(0,U.jsxs)(`div`,{className:r3,children:[d===`method`&&(0,U.jsx)(Ojt,{active:`outbound`}),d===`method`&&re&&(0,U.jsxs)(`div`,{className:`rounded-md border border-amber-300 dark:border-amber-900/60 bg-amber-50 dark:bg-amber-950/40 px-3 py-2.5 text-xs text-amber-900 dark:text-amber-200 leading-relaxed flex items-start gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex-1`,children:[(0,U.jsx)(`div`,{className:`font-semibold`,children:`Inbound auth policy required`}),(0,U.jsx)(`div`,{className:`mt-0.5`,children:`Upstream User OAuth needs an inbound MCP OAuth policy so the gateway can bind upstream grants to the caller. Configure one in the Inbound Auth step before finishing.`})]}),(0,U.jsxs)(`button`,{type:`button`,onClick:r,className:`shrink-0 self-center inline-flex items-center gap-1 rounded-md border border-amber-400 dark:border-amber-900/60 bg-card px-2.5 py-1 text-xs font-medium text-amber-900 dark:text-amber-200 hover:bg-amber-100 dark:hover:bg-amber-900/40`,children:[(0,U.jsx)(ad,{"aria-hidden":`true`,className:`size-3.5`}),`Configure inbound auth`]})]}),d===`method`&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:`Choose whether the gateway needs upstream credentials before forwarding MCP requests.`}),d===`method`&&(0,U.jsx)(y4,{ariaLabel:`Outbound authentication`,idPrefix:`upstream-auth`,layout:`list`,value:p,onValueChange:e=>{s(`mcp-gateway-create-virtual-mcp-outbound-auth-mode-selected`,{value:e}),V(void 0),m(e)},options:[{value:`user-oauth`,title:`User OAuth`,description:`Exchange each user's gateway grant for an upstream MCP grant.`},{value:`api-key`,title:`API key`,description:`Attach a fixed API key from an environment variable to every request.`},{value:`upstream-policy`,title:`Service auth`,description:`Authenticate with a service credential policy — GCP, AWS IAM, Azure AD, and more.`},{value:`none`,title:`None`,description:`Forward directly — the upstream doesn't need credentials from the gateway.`}]}),d===`configure`&&(0,U.jsxs)(`div`,{className:`shrink-0`,children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:`Configure outbound policy`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:p===`user-oauth`?`Configure how the gateway registers its OAuth client with the upstream.`:p===`api-key`?`Configure the API key attached to every upstream request.`:`Name the policy and fill in its configuration.`})]}),d===`method`&&p===`none`&&(0,U.jsxs)(`div`,{className:`rounded-md border bg-card p-3 flex items-center justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:`Remove inbound Authorization header`}),(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed`,children:h===`strip`?(0,U.jsxs)(U.Fragment,{children:[`Strips the inbound MCP client's `,(0,U.jsx)(`code`,{children:`Authorization`}),` `,`header (via a remove-headers policy) before forwarding to the upstream.`]}):(0,U.jsxs)(U.Fragment,{children:[`Forwards the inbound MCP client's `,(0,U.jsx)(`code`,{children:`Authorization`}),` `,`header to the upstream as-is.`]})})]}),(0,U.jsx)(T1,{checked:h===`strip`,onCheckedChange:e=>{let t=e?`strip`:`passthrough`;s(`mcp-gateway-create-virtual-mcp-outbound-no-auth-behavior-selected`,{value:t}),g(t)},"aria-label":`Remove inbound Authorization header`})]}),d===`method`&&p===`upstream-policy`&&(0,U.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{children:`Policy`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Pick the service-credential policy that authenticates the gateway to your upstream, then fill in its details.`}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-0.5`,children:(0,U.jsx)(b4,{tiles:B,selectedId:A,onSelect:e=>{c(`mcp-gateway-create-virtual-mcp-outbound-service-policy-selected`,{value:e}),V(void 0),j(e)},fallbackIcon:(0,U.jsx)(Zd,{className:`size-7 text-muted-foreground`}),emptyState:`No upstream auth policies found in the policy library.`})})]}),d===`configure`&&p===`api-key`&&(0,U.jsxs)(`div`,{className:`rounded-md border bg-card p-3 flex flex-col gap-3`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:`Upstream API key`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`upstream-api-key-header`,children:`Header`}),(0,U.jsx)(XP,{id:`upstream-api-key-header`,size:`sm`,value:E,onChange:e=>D(e.target.value),placeholder:e3})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`upstream-api-key-env`,children:`Environment variable`}),(0,U.jsx)(XP,{id:`upstream-api-key-env`,size:`sm`,value:O,onChange:e=>{V(void 0),k(e.target.value)},placeholder:T})]})]}),(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground leading-relaxed`,children:[`Sets`,` `,(0,U.jsxs)(`code`,{children:[ae||e3,`: $env(`,ie||T,`)`]}),` `,`on every request to the upstream. Define the environment variable with your key in the project's Environment Variables — the wizard references it but doesn't create it.`]})]}),d===`configure`&&p===`upstream-policy`&&A&&(0,U.jsxs)(U.Fragment,{children:[P&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-surface-sunken px-3 py-2 shrink-0`,children:[(0,U.jsx)(b1,{url:P.icon,className:`size-6`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:P.name}),P.description&&(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:P.description})]})]}),z&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 px-1`,children:(0,U.jsx)(X4,{ref:M,designConfig:P,policyType:A,defaultHandler:z,initialName:R?.name??D1(l.getPolicyListEnforced(),A),policies:l.getPolicyListEnforced().filter(e=>e.name!==F),alwaysShowForm:!0},A)})]}),d===`configure`&&p===`user-oauth`&&(0,U.jsxs)(`div`,{className:`rounded-md border bg-card p-3 flex flex-col gap-3`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:`OAuth client registration`}),(0,U.jsx)(y4,{ariaLabel:`OAuth client registration`,idPrefix:`upstream-client-registration`,value:_,onValueChange:e=>{s(`mcp-gateway-create-virtual-mcp-outbound-client-registration-selected`,{value:e}),v(e)},options:[{value:`auto`,title:`Dynamic`,description:`The gateway registers itself with the upstream automatically via Dynamic Client Registration (DCR). Nothing to configure.`},{value:`manual`,title:`Manual`,description:`Use a client ID and secret you already registered with the upstream. Pick this when it doesn't support dynamic registration.`}]}),_===`manual`&&(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`upstream-client-id`,children:`Client ID`}),(0,U.jsx)(XP,{id:`upstream-client-id`,size:`sm`,value:y,onChange:e=>b(e.target.value),placeholder:`$env(UPSTREAM_OAUTH_CLIENT_ID)`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`upstream-client-secret`,children:`Client secret`}),(0,U.jsx)(XP,{id:`upstream-client-secret`,type:`password`,size:`sm`,value:x,onChange:e=>{V(void 0),S(e.target.value)},placeholder:`$env(UPSTREAM_OAUTH_CLIENT_SECRET)`}),(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground leading-relaxed`,children:[`Use `,(0,U.jsx)(`code`,{children:`$env(NAME)`}),`; literal secrets are not written to config.`]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 col-span-2`,children:[(0,U.jsx)(GY,{htmlFor:`upstream-token-auth-method`,children:`Token endpoint auth`}),(0,U.jsxs)(vY,{value:C,onValueChange:e=>w(e),children:[(0,U.jsx)(bY,{id:`upstream-token-auth-method`,children:(0,U.jsx)(yY,{})}),(0,U.jsxs)(xY,{children:[(0,U.jsx)(SY,{value:`client_secret_basic`,children:`Client secret basic`}),(0,U.jsx)(SY,{value:`client_secret_post`,children:`Client secret post`}),(0,U.jsx)(SY,{value:`none`,children:`None`})]})]})]})]})]}),ee&&(0,U.jsx)(`div`,{className:`rounded-md border border-red-200 dark:border-red-900/60 bg-red-50 dark:bg-red-950/40 px-3 py-2 text-xs text-red-700 dark:text-red-200`,children:ee}),d===`method`?(0,U.jsxs)(i3,{onSkip:o,className:`mt-auto`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:i,children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:()=>{p===`none`?le():(V(void 0),f(`configure`))},disabled:oe,title:re?`Configure an inbound auth policy first`:p===`upstream-policy`&&!A?`Select a policy`:void 0,children:p===`none`?`Finish`:`Next`})]}):(0,U.jsxs)(i3,{onSkip:o,className:`mt-auto`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:()=>{if(V(void 0),p===`upstream-policy`&&A)try{let e=M.current?.getPolicyConfig();e&&L(t=>({...t,[A]:e}))}catch{}f(`method`)},children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:le,disabled:se,title:ce,children:`Finish`})]})]})},pNt=({defaultValues:e,mcpUrl:t,upstreamAuth:n,onBack:r,onNext:i,onSkip:a})=>{let{logEvent:o}=on(),[s,c]=(0,H.useState)(e.catalogMode),[l,u]=(0,H.useState)(()=>e.catalogMode===`curated`?e.catalog:nNt),[d,f]=(0,H.useState)(e.catalogMode===`curated`?e.accessControlMode:`allPublic`),p=d===`rolesAndGroups`,m=()=>{i(s===`passthrough`?{catalogMode:`passthrough`}:{catalogMode:`curated`,catalog:l,accessControlMode:d})},h=l.tools.length+l.prompts.length+l.resources.length+l.resourceTemplates.length,g=s===`curated`&&h===0;return(0,U.jsxs)(`div`,{className:r3,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:`Decide which tools, prompts, and resources this virtual server exposes to its clients.`}),(0,U.jsx)(y4,{ariaLabel:`Catalog mode`,idPrefix:`catalog-mode`,columns:2,value:s,onValueChange:e=>{o(`mcp-gateway-create-virtual-mcp-catalog-strategy-selected`,{value:e,mcpUrl:t}),c(e)},options:[{value:`curated`,title:`Filter & curate`,description:`Pick exactly which tools, prompts, and resources this server exposes — and control who can use each.`},{value:`passthrough`,title:`Passthrough`,description:`Federate the upstream's catalog live: everything the server advertises is exposed. Zero config.`}]}),s===`curated`&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-md border bg-card px-3 py-2 shrink-0`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Roles & groups access control`}),(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Mark each capability public, or restrict it to specific roles or groups. Anything left unclassified won't be exposed — nothing is public by default.`})]}),(0,U.jsx)(T1,{checked:p,onCheckedChange:e=>f(e?`rolesAndGroups`:`allPublic`),"aria-label":`Enable roles and groups access control`})]}),s===`curated`&&(0,U.jsx)(fxt,{catalog:l,onChange:u,accessControlEnabled:p,upstream:{mcpUrl:t,upstreamAuth:n}}),(0,U.jsxs)(i3,{onSkip:a,className:`mt-auto`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:r,children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:m,disabled:g,title:g?`Select at least one tool, prompt, or resource to continue`:void 0,children:`Next`})]})]})},mNt=({defaultValues:e,onBack:t,onNext:n,onSkip:r})=>{let{logEvent:i,captureRaw:a}=on(),o=g1(),s=(0,H.useMemo)(()=>o.getPolicyListEnforced().filter(e=>Ujt(e.policyType)),[o]),[c,l]=(0,H.useState)(e?.authPolicyChoice??(s.length>0?`existing`:`new`)),[u,d]=(0,H.useState)(e?.authPolicyChoice===`new`||e?.authPolicyChoice===`new-other`?`configure`:`method`),[f,p]=(0,H.useState)(e?.authPolicyChoice===`existing`?e.existingPolicyName:s[0]?.name??``),[m,h]=(0,H.useState)(e?.authPolicyChoice===`new`?e.providerId:void 0),[g,_]=(0,H.useState)(e?.authPolicyChoice===`new`?e.newPolicyName:``),[v,y]=(0,H.useState)(()=>e?.authPolicyChoice===`new`?{[e.providerId]:e.handler}:{}),[b,x]=(0,H.useState)(e?.authPolicyChoice===`new-other`?e.policyType:void 0),[S,C]=(0,H.useState)(()=>e?.authPolicyChoice===`new-other`?{[e.policyType]:{name:e.newPolicyName,handler:e.handler}}:{}),[w,T]=(0,H.useState)(),[E,D]=(0,H.useState)(!1),O=(0,H.useRef)(null),k=G4(),A=(0,H.useMemo)(()=>j4.map(e=>({id:e.id,name:e.label,iconUrl:e.iconUrl})),[]),j=(0,H.useMemo)(()=>(k.data?.policies??[]).filter(e=>e.id.endsWith(`-inbound`)&&zjt(e.id)&&!e.isInternal&&!e.isDeprecated&&!e.isCustom).sort((e,t)=>e.name.localeCompare(t.name)),[k.data]),M=(0,H.useMemo)(()=>j.map(e=>({id:e.id,name:e.name,iconUrl:e.icon})),[j]),N=b?E1(k.data,b):void 0,P=b?S[b]:void 0,F=P?.handler??N?.defaultHandler,I=m?M4(m):void 0,L=I?v[I.id]??{module:I.policyModule,export:I.policyExport,options:I.defaultOptions??Mjt(I)}:void 0,R=e=>{let t=M4(e);if(!t)return;i(`mcp-gateway-create-virtual-mcp-inbound-auth-provider-selected`,{id:t.id,label:t.label}),T(void 0),D(!1);let n=m?M4(m):void 0,r=g.trim();(!r||r===n?.suggestedPolicyName)&&_(t.suggestedPolicyName),h(t.id)},z=()=>{if(c===`none`){a(`mcp-gateway-create-virtual-mcp-step-inbound-auth-completed`,{choice:c,candidatesLength:s.length}),n({authPolicyChoice:`none`});return}if(c===`existing`){if(!f){T(`Pick a policy.`);return}a(`mcp-gateway-create-virtual-mcp-step-inbound-auth-completed`,{choice:c,candidatesLength:s.length}),n({authPolicyChoice:`existing`,existingPolicyName:f});return}if(T(void 0),c===`new-other`){b&&d(`configure`);return}m&&d(`configure`)},B=()=>{if(!I){d(`method`);return}let e;try{e=O.current?.getPolicyConfig()??a3()}catch{i(`mcp-gateway-create-virtual-mcp-inbound-auth-policy-invalid-failed`,{providerId:I.id,newPolicyName:g});return}_(e.name),y(t=>({...t,[I.id]:e.handler})),a(`mcp-gateway-create-virtual-mcp-step-inbound-auth-completed`,{choice:c,selectedProviderId:I.id,candidatesLength:s.length}),n({authPolicyChoice:`new`,providerId:I.id,policyType:I.policyType,newPolicyName:e.name,handler:e.handler})},ee=()=>{if(!b){d(`method`);return}let e;try{e=O.current?.getPolicyConfig()??a3()}catch{i(`mcp-gateway-create-virtual-mcp-inbound-auth-policy-invalid-failed`,{policyType:b});return}C(t=>({...t,[b]:e})),a(`mcp-gateway-create-virtual-mcp-step-inbound-auth-completed`,{choice:c,otherPolicyType:b,candidatesLength:s.length}),n({authPolicyChoice:`new-other`,policyType:b,newPolicyName:e.name,handler:e.handler})},V=[{value:`new`,title:`New user identity provider`,description:`Scaffold an inbound OAuth policy for the IdP your users sign in with — Auth0, Okta, Entra, and more.`},{value:`new-other`,title:`New other identity provider`,description:`For agents and non-standard clients — API key, JWT, basic auth, and more.`},...s.length>0?[{value:`existing`,title:`Existing policy`,description:`Reuse an inbound auth policy already in this project.`}]:[],{value:`none`,title:`None`,description:`Allow unauthenticated requests, or add your own policy manually.`}];return(0,U.jsxs)(`div`,{className:r3,children:[u===`method`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ojt,{active:`inbound`}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground leading-relaxed shrink-0`,children:[`Choose how MCP clients authenticate `,(0,U.jsx)(`em`,{children:`to`}),` this gateway.`]}),(0,U.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-1 flex flex-col gap-3`,children:[(0,U.jsx)(y4,{ariaLabel:`Inbound authentication method`,idPrefix:`inbound-method`,layout:`list`,value:c,onValueChange:e=>{i(`mcp-gateway-create-virtual-mcp-inbound-auth-method-selected`,{value:e,candidatesLength:s.length}),T(void 0),l(e)},options:V}),c===`existing`&&s.length>0&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{children:`Choose a policy`}),(0,U.jsx)(y4,{ariaLabel:`Existing inbound auth policy`,idPrefix:`inbound-existing`,columns:1,value:f,onValueChange:e=>{T(void 0),p(e)},options:s.map(e=>({value:e.name,title:(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.name})}))})]}),c===`none`&&(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The virtual server will accept unauthenticated requests. You can add an authorization policy later if required.`}),c===`new`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{children:`Identity provider`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Pick the identity provider that issues tokens for this server, then fill in its details.`}),(0,U.jsx)(b4,{tiles:A,selectedId:m,onSelect:R,fallbackIcon:(0,U.jsx)(Zd,{className:`size-7 text-muted-foreground`})})]}),c===`new-other`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{children:`Authentication policy`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Pick how clients authenticate to this server, then fill in the policy's details.`}),(0,U.jsx)(b4,{tiles:M,selectedId:b,onSelect:e=>{i(`mcp-gateway-create-virtual-mcp-inbound-other-policy-selected`,{value:e}),T(void 0),x(e)},fallbackIcon:(0,U.jsx)(Zd,{className:`size-7 text-muted-foreground`}),emptyState:`No authentication policies found in the policy library.`})]}),w&&(0,U.jsx)(`div`,{className:`text-sm text-destructive`,children:w})]}),(0,U.jsxs)(i3,{onSkip:r,className:`border-t pt-3`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:t,children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:z,disabled:c===`new`&&!m||c===`new-other`&&!b,title:c===`new`&&!m?`Select an identity provider`:c===`new-other`&&!b?`Select an authentication policy`:void 0,children:`Next`})]})]}),u===`configure`&&c===`new`&&I&&L&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`shrink-0`,children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:`Configure inbound policy`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:`Name the policy and fill in your identity provider's details.`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-surface-sunken px-3 py-2 shrink-0`,children:[E||!I.iconUrl?(0,U.jsx)(Zd,{className:`h-6 w-6 shrink-0 text-muted-foreground`}):(0,U.jsx)(`img`,{src:I.iconUrl,alt:``,className:`h-6 w-6 object-contain brightness-0 dark:invert`,onError:()=>D(!0)}),(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:I.label}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:I.description})]})]}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0 px-1`,children:(0,U.jsx)(X4,{ref:O,designConfig:E1(k.data,I.policyType),policyType:I.policyType,defaultHandler:L,initialName:g.trim()||I.suggestedPolicyName,policies:o.getPolicyListEnforced(),alwaysShowForm:!0},I.id)}),(0,U.jsxs)(i3,{onSkip:r,className:`border-t pt-3`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:()=>{T(void 0);try{let e=O.current?.getPolicyConfig();e&&(_(e.name),y(t=>({...t,[I.id]:e.handler})))}catch{}d(`method`)},children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:B,children:`Next`})]})]}),u===`configure`&&c===`new-other`&&b&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`shrink-0`,children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:`Configure inbound policy`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:`Name the policy and fill in its configuration.`})]}),N&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-surface-sunken px-3 py-2 shrink-0`,children:[(0,U.jsx)(b1,{url:N.icon,className:`size-6`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:N.name}),N.description&&(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:N.description})]})]}),F&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 px-1`,children:(0,U.jsx)(X4,{ref:O,designConfig:N,policyType:b,defaultHandler:F,initialName:P?.name??D1(o.getPolicyListEnforced(),`mcp-${b}`),policies:o.getPolicyListEnforced(),alwaysShowForm:!0},b)}),(0,U.jsxs)(i3,{onSkip:r,className:`border-t pt-3`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:()=>{T(void 0);try{let e=O.current?.getPolicyConfig();e&&C(t=>({...t,[b]:e}))}catch{}d(`method`)},children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:ee,children:`Next`})]})]})]})};function a3(){throw Error(`The policy editor is not ready`)}function hNt(e){return e.toLowerCase().trim().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).replace(/-{2,}/g,`-`)}function o3(e,t){if(!t.has(e))return e;let n=1;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function gNt(e,t){if(!t.has(e))return e;let n=1;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}var _Nt=`remove-authorization-header`;function vNt(e){return{name:e,policyType:Gjt,handler:{module:`$import(@zuplo/runtime)`,export:`RemoveHeadersInboundPolicy`,options:{headers:[`authorization`]}}}}function yNt(e){return e.find(e=>e.policyType===`remove-headers-inbound`&&L4(e.handler?.options))}function bNt(e){try{let t=new URL(e),n=new URL(`/.well-known/oauth-protected-resource`,t.origin),r=t.pathname.replace(/\/$/,``);return r&&r!==`/`&&(n.pathname+=r),n.toString()}catch{return}}function xNt({result:e,policyList:t,existingOperationIds:n}){let{step1:r,step2:i,step3:a}=e,o=hNt(r.name),s=W1(r.mcpUrl),c=s?.protectedResourceMetadataUrl??bNt(r.mcpUrl),l=[],u=new Set(t.map(e=>e.name)),d=e=>{let t=o3(e,u);return u.add(t),t},f;r.authMode===`user-oauth`&&(f=d(`mcp-upstream-${o}`),l.push({name:f,policyType:F4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpTokenExchangeInboundPolicy`,options:{id:o,displayName:r.name,summary:`${r.name} remote MCP server, federated via the gateway.`,...c?{protectedResourceMetadataUrl:c}:{},authMode:`user-oauth`,scopes:s?.scopes??[],clientRegistration:r.clientRegistration}}}));let p;r.authMode===`api-key`&&(p=d(`set-${o}-api-key`),l.push({name:p,policyType:Wjt,handler:{module:`$import(@zuplo/runtime)`,export:`SetUpstreamApiKeyInboundPolicy`,options:{header:r.apiKeyHeader,value:`$env(${r.apiKeyEnvVar})`}}}));let m;i.catalogMode===`curated`&&(m=d(`mcp-filter-${o}`),l.push({name:m,policyType:I4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpCapabilityFilterInboundPolicy`,options:k4(i)}}));let h;a.authPolicyChoice===`existing`?h=a.existingPolicyName:(a.authPolicyChoice===`new`||a.authPolicyChoice===`new-other`)&&(h=a.newPolicyName,u.add(h),l.push({name:h,policyType:a.policyType,handler:a.handler}));let g;r.authMode===`upstream-policy`&&(g=r.policyName,u.add(g),l.push({name:g,policyType:r.policyType,handler:r.handler}));let _;if(r.authMode===`none`&&r.noAuthBehavior===`strip`){let e=yNt(t);e?_=e.name:(_=d(_Nt),l.push(vNt(_)))}let v=[h,m,f,p,g,_].filter(e=>!!e),y=gNt(`${o}-mcp-server`,n);return{policiesToCreate:l,operationPath:r.path,method:`post`,operation:{summary:r.name,description:`MCP Virtual Server fronted by the gateway (${r.mcpUrl})`,tags:[`MCP`],[xst]:!0,[AX]:{corsPolicy:`none`,handler:{export:`McpProxyHandler`,module:`$import(@zuplo/runtime/mcp-gateway)`,options:{rewritePattern:r.mcpUrl}},policies:{inbound:v}},operationId:y}}}function SNt(e){let{step1:t,step2:n,step3:r}=e,i;try{i=new URL(t.mcpUrl).hostname}catch{i=void 0}return{upstreamHost:i,upstreamAuthMode:t.authMode,inboundAuthChoice:r.authPolicyChoice,...r.authPolicyChoice===`new`?{inboundAuthProvider:r.providerId}:{},...r.authPolicyChoice===`new-other`?{inboundAuthPolicyType:r.policyType}:{},loadToolsFromUpstream:n.catalogMode===`passthrough`,...n.catalogMode===`curated`?{curatedToolCount:n.catalog.tools.length,curatedPromptCount:n.catalog.prompts.length,curatedResourceCount:n.catalog.resources.length,curatedResourceTemplateCount:n.catalog.resourceTemplates.length}:{}}}function CNt({autoCreate:e,onAutoCreateConsumed:t}){let n=t1(),{isReadOnly:r}=jZ(),i=n.openApiData?.tags??[],[a,o]=(0,H.useState)(e?{mode:`create`}:null),s=(0,H.useRef)(!1);(0,H.useEffect)(()=>{e&&!s.current&&(s.current=!0,t?.())},[e,t]);let c=e=>n.operationArray?.filter(t=>t.tags?.includes(e)).length??0,l=new Set(i.map(e=>e.name)),u=a?.mode===`edit`?i.find(e=>e.name===a.name):void 0;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Tags group your API's operations. Assign them to routes from each route's editor; here you can create and edit the tags themselves.`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-[52vh] overflow-y-auto px-0.5 py-1`,children:i.length===0?(0,U.jsxs)(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-sm text-muted-foreground`,children:[`No tags yet.`,!r&&` Use “Add tag” below to create one.`]}):i.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>o({mode:`edit`,name:e.name}),className:`group flex w-full items-center gap-2 rounded-md border border-border bg-card px-3 py-2 text-left transition-colors hover:bg-accent`,children:[(0,U.jsx)(If,{size:14,className:`shrink-0 text-muted-foreground`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,U.jsx)(`div`,{className:e.description?`truncate text-xs text-muted-foreground`:`truncate text-xs italic text-muted-foreground`,children:e.description||`No description`})]}),(0,U.jsx)(pf,{size:13,className:`shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100`})]},e.name))}),!r&&(0,U.jsx)(`div`,{children:(0,U.jsxs)(X,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o({mode:`create`}),children:[(0,U.jsx)(hf,{size:14}),`Add tag`]})}),(0,U.jsx)(wNt,{open:a!==null,mode:a?.mode??`create`,initialName:u?.name??``,initialDescription:u?.description??``,currentName:a?.mode===`edit`?a.name:void 0,existingNames:l,usageCount:a?.mode===`edit`?c(a.name):0,isReadOnly:r,onOpenChange:e=>{e||o(null)},onSubmit:(e,t)=>{let r=e.trim(),i=t.trim();try{a?.mode===`create`?n.addTag(r,i||void 0):a?.mode===`edit`&&n.updateTag(a.name,r,i),o(null)}catch{}},onDelete:a?.mode===`edit`?()=>{a?.mode===`edit`&&n.deleteTag(a.name),o(null)}:void 0},a?.mode===`edit`?`edit:${a.name}`:`create`)]})}function wNt({open:e,onOpenChange:t,mode:n,initialName:r,initialDescription:i,currentName:a,existingNames:o,usageCount:s,isReadOnly:c,onSubmit:l,onDelete:u}){return(0,U.jsx)(Ib,{open:e,onOpenChange:t,children:(0,U.jsx)(zb,{className:`sm:max-w-md`,children:(0,U.jsx)(TNt,{mode:n,initialName:r,initialDescription:i,currentName:a,existingNames:o,usageCount:s,isReadOnly:c,onCancel:()=>t(!1),onSubmit:l,onDelete:u})})})}function TNt({mode:e,initialName:t,initialDescription:n,currentName:r,existingNames:i,usageCount:a,isReadOnly:o,onCancel:s,onSubmit:c,onDelete:l}){let[u,d]=(0,H.useState)(t),[f,p]=(0,H.useState)(n),[m,h]=(0,H.useState)(!1),g=u.trim(),_=g.length>0&&g!==r&&i.has(g),v=g.length>0&&!_&&!o;return(0,U.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),v&&c(u,f)},className:`flex flex-col gap-4`,children:[(0,U.jsxs)(Bb,{children:[(0,U.jsx)(Hb,{children:e===`create`?`Add tag`:`Edit tag`}),(0,U.jsx)(Ub,{children:e===`create`?`Create a tag you can assign to routes.`:`Rename this tag or update its description.`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(GY,{htmlFor:`tag-edit-name`,children:[`Name `,(0,U.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,U.jsx)(XP,{id:`tag-edit-name`,value:u,onChange:e=>d(e.target.value),placeholder:`my-tag`,"aria-invalid":_||g.length===0,disabled:o,autoFocus:!0}),_&&(0,U.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`A tag named “`,g,`” already exists.`]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`tag-edit-description`,children:`Description`}),(0,U.jsx)(AC,{id:`tag-edit-description`,value:f,onChange:e=>p(e.target.value),placeholder:`A short description. Markdown is supported.`,rows:3,disabled:o})]})]}),(0,U.jsx)(Vb,{className:`sm:justify-between`,children:m?(0,U.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,children:[(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Delete “`,r,`”?`,a>0&&` It will be removed from ${a} ${a===1?`route`:`routes`}.`]}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,onClick:()=>h(!1),children:`Keep`}),(0,U.jsxs)(X,{type:`button`,variant:`destructive`,onClick:l,children:[(0,U.jsx)(zf,{size:14}),`Delete tag`]})]})]}):(0,U.jsxs)(U.Fragment,{children:[l&&!o?(0,U.jsxs)(X,{type:`button`,variant:`destructive-outline`,onClick:()=>h(!0),children:[(0,U.jsx)(zf,{size:14}),`Delete`]}):(0,U.jsx)(`span`,{}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,onClick:s,children:`Cancel`}),(0,U.jsx)(X,{type:`submit`,disabled:!v,children:e===`create`?`Add`:`Save`})]})]})})]})}function ENt({open:e,onOpenChange:t,info:n,onSave:r,defaultTab:i=`details`,tagsAutoCreate:a,onTagsAutoCreateConsumed:o}){return(0,U.jsx)(Ib,{open:e,onOpenChange:t,children:(0,U.jsxs)(zb,{className:`top-16 translate-y-0 sm:max-w-xl`,children:[(0,U.jsxs)(Bb,{children:[(0,U.jsx)(Hb,{children:`API Settings`}),(0,U.jsx)(Ub,{children:`Edit your OpenAPI document's details and tags.`})]}),(0,U.jsxs)(Sk,{defaultValue:i,children:[(0,U.jsxs)(Ck,{variant:`underline`,children:[(0,U.jsx)(wk,{variant:`underline`,value:`details`,children:`Details`}),(0,U.jsx)(wk,{variant:`underline`,value:`tags`,children:`Tags`})]}),(0,U.jsx)(Tk,{value:`details`,children:(0,U.jsx)(DNt,{info:n,onCancel:()=>t(!1),onSave:e=>{r(e),t(!1)}})}),(0,U.jsx)(Tk,{value:`tags`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsx)(CNt,{autoCreate:a,onAutoCreateConsumed:o}),(0,U.jsx)(Vb,{children:(0,U.jsx)(X,{type:`button`,onClick:()=>t(!1),children:`Done`})})]})})]})]})})}function DNt({info:e,onSave:t,onCancel:n}){let[r,i]=(0,H.useState)(e.title??``),[a,o]=(0,H.useState)(e.version??``),[s,c]=(0,H.useState)(e.summary??``),[l,u]=(0,H.useState)(e.description??``),[d,f]=(0,H.useState)(e.termsOfService??``),[p,m]=(0,H.useState)(e.contact?.name??``),[h,g]=(0,H.useState)(e.contact?.url??``),[_,v]=(0,H.useState)(e.contact?.email??``),[y,b]=(0,H.useState)(e.license?.name??``),[x,S]=(0,H.useState)(e.license?.url??``),C=r.trim().length>0&&a.trim().length>0;return(0,U.jsxs)(`form`,{onSubmit:n=>{if(n.preventDefault(),!C)return;let i={...e,title:r.trim(),version:a.trim()},o=e=>{let t={summary:s,description:l,termsOfService:d}[e].trim();t?i[e]=t:delete i[e]};o(`summary`),o(`description`),o(`termsOfService`);let c={...e.contact??{}};for(let[e,t]of[[`name`,p],[`url`,h],[`email`,_]])t.trim()?c[e]=t.trim():delete c[e];if(Object.keys(c).length>0?i.contact=c:delete i.contact,y.trim()){let t={...e.license??{},name:y.trim()};x.trim()?t.url=x.trim():delete t.url,i.license=t}else delete i.license;t(i)},className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 max-h-[60vh] overflow-y-auto px-0.5 py-1`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-[1fr_auto] gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(GY,{htmlFor:`openapi-info-title`,children:[`Title `,(0,U.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,U.jsx)(XP,{id:`openapi-info-title`,value:r,onChange:e=>i(e.target.value),placeholder:`My API`,"aria-invalid":r.trim().length===0,autoFocus:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:w-32`,children:[(0,U.jsxs)(GY,{htmlFor:`openapi-info-version`,children:[`Version `,(0,U.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,U.jsx)(XP,{id:`openapi-info-version`,value:a,onChange:e=>o(e.target.value),placeholder:`1.0.0`,"aria-invalid":a.trim().length===0})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`openapi-info-summary`,children:`Summary`}),(0,U.jsx)(XP,{id:`openapi-info-summary`,value:s,onChange:e=>c(e.target.value),placeholder:`A short summary of the API`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`openapi-info-description`,children:`Description`}),(0,U.jsx)(AC,{id:`openapi-info-description`,value:l,onChange:e=>u(e.target.value),placeholder:`A longer description. Markdown is supported.`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`openapi-info-tos`,children:`Terms of service`}),(0,U.jsx)(XP,{id:`openapi-info-tos`,type:`url`,value:d,onChange:e=>f(e.target.value),placeholder:`https://example.com/terms`})]}),(0,U.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-md border border-border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-xs font-medium text-muted-foreground`,children:`Contact`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`openapi-info-contact-name`,children:`Name`}),(0,U.jsx)(XP,{id:`openapi-info-contact-name`,value:p,onChange:e=>m(e.target.value),placeholder:`API Support`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`openapi-info-contact-url`,children:`URL`}),(0,U.jsx)(XP,{id:`openapi-info-contact-url`,type:`url`,value:h,onChange:e=>g(e.target.value),placeholder:`https://example.com/support`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`openapi-info-contact-email`,children:`Email`}),(0,U.jsx)(XP,{id:`openapi-info-contact-email`,type:`email`,value:_,onChange:e=>v(e.target.value),placeholder:`support@example.com`})]})]})]}),(0,U.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-md border border-border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-xs font-medium text-muted-foreground`,children:`License`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`openapi-info-license-name`,children:`Name`}),(0,U.jsx)(XP,{id:`openapi-info-license-name`,value:y,onChange:e=>b(e.target.value),placeholder:`MIT`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(GY,{htmlFor:`openapi-info-license-url`,children:`URL`}),(0,U.jsx)(XP,{id:`openapi-info-license-url`,type:`url`,value:x,onChange:e=>S(e.target.value),placeholder:`https://opensource.org/licenses/MIT`})]})]})]})]}),(0,U.jsxs)(Vb,{children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,U.jsx)(X,{type:`submit`,disabled:!C,children:`Save`})]})]})}var s3=(0,H.createContext)({setPath:()=>{},setSummary:()=>{}}),ONt=({isReadOnly:e,initialSummary:t,onSummaryChange:n,onFieldModified:r})=>{let i=(0,H.useRef)(null),[a,o]=(0,H.useState)(!1),{setSummary:s}=(0,H.useContext)(s3);(0,H.useEffect)(()=>{i.current&&(i.current.value=t??``,s(t))},[t]);let c=e=>{a||(o(!0),r()),s(e.target.value)},l=e=>{a&&(n(e.target.value),o(!1))};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(GY,{htmlFor:`operation-summary`,className:`flex items-center gap-2`,children:`Summary`}),(0,U.jsxs)(rX,{className:`bg-background`,children:[(0,U.jsx)(aX,{ref:i,disabled:e,"data-test":`operation-summary-input`,id:`operation-summary`,name:`summary`,onChange:c,onBlur:l}),(0,U.jsx)(iX,{align:`inline-end`,children:(0,U.jsxs)(iR,{children:[(0,U.jsx)(aR,{asChild:!0,children:(0,U.jsx)(dat,{variant:`ghost`,"aria-label":`Info`,size:`icon-sm`,children:(0,U.jsx)(Xy,{})})}),(0,U.jsx)(oR,{className:`max-w-52`,children:`Summary is used to describe the operation in the API. It should be brief and to the point.`})]})})]})]})};function kNt(){var e=[...arguments];return(0,H.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var c3=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function l3(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function u3(e){return`nodeType`in e}function d3(e){return e?l3(e)?e:u3(e)?e.ownerDocument?.defaultView??window:window:window}function f3(e){let{Document:t}=d3(e);return e instanceof t}function p3(e){return l3(e)?!1:e instanceof d3(e).HTMLElement}function ANt(e){return e instanceof d3(e).SVGElement}function m3(e){return e?l3(e)?e.document:u3(e)?f3(e)?e:p3(e)||ANt(e)?e.ownerDocument:document:document:document}var h3=c3?H.useLayoutEffect:H.useEffect;function g3(e){let t=(0,H.useRef)(e);return h3(()=>{t.current=e}),(0,H.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function jNt(){let e=(0,H.useRef)(null);return[(0,H.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,H.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function _3(e,t){t===void 0&&(t=[e]);let n=(0,H.useRef)(e);return h3(()=>{n.current!==e&&(n.current=e)},t),n}function v3(e,t){let n=(0,H.useRef)();return(0,H.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function y3(e){let t=g3(e),n=(0,H.useRef)(null);return[n,(0,H.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function b3(e){let t=(0,H.useRef)();return(0,H.useEffect)(()=>{t.current=e},[e]),t.current}var x3={};function S3(e,t){return(0,H.useMemo)(()=>{if(t)return t;let n=x3[e]==null?0:x3[e]+1;return x3[e]=n,e+`-`+n},[e,t])}function MNt(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var C3=MNt(1),w3=MNt(-1);function NNt(e){return`clientX`in e&&`clientY`in e}function T3(e){if(!e)return!1;let{KeyboardEvent:t}=d3(e.target);return t&&e instanceof t}function PNt(e){if(!e)return!1;let{TouchEvent:t}=d3(e.target);return t&&e instanceof t}function E3(e){if(PNt(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return NNt(e)?{x:e.clientX,y:e.clientY}:null}var D3=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[D3.Translate.toString(e),D3.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),FNt=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function INt(e){return e.matches(FNt)?e:e.querySelector(FNt)}var LNt={display:`none`};function RNt(e){let{id:t,value:n}=e;return H.createElement(`div`,{id:t,style:LNt},n)}function zNt(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return H.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function BNt(){let[e,t]=(0,H.useState)(``);return{announce:(0,H.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var VNt=(0,H.createContext)(null);function HNt(e){let t=(0,H.useContext)(VNt);(0,H.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function UNt(){let[e]=(0,H.useState)(()=>new Set),t=(0,H.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,H.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var WNt={draggable:`
|
|
487
487
|
To pick up a draggable item, press the space bar.
|
|
488
488
|
While dragging, use the arrow keys to move the item.
|
|
@@ -1562,7 +1562,7 @@ In some cases, you need to provide options to alter GraphQL's execution behavior
|
|
|
1562
1562
|
`+t+`)`}function c8(e){let t=$6(e.defaultValue,e.type),n=e.name+`: `+String(e.type);return t&&(n+=` = ${Sn(t)}`),n+l8(e.deprecationReason)}function tBt(e){return u8(e)+`directive @`+e.name+eBt(e.args)+(e.isRepeatable?` repeatable`:``)+` on `+e.locations.join(` | `)}function l8(e){return e==null?``:e===`No longer supported`?` @deprecated`:` @deprecated(reason: ${Sn({kind:er.STRING,value:e})})`}function nBt(e){return e.specifiedByURL==null?``:` @specifiedBy(url: ${Sn({kind:er.STRING,value:e.specifiedByURL})})`}function u8(e,t=``,n=!0){let{description:r}=e;if(r==null)return``;let i=Sn({kind:er.STRING,value:r,block:eee(r)});return(t&&!n?`
|
|
1563
1563
|
`+t:t)+i.replace(/\n/g,`
|
|
1564
1564
|
`+t)+`
|
|
1565
|
-
`}var d8=`/docs/schema.graphql`,rBt=()=>JSON.stringify({query:Rzt()}),iBt=e=>{if(!e)throw Error(`The endpoint returned an empty response.`);let t;try{t=JSON.parse(e)}catch{throw Error(`The endpoint did not return a valid JSON response.`)}if(t.errors?.length)throw Error(`The introspection query returned errors: ${t.errors.map(e=>e.message).join(`; `)}`);if(!t.data?.__schema)throw Error(`The endpoint did not return an introspection result. Make sure introspection is enabled.`);try{return`${Bzt(zzt(t.data))}\n`}catch(e){throw Error(`Could not build a schema from the introspection result: ${e instanceof Error?e.message:String(e)}`)}},aBt=({endpointUrl:e,rewriteUrl:t,ape:n,onClose:r})=>{let{logEvent:i}=on(),a=ip(),o=UZ(),s=HR(),[c,l]=(0,H.useState)(t??e),[u,d]=(0,H.useState)([{key:``,value:``}]),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(),g=(e,t,n)=>{d(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},_=()=>d(e=>[...e,{key:``,value:``}]),v=e=>d(t=>t.filter((t,n)=>n!==e)),y=async()=>{h(void 0),p(!0);let l=c===t?`handler`:c===e?`gateway`:`custom`,d={account:n.account.name,project:n.project.name,environment:n.environment.name,endpointMode:l};i(`graphql-schema-introspection-run`,d);let f=`request`,m;try{let e;try{f=`invalid_url`,e=new URL(c)}catch{throw Error(`Enter a valid endpoint URL, including the protocol (e.g. https://).`)}let t={"content-type":`application/json`};for(let{key:e,value:n}of u){let r=e.trim();r.length>0&&(t[r]=n)}f=`request`;let l=await(await s({environmentName:n.environment.name,testRequest:{description:`GraphQL introspection`,pathname:`${e.pathname}${e.search}`,method:`POST`,headers:t,body:rBt()},overrideUrl:e.origin})).json();if(m=l.status,l.status<200||l.status>=300)throw f=`upstream_status`,Error(`The endpoint responded with ${l.status} ${l.statusText??``}.`.trim());f=`introspection`;let p=iBt(l.body);f=`save`,await o.mutateAsync({file:{path:d8,content:p},accountName:n.account.name,projectName:n.project.name,environmentName:n.environment.name}),i(`graphql-schema-introspection-success`,{...d,upstreamStatus:m}),a.success(`Schema saved to ${d8}`),r()}catch(e){let t=e instanceof Error?e.message:String(e);i(`graphql-schema-introspection-failed`,{...d,stage:f,upstreamStatus:m,reason:t}),h(t)}finally{p(!1)}};return(0,U.jsx)(Ib,{open:!0,onOpenChange:e=>!e&&!f&&r(),children:(0,U.jsxs)(zb,{className:`sm:max-w-2xl`,children:[(0,U.jsxs)(Bb,{children:[(0,U.jsx)(Hb,{children:`Download GraphQL schema`}),(0,U.jsxs)(Ub,{children:[`Run an introspection query against this endpoint. On success the schema is stored in `,(0,U.jsx)(`code`,{children:d8}),`.`]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(GY,{htmlFor:`graphql-introspection-endpoint`,children:`Endpoint`}),e&&e!==c&&(0,U.jsx)(X,{variant:`link`,size:`xs`,type:`button`,className:`h-auto p-0`,disabled:f,onClick:()=>l(e),children:`Use gateway URL`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(XP,{id:`graphql-introspection-endpoint`,value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com/graphql`,disabled:f,"data-op-ignore":!0}),(0,U.jsx)($P,{textToCopy:c})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(GY,{children:`Headers (optional)`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(XP,{placeholder:`Header name`,value:e.key,onChange:e=>g(t,`key`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(XP,{placeholder:`Value`,value:e.value,onChange:e=>g(t,`value`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,type:`button`,"aria-label":`Remove header`,onClick:()=>v(t),children:(0,U.jsx)(zf,{className:`size-4`})})]},t))}),(0,U.jsx)(`div`,{children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,type:`button`,onClick:_,children:[(0,U.jsx)(hf,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Add header`})]})})]}),m&&(0,U.jsxs)(Sb,{variant:`destructive`,children:[(0,U.jsx)(sd,{}),(0,U.jsx)(Cb,{children:`Introspection failed`}),(0,U.jsx)(wb,{className:`break-words`,children:m})]})]}),(0,U.jsxs)(Vb,{children:[(0,U.jsx)(Rb,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,type:`button`,disabled:f,children:`Cancel`})}),(0,U.jsx)(X,{variant:`brand`,type:`button`,onClick:y,disabled:f||c.trim().length===0,children:f?`Running…`:`Run introspection`})]})]})})},oBt=({path:e,rewriteUrl:t})=>{let n=op(),r=Qa(),{logEvent:i}=on(),[a,o]=(0,H.useState)(!1),s=UR(n.environment),c=s?new URL(e,s).toString():void 0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(aJ,{children:[(0,U.jsx)(oJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,children:[(0,U.jsx)(f1,{className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{children:`Schema`}),(0,U.jsx)(nd,{className:`size-4 shrink-0`})]})}),(0,U.jsxs)(sJ,{align:`end`,children:[(0,U.jsxs)(lJ,{onSelect:()=>{i(`graphql-schema-open`,{account:n.account.name,project:n.project.name,environment:n.environment.name}),r({pathname:$r(Yb.Code,{account:n.account.name,project:n.project.name,environment:encodeURIComponent(n.environment.urlParameter)}),search:`?path=${d8}`})},children:[(0,U.jsx)(Pd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Open Schema`})]}),(0,U.jsxs)(lJ,{disabled:!c,onSelect:()=>o(!0),children:[(0,U.jsx)(Cd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Download Schema`})]})]})]}),a&&c&&(0,U.jsx)(aBt,{endpointUrl:c,rewriteUrl:t,ape:n,onClose:()=>o(!1)})]})},sBt=({operationTags:e,onTagsChanged:t})=>{let{isReadOnly:n}=jZ(),r=t1(),[i,a]=(0,H.useState)(``),o=r.openApiData?.tags?.map(e=>e.name)??[],s=n=>{e.includes(n)?t(e.filter(e=>e!==n)):t([...e,n])},c=()=>{let n=i.trim();if(n){if(!o.includes(n))try{r.addTag(n)}catch{}e.includes(n)||t([...e,n]),a(``)}};return(0,U.jsxs)(bw,{children:[(0,U.jsx)(xw,{asChild:!0,children:(0,U.jsxs)(l6,{children:[(0,U.jsx)(If,{size:16}),e.length===1?(0,U.jsx)(`span`,{className:`truncate max-w-[12ch]`,title:e[0],children:e[0]}):`${e.length} Tags`]})}),(0,U.jsxs)(Sw,{className:`w-64 p-0 z-100`,align:`end`,children:[(0,U.jsx)(`div`,{className:`px-3 pt-3 pb-2`,children:(0,U.jsx)(`h4`,{className:`text-sm font-medium`,children:`Operation Tags`})}),o.length>0&&(0,U.jsx)(`div`,{className:`border-t max-h-48 overflow-y-auto`,children:o.map(t=>(0,U.jsxs)(`button`,{type:`button`,disabled:n,className:`w-full flex items-center justify-between px-3 py-1.5 text-sm hover:bg-accent disabled:opacity-50 disabled:cursor-default cursor-pointer`,onClick:()=>s(t),children:[(0,U.jsx)(`span`,{className:`truncate`,children:t}),(0,U.jsx)(td,{size:14,className:W(`shrink-0`,!e.includes(t)&&`invisible`)})]},t))}),!n&&(0,U.jsx)(`div`,{className:`border-t p-2`,children:(0,U.jsxs)(`form`,{className:`flex gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,U.jsx)(XP,{value:i,onChange:e=>a(e.target.value),placeholder:`New tag...`,className:`h-7 text-xs`}),(0,U.jsx)(X,{type:`submit`,variant:`outline`,size:`icon-sm`,disabled:!i.trim(),children:(0,U.jsx)(hf,{size:14})})]})})]})]})},cBt=r(a((e=>{var t=/~/,n=/~[01]/g;function r(e){switch(e){case`~1`:return`/`;case`~0`:return`~`}throw Error(`Invalid tilde escape: `+e)}function i(e){return t.test(e)?e.replace(n,r):e}function a(e){if(typeof e==`string`){if(e=e.split(`/`),e[0]===``)return e;throw Error(`Invalid JSON pointer.`)}else if(Array.isArray(e)){for(let t of e)if(typeof t!=`string`&&typeof t!=`number`)throw Error(`Invalid JSON pointer. Must be of type string or number.`);return e}throw Error(`Invalid JSON pointer.`)}function o(e,t){if(typeof e!=`object`)throw Error(`Invalid input object.`);t=a(t);var n=t.length;if(n===1)return e;for(var r=1;r<n;){if(e=e[i(t[r++])],n===r)return e;if(typeof e!=`object`||!e)return}}e.get=o}))());function f8(e,t){try{return e.startsWith(`#`)?cBt.get(t,e.replace(`#`,``)):cBt.get(t,e)}catch(e){console.error(`Error resolving schema reference. Reference may be invalid or referencing an external document.`,e);return}}var lBt=(e,t)=>{let n=e;return!n||`$ref`in n&&(n=f8(n.$ref,t),!n)?``:n.example?n.example:n.examples&&n.examples.length>0?n.examples[0]:n.default?n.default:``},uBt=(e,t)=>{if(e.examples&&Object.keys(e.examples).length>0){let n=Object.values(e.examples)[0];if(`$ref`in n){let e=f8(n.$ref,t);if(!e)return``;n=e}return n.value}if(e.example)return e.example;let n=e.schema;return lBt(n,t)},dBt=(e,t)=>{let n=e.requestBody;if(!n)return``;if(`$ref`in n){let e=f8(n.$ref,t);if(!e)return``;n=e}let{content:r}=n;if(!(`application/json`in r))return``;let i=r[`application/json`];if(i.examples&&Object.keys(i.examples).length>0){let e=Object.values(i.examples)[0];if(`$ref`in e){let n=f8(e.$ref,t);if(!n)return``;e=n}return e.value}let a=i.schema;return lBt(a,t)},fBt=JSON.stringify({query:`{ __schema { queryType { name } } }`},null,2),pBt=new VR,mBt=e=>e.additionalOperationContext.method.split(`,`).map(e=>e.toUpperCase()),p8=e=>{let{oasFilePath:t,method:n,path:r}=e.additionalOperationContext;return`${t}::${e.operationId??`${n} ${r}`}`},hBt=({ape:e,envUrl:t,operation:n,openApiDocument:r,showRebuildWarning:i,onClose:a,defaultEndpointsPanelOpen:o=!1,documentsByPath:s,endpointsLoading:c})=>{let l=(t,n)=>{let r=mBt(t)[0],i=t[OX]===!0,a=NX(t),o=dBt(t,n),s=pBt.getTest(e.account.name,e.project.name,e.environment.name,t.operationId),c=t.parameters?.filter(e=>!(`$ref`in e)&&e.in===`header`).reduce((e,t)=>({...e,[t.name]:uBt(t,n)}),{})??{},l=typeof o==`string`?o:JSON.stringify(o),u=a?{"content-type":`application/json`,accept:`application/json, text/event-stream`,...c}:i?{"content-type":`application/json`,...c}:c,d=l||(a?OR:i?fBt:l);return s?.test&&s.test.method===r?s.test:{description:t.summary??t.description??``,pathname:t.additionalOperationContext.path,method:r,headers:u,body:d}},[u,d]=(0,H.useState)(n),[f,p]=(0,H.useState)(()=>l(n,r)),[m,h]=(0,H.useState)(o),g=hp(e=>e.setTestResponse),_=yp(),v=s??_,y=(0,H.useMemo)(()=>({...v,[n.additionalOperationContext.oasFilePath]:r}),[v,n.additionalOperationContext.oasFilePath,r]),b=(0,H.useMemo)(()=>Object.entries(y).flatMap(([e,t])=>e1(e,t)),[y]),x=(0,H.useMemo)(()=>b.map(e=>({id:p8(e),method:e.additionalOperationContext.method,path:e.additionalOperationContext.path,summary:e.summary,file:e.additionalOperationContext.oasFilePath})),[b]);return(0,H.useEffect)(()=>{g(void 0)},[]),(0,U.jsx)(`div`,{className:`flex h-[650px] max-h-[70vh] flex-col`,children:(0,U.jsx)(zit,{ape:e,apiTest:f,showRebuildWarning:i,allowedMethods:mBt(u),url:`${t}${u.additionalOperationContext.path}`,shouldAllowLocalSaving:!!u.operationId,operationId:u.operationId,path:u.additionalOperationContext.path,onRequestChange:e=>{p(e)},onClose:a,endpoints:x,selectedEndpointId:p8(u),onSelectEndpoint:e=>{if(e===p8(u))return;let t=b.find(t=>p8(t)===e);if(!t)return;let n=y[t.additionalOperationContext.oasFilePath]??r;d(t),p(l(t,n)),g(void 0)},isEndpointPanelOpen:m,onToggleEndpointPanel:()=>h(e=>!e),endpointsLoading:c},p8(u))})},gBt=({envUrl:e,ape:t,operation:n,openApiDocument:r,showRebuildWarning:i,entries:a,onClose:o,defaultEndpointsPanelOpen:s})=>(0,U.jsx)(CY.Provider,{value:{entries:a},children:(0,U.jsx)(`div`,{className:`w-full text-muted-foreground`,children:(0,U.jsx)(hBt,{openApiDocument:r,ape:t,envUrl:e,showRebuildWarning:i,operation:n,onClose:o,defaultEndpointsPanelOpen:s})})}),_Bt=({open:e,onOpenChange:t,onProceed:n})=>{let{saveAndDeploy:r,isPending:i}=tpt();return(0,U.jsx)(Ib,{open:e,onOpenChange:t,children:(0,U.jsxs)(zb,{className:`sm:max-w-md`,children:[(0,U.jsxs)(Bb,{children:[(0,U.jsx)(Hb,{children:`Unsaved changes`}),(0,U.jsx)(Ub,{children:`Your unsaved changes will not be reflected when you test this route until you save and deploy them. Save them now, or continue testing the currently deployed version.`})]}),(0,U.jsxs)(Vb,{children:[(0,U.jsx)(X,{variant:`ghost`,onClick:n,disabled:i,children:`Continue without saving`}),(0,U.jsx)(X,{variant:`default`,onClick:async()=>{try{await r()}catch{return}n()},disabled:i,children:(0,U.jsx)(YP,{loading:i,children:`Save changes`})})]})]})})},vBt=(0,H.lazy)(()=>gn(()=>import(`./GraphiQLConsole-BIM6Kiy9.js`),__vite__mapDeps([9,1,2,8,10,11,12]))),yBt=({path:e,method:t,summary:n,operationData:r,hasFileChanged:i,isGraphql:a})=>{let{logEvent:o}=on(),s=op(),c=t1().getOpenApiDataEnforced(),{entries:l}=(0,H.useContext)(CY),u=UR(s.environment),[d,f]=(0,H.useState)(null),p=u?new URL(e,u).toString():void 0,m=zee({mutationKey:Bft})>0,[h,g]=x$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:t.includes(`,`)?t.split(`,`)[0]:t,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:a?`playground`:`default`}),(0,U.jsx)(Ib,{open:!0,onOpenChange:e=>!e&&g(),children:(0,U.jsxs)(zb,{showCloseButton:!1,className:`max-w-6xl! w-full gap-0 overflow-hidden p-0`,children:[(0,U.jsx)(Hb,{className:`sr-only`,children:`Test route`}),(0,U.jsx)(gBt,{envUrl:u??``,showRebuildWarning:i,ape:s,entries:l,operation:r,openApiDocument:c,onClose:g})]})})),[e,t,n,r,l,a]),[_,v]=x$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:`POST`,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:`graphiql`}),(0,U.jsx)(Ib,{open:!0,onOpenChange:e=>!e&&v(),children:(0,U.jsxs)(zb,{className:`max-w-6xl! w-full p-0 overflow-hidden`,children:[(0,U.jsx)(Hb,{className:`sr-only`,children:`GraphiQL`}),(0,U.jsx)(`div`,{className:`h-[80vh] w-full`,children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:`Loading GraphiQL…`}),children:(0,U.jsx)(vBt,{url:p??``,ape:s})})})]})})),[p,s]),y=e=>{e===`graphiql`?_():h()},b=e=>{if(i){f(e);return}y(e)},x=(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{children:`Saving`}),(0,U.jsx)(JP,{color:`current`})]}),S=m?`Saving`:`Test Route`;return(0,U.jsxs)(U.Fragment,{children:[a?(0,U.jsxs)(aJ,{children:[(0,U.jsx)(oJ,{asChild:!0,children:(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":S,children:(0,U.jsxs)(YP,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(qf,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`}),(0,U.jsx)(nd,{className:`size-4 shrink-0`})]})})}),(0,U.jsxs)(sJ,{align:`end`,children:[(0,U.jsxs)(lJ,{onSelect:()=>b(`playground`),children:[(0,U.jsx)(qf,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Playground`})]}),(0,U.jsxs)(lJ,{disabled:!p,onSelect:()=>b(`graphiql`),children:[(0,U.jsx)(f1,{className:`size-4`}),(0,U.jsx)(`span`,{children:`GraphiQL`})]})]})]}):(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":S,onClick:()=>b(`playground`),children:(0,U.jsxs)(YP,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(qf,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`})]})}),(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(_Bt,{open:d!==null,onOpenChange:e=>{e||f(null)},onProceed:()=>{let e=d;f(null),e&&y(e)}})})]})},bBt=({onRequestHandlerChange:e,isReadOnly:t,routeHandler:n})=>{let r=m1(n),i=(t,i)=>{e({...n,options:{...r.options,[t]:i}})};return(0,U.jsxs)(kO,{className:`p-4 bg-surface-sunken`,children:[(0,U.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-base font-medium`,children:`MCP Server Options`}),(0,U.jsx)(Rw,{showIcon:!0,href:`https://docs.zuplo.com/handlers/mcp-server`,className:`text-sm text-zuplo-pink`,children:`MCP Server Docs`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-12 gap-4 col-span-full items-center`,children:[(0,U.jsx)(`div`,{className:`col-span-8`,children:(0,U.jsx)(s6,{isReadOnly:t,label:`Server Name`,onChange:e=>i(`name`,e.target.value),className:`col-span-8`,value:typeof r.options.name==`string`?r.options.name:`My MCP Server`})}),(0,U.jsx)(`div`,{className:`col-span-4`,children:(0,U.jsx)(s6,{isReadOnly:t,label:`Server Version`,className:`col-span-4`,onChange:e=>i(`version`,e.target.value),value:typeof r.options.version==`string`?r.options.version:`v0.0.1`})}),(0,U.jsxs)(`div`,{className:`col-span-12 mt-2`,children:[(0,U.jsx)(GY,{className:`text-sm mb-2 block`,children:`Advanced Options`}),(0,U.jsx)(`div`,{className:W(`flex gap-4`,t&&`opacity-50`),children:(0,U.jsxs)(`label`,{className:`text-sm flex items-center gap-2`,children:[(0,U.jsx)(IY,{"data-test":`mcp-debug-mode`,checked:!!r.options.debugMode,onCheckedChange:e=>{i(`debugMode`,e)},disabled:t}),`Debug Mode`]})})]})]})]})},xBt=({routeHandler:e,operation:t,isReadOnly:n,onRequestHandlerChange:r})=>{let{captureRaw:i}=on(),a=Syt(),o=m1(e),s=typeof o.options.rewritePattern==`string`?o.options.rewritePattern:``,c=LIt(()=>{i(`mcp-gateway-upstream-url-edited`)});return(0,U.jsx)(kO,{className:`p-4`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground font-medium`,children:`Upstream MCP server`}),!!(a&&t)&&(0,U.jsxs)(X,{type:`button`,variant:`default`,size:`sm`,disabled:n,onClick:()=>{!t||!a||(i(`mcp-gateway-edit-virtual-mcp-opened`),a(t))},className:`shrink-0`,children:[(0,U.jsx)(Tf,{className:`w-3.5 h-3.5`}),`Edit MCP Server Policy`]})]}),(0,U.jsx)($4,{isReadOnly:n,url:s,onUrlChange:t=>{c(),r({...e,options:{...o.options,rewritePattern:t}})},placeholder:`https://example.com/mcp`,"aria-label":`Upstream MCP server URL`,"data-test":`mcp-upstream-url-input`})]})})};function SBt(e){if(e)switch(e.type){case`tool`:return{type:e.type,name:e.name??``,description:e.description??``,annotations:e.annotations};case`prompt`:return{type:e.type,name:e.name??``,description:e.description??``};case`resource`:return{type:e.type,name:e.name??``,description:e.description??``,uri:e.uri??``,mimeType:e.mimeType??``};case`graphql`:return{type:e.type,introspectionTool:{name:e.introspectionTool?.name??``,description:e.introspectionTool?.description??``},executeTool:{name:e.executeTool?.name??``,description:e.executeTool?.description??``}}}}function CBt({operationData:e,addRouteMenuProps:t}){return e?(0,U.jsx)(`div`,{className:`w-full h-full min-h-0 overflow-y-auto px-4 pt-2 pb-4`,children:(0,U.jsx)(TBt,{operationData:e})}):(0,U.jsx)(Dvt,{...t})}var wBt=()=>{let e=vp(),t=yp(),n=(0,H.useMemo)(()=>e.flatMap(e=>{let n=t[e.path];return n?e1(e.path,n).filter(e=>NX(e)).map(t=>[e,t]):[]}),[e,t]);return{getLinkedMcpServers:(e,t)=>n.filter(([,n])=>{let r=n[AX]?.handler;return jX(r)?r.options?.operations?.some(n=>d1(n.file)===e&&n.id===t):!1})}},TBt=({operationData:e})=>{let[t]=wY(`path`);if(!t)throw Error(`Open API file path not found in URL`);let n=ept(t),r=op(),{logEvent:i}=on(),{additionalOperationContext:a,...o}=e,{path:s,method:c}=a,l=t1(),u=ip(),d=g1(),{isReadOnly:f}=jZ(),[p,m]=(0,H.useState)(),[h,g]=(0,H.useState)();wBt();let _=l.openApiData?.servers?.at(0)?.url,v=o[AX]??r1(_??`https://echo.zuplo.io`),y=o[DX]===!0,b=o.deprecated===!0,x=o[OX]===!0,S=l.openApiFileModel.saveState!==Ws.unmodified,C=v.handler,w=jX(C)&&c.toUpperCase()!==`POST`?`MCP Server handler must use POST method`:void 0,T=e=>{try{l.updateOperation({path:s,method:c,newMethod:e.export===`mcpServerHandler`?`post`:void 0,newOperationObject:{...o,[AX]:{...v,handler:{...e}}}})}catch(e){u.error(e instanceof Error?e.message:`Unknown error`)}},E=e=>{l.updateOperation({path:s,method:c,newOperationObject:{...o,summary:e}})},D=e=>{l.updateOperation({path:s,method:c,newOperationObject:{...o,description:e}})},O=e=>{i(`route-visibility-changed`,{excludeFromDocs:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),l.updateOperation({path:s,method:c,newOperationObject:{...o,[DX]:e}})},k=e=>{i(`route-deprecated-changed`,{deprecated:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),l.updateOperation({path:s,method:c,newOperationObject:{...o,deprecated:e||void 0}})},A=e=>{i(`route-graphql-changed`,{graphql:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name});let n={...o};e?(n[OX]=!0,dvt(d),n[AX]=uvt(v,!0)):(delete n[OX],o[AX]&&(n[AX]=uvt(v,!1))),l.updateOperation({path:s,method:c,newOperationObject:n})},j=e=>{let{newPath:t}=e,{newMethod:n}=e;h!=null&&t==null&&(t=h);try{l.updateOperation({path:s,newPath:t,method:c,newMethod:n,newOperationObject:o}),m(void 0),g(void 0)}catch(e){e instanceof Error&&t!=null&&(g(t),m(e.message))}},M=e=>{if(e===s){m(void 0),g(void 0);return}j({newPath:e.startsWith(`/`)?e:`/${e}`})},N=e=>{let n=e;n!==c&&(i(`route-method-changed`,{httpMethod:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),j({newMethod:n}))},P=e=>{let n={...v,corsPolicy:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[AX]:n}}),i(`route-cors-changed`,{newCors:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},F=e=>{let t={...o};e.length>0?t.tags=e:delete t.tags,l.updateOperation({path:s,method:c,newOperationObject:t})},I=n=>{let a={...e.additionalOperationContext.pathZuploConfig,pathMode:n},o=l.getOpenApiDataEnforced().paths;if(!o)throw Error(`Property 'paths' is undefined`);let c=o[s];if(!c)throw Error(`Path Item '${s}' is undefined`);l.updatePathItem(s,{...c,[kX]:a}),i(`route-path-mode-changed`,{pathMode:n,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},L=()=>{n(Ws.modified)};return(0,U.jsxs)(`div`,{className:`mb-4 flex flex-col gap-6`,children:[(0,U.jsxs)(kO,{className:`bg-neutral-50 dark:bg-transparent`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,U.jsxs)(AO,{children:[(0,U.jsx)(jO,{children:`Request Handling`}),(0,U.jsx)(MO,{})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-6`,children:[x&&(0,U.jsx)(oBt,{path:s,rewriteUrl:typeof C.options?.rewritePattern==`string`?C.options?.rewritePattern:void 0}),(0,U.jsx)(FRt,{operationData:e}),(0,U.jsx)(yBt,{path:s,method:c,summary:o.summary??``,operationData:e,hasFileChanged:S,isGraphql:x})]})]}),(0,U.jsxs)(NO,{className:`grid grid-cols-1 xl:grid-cols-[max-content_1fr] gap-y-3 xl:gap-y-2 items-center gap-x-6`,children:[(0,U.jsx)(WRt,{isReadOnly:f,initialPath:s,method:c,onChangeMethod:N,pathMode:e.additionalOperationContext.pathZuploConfig?.pathMode,hasError:p!=null,onPathChange:M,onPathModeChange:I,onFieldModified:L,isMcpToolHandler:jX(C)||MX(C)}),p&&(0,U.jsx)(Sb,{"data-test":`path-error`,className:`col-span-full p-2`,variant:`destructive`,children:(0,U.jsx)(wb,{children:p})}),w&&(0,U.jsx)(Sb,{className:`col-span-full p-2 py-1`,variant:`destructive`,children:(0,U.jsxs)(wb,{"data-test":`request-handler-error`,className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{children:w}),(0,U.jsx)(X,{onClick:()=>N(`post`),size:`xs`,variant:`outline`,className:`border-none`,children:`Switch to POST method`})]})}),(0,U.jsx)(ONt,{isReadOnly:f,initialSummary:o.summary,onSummaryChange:E,onFieldModified:L}),(0,U.jsx)(IRt,{isReadOnly:f,defaultOperationId:e.operationId,openApiManager:l,path:s,method:c,operationData:e})]}),(0,U.jsxs)(PO,{className:`flex flex-wrap gap-2 px-3 py-1.5 bg-card justify-end`,children:[(0,U.jsx)(sBt,{operationTags:o.tags??[],onTagsChanged:F}),(0,U.jsx)(hLt,{isReadOnly:f,selectedCorsPolicy:v.corsPolicy,corsPolicies:d.corsPolicyList??[],onSelectionChanged:P}),!jX(v.handler)&&!MX(v.handler)&&(0,U.jsx)(VRt,{operation:e,defaultValues:SBt(v.mcp),onSubmit:e=>{let t={...v,mcp:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[AX]:t}})}}),(0,U.jsx)(uRt,{isExcludedFromDocs:y,onVisibilityChanged:O}),(0,U.jsx)(GRt,{isGraphql:x,onGraphqlChanged:A,isDeprecated:b,onDeprecatedChanged:k})]})]}),(0,U.jsx)(AIt,{inboundPolicies:v.policies?.inbound??[],outboundPolicies:v.policies?.outbound??[],operation:e,children:(0,U.jsx)(EBt,{isReadOnly:f,operationData:e,handler:v.handler,firstServerUrl:_,onRequestHandlerChange:T})}),(0,U.jsx)(lRt,{initialDescription:o.description??``,onChange:D,path:s,method:c,oasFilePath:t})]})},EBt=({operationData:e,handler:t,firstServerUrl:n,isReadOnly:r,onRequestHandlerChange:i})=>{let a=(e[AX]??r1(n??`https://echo.zuplo.io`)).handler;switch(t.export){case`mcpServerHandler`:return(0,U.jsx)(bBt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i});case`McpProxyHandler`:case`McpVirtualServerHandler`:case`mcpVirtualServerHandler`:return(0,U.jsx)(xBt,{routeHandler:a,operation:e,isReadOnly:r,onRequestHandlerChange:i});default:return(0,U.jsx)(dLt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i})}},DBt=Ae()(e=>({updateLinkedMcpServers:void 0,setUpdateLinkedMcpServers:t=>e({updateLinkedMcpServers:t})})),OBt=()=>{let e=p(DBt,e=>e.updateLinkedMcpServers),t=JZ(),n=()=>{DBt.setState({updateLinkedMcpServers:void 0})};return(0,U.jsx)(Ib,{open:!!e,onOpenChange:e=>{e||n()},children:(0,U.jsxs)(zb,{children:[(0,U.jsx)(Hb,{children:`MCP Server Links`}),(0,U.jsx)(Ub,{children:`This operation is linked to MCP servers, if you update the operation id, you need to update the MCP server links as well.`}),(0,U.jsx)(`div`,{className:`flex gap-2 items-center justify-center`,children:e?.linkedMcpServers.map(([,e])=>(0,U.jsx)(OO,{children:e},e))}),(0,U.jsxs)(Vb,{children:[(0,U.jsx)(X,{variant:`outline`,onClick:n,children:`Cancel`}),(0,U.jsx)(X,{onClick:()=>{e?.linkedMcpServers.forEach(([n,r])=>{let i=new Z_t(n,t),a=i.getOperationById(r);if(!a)return;let o=a[AX];if(!o)return;let s=o.handler;if(jX(s)){if(n.path===e.file){let t=i.getOperationById(e.oldOperationId);if(!t)throw Error(`Operation not found`);i.updateOperation({path:t.additionalOperationContext.path,method:t.additionalOperationContext.method,newOperationObject:j$(t,`operationId`,e.newOperationId)})}i.updateOperation({path:a?.additionalOperationContext.path,method:a.additionalOperationContext.method,newOperationObject:j$(a,`${AX}.handler.options.operations`,s.options?.operations?.map(t=>d1(t.file)===n.path?{...t,id:t.id===e.oldOperationId?e.newOperationId:t.id}:t))})}})},children:`Update`})]})]})})},kBt=`$import(@zuplo/runtime)`,ABt=`${kBt}::urlForwardHandler`,jBt=`${kBt}::urlRewriteHandler`,MBt=(e,t)=>{let n=e.options?.[t],r=typeof n==`string`?n.trim():``;return r.length>0?r:void 0},NBt=e=>{let t=e.trim();if(t.startsWith("${")){let e=t.indexOf(`}`);if(e!==-1)return t.slice(0,e+1)}let n=/^[a-z][a-z0-9+.-]*:\/\/[^/$?#]+/i.exec(t);if(n)return n[0];let r=t.indexOf(`/`);return r===-1?t:t.slice(0,r)},PBt=e=>{if(e){let t=`${e.module}::${e.export}`,n=t===ABt?MBt(e,`baseUrl`):t===jBt?MBt(e,`rewritePattern`):void 0;if(n){let e=NBt(n);return{key:`target:${e}`,label:e,mono:!0,icon:Wd,collapsible:!0}}}return{...uyt(e),collapsible:!1}};function FBt(){let e=t1(),{captureRaw:t}=on(),n=op(),r=GZ();return i=>{e.updateInfo(i),t(`openapi-info-updated`);let{projectTreeNodes:a,filesByPath:o}=hp.getState(),s=a.map(e=>e.path?o[e.path]:void 0).filter(e=>!!e&&e.saveState===Ws.modified);s.length!==0&&r.mutateAsync({environmentName:n.environment.name,accountName:n.account.name,projectName:n.project.name,files:s}).catch(()=>{})}}var m8=`Document Order`,IBt=[`Document Order`,`Path`,`Summary`],h8=`Untagged`,LBt=[{value:`none`,label:`None`},{value:`path`,label:`Path`},{value:`handler`,label:`Handler type`},{value:`target`,label:`Target`}],RBt=new Set([`handler`,`target`]);function zBt(e){return`${e}-${Ne().split(`-`).at(0)}`}function g8(e){return new Set(e.getPolicyListEnforced().map(e=>e.name))}function BBt(e){if(!e)return;let t=yNt(e.getPolicyListEnforced());if(t)return t.name;let n=o3(_Nt,g8(e));return e.createPolicy(vNt(n)),n}var VBt=e=>(t,n)=>{switch(e){case`Document Order`:return 0;case`Path`:return t.additionalOperationContext.path.localeCompare(n.additionalOperationContext.path);case`Summary`:return!t.summary&&!n.summary?0:!t.summary&&n.summary?1:t.summary&&!n.summary?-1:t.summary?.localeCompare(n.summary??``)??0;default:return 0}},HBt=e=>t=>{if(e.length===0)return!0;let n=t.tags;return!n||n.length===0?e.includes(h8):n.some(t=>e.includes(t))},UBt=({onNavigateToOpenApiFileTab:e})=>{let{logEvent:t,captureRaw:n}=on(),[r,i]=Lrt(`tags`,[]),[a,o]=ww(`open-api-designer-group-by`,`none`);(0,H.useEffect)(()=>{let e=window.localStorage.getItem(`open-api-designer-show-headers`);e!==null&&(e===`true`&&a===`none`&&o(`path`),window.localStorage.removeItem(`open-api-designer-show-headers`))},[a,o]);let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(`details`),[d,f]=(0,H.useState)(!1),p=FBt(),m=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)||(e.preventDefault(),m.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let[h,g]=(0,H.useState)(),[_,v]=(0,H.useState)(),[y,b]=(0,H.useState)(()=>new Set),x=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[S,C]=(0,H.useState)(()=>new Set),w=e=>C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),{isReadOnly:T}=jZ(),[E,D]=wY(`operation`),[O,k]=ww(`default-sort-routes`,m8),[A,j]=wY(`sort`,O);(0,H.useEffect)(()=>{A&&k(A)},[k,A]),(0,H.useEffectEvent)(()=>{if(E)try{document.querySelector(`#op-${E}`)?.scrollIntoView()}catch{}});let[M,N]=(0,H.useState)(void 0),P=t1(),F=g1(),I=nF(),L=YZ(dyt),R=XZ(),z=()=>{if(L)return pyt(L.content??``)?`ok`:`manual`;let e=fyt,t={path:dyt,content:e,type:Us.File,saveState:Ws.new};if(I){let n=I.Uri.file(t.path);I.editor.getModel(n)||I.editor.createModel(e,void 0,n)}return R(t),R({...t,saveState:Ws.modified}),`ok`},{results:B,setSearchTerm:ee,searchTerm:V}=Gvt(P.operationArray?.filter(HBt(r)).sort(VBt(A))??[],{keys:[e=>e.additionalOperationContext.path,e=>e.summary??``,e=>e.operationId,e=>e.additionalOperationContext.method]});(0,H.useEffect)(()=>{let e=V?.trim()??``;if(e.length===0)return;let n=setTimeout(()=>{t(`route-search-used`,{view:`routes`,query:e,queryLength:e.length})},600);return()=>clearTimeout(n)},[V,t]);let te=(()=>{let e=new Map;for(let t of B){let n,r,i,o,s;if(a===`handler`||a===`target`){let e=t[AX]?.handler,c=a===`target`?PBt(e):{...uyt(e),collapsible:!1};({key:n,label:r,mono:i,collapsible:o,icon:s}=c)}else n=t.additionalOperationContext.path,r=n,i=!0,o=!1,s=void 0;let c=e.get(n);c?c.operations.push(t):e.set(n,{key:n,label:r,mono:i,icon:s,collapsible:o,operations:[t]})}return[...e.values()]})(),[ne,re]=(0,H.useState)(),[ie,ae]=(0,H.useState)(),[oe,se]=(0,H.useState)(!1),ce=(0,H.useMemo)(()=>{if(!_)return[];let e=(P.operationArray?.find(e=>e.additionalOperationContext.path===_.path&&e.additionalOperationContext.method===_.method))?.[AX]?.policies?.inbound??[];if(e.length===0)return[];let t=new Set;for(let e of F.policyList??[]){if(e.policyType!==`composite-inbound`&&e.policyType!==`composite-outbound`)continue;let n=e.handler.options?.policies;if(n)for(let e of n)t.add(e)}let n=F.policiesUsageInfo??[];return e.map(e=>n.find(t=>t.name===e)).filter(e=>{if(!e||e.operations.length!==1)return!1;let n=e.operations[0];return!(n.additionalOperationContext.path!==_.path||n.additionalOperationContext.method!==_.method||t.has(e.name))})},[_,P.operationArray,F.policyList,F.policiesUsageInfo]),[le,ue]=(0,H.useState)(()=>new Set);(0,H.useEffect)(()=>{ue(_?new Set(ce.map(e=>e.name)):new Set)},[_]);let de=(e,t)=>{ue(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},fe=()=>{if(_==null){se(!1);return}try{for(let e of le)try{F.deletePolicy(e),t(`policy-deleted`,{policy:e})}catch{}P.deleteOperation(_.path,_.method),t(`route-deleted`,_)}catch(e){e instanceof Error&&(t(`route-deletion-failed`,_),N(e.message),pe())}v(void 0),se(!1)},[pe,me]=x$(()=>{let t=()=>{N(void 0),me()};return(0,U.jsx)(sQ,{alertType:`ERROR`,bodyText:M??``,onPrimaryButtonClick:e,onSecondaryButtonClick:t,primaryButtonText:`Edit file directly`,secondaryButtonText:`Cancel`,hideModal:t,title:`Error`})},[M]),[he,ge]=x$(()=>(0,U.jsx)(sQ,{alertType:`CAUTION`,bodyText:`Cannot reorder in this view — view by Document Order to reorganize the order of operations.`,onPrimaryButtonClick:()=>{j(m8),ge()},onSecondaryButtonClick:ge,primaryButtonText:`Switch to Document Order`,secondaryButtonText:`Cancel`,hideModal:ge,title:`Cannot reorder`})),[_e,ve]=x$(()=>(0,U.jsx)(hyt,{open:!0,onOpenChange:e=>{e||ve()}})),ye=(e,t)=>{if(A!==m8){he();return}P.movePathInDocument(e,t)};if(!P.openApiData)throw Error(`Invalid State - no OpenApiData`);let be=P.openApiData.info,xe=P.openApiData.tags?.map(e=>({value:e.name,label:e.name}));xe?.push({value:h8,label:h8});let Se=()=>{let e=c1.OpenAPIV3.HttpMethods.GET,n=P.openApiData?.servers?.at(0)?.url,r=cvt(n??`https://echo.zuplo.io`),i=`/path-${((P.operationArray?.filter(t=>t.additionalOperationContext.path.startsWith(`/path-`)&&t.additionalOperationContext.method===e)?.map(e=>parseInt(e.additionalOperationContext.path.replace(`/path-`,``),10))?.filter(e=>!Number.isNaN(e))?.sort((e,t)=>t-e))?.at(0)??0)+1}`;try{let t=P.addOperation(i,e,r);t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:i,httpMethod:e}),N(n.message),pe())}t(`route-added`)},Ce=(e,n,r)=>{let i=P.openApiData?.servers?.at(0)?.url,a=cvt(i??`https://echo.zuplo.io`),o=r?.[AX],s=a[AX];o&&s&&(o.handler&&(s.handler=JSON.parse(JSON.stringify(o.handler))),o.policies&&(s.policies=JSON.parse(JSON.stringify(o.policies))));try{let t=P.addOperation(e,n,a);t&&D(t)}catch(r){r instanceof Error&&(t(`route-add-failed`,{httpPath:e,httpMethod:n}),N(r.message),pe())}t(`route-added`)},we=()=>{let e=c1.OpenAPIV3.HttpMethods.POST,n=zBt(`mcp`),r=P.addOperation(`/mcp`,e,{summary:`MCP Server`,description:`Default MCP Server`,[AX]:{corsPolicy:`none`,handler:{export:`mcpServerHandler`,module:`$import(@zuplo/runtime)`,options:{operations:[]}},policies:{inbound:[]}},operationId:n},{avoidConflict:!0});r&&D(r),t(`route-added`)},Te=()=>{let e=c1.OpenAPIV3.HttpMethods.POST,n=fvt(`https://rickandmortyapi.com/graphql`);try{dvt(F);let t=P.addOperation(`/graphql`,e,n,{avoidConflict:!0});t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/graphql`,httpMethod:e}),N(n.message),pe())}t(`route-added`)},Ee=()=>{let e=c1.OpenAPIV3.HttpMethods.GET,n=pvt();try{let t=P.addOperation(`/websocket`,e,n,{avoidConflict:!0});t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/websocket`,httpMethod:e}),N(n.message),pe())}t(`route-added`)},[De,Oe]=(0,H.useState)(!1),[ke,Ae]=(0,H.useState)(),[je,Me]=(0,H.useState)(0),Pe=(0,H.useMemo)(()=>{let e=new Set(Object.keys(P.openApiData?.paths??{}));return ke&&e.delete(ke.path),e},[P.openApiData?.paths,ke]),Fe=async e=>{let n;try{n=z()}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}let r;try{r=xNt({result:e,policyList:F.getPolicyListEnforced(),existingOperationIds:new Set(P.operationArray?.map(e=>e.operationId)??[])});for(let e of r.policiesToCreate)F.createPolicy(e)}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}try{let e=P.addOperation(r.operationPath,r.method,r.operation,{avoidConflict:!0});e&&D(e)}catch(e){e instanceof Error&&(N(e.message),pe())}t(`route-added`),t(`mcp-gateway-create-virtual-mcp-submitted`,SNt(e)),n===`manual`&&_e()},Ie=()=>{Me(e=>e+1),Oe(!0)},Le=e=>{let t=cNt({operationPath:e.additionalOperationContext.path,operation:e,policyList:F?.getPolicyListEnforced()??[]});t&&(Me(e=>e+1),Ae({initialResult:t,path:e.additionalOperationContext.path,method:e.additionalOperationContext.method,operationId:e.operationId}))},Re=async e=>{let t=ke;if(!t)return;let{initialResult:r,path:i,method:a}=t,o=P.operationArray?.find(e=>e.additionalOperationContext.path===i&&e.additionalOperationContext.method===a);if(!o){Ae(void 0);return}let s;try{s=z()}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}let c=hNt(e.step1.name),l=W1(e.step1.mcpUrl),u=l?.protectedResourceMetadataUrl??bNt(e.step1.mcpUrl),d=o[AX]?.policies?.inbound??[],f=F?.getPolicyListEnforced()??[],p=new Map(f.map(e=>[e.name,e])),m=d.map(e=>p.get(e)).filter(e=>e!=null),h=m.find(e=>e.policyType===F4),g=m.find(e=>e.policyType===I4),_=m.find(e=>e.policyType===`remove-headers-inbound`&&L4(e.handler?.options)),v=m.find(e=>e.policyType.startsWith(`upstream-`)),y;if(e.step1.authMode===`user-oauth`){let t={id:c,displayName:e.step1.name,summary:`${e.step1.name} remote MCP server, federated via the gateway.`,...u?{protectedResourceMetadataUrl:u}:{},authMode:`user-oauth`,scopes:l?.scopes??[],clientRegistration:e.step1.clientRegistration};if(h&&F)try{F.updatePolicy(h.name,{...h,handler:{...h.handler,options:t}}),y=h.name}catch(e){if(e instanceof Error){N(e.message),pe();return}}else if(F){y=o3(`mcp-upstream-${c}`,g8(F));try{F.createPolicy({name:y,policyType:F4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpTokenExchangeInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}}}let b;if(e.step1.authMode===`upstream-policy`&&F){let{policyType:t,policyName:n,handler:r}=e.step1;try{v&&v.policyType===t?F.updatePolicy(v.name,{...v,name:n,handler:r}):F.createPolicy({name:n,policyType:t,handler:r}),b=n}catch(e){if(e instanceof Error){N(e.message),pe();return}}}let x;if(e.step2.catalogMode===`curated`){let t=k4(e.step2);if(g&&F)try{F.updatePolicy(g.name,{...g,handler:{...g.handler,options:t}}),x=g.name}catch(e){if(e instanceof Error){N(e.message),pe();return}}else if(F){x=o3(`mcp-filter-${c}`,g8(F));try{F.createPolicy({name:x,policyType:I4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpCapabilityFilterInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}}}let S;if(e.step3.authPolicyChoice===`existing`)S=e.step3.existingPolicyName;else if((e.step3.authPolicyChoice===`new`||e.step3.authPolicyChoice===`new-other`)&&(S=e.step3.newPolicyName,F))try{F.createPolicy({name:S,policyType:e.step3.policyType,handler:e.step3.handler})}catch(e){if(e instanceof Error){N(e.message),pe();return}}let C;if(e.step1.authMode===`none`&&e.step1.noAuthBehavior===`strip`)try{C=_?.name??BBt(F)}catch(e){if(e instanceof Error){N(e.message),pe();return}}let w=[S,x,y,b,C].filter(e=>!!e),T=o[AX],E=T?.handler;try{P.updateOperation({path:i,method:a,newOperationObject:{...o,summary:e.step1.name,description:`MCP Virtual Server fronted by the gateway (${e.step1.mcpUrl})`,[AX]:{...T??{},handler:{...E??{export:`McpProxyHandler`,module:`$import(@zuplo/runtime/mcp-gateway)`},options:{...E?.options??{},rewritePattern:e.step1.mcpUrl}},policies:{...T?.policies??{},inbound:w}}}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}let D;try{D=new URL(e.step1.mcpUrl).hostname}catch{D=void 0}n(`mcp-gateway-edit-virtual-mcp-submitted`,{upstreamHost:D,upstreamAuthMode:e.step1.authMode,previousUpstreamAuthMode:r.step1.authMode,inboundAuthChoice:e.step3.authPolicyChoice,previousInboundAuthChoice:r.step3.authPolicyChoice}),Ae(void 0),s===`manual`&&_e()},ze=(0,H.useMemo)(()=>E?B.find(e=>e.operationId===E)||B.find(e=>h?.path===e.additionalOperationContext.path&&h?.method===e.additionalOperationContext.method):void 0,[B,E,h]);(0,H.useEffect)(()=>{ze&&!h&&g({path:ze.additionalOperationContext.path,method:ze.additionalOperationContext.method})},[ze,h]);let Be=(e,n,r)=>{let i=(e,t)=>{let n=e.replace(/-duplicate(-\d+)?$/,``),r=`${n}-duplicate`,i=2;for(;t(r);)r=`${n}-duplicate-${i}`,i++;return r},a=P.operationArray??[],o=i(e,e=>a.some(t=>t.additionalOperationContext.path===e&&t.additionalOperationContext.method===n)),s=i(r.operationId??`op-${Ne().slice(0,4)}`,e=>a.some(t=>t.operationId===e)),c=JSON.parse(JSON.stringify(r));c.operationId=s;try{let e=P.addOperation(o,n,c);e&&D(e)}catch(e){e instanceof Error&&(t(`route-add-failed`,{httpPath:o,httpMethod:n}),N(e.message),pe())}t(`route-added`,{httpPath:o,httpMethod:n,duplicate:!0})},Ve=()=>{f(!0),u(`tags`),c(!0)},He=ke!==void 0,Ue=(0,U.jsx)(lNt,{isOpen:De||He,existingPaths:Pe,mode:He?`edit`:`create`,initialResult:ke?.initialResult,onClose:()=>{Oe(!1),Ae(void 0)},onFinish:He?Re:Fe},`mcp-wizard-${je}`),We={onAddRest:Se,onAddGraphql:Te,onAddWebSocket:Ee,onAddMcpVirtual:Ie,onAddMcpServer:we,onAddTag:Ve};return P.operationArray?.length===0&&(!V||V.trim().length===0)?(0,U.jsxs)(U.Fragment,{children:[Ue,(0,U.jsx)(Dvt,{...We})]}):(0,U.jsxs)(`div`,{className:`ms-2 grid grid-cols-3 h-full grow`,children:[(0,U.jsx)(v$,{open:oe,onOpenChange:e=>{se(e),e||v(void 0)},onClickDelete:fe,title:`Delete`,deleteButtonText:`Confirm`,children:ce.length===0?`Are you sure you want to delete this operation?`:(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{children:[`The following`,` `,ce.length===1?`policy is`:`policies are`,` `,`used only by this route. Would you like to delete`,` `,ce.length===1?`it`:`them`,` `,`too?`]}),(0,U.jsx)(`ul`,{className:`flex flex-col divide-y divide-border max-h-[40vh] overflow-y-auto rounded-md border bg-surface-sunken`,children:ce.map(e=>{let t=`delete-policy-${e.name}`;return(0,U.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2`,children:[(0,U.jsx)(IY,{id:t,checked:le.has(e.name),onCheckedChange:t=>de(e.name,t===!0),className:`mt-0.5`}),(0,U.jsxs)(`label`,{htmlFor:t,className:`flex flex-col gap-0.5 text-left cursor-pointer min-w-0`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.name}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e.policyType})]})]},e.name)})})]})}),(0,U.jsx)(OBt,{}),Ue,be&&(0,U.jsx)(ENt,{open:s,onOpenChange:c,info:be,onSave:p,defaultTab:l,tagsAutoCreate:d,onTagsAutoCreateConsumed:()=>f(!1)}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 justify-start h-full pt-2 min-h-0`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between gap-x-2`,children:[(0,U.jsx)(`div`,{className:`flex gap-1`,children:(0,U.jsxs)(aJ,{children:[(0,U.jsx)(oJ,{className:`flex group select-none`,asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,title:`Filter and sort routes`,children:[(0,U.jsx)(Vd,{size:16}),`Filter`]})}),(0,U.jsxs)(sJ,{className:`min-w-[220px]`,align:`start`,children:[(0,U.jsx)(dJ,{children:`Sort by`}),(0,U.jsx)(cJ,{children:IBt.map(e=>(0,U.jsxs)(lJ,{onClick:()=>j(e),className:`justify-between`,children:[e,(0,U.jsx)(td,{className:W(`mr-2`,e!==A&&`invisible`),size:16})]},e))}),(0,U.jsx)(fJ,{}),(0,U.jsx)(dJ,{children:`Filter by tag`}),(0,U.jsx)(cJ,{className:`max-h-60 overflow-y-auto`,children:xe?.map(e=>(0,U.jsxs)(lJ,{onClick:t=>{t.stopPropagation(),t.preventDefault(),r.includes(e.value)?i(r.filter(t=>t!==e.value)):i([...r,e.value])},className:`justify-between`,children:[e.label,(0,U.jsx)(td,{className:W(`mr-2`,!r.includes(e.value)&&`invisible`),size:18})]},e.label))}),(0,U.jsx)(fJ,{}),(0,U.jsx)(dJ,{children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(wee,{size:16}),`Group by`]})}),(0,U.jsx)(cJ,{children:LBt.map(e=>(0,U.jsxs)(lJ,{onClick:t=>{t.stopPropagation(),t.preventDefault(),o(e.value)},className:`justify-between`,children:[e.label,(0,U.jsx)(td,{className:W(`mr-2`,a!==e.value&&`invisible`),size:16})]},e.value))})]})]})}),T?null:(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>{f(!1),u(`details`),c(!0)},"aria-label":`API Settings`,title:`API Settings`,children:(0,U.jsx)(pf,{size:16})}),(0,U.jsxs)(aJ,{children:[(0,U.jsx)(oJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,"data-test":`add-route-btn`,className:`relative gap-0.5!`,children:[(0,U.jsx)(`div`,{className:`absolute w-1.5 h-1.5 rounded-full -top-0.5 -right-[3px] bg-zuplo-700`}),(0,U.jsx)(hf,{"aria-hidden":`true`,className:`size-3.5`}),`Add`]})}),(0,U.jsx)(sJ,{children:(0,U.jsx)(Evt,{...We})})]})]})]}),(0,U.jsx)(jY,{onClearValue:()=>ee(``),value:V,showClearButton:!!V&&V.length>0,children:(0,U.jsx)(XP,{ref:m,value:V,onChange:e=>ee(e.target.value),placeholder:`Search Routes`,className:`px-8`})}),r.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,U.jsxs)(`div`,{className:`group flex items-center gap-1 max-w-full pl-1.5 pr-0.5 py-0.5 rounded-full border border-border bg-card text-xs text-foreground`,children:[(0,U.jsx)(If,{size:11,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e} filter`,onClick:t=>{t.stopPropagation(),i(r.filter(t=>t!==e))},className:`shrink-0 size-4 rounded-full flex items-center justify-center text-muted-foreground hover:bg-neutral-200 dark:hover:bg-neutral-700 hover:text-neutral-900 dark:hover:text-foreground`,children:(0,U.jsx)(Kf,{size:11})})]},e))}),(0,U.jsx)(`div`,{className:`overflow-y-auto space-y-1`,children:te.map((e,t,n)=>{let r=!e.collapsible||S.has(e.key),i=e.operations.length,o=e.icon,s=(0,U.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-background px-1.5 py-0.5 text-xs font-normal tabular-nums text-muted-foreground`,children:i});return(0,U.jsxs)(`div`,{children:[e.collapsible?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>w(e.key),"aria-expanded":r,className:`mt-3 mb-1 flex w-full items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-left text-sm font-semibold text-foreground transition-colors first:mt-1 hover:bg-muted`,title:r?`Collapse ${e.label}`:`Expand ${e.label} (${i} ${i===1?`route`:`routes`})`,children:[r?(0,U.jsx)(nd,{size:15,className:`shrink-0 text-muted-foreground`}):(0,U.jsx)(rd,{size:15,className:`shrink-0 text-muted-foreground`}),o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate font-mono`,title:e.label,children:e.label}),s]}):a!==`none`&&(0,U.jsxs)(`div`,{className:`mt-3 mb-1 flex items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-sm font-semibold text-foreground first:mt-1`,children:[o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:W(`truncate`,e.mono&&`font-mono`),title:e.label,children:e.label}),s]}),r&&e.operations.map(({additionalOperationContext:e,...r})=>{let i=ze?.operationId===r.operationId,o=r[AX]?.handler,s=jX(o),c=MX(o),l=s?o.options?.operations?.length??0:0,u=l>0,d=y.has(r.operationId);return(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(Qvt,{path:i&&ne?ne:e.path,type:c?`mcp-virtual`:s?`mcp`:`route`,method:e.method,summary:i&&ie?ie:r.summary,operationId:r.operationId,operation:r,isSelected:i,onOperationSelected:t=>{re(``),ae(``),g({path:e.path,method:e.method}),D(t)},onDelete:(e,t,n)=>{v({path:e,method:t,operationId:n}),se(!0)},onAddRoute:Ce,onDuplicate:()=>Be(e.path,e.method,r),onMoveUp:RBt.has(a)?void 0:()=>ye(e.path,`up`),onMoveDown:RBt.has(a)?void 0:()=>ye(e.path,`down`),isFirstPath:A===m8&&t===0,isLastPath:A===m8&&t===n.length-1,isToolsExpanded:u?d:void 0,onToggleTools:u?()=>x(r.operationId):void 0,toolsCount:u?l:void 0}),o&&u&&d&&(0,U.jsx)(byt,{handler:o,operation:{...r,additionalOperationContext:e}})]},r.operationId)})]},e.key)})})]}),(0,U.jsx)(`div`,{className:`col-span-2 flex flex-col h-full overflow-y-auto`,children:(0,U.jsx)(s3.Provider,{value:{setPath:re,setSummary:ae},children:(0,U.jsx)(xyt.Provider,{value:Le,children:(0,U.jsx)(CBt,{operationData:ze,addRouteMenuProps:We})})})})]})},WBt={create:{shell:`bg-emerald-500/8 shadow-emerald-950/5`,icon:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`,count:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`},update:{shell:`bg-brand/8 shadow-brand/5`,icon:`bg-brand/12 text-brand`,count:`bg-brand/12 text-brand`},keep:{shell:`bg-background shadow-black/5 dark:shadow-white/5`,icon:`bg-muted text-muted-foreground`,count:`bg-muted text-muted-foreground`}},_8=({icon:e,operations:t,title:n,tone:r})=>{let i=WBt[r];return(0,U.jsxs)(`section`,{className:`rounded-2xl p-4 shadow-sm ${i.shell}`,"aria-label":`${n} operations`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 font-semibold text-foreground`,children:[(0,U.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-xl ${i.icon}`,children:e}),n,` operations`]}),(0,U.jsx)(`div`,{className:`rounded-full px-2.5 py-1 text-xs font-medium tabular-nums ${i.count}`,children:t.size})]}),(0,U.jsx)(`div`,{className:`space-y-1.5`,children:Array.from(t).map(e=>{let t=e.split(`>`),n=t[0],r=t.slice(1,t.length).join(`>`);return(0,U.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 rounded-xl bg-background/80 px-3 py-2 text-sm shadow-xs`,children:[(0,U.jsx)(MY,{className:`w-14`,method:n}),(0,U.jsx)(`span`,{className:`break-all text-foreground/90`,children:r})]},e)})})]})},GBt=({openApiFileModel:e,onOpenApiFileSynced:t,setIsOpen:n})=>{let[r,i]=(0,H.useState)(),a=ip(),o=e=>{i(e)},s=async()=>{if(!r)throw Error(`No file selected`);let i=e.content?JSON.parse(e.content):null;t(i?Eut(i,r.content):r.content),n(!1),a.success(`OpenAPI file merged successfully`,{icon:(0,U.jsx)(epe,{className:`h-4 w-4`})})};if(r){let t=jut(JSON.parse(e.content??`{}`),r.content);return(0,U.jsx)(a1,{isOpen:!0,setIsOpen:n,title:`Review OpenAPI import`,className:`sm:max-w-4xl max-h-[88vh] overflow-y-auto`,icon:(0,U.jsx)(Yy,{className:`shrink-0 h-6 w-6 text-brand`}),iconStyle:`bg-zuplo-pink/10`,buttons:[{onButtonClick:()=>{n(!1)},variant:`outline`,buttonContent:`Cancel`,id:`Close merge open-api modal`,testID:`merge-cancel-btn`},{onButtonClick:s,variant:`brand`,buttonContent:`Import changes`,id:`Complete open-api merge`,testID:`complete-merge-btn`}],bodyComponent:(0,U.jsxs)(`div`,{className:`mt-6 text-left text-sm`,children:[(0,U.jsx)(`div`,{className:`overflow-hidden rounded-3xl bg-gradient-to-br from-brand/12 via-background to-background p-px shadow-lg shadow-brand/5`,children:(0,U.jsxs)(`div`,{className:`rounded-[calc(1.5rem-1px)] bg-background p-5`,children:[(0,U.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[1fr_auto_1fr] md:items-center`,children:[(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-brand/10 text-brand`,children:(0,U.jsx)(Tpe,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Import file`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:r.name})]})]})}),(0,U.jsx)(`div`,{className:`hidden h-10 w-10 items-center justify-center rounded-full bg-brand text-brand-foreground shadow-sm shadow-brand/24 md:flex`,children:(0,U.jsx)(Yy,{className:`h-5 w-5`})}),(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,children:(0,U.jsx)(tb,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Current API`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:e.path})]})]})})]}),(0,U.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2 text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:`Operations are matched by`}),(0,U.jsx)(OO,{variant:`outline`,children:`Path + method`}),(0,U.jsx)(`span`,{children:`so existing Zuplo extensions and policies stay in place.`})]})]})}),(0,U.jsxs)(`div`,{className:`mt-6 flex items-end justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:`Import summary`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Review what will change before applying this file.`})]}),(0,U.jsxs)(`div`,{className:`rounded-full bg-surface-sunken px-3 py-1 text-xs font-medium text-muted-foreground tabular-nums`,children:[t.created.size+t.merged.size+t.retained.size,` `,`operations`]})]}),(0,U.jsxs)(`div`,{className:`mt-3 grid max-h-96 gap-3 overflow-y-auto rounded-3xl bg-surface-sunken p-3 shadow-[inset_0_1px_rgba(255,255,255,0.04)]`,children:[t.created.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(Gpe,{className:`h-4 w-4`}),title:`Create`,tone:`create`,operations:t.created}):null,t.merged.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(Hpe,{className:`h-4 w-4`}),title:`Update`,tone:`update`,operations:t.merged}):null,t.retained.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(tpe,{className:`h-4 w-4`}),title:`Keep`,tone:`keep`,operations:t.retained}):null]})]})})}return(0,U.jsx)(bvt,{title:`Import OpenAPI`,onValidFileSelected:o,setIsOpen:n})},KBt=()=>{let e=Dt(),t=je({mutationFn:t=>e.fetch(tn.users.updatePreferences(t))}),{data:n}=qb(mt.user.preferences());return{preferences:n,updatePreferences:t.mutate,updatePreferencesMutation:t}},qBt=!1;function v8(){let e=at(),{preferences:t,updatePreferencesMutation:n}=KBt();return{isFileTreeOpen:t.fileTreeOpen??qBt,setIsFileTreeOpen:r=>{let i=[mt.user.preferences().url,!0],a=e.getQueryData(i),o={...a??t,fileTreeOpen:r};e.setQueryData(i,o),n.mutate(o,{onError:()=>{a&&e.setQueryData(i,a),e.invalidateQueries({queryKey:i})}})}}}function JBt(){let e=qZ(),{logEvent:t}=on(),[n,r]=wY(`v`,`designer`),{isFileTreeOpen:i}=v8(),a=e?.path.split(`/`).pop()??`JSON`,o=JZ(),s=Svt(),[c,l]=x$(()=>{if(!e)throw Error(`File model not found`);return t(`merge-open-api`),(0,U.jsx)(GBt,{openApiFileModel:e,onOpenApiFileSynced:n=>{let r={...e,content:JSON.stringify(n,null,2)};o(r,!0),t(`merge-open-api-complete`),s(r.path)},setIsOpen:l})},[e,s]);return(0,U.jsx)(nyt,{children:(0,U.jsx)($_t,{children:(0,U.jsxs)(Sk,{defaultValue:`designer`,value:n,onValueChange:e=>r(e),className:`flex flex-col h-full w-full max-h-screen min-w-[850px]`,children:[i&&(0,U.jsxs)(Ck,{className:`rounded-none border-b w-full justify-start`,children:[(0,U.jsx)(wk,{value:`designer`,children:`Route Designer`}),(0,U.jsx)(wk,{value:`raw`,children:a??`Raw`}),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,onClick:c,className:`ml-4`,children:[(0,U.jsx)($pe,{className:`w-4 h-4`}),` Import`]})]}),(0,U.jsx)(Tk,{value:`designer`,className:`grow h-full overflow-y-auto`,children:(0,U.jsx)(svt,{onNavigateToOpenApiFileTab:()=>r(`raw`),children:(0,U.jsx)(UBt,{onNavigateToOpenApiFileTab:()=>r(`raw`)})})}),(0,U.jsx)(Tk,{value:`raw`,className:`grow h-full overflow-y-auto`,forceMount:!0,children:(0,U.jsx)(oQ,{})})]})})})}function YBt({title:e,description:t,folder:n,icon:r,emptyText:i,newLabel:a,onCreate:o}){let s=hp(e=>e.projectTreeNodes),[c,l]=Ms(),{isReadOnly:u}=jZ(),d=n.endsWith(`/`)?n:`${n}/`,f=(0,H.useMemo)(()=>s.filter(e=>e.type===Us.File&&e.path.startsWith(d)).sort((e,t)=>e.path.localeCompare(t.path)),[s,d]),p=e=>{let t=new URLSearchParams(c);t.set(`path`,e),t.delete(`v`),t.delete(`line`),l(t)};return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:e}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:t})]}),!u&&(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,onClick:o,className:`shrink-0`,children:[(0,U.jsx)(hf,{className:`size-4`}),a]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:f.length===0?(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:i}):f.map(e=>{let t=e.path.slice(d.length);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:W(`group flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors`,`bg-surface hover:border-brand/40 hover:bg-brand/5`,`ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`),children:[(0,U.jsx)(r,{className:`size-4 shrink-0 text-neutral-500 group-hover:text-brand`}),(0,U.jsx)(`span`,{className:`truncate text-sm font-medium text-neutral-800 dark:text-neutral-200`,children:t})]},e.path)})})]})})}function XBt(){let e=hp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=v8();return(0,U.jsx)(YBt,{title:`Custom Modules`,description:`TypeScript modules in your project's modules/ folder — request handlers, policies, and other custom code.`,folder:`/modules`,icon:uf,emptyText:`No custom modules yet. Create one to add request handlers or custom logic.`,newLabel:`New Module`,onCreate:()=>{t(!0),e({strategyFolder:`/modules`,template:`Request Handler`})}})}function ZBt(){let e=hp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=v8();return(0,U.jsx)(YBt,{title:`Schemas`,description:`JSON schemas in your project's schemas/ folder, used to validate requests and responses.`,folder:`/schemas`,icon:jd,emptyText:`No schemas yet. Create one to validate request or response bodies.`,newLabel:`New Schema`,onCreate:()=>{t(!0),e({strategyFolder:`/schemas`,template:`Schema`})}})}var QBt=()=>{let[e,t]=(0,H.useState)(),{isReadOnly:n}=jZ(),r=g1(),i=r.policiesUsageInfo,{logEvent:a}=on(),o=op([`account`,`project`,`environment`]),[s,c]=x$(()=>e?(0,U.jsx)(DIt,{isOpen:!0,setIsOpen:c,stackType:e,shouldHideExistingPolicies:!0,policyManager:r}):null,[e]),l=e=>{t(e),a(`create-policy-clicked`,{account:o.account.name,project:o.project.name,environment:o.environment.name,type:e}),s()},u=(r.policyList??[]).flatMap(e=>i?.find(t=>t.name===e.name)??[]);return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:`Policies`}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:`Reusable policies from your project's config/policies.json — apply them to routes to inspect and control requests and responses.`})]}),!n&&(0,U.jsxs)(aJ,{modal:!1,children:[(0,U.jsx)(oJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,className:`shrink-0`,children:[(0,U.jsx)(hf,{className:`size-4`}),`New Policy`]})}),(0,U.jsxs)(sJ,{align:`end`,children:[(0,U.jsxs)(lJ,{onClick:()=>l(`inbound`),children:[(0,U.jsx)(Iu,{className:`mr-2 size-4`}),`Inbound Policy`]}),(0,U.jsxs)(lJ,{onClick:()=>l(`outbound`),children:[(0,U.jsx)(zu,{className:`mr-2 size-4`}),`Outbound Policy`]})]})]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:u.length===0?(0,U.jsxs)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:[`No policies yet. Create an inbound or outbound policy to inspect and control requests and responses, or`,` `,(0,U.jsx)(Rw,{href:`https://zuplo.com/docs/overview/policies`,children:`read the docs`}),`.`]}):u.map(e=>(0,U.jsx)(bIt,{policy:e},e.name))})]})})},$Bt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DeploymentLogState=void 0;var t;(function(e){e.ERROR=`ERROR`,e.IN_PROGRESS=`IN_PROGRESS`,e.SUCCESS=`SUCCESS`})(t||(e.DeploymentLogState=t={}))})),eVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SourceControlProvider=e.PlanType=e.EnvironmentType=e.EnvironmentTarget=e.DeploymentState=void 0;var t;(function(e){e[e.IS_STARTING=0]=`IS_STARTING`,e[e.STARTED=1]=`STARTED`,e[e.STOPPED=2]=`STOPPED`,e[e.ERRORED=3]=`ERRORED`})(t||(e.DeploymentState=t={}));var n;(function(e){e.CLOUDFLARE=`CLOUDFLARE`,e.KNATIVE=`KNATIVE`})(n||(e.EnvironmentTarget=n={}));var r;(function(e){e.PRODUCTION=`PRODUCTION`,e.PREVIEW=`PREVIEW`,e.WORKING_COPY=`WORKING_COPY`})(r||(e.EnvironmentType=r={}));var i;(function(e){e.FREE_V1=`FREE_V1`,e.BUILDER_V1=`BUILDER_V1`,e.BUSINESS_V1=`BUSINESS_V1`,e.CUSTOM=`CUSTOM`,e.EMPLOYEE=`EMPLOYEE`,e.CUSTOM_TRIAL_V1=`CUSTOM_TRIAL_V1`})(i||(e.PlanType=i={}));var a;(function(e){e.GITHUB=`GITHUB`,e.GITLAB=`GITLAB`,e.BITBUCKET=`BITBUCKET`})(a||(e.SourceControlProvider=a={}))})),tVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),nVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.INTERNAL_ROUTE_VENDOR_TAG=e.ZUPLO_OPEN_API_ROUTE_KEY=e.ZUPLO_OPEN_API_PATH_KEY=e.ZUPLO_OPEN_API_VENDOR_PREFIX=void 0,e.ZUPLO_OPEN_API_VENDOR_PREFIX=`x-zuplo`,e.ZUPLO_OPEN_API_PATH_KEY=`${e.ZUPLO_OPEN_API_VENDOR_PREFIX}-path`,e.ZUPLO_OPEN_API_ROUTE_KEY=`${e.ZUPLO_OPEN_API_VENDOR_PREFIX}-route`,e.INTERNAL_ROUTE_VENDOR_TAG=`x-internal`})),rVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.processJsonErrorObject=void 0;var t={'must match pattern "^[0-9a-z-]+$"':`Value must be alphanumeric or dash '-' only`,'must match pattern "^\\$import\\([^ )]*?\\)$"':`Value must be of form '$import(./path/to/module)`},n={'must match pattern "^[0-9a-z-]+$"':`Make sure the value uses only lowercase letters, numbers and dashes ('-').`,'must match pattern "^\\$import\\([^ )]*?\\)$"':`Value must be of form '$import(./path/to/module)`},r=e=>e.replace(`/`,``).replaceAll(`/`,` → `).replaceAll(`~1`,`/`),i={paths:`paths`};function a(e,a){let o=e.message,s=e.details?.property??``,c=e.details?.index??0,l=e.details?.field,u=e.details?.fieldValue,d=e.keyword,f=e.params,p=e.propertyName,m=r(e.instancePath),h=t[o]??o,g,_;if(d===`unevaluatedProperties`)g=`Unrecognized property '${f.unevaluatedProperty}'${l?` detected in '${l}'`:``} within '${a}'. Property location: ${m}.`;else if(d===`additionalProperties`)g=`Unrecognized property '${f.additionalProperty}'${l?` detected in '${l}'`:``} within '${a}'. Property location: ${m}.`;else if(d===`enum`)g=`Unrecognized value${u?` '${u}'`:``} for '${l}' detected in '${a}'. Value ${h}. Property location: ${m}.`;else if(d===`pattern`){let e=f.pattern;g=p?`Property name '${p}' does not match pattern ${e} in '${a}'. Property location: ${m}.`:`Invalid value '${u}' for field '${l}' in '${a}'. Value does not match pattern ${e}. Property location: ${m}.`}else d===`propertyNames`?g=`Invalid property name '${f.propertyName}' for property '${s}' detected in '${a}'. Property location: ${m}.`:d===`required`?g=`Missing required property '${f.missingProperty}' in '${a}'. Property location: ${m}.`:l&&s?(g=`Property ${i[s]} entry at position ${c+1} in '${a}' has invalid ${l} with value '${e.details?.fieldValue}' (${h})`,_={field:l,fieldValue:e.details?.fieldValue??``,property:s,instancePath:m,suggestion:n[o]??``}):g=s?`The ${i[s]} entry at position ${c+1} in '${a}' is invalid (${h})`:`The '${a}' configuration is invalid (${h})`;return{property:s,entry:{message:g,index:c,field:l,details:_}}}e.processJsonErrorObject=a})),iVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.startsWithReservedKeyword=void 0;var t=[`settings`,`user`,`manage`,`profile`,`login`,`logout`,`admin`,`system`,`account`,`accounts`,`home`,`dashboard`];function n(e){return t.filter(t=>e.startsWith(t)).length>0}e.startsWithReservedKeyword=n})),aVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isValidProjectName=e.MAX_PRETTY_BRANCH_LENGTH=e.MAX_HASH_LENGTH=void 0;var t=iVt();e.MAX_HASH_LENGTH=7,e.MAX_PRETTY_BRANCH_LENGTH=10;var n=40;function r(e){let r={isValid:!0};return e.length===0?(r.isValid=!1,r.errorMessage=`Project name cannot be empty`,r):(0,t.startsWithReservedKeyword)(e)?(r.isValid=!1,r.errorMessage=`Project name can not start with a reserved keyword`,r):/[\s]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name can't contain spaces`,r):/[A-Z]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should be in lowercase`,r):/^[^a-z]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should start with a letter`,r):/[^a-z0-9]$/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should end with a letter or number`,r):/[^a-z0-9\\-]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name only can contain letter, numbers and dashes`,r):(e.length>n&&(r.isValid=!1,r.errorMessage=`Project name cannot exceed ${n} characters because it needs to be part of the URL subdomain. Your chosen name is ${e.length-n} over.`),r)}e.isValidProjectName=r})),oVt=i({$defs:()=>w8,$id:()=>b8,$schema:()=>y8,additionalProperties:()=>!1,default:()=>sVt,description:()=>``,properties:()=>T8,required:()=>C8,title:()=>x8,type:()=>S8}),y8,b8,x8,S8,C8,w8,T8,sVt,cVt=n((()=>{y8=`https://json-schema.org/draft/2020-12/schema`,b8=`http://schemas.zuplo.com/route.json`,x8=`Route Config File`,S8=`object`,C8=[`routes`,`versions`],w8={corsPolicy:{type:`string`,pattern:`^[0-9a-z-]+$`},httpMethod:{type:`string`,enum:[`GET`,`HEAD`,`POST`,`PUT`,`DELETE`,`CONNECT`,`OPTIONS`,`TRACE`,`PATCH`]},handlerDefinition:{type:`object`,properties:{module:{type:`string`,pattern:`^\\$import\\([^ )]*?\\)$`},export:{type:`string`},options:{type:`object`,additionalProperties:!0}},additionalProperties:!1,required:[`module`,`export`]},schema:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:[`object`,`boolean`]},parameterBaseObject:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:`object`,properties:{description:{type:`string`},required:{default:!1,type:`boolean`},deprecated:{default:!1,type:`boolean`},schema:{$ref:`#/$defs/schema`}},required:[`schema`]},parameterDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#parameter-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,properties:{name:{type:`string`},in:{type:`string`,enum:[`query`,`header`,`path`,`cookie`]}},required:[`name`,`in`,`schema`],if:{type:`object`,properties:{in:{const:`query`}},required:[`in`]},then:{type:`object`,properties:{allowEmptyValue:{default:!1,type:`boolean`}}}},"media-type":{$comment:`https://spec.openapis.org/oas/v3.1.0#media-type-object`,type:`object`,properties:{schema:{$ref:`#/$defs/schema`}},unevaluatedProperties:!1},content:{$comment:`https://spec.openapis.org/oas/v3.1.0#fixed-fields-10`,type:`object`,additionalProperties:{$ref:`#/$defs/media-type`},propertyNames:{enum:[`application/json`,`application/problem+json`]}},header:{$comment:`https://spec.openapis.org/oas/v3.1.0#header-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,required:[`schema`]},response:{$comment:`https://spec.openapis.org/oas/v3.1.0#response-object`,type:`object`,properties:{description:{type:`string`},headers:{type:`object`,additionalProperties:{$ref:`#/$defs/header`}},content:{$ref:`#/$defs/content`}},required:[`description`],unevaluatedProperties:!1},responsesDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#responses-object`,type:`object`,properties:{default:{$ref:`#/$defs/response`}},patternProperties:{"^[1-5](?:[0-9]{2}|XX)$":{$ref:`#/$defs/response`}},minProperties:1,unevaluatedProperties:!1},tag:{$comment:`https://spec.openapis.org/oas/v3.1.0#tag-object`,type:`object`,properties:{name:{type:`string`},description:{type:`string`}},required:[`name`],unevaluatedProperties:!1},info:{type:`object`,required:[`title`,`version`],properties:{title:{type:`string`},summary:{type:`string`},description:{type:`string`},termsOfService:{type:`string`,format:`uri`},version:{type:`string`}}},versionData:{type:`object`,required:[`name`,`pathPrefix`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},pathPrefix:{type:`string`,pattern:`(^$|^/[^\\s]*$)`},info:{$ref:`#/$defs/info`},openApiFile:{description:`The project relative path to the OpenAPI spec.`,type:`string`},tags:{type:`array`,items:{$ref:`#/$defs/tag`}},excludeFromOpenApi:{type:`boolean`,description:`If false, OpenAPI documentation will not be generated for this version. If openApiFile is set this setting is ignored.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`}}},routeConfiguration:{type:`object`,required:[`path`,`methods`,`handler`,`version`],additionalProperties:!1,properties:{operationId:{type:`string`},path:{type:`string`,pattern:`^/[^\\s]*$`},methods:{type:`array`,items:{$ref:`#/$defs/httpMethod`}},label:{type:`string`,description:`An internal user-friendly identifier of the route.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`},key:{type:`string`,deprecated:!0},handler:{$ref:`#/$defs/handlerDefinition`},corsPolicy:{$ref:`#/$defs/corsPolicy`},custom:{},version:{type:`string`,pattern:`^[0-9a-z-]+$`},policies:{type:`object`,additionalProperties:!1,properties:{inbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}},outbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}}}},summary:{type:`string`},description:{type:`string`},parameters:{type:`array`,items:{$ref:`#/$defs/parameterDefinition`}},excludeFromOpenApi:{type:`boolean`},responses:{$ref:`#/$defs/responsesDefinition`},tags:{type:`array`,items:{type:`string`}}}},policyConfiguration:{type:`object`,required:[`name`,`policyType`,`handler`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},policyType:{type:`string`},handler:{$ref:`#/$defs/handlerDefinition`},options:{type:`object`,additionalProperties:!0}}},corsPolicyConfiguration:{type:`object`,required:[`name`,`allowedOrigins`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},allowCredentials:{type:`boolean`},maxAge:{type:`number`},allowedOrigins:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},allowedMethods:{oneOf:[{type:`array`,items:{$ref:`#/$defs/httpMethod`}},{type:`string`}]},allowedHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},exposeHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]}}}},T8={$schema:{type:`string`},info:{$ref:`#/$defs/info`,deprecated:!0},versions:{type:`array`,minItems:1,items:{$ref:`#/$defs/versionData`}},routes:{type:`array`,minItems:0,items:{$ref:`#/$defs/routeConfiguration`}},policies:{type:`array`,items:{$ref:`#/$defs/policyConfiguration`}},corsPolicies:{type:`array`,items:{$ref:`#/$defs/corsPolicyConfiguration`}},requestErrorHandler:{$ref:`#/$defs/handlerDefinition`}},sVt={$schema:y8,$id:b8,title:x8,description:``,type:S8,additionalProperties:!1,required:C8,$defs:w8,properties:T8}})),lVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c,l),"date-time":t(d,f),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:h,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:w,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:_,int32:{type:`number`,validate:b},int64:{type:`number`,validate:x},float:{type:`number`,validate:S},double:{type:`number`,validate:S},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,f),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function c(e,t){let n=s.exec(e);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[5];return(r<=23&&i<=59&&a<=59||r===23&&i===59&&a===60)&&(!t||o!==``)}function l(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3]+(n[4]||``),t=r[1]+r[2]+r[3]+(r[4]||``),e>t?1:e<t?-1:0}var u=/t|\s/i;function d(e){let t=e.split(u);return t.length===2&&a(t[0])&&c(t[1],!0)}function f(e,t){if(!(e&&t))return;let[n,r]=e.split(u),[i,a]=t.split(u),s=o(n,i);if(s!==void 0)return s||l(r,a)}var p=/\/|:/,m=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function h(e){return p.test(e)&&m.test(e)}var g=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function _(e){return g.lastIndex=0,g.test(e)}var v=-(2**31),y=2**31-1;function b(e){return Number.isInteger(e)&&e<=y&&e>=v}function x(e){return Number.isInteger(e)}function S(){return!0}var C=/[^\\]\\Z/;function w(e){if(C.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),E8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),uVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=E8(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r=e.UsedValueState||={}),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),D8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=E8(),n=uVt(),r=E8();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=uVt();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
1565
|
+
`}var d8=`/docs/schema.graphql`,rBt=()=>JSON.stringify({query:Rzt()}),iBt=e=>{if(!e)throw Error(`The endpoint returned an empty response.`);let t;try{t=JSON.parse(e)}catch{throw Error(`The endpoint did not return a valid JSON response.`)}if(t.errors?.length)throw Error(`The introspection query returned errors: ${t.errors.map(e=>e.message).join(`; `)}`);if(!t.data?.__schema)throw Error(`The endpoint did not return an introspection result. Make sure introspection is enabled.`);try{return`${Bzt(zzt(t.data))}\n`}catch(e){throw Error(`Could not build a schema from the introspection result: ${e instanceof Error?e.message:String(e)}`)}},aBt=({endpointUrl:e,rewriteUrl:t,ape:n,onClose:r})=>{let{logEvent:i}=on(),a=ip(),o=UZ(),s=HR(),[c,l]=(0,H.useState)(t??e),[u,d]=(0,H.useState)([{key:``,value:``}]),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(),g=(e,t,n)=>{d(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},_=()=>d(e=>[...e,{key:``,value:``}]),v=e=>d(t=>t.filter((t,n)=>n!==e)),y=async()=>{h(void 0),p(!0);let l=c===t?`handler`:c===e?`gateway`:`custom`,d={account:n.account.name,project:n.project.name,environment:n.environment.name,endpointMode:l};i(`graphql-schema-introspection-run`,d);let f=`request`,m;try{let e;try{f=`invalid_url`,e=new URL(c)}catch{throw Error(`Enter a valid endpoint URL, including the protocol (e.g. https://).`)}let t={"content-type":`application/json`};for(let{key:e,value:n}of u){let r=e.trim();r.length>0&&(t[r]=n)}f=`request`;let l=await(await s({environmentName:n.environment.name,testRequest:{description:`GraphQL introspection`,pathname:`${e.pathname}${e.search}`,method:`POST`,headers:t,body:rBt()},overrideUrl:e.origin})).json();if(m=l.status,l.status<200||l.status>=300)throw f=`upstream_status`,Error(`The endpoint responded with ${l.status} ${l.statusText??``}.`.trim());f=`introspection`;let p=iBt(l.body);f=`save`,await o.mutateAsync({file:{path:d8,content:p},accountName:n.account.name,projectName:n.project.name,environmentName:n.environment.name}),i(`graphql-schema-introspection-success`,{...d,upstreamStatus:m}),a.success(`Schema saved to ${d8}`),r()}catch(e){let t=e instanceof Error?e.message:String(e);i(`graphql-schema-introspection-failed`,{...d,stage:f,upstreamStatus:m,reason:t}),h(t)}finally{p(!1)}};return(0,U.jsx)(Ib,{open:!0,onOpenChange:e=>!e&&!f&&r(),children:(0,U.jsxs)(zb,{className:`sm:max-w-2xl`,children:[(0,U.jsxs)(Bb,{children:[(0,U.jsx)(Hb,{children:`Download GraphQL schema`}),(0,U.jsxs)(Ub,{children:[`Run an introspection query against this endpoint. On success the schema is stored in `,(0,U.jsx)(`code`,{children:d8}),`.`]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(GY,{htmlFor:`graphql-introspection-endpoint`,children:`Endpoint`}),e&&e!==c&&(0,U.jsx)(X,{variant:`link`,size:`xs`,type:`button`,className:`h-auto p-0`,disabled:f,onClick:()=>l(e),children:`Use gateway URL`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(XP,{id:`graphql-introspection-endpoint`,value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com/graphql`,disabled:f,"data-op-ignore":!0}),(0,U.jsx)($P,{textToCopy:c})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(GY,{children:`Headers (optional)`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(XP,{placeholder:`Header name`,value:e.key,onChange:e=>g(t,`key`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(XP,{placeholder:`Value`,value:e.value,onChange:e=>g(t,`value`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,type:`button`,"aria-label":`Remove header`,onClick:()=>v(t),children:(0,U.jsx)(zf,{className:`size-4`})})]},t))}),(0,U.jsx)(`div`,{children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,type:`button`,onClick:_,children:[(0,U.jsx)(hf,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Add header`})]})})]}),m&&(0,U.jsxs)(Sb,{variant:`destructive`,children:[(0,U.jsx)(sd,{}),(0,U.jsx)(Cb,{children:`Introspection failed`}),(0,U.jsx)(wb,{className:`break-words`,children:m})]})]}),(0,U.jsxs)(Vb,{children:[(0,U.jsx)(Rb,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,type:`button`,disabled:f,children:`Cancel`})}),(0,U.jsx)(X,{variant:`brand`,type:`button`,onClick:y,disabled:f||c.trim().length===0,children:f?`Running…`:`Run introspection`})]})]})})},oBt=({path:e,rewriteUrl:t})=>{let n=op(),r=Qa(),{logEvent:i}=on(),[a,o]=(0,H.useState)(!1),s=UR(n.environment),c=s?new URL(e,s).toString():void 0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(aJ,{children:[(0,U.jsx)(oJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,children:[(0,U.jsx)(f1,{className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{children:`Schema`}),(0,U.jsx)(nd,{className:`size-4 shrink-0`})]})}),(0,U.jsxs)(sJ,{align:`end`,children:[(0,U.jsxs)(lJ,{onSelect:()=>{i(`graphql-schema-open`,{account:n.account.name,project:n.project.name,environment:n.environment.name}),r({pathname:$r(Yb.Code,{account:n.account.name,project:n.project.name,environment:encodeURIComponent(n.environment.urlParameter)}),search:`?path=${d8}`})},children:[(0,U.jsx)(Pd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Open Schema`})]}),(0,U.jsxs)(lJ,{disabled:!c,onSelect:()=>o(!0),children:[(0,U.jsx)(Cd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Download Schema`})]})]})]}),a&&c&&(0,U.jsx)(aBt,{endpointUrl:c,rewriteUrl:t,ape:n,onClose:()=>o(!1)})]})},sBt=({operationTags:e,onTagsChanged:t})=>{let{isReadOnly:n}=jZ(),r=t1(),[i,a]=(0,H.useState)(``),o=r.openApiData?.tags?.map(e=>e.name)??[],s=n=>{e.includes(n)?t(e.filter(e=>e!==n)):t([...e,n])},c=()=>{let n=i.trim();if(n){if(!o.includes(n))try{r.addTag(n)}catch{}e.includes(n)||t([...e,n]),a(``)}};return(0,U.jsxs)(bw,{children:[(0,U.jsx)(xw,{asChild:!0,children:(0,U.jsxs)(l6,{children:[(0,U.jsx)(If,{size:16}),e.length===1?(0,U.jsx)(`span`,{className:`truncate max-w-[12ch]`,title:e[0],children:e[0]}):`${e.length} Tags`]})}),(0,U.jsxs)(Sw,{className:`w-64 p-0 z-100`,align:`end`,children:[(0,U.jsx)(`div`,{className:`px-3 pt-3 pb-2`,children:(0,U.jsx)(`h4`,{className:`text-sm font-medium`,children:`Operation Tags`})}),o.length>0&&(0,U.jsx)(`div`,{className:`border-t max-h-48 overflow-y-auto`,children:o.map(t=>(0,U.jsxs)(`button`,{type:`button`,disabled:n,className:`w-full flex items-center justify-between px-3 py-1.5 text-sm hover:bg-accent disabled:opacity-50 disabled:cursor-default cursor-pointer`,onClick:()=>s(t),children:[(0,U.jsx)(`span`,{className:`truncate`,children:t}),(0,U.jsx)(td,{size:14,className:W(`shrink-0`,!e.includes(t)&&`invisible`)})]},t))}),!n&&(0,U.jsx)(`div`,{className:`border-t p-2`,children:(0,U.jsxs)(`form`,{className:`flex gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,U.jsx)(XP,{value:i,onChange:e=>a(e.target.value),placeholder:`New tag...`,className:`h-7 text-xs`}),(0,U.jsx)(X,{type:`submit`,variant:`outline`,size:`icon-sm`,disabled:!i.trim(),children:(0,U.jsx)(hf,{size:14})})]})})]})]})},cBt=r(a((e=>{var t=/~/,n=/~[01]/g;function r(e){switch(e){case`~1`:return`/`;case`~0`:return`~`}throw Error(`Invalid tilde escape: `+e)}function i(e){return t.test(e)?e.replace(n,r):e}function a(e){if(typeof e==`string`){if(e=e.split(`/`),e[0]===``)return e;throw Error(`Invalid JSON pointer.`)}else if(Array.isArray(e)){for(let t of e)if(typeof t!=`string`&&typeof t!=`number`)throw Error(`Invalid JSON pointer. Must be of type string or number.`);return e}throw Error(`Invalid JSON pointer.`)}function o(e,t){if(typeof e!=`object`)throw Error(`Invalid input object.`);t=a(t);var n=t.length;if(n===1)return e;for(var r=1;r<n;){if(e=e[i(t[r++])],n===r)return e;if(typeof e!=`object`||!e)return}}e.get=o}))());function f8(e,t){try{return e.startsWith(`#`)?cBt.get(t,e.replace(`#`,``)):cBt.get(t,e)}catch(e){console.error(`Error resolving schema reference. Reference may be invalid or referencing an external document.`,e);return}}var lBt=(e,t)=>{let n=e;return!n||`$ref`in n&&(n=f8(n.$ref,t),!n)?``:n.example?n.example:n.examples&&n.examples.length>0?n.examples[0]:n.default?n.default:``},uBt=(e,t)=>{if(e.examples&&Object.keys(e.examples).length>0){let n=Object.values(e.examples)[0];if(`$ref`in n){let e=f8(n.$ref,t);if(!e)return``;n=e}return n.value}if(e.example)return e.example;let n=e.schema;return lBt(n,t)},dBt=(e,t)=>{let n=e.requestBody;if(!n)return``;if(`$ref`in n){let e=f8(n.$ref,t);if(!e)return``;n=e}let{content:r}=n;if(!(`application/json`in r))return``;let i=r[`application/json`];if(i.examples&&Object.keys(i.examples).length>0){let e=Object.values(i.examples)[0];if(`$ref`in e){let n=f8(e.$ref,t);if(!n)return``;e=n}return e.value}let a=i.schema;return lBt(a,t)},fBt=JSON.stringify({query:`{ __schema { queryType { name } } }`},null,2),pBt=new VR,mBt=e=>e.additionalOperationContext.method.split(`,`).map(e=>e.toUpperCase()),p8=e=>{let{oasFilePath:t,method:n,path:r}=e.additionalOperationContext;return`${t}::${e.operationId??`${n} ${r}`}`},hBt=({ape:e,envUrl:t,operation:n,openApiDocument:r,showRebuildWarning:i,onClose:a,defaultEndpointsPanelOpen:o=!1,documentsByPath:s,endpointsLoading:c})=>{let l=(t,n)=>{let r=mBt(t)[0],i=t[OX]===!0,a=NX(t),o=dBt(t,n),s=pBt.getTest(e.account.name,e.project.name,e.environment.name,t.operationId),c=t.parameters?.filter(e=>!(`$ref`in e)&&e.in===`header`).reduce((e,t)=>({...e,[t.name]:uBt(t,n)}),{})??{},l=typeof o==`string`?o:JSON.stringify(o),u=a?{"content-type":`application/json`,accept:`application/json, text/event-stream`,...c}:i?{"content-type":`application/json`,...c}:c,d=l||(a?OR:i?fBt:l);return s?.test&&s.test.method===r?s.test:{description:t.summary??t.description??``,pathname:t.additionalOperationContext.path,method:r,headers:u,body:d}},[u,d]=(0,H.useState)(n),[f,p]=(0,H.useState)(()=>l(n,r)),[m,h]=(0,H.useState)(o),g=hp(e=>e.setTestResponse),_=yp(),v=s??_,y=(0,H.useMemo)(()=>({...v,[n.additionalOperationContext.oasFilePath]:r}),[v,n.additionalOperationContext.oasFilePath,r]),b=(0,H.useMemo)(()=>Object.entries(y).flatMap(([e,t])=>e1(e,t)),[y]),x=(0,H.useMemo)(()=>b.map(e=>({id:p8(e),method:e.additionalOperationContext.method,path:e.additionalOperationContext.path,summary:e.summary,file:e.additionalOperationContext.oasFilePath})),[b]);return(0,H.useEffect)(()=>{g(void 0)},[]),(0,U.jsx)(`div`,{className:`flex h-[650px] max-h-[70vh] flex-col`,children:(0,U.jsx)(zit,{ape:e,apiTest:f,showRebuildWarning:i,allowedMethods:mBt(u),url:`${t}${u.additionalOperationContext.path}`,shouldAllowLocalSaving:!!u.operationId,operationId:u.operationId,path:u.additionalOperationContext.path,onRequestChange:e=>{p(e)},onClose:a,endpoints:x,selectedEndpointId:p8(u),onSelectEndpoint:e=>{if(e===p8(u))return;let t=b.find(t=>p8(t)===e);if(!t)return;let n=y[t.additionalOperationContext.oasFilePath]??r;d(t),p(l(t,n)),g(void 0)},isEndpointPanelOpen:m,onToggleEndpointPanel:()=>h(e=>!e),endpointsLoading:c},p8(u))})},gBt=({envUrl:e,ape:t,operation:n,openApiDocument:r,showRebuildWarning:i,entries:a,onClose:o,defaultEndpointsPanelOpen:s})=>(0,U.jsx)(CY.Provider,{value:{entries:a},children:(0,U.jsx)(`div`,{className:`w-full text-muted-foreground`,children:(0,U.jsx)(hBt,{openApiDocument:r,ape:t,envUrl:e,showRebuildWarning:i,operation:n,onClose:o,defaultEndpointsPanelOpen:s})})}),_Bt=({open:e,onOpenChange:t,onProceed:n})=>{let{saveAndDeploy:r,isPending:i}=tpt();return(0,U.jsx)(Ib,{open:e,onOpenChange:t,children:(0,U.jsxs)(zb,{className:`sm:max-w-md`,children:[(0,U.jsxs)(Bb,{children:[(0,U.jsx)(Hb,{children:`Unsaved changes`}),(0,U.jsx)(Ub,{children:`Your unsaved changes will not be reflected when you test this route until you save and deploy them. Save them now, or continue testing the currently deployed version.`})]}),(0,U.jsxs)(Vb,{children:[(0,U.jsx)(X,{variant:`ghost`,onClick:n,disabled:i,children:`Continue without saving`}),(0,U.jsx)(X,{variant:`default`,onClick:async()=>{try{await r()}catch{return}n()},disabled:i,children:(0,U.jsx)(YP,{loading:i,children:`Save changes`})})]})]})})},vBt=(0,H.lazy)(()=>gn(()=>import(`./GraphiQLConsole-CZejKwC9.js`),__vite__mapDeps([9,1,2,8,10,11,12]))),yBt=({path:e,method:t,summary:n,operationData:r,hasFileChanged:i,isGraphql:a})=>{let{logEvent:o}=on(),s=op(),c=t1().getOpenApiDataEnforced(),{entries:l}=(0,H.useContext)(CY),u=UR(s.environment),[d,f]=(0,H.useState)(null),p=u?new URL(e,u).toString():void 0,m=zee({mutationKey:Bft})>0,[h,g]=x$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:t.includes(`,`)?t.split(`,`)[0]:t,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:a?`playground`:`default`}),(0,U.jsx)(Ib,{open:!0,onOpenChange:e=>!e&&g(),children:(0,U.jsxs)(zb,{showCloseButton:!1,className:`max-w-6xl! w-full gap-0 overflow-hidden p-0`,children:[(0,U.jsx)(Hb,{className:`sr-only`,children:`Test route`}),(0,U.jsx)(gBt,{envUrl:u??``,showRebuildWarning:i,ape:s,entries:l,operation:r,openApiDocument:c,onClose:g})]})})),[e,t,n,r,l,a]),[_,v]=x$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:`POST`,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:`graphiql`}),(0,U.jsx)(Ib,{open:!0,onOpenChange:e=>!e&&v(),children:(0,U.jsxs)(zb,{className:`max-w-6xl! w-full p-0 overflow-hidden`,children:[(0,U.jsx)(Hb,{className:`sr-only`,children:`GraphiQL`}),(0,U.jsx)(`div`,{className:`h-[80vh] w-full`,children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:`Loading GraphiQL…`}),children:(0,U.jsx)(vBt,{url:p??``,ape:s})})})]})})),[p,s]),y=e=>{e===`graphiql`?_():h()},b=e=>{if(i){f(e);return}y(e)},x=(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{children:`Saving`}),(0,U.jsx)(JP,{color:`current`})]}),S=m?`Saving`:`Test Route`;return(0,U.jsxs)(U.Fragment,{children:[a?(0,U.jsxs)(aJ,{children:[(0,U.jsx)(oJ,{asChild:!0,children:(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":S,children:(0,U.jsxs)(YP,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(qf,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`}),(0,U.jsx)(nd,{className:`size-4 shrink-0`})]})})}),(0,U.jsxs)(sJ,{align:`end`,children:[(0,U.jsxs)(lJ,{onSelect:()=>b(`playground`),children:[(0,U.jsx)(qf,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Playground`})]}),(0,U.jsxs)(lJ,{disabled:!p,onSelect:()=>b(`graphiql`),children:[(0,U.jsx)(f1,{className:`size-4`}),(0,U.jsx)(`span`,{children:`GraphiQL`})]})]})]}):(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":S,onClick:()=>b(`playground`),children:(0,U.jsxs)(YP,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(qf,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`})]})}),(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(_Bt,{open:d!==null,onOpenChange:e=>{e||f(null)},onProceed:()=>{let e=d;f(null),e&&y(e)}})})]})},bBt=({onRequestHandlerChange:e,isReadOnly:t,routeHandler:n})=>{let r=m1(n),i=(t,i)=>{e({...n,options:{...r.options,[t]:i}})};return(0,U.jsxs)(kO,{className:`p-4 bg-surface-sunken`,children:[(0,U.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-base font-medium`,children:`MCP Server Options`}),(0,U.jsx)(Rw,{showIcon:!0,href:`https://docs.zuplo.com/handlers/mcp-server`,className:`text-sm text-zuplo-pink`,children:`MCP Server Docs`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-12 gap-4 col-span-full items-center`,children:[(0,U.jsx)(`div`,{className:`col-span-8`,children:(0,U.jsx)(s6,{isReadOnly:t,label:`Server Name`,onChange:e=>i(`name`,e.target.value),className:`col-span-8`,value:typeof r.options.name==`string`?r.options.name:`My MCP Server`})}),(0,U.jsx)(`div`,{className:`col-span-4`,children:(0,U.jsx)(s6,{isReadOnly:t,label:`Server Version`,className:`col-span-4`,onChange:e=>i(`version`,e.target.value),value:typeof r.options.version==`string`?r.options.version:`v0.0.1`})}),(0,U.jsxs)(`div`,{className:`col-span-12 mt-2`,children:[(0,U.jsx)(GY,{className:`text-sm mb-2 block`,children:`Advanced Options`}),(0,U.jsx)(`div`,{className:W(`flex gap-4`,t&&`opacity-50`),children:(0,U.jsxs)(`label`,{className:`text-sm flex items-center gap-2`,children:[(0,U.jsx)(IY,{"data-test":`mcp-debug-mode`,checked:!!r.options.debugMode,onCheckedChange:e=>{i(`debugMode`,e)},disabled:t}),`Debug Mode`]})})]})]})]})},xBt=({routeHandler:e,operation:t,isReadOnly:n,onRequestHandlerChange:r})=>{let{captureRaw:i}=on(),a=Syt(),o=m1(e),s=typeof o.options.rewritePattern==`string`?o.options.rewritePattern:``,c=LIt(()=>{i(`mcp-gateway-upstream-url-edited`)});return(0,U.jsx)(kO,{className:`p-4`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground font-medium`,children:`Upstream MCP server`}),!!(a&&t)&&(0,U.jsxs)(X,{type:`button`,variant:`default`,size:`sm`,disabled:n,onClick:()=>{!t||!a||(i(`mcp-gateway-edit-virtual-mcp-opened`),a(t))},className:`shrink-0`,children:[(0,U.jsx)(Tf,{className:`w-3.5 h-3.5`}),`Edit MCP Server Policy`]})]}),(0,U.jsx)($4,{isReadOnly:n,url:s,onUrlChange:t=>{c(),r({...e,options:{...o.options,rewritePattern:t}})},placeholder:`https://example.com/mcp`,"aria-label":`Upstream MCP server URL`,"data-test":`mcp-upstream-url-input`})]})})};function SBt(e){if(e)switch(e.type){case`tool`:return{type:e.type,name:e.name??``,description:e.description??``,annotations:e.annotations};case`prompt`:return{type:e.type,name:e.name??``,description:e.description??``};case`resource`:return{type:e.type,name:e.name??``,description:e.description??``,uri:e.uri??``,mimeType:e.mimeType??``};case`graphql`:return{type:e.type,introspectionTool:{name:e.introspectionTool?.name??``,description:e.introspectionTool?.description??``},executeTool:{name:e.executeTool?.name??``,description:e.executeTool?.description??``}}}}function CBt({operationData:e,addRouteMenuProps:t}){return e?(0,U.jsx)(`div`,{className:`w-full h-full min-h-0 overflow-y-auto px-4 pt-2 pb-4`,children:(0,U.jsx)(TBt,{operationData:e})}):(0,U.jsx)(Dvt,{...t})}var wBt=()=>{let e=vp(),t=yp(),n=(0,H.useMemo)(()=>e.flatMap(e=>{let n=t[e.path];return n?e1(e.path,n).filter(e=>NX(e)).map(t=>[e,t]):[]}),[e,t]);return{getLinkedMcpServers:(e,t)=>n.filter(([,n])=>{let r=n[AX]?.handler;return jX(r)?r.options?.operations?.some(n=>d1(n.file)===e&&n.id===t):!1})}},TBt=({operationData:e})=>{let[t]=wY(`path`);if(!t)throw Error(`Open API file path not found in URL`);let n=ept(t),r=op(),{logEvent:i}=on(),{additionalOperationContext:a,...o}=e,{path:s,method:c}=a,l=t1(),u=ip(),d=g1(),{isReadOnly:f}=jZ(),[p,m]=(0,H.useState)(),[h,g]=(0,H.useState)();wBt();let _=l.openApiData?.servers?.at(0)?.url,v=o[AX]??r1(_??`https://echo.zuplo.io`),y=o[DX]===!0,b=o.deprecated===!0,x=o[OX]===!0,S=l.openApiFileModel.saveState!==Ws.unmodified,C=v.handler,w=jX(C)&&c.toUpperCase()!==`POST`?`MCP Server handler must use POST method`:void 0,T=e=>{try{l.updateOperation({path:s,method:c,newMethod:e.export===`mcpServerHandler`?`post`:void 0,newOperationObject:{...o,[AX]:{...v,handler:{...e}}}})}catch(e){u.error(e instanceof Error?e.message:`Unknown error`)}},E=e=>{l.updateOperation({path:s,method:c,newOperationObject:{...o,summary:e}})},D=e=>{l.updateOperation({path:s,method:c,newOperationObject:{...o,description:e}})},O=e=>{i(`route-visibility-changed`,{excludeFromDocs:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),l.updateOperation({path:s,method:c,newOperationObject:{...o,[DX]:e}})},k=e=>{i(`route-deprecated-changed`,{deprecated:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),l.updateOperation({path:s,method:c,newOperationObject:{...o,deprecated:e||void 0}})},A=e=>{i(`route-graphql-changed`,{graphql:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name});let n={...o};e?(n[OX]=!0,dvt(d),n[AX]=uvt(v,!0)):(delete n[OX],o[AX]&&(n[AX]=uvt(v,!1))),l.updateOperation({path:s,method:c,newOperationObject:n})},j=e=>{let{newPath:t}=e,{newMethod:n}=e;h!=null&&t==null&&(t=h);try{l.updateOperation({path:s,newPath:t,method:c,newMethod:n,newOperationObject:o}),m(void 0),g(void 0)}catch(e){e instanceof Error&&t!=null&&(g(t),m(e.message))}},M=e=>{if(e===s){m(void 0),g(void 0);return}j({newPath:e.startsWith(`/`)?e:`/${e}`})},N=e=>{let n=e;n!==c&&(i(`route-method-changed`,{httpMethod:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name}),j({newMethod:n}))},P=e=>{let n={...v,corsPolicy:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[AX]:n}}),i(`route-cors-changed`,{newCors:e,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},F=e=>{let t={...o};e.length>0?t.tags=e:delete t.tags,l.updateOperation({path:s,method:c,newOperationObject:t})},I=n=>{let a={...e.additionalOperationContext.pathZuploConfig,pathMode:n},o=l.getOpenApiDataEnforced().paths;if(!o)throw Error(`Property 'paths' is undefined`);let c=o[s];if(!c)throw Error(`Path Item '${s}' is undefined`);l.updatePathItem(s,{...c,[kX]:a}),i(`route-path-mode-changed`,{pathMode:n,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},L=()=>{n(Ws.modified)};return(0,U.jsxs)(`div`,{className:`mb-4 flex flex-col gap-6`,children:[(0,U.jsxs)(kO,{className:`bg-neutral-50 dark:bg-transparent`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,U.jsxs)(AO,{children:[(0,U.jsx)(jO,{children:`Request Handling`}),(0,U.jsx)(MO,{})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-6`,children:[x&&(0,U.jsx)(oBt,{path:s,rewriteUrl:typeof C.options?.rewritePattern==`string`?C.options?.rewritePattern:void 0}),(0,U.jsx)(FRt,{operationData:e}),(0,U.jsx)(yBt,{path:s,method:c,summary:o.summary??``,operationData:e,hasFileChanged:S,isGraphql:x})]})]}),(0,U.jsxs)(NO,{className:`grid grid-cols-1 xl:grid-cols-[max-content_1fr] gap-y-3 xl:gap-y-2 items-center gap-x-6`,children:[(0,U.jsx)(WRt,{isReadOnly:f,initialPath:s,method:c,onChangeMethod:N,pathMode:e.additionalOperationContext.pathZuploConfig?.pathMode,hasError:p!=null,onPathChange:M,onPathModeChange:I,onFieldModified:L,isMcpToolHandler:jX(C)||MX(C)}),p&&(0,U.jsx)(Sb,{"data-test":`path-error`,className:`col-span-full p-2`,variant:`destructive`,children:(0,U.jsx)(wb,{children:p})}),w&&(0,U.jsx)(Sb,{className:`col-span-full p-2 py-1`,variant:`destructive`,children:(0,U.jsxs)(wb,{"data-test":`request-handler-error`,className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{children:w}),(0,U.jsx)(X,{onClick:()=>N(`post`),size:`xs`,variant:`outline`,className:`border-none`,children:`Switch to POST method`})]})}),(0,U.jsx)(ONt,{isReadOnly:f,initialSummary:o.summary,onSummaryChange:E,onFieldModified:L}),(0,U.jsx)(IRt,{isReadOnly:f,defaultOperationId:e.operationId,openApiManager:l,path:s,method:c,operationData:e})]}),(0,U.jsxs)(PO,{className:`flex flex-wrap gap-2 px-3 py-1.5 bg-card justify-end`,children:[(0,U.jsx)(sBt,{operationTags:o.tags??[],onTagsChanged:F}),(0,U.jsx)(hLt,{isReadOnly:f,selectedCorsPolicy:v.corsPolicy,corsPolicies:d.corsPolicyList??[],onSelectionChanged:P}),!jX(v.handler)&&!MX(v.handler)&&(0,U.jsx)(VRt,{operation:e,defaultValues:SBt(v.mcp),onSubmit:e=>{let t={...v,mcp:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[AX]:t}})}}),(0,U.jsx)(uRt,{isExcludedFromDocs:y,onVisibilityChanged:O}),(0,U.jsx)(GRt,{isGraphql:x,onGraphqlChanged:A,isDeprecated:b,onDeprecatedChanged:k})]})]}),(0,U.jsx)(AIt,{inboundPolicies:v.policies?.inbound??[],outboundPolicies:v.policies?.outbound??[],operation:e,children:(0,U.jsx)(EBt,{isReadOnly:f,operationData:e,handler:v.handler,firstServerUrl:_,onRequestHandlerChange:T})}),(0,U.jsx)(lRt,{initialDescription:o.description??``,onChange:D,path:s,method:c,oasFilePath:t})]})},EBt=({operationData:e,handler:t,firstServerUrl:n,isReadOnly:r,onRequestHandlerChange:i})=>{let a=(e[AX]??r1(n??`https://echo.zuplo.io`)).handler;switch(t.export){case`mcpServerHandler`:return(0,U.jsx)(bBt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i});case`McpProxyHandler`:case`McpVirtualServerHandler`:case`mcpVirtualServerHandler`:return(0,U.jsx)(xBt,{routeHandler:a,operation:e,isReadOnly:r,onRequestHandlerChange:i});default:return(0,U.jsx)(dLt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i})}},DBt=Ae()(e=>({updateLinkedMcpServers:void 0,setUpdateLinkedMcpServers:t=>e({updateLinkedMcpServers:t})})),OBt=()=>{let e=p(DBt,e=>e.updateLinkedMcpServers),t=JZ(),n=()=>{DBt.setState({updateLinkedMcpServers:void 0})};return(0,U.jsx)(Ib,{open:!!e,onOpenChange:e=>{e||n()},children:(0,U.jsxs)(zb,{children:[(0,U.jsx)(Hb,{children:`MCP Server Links`}),(0,U.jsx)(Ub,{children:`This operation is linked to MCP servers, if you update the operation id, you need to update the MCP server links as well.`}),(0,U.jsx)(`div`,{className:`flex gap-2 items-center justify-center`,children:e?.linkedMcpServers.map(([,e])=>(0,U.jsx)(OO,{children:e},e))}),(0,U.jsxs)(Vb,{children:[(0,U.jsx)(X,{variant:`outline`,onClick:n,children:`Cancel`}),(0,U.jsx)(X,{onClick:()=>{e?.linkedMcpServers.forEach(([n,r])=>{let i=new Z_t(n,t),a=i.getOperationById(r);if(!a)return;let o=a[AX];if(!o)return;let s=o.handler;if(jX(s)){if(n.path===e.file){let t=i.getOperationById(e.oldOperationId);if(!t)throw Error(`Operation not found`);i.updateOperation({path:t.additionalOperationContext.path,method:t.additionalOperationContext.method,newOperationObject:j$(t,`operationId`,e.newOperationId)})}i.updateOperation({path:a?.additionalOperationContext.path,method:a.additionalOperationContext.method,newOperationObject:j$(a,`${AX}.handler.options.operations`,s.options?.operations?.map(t=>d1(t.file)===n.path?{...t,id:t.id===e.oldOperationId?e.newOperationId:t.id}:t))})}})},children:`Update`})]})]})})},kBt=`$import(@zuplo/runtime)`,ABt=`${kBt}::urlForwardHandler`,jBt=`${kBt}::urlRewriteHandler`,MBt=(e,t)=>{let n=e.options?.[t],r=typeof n==`string`?n.trim():``;return r.length>0?r:void 0},NBt=e=>{let t=e.trim();if(t.startsWith("${")){let e=t.indexOf(`}`);if(e!==-1)return t.slice(0,e+1)}let n=/^[a-z][a-z0-9+.-]*:\/\/[^/$?#]+/i.exec(t);if(n)return n[0];let r=t.indexOf(`/`);return r===-1?t:t.slice(0,r)},PBt=e=>{if(e){let t=`${e.module}::${e.export}`,n=t===ABt?MBt(e,`baseUrl`):t===jBt?MBt(e,`rewritePattern`):void 0;if(n){let e=NBt(n);return{key:`target:${e}`,label:e,mono:!0,icon:Wd,collapsible:!0}}}return{...uyt(e),collapsible:!1}};function FBt(){let e=t1(),{captureRaw:t}=on(),n=op(),r=GZ();return i=>{e.updateInfo(i),t(`openapi-info-updated`);let{projectTreeNodes:a,filesByPath:o}=hp.getState(),s=a.map(e=>e.path?o[e.path]:void 0).filter(e=>!!e&&e.saveState===Ws.modified);s.length!==0&&r.mutateAsync({environmentName:n.environment.name,accountName:n.account.name,projectName:n.project.name,files:s}).catch(()=>{})}}var m8=`Document Order`,IBt=[`Document Order`,`Path`,`Summary`],h8=`Untagged`,LBt=[{value:`none`,label:`None`},{value:`path`,label:`Path`},{value:`handler`,label:`Handler type`},{value:`target`,label:`Target`}],RBt=new Set([`handler`,`target`]);function zBt(e){return`${e}-${Ne().split(`-`).at(0)}`}function g8(e){return new Set(e.getPolicyListEnforced().map(e=>e.name))}function BBt(e){if(!e)return;let t=yNt(e.getPolicyListEnforced());if(t)return t.name;let n=o3(_Nt,g8(e));return e.createPolicy(vNt(n)),n}var VBt=e=>(t,n)=>{switch(e){case`Document Order`:return 0;case`Path`:return t.additionalOperationContext.path.localeCompare(n.additionalOperationContext.path);case`Summary`:return!t.summary&&!n.summary?0:!t.summary&&n.summary?1:t.summary&&!n.summary?-1:t.summary?.localeCompare(n.summary??``)??0;default:return 0}},HBt=e=>t=>{if(e.length===0)return!0;let n=t.tags;return!n||n.length===0?e.includes(h8):n.some(t=>e.includes(t))},UBt=({onNavigateToOpenApiFileTab:e})=>{let{logEvent:t,captureRaw:n}=on(),[r,i]=Lrt(`tags`,[]),[a,o]=ww(`open-api-designer-group-by`,`none`);(0,H.useEffect)(()=>{let e=window.localStorage.getItem(`open-api-designer-show-headers`);e!==null&&(e===`true`&&a===`none`&&o(`path`),window.localStorage.removeItem(`open-api-designer-show-headers`))},[a,o]);let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(`details`),[d,f]=(0,H.useState)(!1),p=FBt(),m=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)||(e.preventDefault(),m.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let[h,g]=(0,H.useState)(),[_,v]=(0,H.useState)(),[y,b]=(0,H.useState)(()=>new Set),x=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[S,C]=(0,H.useState)(()=>new Set),w=e=>C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),{isReadOnly:T}=jZ(),[E,D]=wY(`operation`),[O,k]=ww(`default-sort-routes`,m8),[A,j]=wY(`sort`,O);(0,H.useEffect)(()=>{A&&k(A)},[k,A]),(0,H.useEffectEvent)(()=>{if(E)try{document.querySelector(`#op-${E}`)?.scrollIntoView()}catch{}});let[M,N]=(0,H.useState)(void 0),P=t1(),F=g1(),I=nF(),L=YZ(dyt),R=XZ(),z=()=>{if(L)return pyt(L.content??``)?`ok`:`manual`;let e=fyt,t={path:dyt,content:e,type:Us.File,saveState:Ws.new};if(I){let n=I.Uri.file(t.path);I.editor.getModel(n)||I.editor.createModel(e,void 0,n)}return R(t),R({...t,saveState:Ws.modified}),`ok`},{results:B,setSearchTerm:ee,searchTerm:V}=Gvt(P.operationArray?.filter(HBt(r)).sort(VBt(A))??[],{keys:[e=>e.additionalOperationContext.path,e=>e.summary??``,e=>e.operationId,e=>e.additionalOperationContext.method]});(0,H.useEffect)(()=>{let e=V?.trim()??``;if(e.length===0)return;let n=setTimeout(()=>{t(`route-search-used`,{view:`routes`,query:e,queryLength:e.length})},600);return()=>clearTimeout(n)},[V,t]);let te=(()=>{let e=new Map;for(let t of B){let n,r,i,o,s;if(a===`handler`||a===`target`){let e=t[AX]?.handler,c=a===`target`?PBt(e):{...uyt(e),collapsible:!1};({key:n,label:r,mono:i,collapsible:o,icon:s}=c)}else n=t.additionalOperationContext.path,r=n,i=!0,o=!1,s=void 0;let c=e.get(n);c?c.operations.push(t):e.set(n,{key:n,label:r,mono:i,icon:s,collapsible:o,operations:[t]})}return[...e.values()]})(),[ne,re]=(0,H.useState)(),[ie,ae]=(0,H.useState)(),[oe,se]=(0,H.useState)(!1),ce=(0,H.useMemo)(()=>{if(!_)return[];let e=(P.operationArray?.find(e=>e.additionalOperationContext.path===_.path&&e.additionalOperationContext.method===_.method))?.[AX]?.policies?.inbound??[];if(e.length===0)return[];let t=new Set;for(let e of F.policyList??[]){if(e.policyType!==`composite-inbound`&&e.policyType!==`composite-outbound`)continue;let n=e.handler.options?.policies;if(n)for(let e of n)t.add(e)}let n=F.policiesUsageInfo??[];return e.map(e=>n.find(t=>t.name===e)).filter(e=>{if(!e||e.operations.length!==1)return!1;let n=e.operations[0];return!(n.additionalOperationContext.path!==_.path||n.additionalOperationContext.method!==_.method||t.has(e.name))})},[_,P.operationArray,F.policyList,F.policiesUsageInfo]),[le,ue]=(0,H.useState)(()=>new Set);(0,H.useEffect)(()=>{ue(_?new Set(ce.map(e=>e.name)):new Set)},[_]);let de=(e,t)=>{ue(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},fe=()=>{if(_==null){se(!1);return}try{for(let e of le)try{F.deletePolicy(e),t(`policy-deleted`,{policy:e})}catch{}P.deleteOperation(_.path,_.method),t(`route-deleted`,_)}catch(e){e instanceof Error&&(t(`route-deletion-failed`,_),N(e.message),pe())}v(void 0),se(!1)},[pe,me]=x$(()=>{let t=()=>{N(void 0),me()};return(0,U.jsx)(sQ,{alertType:`ERROR`,bodyText:M??``,onPrimaryButtonClick:e,onSecondaryButtonClick:t,primaryButtonText:`Edit file directly`,secondaryButtonText:`Cancel`,hideModal:t,title:`Error`})},[M]),[he,ge]=x$(()=>(0,U.jsx)(sQ,{alertType:`CAUTION`,bodyText:`Cannot reorder in this view — view by Document Order to reorganize the order of operations.`,onPrimaryButtonClick:()=>{j(m8),ge()},onSecondaryButtonClick:ge,primaryButtonText:`Switch to Document Order`,secondaryButtonText:`Cancel`,hideModal:ge,title:`Cannot reorder`})),[_e,ve]=x$(()=>(0,U.jsx)(hyt,{open:!0,onOpenChange:e=>{e||ve()}})),ye=(e,t)=>{if(A!==m8){he();return}P.movePathInDocument(e,t)};if(!P.openApiData)throw Error(`Invalid State - no OpenApiData`);let be=P.openApiData.info,xe=P.openApiData.tags?.map(e=>({value:e.name,label:e.name}));xe?.push({value:h8,label:h8});let Se=()=>{let e=c1.OpenAPIV3.HttpMethods.GET,n=P.openApiData?.servers?.at(0)?.url,r=cvt(n??`https://echo.zuplo.io`),i=`/path-${((P.operationArray?.filter(t=>t.additionalOperationContext.path.startsWith(`/path-`)&&t.additionalOperationContext.method===e)?.map(e=>parseInt(e.additionalOperationContext.path.replace(`/path-`,``),10))?.filter(e=>!Number.isNaN(e))?.sort((e,t)=>t-e))?.at(0)??0)+1}`;try{let t=P.addOperation(i,e,r);t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:i,httpMethod:e}),N(n.message),pe())}t(`route-added`)},Ce=(e,n,r)=>{let i=P.openApiData?.servers?.at(0)?.url,a=cvt(i??`https://echo.zuplo.io`),o=r?.[AX],s=a[AX];o&&s&&(o.handler&&(s.handler=JSON.parse(JSON.stringify(o.handler))),o.policies&&(s.policies=JSON.parse(JSON.stringify(o.policies))));try{let t=P.addOperation(e,n,a);t&&D(t)}catch(r){r instanceof Error&&(t(`route-add-failed`,{httpPath:e,httpMethod:n}),N(r.message),pe())}t(`route-added`)},we=()=>{let e=c1.OpenAPIV3.HttpMethods.POST,n=zBt(`mcp`),r=P.addOperation(`/mcp`,e,{summary:`MCP Server`,description:`Default MCP Server`,[AX]:{corsPolicy:`none`,handler:{export:`mcpServerHandler`,module:`$import(@zuplo/runtime)`,options:{operations:[]}},policies:{inbound:[]}},operationId:n},{avoidConflict:!0});r&&D(r),t(`route-added`)},Te=()=>{let e=c1.OpenAPIV3.HttpMethods.POST,n=fvt(`https://rickandmortyapi.com/graphql`);try{dvt(F);let t=P.addOperation(`/graphql`,e,n,{avoidConflict:!0});t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/graphql`,httpMethod:e}),N(n.message),pe())}t(`route-added`)},Ee=()=>{let e=c1.OpenAPIV3.HttpMethods.GET,n=pvt();try{let t=P.addOperation(`/websocket`,e,n,{avoidConflict:!0});t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/websocket`,httpMethod:e}),N(n.message),pe())}t(`route-added`)},[De,Oe]=(0,H.useState)(!1),[ke,Ae]=(0,H.useState)(),[je,Me]=(0,H.useState)(0),Pe=(0,H.useMemo)(()=>{let e=new Set(Object.keys(P.openApiData?.paths??{}));return ke&&e.delete(ke.path),e},[P.openApiData?.paths,ke]),Fe=async e=>{let n;try{n=z()}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}let r;try{r=xNt({result:e,policyList:F.getPolicyListEnforced(),existingOperationIds:new Set(P.operationArray?.map(e=>e.operationId)??[])});for(let e of r.policiesToCreate)F.createPolicy(e)}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}try{let e=P.addOperation(r.operationPath,r.method,r.operation,{avoidConflict:!0});e&&D(e)}catch(e){e instanceof Error&&(N(e.message),pe())}t(`route-added`),t(`mcp-gateway-create-virtual-mcp-submitted`,SNt(e)),n===`manual`&&_e()},Ie=()=>{Me(e=>e+1),Oe(!0)},Le=e=>{let t=cNt({operationPath:e.additionalOperationContext.path,operation:e,policyList:F?.getPolicyListEnforced()??[]});t&&(Me(e=>e+1),Ae({initialResult:t,path:e.additionalOperationContext.path,method:e.additionalOperationContext.method,operationId:e.operationId}))},Re=async e=>{let t=ke;if(!t)return;let{initialResult:r,path:i,method:a}=t,o=P.operationArray?.find(e=>e.additionalOperationContext.path===i&&e.additionalOperationContext.method===a);if(!o){Ae(void 0);return}let s;try{s=z()}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}let c=hNt(e.step1.name),l=W1(e.step1.mcpUrl),u=l?.protectedResourceMetadataUrl??bNt(e.step1.mcpUrl),d=o[AX]?.policies?.inbound??[],f=F?.getPolicyListEnforced()??[],p=new Map(f.map(e=>[e.name,e])),m=d.map(e=>p.get(e)).filter(e=>e!=null),h=m.find(e=>e.policyType===F4),g=m.find(e=>e.policyType===I4),_=m.find(e=>e.policyType===`remove-headers-inbound`&&L4(e.handler?.options)),v=m.find(e=>e.policyType.startsWith(`upstream-`)),y;if(e.step1.authMode===`user-oauth`){let t={id:c,displayName:e.step1.name,summary:`${e.step1.name} remote MCP server, federated via the gateway.`,...u?{protectedResourceMetadataUrl:u}:{},authMode:`user-oauth`,scopes:l?.scopes??[],clientRegistration:e.step1.clientRegistration};if(h&&F)try{F.updatePolicy(h.name,{...h,handler:{...h.handler,options:t}}),y=h.name}catch(e){if(e instanceof Error){N(e.message),pe();return}}else if(F){y=o3(`mcp-upstream-${c}`,g8(F));try{F.createPolicy({name:y,policyType:F4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpTokenExchangeInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}}}let b;if(e.step1.authMode===`upstream-policy`&&F){let{policyType:t,policyName:n,handler:r}=e.step1;try{v&&v.policyType===t?F.updatePolicy(v.name,{...v,name:n,handler:r}):F.createPolicy({name:n,policyType:t,handler:r}),b=n}catch(e){if(e instanceof Error){N(e.message),pe();return}}}let x;if(e.step2.catalogMode===`curated`){let t=k4(e.step2);if(g&&F)try{F.updatePolicy(g.name,{...g,handler:{...g.handler,options:t}}),x=g.name}catch(e){if(e instanceof Error){N(e.message),pe();return}}else if(F){x=o3(`mcp-filter-${c}`,g8(F));try{F.createPolicy({name:x,policyType:I4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpCapabilityFilterInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}}}let S;if(e.step3.authPolicyChoice===`existing`)S=e.step3.existingPolicyName;else if((e.step3.authPolicyChoice===`new`||e.step3.authPolicyChoice===`new-other`)&&(S=e.step3.newPolicyName,F))try{F.createPolicy({name:S,policyType:e.step3.policyType,handler:e.step3.handler})}catch(e){if(e instanceof Error){N(e.message),pe();return}}let C;if(e.step1.authMode===`none`&&e.step1.noAuthBehavior===`strip`)try{C=_?.name??BBt(F)}catch(e){if(e instanceof Error){N(e.message),pe();return}}let w=[S,x,y,b,C].filter(e=>!!e),T=o[AX],E=T?.handler;try{P.updateOperation({path:i,method:a,newOperationObject:{...o,summary:e.step1.name,description:`MCP Virtual Server fronted by the gateway (${e.step1.mcpUrl})`,[AX]:{...T??{},handler:{...E??{export:`McpProxyHandler`,module:`$import(@zuplo/runtime/mcp-gateway)`},options:{...E?.options??{},rewritePattern:e.step1.mcpUrl}},policies:{...T?.policies??{},inbound:w}}}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}let D;try{D=new URL(e.step1.mcpUrl).hostname}catch{D=void 0}n(`mcp-gateway-edit-virtual-mcp-submitted`,{upstreamHost:D,upstreamAuthMode:e.step1.authMode,previousUpstreamAuthMode:r.step1.authMode,inboundAuthChoice:e.step3.authPolicyChoice,previousInboundAuthChoice:r.step3.authPolicyChoice}),Ae(void 0),s===`manual`&&_e()},ze=(0,H.useMemo)(()=>E?B.find(e=>e.operationId===E)||B.find(e=>h?.path===e.additionalOperationContext.path&&h?.method===e.additionalOperationContext.method):void 0,[B,E,h]);(0,H.useEffect)(()=>{ze&&!h&&g({path:ze.additionalOperationContext.path,method:ze.additionalOperationContext.method})},[ze,h]);let Be=(e,n,r)=>{let i=(e,t)=>{let n=e.replace(/-duplicate(-\d+)?$/,``),r=`${n}-duplicate`,i=2;for(;t(r);)r=`${n}-duplicate-${i}`,i++;return r},a=P.operationArray??[],o=i(e,e=>a.some(t=>t.additionalOperationContext.path===e&&t.additionalOperationContext.method===n)),s=i(r.operationId??`op-${Ne().slice(0,4)}`,e=>a.some(t=>t.operationId===e)),c=JSON.parse(JSON.stringify(r));c.operationId=s;try{let e=P.addOperation(o,n,c);e&&D(e)}catch(e){e instanceof Error&&(t(`route-add-failed`,{httpPath:o,httpMethod:n}),N(e.message),pe())}t(`route-added`,{httpPath:o,httpMethod:n,duplicate:!0})},Ve=()=>{f(!0),u(`tags`),c(!0)},He=ke!==void 0,Ue=(0,U.jsx)(lNt,{isOpen:De||He,existingPaths:Pe,mode:He?`edit`:`create`,initialResult:ke?.initialResult,onClose:()=>{Oe(!1),Ae(void 0)},onFinish:He?Re:Fe},`mcp-wizard-${je}`),We={onAddRest:Se,onAddGraphql:Te,onAddWebSocket:Ee,onAddMcpVirtual:Ie,onAddMcpServer:we,onAddTag:Ve};return P.operationArray?.length===0&&(!V||V.trim().length===0)?(0,U.jsxs)(U.Fragment,{children:[Ue,(0,U.jsx)(Dvt,{...We})]}):(0,U.jsxs)(`div`,{className:`ms-2 grid grid-cols-3 h-full grow`,children:[(0,U.jsx)(v$,{open:oe,onOpenChange:e=>{se(e),e||v(void 0)},onClickDelete:fe,title:`Delete`,deleteButtonText:`Confirm`,children:ce.length===0?`Are you sure you want to delete this operation?`:(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{children:[`The following`,` `,ce.length===1?`policy is`:`policies are`,` `,`used only by this route. Would you like to delete`,` `,ce.length===1?`it`:`them`,` `,`too?`]}),(0,U.jsx)(`ul`,{className:`flex flex-col divide-y divide-border max-h-[40vh] overflow-y-auto rounded-md border bg-surface-sunken`,children:ce.map(e=>{let t=`delete-policy-${e.name}`;return(0,U.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2`,children:[(0,U.jsx)(IY,{id:t,checked:le.has(e.name),onCheckedChange:t=>de(e.name,t===!0),className:`mt-0.5`}),(0,U.jsxs)(`label`,{htmlFor:t,className:`flex flex-col gap-0.5 text-left cursor-pointer min-w-0`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.name}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e.policyType})]})]},e.name)})})]})}),(0,U.jsx)(OBt,{}),Ue,be&&(0,U.jsx)(ENt,{open:s,onOpenChange:c,info:be,onSave:p,defaultTab:l,tagsAutoCreate:d,onTagsAutoCreateConsumed:()=>f(!1)}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 justify-start h-full pt-2 min-h-0`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between gap-x-2`,children:[(0,U.jsx)(`div`,{className:`flex gap-1`,children:(0,U.jsxs)(aJ,{children:[(0,U.jsx)(oJ,{className:`flex group select-none`,asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,title:`Filter and sort routes`,children:[(0,U.jsx)(Vd,{size:16}),`Filter`]})}),(0,U.jsxs)(sJ,{className:`min-w-[220px]`,align:`start`,children:[(0,U.jsx)(dJ,{children:`Sort by`}),(0,U.jsx)(cJ,{children:IBt.map(e=>(0,U.jsxs)(lJ,{onClick:()=>j(e),className:`justify-between`,children:[e,(0,U.jsx)(td,{className:W(`mr-2`,e!==A&&`invisible`),size:16})]},e))}),(0,U.jsx)(fJ,{}),(0,U.jsx)(dJ,{children:`Filter by tag`}),(0,U.jsx)(cJ,{className:`max-h-60 overflow-y-auto`,children:xe?.map(e=>(0,U.jsxs)(lJ,{onClick:t=>{t.stopPropagation(),t.preventDefault(),r.includes(e.value)?i(r.filter(t=>t!==e.value)):i([...r,e.value])},className:`justify-between`,children:[e.label,(0,U.jsx)(td,{className:W(`mr-2`,!r.includes(e.value)&&`invisible`),size:18})]},e.label))}),(0,U.jsx)(fJ,{}),(0,U.jsx)(dJ,{children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(wee,{size:16}),`Group by`]})}),(0,U.jsx)(cJ,{children:LBt.map(e=>(0,U.jsxs)(lJ,{onClick:t=>{t.stopPropagation(),t.preventDefault(),o(e.value)},className:`justify-between`,children:[e.label,(0,U.jsx)(td,{className:W(`mr-2`,a!==e.value&&`invisible`),size:16})]},e.value))})]})]})}),T?null:(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>{f(!1),u(`details`),c(!0)},"aria-label":`API Settings`,title:`API Settings`,children:(0,U.jsx)(pf,{size:16})}),(0,U.jsxs)(aJ,{children:[(0,U.jsx)(oJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,"data-test":`add-route-btn`,className:`relative gap-0.5!`,children:[(0,U.jsx)(`div`,{className:`absolute w-1.5 h-1.5 rounded-full -top-0.5 -right-[3px] bg-zuplo-700`}),(0,U.jsx)(hf,{"aria-hidden":`true`,className:`size-3.5`}),`Add`]})}),(0,U.jsx)(sJ,{children:(0,U.jsx)(Evt,{...We})})]})]})]}),(0,U.jsx)(jY,{onClearValue:()=>ee(``),value:V,showClearButton:!!V&&V.length>0,children:(0,U.jsx)(XP,{ref:m,value:V,onChange:e=>ee(e.target.value),placeholder:`Search Routes`,className:`px-8`})}),r.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,U.jsxs)(`div`,{className:`group flex items-center gap-1 max-w-full pl-1.5 pr-0.5 py-0.5 rounded-full border border-border bg-card text-xs text-foreground`,children:[(0,U.jsx)(If,{size:11,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e} filter`,onClick:t=>{t.stopPropagation(),i(r.filter(t=>t!==e))},className:`shrink-0 size-4 rounded-full flex items-center justify-center text-muted-foreground hover:bg-neutral-200 dark:hover:bg-neutral-700 hover:text-neutral-900 dark:hover:text-foreground`,children:(0,U.jsx)(Kf,{size:11})})]},e))}),(0,U.jsx)(`div`,{className:`overflow-y-auto space-y-1`,children:te.map((e,t,n)=>{let r=!e.collapsible||S.has(e.key),i=e.operations.length,o=e.icon,s=(0,U.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-background px-1.5 py-0.5 text-xs font-normal tabular-nums text-muted-foreground`,children:i});return(0,U.jsxs)(`div`,{children:[e.collapsible?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>w(e.key),"aria-expanded":r,className:`mt-3 mb-1 flex w-full items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-left text-sm font-semibold text-foreground transition-colors first:mt-1 hover:bg-muted`,title:r?`Collapse ${e.label}`:`Expand ${e.label} (${i} ${i===1?`route`:`routes`})`,children:[r?(0,U.jsx)(nd,{size:15,className:`shrink-0 text-muted-foreground`}):(0,U.jsx)(rd,{size:15,className:`shrink-0 text-muted-foreground`}),o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate font-mono`,title:e.label,children:e.label}),s]}):a!==`none`&&(0,U.jsxs)(`div`,{className:`mt-3 mb-1 flex items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-sm font-semibold text-foreground first:mt-1`,children:[o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:W(`truncate`,e.mono&&`font-mono`),title:e.label,children:e.label}),s]}),r&&e.operations.map(({additionalOperationContext:e,...r})=>{let i=ze?.operationId===r.operationId,o=r[AX]?.handler,s=jX(o),c=MX(o),l=s?o.options?.operations?.length??0:0,u=l>0,d=y.has(r.operationId);return(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(Qvt,{path:i&&ne?ne:e.path,type:c?`mcp-virtual`:s?`mcp`:`route`,method:e.method,summary:i&&ie?ie:r.summary,operationId:r.operationId,operation:r,isSelected:i,onOperationSelected:t=>{re(``),ae(``),g({path:e.path,method:e.method}),D(t)},onDelete:(e,t,n)=>{v({path:e,method:t,operationId:n}),se(!0)},onAddRoute:Ce,onDuplicate:()=>Be(e.path,e.method,r),onMoveUp:RBt.has(a)?void 0:()=>ye(e.path,`up`),onMoveDown:RBt.has(a)?void 0:()=>ye(e.path,`down`),isFirstPath:A===m8&&t===0,isLastPath:A===m8&&t===n.length-1,isToolsExpanded:u?d:void 0,onToggleTools:u?()=>x(r.operationId):void 0,toolsCount:u?l:void 0}),o&&u&&d&&(0,U.jsx)(byt,{handler:o,operation:{...r,additionalOperationContext:e}})]},r.operationId)})]},e.key)})})]}),(0,U.jsx)(`div`,{className:`col-span-2 flex flex-col h-full overflow-y-auto`,children:(0,U.jsx)(s3.Provider,{value:{setPath:re,setSummary:ae},children:(0,U.jsx)(xyt.Provider,{value:Le,children:(0,U.jsx)(CBt,{operationData:ze,addRouteMenuProps:We})})})})]})},WBt={create:{shell:`bg-emerald-500/8 shadow-emerald-950/5`,icon:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`,count:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`},update:{shell:`bg-brand/8 shadow-brand/5`,icon:`bg-brand/12 text-brand`,count:`bg-brand/12 text-brand`},keep:{shell:`bg-background shadow-black/5 dark:shadow-white/5`,icon:`bg-muted text-muted-foreground`,count:`bg-muted text-muted-foreground`}},_8=({icon:e,operations:t,title:n,tone:r})=>{let i=WBt[r];return(0,U.jsxs)(`section`,{className:`rounded-2xl p-4 shadow-sm ${i.shell}`,"aria-label":`${n} operations`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 font-semibold text-foreground`,children:[(0,U.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-xl ${i.icon}`,children:e}),n,` operations`]}),(0,U.jsx)(`div`,{className:`rounded-full px-2.5 py-1 text-xs font-medium tabular-nums ${i.count}`,children:t.size})]}),(0,U.jsx)(`div`,{className:`space-y-1.5`,children:Array.from(t).map(e=>{let t=e.split(`>`),n=t[0],r=t.slice(1,t.length).join(`>`);return(0,U.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 rounded-xl bg-background/80 px-3 py-2 text-sm shadow-xs`,children:[(0,U.jsx)(MY,{className:`w-14`,method:n}),(0,U.jsx)(`span`,{className:`break-all text-foreground/90`,children:r})]},e)})})]})},GBt=({openApiFileModel:e,onOpenApiFileSynced:t,setIsOpen:n})=>{let[r,i]=(0,H.useState)(),a=ip(),o=e=>{i(e)},s=async()=>{if(!r)throw Error(`No file selected`);let i=e.content?JSON.parse(e.content):null;t(i?Eut(i,r.content):r.content),n(!1),a.success(`OpenAPI file merged successfully`,{icon:(0,U.jsx)(epe,{className:`h-4 w-4`})})};if(r){let t=jut(JSON.parse(e.content??`{}`),r.content);return(0,U.jsx)(a1,{isOpen:!0,setIsOpen:n,title:`Review OpenAPI import`,className:`sm:max-w-4xl max-h-[88vh] overflow-y-auto`,icon:(0,U.jsx)(Yy,{className:`shrink-0 h-6 w-6 text-brand`}),iconStyle:`bg-zuplo-pink/10`,buttons:[{onButtonClick:()=>{n(!1)},variant:`outline`,buttonContent:`Cancel`,id:`Close merge open-api modal`,testID:`merge-cancel-btn`},{onButtonClick:s,variant:`brand`,buttonContent:`Import changes`,id:`Complete open-api merge`,testID:`complete-merge-btn`}],bodyComponent:(0,U.jsxs)(`div`,{className:`mt-6 text-left text-sm`,children:[(0,U.jsx)(`div`,{className:`overflow-hidden rounded-3xl bg-gradient-to-br from-brand/12 via-background to-background p-px shadow-lg shadow-brand/5`,children:(0,U.jsxs)(`div`,{className:`rounded-[calc(1.5rem-1px)] bg-background p-5`,children:[(0,U.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[1fr_auto_1fr] md:items-center`,children:[(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-brand/10 text-brand`,children:(0,U.jsx)(Tpe,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Import file`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:r.name})]})]})}),(0,U.jsx)(`div`,{className:`hidden h-10 w-10 items-center justify-center rounded-full bg-brand text-brand-foreground shadow-sm shadow-brand/24 md:flex`,children:(0,U.jsx)(Yy,{className:`h-5 w-5`})}),(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,children:(0,U.jsx)(tb,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Current API`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:e.path})]})]})})]}),(0,U.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2 text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:`Operations are matched by`}),(0,U.jsx)(OO,{variant:`outline`,children:`Path + method`}),(0,U.jsx)(`span`,{children:`so existing Zuplo extensions and policies stay in place.`})]})]})}),(0,U.jsxs)(`div`,{className:`mt-6 flex items-end justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:`Import summary`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Review what will change before applying this file.`})]}),(0,U.jsxs)(`div`,{className:`rounded-full bg-surface-sunken px-3 py-1 text-xs font-medium text-muted-foreground tabular-nums`,children:[t.created.size+t.merged.size+t.retained.size,` `,`operations`]})]}),(0,U.jsxs)(`div`,{className:`mt-3 grid max-h-96 gap-3 overflow-y-auto rounded-3xl bg-surface-sunken p-3 shadow-[inset_0_1px_rgba(255,255,255,0.04)]`,children:[t.created.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(Gpe,{className:`h-4 w-4`}),title:`Create`,tone:`create`,operations:t.created}):null,t.merged.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(Hpe,{className:`h-4 w-4`}),title:`Update`,tone:`update`,operations:t.merged}):null,t.retained.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(tpe,{className:`h-4 w-4`}),title:`Keep`,tone:`keep`,operations:t.retained}):null]})]})})}return(0,U.jsx)(bvt,{title:`Import OpenAPI`,onValidFileSelected:o,setIsOpen:n})},KBt=()=>{let e=Dt(),t=je({mutationFn:t=>e.fetch(tn.users.updatePreferences(t))}),{data:n}=qb(mt.user.preferences());return{preferences:n,updatePreferences:t.mutate,updatePreferencesMutation:t}},qBt=!1;function v8(){let e=at(),{preferences:t,updatePreferencesMutation:n}=KBt();return{isFileTreeOpen:t.fileTreeOpen??qBt,setIsFileTreeOpen:r=>{let i=[mt.user.preferences().url,!0],a=e.getQueryData(i),o={...a??t,fileTreeOpen:r};e.setQueryData(i,o),n.mutate(o,{onError:()=>{a&&e.setQueryData(i,a),e.invalidateQueries({queryKey:i})}})}}}function JBt(){let e=qZ(),{logEvent:t}=on(),[n,r]=wY(`v`,`designer`),{isFileTreeOpen:i}=v8(),a=e?.path.split(`/`).pop()??`JSON`,o=JZ(),s=Svt(),[c,l]=x$(()=>{if(!e)throw Error(`File model not found`);return t(`merge-open-api`),(0,U.jsx)(GBt,{openApiFileModel:e,onOpenApiFileSynced:n=>{let r={...e,content:JSON.stringify(n,null,2)};o(r,!0),t(`merge-open-api-complete`),s(r.path)},setIsOpen:l})},[e,s]);return(0,U.jsx)(nyt,{children:(0,U.jsx)($_t,{children:(0,U.jsxs)(Sk,{defaultValue:`designer`,value:n,onValueChange:e=>r(e),className:`flex flex-col h-full w-full max-h-screen min-w-[850px]`,children:[i&&(0,U.jsxs)(Ck,{className:`rounded-none border-b w-full justify-start`,children:[(0,U.jsx)(wk,{value:`designer`,children:`Route Designer`}),(0,U.jsx)(wk,{value:`raw`,children:a??`Raw`}),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,onClick:c,className:`ml-4`,children:[(0,U.jsx)($pe,{className:`w-4 h-4`}),` Import`]})]}),(0,U.jsx)(Tk,{value:`designer`,className:`grow h-full overflow-y-auto`,children:(0,U.jsx)(svt,{onNavigateToOpenApiFileTab:()=>r(`raw`),children:(0,U.jsx)(UBt,{onNavigateToOpenApiFileTab:()=>r(`raw`)})})}),(0,U.jsx)(Tk,{value:`raw`,className:`grow h-full overflow-y-auto`,forceMount:!0,children:(0,U.jsx)(oQ,{})})]})})})}function YBt({title:e,description:t,folder:n,icon:r,emptyText:i,newLabel:a,onCreate:o}){let s=hp(e=>e.projectTreeNodes),[c,l]=Ms(),{isReadOnly:u}=jZ(),d=n.endsWith(`/`)?n:`${n}/`,f=(0,H.useMemo)(()=>s.filter(e=>e.type===Us.File&&e.path.startsWith(d)).sort((e,t)=>e.path.localeCompare(t.path)),[s,d]),p=e=>{let t=new URLSearchParams(c);t.set(`path`,e),t.delete(`v`),t.delete(`line`),l(t)};return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:e}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:t})]}),!u&&(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,onClick:o,className:`shrink-0`,children:[(0,U.jsx)(hf,{className:`size-4`}),a]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:f.length===0?(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:i}):f.map(e=>{let t=e.path.slice(d.length);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:W(`group flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors`,`bg-surface hover:border-brand/40 hover:bg-brand/5`,`ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`),children:[(0,U.jsx)(r,{className:`size-4 shrink-0 text-neutral-500 group-hover:text-brand`}),(0,U.jsx)(`span`,{className:`truncate text-sm font-medium text-neutral-800 dark:text-neutral-200`,children:t})]},e.path)})})]})})}function XBt(){let e=hp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=v8();return(0,U.jsx)(YBt,{title:`Custom Modules`,description:`TypeScript modules in your project's modules/ folder — request handlers, policies, and other custom code.`,folder:`/modules`,icon:uf,emptyText:`No custom modules yet. Create one to add request handlers or custom logic.`,newLabel:`New Module`,onCreate:()=>{t(!0),e({strategyFolder:`/modules`,template:`Request Handler`})}})}function ZBt(){let e=hp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=v8();return(0,U.jsx)(YBt,{title:`Schemas`,description:`JSON schemas in your project's schemas/ folder, used to validate requests and responses.`,folder:`/schemas`,icon:jd,emptyText:`No schemas yet. Create one to validate request or response bodies.`,newLabel:`New Schema`,onCreate:()=>{t(!0),e({strategyFolder:`/schemas`,template:`Schema`})}})}var QBt=()=>{let[e,t]=(0,H.useState)(),{isReadOnly:n}=jZ(),r=g1(),i=r.policiesUsageInfo,{logEvent:a}=on(),o=op([`account`,`project`,`environment`]),[s,c]=x$(()=>e?(0,U.jsx)(DIt,{isOpen:!0,setIsOpen:c,stackType:e,shouldHideExistingPolicies:!0,policyManager:r}):null,[e]),l=e=>{t(e),a(`create-policy-clicked`,{account:o.account.name,project:o.project.name,environment:o.environment.name,type:e}),s()},u=(r.policyList??[]).flatMap(e=>i?.find(t=>t.name===e.name)??[]);return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:`Policies`}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:`Reusable policies from your project's config/policies.json — apply them to routes to inspect and control requests and responses.`})]}),!n&&(0,U.jsxs)(aJ,{modal:!1,children:[(0,U.jsx)(oJ,{asChild:!0,children:(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,className:`shrink-0`,children:[(0,U.jsx)(hf,{className:`size-4`}),`New Policy`]})}),(0,U.jsxs)(sJ,{align:`end`,children:[(0,U.jsxs)(lJ,{onClick:()=>l(`inbound`),children:[(0,U.jsx)(Iu,{className:`mr-2 size-4`}),`Inbound Policy`]}),(0,U.jsxs)(lJ,{onClick:()=>l(`outbound`),children:[(0,U.jsx)(zu,{className:`mr-2 size-4`}),`Outbound Policy`]})]})]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:u.length===0?(0,U.jsxs)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:[`No policies yet. Create an inbound or outbound policy to inspect and control requests and responses, or`,` `,(0,U.jsx)(Rw,{href:`https://zuplo.com/docs/overview/policies`,children:`read the docs`}),`.`]}):u.map(e=>(0,U.jsx)(bIt,{policy:e},e.name))})]})})},$Bt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DeploymentLogState=void 0;var t;(function(e){e.ERROR=`ERROR`,e.IN_PROGRESS=`IN_PROGRESS`,e.SUCCESS=`SUCCESS`})(t||(e.DeploymentLogState=t={}))})),eVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SourceControlProvider=e.PlanType=e.EnvironmentType=e.EnvironmentTarget=e.DeploymentState=void 0;var t;(function(e){e[e.IS_STARTING=0]=`IS_STARTING`,e[e.STARTED=1]=`STARTED`,e[e.STOPPED=2]=`STOPPED`,e[e.ERRORED=3]=`ERRORED`})(t||(e.DeploymentState=t={}));var n;(function(e){e.CLOUDFLARE=`CLOUDFLARE`,e.KNATIVE=`KNATIVE`})(n||(e.EnvironmentTarget=n={}));var r;(function(e){e.PRODUCTION=`PRODUCTION`,e.PREVIEW=`PREVIEW`,e.WORKING_COPY=`WORKING_COPY`})(r||(e.EnvironmentType=r={}));var i;(function(e){e.FREE_V1=`FREE_V1`,e.BUILDER_V1=`BUILDER_V1`,e.BUSINESS_V1=`BUSINESS_V1`,e.CUSTOM=`CUSTOM`,e.EMPLOYEE=`EMPLOYEE`,e.CUSTOM_TRIAL_V1=`CUSTOM_TRIAL_V1`})(i||(e.PlanType=i={}));var a;(function(e){e.GITHUB=`GITHUB`,e.GITLAB=`GITLAB`,e.BITBUCKET=`BITBUCKET`})(a||(e.SourceControlProvider=a={}))})),tVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),nVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.INTERNAL_ROUTE_VENDOR_TAG=e.ZUPLO_OPEN_API_ROUTE_KEY=e.ZUPLO_OPEN_API_PATH_KEY=e.ZUPLO_OPEN_API_VENDOR_PREFIX=void 0,e.ZUPLO_OPEN_API_VENDOR_PREFIX=`x-zuplo`,e.ZUPLO_OPEN_API_PATH_KEY=`${e.ZUPLO_OPEN_API_VENDOR_PREFIX}-path`,e.ZUPLO_OPEN_API_ROUTE_KEY=`${e.ZUPLO_OPEN_API_VENDOR_PREFIX}-route`,e.INTERNAL_ROUTE_VENDOR_TAG=`x-internal`})),rVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.processJsonErrorObject=void 0;var t={'must match pattern "^[0-9a-z-]+$"':`Value must be alphanumeric or dash '-' only`,'must match pattern "^\\$import\\([^ )]*?\\)$"':`Value must be of form '$import(./path/to/module)`},n={'must match pattern "^[0-9a-z-]+$"':`Make sure the value uses only lowercase letters, numbers and dashes ('-').`,'must match pattern "^\\$import\\([^ )]*?\\)$"':`Value must be of form '$import(./path/to/module)`},r=e=>e.replace(`/`,``).replaceAll(`/`,` → `).replaceAll(`~1`,`/`),i={paths:`paths`};function a(e,a){let o=e.message,s=e.details?.property??``,c=e.details?.index??0,l=e.details?.field,u=e.details?.fieldValue,d=e.keyword,f=e.params,p=e.propertyName,m=r(e.instancePath),h=t[o]??o,g,_;if(d===`unevaluatedProperties`)g=`Unrecognized property '${f.unevaluatedProperty}'${l?` detected in '${l}'`:``} within '${a}'. Property location: ${m}.`;else if(d===`additionalProperties`)g=`Unrecognized property '${f.additionalProperty}'${l?` detected in '${l}'`:``} within '${a}'. Property location: ${m}.`;else if(d===`enum`)g=`Unrecognized value${u?` '${u}'`:``} for '${l}' detected in '${a}'. Value ${h}. Property location: ${m}.`;else if(d===`pattern`){let e=f.pattern;g=p?`Property name '${p}' does not match pattern ${e} in '${a}'. Property location: ${m}.`:`Invalid value '${u}' for field '${l}' in '${a}'. Value does not match pattern ${e}. Property location: ${m}.`}else d===`propertyNames`?g=`Invalid property name '${f.propertyName}' for property '${s}' detected in '${a}'. Property location: ${m}.`:d===`required`?g=`Missing required property '${f.missingProperty}' in '${a}'. Property location: ${m}.`:l&&s?(g=`Property ${i[s]} entry at position ${c+1} in '${a}' has invalid ${l} with value '${e.details?.fieldValue}' (${h})`,_={field:l,fieldValue:e.details?.fieldValue??``,property:s,instancePath:m,suggestion:n[o]??``}):g=s?`The ${i[s]} entry at position ${c+1} in '${a}' is invalid (${h})`:`The '${a}' configuration is invalid (${h})`;return{property:s,entry:{message:g,index:c,field:l,details:_}}}e.processJsonErrorObject=a})),iVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.startsWithReservedKeyword=void 0;var t=[`settings`,`user`,`manage`,`profile`,`login`,`logout`,`admin`,`system`,`account`,`accounts`,`home`,`dashboard`];function n(e){return t.filter(t=>e.startsWith(t)).length>0}e.startsWithReservedKeyword=n})),aVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isValidProjectName=e.MAX_PRETTY_BRANCH_LENGTH=e.MAX_HASH_LENGTH=void 0;var t=iVt();e.MAX_HASH_LENGTH=7,e.MAX_PRETTY_BRANCH_LENGTH=10;var n=40;function r(e){let r={isValid:!0};return e.length===0?(r.isValid=!1,r.errorMessage=`Project name cannot be empty`,r):(0,t.startsWithReservedKeyword)(e)?(r.isValid=!1,r.errorMessage=`Project name can not start with a reserved keyword`,r):/[\s]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name can't contain spaces`,r):/[A-Z]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should be in lowercase`,r):/^[^a-z]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should start with a letter`,r):/[^a-z0-9]$/.test(e)?(r.isValid=!1,r.errorMessage=`Project name should end with a letter or number`,r):/[^a-z0-9\\-]/.test(e)?(r.isValid=!1,r.errorMessage=`Project name only can contain letter, numbers and dashes`,r):(e.length>n&&(r.isValid=!1,r.errorMessage=`Project name cannot exceed ${n} characters because it needs to be part of the URL subdomain. Your chosen name is ${e.length-n} over.`),r)}e.isValidProjectName=r})),oVt=i({$defs:()=>w8,$id:()=>b8,$schema:()=>y8,additionalProperties:()=>!1,default:()=>sVt,description:()=>``,properties:()=>T8,required:()=>C8,title:()=>x8,type:()=>S8}),y8,b8,x8,S8,C8,w8,T8,sVt,cVt=n((()=>{y8=`https://json-schema.org/draft/2020-12/schema`,b8=`http://schemas.zuplo.com/route.json`,x8=`Route Config File`,S8=`object`,C8=[`routes`,`versions`],w8={corsPolicy:{type:`string`,pattern:`^[0-9a-z-]+$`},httpMethod:{type:`string`,enum:[`GET`,`HEAD`,`POST`,`PUT`,`DELETE`,`CONNECT`,`OPTIONS`,`TRACE`,`PATCH`]},handlerDefinition:{type:`object`,properties:{module:{type:`string`,pattern:`^\\$import\\([^ )]*?\\)$`},export:{type:`string`},options:{type:`object`,additionalProperties:!0}},additionalProperties:!1,required:[`module`,`export`]},schema:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:[`object`,`boolean`]},parameterBaseObject:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:`object`,properties:{description:{type:`string`},required:{default:!1,type:`boolean`},deprecated:{default:!1,type:`boolean`},schema:{$ref:`#/$defs/schema`}},required:[`schema`]},parameterDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#parameter-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,properties:{name:{type:`string`},in:{type:`string`,enum:[`query`,`header`,`path`,`cookie`]}},required:[`name`,`in`,`schema`],if:{type:`object`,properties:{in:{const:`query`}},required:[`in`]},then:{type:`object`,properties:{allowEmptyValue:{default:!1,type:`boolean`}}}},"media-type":{$comment:`https://spec.openapis.org/oas/v3.1.0#media-type-object`,type:`object`,properties:{schema:{$ref:`#/$defs/schema`}},unevaluatedProperties:!1},content:{$comment:`https://spec.openapis.org/oas/v3.1.0#fixed-fields-10`,type:`object`,additionalProperties:{$ref:`#/$defs/media-type`},propertyNames:{enum:[`application/json`,`application/problem+json`]}},header:{$comment:`https://spec.openapis.org/oas/v3.1.0#header-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,required:[`schema`]},response:{$comment:`https://spec.openapis.org/oas/v3.1.0#response-object`,type:`object`,properties:{description:{type:`string`},headers:{type:`object`,additionalProperties:{$ref:`#/$defs/header`}},content:{$ref:`#/$defs/content`}},required:[`description`],unevaluatedProperties:!1},responsesDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#responses-object`,type:`object`,properties:{default:{$ref:`#/$defs/response`}},patternProperties:{"^[1-5](?:[0-9]{2}|XX)$":{$ref:`#/$defs/response`}},minProperties:1,unevaluatedProperties:!1},tag:{$comment:`https://spec.openapis.org/oas/v3.1.0#tag-object`,type:`object`,properties:{name:{type:`string`},description:{type:`string`}},required:[`name`],unevaluatedProperties:!1},info:{type:`object`,required:[`title`,`version`],properties:{title:{type:`string`},summary:{type:`string`},description:{type:`string`},termsOfService:{type:`string`,format:`uri`},version:{type:`string`}}},versionData:{type:`object`,required:[`name`,`pathPrefix`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},pathPrefix:{type:`string`,pattern:`(^$|^/[^\\s]*$)`},info:{$ref:`#/$defs/info`},openApiFile:{description:`The project relative path to the OpenAPI spec.`,type:`string`},tags:{type:`array`,items:{$ref:`#/$defs/tag`}},excludeFromOpenApi:{type:`boolean`,description:`If false, OpenAPI documentation will not be generated for this version. If openApiFile is set this setting is ignored.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`}}},routeConfiguration:{type:`object`,required:[`path`,`methods`,`handler`,`version`],additionalProperties:!1,properties:{operationId:{type:`string`},path:{type:`string`,pattern:`^/[^\\s]*$`},methods:{type:`array`,items:{$ref:`#/$defs/httpMethod`}},label:{type:`string`,description:`An internal user-friendly identifier of the route.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`},key:{type:`string`,deprecated:!0},handler:{$ref:`#/$defs/handlerDefinition`},corsPolicy:{$ref:`#/$defs/corsPolicy`},custom:{},version:{type:`string`,pattern:`^[0-9a-z-]+$`},policies:{type:`object`,additionalProperties:!1,properties:{inbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}},outbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}}}},summary:{type:`string`},description:{type:`string`},parameters:{type:`array`,items:{$ref:`#/$defs/parameterDefinition`}},excludeFromOpenApi:{type:`boolean`},responses:{$ref:`#/$defs/responsesDefinition`},tags:{type:`array`,items:{type:`string`}}}},policyConfiguration:{type:`object`,required:[`name`,`policyType`,`handler`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},policyType:{type:`string`},handler:{$ref:`#/$defs/handlerDefinition`},options:{type:`object`,additionalProperties:!0}}},corsPolicyConfiguration:{type:`object`,required:[`name`,`allowedOrigins`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},allowCredentials:{type:`boolean`},maxAge:{type:`number`},allowedOrigins:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},allowedMethods:{oneOf:[{type:`array`,items:{$ref:`#/$defs/httpMethod`}},{type:`string`}]},allowedHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},exposeHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]}}}},T8={$schema:{type:`string`},info:{$ref:`#/$defs/info`,deprecated:!0},versions:{type:`array`,minItems:1,items:{$ref:`#/$defs/versionData`}},routes:{type:`array`,minItems:0,items:{$ref:`#/$defs/routeConfiguration`}},policies:{type:`array`,items:{$ref:`#/$defs/policyConfiguration`}},corsPolicies:{type:`array`,items:{$ref:`#/$defs/corsPolicyConfiguration`}},requestErrorHandler:{$ref:`#/$defs/handlerDefinition`}},sVt={$schema:y8,$id:b8,title:x8,description:``,type:S8,additionalProperties:!1,required:C8,$defs:w8,properties:T8}})),lVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c,l),"date-time":t(d,f),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:h,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:w,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:_,int32:{type:`number`,validate:b},int64:{type:`number`,validate:x},float:{type:`number`,validate:S},double:{type:`number`,validate:S},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,f),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function c(e,t){let n=s.exec(e);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[5];return(r<=23&&i<=59&&a<=59||r===23&&i===59&&a===60)&&(!t||o!==``)}function l(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3]+(n[4]||``),t=r[1]+r[2]+r[3]+(r[4]||``),e>t?1:e<t?-1:0}var u=/t|\s/i;function d(e){let t=e.split(u);return t.length===2&&a(t[0])&&c(t[1],!0)}function f(e,t){if(!(e&&t))return;let[n,r]=e.split(u),[i,a]=t.split(u),s=o(n,i);if(s!==void 0)return s||l(r,a)}var p=/\/|:/,m=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function h(e){return p.test(e)&&m.test(e)}var g=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function _(e){return g.lastIndex=0,g.test(e)}var v=-(2**31),y=2**31-1;function b(e){return Number.isInteger(e)&&e<=y&&e>=v}function x(e){return Number.isInteger(e)}function S(){return!0}var C=/[^\\]\\Z/;function w(e){if(C.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),E8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),uVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=E8(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r=e.UsedValueState||={}),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),D8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=E8(),n=uVt(),r=E8();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=uVt();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
1566
1566
|
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${L(e)}`}e.not=j;var M=I(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=I(e.operators.OR);function F(...e){return e.reduce(P)}e.or=F;function I(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${L(n)} ${e} ${L(r)}`}function L(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),O8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=D8(),n=E8();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y=e.Type||={});function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),k8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=D8();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),A8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=D8(),n=O8(),r=k8();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),dVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=A8(),n=D8(),r=k8(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),fVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),pVt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),j8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=fVt(),n=pVt(),r=A8(),i=D8(),a=O8(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o=e.DataType||={});function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
1567
1567
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
1568
1568
|
|| (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
|