@zuplo/editor 1.0.39599512467 → 1.0.39603386871
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 +1 -1
- package/dist/client/static/js/{GraphiQLConsole-DXGTvWaz.js → GraphiQLConsole-DwFr-ErF.js} +4 -4
- package/dist/client/static/js/{McpCapabilityFilterDesigner-Y6K_fhN4.js → McpCapabilityFilterDesigner-D6thjIZK.js} +1 -1
- package/dist/client/static/js/{SchemaReference-C7JiVr1-.js → SchemaReference-CxbSOShG.js} +1 -1
- package/dist/client/static/js/{esm-CQgQ3ofW.js → esm-zH1nNC3k.js} +1 -1
- package/dist/client/static/js/{hint-Baeg6JQ_.js → hint-B4xy5KbC.js} +1 -1
- package/dist/client/static/js/{hint-FiiNk9zP.js → hint-CBEA_b_Q.js} +1 -1
- package/dist/client/static/js/{info-Bf6GWCZq.js → info-Du4AjZuV.js} +1 -1
- package/dist/client/static/js/{jump-DUeH5zrv.js → jump-CVv2vjEa.js} +1 -1
- package/dist/client/static/js/{lint-BBeNv-FO.js → lint-DRmJndLt.js} +1 -1
- package/dist/client/static/js/{main-Btu6gjTU.js → main-qL9GBAvf.js} +5 -5
- package/dist/client/static/js/{mode-goIghDVK.js → mode-CWjkrT4h.js} +1 -1
- package/dist/client/static/js/{mode-CIPXOEDg.js → mode-DSaR-3CK.js} +1 -1
- package/dist/client/static/js/{mode-feZN4MkV.js → mode-DivjVJcf.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-D6thjIZK.js","static/js/dist-DtRuiixr.js","static/js/GraphiQLConsole-DwFr-ErF.js","static/js/esm-zH1nNC3k.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,Gn as D,Gt as O,H as k,Hn as A,Ht as j,I as M,In as N,It as P,Jn as F,Jt as I,Kn as L,Kt as R,L as z,Ln as B,Lt as V,M as ee,Mn as H,Mt as te,N as ne,Nn as re,Nt as ie,O as ae,On as oe,Ot as se,P as ce,Pn as le,Pt as ue,Q as de,Qn as fe,Qt as pe,R as me,Rn as he,Rt as ge,S as _e,Sn as ve,St as ye,T as be,Tn as xe,Tt as Se,U as Ce,Un as we,Ut as Te,Vn as Ee,Vt as De,Wn as Oe,Wt as ke,Xn as Ae,Xt as je,Yn as Me,Yt as Ne,Z as Pe,Zn as Fe,Zt as Ie,_ as Le,_n as Re,_t as ze,a as Be,an as Ve,ar as He,at as Ue,b as We,bn as Ge,bt as Ke,c as qe,cn as Je,cr as Ye,ct as Xe,d as Ze,dn as Qe,dr as $e,dt as et,en as tt,er as nt,et as rt,f as it,fn as at,fr as ot,ft as st,g as ct,gn as lt,gt as ut,h as dt,hn as ft,ht as pt,i as mt,in as ht,ir as gt,it as _t,j as vt,jn as yt,jt as bt,k as xt,kn as St,kt as Ct,l as wt,ln as Tt,lr as Et,lt as Dt,m as Ot,mn as kt,mt as At,n as jt,nn as Mt,nr as Nt,nt as Pt,o as Ft,on as It,or as Lt,ot as Rt,p as zt,pn as Bt,pr as Vt,pt as Ht,qn as Ut,qt as Wt,r as Gt,rn as Kt,rr as qt,rt as Jt,s as Yt,sn as Xt,sr as Zt,st as Qt,t as $t,tn as en,tr as tn,tt as nn,u as rn,un as an,ur as on,ut as sn,v as cn,vn as ln,vt as un,w as dn,wn as fn,wt as pn,x as mn,xn as hn,xt as gn,y as _n,yn as vn,yt as yn,z as bn,zn as xn,zt as Sn}from"./dist-DtRuiixr.js";import{t as Cn}from"./preload-helper-DxkSl20Q.js";import{$ as eee,C as wn,E as Tn,F as En,G as Dn,I as On,J as kn,K as An,M as jn,O as Mn,P as Nn,Q as Pn,S as Fn,V as In,X as tee,Y as Ln,Z as nee,_ as Rn,a as zn,at as Bn,b as Vn,c as Hn,ct as Un,d as Wn,et as Gn,f as Kn,h as ree,i as qn,k as iee,l as Jn,lt as Yn,m as Xn,n as Zn,nt as aee,o as Qn,p as $n,r as er,rt as tr,s as nr,st as rr,t as ir,tt as ar,ut as or,w as sr,x as oee,y as cr}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 see=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}}}})),cee=a(((e,t)=>{t.exports=see()})),lr=a((e=>{var t=cee(),n=Vt(),r=ot();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 V=R(null),ee=R(null),H=R(null),te=R(null);function ne(e,t){switch(B(H,t),B(ee,e),B(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?bd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=bd(t),e=xd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(V),B(V,e)}function re(){z(V),z(ee),z(H)}function ie(e){e.memoizedState!==null&&B(te,e);var t=V.current,n=xd(t,e.type);t!==n&&(B(ee,e),B(V,n))}function ae(e){ee.current===e&&(z(V),z(ee)),te.current===e&&(z(te),G._currentValue=F)}var oe,se;function ce(e){if(oe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);oe=t&&t[1]||``,se=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+oe+e+se}var le=!1;function ue(e,t){if(!e||le)return``;le=!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(`
|
|
@@ -348,7 +348,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
348
348
|
`+e.slice(o+1):c+=e.slice(i),c.slice(1)}function vft(e){for(var t=``,n=0,r,i=0;i<e.length;n>=65536?i+=2:i++)n=PZ(e,i),r=kZ[n],!r&&NZ(n)?(t+=e[i],n>=65536&&(t+=e[i+1])):t+=r||$dt(n);return t}function yft(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)),(LZ(e,t,s,!1,!1)||s===void 0&&LZ(e,t,null,!1,!1))&&(r!==``&&(r+=`,`+(e.condenseFlow?``:` `)),r+=e.dump);e.tag=i,e.dump=`[`+r+`]`}function bft(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)),(LZ(e,t+1,c,!0,!0,!1,!0)||c===void 0&&LZ(e,t+1,null,!0,!0,!1,!0))&&((!r||i!==``)&&(i+=jZ(e,t)),e.dump&&EZ===e.dump.charCodeAt(0)?i+=`-`:i+=`- `,i+=e.dump);e.tag=a,e.dump=i||`[]`}function xft(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)),LZ(e,t,c,!1,!1)&&(e.dump.length>1024&&(u+=`? `),u+=e.dump+(e.condenseFlow?`"`:``)+`:`+(e.condenseFlow?``:` `),LZ(e,t,l,!1,!1)&&(u+=e.dump,r+=u));e.tag=i,e.dump=`{`+r+`}`}function Sft(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 eZ(`sortKeys must be a boolean or a function`);for(s=0,c=o.length;s<c;s+=1)f=``,(!r||i!==``)&&(f+=jZ(e,t)),l=o[s],u=n[l],e.replacer&&(u=e.replacer.call(n,l,u)),LZ(e,t+1,l,!0,!0,!0)&&(d=e.tag!==null&&e.tag!==`?`||e.dump&&e.dump.length>1024,d&&(e.dump&&EZ===e.dump.charCodeAt(0)?f+=`?`:f+=`? `),f+=e.dump,d&&(f+=jZ(e,t)),LZ(e,t+1,u,!0,d)&&(e.dump&&EZ===e.dump.charCodeAt(0)?f+=`:`:f+=`: `,f+=e.dump,i+=f));e.tag=a,e.dump=i||`{}`}function Cft(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,Ddt.call(s.represent)===`[object Function]`)r=s.represent(t,c);else if(Odt.call(s.represent,c))r=s.represent[c](t,c);else throw new eZ(`!<`+s.tag+`> tag resolver accepts not "`+c+`" style`);e.dump=r}return!0}return!1}function LZ(e,t,n,r,i,a,o){e.tag=null,e.dump=n,Cft(e,n,!1)||Cft(e,n,!0);var s=Ddt.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?(Sft(e,t,e.dump,i),f&&(e.dump=`&ref_`+d+e.dump)):(xft(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?bft(e,t-1,e.dump,i):bft(e,t,e.dump,i),f&&(e.dump=`&ref_`+d+e.dump)):(yft(e,t,e.dump),f&&(e.dump=`&ref_`+d+` `+e.dump));else if(s===`[object String]`)e.tag!==`?`&&pft(e,e.dump,t,a,c);else if(s===`[object Undefined]`)return!1;else{if(e.skipInvalid)return!1;throw new eZ(`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 wft(e,t){var n=[],r=[],i,a;for(RZ(e,n,r),i=0,a=r.length;i<a;i+=1)t.duplicates.push(n[r[i]]);t.usedDuplicates=Array(a)}function RZ(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)RZ(e[i],t,n);else for(r=Object.keys(e),i=0,a=r.length;i<a;i+=1)RZ(e[r[i]],t,n)}function Tft(e,t){t||={};var n=new tft(t);n.noRefs||wft(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},``,r)),LZ(n,0,r,!0,!0)?n.dump+`
|
|
349
349
|
`:``}var Eft={dump:Tft};function zZ(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 Dft={Type:rZ,Schema:Ult,FAILSAFE_SCHEMA:qlt,JSON_SCHEMA:gut,CORE_SCHEMA:_ut,DEFAULT_SCHEMA:oZ,load:Edt.load,loadAll:Edt.loadAll,dump:Eft.dump,YAMLException:eZ,types:{binary:Aut,float:hut,map:Klt,null:Zlt,pairs:zut,set:Uut,timestamp:Cut,bool:tut,int:cut,merge:Tut,omap:Fut,seq:Glt,str:Wlt},safeLoad:zZ(`safeLoad`,`load`),safeLoadAll:zZ(`safeLoadAll`,`loadAll`),safeDump:zZ(`safeDump`,`dump`)},Oft=[`get`,`put`,`post`,`delete`,`options`,`head`,`patch`,`trace`],kft=async e=>{let t=await e.text();return e.name.endsWith(`.json`)?JSON.parse(t):Dft.load(t)},Aft=(e,t)=>jft(e,t),jft=(e,t)=>{let n=new Set(Object.values(e.paths??{}).flatMap(e=>e?Oft.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]=Pft(i??{},r,t,n),e},e.paths??{})),{info:t.info,openapi:Nft(e.openapi,t.openapi),components:Mft(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}},Mft=(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}},Nft=(e,t)=>e===`3.1.0`?e:t===`3.1.0`?t:e,Pft=(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[qX],_=typeof t==`object`&&t&&qX in t?t[qX]:void 0;return{summary:t.summary??i,description:t.description??a,[qX]:_??g,servers:t.servers??m,parameters:t.parameters??h,get:BZ(o,t.get,`get`,n,r),put:BZ(s,t.put,`put`,n,r),post:BZ(c,t.post,`post`,n,r),delete:BZ(l,t.delete,`delete`,n,r),options:BZ(u,t.options,`options`,n,r),head:BZ(d,t.head,`head`,n,r),patch:BZ(f,t.patch,`patch`,n,r),trace:BZ(p,t.trace,`trace`,n,r)}},BZ=(e,t,n,r,i)=>{if(!t)return e;let a=e?.operationId??t.operationId??WX(t,{method:n,path:r,existingOperationIds:i});i&&i.add(a);let o=e?.[JX];return{...t,operationId:a,[JX]:o}},Fft=(e,t)=>Ift(e,t),Ift=(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(VZ(o)),{created:n,merged:r,retained:i};if(!o&&a)return i=new Set(VZ(a)),{created:n,merged:r,retained:i};if(o&&a){let e=VZ(a),t=VZ(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}},VZ=e=>Object.entries(e).flatMap(([e,t])=>Object.keys(t).filter(e=>Oft.includes(e)).map(t=>`${t}>${e}`)),HZ=[`get`,`post`,`put`,`patch`,`delete`,`options`,`head`,`trace`],Lft=`$import(@zuplo/runtime)`,Rft=e=>{if(!e)return;let t=/^\$import\((.+)\)$/.exec(e);return t?t[1]:e},zft=e=>{try{return new URL(e).hostname}catch{return e}},Bft=e=>{let t=e.options??{};if(e.module===Lft)switch(e.export){case`urlForwardHandler`:{let e=typeof t.baseUrl==`string`?t.baseUrl:``;return{name:e?zft(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?zft(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:Rft(e.module),kind:`function`}},Vft=e=>JSON.stringify([e.export,e.module,e.options??null]),Hft=(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 HZ){let c=s[e];if(!c)continue;let l=c[JX],u,d=l?.handler;if(d&&(u=Vft(d),!i.has(u))){let e={key:u,definition:d,...Bft(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[KX]===!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]}},Uft=`/config/policies.json`,Wft=e=>[`api-flow-model`,e],Gft=(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:Hft(n,r),rawFiles:e,policiesFile:t,corsPolicies:i}},Kft=(e,t)=>je({enabled:t?.enabled,queryKey:Wft(e),queryFn:async()=>{let t=(await iu(e,`/`)).filter(e=>e.type===$l.File&&um.test(e.path)).map(e=>e.path),n={},[,r]=await Promise.all([Promise.all(t.map(async t=>{try{let r=await ru(e,t);n[t]={content:r.content??``,lastModified:r.lastModified}}catch{}})),ru(e,Uft).catch(()=>void 0)]);return Gft(n,r?{content:r.content??``,lastModified:r.lastModified}:void 0)}});function qft(e){if(typeof e!=`object`||!e)return{};let t=e;return{message:typeof t.message==`string`?t.message:void 0}}var Jft=e=>e.replace(/\.(oas\.)?(json|yaml|yml)$/i,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`imported`;function Yft({data:e,onSend:t,disabled:n,primaryProject:r}){let{account:i,project:a}=Ab([]),{logEvent:o}=H(),s=Je(),c=r??a,l=qP(i??``,c??``,{enabled:!!(i&&c)}),u=l.data?.find(e=>e.urlParameter===YP)?.name,[d,f]=(0,U.useState)(`idle`),[p,m]=(0,U.useState)(),[h,g]=(0,U.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 kft(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=Clt(n),a=JSON.stringify(r,null,2),l=await iu(u,`/config`).catch(()=>[]),d=new Set(l.map(e=>`/${e.path.replace(/^\/+/,``)}`)),p=Jft(e.name),m=`/config/${p}.oas.json`;for(let e=2;d.has(m);e++)m=`/config/${p}-${e}.oas.json`;await au(u,{path:m,content:a}),s.invalidateQueries({queryKey:[`reloadFiles`],exact:!1}),s.invalidateQueries({queryKey:Wft(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,W.jsx)(bIe,{data:e,status:d,fileName:p,errorText:h??v,disabled:n||!_||d===`saving`,onFileSelected:e=>void y(e)})}var Xft=`accountPlan`,Zft=`accountPremiumSupport`,Qft=e=>e.entitlements?.premiumSupport===!0;function $ft(e){return{[Xft]:e?.plan??null,[Zft]:e?Qft(e):null}}function ept(e,t){return`${e}\n\n${t}`}var tpt=`Support chat isn't available right now — email ${yb} instead.`,npt=`We couldn't confirm whether that went through, so it may already have been filed. Check the support widget before sending again — sending anyway can open a second ticket.`;function rpt({data:e,onSend:t,disabled:n}){let r=re(),{user:i}=N(),{account:a,project:o}=Ab([]),{data:s}=Ib({enabled:!!a}),{logEvent:c}=H(),l=lc(),[u,d]=(0,U.useState)(`idle`),[f,p]=(0,U.useState)(),[m,h]=(0,U.useState)(),g=async e=>{let n=$ft(s?.find(e=>e.name===a));d(`sending`),h(void 0),c(`agent-z-support-ticket-submitted`,{account:a,project:o});try{if(!r.conversations.isAvailable()){d(`error`),h(tpt),c(`agent-z-support-ticket-failed`,{account:a,project:o,reason:`unavailable`});return}let s=await r.conversations.sendMessage(ept(e.subject,e.message),{name:i?.name,email:i?.email},!0);if(!s){d(`error`),h(tpt),c(`agent-z-support-ticket-failed`,{account:a,project:o,reason:`no-response`});return}p(s.ticket_id),d(`sent`),c(`agent-z-support-ticket-created`,{account:a,project:o,ticketId:s.ticket_id,...n}),t(`I've sent the support ticket "${e.subject}". Its ticket ID is ${s.ticket_id}.`)}catch{d(`unconfirmed`),h(npt),c(`agent-z-support-ticket-failed`,{account:a,project:o,reason:`unconfirmed`})}};return(0,W.jsx)(SIe,{data:e,status:u,ticketId:f,errorText:m,disabled:n,onSubmit:e=>void g(e),onOpenTicket:f?()=>{c(`agent-z-support-ticket-opened`,{account:a,project:o,ticketId:f}),l(MFe(f))}:void 0})}var ipt=`$ai_feedback`;function apt({traceId:e,sessionId:t,account:n,project:r}){let{logEvent:i,captureRaw:a}=H(),[o,s]=(0,U.useState)(null);return(0,W.jsx)(eIe,{rating:o,onRate:c=>{o!==c&&(s(c),a(ipt,{$ai_trace_id:e,$ai_session_id:t,$ai_feedback_text:c===`up`?`thumbs up`:`thumbs down`,feedback_source:`user`,feedback_type:`thumbs`,feedback_value:c===`up`?1:-1,account:n,project:r}),i(`agent-z-response-rated`,{rating:c,hasTraceId:!!e,account:n,project:r}))}})}var opt=[{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`}],spt=[{id:`ai-user-setup-claude-code`,prompt:`How do I set up Claude Code with this gateway?`,category:`ai-user`},{id:`ai-user-setup-codex`,prompt:`How do I use Codex with this gateway?`,category:`ai-user`},{id:`ai-user-show-api-key`,prompt:`Show my API key`,category:`ai-user`},{id:`ai-user-gateway-url`,prompt:`What's my gateway URL?`,category:`ai-user`},{id:`ai-user-which-models`,prompt:`Which models can I use?`,category:`ai-user`},{id:`ai-user-explain-429`,prompt:`Why am I getting a 429?`,category:`ai-user`}];function cpt(e=4,t=Math.random,n=opt){let r=[...n],i=Math.max(0,Math.min(e,r.length));for(let e=0;e<i;e++){let n=Math.min(r.length-1,e+Math.floor(t()*(r.length-e)));[r[e],r[n]]=[r[n],r[e]]}return r.slice(0,i)}function lpt(){return crypto.randomUUID().replace(/-/g,``)}function upt(e){if(typeof e!=`object`||!e)return null;let t=e;return{description:typeof t.description==`string`?t.description:void 0}}function dpt({data:e}){let t=lc(),{account:n,project:r}=Ab([]),{logEvent:i}=H(),a=!!(n&&r);return(0,W.jsx)(hIe,{description:e.description,disabled:!a,onOpen:()=>{!n||!r||(i(`agent-z-update-working-copy-card-clicked`,{account:n,project:r}),t(`${fo(Cb.Code,{account:n,project:r,environment:YP})}?${C_e}=${w_e}`))}})}function fpt(e,t,n){let[r,i]=(0,U.useState)(void 0),a=r&&r.account===e?r.name:void 0,o=(0,U.useCallback)(t=>{let n=t.trim();n&&i({account:e,name:n})},[e]),s=(0,U.useCallback)(e=>e===a,[a]),c=(0,U.useRef)(void 0);return(0,U.useEffect)(()=>{let r=t?`${e??``}/${t}`:void 0;n&&t&&r!==c.current&&(o(t),c.current=r)},[n,e,t,o]),(0,U.useMemo)(()=>({name:a,select:o,isActive:s}),[a,o,s])}var ppt=new Set([`create-ai-team`,`create-ai-pool`,`create-ai-app`]);function mpt(e){let t=Je(),n=(0,U.useRef)(new Set);(0,U.useEffect)(()=>{let r=!1;for(let t of e)if(t.role===`assistant`)for(let e of t.parts){if(!tS(e)||!ppt.has(rS(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 hpt=`save-file`;function gpt(e){let t=Je(),n=(0,U.useRef)(new Set);(0,U.useEffect)(()=>{let r=!1;for(let t of e)if(t.role===`assistant`)for(let e of t.parts){if(!tS(e)||rS(e)!==hpt||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 _pt=`create-working-copy`;function vpt(e){let t=Je(),n=(0,U.useRef)(new Set);(0,U.useEffect)(()=>{let r=!1;for(let t of e)if(t.role===`assistant`)for(let e of t.parts){if(!tS(e)||rS(e)!==_pt||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 ypt(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 bpt(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 xpt(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 Spt=`https://zuplo.com/docs`;function Cpt(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:`${Spt}/${i.replace(/^\/?(docs\/)?/,``)}`,title:r}}function wpt({active:e}){let t=oe(),{logEvent:n}=H(),{account:r,project:i}=Ab([]),a=fpt(r,i,e),o=!!(r&&a.name),c=gDe(r??``,a.name??``,{enabled:o}),l=o?c.isAiUser?`ai-user`:c.isLoading?`pending`:`everyone`:`everyone`,{pendingPrompt:u,clearPendingPrompt:d}=WZ(),f=(0,U.useMemo)(()=>crypto.randomUUID(),[]),{messages:p,sendMessage:m,status:h,error:g,stop:_,addToolApprovalResponse:v}=Tye({transport:(0,U.useMemo)(()=>new iS({api:s}),[]),sendAutomaticallyWhen:xye,experimental_throttle:50});gpt(p),vpt(p),mpt(p);let[y,b]=(0,U.useState)(``),x=h===`submitted`||h===`streaming`,S=x&&p[p.length-1]?.role!==`assistant`,C=(0,U.useRef)(null),w=(0,U.useRef)(null),[T,E]=(0,U.useState)(!0),D=(0,U.useRef)(null),[O,k]=(0,U.useState)({}),A=(0,U.useRef)(null),j=(0,U.useRef)(void 0),M=(0,U.useRef)(!1),N=(0,U.useRef)(!1),P=(0,U.useRef)(!1);(0,U.useEffect)(()=>{if(!T)return;let e=C.current;e&&e.scrollTo({top:e.scrollHeight})},[p,h]);let F=()=>{let e=C.current;e&&E(e.scrollHeight-e.scrollTop-e.clientHeight<=32)},I=()=>{let e=C.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`}),E(!0)};(0,U.useEffect)(()=>{e&&w.current?.focus()},[e]);let L=async(e,o,s,c)=>{let l=e.trim();if(!l||x)return;let u=c??a.name;n(`agent-z-message-sent`,{source:o,ctaId:s,messageLength:l.length,isFirstMessage:p.length===0,account:r,project:i,hasProject:!!i,activeProject:u}),b(``),j.current=u,E(!0);let d=lpt();D.current={traceId:d,account:r,project:u};try{let e=await t();await m({text:l},{headers:{Authorization:`Bearer ${e}`},body:{accountName:r,projectName:u,sessionId:f,tracingOptions:{traceId:d}}})}catch{b(e=>e.length===0?l:e)}},R=async(e,o)=>{n(`agent-z-tool-approval-responded`,{approved:o,account:r,project:i});let s=p.find(t=>t.parts.some(t=>zFe(t)===e)),c=s?O[s.id]:void 0;c&&(D.current=c);try{await v({id:e,approved:o,options:{headers:{Authorization:`Bearer ${await t()}`},body:{accountName:r,projectName:j.current??a.name,sessionId:f,...c?{tracingOptions:{traceId:c.traceId}}:{}}}})}catch{}},z=e=>{a.isActive(e)||(a.select(e),n(`agent-z-active-project-changed`,{source:`suggestion`,account:r,project:e}),L(`Switched to ${e} — go ahead.`,`context-suggestion`,void 0,e))};(0,U.useEffect)(()=>{if(u&&!x){let e=i??a.name;i&&!a.isActive(i)&&a.select(i),L(u,`resolve-handoff`,void 0,e),d()}},[u,x,d]),(0,U.useEffect)(()=>{if(x&&A.current===null&&(A.current=performance.now()),M.current&&!x){let e=A.current,t=e===null?void 0:Math.round(performance.now()-e);if(A.current=null,N.current)N.current=!1;else if(!g){let e=[...p].reverse().find(e=>e.role===`assistant`);n(`agent-z-response-completed`,{durationMs:t,toolCallCount:e?.parts.filter(tS).length??0});let r=D.current;e&&r&&k(t=>t[e.id]?.traceId===r.traceId?t:{...t,[e.id]:r})}}M.current=x},[x,g,n]),(0,U.useEffect)(()=>{g&&!P.current?(P.current=!0,n(`agent-z-response-error`,{message:g.message})):g||(P.current=!1)},[g,n]);let B=e=>{e.preventDefault(),L(y,`composer`)},V=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),L(y,`composer`))};return(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-sunken`,children:[(0,W.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,W.jsx)(`div`,{ref:C,onScroll:F,className:`h-full overflow-y-auto`,children:(0,W.jsxs)(`div`,{className:`flex w-full flex-col gap-4 px-4 py-4`,children:[p.length===0?(0,W.jsx)(Opt,{active:e,audience:l,onPick:e=>void L(e.prompt,`suggested-prompt`,e.id)}):p.map((e,t)=>(0,W.jsx)(Tpt,{message:e,onSend:e=>void L(e,`option`),onApproval:(e,t)=>void R(e,t),onSwitchProject:z,isActiveProject:a.isActive,primaryProject:a.name,disabled:x,isStreaming:x&&t===p.length-1,turn:O[e.id],sessionId:f},e.id)),S?(0,W.jsx)($Fe,{children:(0,W.jsx)(wIe,{})}):null,g?(0,W.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]})}),T?null:(0,W.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,onClick:I,"aria-label":`Scroll to latest messages`,className:`-translate-x-1/2 absolute bottom-4 left-1/2 rounded-full shadow-md`,children:(0,W.jsx)(Af,{})})]}),(0,W.jsxs)(`div`,{className:`border-t bg-background`,children:[r?(0,W.jsx)(DAe,{accountName:r,active:a}):null,(0,W.jsxs)(`form`,{onSubmit:B,className:`flex w-full items-end gap-2 px-4 py-3`,children:[(0,W.jsx)(Lw,{ref:w,value:y,onChange:e=>b(e.target.value),onKeyDown:V,placeholder:`Ask Zuplo AI…`,rows:1,className:`max-h-48 min-h-9 resize-none py-1`}),x?(0,W.jsx)(Y,{type:`button`,variant:`outline`,size:`icon-lg`,onClick:()=>{N.current=!0,n(`agent-z-generation-stopped`),_()},"aria-label":`Stop generating`,children:(0,W.jsx)(Np,{})}):(0,W.jsx)(Y,{type:`submit`,size:`icon-lg`,disabled:y.trim().length===0,"aria-label":`Send message`,children:(0,W.jsx)(Ff,{})})]})]})]})}function Tpt({message:e,onSend:t,onApproval:n,onSwitchProject:r,isActiveProject:i,primaryProject:a,disabled:o,isStreaming:s,turn:c,sessionId:l}){let u=e.role===`user`,d=BFe(e),f=HFe(VFe(e.parts)),p=u?``:e.parts.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
|
|
350
350
|
|
|
351
|
-
`).trim();return(0,W.jsx)($Fe,{isUser:u,footer:!u&&!s?(0,W.jsxs)(`div`,{className:`mt-1 flex items-center gap-0.5`,children:[p?(0,W.jsx)(Ept,{text:p}):null,d?null:(0,W.jsx)(apt,{traceId:c?.traceId,sessionId:l,account:c?.account,project:c?.project})]}):null,children:!u&&f.length===0?(0,W.jsx)(wIe,{}):f.map(s=>s.kind===`tools`?(0,W.jsx)(rIe,{tools:s.tools},`${e.id}-${s.index}`):(0,W.jsx)(Dpt,{part:s.part,isUser:u,onSend:t,onApproval:n,onSwitchProject:r,isActiveProject:i,primaryProject:a,disabled:o},`${e.id}-${s.index}`))})}function Ept({text:e}){let{logEvent:t}=H(),{copyToClipboard:n,state:r}=zw(e,{onCopy:()=>t(`agent-z-response-copied`,{messageLength:e.length})}),i=r===`copied`;return(0,W.jsx)(Iw,{copied:i,children:(0,W.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>void n(),"aria-label":`Copy response`,title:`Copy response`,className:G(`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,W.jsx)(Xf,{className:`size-3.5`}):(0,W.jsx)(sp,{className:`size-3.5`})})})}function Dpt({part:e,isUser:t,onSend:n,onApproval:r,onSwitchProject:i,isActiveProject:a,primaryProject:o,disabled:s}){if(e.type===`text`)return t?(0,W.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.text}):(0,W.jsx)(kw,{content:e.text});if(e.type===`reasoning`)return e.text?(0,W.jsx)(iIe,{text:e.text}):null;if(tS(e)){let t=rS(e);if(RFe(e)){let n=e.state===`approval-requested`?{kind:`requested`}:e.state===`approval-responded`?{kind:`responded`,approved:e.approval.approved===!0}:{kind:`denied`};return(0,W.jsx)(CIe,{toolLabel:QFe(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=ypt(`input`in e?e.input:void 0);return t?(0,W.jsx)(aIe,{data:t,onSend:n,disabled:s}):null}if(t===`present-link`){let t=bpt(`input`in e?e.input:void 0);return t?(0,W.jsx)(oIe,{data:t}):null}if(t===`present-consumer`){let t=JWe(`input`in e?e.input:void 0);return t?(0,W.jsx)(YWe,{data:t}):null}if(t===`present-ai-api-key`){let t=kIe(`input`in e?e.input:void 0);return t?(0,W.jsx)(AIe,{data:t}):null}if(t===`present-environment-variable`){let t=TGe(`input`in e?e.input:void 0);return t?(0,W.jsx)(EGe,{data:t}):null}if(t===`present-source`){let t=Cpt(`input`in e?e.input:void 0);return t?(0,W.jsx)(sIe,{data:t}):null}if(t===`celebrate`){let t=TIe(`input`in e?e.input:void 0);return t?(0,W.jsx)(OIe,{data:t}):null}if(t===`present-file`){let t=DGe(`input`in e?e.input:void 0);return t?(0,W.jsx)(OGe,{data:t}):null}if(t===`present-support-ticket`){let t=kGe(`input`in e?e.input:void 0);return t?(0,W.jsx)(AGe,{data:t}):null}if(t===`show-test-console`){let t=Sat(`input`in e?e.input:void 0);return t?(0,W.jsx)(Cat,{data:t}):null}if(t===`switch-project`){let t=xpt(`input`in e?e.input:void 0);return t?(0,W.jsx)(mIe,{projectName:t.projectName,reason:t.reason,isActive:a(t.projectName),disabled:s,onSwitch:()=>i(t.projectName)}):null}if(t===`update-working-copy`){let t=upt(`input`in e?e.input:void 0);return t?(0,W.jsx)(dpt,{data:t}):null}if(t===`request-ai-provider`){let t=jAe(`input`in e?e.input:void 0);return t?(0,W.jsx)(vlt,{data:t}):null}if(t===`request-ai-team`){let t=MAe(`input`in e?e.input:void 0);return t?(0,W.jsx)(Fst,{data:t}):null}if(t===`request-ai-app`){let t=NAe(`input`in e?e.input:void 0);return t?(0,W.jsx)(wat,{data:t}):null}if(t===`request-support-ticket`&&e.state===`output-available`){let t=PAe(`input`in e?e.input:void 0);return t?(0,W.jsx)(rpt,{data:t,onSend:n,disabled:s}):null}return t===`request-openapi-import`?(0,W.jsx)(Yft,{data:qft(`input`in e?e.input:void 0),onSend:n,disabled:s,primaryProject:o}):(0,W.jsx)(rIe,{tools:[{name:t,pending:IFe(e)}]})}return null}function Opt({active:e,audience:t=`everyone`,onPick:n}){let{logEvent:r}=H(),i=(0,U.useMemo)(()=>t===`pending`?[]:t===`ai-user`?cpt(void 0,void 0,spt):cpt(),[t]);return(0,U.useEffect)(()=>{e&&i.forEach((e,t)=>{r(`agent-z-cta-shown`,{ctaId:e.id,ctaCategory:e.category,position:t,batchSize:i.length})})},[e,i,r]),(0,W.jsxs)(`div`,{className:`mt-8 flex flex-col items-center text-center`,children:[(0,W.jsx)(Sb,{"aria-hidden":!0,className:`size-14`}),(0,W.jsx)(`h2`,{className:`mt-4 text-lg font-medium`,children:`Ask Zuplo AI`}),(0,W.jsx)(`p`,{className:`mt-1 max-w-md text-sm text-muted-foreground`,children:t===`ai-user`?`Ask how to connect Claude Code or Codex to your AI Gateway, where your API key is, or why a request failed.`:`Your AI assistant — ask about your APIs, policies, deployments, and more, right where you’re working.`}),(0,W.jsx)(`div`,{className:`mt-6 flex flex-wrap justify-center gap-2`,children:i.map((e,t)=>(0,W.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{r(`agent-z-cta-clicked`,{ctaId:e.id,ctaCategory:e.category,position:t,batchSize:i.length}),n(e)},children:e.prompt},e.id))})]})}var kpt=`w-full max-w-[440px]`;function Apt(){let{isOpen:e,close:t}=WZ(),{logEvent:n}=H(),[r,i]=(0,U.useState)(0),{account:a}=Ab([]),o=Ib({enabled:!!a}),s=a?o.data?.find(e=>e.name===a):void 0,c=s?V_e(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,W.jsxs)(`aside`,{"aria-label":`Zuplo AI assistant`,inert:!e,onKeyDown:d,className:G(`fixed inset-y-0 right-0 z-40 flex flex-col border-l bg-background shadow-2xl`,kpt,`transition-transform duration-200 ease-in-out will-change-transform`,e?`translate-x-0`:`pointer-events-none translate-x-full`),children:[(0,W.jsxs)(`header`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,W.jsx)(Sb,{"aria-hidden":!0,className:`size-5`}),(0,W.jsx)(`span`,{className:`text-sm`,children:`Zuplo AI`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u||l?null:(0,W.jsxs)(Y,{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,W.jsx)(Op,{className:`size-4`}),`New chat`]}),(0,W.jsx)(Y,{variant:`ghost`,size:`icon-sm`,onClick:()=>{n(`agent-z-panel-closed`,{source:`close-button`}),t()},"aria-label":`Close Zuplo AI`,children:(0,W.jsx)(Up,{className:`size-4`})})]})]}),l?(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col justify-center overflow-y-auto bg-surface-sunken`,children:(0,W.jsx)(S_e,{})}):u?(0,W.jsx)(jpt,{active:e}):(0,W.jsx)(wpt,{active:e},r)]})}function jpt({active:e}){let{close:t}=WZ(),{logEvent:n}=H(),{account:r}=Ab([]);(0,U.useEffect)(()=>{e&&n(`agent-z-disabled-state-shown`)},[e,n]);let{isAdmin:i}=k_e(r??``);return(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col justify-center overflow-y-auto bg-surface-sunken`,children:(0,W.jsx)(_b,{title:`AI features are disabled`,description:`Zuplo AI is turned off for this account. Need a hand? Our support team is one click away.`,action:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[r?(0,W.jsx)(Y,{type:`button`,asChild:!0,children:(0,W.jsxs)(Pl,{to:Cb.Support,onClick:()=>{n(`agent-z-disabled-support-clicked`),t()},children:[(0,W.jsx)(Cp,{"aria-hidden":!0,className:`size-4`}),`Contact support`]})}):null,i&&r?(0,W.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,asChild:!0,children:(0,W.jsxs)(Pl,{to:fo(Cb.AccountSettings,{account:r}),children:[(0,W.jsx)(Hy,{weight:`fill`,"aria-hidden":!0,className:`size-4`}),`Enable AI features`]})}):null]})})})}var Mpt=null,UZ=new Set,Npt=e=>{Mpt=e;for(let e of UZ)e()},Ppt=e=>(UZ.add(e),()=>{UZ.delete(e)}),Fpt=()=>Mpt,Ipt=()=>(0,U.useSyncExternalStore)(Ppt,Fpt,Fpt),Lpt=(0,U.createContext)(void 0);function WZ(){let e=(0,U.useContext)(Lpt);if(!e)throw Error(`useAgentZPanel must be used within AgentZPanelProvider`);return e}function Rpt({children:e}){let{variant:t}=Dpe(mpe),n=t===hpe,[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(null),s=(0,U.useCallback)(()=>i(!0),[]),c=(0,U.useCallback)(()=>i(!1),[]),l=(0,U.useCallback)(()=>i(e=>!e),[]),u=(0,U.useCallback)(e=>{o(e),i(!0)},[]),d=(0,U.useCallback)(()=>o(null),[]),f=(0,U.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,U.useEffect)(()=>(Npt({enabled:n,openWithPrompt:u}),()=>Npt(null)),[n,u]),(0,W.jsxs)(Lpt.Provider,{value:f,children:[(0,W.jsx)(`div`,{className:G(`transition-[padding] duration-200 ease-in-out`,f.isOpen&&`xl:pr-[440px]`),children:e}),n?(0,W.jsx)(Apt,{}):null]})}var zpt=e=>(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 127.14 96.36`,...e,children:(0,W.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`}})}),GZ=({text:e,onClick:t,className:n})=>(0,W.jsx)(Y,{onClick:t,className:G(`bg-[#5865f2] hover:bg-[#464ec7] text-white`,n),asChild:!0,children:(0,W.jsxs)(`a`,{href:vb,target:`_blank`,rel:`noreferrer`,children:[(0,W.jsx)(zpt,{className:`w-6`}),e]})}),Bpt=({goBack:e,hasGoHome:t})=>(0,W.jsxs)(`div`,{className:`flex gap-2 border-t pt-4 mt-2`,children:[t&&(0,W.jsx)(Y,{asChild:!0,children:(0,W.jsxs)(`a`,{href:`/`,children:[(0,W.jsx)(yte,{size:22}),`Go Home`]})}),(0,W.jsx)(GZ,{text:`Chat with us`}),e&&(0,W.jsx)(Y,{onClick:()=>{e()},children:`Try again`})]}),Vpt=({isReconnecting:e=!1,onRetry:t})=>(0,W.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,W.jsx)(`div`,{className:`relative max-w-md mx-4`,children:(0,W.jsxs)(`div`,{className:`relative bg-card rounded-xl shadow-2xl overflow-hidden border border-border`,children:[(0,W.jsx)(`div`,{className:`bg-muted border-b border-border p-6`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,W.jsx)(`div`,{className:`shrink-0`,children:(0,W.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-red-100 dark:bg-red-500/15 flex items-center justify-center`,children:(0,W.jsx)(one,{className:`w-6 h-6 text-red-600 dark:text-red-400`})})}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-1`,children:`You're offline`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`We can't reach Zuplo right now`})]})]})}),(0,W.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,W.jsx)(`div`,{className:`bg-muted rounded-lg p-4 border border-border`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(Kee,{className:`w-5 h-5 text-green-600 dark:text-green-400 shrink-0 mt-0.5`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-foreground mb-1`,children:`Your work is safe`}),(0,W.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,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,W.jsx)(kp,{className:`w-3.5 h-3.5 ${e?`animate-spin`:``}`}),e?`Checking connection…`:`Waiting for connection…`]}),t&&(0,W.jsx)(Y,{variant:`outline`,size:`sm`,onClick:t,disabled:e,children:`Try now`})]})]})]})})}),Hpt=e=>e instanceof Lt||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 Upt(e){return e===`root`?`app-dead`:`page-dead`}function Wpt({id:e}){let t=Dc(),n=Zt(t);if((0,U.useEffect)(()=>{if(n)return Bt.subscribe(e=>{e&&window.location.reload()})},[n]),(0,U.useEffect)(()=>{!t||n||Oat(`Portal route error boundary rendered`,t,Upt(e),{routeBoundaryId:e??`unknown`})},[t,n,e]),n)return(0,W.jsx)(Vpt,{onRetry:()=>window.location.reload()});let r=Hpt(t);return(0,W.jsx)(`div`,{className:`m-auto`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 my-5 max-w-(--breakpoint-sm) m-6`,children:[(0,W.jsx)(`div`,{children:(0,W.jsxs)(qT,{variant:`outline`,children:[e,` Error`]})}),(0,W.jsx)(`span`,{className:`text-2xl font-medium`,children:r.title}),(0,W.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,W.jsx)(`br`,{}),` In the meantime, try again or reach out and chat with us.`]}),r.detail&&(0,W.jsx)(sb,{variant:`destructive`,children:(0,W.jsxs)(lb,{children:[r.type&&`${r.type}:`,` `,r.detail]})}),(0,W.jsxs)(`span`,{className:`font-mono text-sm`,children:[`Version `,``,` `,r.traceId&&`| Trace ID ${r.traceId}`]}),(0,W.jsx)(Bpt,{hasGoHome:!0})]})})}var Gpt={"in-progress":`Build in progress`,failed:`Last build failed`,success:`Gateway deployed`,idle:`No deployment yet`},Kpt=({status:e,className:t})=>e===`in-progress`?(0,W.jsx)(wp,{size:14,"aria-label":Gpt[e],className:G(`animate-spin text-yellow-500`,t)}):(0,W.jsx)(`span`,{role:`img`,"aria-label":Gpt[e],className:G(`w-2 h-2 shrink-0 rounded-full`,{"bg-green-500":e===`success`,"bg-red-500":e===`failed`,"bg-neutral-400":e===`idle`},t)}),qpt=({children:e,className:t,...n})=>(0,W.jsx)(`div`,{className:G(`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}),Jpt=`/:account/:project/:environment`,Ypt=({count:e})=>!e||e===0?null:(0,W.jsx)(`span`,{className:`absolute top-1 right-0 h-2 w-2 rounded-full bg-blue-400`}),Xpt=({children:e,to:t,badgeCount:n,end:r})=>(0,W.jsx)(Fl,{end:r,to:t,className:({isActive:e,isPending:t})=>G(`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,W.jsxs)(W.Fragment,{children:[t&&(0,W.jsx)(yP.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,W.jsx)(Ypt,{count:n})]})}),Zpt=()=>{let e=sF(nm().environment),{copyToClipboard:t,state:n}=zw(e??``);return(0,W.jsxs)(pq,{children:[(0,W.jsx)(mq,{asChild:!0,children:(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,className:`gap-2 flex justify-between h-8 mt-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Kpt,{status:`success`}),(0,W.jsx)(X,{children:`Deployment URLs`})]}),(0,W.jsx)(Zf,{size:16})]})}),(0,W.jsx)(hq,{className:`divide-y p-0`,align:`end`,children:e?(0,W.jsxs)(`div`,{className:`p-4`,children:[(0,W.jsx)(`div`,{className:`font-medium text-lg`,children:(0,W.jsx)(X,{children:`Local Development`})}),(0,W.jsx)(`div`,{className:`h-2`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`uppercase text-muted-foreground font-semibold text-xs`,children:(0,W.jsx)(X,{children:`Gateway`})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Kpt,{status:`success`}),(0,W.jsx)(`div`,{className:`text-sm max-w-52 truncate break-all`,children:(0,W.jsx)(tE,{href:e,target:`_blank`,variant:`ghost`,rel:`noopener noreferrer`,className:`hover:underline`,children:e})}),(0,W.jsx)(Iw,{copied:n===`copied`,children:(0,W.jsx)(`button`,{type:`button`,"aria-label":`Copy gateway URL`,className:`p-1 hover:bg-muted rounded-md transition-colors`,onClick:()=>void t(),children:n===`copied`?(0,W.jsx)(Xf,{size:16,className:`text-green-500`}):(0,W.jsx)(sp,{size:16})})})]})]})]}):(0,W.jsxs)(`div`,{className:`w-60 p-5 text-center`,children:[(0,W.jsx)(`div`,{className:`text-2xl font-medium`,children:`🙈`}),(0,W.jsx)(X,{as:`div`,className:`mt-4`,children:`Deployment URL not configured. Make sure your local gateway is running.`})]})})]})},Qpt=()=>{let e=nm(),t={account:e.account.name,project:e.project.name,environment:encodeURIComponent(e.environment.urlParameter)};return(0,W.jsxs)(qpt,{className:`flex-row justify-between`,children:[(0,W.jsxs)(`nav`,{"aria-label":`Sidebar`,className:`flex gap-2 items-center`,children:[(0,W.jsx)(Xpt,{end:!0,to:fo(Jpt,t),children:`Project`}),(0,W.jsx)(Xpt,{to:fo(Cb.Code,t),children:`Code`})]}),(0,W.jsx)(Zpt,{})]})},KZ=(0,U.createContext)({chromeBottom:0});function $pt({height:e,children:t}){let n={chromeBottom:(0,U.useContext)(KZ).chromeBottom+e};return(0,W.jsx)(KZ.Provider,{value:n,children:t})}function emt(){return(0,U.useContext)(KZ).chromeBottom}function tmt(e=0){let t=emt()+e;return{top:`calc(${t}px + var(--banner-height, 0px))`,fillHeight:`calc(100vh - ${t}px - var(--banner-height, 0px))`}}var nmt=({children:e,className:t,offset:n=0})=>{let{fillHeight:r}=tmt(n);return(0,W.jsx)(`div`,{className:G(t),style:{height:r},children:e})};function rmt({open:e,editors:t,onSelect:n,onCancel:r}){let[i,a]=(0,U.useState)(null);return(0,W.jsx)(tT,{open:e,onOpenChange:e=>!e&&r(),children:(0,W.jsxs)(iT,{className:`sm:max-w-md`,children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:`Choose Your Editor`}),(0,W.jsx)(cT,{children:`Select which editor you'd like to use for opening files. This preference will be saved for future use.`})]}),(0,W.jsx)(`div`,{className:`space-y-2 py-4`,children:t.map(e=>(0,W.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-info-muted`:`border-surface-border 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,W.jsx)(`div`,{className:`font-medium`,children:e.name})},e.id))}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`ghost`,onClick:r,children:`Cancel`}),(0,W.jsx)(Y,{variant:`default`,onClick:()=>{i&&n(i)},disabled:!i,children:`Save Preference`})]})]})})}var qZ=`/api/v1/editor`;function imt(){let[e]=Hl(),[t,n]=(0,U.useState)(null),[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)([]),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(!0);(0,U.useEffect)(()=>{(async()=>{try{let e=await fetch(`${qZ}/list`);if(!e.ok)throw Error(`Failed to fetch editors: ${e.status}`);o((await e.json()).editors);let t=await fetch(`${qZ}/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){Ye.error(`Failed to load editor preference`,{error:e})}finally{u(!1)}})()},[]);let d=(0,U.useCallback)(async e=>{try{if((await fetch(`${qZ}/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){Ye.error(`Failed to save editor preference`,{error:e})}},[a]),f=(0,U.useCallback)(async()=>{let n=e.get(`path`);if(!n){Ye.warn(`No file path in URL`);return}if(!t){c(!0);return}try{let e=await fetch(`${qZ}/open`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({file:n})});if(!e.ok){let t=await e.json();Ye.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){Ye.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 amt=e=>new Promise(t=>setTimeout(t,e)),JZ=e=>{let[t,n]=(0,U.useState)(`idle`),[r,i]=(0,U.useState)(),[a,o]=(0,U.useState)(null);return{state:t,error:r,execute:(0,U.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}},YZ=()=>({isReadOnly:nm().environment.environmentType!==BP.WORKING_COPY}),omt=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}})),smt=r(a(((e,t)=>{var n=omt();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}}))()),cmt=1024*64,XZ=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>cmt)throw TypeError(`pattern is too long`)},lmt={"[: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]},ZZ=e=>e.replace(/[[\]\\-]/g,`\\$&`),umt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),dmt=e=>e.join(``),fmt=(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(lmt))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(ZZ(d)+`-`+ZZ(t)):t===d&&r.push(ZZ(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(ZZ(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(ZZ(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[umt(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+dmt(r)+`]`,p=`[`+(l?``:`^`)+dmt(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},QZ=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/\[([^\/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,`$1$2`).replace(/\\([^\/])/g,`$1`),pmt=new Set([`!`,`?`,`+`,`*`,`@`]),$Z=e=>pmt.has(e),mmt=e=>$Z(e.type),hmt=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),gmt=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),_mt=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),vmt=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),ymt=`(?!\\.\\.?(?:$|/))`,eQ=`(?!\\.)`,bmt=new Set([`[`,`.`]),xmt=new Set([`..`,`.`]),Smt=new Set(`().*{}+?[]^$\\!`),Cmt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),tQ=`[^/]`,wmt=tQ+`*?`,Tmt=tQ+`+?`,Emt=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&&$Z(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($Z(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,gmt)}#m(e,t=hmt){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=_mt){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!!vmt.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=vmt.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(mmt(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()),!mmt(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&&xmt.has(this.#r[0]))){let e=bmt,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?ymt:i?eQ:``}let i=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(i=`(?:$|\\/)`),[r+n+i,QZ(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,QZ(this.toString()),!1,!1]}let r=``;if(this.type===`!`&&this.#u)r=(this.isStart()&&!this.#c.dot?eQ:``)+Tmt;else{let e=this.type===`!`?`))`+(this.isStart()&&!this.#c.dot?eQ:``)+wmt+`)`:this.type===`@`?`)`:`)${this.type}`;r=t+n+e}return[r,QZ(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+=(Smt.has(c)?`\\`:``)+c;continue}if(c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=fmt(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)?Tmt:wmt,t=!0;continue}if(c===`?`){i+=tQ,t=!0;continue}i+=Cmt(c)}return[i,QZ(e),!!t,a]}},Dmt=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),nQ=(e,t,n={})=>(XZ(t),!n.nocomment&&t.charAt(0)===`#`?!1:new aQ(t,n).match(e)),Omt=/^\*+([^+@!?\*\[\(]*)$/,kmt=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),Amt=e=>t=>t.endsWith(e),jmt=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),Mmt=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Nmt=/^\*+\.\*+$/,Pmt=e=>!e.startsWith(`.`)&&e.includes(`.`),Fmt=e=>e!==`.`&&e!==`..`&&e.includes(`.`),Imt=/^\.\*+$/,Lmt=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),Rmt=/^\*+$/,zmt=e=>e.length!==0&&!e.startsWith(`.`),Bmt=e=>e.length!==0&&e!==`.`&&e!==`..`,Vmt=/^\?+([^+@!?\*\[\(]*)?$/,Hmt=([e,t=``])=>{let n=Kmt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Umt=([e,t=``])=>{let n=qmt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Wmt=([e,t=``])=>{let n=qmt([e]);return t?e=>n(e)&&e.endsWith(t):n},Gmt=([e,t=``])=>{let n=Kmt([e]);return t?e=>n(e)&&e.endsWith(t):n},Kmt=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},qmt=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},Jmt=typeof process==`object`&&process?{}.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Ymt={win32:{sep:`\\`},posix:{sep:`/`}};nQ.sep=Jmt===`win32`?Ymt.win32.sep:Ymt.posix.sep;var rQ=Symbol(`globstar **`);nQ.GLOBSTAR=rQ;var Xmt=`[^/]*?`,Zmt=`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`,Qmt=`(?:(?!(?:\\/|^)\\.).)*?`;nQ.filter=(e,t={})=>n=>nQ(n,e,t);var iQ=(e,t={})=>Object.assign({},e,t);nQ.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return nQ;let t=nQ;return Object.assign((n,r,i={})=>t(n,r,iQ(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,iQ(e,n))}static defaults(n){return t.defaults(iQ(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,iQ(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,iQ(e,r))}},unescape:(n,r={})=>t.unescape(n,iQ(e,r)),escape:(n,r={})=>t.escape(n,iQ(e,r)),filter:(n,r={})=>t.filter(n,iQ(e,r)),defaults:n=>t.defaults(iQ(e,n)),makeRe:(n,r={})=>t.makeRe(n,iQ(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,iQ(e,r)),match:(n,r,i={})=>t.match(n,r,iQ(e,i)),sep:t.sep,GLOBSTAR:rQ})};var $mt=(e,t={})=>(XZ(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:(0,smt.default)(e));nQ.braceExpand=$mt,nQ.makeRe=(e,t={})=>new aQ(e,t).makeRe(),nQ.match=(e,t,n={})=>{let r=new aQ(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};var eht=/[?*]|[+@!]\(.*?\)|\[|\]/,tht=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),aQ=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){XZ(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||Jmt,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]===`?`||!eht.test(e[2]))&&!eht.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(rQ)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(rQ,i),o=t.lastIndexOf(rQ),[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===rQ?(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===rQ)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 $mt(this.pattern,this.options)}parse(e){XZ(e);let t=this.options;if(e===`**`)return rQ;if(e===``)return``;let n,r=null;(n=e.match(Rmt))?r=t.dot?Bmt:zmt:(n=e.match(Omt))?r=(t.nocase?t.dot?Mmt:jmt:t.dot?Amt:kmt)(n[1]):(n=e.match(Vmt))?r=(t.nocase?t.dot?Umt:Hmt:t.dot?Wmt:Gmt)(n):(n=e.match(Nmt))?r=t.dot?Fmt:Pmt:(n=e.match(Imt))&&(r=Lmt);let i=Emt.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?Xmt:t.dot?Zmt:Qmt,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`?tht(e):e===rQ?rQ:e._src});return t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==rQ||a===rQ||(a===void 0?i!==void 0&&i!==rQ?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|`+n+`)?`:i!==rQ&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=rQ))}),t.filter(e=>e!==rQ).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 nQ.defaults(e).Minimatch}};nQ.AST=Emt,nQ.Minimatch=aQ,nQ.escape=Dmt,nQ.unescape=QZ;var nht=()=>{let e=P();return I({mutationFn:async t=>await e.fetch(V.directories.createDirectory(t))})};function rht(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===$l.Directory&&r.some(t=>nQ(e.path,t))?!0:n.find(t=>nQ(e.path,t))!==void 0)}function iht(e,t){return(0,U.useCallback)(async()=>rht(await iu(t,`/`),e),[t,e])}function oQ(){let{logEvent:e}=H(),t=dQ(),n=lm(),r=cm(e=>e.showSaveConflict);return yX({onMutate:({files:e})=>{e.forEach(e=>{t({...e,saveState:eu.saving})})},onSuccess:async(e,{files:n,environmentName:r})=>{e.buildId&&r&&mt(r,e.buildId),n.forEach(n=>{let r=e.files?.[n.path];Ye.debug(`Updated ${n.path} after save - lastModified: ${r}`),t({...n,lastModified:r,saveState:eu.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){Ye.error(`Failed to parse conflict error instance data`,{error:e})}return}a.forEach(e=>{t({...e,saveState:eu.modified})}),e(`file-save-failed`,{fileNames:n.map(e=>e.path).join(`, `)})}})}function aht(){let e=nm(),{logEvent:t,captureException:n}=H(),r=uht(),i=dQ(),a=sst(),{isReadOnly:o}=YZ(),{execute:s}=JZ(async s=>{if(o)return{success:!1,error:Error(`Unable to delete file - environment is read-only`)};let c=s.saveState;i({...s,saveState:eu.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 sQ(){let e=kP(),{logEvent:t,captureException:n}=H(),r=dQ(),i=cm(e=>e.projectTreeNodes),a=vX(),o=nm([`account`,`project`,`environment`]),{execute:s}=JZ(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 iu(o.environment.name,c).catch(()=>[])).find(e=>e.path===m);if(e)return e}let _={content:h,path:m},v={saveState:eu.new,type:$l.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&&mt(o.environment.name,s.buildId),r({...v,lastModified:s.lastModified,saveState:eu.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:eu.modified});return}});return s}function oht(e){let t=kP(),{logEvent:n,captureException:r}=H(),i=Ab([`account`,`project`]),a=dQ(),o=uht(),s=cst(),{execute:c}=JZ(async(c,l)=>{if(t)try{a({...c,saveState:eu.removing}),await s.mutateAsync({environmentName:e,path:c.path,newPath:l}),a({...c,saveState:eu.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:eu.unmodified});return}});return c}function sht(e){let t=kP(),{logEvent:n,captureException:r}=H(),i=dQ(),a=nht(),{execute:o}=JZ(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:eu.new,type:$l.Directory,...u};try{return i(d),await a.mutateAsync({environmentName:e,path:l}),i({...d,saveState:eu.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:eu.modified}),t}});return o}function cQ(){return uQ(vit().get(`path`))}function lQ(){let e=kP(),t=dQ();return(0,U.useCallback)((n,r=!1,i=eu.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 uQ(e){return cm(t=>e?t.filesByPath[e]:void 0)}function cht(e){let t=cm(e=>e.projectTreeNodes),n=[],r=Object.values(e);return t.filter(e=>e.type===$l.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 lht(e){return cm(e=>e.projectTreeNodes).filter(t=>!t.path&&!e.fileGlob?!1:t.type===$l.Directory&&e.subdirectoryGlob?nQ(t.path,e.subdirectoryGlob):nQ(t.path,e.fileGlob))}function uht(){let e=kP(),t=cm(e=>e.removeFile),n=cm(e=>e.filterProjectTreeNodes);return r=>{e&&e.editor.getModel(e.Uri.file(r))?.dispose(),t(r),n(e=>e.path!==r)}}function dQ(){return cm(e=>e.updateFile)}var dht=e=>{let t=lQ(),n=uQ(e);return e=>{n&&t(n,!0,e)}},fht=()=>{let e=nm(),t=oQ(),n=lm();return wGe(e.environment.name),{isPending:t.isPending,isSuccess:t.isSuccess,saveAndDeploy:(0,U.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])}},pht=(e={})=>{let{isReadOnly:t=!1,onSave:n}=e,{saveAndDeploy:r,isPending:i,isSuccess:a}=fht(),[o,s]=(0,U.useState)(null),c=cm(e=>{let t=0;for(let n of e.projectTreeNodes){let r=n.path?e.filesByPath[n.path]:void 0;r&&r.saveState===eu.modified&&t++}return t}),l=cm(e=>{let t=0;for(let n of e.projectTreeNodes){let r=n.path?e.filesByPath[n.path]:void 0;r&&(r.saveState===eu.modified||r.saveState===eu.saving)&&t++}return t}),u=(0,U.useRef)(null),d=e=>{s(e),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{s(null)},1600)},f=lF(r),p=lF(n),m=$p(e=>e.addToast),h=(0,U.useRef)(!1),g=(0,U.useRef)(!1);return(0,U.useEffect)(()=>{let e=h.current;!e&&i?g.current=l>0:e&&!i&&a&&g.current&&(m({message:`Changes saved`,icon:(0,U.createElement)(Xf,{size:18}),duration:2e3}),g.current=!1),h.current=i},[i,a,l,m]),(0,U.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 amt(100)}if(c===0){d(`No unsaved changes`);return}p.current?.(),await f.current()}}catch(e){Ye.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}},mht=()=>{let{showTooltip:e,saveAll:t,isSaving:n,unsavedChangesCount:r}=pht(),{hasEditor:i,editorName:a,isLoading:o,showPreferenceDialog:s,setShowPreferenceDialog:c,availableEditors:l,savePreference:u,openInEditor:d}=imt();return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`sticky bottom-0 h-12 border-t bg-surface-sunken items-center flex px-2 gap-x-2`,children:[(0,W.jsx)(Pw,{open:!!e,content:e??``,children:(0,W.jsx)(Y,{variant:r>0||n?`default`:`ghost`,size:`sm`,className:`text-xs`,"data-test":`save`,disabled:n,onClick:async()=>{await t()},children:(0,W.jsxs)(CP,{className:`flex items-center gap-1 text-xs relative`,loading:n,children:[`Save`,(0,W.jsx)(`span`,{className:r>0?`text-white`:`text-muted-foreground`,children:`[⌘+S]`})]})})}),!o&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`h-6 w-px bg-border`}),(0,W.jsx)(Pw,{content:i?`Open in ${a}`:`Choose editor to open files`,children:(0,W.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:d,className:`text-xs`,children:[(0,W.jsx)(up,{size:14}),`Open in Editor`]})})]})]}),(0,W.jsx)(rmt,{open:s,editors:l,onSelect:u,onCancel:()=>c(!1)})]})},hht=({className:e})=>(0,W.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,W.jsx)(`title`,{children:`route`}),(0,W.jsx)(`g`,{id:`Page-1`,stroke:`none`,strokeWidth:`1`,fill:`none`,fillRule:`evenodd`,children:(0,W.jsxs)(`g`,{id:`route`,transform:`translate(0.393398, 0.686292)`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,W.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,W.jsxs)(`g`,{id:`arrow`,transform:`translate(7.616869, 7.313708)`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`polyline`,{id:`Path-2`,points:`3.71305334 5.62451673 6 2.81225836 3.71305334 2.8356215e-17`}),(0,W.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`})]})]})})]}),ght=[`@zuplo/runtime`,`@zuplo/graphql`,`@zuplo/otel`];function _ht(e){return e===`.`?`index.d.ts`:`${e.replace(/^\.\//,``)}/index.d.ts`}var vht=[{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`}],yht=[{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 bht(){try{return await(await fetch(`https://cdn.zuplo.com/types/remote-modules.d.ts`)).text()}catch(e){Et.captureException(e)}}async function xht(e,t){try{let n=await fetch(`${nt}/types/${e}/${t}/package.json`);if(!n.ok)throw Error(`Error loading package.json for ${e}`);return await n.json()}catch(e){Et.captureException(e)}}async function Sht(){try{let e=await fetch(`${nt}/types/@zuplo/bundled/bundles.json`);if(!e.ok)throw Error(`Error loading bundles from CDN`);let t=await e.json();return[...vht,...t.bundles]}catch(e){Et.captureException(e)}return[...vht]}async function fQ(e){try{let t=await fetch(`${nt}/${e}`);if(!t.ok)throw Error(`Error loading type definition: ${e}`);return await t.text()}catch(e){Et.captureException(e)}}var Cht=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 wht(e){await Promise.all(ght.map(async t=>{let n=await xht(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 fQ(`types/${t}/latest/${r.types.substring(2)}`);if(i){let r=_ht(n);e.typescript.typescriptDefaults.addExtraLib(i,`file:///node_modules/${t}/${r}`)}})))}))}async function Tht(e){let t=Object.keys(e.typescript.typescriptDefaults.getExtraLibs()),n=await Sht();await Promise.allSettled([...yht.map(async({types:t,name:n})=>{let r=await fQ(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 fQ(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 Eht=null,Dht=`
|
|
351
|
+
`).trim();return(0,W.jsx)($Fe,{isUser:u,footer:!u&&!s?(0,W.jsxs)(`div`,{className:`mt-1 flex items-center gap-0.5`,children:[p?(0,W.jsx)(Ept,{text:p}):null,d?null:(0,W.jsx)(apt,{traceId:c?.traceId,sessionId:l,account:c?.account,project:c?.project})]}):null,children:!u&&f.length===0?(0,W.jsx)(wIe,{}):f.map(s=>s.kind===`tools`?(0,W.jsx)(rIe,{tools:s.tools},`${e.id}-${s.index}`):(0,W.jsx)(Dpt,{part:s.part,isUser:u,onSend:t,onApproval:n,onSwitchProject:r,isActiveProject:i,primaryProject:a,disabled:o},`${e.id}-${s.index}`))})}function Ept({text:e}){let{logEvent:t}=H(),{copyToClipboard:n,state:r}=zw(e,{onCopy:()=>t(`agent-z-response-copied`,{messageLength:e.length})}),i=r===`copied`;return(0,W.jsx)(Iw,{copied:i,children:(0,W.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>void n(),"aria-label":`Copy response`,title:`Copy response`,className:G(`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,W.jsx)(Xf,{className:`size-3.5`}):(0,W.jsx)(sp,{className:`size-3.5`})})})}function Dpt({part:e,isUser:t,onSend:n,onApproval:r,onSwitchProject:i,isActiveProject:a,primaryProject:o,disabled:s}){if(e.type===`text`)return t?(0,W.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.text}):(0,W.jsx)(kw,{content:e.text});if(e.type===`reasoning`)return e.text?(0,W.jsx)(iIe,{text:e.text}):null;if(tS(e)){let t=rS(e);if(RFe(e)){let n=e.state===`approval-requested`?{kind:`requested`}:e.state===`approval-responded`?{kind:`responded`,approved:e.approval.approved===!0}:{kind:`denied`};return(0,W.jsx)(CIe,{toolLabel:QFe(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=ypt(`input`in e?e.input:void 0);return t?(0,W.jsx)(aIe,{data:t,onSend:n,disabled:s}):null}if(t===`present-link`){let t=bpt(`input`in e?e.input:void 0);return t?(0,W.jsx)(oIe,{data:t}):null}if(t===`present-consumer`){let t=JWe(`input`in e?e.input:void 0);return t?(0,W.jsx)(YWe,{data:t}):null}if(t===`present-ai-api-key`){let t=kIe(`input`in e?e.input:void 0);return t?(0,W.jsx)(AIe,{data:t}):null}if(t===`present-environment-variable`){let t=TGe(`input`in e?e.input:void 0);return t?(0,W.jsx)(EGe,{data:t}):null}if(t===`present-source`){let t=Cpt(`input`in e?e.input:void 0);return t?(0,W.jsx)(sIe,{data:t}):null}if(t===`celebrate`){let t=TIe(`input`in e?e.input:void 0);return t?(0,W.jsx)(OIe,{data:t}):null}if(t===`present-file`){let t=DGe(`input`in e?e.input:void 0);return t?(0,W.jsx)(OGe,{data:t}):null}if(t===`present-support-ticket`){let t=kGe(`input`in e?e.input:void 0);return t?(0,W.jsx)(AGe,{data:t}):null}if(t===`show-test-console`){let t=Sat(`input`in e?e.input:void 0);return t?(0,W.jsx)(Cat,{data:t}):null}if(t===`switch-project`){let t=xpt(`input`in e?e.input:void 0);return t?(0,W.jsx)(mIe,{projectName:t.projectName,reason:t.reason,isActive:a(t.projectName),disabled:s,onSwitch:()=>i(t.projectName)}):null}if(t===`update-working-copy`){let t=upt(`input`in e?e.input:void 0);return t?(0,W.jsx)(dpt,{data:t}):null}if(t===`request-ai-provider`){let t=jAe(`input`in e?e.input:void 0);return t?(0,W.jsx)(vlt,{data:t}):null}if(t===`request-ai-team`){let t=MAe(`input`in e?e.input:void 0);return t?(0,W.jsx)(Fst,{data:t}):null}if(t===`request-ai-app`){let t=NAe(`input`in e?e.input:void 0);return t?(0,W.jsx)(wat,{data:t}):null}if(t===`request-support-ticket`&&e.state===`output-available`){let t=PAe(`input`in e?e.input:void 0);return t?(0,W.jsx)(rpt,{data:t,onSend:n,disabled:s}):null}return t===`request-openapi-import`?(0,W.jsx)(Yft,{data:qft(`input`in e?e.input:void 0),onSend:n,disabled:s,primaryProject:o}):(0,W.jsx)(rIe,{tools:[{name:t,pending:IFe(e)}]})}return null}function Opt({active:e,audience:t=`everyone`,onPick:n}){let{logEvent:r}=H(),i=(0,U.useMemo)(()=>t===`pending`?[]:t===`ai-user`?cpt(void 0,void 0,spt):cpt(),[t]);return(0,U.useEffect)(()=>{e&&i.forEach((e,t)=>{r(`agent-z-cta-shown`,{ctaId:e.id,ctaCategory:e.category,position:t,batchSize:i.length})})},[e,i,r]),(0,W.jsxs)(`div`,{className:`mt-8 flex flex-col items-center text-center`,children:[(0,W.jsx)(Sb,{"aria-hidden":!0,className:`size-14`}),(0,W.jsx)(`h2`,{className:`mt-4 text-lg font-medium`,children:`Ask Zuplo AI`}),(0,W.jsx)(`p`,{className:`mt-1 max-w-md text-sm text-muted-foreground`,children:t===`ai-user`?`Ask how to connect Claude Code or Codex to your AI Gateway, where your API key is, or why a request failed.`:`Your AI assistant — ask about your APIs, policies, deployments, and more, right where you’re working.`}),(0,W.jsx)(`div`,{className:`mt-6 flex flex-wrap justify-center gap-2`,children:i.map((e,t)=>(0,W.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{r(`agent-z-cta-clicked`,{ctaId:e.id,ctaCategory:e.category,position:t,batchSize:i.length}),n(e)},children:e.prompt},e.id))})]})}var kpt=`w-full max-w-[440px]`;function Apt(){let{isOpen:e,close:t}=WZ(),{logEvent:n}=H(),[r,i]=(0,U.useState)(0),{account:a}=Ab([]),o=Ib({enabled:!!a}),s=a?o.data?.find(e=>e.name===a):void 0,c=s?V_e(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,W.jsxs)(`aside`,{"aria-label":`Zuplo AI assistant`,inert:!e,onKeyDown:d,className:G(`fixed inset-y-0 right-0 z-40 flex flex-col border-l bg-background shadow-2xl`,kpt,`transition-transform duration-200 ease-in-out will-change-transform`,e?`translate-x-0`:`pointer-events-none translate-x-full`),children:[(0,W.jsxs)(`header`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,W.jsx)(Sb,{"aria-hidden":!0,className:`size-5`}),(0,W.jsx)(`span`,{className:`text-sm`,children:`Zuplo AI`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u||l?null:(0,W.jsxs)(Y,{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,W.jsx)(Op,{className:`size-4`}),`New chat`]}),(0,W.jsx)(Y,{variant:`ghost`,size:`icon-sm`,onClick:()=>{n(`agent-z-panel-closed`,{source:`close-button`}),t()},"aria-label":`Close Zuplo AI`,children:(0,W.jsx)(Up,{className:`size-4`})})]})]}),l?(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col justify-center overflow-y-auto bg-surface-sunken`,children:(0,W.jsx)(S_e,{})}):u?(0,W.jsx)(jpt,{active:e}):(0,W.jsx)(wpt,{active:e},r)]})}function jpt({active:e}){let{close:t}=WZ(),{logEvent:n}=H(),{account:r}=Ab([]);(0,U.useEffect)(()=>{e&&n(`agent-z-disabled-state-shown`)},[e,n]);let{isAdmin:i}=k_e(r??``);return(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col justify-center overflow-y-auto bg-surface-sunken`,children:(0,W.jsx)(_b,{title:`AI features are disabled`,description:`Zuplo AI is turned off for this account. Need a hand? Our support team is one click away.`,action:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[r?(0,W.jsx)(Y,{type:`button`,asChild:!0,children:(0,W.jsxs)(Pl,{to:Cb.Support,onClick:()=>{n(`agent-z-disabled-support-clicked`),t()},children:[(0,W.jsx)(Cp,{"aria-hidden":!0,className:`size-4`}),`Contact support`]})}):null,i&&r?(0,W.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,asChild:!0,children:(0,W.jsxs)(Pl,{to:fo(Cb.AccountSettings,{account:r}),children:[(0,W.jsx)(Hy,{weight:`fill`,"aria-hidden":!0,className:`size-4`}),`Enable AI features`]})}):null]})})})}var Mpt=null,UZ=new Set,Npt=e=>{Mpt=e;for(let e of UZ)e()},Ppt=e=>(UZ.add(e),()=>{UZ.delete(e)}),Fpt=()=>Mpt,Ipt=()=>(0,U.useSyncExternalStore)(Ppt,Fpt,Fpt),Lpt=(0,U.createContext)(void 0);function WZ(){let e=(0,U.useContext)(Lpt);if(!e)throw Error(`useAgentZPanel must be used within AgentZPanelProvider`);return e}function Rpt({children:e}){let{variant:t}=Dpe(mpe),n=t===hpe,[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(null),s=(0,U.useCallback)(()=>i(!0),[]),c=(0,U.useCallback)(()=>i(!1),[]),l=(0,U.useCallback)(()=>i(e=>!e),[]),u=(0,U.useCallback)(e=>{o(e),i(!0)},[]),d=(0,U.useCallback)(()=>o(null),[]),f=(0,U.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,U.useEffect)(()=>(Npt({enabled:n,openWithPrompt:u}),()=>Npt(null)),[n,u]),(0,W.jsxs)(Lpt.Provider,{value:f,children:[(0,W.jsx)(`div`,{className:G(`transition-[padding] duration-200 ease-in-out`,f.isOpen&&`xl:pr-[440px]`),children:e}),n?(0,W.jsx)(Apt,{}):null]})}var zpt=e=>(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 127.14 96.36`,...e,children:(0,W.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`}})}),GZ=({text:e,onClick:t,className:n})=>(0,W.jsx)(Y,{onClick:t,className:G(`bg-[#5865f2] hover:bg-[#464ec7] text-white`,n),asChild:!0,children:(0,W.jsxs)(`a`,{href:vb,target:`_blank`,rel:`noreferrer`,children:[(0,W.jsx)(zpt,{className:`w-6`}),e]})}),Bpt=({goBack:e,hasGoHome:t})=>(0,W.jsxs)(`div`,{className:`flex gap-2 border-t pt-4 mt-2`,children:[t&&(0,W.jsx)(Y,{asChild:!0,children:(0,W.jsxs)(`a`,{href:`/`,children:[(0,W.jsx)(yte,{size:22}),`Go Home`]})}),(0,W.jsx)(GZ,{text:`Chat with us`}),e&&(0,W.jsx)(Y,{onClick:()=>{e()},children:`Try again`})]}),Vpt=({isReconnecting:e=!1,onRetry:t})=>(0,W.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,W.jsx)(`div`,{className:`relative max-w-md mx-4`,children:(0,W.jsxs)(`div`,{className:`relative bg-card rounded-xl shadow-2xl overflow-hidden border border-border`,children:[(0,W.jsx)(`div`,{className:`bg-muted border-b border-border p-6`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,W.jsx)(`div`,{className:`shrink-0`,children:(0,W.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-red-100 dark:bg-red-500/15 flex items-center justify-center`,children:(0,W.jsx)(one,{className:`w-6 h-6 text-red-600 dark:text-red-400`})})}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-1`,children:`You're offline`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`We can't reach Zuplo right now`})]})]})}),(0,W.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,W.jsx)(`div`,{className:`bg-muted rounded-lg p-4 border border-border`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(Kee,{className:`w-5 h-5 text-green-600 dark:text-green-400 shrink-0 mt-0.5`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-foreground mb-1`,children:`Your work is safe`}),(0,W.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,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,W.jsx)(kp,{className:`w-3.5 h-3.5 ${e?`animate-spin`:``}`}),e?`Checking connection…`:`Waiting for connection…`]}),t&&(0,W.jsx)(Y,{variant:`outline`,size:`sm`,onClick:t,disabled:e,children:`Try now`})]})]})]})})}),Hpt=e=>e instanceof Lt||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 Upt(e){return e===`root`?`app-dead`:`page-dead`}function Wpt({id:e}){let t=Dc(),n=Zt(t);if((0,U.useEffect)(()=>{if(n)return Bt.subscribe(e=>{e&&window.location.reload()})},[n]),(0,U.useEffect)(()=>{!t||n||Oat(`Portal route error boundary rendered`,t,Upt(e),{routeBoundaryId:e??`unknown`})},[t,n,e]),n)return(0,W.jsx)(Vpt,{onRetry:()=>window.location.reload()});let r=Hpt(t);return(0,W.jsx)(`div`,{className:`m-auto`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 my-5 max-w-(--breakpoint-sm) m-6`,children:[(0,W.jsx)(`div`,{children:(0,W.jsxs)(qT,{variant:`outline`,children:[e,` Error`]})}),(0,W.jsx)(`span`,{className:`text-2xl font-medium`,children:r.title}),(0,W.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,W.jsx)(`br`,{}),` In the meantime, try again or reach out and chat with us.`]}),r.detail&&(0,W.jsx)(sb,{variant:`destructive`,children:(0,W.jsxs)(lb,{children:[r.type&&`${r.type}:`,` `,r.detail]})}),(0,W.jsxs)(`span`,{className:`font-mono text-sm`,children:[`Version `,``,` `,r.traceId&&`| Trace ID ${r.traceId}`]}),(0,W.jsx)(Bpt,{hasGoHome:!0})]})})}var Gpt={"in-progress":`Build in progress`,failed:`Last build failed`,success:`Gateway deployed`,idle:`No deployment yet`},Kpt=({status:e,className:t})=>e===`in-progress`?(0,W.jsx)(wp,{size:14,"aria-label":Gpt[e],className:G(`animate-spin text-yellow-500`,t)}):(0,W.jsx)(`span`,{role:`img`,"aria-label":Gpt[e],className:G(`w-2 h-2 shrink-0 rounded-full`,{"bg-green-500":e===`success`,"bg-red-500":e===`failed`,"bg-neutral-400":e===`idle`},t)}),qpt=({children:e,className:t,...n})=>(0,W.jsx)(`div`,{className:G(`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}),Jpt=`/:account/:project/:environment`,Ypt=({count:e})=>!e||e===0?null:(0,W.jsx)(`span`,{className:`absolute top-1 right-0 h-2 w-2 rounded-full bg-blue-400`}),Xpt=({children:e,to:t,badgeCount:n,end:r})=>(0,W.jsx)(Fl,{end:r,to:t,className:({isActive:e,isPending:t})=>G(`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,W.jsxs)(W.Fragment,{children:[t&&(0,W.jsx)(yP.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,W.jsx)(Ypt,{count:n})]})}),Zpt=()=>{let e=sF(nm().environment),{copyToClipboard:t,state:n}=zw(e??``);return(0,W.jsxs)(pq,{children:[(0,W.jsx)(mq,{asChild:!0,children:(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,className:`gap-2 flex justify-between h-8 mt-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Kpt,{status:`success`}),(0,W.jsx)(X,{children:`Deployment URLs`})]}),(0,W.jsx)(Zf,{size:16})]})}),(0,W.jsx)(hq,{className:`divide-y p-0`,align:`end`,children:e?(0,W.jsxs)(`div`,{className:`p-4`,children:[(0,W.jsx)(`div`,{className:`font-medium text-lg`,children:(0,W.jsx)(X,{children:`Local Development`})}),(0,W.jsx)(`div`,{className:`h-2`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`uppercase text-muted-foreground font-semibold text-xs`,children:(0,W.jsx)(X,{children:`Gateway`})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Kpt,{status:`success`}),(0,W.jsx)(`div`,{className:`text-sm max-w-52 truncate break-all`,children:(0,W.jsx)(tE,{href:e,target:`_blank`,variant:`ghost`,rel:`noopener noreferrer`,className:`hover:underline`,children:e})}),(0,W.jsx)(Iw,{copied:n===`copied`,children:(0,W.jsx)(`button`,{type:`button`,"aria-label":`Copy gateway URL`,className:`p-1 hover:bg-muted rounded-md transition-colors`,onClick:()=>void t(),children:n===`copied`?(0,W.jsx)(Xf,{size:16,className:`text-green-500`}):(0,W.jsx)(sp,{size:16})})})]})]})]}):(0,W.jsxs)(`div`,{className:`w-60 p-5 text-center`,children:[(0,W.jsx)(`div`,{className:`text-2xl font-medium`,children:`🙈`}),(0,W.jsx)(X,{as:`div`,className:`mt-4`,children:`Deployment URL not configured. Make sure your local gateway is running.`})]})})]})},Qpt=()=>{let e=nm(),t={account:e.account.name,project:e.project.name,environment:encodeURIComponent(e.environment.urlParameter)};return(0,W.jsxs)(qpt,{id:`_sidebar`,className:`flex-row justify-between`,children:[(0,W.jsxs)(`nav`,{"aria-label":`Sidebar`,className:`flex gap-2 items-center`,children:[(0,W.jsx)(Xpt,{end:!0,to:fo(Jpt,t),children:`Project`}),(0,W.jsx)(Xpt,{to:fo(Cb.Code,t),children:`Code`})]}),(0,W.jsx)(Zpt,{})]})},KZ=(0,U.createContext)({chromeBottom:0});function $pt({height:e,children:t}){let n={chromeBottom:(0,U.useContext)(KZ).chromeBottom+e};return(0,W.jsx)(KZ.Provider,{value:n,children:t})}function emt(){return(0,U.useContext)(KZ).chromeBottom}function tmt(e=0){let t=emt()+e;return{top:`calc(${t}px + var(--banner-height, 0px))`,fillHeight:`calc(100vh - ${t}px - var(--banner-height, 0px))`}}var nmt=({children:e,className:t,offset:n=0})=>{let{fillHeight:r}=tmt(n);return(0,W.jsx)(`div`,{className:G(t),style:{height:r},children:e})};function rmt({open:e,editors:t,onSelect:n,onCancel:r}){let[i,a]=(0,U.useState)(null);return(0,W.jsx)(tT,{open:e,onOpenChange:e=>!e&&r(),children:(0,W.jsxs)(iT,{className:`sm:max-w-md`,children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:`Choose Your Editor`}),(0,W.jsx)(cT,{children:`Select which editor you'd like to use for opening files. This preference will be saved for future use.`})]}),(0,W.jsx)(`div`,{className:`space-y-2 py-4`,children:t.map(e=>(0,W.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-info-muted`:`border-surface-border 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,W.jsx)(`div`,{className:`font-medium`,children:e.name})},e.id))}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`ghost`,onClick:r,children:`Cancel`}),(0,W.jsx)(Y,{variant:`default`,onClick:()=>{i&&n(i)},disabled:!i,children:`Save Preference`})]})]})})}var qZ=`/api/v1/editor`;function imt(){let[e]=Hl(),[t,n]=(0,U.useState)(null),[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)([]),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(!0);(0,U.useEffect)(()=>{(async()=>{try{let e=await fetch(`${qZ}/list`);if(!e.ok)throw Error(`Failed to fetch editors: ${e.status}`);o((await e.json()).editors);let t=await fetch(`${qZ}/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){Ye.error(`Failed to load editor preference`,{error:e})}finally{u(!1)}})()},[]);let d=(0,U.useCallback)(async e=>{try{if((await fetch(`${qZ}/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){Ye.error(`Failed to save editor preference`,{error:e})}},[a]),f=(0,U.useCallback)(async()=>{let n=e.get(`path`);if(!n){Ye.warn(`No file path in URL`);return}if(!t){c(!0);return}try{let e=await fetch(`${qZ}/open`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({file:n})});if(!e.ok){let t=await e.json();Ye.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){Ye.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 amt=e=>new Promise(t=>setTimeout(t,e)),JZ=e=>{let[t,n]=(0,U.useState)(`idle`),[r,i]=(0,U.useState)(),[a,o]=(0,U.useState)(null);return{state:t,error:r,execute:(0,U.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}},YZ=()=>({isReadOnly:nm().environment.environmentType!==BP.WORKING_COPY}),omt=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}})),smt=r(a(((e,t)=>{var n=omt();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}}))()),cmt=1024*64,XZ=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>cmt)throw TypeError(`pattern is too long`)},lmt={"[: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]},ZZ=e=>e.replace(/[[\]\\-]/g,`\\$&`),umt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),dmt=e=>e.join(``),fmt=(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(lmt))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(ZZ(d)+`-`+ZZ(t)):t===d&&r.push(ZZ(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(ZZ(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(ZZ(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[umt(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+dmt(r)+`]`,p=`[`+(l?``:`^`)+dmt(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},QZ=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/\[([^\/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,`$1$2`).replace(/\\([^\/])/g,`$1`),pmt=new Set([`!`,`?`,`+`,`*`,`@`]),$Z=e=>pmt.has(e),mmt=e=>$Z(e.type),hmt=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),gmt=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),_mt=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),vmt=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),ymt=`(?!\\.\\.?(?:$|/))`,eQ=`(?!\\.)`,bmt=new Set([`[`,`.`]),xmt=new Set([`..`,`.`]),Smt=new Set(`().*{}+?[]^$\\!`),Cmt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),tQ=`[^/]`,wmt=tQ+`*?`,Tmt=tQ+`+?`,Emt=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&&$Z(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($Z(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,gmt)}#m(e,t=hmt){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=_mt){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!!vmt.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=vmt.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(mmt(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()),!mmt(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&&xmt.has(this.#r[0]))){let e=bmt,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?ymt:i?eQ:``}let i=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(i=`(?:$|\\/)`),[r+n+i,QZ(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,QZ(this.toString()),!1,!1]}let r=``;if(this.type===`!`&&this.#u)r=(this.isStart()&&!this.#c.dot?eQ:``)+Tmt;else{let e=this.type===`!`?`))`+(this.isStart()&&!this.#c.dot?eQ:``)+wmt+`)`:this.type===`@`?`)`:`)${this.type}`;r=t+n+e}return[r,QZ(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+=(Smt.has(c)?`\\`:``)+c;continue}if(c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=fmt(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)?Tmt:wmt,t=!0;continue}if(c===`?`){i+=tQ,t=!0;continue}i+=Cmt(c)}return[i,QZ(e),!!t,a]}},Dmt=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),nQ=(e,t,n={})=>(XZ(t),!n.nocomment&&t.charAt(0)===`#`?!1:new aQ(t,n).match(e)),Omt=/^\*+([^+@!?\*\[\(]*)$/,kmt=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),Amt=e=>t=>t.endsWith(e),jmt=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),Mmt=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Nmt=/^\*+\.\*+$/,Pmt=e=>!e.startsWith(`.`)&&e.includes(`.`),Fmt=e=>e!==`.`&&e!==`..`&&e.includes(`.`),Imt=/^\.\*+$/,Lmt=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),Rmt=/^\*+$/,zmt=e=>e.length!==0&&!e.startsWith(`.`),Bmt=e=>e.length!==0&&e!==`.`&&e!==`..`,Vmt=/^\?+([^+@!?\*\[\(]*)?$/,Hmt=([e,t=``])=>{let n=Kmt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Umt=([e,t=``])=>{let n=qmt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Wmt=([e,t=``])=>{let n=qmt([e]);return t?e=>n(e)&&e.endsWith(t):n},Gmt=([e,t=``])=>{let n=Kmt([e]);return t?e=>n(e)&&e.endsWith(t):n},Kmt=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},qmt=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},Jmt=typeof process==`object`&&process?{}.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Ymt={win32:{sep:`\\`},posix:{sep:`/`}};nQ.sep=Jmt===`win32`?Ymt.win32.sep:Ymt.posix.sep;var rQ=Symbol(`globstar **`);nQ.GLOBSTAR=rQ;var Xmt=`[^/]*?`,Zmt=`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`,Qmt=`(?:(?!(?:\\/|^)\\.).)*?`;nQ.filter=(e,t={})=>n=>nQ(n,e,t);var iQ=(e,t={})=>Object.assign({},e,t);nQ.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return nQ;let t=nQ;return Object.assign((n,r,i={})=>t(n,r,iQ(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,iQ(e,n))}static defaults(n){return t.defaults(iQ(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,iQ(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,iQ(e,r))}},unescape:(n,r={})=>t.unescape(n,iQ(e,r)),escape:(n,r={})=>t.escape(n,iQ(e,r)),filter:(n,r={})=>t.filter(n,iQ(e,r)),defaults:n=>t.defaults(iQ(e,n)),makeRe:(n,r={})=>t.makeRe(n,iQ(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,iQ(e,r)),match:(n,r,i={})=>t.match(n,r,iQ(e,i)),sep:t.sep,GLOBSTAR:rQ})};var $mt=(e,t={})=>(XZ(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:(0,smt.default)(e));nQ.braceExpand=$mt,nQ.makeRe=(e,t={})=>new aQ(e,t).makeRe(),nQ.match=(e,t,n={})=>{let r=new aQ(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};var eht=/[?*]|[+@!]\(.*?\)|\[|\]/,tht=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),aQ=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){XZ(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||Jmt,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]===`?`||!eht.test(e[2]))&&!eht.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(rQ)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(rQ,i),o=t.lastIndexOf(rQ),[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===rQ?(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===rQ)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 $mt(this.pattern,this.options)}parse(e){XZ(e);let t=this.options;if(e===`**`)return rQ;if(e===``)return``;let n,r=null;(n=e.match(Rmt))?r=t.dot?Bmt:zmt:(n=e.match(Omt))?r=(t.nocase?t.dot?Mmt:jmt:t.dot?Amt:kmt)(n[1]):(n=e.match(Vmt))?r=(t.nocase?t.dot?Umt:Hmt:t.dot?Wmt:Gmt)(n):(n=e.match(Nmt))?r=t.dot?Fmt:Pmt:(n=e.match(Imt))&&(r=Lmt);let i=Emt.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?Xmt:t.dot?Zmt:Qmt,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`?tht(e):e===rQ?rQ:e._src});return t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==rQ||a===rQ||(a===void 0?i!==void 0&&i!==rQ?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|`+n+`)?`:i!==rQ&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=rQ))}),t.filter(e=>e!==rQ).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 nQ.defaults(e).Minimatch}};nQ.AST=Emt,nQ.Minimatch=aQ,nQ.escape=Dmt,nQ.unescape=QZ;var nht=()=>{let e=P();return I({mutationFn:async t=>await e.fetch(V.directories.createDirectory(t))})};function rht(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===$l.Directory&&r.some(t=>nQ(e.path,t))?!0:n.find(t=>nQ(e.path,t))!==void 0)}function iht(e,t){return(0,U.useCallback)(async()=>rht(await iu(t,`/`),e),[t,e])}function oQ(){let{logEvent:e}=H(),t=dQ(),n=lm(),r=cm(e=>e.showSaveConflict);return yX({onMutate:({files:e})=>{e.forEach(e=>{t({...e,saveState:eu.saving})})},onSuccess:async(e,{files:n,environmentName:r})=>{e.buildId&&r&&mt(r,e.buildId),n.forEach(n=>{let r=e.files?.[n.path];Ye.debug(`Updated ${n.path} after save - lastModified: ${r}`),t({...n,lastModified:r,saveState:eu.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){Ye.error(`Failed to parse conflict error instance data`,{error:e})}return}a.forEach(e=>{t({...e,saveState:eu.modified})}),e(`file-save-failed`,{fileNames:n.map(e=>e.path).join(`, `)})}})}function aht(){let e=nm(),{logEvent:t,captureException:n}=H(),r=uht(),i=dQ(),a=sst(),{isReadOnly:o}=YZ(),{execute:s}=JZ(async s=>{if(o)return{success:!1,error:Error(`Unable to delete file - environment is read-only`)};let c=s.saveState;i({...s,saveState:eu.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 sQ(){let e=kP(),{logEvent:t,captureException:n}=H(),r=dQ(),i=cm(e=>e.projectTreeNodes),a=vX(),o=nm([`account`,`project`,`environment`]),{execute:s}=JZ(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 iu(o.environment.name,c).catch(()=>[])).find(e=>e.path===m);if(e)return e}let _={content:h,path:m},v={saveState:eu.new,type:$l.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&&mt(o.environment.name,s.buildId),r({...v,lastModified:s.lastModified,saveState:eu.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:eu.modified});return}});return s}function oht(e){let t=kP(),{logEvent:n,captureException:r}=H(),i=Ab([`account`,`project`]),a=dQ(),o=uht(),s=cst(),{execute:c}=JZ(async(c,l)=>{if(t)try{a({...c,saveState:eu.removing}),await s.mutateAsync({environmentName:e,path:c.path,newPath:l}),a({...c,saveState:eu.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:eu.unmodified});return}});return c}function sht(e){let t=kP(),{logEvent:n,captureException:r}=H(),i=dQ(),a=nht(),{execute:o}=JZ(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:eu.new,type:$l.Directory,...u};try{return i(d),await a.mutateAsync({environmentName:e,path:l}),i({...d,saveState:eu.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:eu.modified}),t}});return o}function cQ(){return uQ(vit().get(`path`))}function lQ(){let e=kP(),t=dQ();return(0,U.useCallback)((n,r=!1,i=eu.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 uQ(e){return cm(t=>e?t.filesByPath[e]:void 0)}function cht(e){let t=cm(e=>e.projectTreeNodes),n=[],r=Object.values(e);return t.filter(e=>e.type===$l.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 lht(e){return cm(e=>e.projectTreeNodes).filter(t=>!t.path&&!e.fileGlob?!1:t.type===$l.Directory&&e.subdirectoryGlob?nQ(t.path,e.subdirectoryGlob):nQ(t.path,e.fileGlob))}function uht(){let e=kP(),t=cm(e=>e.removeFile),n=cm(e=>e.filterProjectTreeNodes);return r=>{e&&e.editor.getModel(e.Uri.file(r))?.dispose(),t(r),n(e=>e.path!==r)}}function dQ(){return cm(e=>e.updateFile)}var dht=e=>{let t=lQ(),n=uQ(e);return e=>{n&&t(n,!0,e)}},fht=()=>{let e=nm(),t=oQ(),n=lm();return wGe(e.environment.name),{isPending:t.isPending,isSuccess:t.isSuccess,saveAndDeploy:(0,U.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])}},pht=(e={})=>{let{isReadOnly:t=!1,onSave:n}=e,{saveAndDeploy:r,isPending:i,isSuccess:a}=fht(),[o,s]=(0,U.useState)(null),c=cm(e=>{let t=0;for(let n of e.projectTreeNodes){let r=n.path?e.filesByPath[n.path]:void 0;r&&r.saveState===eu.modified&&t++}return t}),l=cm(e=>{let t=0;for(let n of e.projectTreeNodes){let r=n.path?e.filesByPath[n.path]:void 0;r&&(r.saveState===eu.modified||r.saveState===eu.saving)&&t++}return t}),u=(0,U.useRef)(null),d=e=>{s(e),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{s(null)},1600)},f=lF(r),p=lF(n),m=$p(e=>e.addToast),h=(0,U.useRef)(!1),g=(0,U.useRef)(!1);return(0,U.useEffect)(()=>{let e=h.current;!e&&i?g.current=l>0:e&&!i&&a&&g.current&&(m({message:`Changes saved`,icon:(0,U.createElement)(Xf,{size:18}),duration:2e3}),g.current=!1),h.current=i},[i,a,l,m]),(0,U.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 amt(100)}if(c===0){d(`No unsaved changes`);return}p.current?.(),await f.current()}}catch(e){Ye.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}},mht=()=>{let{showTooltip:e,saveAll:t,isSaving:n,unsavedChangesCount:r}=pht(),{hasEditor:i,editorName:a,isLoading:o,showPreferenceDialog:s,setShowPreferenceDialog:c,availableEditors:l,savePreference:u,openInEditor:d}=imt();return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`h-12 shrink-0 border-t bg-surface-sunken items-center flex px-2 gap-x-2`,children:[(0,W.jsx)(Pw,{open:!!e,content:e??``,children:(0,W.jsx)(Y,{variant:r>0||n?`default`:`ghost`,size:`sm`,className:`text-xs`,"data-test":`save`,disabled:n,onClick:async()=>{await t()},children:(0,W.jsxs)(CP,{className:`flex items-center gap-1 text-xs relative`,loading:n,children:[`Save`,(0,W.jsx)(`span`,{className:r>0?`text-white`:`text-muted-foreground`,children:`[⌘+S]`})]})})}),!o&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`h-6 w-px bg-border`}),(0,W.jsx)(Pw,{content:i?`Open in ${a}`:`Choose editor to open files`,children:(0,W.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:d,className:`text-xs`,children:[(0,W.jsx)(up,{size:14}),`Open in Editor`]})})]})]}),(0,W.jsx)(rmt,{open:s,editors:l,onSelect:u,onCancel:()=>c(!1)})]})},hht=({className:e})=>(0,W.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,W.jsx)(`title`,{children:`route`}),(0,W.jsx)(`g`,{id:`Page-1`,stroke:`none`,strokeWidth:`1`,fill:`none`,fillRule:`evenodd`,children:(0,W.jsxs)(`g`,{id:`route`,transform:`translate(0.393398, 0.686292)`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,W.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,W.jsxs)(`g`,{id:`arrow`,transform:`translate(7.616869, 7.313708)`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`polyline`,{id:`Path-2`,points:`3.71305334 5.62451673 6 2.81225836 3.71305334 2.8356215e-17`}),(0,W.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`})]})]})})]}),ght=[`@zuplo/runtime`,`@zuplo/graphql`,`@zuplo/otel`];function _ht(e){return e===`.`?`index.d.ts`:`${e.replace(/^\.\//,``)}/index.d.ts`}var vht=[{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`}],yht=[{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 bht(){try{return await(await fetch(`https://cdn.zuplo.com/types/remote-modules.d.ts`)).text()}catch(e){Et.captureException(e)}}async function xht(e,t){try{let n=await fetch(`${nt}/types/${e}/${t}/package.json`);if(!n.ok)throw Error(`Error loading package.json for ${e}`);return await n.json()}catch(e){Et.captureException(e)}}async function Sht(){try{let e=await fetch(`${nt}/types/@zuplo/bundled/bundles.json`);if(!e.ok)throw Error(`Error loading bundles from CDN`);let t=await e.json();return[...vht,...t.bundles]}catch(e){Et.captureException(e)}return[...vht]}async function fQ(e){try{let t=await fetch(`${nt}/${e}`);if(!t.ok)throw Error(`Error loading type definition: ${e}`);return await t.text()}catch(e){Et.captureException(e)}}var Cht=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 wht(e){await Promise.all(ght.map(async t=>{let n=await xht(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 fQ(`types/${t}/latest/${r.types.substring(2)}`);if(i){let r=_ht(n);e.typescript.typescriptDefaults.addExtraLib(i,`file:///node_modules/${t}/${r}`)}})))}))}async function Tht(e){let t=Object.keys(e.typescript.typescriptDefaults.getExtraLibs()),n=await Sht();await Promise.allSettled([...yht.map(async({types:t,name:n})=>{let r=await fQ(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 fQ(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 Eht=null,Dht=`
|
|
352
352
|
declare module "@zuplo/zudoku-plugin-monetization" {
|
|
353
353
|
export interface ZuploMonetizationPluginOptions {
|
|
354
354
|
pricing?: {
|
|
@@ -483,7 +483,7 @@ export function runtimeInit(runtime: RuntimeExtensions) {
|
|
|
483
483
|
`,`
|
|
484
484
|
+`).split(`
|
|
485
485
|
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,U.useEffect)(()=>{let n=t?.target??QAt,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)&&nkt(e))return!1;let n=ejt(e.code,s);if(a.current.add(e[n]),$At(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=ejt(e.code,s);$At(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 $At(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function ejt(e,t){return t.includes(e)?`code`:`key`}var tjt=()=>{let e=_4();return(0,U.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=V2(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 R2(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=z2(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function njt(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)rjt(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 rjt(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 ijt(e,t){return njt(e,t)}function ajt(e,t){return njt(e,t)}function S4(e,t){return{id:e,type:`select`,selected:t}}function C4(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(S4(a.id,e)))}return r}function ojt({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 sjt(e){return{id:e.id,type:`remove`}}var cjt=e=>POt(e),ljt=e=>NOt(e);function ujt(e){return(0,U.forwardRef)(e)}function djt(e){let[t,n]=(0,U.useState)(BigInt(0)),[r]=(0,U.useState)(()=>fjt(()=>n(e=>e+BigInt(1))));return b4(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function fjt(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var pjt=(0,U.createContext)(null);function mjt({children:e}){let t=_4(),n=djt((0,U.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=ojt({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=djt((0,U.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(ojt({items:s,lookup:o}))},[])),i=(0,U.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,W.jsx)(pjt.Provider,{value:i,children:e})}function hjt(){let e=(0,U.useContext)(pjt);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var gjt=e=>!!e.panZoom;function w4(){let e=tjt(),t=_4(),n=hjt(),r=g4(gjt),i=(0,U.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=cjt(e)?e:n.get(e.id),a=i.parentId?XOt(i.position,i.measured,i.parentId,n,r):i.position;return N2({...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&&cjt(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&&ljt(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 BOt({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(sjt);o?.(f),c(e)}if(m){let e=d.map(sjt);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=GOt(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=N2(s?r:a),l=F2(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=GOt(e)?e:a(e);if(!r)return!1;let i=F2(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 FOt(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??QOt();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,U.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var _jt=e=>e.selected,vjt=typeof window<`u`?window:void 0;function yjt({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=_4(),{deleteElements:r}=w4(),i=x4(e,{actInsideInputWithModifier:!1}),a=x4(t,{target:vjt});(0,U.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(_jt),edges:e.filter(_jt)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,U.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function bjt(e){let t=_4();(0,U.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=K2(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,g2.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 T4={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},xjt=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Sjt({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=y2.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=_4(),S=(0,U.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=g4(xjt,m4),E=x4(f),D=(0,U.useRef)();bjt(S);let O=(0,U.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,U.useEffect)(()=>{if(S.current){D.current=sAt({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,U.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,W.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:T4,children:m})}var Cjt=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function wjt(){let{userSelectionActive:e,userSelectionRect:t}=g4(Cjt,m4);return e&&t?(0,W.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 E4=(e,t)=>n=>{n.target===t.current&&e?.(n)},Tjt=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Ejt({isSelecting:e,selectionKeyPressed:t,selectionMode:n=b2.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=_4(),{userSelectionActive:g,elementsSelectable:_,dragging:v,connectionInProgress:y}=g4(Tjt,m4),b=_&&(e||g),x=(0,U.useRef)(null),S=(0,U.useRef)(),C=(0,U.useRef)(new Set),w=(0,U.useRef)(new Set),T=(0,U.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,W.jsxs)(`div`,{className:u0([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:v,selection:e}]),onClick:b?void 0:E4(E,x),onContextMenu:E4(D,x),onWheel:E4(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}=q2(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===b2.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)}}ZOt(b,C.current)||u(C4(s,C.current,!0)),ZOt(x,w.current)||d(C4(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}=q2(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:T4,children:[m,(0,W.jsx)(wjt,{})]})}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`,g2.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function Djt({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=_4(),[c,l]=(0,U.useState)(!1),u=(0,U.useRef)();return(0,U.useEffect)(()=>{u.current=Vkt({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{D4({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,U.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 Ojt=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function kjt(){let e=_4();return(0,U.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=Ojt(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=L2(t,i));let{position:a,positionAbsolute:s}=zOt({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 O4=(0,U.createContext)(null),Ajt=O4.Provider;O4.Consumer;var jjt=()=>(0,U.useContext)(O4),Mjt=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Njt=(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===v2.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function Pjt({type:e=`source`,position:t=C2.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=_4(),_=jjt(),{connectOnClick:v,noPanClassName:y,rfId:b}=g4(Mjt,m4),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=g4(Njt(_,m,e),m4);_||g.getState().onError?.(`010`,g2.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(pkt(i,e))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=rkt(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();a4.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=ekt(t.target),h=n||c,{connection:v,isValid:y}=a4.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,W.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:u0([`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 k4=(0,U.memo)(ujt(Pjt));function Fjt({data:e,isConnectable:t,sourcePosition:n=C2.Bottom}){return(0,W.jsxs)(W.Fragment,{children:[e?.label,(0,W.jsx)(k4,{type:`source`,position:n,isConnectable:t})]})}function Ijt({data:e,isConnectable:t,targetPosition:n=C2.Top,sourcePosition:r=C2.Bottom}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(k4,{type:`target`,position:n,isConnectable:t}),e?.label,(0,W.jsx)(k4,{type:`source`,position:r,isConnectable:t})]})}function Ljt(){return null}function Rjt({data:e,isConnectable:t,targetPosition:n=C2.Top}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(k4,{type:`target`,position:n,isConnectable:t}),e?.label]})}var A4={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},zjt={input:Fjt,default:Ijt,output:Rjt,group:Ljt};function Bjt(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 Vjt=e=>{let{width:t,height:n,x:r,y:i}=E2(e.nodeLookup,{filter:e=>!!e.selected});return{width:I2(t)?t:null,height:I2(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 Hjt({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=_4(),{width:i,height:a,transformString:o,userSelectionActive:s}=g4(Vjt,m4),c=kjt(),l=(0,U.useRef)(null);(0,U.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(Djt({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,W.jsx)(`div`,{className:u0([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,W.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(A4,e.key)&&(e.preventDefault(),c({direction:A4[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var Ujt=typeof window<`u`?window:void 0,Wjt=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Gjt({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}=g4(Wjt,m4),R=x4(l,{target:Ujt}),z=x4(h,{target:Ujt}),B=z||w,V=z||b,ee=u&&B!==!0,H=R||L||ee;return yjt({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,W.jsx)(Sjt,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:V,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:ee,children:(0,W.jsxs)(Ejt,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:B,isSelecting:!!H,selectionMode:d,selectionKeyPressed:R,paneClickDistance:s,selectionOnDrag:ee,children:[e,I&&(0,W.jsx)(Hjt,{onSelectionContextMenu:A,noPanClassName:M,disableKeyboardA11y:N})]})})}Gjt.displayName=`FlowRenderer`;var Kjt=(0,U.memo)(Gjt),qjt=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 Jjt(e){return g4((0,U.useCallback)(qjt(e),[e]),m4)}var Yjt=e=>e.updateNodeInternals;function Xjt(){let e=g4(Yjt),[t]=(0,U.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,U.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Zjt({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=_4(),a=(0,U.useRef)(null),o=(0,U.useRef)(null),s=(0,U.useRef)(e.sourcePosition),c=(0,U.useRef)(e.targetPosition),l=(0,U.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,U.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,U.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,U.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 Qjt({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}=g4(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},m4),S=y.type||`default`,C=g?.[S]||zjt[S];C===void 0&&(v?.(`003`,g2.error003(S)),S=`default`,C=g?.default||zjt.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=_4(),k=YOt(y),A=Zjt({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=Djt({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=kjt();if(y.hidden)return null;let N=W2(y),P=Bjt(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,V=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})},ee=t=>{if(!(nkt(t.nativeEvent)||m)){if(OOt.includes(t.key)&&T)D4({id:e,store:O,unselect:t.key===`Escape`,nodeRef:A});else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(A4,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:A4[t.key],factor:t.shiftKey?4:1})}}},H=()=>{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,W.jsx)(`div`,{className:u0([`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:V,onDoubleClick:B,onKeyDown:D?ee:void 0,tabIndex:D?0:void 0,onFocus:D?H:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${jAt}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,W.jsx)(Ajt,{value:e,children:(0,W.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 $jt=(0,U.memo)(Qjt),eMt=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function tMt(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=g4(eMt,m4),o=Jjt(e.onlyRenderVisibleElements),s=Xjt();return(0,W.jsx)(`div`,{className:`react-flow__nodes`,style:T4,children:o.map(o=>(0,W.jsx)($jt,{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))})}tMt.displayName=`NodeRenderer`;var nMt=(0,U.memo)(tMt);function rMt(e){return g4((0,U.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&&ukt({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),m4)}var iMt=({color:e=`none`,strokeWidth:t=1})=>(0,W.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),aMt=({color:e=`none`,strokeWidth:t=1})=>(0,W.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`}),oMt={[S2.Arrow]:iMt,[S2.ArrowClosed]:aMt};function sMt(e){let t=_4();return(0,U.useMemo)(()=>Object.prototype.hasOwnProperty.call(oMt,e)?oMt[e]:(t.getState().onError?.(`009`,g2.error009(e)),null),[e])}var cMt=({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=sMt(t);return c?(0,W.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,W.jsx)(c,{color:n,strokeWidth:o})}):null},lMt=({defaultColor:e,rfId:t})=>{let n=g4(e=>e.edges),r=g4(e=>e.defaultEdgeOptions),i=(0,U.useMemo)(()=>wkt(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,W.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,W.jsx)(`defs`,{children:i.map(e=>(0,W.jsx)(cMt,{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};lMt.displayName=`MarkerDefinitions`;var uMt=(0,U.memo)(lMt);function dMt({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,U.useState)({x:1,y:0,width:0,height:0}),p=u0([`react-flow__edge-textwrapper`,l]),m=(0,U.useRef)(null);return(0,U.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,W.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,W.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,W.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}dMt.displayName=`EdgeText`;var fMt=(0,U.memo)(dMt);function j4({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{...u,d:e,fill:`none`,className:u0([`react-flow__edge-path`,u.className])}),l?(0,W.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&I2(t)&&I2(n)?(0,W.jsx)(fMt,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function pMt({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===C2.Left||e===C2.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function mMt({sourceX:e,sourceY:t,sourcePosition:n=C2.Bottom,targetX:r,targetY:i,targetPosition:a=C2.Top}){let[o,s]=pMt({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=pMt({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=akt({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 hMt(e){return(0,U.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]=mMt({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,W.jsx)(j4,{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 gMt=hMt({isInternal:!1}),_Mt=hMt({isInternal:!0});gMt.displayName=`SimpleBezierEdge`,_Mt.displayName=`SimpleBezierEdgeInternal`;function vMt(e){return(0,U.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=C2.Bottom,targetPosition:m=C2.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Y2({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,W.jsx)(j4,{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 yMt=vMt({isInternal:!1}),bMt=vMt({isInternal:!0});yMt.displayName=`SmoothStepEdge`,bMt.displayName=`SmoothStepEdgeInternal`;function xMt(e){return(0,U.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,W.jsx)(yMt,{...n,id:r,pathOptions:(0,U.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var SMt=xMt({isInternal:!1}),CMt=xMt({isInternal:!0});SMt.displayName=`StepEdge`,CMt.displayName=`StepEdgeInternal`;function wMt(e){return(0,U.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]=mkt({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,W.jsx)(j4,{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 TMt=wMt({isInternal:!1}),EMt=wMt({isInternal:!0});TMt.displayName=`StraightEdge`,EMt.displayName=`StraightEdgeInternal`;function DMt(e){return(0,U.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=C2.Bottom,targetPosition:s=C2.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]=skt({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,W.jsx)(j4,{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 OMt=DMt({isInternal:!1}),kMt=DMt({isInternal:!0});OMt.displayName=`BezierEdge`,kMt.displayName=`BezierEdgeInternal`;var AMt={default:kMt,straight:EMt,step:CMt,smoothstep:bMt,simplebezier:_Mt},jMt={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},MMt=(e,t,n)=>n===C2.Left?e-t:n===C2.Right?e+t:e,NMt=(e,t,n)=>n===C2.Top?e-t:n===C2.Bottom?e+t:e,PMt=`react-flow__edgeupdater`;function FMt({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,W.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:u0([PMt,`${PMt}-${s}`]),cx:MMt(t,r,e),cy:NMt(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function IMt({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=_4(),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`;a4.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,W.jsxs)(W.Fragment,{children:[(e===!0||e===`source`)&&(0,W.jsx)(FMt,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,W.jsx)(FMt,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function LMt({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=g4(t=>t.edgeLookup.get(e)),b=g4(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||AMt[x];S===void 0&&(_?.(`011`,g2.error011(x)),x=`default`,S=h?.default||AMt.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,U.useRef)(null),[D,O]=(0,U.useState)(!1),[k,A]=(0,U.useState)(!1),j=_4(),{zIndex:M,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=g4((0,U.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return{zIndex:y.zIndex,...jMt};let i=xkt({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_});return{zIndex:lkt({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...i||jMt}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),m4),z=(0,U.useMemo)(()=>y.markerStart?`url('#${Z2(y.markerStart,m)}')`:void 0,[y.markerStart,m]),B=(0,U.useMemo)(()=>y.markerEnd?`url('#${Z2(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let V=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)},ee=a?e=>{a(e,{...y})}:void 0,H=o?e=>{o(e,{...y})}:void 0,te=s?e=>{s(e,{...y})}:void 0,ne=c?e=>{c(e,{...y})}:void 0,re=l?e=>{l(e,{...y})}:void 0;return(0,W.jsx)(`svg`,{style:{zIndex:M},children:(0,W.jsxs)(`g`,{className:u0([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:V,onDoubleClick:ee,onContextMenu:H,onMouseEnter:te,onMouseMove:ne,onMouseLeave:re,onKeyDown:C?t=>{if(!v&&OOt.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?`${MAt}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,W.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,W.jsx)(IMt,{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 RMt=(0,U.memo)(LMt),zMt=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function BMt({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}=g4(zMt,m4),b=rMt(t);return(0,W.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,W.jsx)(uMt,{defaultColor:e,rfId:n}),b.map(e=>(0,W.jsx)(RMt,{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))]})}BMt.displayName=`EdgeRenderer`;var VMt=(0,U.memo)(BMt),HMt=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function UMt({children:e}){return(0,W.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:g4(HMt)},children:e})}function WMt(e){let t=w4(),n=(0,U.useRef)(!1);(0,U.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var GMt=e=>e.panZoom?.syncViewport;function KMt(e){let t=g4(GMt),n=_4();return(0,U.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function qMt(e){return e.connection.inProgress?{...e.connection,to:R2(e.connection.to,e.transform)}:{...e.connection}}function JMt(e){return e?t=>e(qMt(t)):qMt}function YMt(e){return g4(JMt(e),m4)}var XMt=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function ZMt({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=g4(XMt,m4);return a&&i&&c?(0,W.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,W.jsx)(`g`,{className:u0([`react-flow__connection`,MOt(s)]),children:(0,W.jsx)(QMt,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var QMt=({style:e,type:t=x2.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}=YMt();if(!i)return;if(n)return(0,W.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:MOt(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 x2.Bezier:[m]=skt(h);break;case x2.SimpleBezier:[m]=mMt(h);break;case x2.Step:[m]=Y2({...h,borderRadius:0});break;case x2.SmoothStep:[m]=Y2(h);break;default:[m]=mkt(h)}return(0,W.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};QMt.displayName=`ConnectionLine`;var $Mt={};function eNt(e=$Mt){(0,U.useRef)(e),_4(),(0,U.useEffect)(()=>{},[e])}function tNt(){_4(),(0,U.useRef)(!1),(0,U.useEffect)(()=>{},[])}function nNt({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:V,onPaneMouseMove:ee,onPaneMouseLeave:H,onPaneScroll:te,onPaneContextMenu:ne,paneClickDistance:re,nodeClickDistance:ie,onEdgeContextMenu:ae,onEdgeMouseEnter:oe,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:le,onReconnect:ue,onReconnectStart:de,onReconnectEnd:fe,noDragClassName:pe,noWheelClassName:me,noPanClassName:he,disableKeyboardA11y:ge,nodeExtent:_e,rfId:ve,viewport:ye,onViewportChange:be}){return eNt(e),eNt(t),tNt(),WMt(n),KMt(ye),(0,W.jsx)(Kjt,{onPaneClick:B,onPaneMouseEnter:V,onPaneMouseMove:ee,onPaneMouseLeave:H,onPaneContextMenu:ne,onPaneScroll:te,paneClickDistance:re,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:pe,noWheelClassName:me,noPanClassName:he,disableKeyboardA11y:ge,onViewportChange:be,isControlledViewport:!!ye,children:(0,W.jsxs)(UMt,{children:[(0,W.jsx)(VMt,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:ue,onReconnectStart:de,onReconnectEnd:fe,onlyRenderVisibleElements:T,onEdgeContextMenu:ae,onEdgeMouseEnter:oe,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:le,defaultMarkerColor:M,noPanClassName:he,disableKeyboardA11y:ge,rfId:ve}),(0,W.jsx)(ZMt,{style:h,type:m,component:g,containerStyle:_}),(0,W.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,W.jsx)(nMt,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:ie,onlyRenderVisibleElements:T,noPanClassName:he,noDragClassName:pe,disableKeyboardA11y:ge,nodeExtent:_e,rfId:ve}),(0,W.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}nNt.displayName=`GraphView`;var rNt=(0,U.memo)(nNt),iNt=({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??_2;Ikt(h,g,_);let{nodesInitialized:x}=t4(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=V2(E2(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:_2,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:v2.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:{...AOt},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KOt,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:kOt,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},aNt=({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})=>EAt((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 ROt({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...iNt({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}=t4(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();Ikt(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}=Nkt(e,n,r,i,a,o,l);d&&(Okt(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=X2(e,o.fromHandle,C2.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=r4(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(ijt(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(ajt(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=>S4(e,!0)));return}i(C4(r,new Set([...e]),!0)),a(C4(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>S4(e,!0)));return}a(C4(n,new Set([...e]))),i(C4(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(S4(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(S4(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,S4(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,S4(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]||(t4(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 Pkt({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:{...AOt}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...iNt()})}},Object.is);function oNt({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,U.useState)(()=>aNt({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,W.jsx)(DAt,{value:m,children:(0,W.jsx)(mjt,{children:p})})}function sNt({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,U.useContext)(h4)?(0,W.jsx)(W.Fragment,{children:e}):(0,W.jsx)(oNt,{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 cNt={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function lNt({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=x2.Bezier,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,deleteKeyCode:ee=`Backspace`,selectionKeyCode:H=`Shift`,selectionOnDrag:te=!1,selectionMode:ne=b2.Full,panActivationKeyCode:re=`Space`,multiSelectionKeyCode:ie=H2()?`Meta`:`Control`,zoomActivationKeyCode:ae=H2()?`Meta`:`Control`,snapToGrid:oe,snapGrid:se,onlyRenderVisibleElements:ce=!1,selectNodesOnDrag:le,nodesDraggable:ue,autoPanOnNodeFocus:de,nodesConnectable:fe,nodesFocusable:pe,nodeOrigin:me=WAt,edgesFocusable:he,edgesReconnectable:ge,elementsSelectable:_e=!0,defaultViewport:ve=GAt,minZoom:ye=.5,maxZoom:be=2,translateExtent:xe=_2,preventScrolling:Se=!0,nodeExtent:Ce,defaultMarkerColor:we=`#b1b1b7`,zoomOnScroll:Te=!0,zoomOnPinch:Ee=!0,panOnScroll:De=!1,panOnScrollSpeed:Oe=.5,panOnScrollMode:ke=y2.Free,zoomOnDoubleClick:Ae=!0,panOnDrag:je=!0,onPaneClick:Me,onPaneMouseEnter:Ne,onPaneMouseMove:Pe,onPaneMouseLeave:Fe,onPaneScroll:Ie,onPaneContextMenu:Le,paneClickDistance:Re=1,nodeClickDistance:ze=0,children:Be,onReconnect:Ve,onReconnectStart:He,onReconnectEnd:Ue,onEdgeContextMenu:We,onEdgeDoubleClick:Ge,onEdgeMouseEnter:Ke,onEdgeMouseMove:qe,onEdgeMouseLeave:Je,reconnectRadius:Ye=10,onNodesChange:Xe,onEdgesChange:Ze,noDragClassName:Qe=`nodrag`,noWheelClassName:$e=`nowheel`,noPanClassName:et=`nopan`,fitView:tt,fitViewOptions:nt,connectOnClick:rt,attributionPosition:it,proOptions:at,defaultEdgeOptions:ot,elevateNodesOnSelect:st=!0,elevateEdgesOnSelect:ct=!1,disableKeyboardA11y:lt=!1,autoPanOnConnect:ut,autoPanOnNodeDrag:dt,autoPanSpeed:ft,connectionRadius:pt,isValidConnection:mt,onError:ht,style:gt,id:_t,nodeDragThreshold:vt,connectionDragThreshold:yt,viewport:bt,onViewportChange:xt,width:St,height:Ct,colorMode:wt=`light`,debug:Tt,onScroll:Et,ariaLabelConfig:Dt,zIndexMode:Ot=`basic`,...kt},At){let jt=_t||`1`,Mt=ZAt(wt),Nt=(0,U.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Et?.(e)},[Et]);return(0,W.jsx)(`div`,{"data-testid":`rf__wrapper`,...kt,onScroll:Nt,style:{...gt,...cNt},ref:At,className:u0([`react-flow`,i,Mt]),id:_t,role:`application`,children:(0,W.jsxs)(sNt,{nodes:e,edges:t,width:St,height:Ct,fitView:tt,fitViewOptions:nt,minZoom:ye,maxZoom:be,nodeOrigin:me,nodeExtent:Ce,zIndexMode:Ot,children:[(0,W.jsx)(YAt,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:ue,autoPanOnNodeFocus:de,nodesConnectable:fe,nodesFocusable:pe,edgesFocusable:he,edgesReconnectable:ge,elementsSelectable:_e,elevateNodesOnSelect:st,elevateEdgesOnSelect:ct,minZoom:ye,maxZoom:be,nodeExtent:Ce,onNodesChange:Xe,onEdgesChange:Ze,snapToGrid:oe,snapGrid:se,connectionMode:L,translateExtent:xe,connectOnClick:rt,defaultEdgeOptions:ot,fitView:tt,fitViewOptions:nt,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:et,nodeOrigin:me,rfId:jt,autoPanOnConnect:ut,autoPanOnNodeDrag:dt,autoPanSpeed:ft,onError:ht,connectionRadius:pt,isValidConnection:mt,selectNodesOnDrag:le,nodeDragThreshold:vt,connectionDragThreshold:yt,onBeforeDelete:I,debug:Tt,ariaLabelConfig:Dt,zIndexMode:Ot}),(0,W.jsx)(rNt,{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:V,selectionKeyCode:H,selectionOnDrag:te,selectionMode:ne,deleteKeyCode:ee,multiSelectionKeyCode:ie,panActivationKeyCode:re,zoomActivationKeyCode:ae,onlyRenderVisibleElements:ce,defaultViewport:ve,translateExtent:xe,minZoom:ye,maxZoom:be,preventScrolling:Se,zoomOnScroll:Te,zoomOnPinch:Ee,zoomOnDoubleClick:Ae,panOnScroll:De,panOnScrollSpeed:Oe,panOnScrollMode:ke,panOnDrag:je,onPaneClick:Me,onPaneMouseEnter:Ne,onPaneMouseMove:Pe,onPaneMouseLeave:Fe,onPaneScroll:Ie,onPaneContextMenu:Le,paneClickDistance:Re,nodeClickDistance:ze,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Ve,onReconnectStart:He,onReconnectEnd:Ue,onEdgeContextMenu:We,onEdgeDoubleClick:Ge,onEdgeMouseEnter:Ke,onEdgeMouseMove:qe,onEdgeMouseLeave:Je,reconnectRadius:Ye,defaultMarkerColor:we,noDragClassName:Qe,noWheelClassName:$e,noPanClassName:et,rfId:jt,disableKeyboardA11y:lt,nodeExtent:Ce,viewport:bt,onViewportChange:xt}),(0,W.jsx)(UAt,{onSelectionChange:k}),Be,(0,W.jsx)(RAt,{proOptions:at,position:it}),(0,W.jsx)(LAt,{rfId:jt,disableKeyboardA11y:lt})]})})}var uNt=ujt(lNt);g2.error014();function dNt({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,W.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:u0([`react-flow__background-pattern`,n,r])})}function fNt({radius:e,className:t}){return(0,W.jsx)(`circle`,{cx:e,cy:e,r:e,className:u0([`react-flow__background-pattern`,`dots`,t])})}var M4;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(M4||={});var pNt={[M4.Dots]:1,[M4.Lines]:1,[M4.Cross]:6},mNt=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function hNt({id:e,variant:t=M4.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,U.useRef)(null),{transform:f,patternId:p}=g4(mNt,m4),m=r||pNt[t],h=t===M4.Dots,g=t===M4.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,W.jsxs)(`svg`,{className:u0([`react-flow__background`,l]),style:{...c,...T4,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,W.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,W.jsx)(fNt,{radius:y/2,className:u}):(0,W.jsx)(dNt,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,W.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}hNt.displayName=`Background`;var gNt=(0,U.memo)(hNt);function _Nt(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,W.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function vNt(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,W.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function yNt(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,W.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 bNt(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,W.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 xNt(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,W.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 N4({children:e,className:t,...n}){return(0,W.jsx)(`button`,{type:`button`,className:u0([`react-flow__controls-button`,t]),...n,children:e})}var SNt=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function CNt({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=_4(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=g4(SNt,m4),{zoomIn:y,zoomOut:b,fitView:x}=w4(),S=()=>{y(),a?.()},C=()=>{b(),o?.()},w=()=>{x(i),s?.()},T=()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)};return(0,W.jsxs)(v4,{className:u0([`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,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(N4,{onClick:S,className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,W.jsx)(_Nt,{})}),(0,W.jsx)(N4,{onClick:C,className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,W.jsx)(vNt,{})})]}),n&&(0,W.jsx)(N4,{className:`react-flow__controls-fitview`,onClick:w,title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,W.jsx)(yNt,{})}),r&&(0,W.jsx)(N4,{className:`react-flow__controls-interactive`,onClick:T,title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,W.jsx)(xNt,{}):(0,W.jsx)(bNt,{})}),u]})}CNt.displayName=`Controls`,(0,U.memo)(CNt);function wNt({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,W.jsx)(`rect`,{className:u0([`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 TNt=(0,U.memo)(wNt),ENt=e=>e.nodes.map(e=>e.id),P4=e=>e instanceof Function?e:()=>e;function DNt({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=TNt,onClick:o}){let s=g4(ENt,m4),c=P4(t),l=P4(e),u=P4(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,W.jsx)(W.Fragment,{children:s.map(e=>(0,W.jsx)(kNt,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function ONt({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}=g4(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}=W2(r);return{node:r,x:i,y:a,width:o,height:s}},m4);return!l||l.hidden||!YOt(l)?null:(0,W.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 kNt=(0,U.memo)(ONt),ANt=(0,U.memo)(DNt),jNt=200,MNt=150,NNt=e=>!e.hidden,PNt=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?WOt(E2(e.nodeLookup,{filter:NNt}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},FNt=`react-flow__minimap-desc`;function INt({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=_4(),S=(0,U.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=g4(PNt,m4),j=e?.width??jNt,M=e?.height??MNt,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,V=I+R*2,ee=L+R*2,H=`${FNt}-${T}`,te=(0,U.useRef)(0),ne=(0,U.useRef)();te.current=F,(0,U.useEffect)(()=>{if(S.current&&E)return ne.current=Zkt({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>te.current}),()=>{ne.current?.destroy()}},[E]),(0,U.useEffect)(()=>{ne.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let re=p?e=>{let[t,n]=ne.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ie=m?(0,U.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,ae=_??A[`minimap.ariaLabel`];return(0,W.jsx)(v4,{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:u0([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,W.jsxs)(`svg`,{width:j,height:M,viewBox:`${z} ${B} ${V} ${ee}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":H,ref:S,onClick:re,children:[ae&&(0,W.jsx)(`title`,{id:H,children:ae}),(0,W.jsx)(ANt,{onClick:ie,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,W.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${z-R},${B-R}h${V+R*2}v${ee+R*2}h${-V-R*2}z
|
|
486
|
-
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}INt.displayName=`MiniMap`,(0,U.memo)(INt);var LNt=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,RNt={[u4.Line]:`right`,[u4.Handle]:`bottom-right`};function zNt({nodeId:e,position:t,variant:n=u4.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=jjt(),y=typeof e==`string`?e:v,b=_4(),x=(0,U.useRef)(null),S=n===u4.Handle,C=g4((0,U.useCallback)(LNt(S&&p),[S,p]),m4),w=(0,U.useRef)(null),T=t??RNt[n];return(0,U.useEffect)(()=>{if(!(!x.current||!y))return w.current||=gAt({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=r4([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...XOt({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,W.jsx)(`div`,{className:u0([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,U.memo)(zNt);function F4({value:e,onValueChange:t,options:n,columns:r=2,layout:i=`cards`,idPrefix:a=`wizard-choice`,ariaLabel:o,className:s}){return(0,W.jsx)(fwt,{value:e,onValueChange:e=>t(e),"aria-label":o,className:G(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=G(`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,W.jsxs)(rE,{htmlFor:n,className:G(`flex items-center gap-3 px-3 py-2.5`,o),children:[(0,W.jsx)(l0,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,W.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,W.jsx)(`div`,{className:`text-sm font-medium sm:w-56 sm:shrink-0`,children:t.title}),t.description&&(0,W.jsx)(`div`,{className:`min-w-0 flex-1 text-xs leading-snug text-muted-foreground`,children:t.description})]})]},t.value):(0,W.jsxs)(rE,{htmlFor:n,className:G(`flex flex-col gap-1.5 p-3`,o),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(l0,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,W.jsx)(`div`,{className:`text-sm font-medium`,children:t.title})]}),t.description&&(0,W.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t.description})]},t.value)})})}var I4=({tiles:e,selectedId:t,onSelect:n,fallbackIcon:r,columns:i=4,emptyState:a,className:o})=>{let[s,c]=(0,U.useState)(()=>new Set);return(0,W.jsxs)(`div`,{className:G(`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,W.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-pressed":i,className:G(`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,W.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,W.jsx)(`span`,{className:`w-full truncate text-xs leading-tight`,children:e.name})]},e.id)}),e.length===0&&a&&(0,W.jsx)(`div`,{className:`col-span-full py-6 text-center text-sm text-muted-foreground`,children:a})]})},BNt=`#ff00bd`,VNt=`#98036a`,HNt=`#fff0fc`,UNt=`#9ca3af`,WNt=`#6b7280`,GNt=`#f7f9fb`,L4=152,R4=60,KNt={client:Hf,gateway:Hp,origin:qte},qNt=`!h-0 !min-h-0 !w-0 !min-w-0 !border-0 !bg-transparent`,JNt={box:({data:e})=>{let{label:t,kind:n,emphasis:r}=e,i=KNt[n];return(0,W.jsxs)(`div`,{className:G(`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:L4,height:R4},children:[(0,W.jsx)(k4,{type:`target`,position:C2.Left,isConnectable:!1,className:qNt}),(0,W.jsx)(i,{"aria-hidden":`true`,strokeWidth:1.75,className:G(`size-[18px] shrink-0`,r?`text-zuplo-600`:`text-muted-foreground`)}),(0,W.jsx)(`span`,{className:`text-xs font-medium leading-tight text-muted-foreground`,children:t}),(0,W.jsx)(k4,{type:`source`,position:C2.Right,isConnectable:!1,className:qNt})]})}},z4=[{id:`client`,type:`box`,position:{x:0,y:0},width:L4,height:R4,initialWidth:L4,initialHeight:R4,data:{label:`MCP Client`,kind:`client`,emphasis:!1},draggable:!1,selectable:!1},{id:`gateway`,type:`box`,position:{x:270,y:0},width:L4,height:R4,initialWidth:L4,initialHeight:R4,data:{label:`Zuplo MCP Gateway`,kind:`gateway`,emphasis:!0},draggable:!1,selectable:!1},{id:`origin`,type:`box`,position:{x:540,y:0},width:L4,height:R4,initialWidth:L4,initialHeight:R4,data:{label:`Origin MCP Server`,kind:`origin`,emphasis:!1},draggable:!1,selectable:!1}],YNt=e=>{let t=(e,t,n,r,i)=>({id:e,source:t,target:n,type:`smoothstep`,label:r,animated:!1,style:{stroke:i?BNt:UNt,strokeWidth:i?2:1.5},labelStyle:{fill:i?VNt:WNt,fontWeight:i?600:500,fontSize:11},labelBgStyle:{fill:i?HNt:GNt,fillOpacity:.95},labelBgPadding:[6,3],labelBgBorderRadius:4,markerEnd:{type:S2.ArrowClosed,width:14,height:14,color:i?BNt:UNt}});return[t(`inbound`,`client`,`gateway`,`Inbound auth`,e===`inbound`),t(`outbound`,`gateway`,`origin`,`Outbound auth`,e===`outbound`)]},B4={minX:Math.min(...z4.map(e=>e.position.x)),minY:Math.min(...z4.map(e=>e.position.y)),maxX:Math.max(...z4.map(e=>e.position.x+(e.width??L4))),maxY:Math.max(...z4.map(e=>e.position.y+(e.height??R4)))},XNt=B4.maxX-B4.minX,ZNt=B4.maxY-B4.minY,QNt=.5,$Nt=1.2,ePt=.12;function tPt(e,t){let n=Math.min(e/XNt,t/ZNt),r=Math.min($Nt,Math.max(QNt,n*(1-ePt*2)));return{x:(e-XNt*r)/2-B4.minX*r,y:(t-ZNt*r)/2-B4.minY*r,zoom:r}}var nPt=({active:e})=>{let t=(0,U.useMemo)(()=>YNt(e),[e]),n=(0,U.useRef)(null),r=(0,U.useRef)(null),i=(0,U.useCallback)(()=>{let e=n.current,t=e?.clientWidth??0,i=e?.clientHeight??0;t>0&&i>0&&r.current?.setViewport(tPt(t,i))},[]),a=(0,U.useCallback)(e=>{r.current=e,i()},[i]);return(0,U.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,W.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,W.jsx)(uNt,{nodes:z4,edges:t,nodeTypes:JNt,onInit:a,minZoom:QNt,maxZoom:$Nt,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:GNt},children:(0,W.jsx)(gNt,{variant:M4.Dots,gap:16,size:1,color:`#dbe1e8`})})})};function V4(e){return e&&e.length>0?e:void 0}function H4(e){return e&&Object.keys(e).length>0?e:void 0}function rPt(e){let t=new Set;for(let n of e??[]){let e=n.trim();e&&t.add(e)}return[...t]}function U4(e,t){if(t!==`rolesAndGroups`)return{};if(e.public===!0)return{public:!0};let n=rPt(e.roles),r=rPt(e.groups);return{...n.length>0?{roles:n}:{},...r.length>0?{groups:r}:{}}}function iPt(e){let t=e&&typeof e==`object`?e:{};return{accessControlMode:t.accessControl?.mode===`rolesAndGroups`?`rolesAndGroups`:`allPublic`,catalog:{tools:W4(t.tools,`name`,e=>({name:e})),prompts:W4(t.prompts,`name`,e=>({name:e})),resources:W4(t.resources,`uri`,e=>({uri:e,name:e})),resourceTemplates:W4(t.resourceTemplates,`uriTemplate`,e=>({uriTemplate:e,name:e}))}}}function W4(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 G4(e){return aPt(e.catalog,e.accessControlMode)}function aPt(e,t=`allPublic`){return{...t===`rolesAndGroups`?{accessControl:{mode:t}}:{},tools:e.tools.flatMap(e=>{let n=V4(e.name);if(!n)return[];let r=V4(e.description),i=H4(e.annotations),a=H4(e._meta);return[{name:n,...r?{description:r}:{},...i?{annotations:i}:{},...a?{_meta:a}:{},...U4(e,t)}]}),prompts:e.prompts.flatMap(e=>{let n=V4(e.name);if(!n)return[];let r=V4(e.description),i=H4(e._meta);return[{name:n,...r?{description:r}:{},...i?{_meta:i}:{},...U4(e,t)}]}),resources:e.resources.flatMap(e=>{let n=V4(e.uri);if(!n)return[];let r=V4(e.name),i=V4(e.description),a=V4(e.mimeType),o=H4(e._meta);return[{uri:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...U4(e,t)}]}),resourceTemplates:e.resourceTemplates.flatMap(e=>{let n=V4(e.uriTemplate);if(!n)return[];let r=V4(e.name),i=V4(e.description),a=V4(e.mimeType),o=H4(e._meta);return[{uriTemplate:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...U4(e,t)}]})}}var K4=e=>`/mcp-idp-icons/${e}.svg`,q4=[{id:`auth0`,label:`Auth0`,description:`Auth0 by Okta`,iconUrl:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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 J4(e){return q4.find(t=>t.id===e)}function oPt(e){return Object.fromEntries(e.fields.map(e=>[e.key,e.defaultValue]))}var sPt=`Most Used`,cPt=`Other`,lPt=[`rate-limit`,`api-key`],uPt=[{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`,`ai-gateway-fallback-model`,`ai-gateway-metering`,`ai-gateway-semantic-cache`,`ai-gateway-dlp`,`ai-gateway-smart-router`,`ai-gateway-akamai-firewall`,`ai-gateway-opik-tracing`,`ai-gateway-galileo-tracing`]},{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`]}],dPt=/-(inbound|outbound|internal)$/,Y4=e=>e.replace(dPt,``),X4=new Map;for(let e of uPt)for(let t of e.baseIds)X4.has(t)||X4.set(t,e.name);var fPt=e=>X4.get(Y4(e.id))??`Other`,pPt=e=>X4.get(Y4(e))===`Authentication`,mPt=e=>lPt.includes(Y4(e.id)),hPt=e=>{let t=new Map,n=[];for(let r of e){mPt(r)&&n.push(r);let e=fPt(r),i=t.get(e);i?i.push(r):t.set(e,[r])}let r=[];n.length>0&&r.push({name:sPt,policies:n});for(let{name:e}of uPt){let n=t.get(e);n&&n.length>0&&r.push({name:e,policies:n})}let i=t.get(cPt);return i&&i.length>0&&r.push({name:cPt,policies:i}),r},gPt=[...q4.map(e=>e.policyType)];function _Pt(e){return gPt.includes(e)||pPt(e)}var Z4=`mcp-token-exchange-inbound`,Q4=`mcp-capability-filter-inbound`,vPt=`set-upstream-api-key-inbound`,yPt=`remove-headers-inbound`;function $4(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 bPt=e=>e.toLowerCase().replaceAll(` `,`-`),e3=({name:e,onChangeName:t,disabled:n,policies:r})=>{let[i,a]=(0,U.useState)(null);return(0,W.jsxs)(`div`,{className:`grid grid-cols-12 text-sm gap-2 items-center pt-1`,children:[(0,W.jsx)(`label`,{className:`col-span-1`,children:`Name`}),(0,W.jsx)(`div`,{className:`col-span-11`,children:(0,W.jsx)(nE,{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=bPt(n.toLowerCase());a(OSt(i,r)),t(i)},"aria-describedby":`email-description`})}),i&&(0,W.jsx)(`div`,{className:`col-span-11 col-start-2 mt-1 text-red-600`,children:i})]})},xPt=({documentationSrc:e,className:t})=>(0,W.jsx)(`div`,{className:G(`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}}),SPt=({documentationSrc:e})=>(0,W.jsxs)(`div`,{className:`px-4 py-2 border-t h-full overflow-y-auto h-[stretch]`,children:[(0,W.jsx)(`h3`,{className:`text-lg font-medium text-foreground`,children:`Documentation`}),(0,W.jsx)(xPt,{documentationSrc:e})]}),CPt={[Q4]:(0,U.lazy)(()=>Cn(()=>import(`./McpCapabilityFilterDesigner-Y6K_fhN4.js`),__vite__mapDeps([7,1,8,2])))};function wPt(e){return e?CPt[e]:void 0}var TPt={type:`object`,properties:{handler:{type:`object`,properties:{options:{type:`object`,title:`Ensure Gateway Internal Invocation Only`,"x-no-options":!0,description:`Accepts only requests this gateway made itself with context.invokeRoute, and answers anything that arrived over the network with 403 Forbidden.
|
|
486
|
+
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}INt.displayName=`MiniMap`,(0,U.memo)(INt);var LNt=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,RNt={[u4.Line]:`right`,[u4.Handle]:`bottom-right`};function zNt({nodeId:e,position:t,variant:n=u4.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=jjt(),y=typeof e==`string`?e:v,b=_4(),x=(0,U.useRef)(null),S=n===u4.Handle,C=g4((0,U.useCallback)(LNt(S&&p),[S,p]),m4),w=(0,U.useRef)(null),T=t??RNt[n];return(0,U.useEffect)(()=>{if(!(!x.current||!y))return w.current||=gAt({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=r4([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...XOt({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,W.jsx)(`div`,{className:u0([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,U.memo)(zNt);function F4({value:e,onValueChange:t,options:n,columns:r=2,layout:i=`cards`,idPrefix:a=`wizard-choice`,ariaLabel:o,className:s}){return(0,W.jsx)(fwt,{value:e,onValueChange:e=>t(e),"aria-label":o,className:G(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=G(`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,W.jsxs)(rE,{htmlFor:n,className:G(`flex items-center gap-3 px-3 py-2.5`,o),children:[(0,W.jsx)(l0,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,W.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,W.jsx)(`div`,{className:`text-sm font-medium sm:w-56 sm:shrink-0`,children:t.title}),t.description&&(0,W.jsx)(`div`,{className:`min-w-0 flex-1 text-xs leading-snug text-muted-foreground`,children:t.description})]})]},t.value):(0,W.jsxs)(rE,{htmlFor:n,className:G(`flex flex-col gap-1.5 p-3`,o),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(l0,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,W.jsx)(`div`,{className:`text-sm font-medium`,children:t.title})]}),t.description&&(0,W.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t.description})]},t.value)})})}var I4=({tiles:e,selectedId:t,onSelect:n,fallbackIcon:r,columns:i=4,emptyState:a,className:o})=>{let[s,c]=(0,U.useState)(()=>new Set);return(0,W.jsxs)(`div`,{className:G(`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,W.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-pressed":i,className:G(`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,W.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,W.jsx)(`span`,{className:`w-full truncate text-xs leading-tight`,children:e.name})]},e.id)}),e.length===0&&a&&(0,W.jsx)(`div`,{className:`col-span-full py-6 text-center text-sm text-muted-foreground`,children:a})]})},BNt=`#ff00bd`,VNt=`#98036a`,HNt=`#fff0fc`,UNt=`#9ca3af`,WNt=`#6b7280`,GNt=`#f7f9fb`,L4=152,R4=60,KNt={client:Hf,gateway:Hp,origin:qte},qNt=`!h-0 !min-h-0 !w-0 !min-w-0 !border-0 !bg-transparent`,JNt={box:({data:e})=>{let{label:t,kind:n,emphasis:r}=e,i=KNt[n];return(0,W.jsxs)(`div`,{className:G(`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:L4,height:R4},children:[(0,W.jsx)(k4,{type:`target`,position:C2.Left,isConnectable:!1,className:qNt}),(0,W.jsx)(i,{"aria-hidden":`true`,strokeWidth:1.75,className:G(`size-[18px] shrink-0`,r?`text-zuplo-600`:`text-muted-foreground`)}),(0,W.jsx)(`span`,{className:`text-xs font-medium leading-tight text-muted-foreground`,children:t}),(0,W.jsx)(k4,{type:`source`,position:C2.Right,isConnectable:!1,className:qNt})]})}},z4=[{id:`client`,type:`box`,position:{x:0,y:0},width:L4,height:R4,initialWidth:L4,initialHeight:R4,data:{label:`MCP Client`,kind:`client`,emphasis:!1},draggable:!1,selectable:!1},{id:`gateway`,type:`box`,position:{x:270,y:0},width:L4,height:R4,initialWidth:L4,initialHeight:R4,data:{label:`Zuplo MCP Gateway`,kind:`gateway`,emphasis:!0},draggable:!1,selectable:!1},{id:`origin`,type:`box`,position:{x:540,y:0},width:L4,height:R4,initialWidth:L4,initialHeight:R4,data:{label:`Origin MCP Server`,kind:`origin`,emphasis:!1},draggable:!1,selectable:!1}],YNt=e=>{let t=(e,t,n,r,i)=>({id:e,source:t,target:n,type:`smoothstep`,label:r,animated:!1,style:{stroke:i?BNt:UNt,strokeWidth:i?2:1.5},labelStyle:{fill:i?VNt:WNt,fontWeight:i?600:500,fontSize:11},labelBgStyle:{fill:i?HNt:GNt,fillOpacity:.95},labelBgPadding:[6,3],labelBgBorderRadius:4,markerEnd:{type:S2.ArrowClosed,width:14,height:14,color:i?BNt:UNt}});return[t(`inbound`,`client`,`gateway`,`Inbound auth`,e===`inbound`),t(`outbound`,`gateway`,`origin`,`Outbound auth`,e===`outbound`)]},B4={minX:Math.min(...z4.map(e=>e.position.x)),minY:Math.min(...z4.map(e=>e.position.y)),maxX:Math.max(...z4.map(e=>e.position.x+(e.width??L4))),maxY:Math.max(...z4.map(e=>e.position.y+(e.height??R4)))},XNt=B4.maxX-B4.minX,ZNt=B4.maxY-B4.minY,QNt=.5,$Nt=1.2,ePt=.12;function tPt(e,t){let n=Math.min(e/XNt,t/ZNt),r=Math.min($Nt,Math.max(QNt,n*(1-ePt*2)));return{x:(e-XNt*r)/2-B4.minX*r,y:(t-ZNt*r)/2-B4.minY*r,zoom:r}}var nPt=({active:e})=>{let t=(0,U.useMemo)(()=>YNt(e),[e]),n=(0,U.useRef)(null),r=(0,U.useRef)(null),i=(0,U.useCallback)(()=>{let e=n.current,t=e?.clientWidth??0,i=e?.clientHeight??0;t>0&&i>0&&r.current?.setViewport(tPt(t,i))},[]),a=(0,U.useCallback)(e=>{r.current=e,i()},[i]);return(0,U.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,W.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,W.jsx)(uNt,{nodes:z4,edges:t,nodeTypes:JNt,onInit:a,minZoom:QNt,maxZoom:$Nt,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:GNt},children:(0,W.jsx)(gNt,{variant:M4.Dots,gap:16,size:1,color:`#dbe1e8`})})})};function V4(e){return e&&e.length>0?e:void 0}function H4(e){return e&&Object.keys(e).length>0?e:void 0}function rPt(e){let t=new Set;for(let n of e??[]){let e=n.trim();e&&t.add(e)}return[...t]}function U4(e,t){if(t!==`rolesAndGroups`)return{};if(e.public===!0)return{public:!0};let n=rPt(e.roles),r=rPt(e.groups);return{...n.length>0?{roles:n}:{},...r.length>0?{groups:r}:{}}}function iPt(e){let t=e&&typeof e==`object`?e:{};return{accessControlMode:t.accessControl?.mode===`rolesAndGroups`?`rolesAndGroups`:`allPublic`,catalog:{tools:W4(t.tools,`name`,e=>({name:e})),prompts:W4(t.prompts,`name`,e=>({name:e})),resources:W4(t.resources,`uri`,e=>({uri:e,name:e})),resourceTemplates:W4(t.resourceTemplates,`uriTemplate`,e=>({uriTemplate:e,name:e}))}}}function W4(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 G4(e){return aPt(e.catalog,e.accessControlMode)}function aPt(e,t=`allPublic`){return{...t===`rolesAndGroups`?{accessControl:{mode:t}}:{},tools:e.tools.flatMap(e=>{let n=V4(e.name);if(!n)return[];let r=V4(e.description),i=H4(e.annotations),a=H4(e._meta);return[{name:n,...r?{description:r}:{},...i?{annotations:i}:{},...a?{_meta:a}:{},...U4(e,t)}]}),prompts:e.prompts.flatMap(e=>{let n=V4(e.name);if(!n)return[];let r=V4(e.description),i=H4(e._meta);return[{name:n,...r?{description:r}:{},...i?{_meta:i}:{},...U4(e,t)}]}),resources:e.resources.flatMap(e=>{let n=V4(e.uri);if(!n)return[];let r=V4(e.name),i=V4(e.description),a=V4(e.mimeType),o=H4(e._meta);return[{uri:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...U4(e,t)}]}),resourceTemplates:e.resourceTemplates.flatMap(e=>{let n=V4(e.uriTemplate);if(!n)return[];let r=V4(e.name),i=V4(e.description),a=V4(e.mimeType),o=H4(e._meta);return[{uriTemplate:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...U4(e,t)}]})}}var K4=e=>`/mcp-idp-icons/${e}.svg`,q4=[{id:`auth0`,label:`Auth0`,description:`Auth0 by Okta`,iconUrl:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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:K4(`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 J4(e){return q4.find(t=>t.id===e)}function oPt(e){return Object.fromEntries(e.fields.map(e=>[e.key,e.defaultValue]))}var sPt=`Most Used`,cPt=`Other`,lPt=[`rate-limit`,`api-key`],uPt=[{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`,`ai-gateway-fallback-model`,`ai-gateway-metering`,`ai-gateway-semantic-cache`,`ai-gateway-dlp`,`ai-gateway-smart-router`,`ai-gateway-akamai-firewall`,`ai-gateway-opik-tracing`,`ai-gateway-galileo-tracing`]},{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`]}],dPt=/-(inbound|outbound|internal)$/,Y4=e=>e.replace(dPt,``),X4=new Map;for(let e of uPt)for(let t of e.baseIds)X4.has(t)||X4.set(t,e.name);var fPt=e=>X4.get(Y4(e.id))??`Other`,pPt=e=>X4.get(Y4(e))===`Authentication`,mPt=e=>lPt.includes(Y4(e.id)),hPt=e=>{let t=new Map,n=[];for(let r of e){mPt(r)&&n.push(r);let e=fPt(r),i=t.get(e);i?i.push(r):t.set(e,[r])}let r=[];n.length>0&&r.push({name:sPt,policies:n});for(let{name:e}of uPt){let n=t.get(e);n&&n.length>0&&r.push({name:e,policies:n})}let i=t.get(cPt);return i&&i.length>0&&r.push({name:cPt,policies:i}),r},gPt=[...q4.map(e=>e.policyType)];function _Pt(e){return gPt.includes(e)||pPt(e)}var Z4=`mcp-token-exchange-inbound`,Q4=`mcp-capability-filter-inbound`,vPt=`set-upstream-api-key-inbound`,yPt=`remove-headers-inbound`;function $4(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 bPt=e=>e.toLowerCase().replaceAll(` `,`-`),e3=({name:e,onChangeName:t,disabled:n,policies:r})=>{let[i,a]=(0,U.useState)(null);return(0,W.jsxs)(`div`,{className:`grid grid-cols-12 text-sm gap-2 items-center pt-1`,children:[(0,W.jsx)(`label`,{className:`col-span-1`,children:`Name`}),(0,W.jsx)(`div`,{className:`col-span-11`,children:(0,W.jsx)(nE,{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=bPt(n.toLowerCase());a(OSt(i,r)),t(i)},"aria-describedby":`email-description`})}),i&&(0,W.jsx)(`div`,{className:`col-span-11 col-start-2 mt-1 text-red-600`,children:i})]})},xPt=({documentationSrc:e,className:t})=>(0,W.jsx)(`div`,{className:G(`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}}),SPt=({documentationSrc:e})=>(0,W.jsxs)(`div`,{className:`px-4 py-2 border-t h-full overflow-y-auto h-[stretch]`,children:[(0,W.jsx)(`h3`,{className:`text-lg font-medium text-foreground`,children:`Documentation`}),(0,W.jsx)(xPt,{documentationSrc:e})]}),CPt={[Q4]:(0,U.lazy)(()=>Cn(()=>import(`./McpCapabilityFilterDesigner-D6thjIZK.js`),__vite__mapDeps([7,1,8,2])))};function wPt(e){return e?CPt[e]:void 0}var TPt={type:`object`,properties:{handler:{type:`object`,properties:{options:{type:`object`,title:`Ensure Gateway Internal Invocation Only`,"x-no-options":!0,description:`Accepts only requests this gateway made itself with context.invokeRoute, and answers anything that arrived over the network with 403 Forbidden.
|
|
487
487
|
|
|
488
488
|
Put it on an app that nothing outside the gateway calls — the classifier app behind Smart Router or Prompt Injection Protection, say — in place of API Key Authentication. Those calls never leave the gateway, so a key on them protects nothing; this checks the one thing that does, that the request started inside the deployment.`,additionalProperties:!1,properties:{}}}}}},EPt={"ai-gateway-internal-only-inbound":TPt},DPt=e=>e?EPt[e]:void 0;function OPt(e){return e[`x-no-options`]===!0&&!!e.description}function kPt(e){let t=e?.properties?.handler?.properties?.options;if(!(!t||t.type!==`object`)&&(OPt(t)||!(!t.properties||Object.keys(t.properties).length===0)))return t}function APt(e){let t=NPt(e);if(t){let e=t.every(n3),n=t.some(n3);return e?`string-array`:n?`multiline-text`:`text`}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 t3(e,t){return e.required?.includes(t)??!1}function jPt(e){return e[`x-advanced`]===!0||e[`x-show-example`]===!1}function MPt(e){return e.deprecated===!0||/^\s*deprecated\b/i.test(e.description??``)}function NPt(e){if(e.allOf||e.const||e.enum)return;let t=e.oneOf??e.anyOf;if(!(!t||t.length===0)&&t.every(e=>PPt(e)||n3(e)))return t}function PPt(e){return e.type===`string`&&!e.enum&&!e.const&&!e.oneOf&&!e.anyOf&&!e.allOf}function n3(e){let t=e.items;return e.type===`array`&&!!t&&!Array.isArray(t)&&PPt(t)&&!e.oneOf&&!e.anyOf&&!e.allOf}var FPt=()=>{let e=(0,U.useContext)(tm);return!!(e?.account&&e?.project)},IPt=({children:e,onInject:t,isEnabled:n=!0})=>{let r=FPt();return!n||!r?(0,W.jsx)(`div`,{className:`relative w-full`,children:e}):(0,W.jsx)(LPt,{onInject:t,children:e})},LPt=({children:e,onInject:t})=>{let n=nm([`account`,`project`]),r=KP(n.account.name,n.project.name);return(0,W.jsxs)(tT,{children:[(0,W.jsxs)(`div`,{className:`relative w-full`,children:[e,(0,W.jsx)(nT,{asChild:!0,children:(0,W.jsx)(Y,{variant:`ghost`,size:`icon-sm`,className:`flex-none ml-1 absolute top-1 right-1 bg-card`,title:`Select environment variable`,children:(0,W.jsx)(wte,{className:`w-4`})})})]}),(0,W.jsxs)(iT,{children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:`Environment Variables`}),(0,W.jsx)(cT,{asChild:!0,children:(0,W.jsxs)(lk,{className:`mt-4 divide-y divide-double bg-gray-50 dark:bg-neutral-900 max-h-96 overflow-y-auto`,children:[r.isPending?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(wD,{className:`h-6 w-2/3 m-1`}),(0,W.jsx)(wD,{className:`h-6 w-2/3 m-1`}),(0,W.jsx)(wD,{className:`h-6 w-2/3 m-1`})]}):r.data?.length===0&&(0,W.jsx)(`div`,{className:`p-2`,children:`No environment variables`}),r.data?.map(e=>(0,W.jsxs)(`div`,{className:`p-2 py-3 flex justify-between items-center`,children:[(0,W.jsx)(`div`,{children:e.name}),(0,W.jsx)(rT,{asChild:!0,children:(0,W.jsx)(Y,{variant:`outline`,size:`xs`,className:`flex-none`,onClick:()=>t(e,`$env(${e.name})`),children:`Use`})})]},e.id))]})})]}),(0,W.jsx)(oT,{children:(0,W.jsx)(rT,{children:(0,W.jsx)(Y,{type:`submit`,variant:`outline`,children:`Close`})})})]})]})},r3=(0,U.createContext)(!0),i3=(0,U.createContext)([]),a3=({schema:e,value:t,onChange:n,disabled:r,allowEnvVariables:i,fieldControls:a})=>{let o=(0,U.useContext)(r3),s=i??o,c=(0,U.useContext)(i3),l=a??c,u=(e,r)=>{if(r===void 0){let{[e]:r,...i}=t;n(i)}else n({...t,[e]:r})},d=(n,i)=>(0,W.jsx)(zPt,{name:n,schema:i,parentSchema:e,required:t3(e,n),value:t[n],onChange:e=>u(n,e),disabled:r},n),f=Object.entries(e.properties??{}),p=f.filter(([,e])=>!MPt(e)),m=(t,n)=>jPt(n)&&!t3(e,t),h=p.filter(([e,t])=>m(e,t)),g=p.filter(([e,t])=>!m(e,t)),_=[...g.filter(([t])=>t3(e,t)),...g.filter(([t])=>!t3(e,t))];return(0,W.jsx)(r3.Provider,{value:s,children:(0,W.jsx)(i3.Provider,{value:l,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f.length===0&&(0,W.jsxs)(`div`,{className:`rounded-md border bg-surface-muted px-4 py-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium`,children:`This policy has no options`}),e.description&&(0,W.jsx)(`p`,{className:`mt-1 whitespace-pre-line text-sm text-muted-foreground`,children:e.description})]}),_.map(([e,t])=>d(e,t)),h.length>0&&(0,W.jsx)(RPt,{defaultOpen:h.some(([e])=>t[e]!==void 0),children:h.map(([e,t])=>d(e,t))})]})})})},RPt=({defaultOpen:e,children:t})=>{let[n,r]=(0,U.useState)(e);return(0,W.jsxs)(QT,{open:n,onOpenChange:r,children:[(0,W.jsxs)($T,{className:`flex items-center gap-1 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground`,children:[(0,W.jsx)(Qf,{className:G(`size-4 transition-transform`,n&&`rotate-90`)}),n?`Hide advanced options`:`Show advanced options`]}),(0,W.jsx)(eE,{className:`flex flex-col gap-5 pt-5`,children:t})]})},zPt=({name:e,schema:t,parentSchema:n,required:r,value:i,onChange:a,disabled:o})=>{let s=(0,U.useId)(),c=APt(t),l=t.description?`${s}-description`:void 0,u=(0,U.useContext)(i3).find(r=>r.matches(e,t,n)),d=u?.annotate?`${s}-annotation`:void 0,f=[l,d].filter(Boolean).join(` `)||void 0,p={id:s,name:e,schema:t,required:r,value:i,onChange:a,disabled:o,descriptionId:f},m=(0,W.jsx)(BPt,{htmlFor:s,name:e,schema:t,required:r,descriptionId:l}),h=u?.annotate?(0,W.jsx)(`div`,{id:d,className:`flex flex-col gap-1`,children:u.annotate(p)}):null;if(u?.render)return(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m,u.render(p),h]});if(c===`boolean`){let e=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[m,(0,W.jsx)(B1,{id:s,"aria-describedby":f,checked:typeof i==`boolean`?i:t.default===!0,onCheckedChange:e=>a(e),disabled:o})]});return h?(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,h]}):e}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m,(0,W.jsx)(VPt,{id:s,name:e,descriptionId:f,kind:c,schema:t,required:r,value:i,onChange:a,disabled:o}),h]})},BPt=({htmlFor:e,name:t,schema:n,required:r,descriptionId:i})=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,W.jsxs)(rE,{htmlFor:e,className:`capitalize`,children:[t,r?(0,W.jsx)(`span`,{className:`text-destructive`,children:` *`}):(0,W.jsx)(`span`,{className:`ml-1 font-normal normal-case text-muted-foreground`,children:`(optional)`})]}),n.description&&(0,W.jsx)(`span`,{id:i,className:`text-xs text-muted-foreground`,children:n.description})]}),VPt=({id:e,name:t,descriptionId:n,kind:r,schema:i,required:a,value:o,onChange:s,disabled:c})=>{switch(r){case`text`:return(0,W.jsx)(UPt,{id:e,name:t,descriptionId:n,schema:i,required:a,value:o,onChange:s,disabled:c});case`multiline-text`:return(0,W.jsx)(WPt,{id:e,descriptionId:n,value:o,onChange:s,disabled:c});case`number`:return(0,W.jsx)(nE,{id:e,type:`number`,"aria-describedby":n,step:i.type===`integer`?1:void 0,value:typeof o==`number`?o:``,placeholder:typeof i.default==`number`?String(i.default):void 0,onChange:e=>{let t=e.target.value===``?NaN:Number(e.target.value);s(Number.isNaN(t)?void 0:t)},disabled:c});case`select`:return(0,W.jsxs)(gY,{value:typeof o==`string`?o:cit,onValueChange:e=>s(e===`__UNSET`?void 0:e),disabled:c,children:[(0,W.jsx)(vY,{id:e,"aria-describedby":n,className:`w-full`,children:(0,W.jsx)(_Y,{placeholder:`Select an option`})}),(0,W.jsxs)(yY,{children:[!a&&(0,W.jsx)(bY,{value:`__UNSET`,children:(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Not set`})}),(i.enum??[]).filter(e=>typeof e==`string`).map(e=>(0,W.jsx)(bY,{value:e,children:e},e))]})]});case`string-array`:return(0,W.jsx)(GPt,{value:o,onChange:s,disabled:c});case`object-array`:return(0,W.jsx)(KPt,{schema:i,value:o,onChange:s,disabled:c});case`record`:return(0,W.jsx)(qPt,{schema:i,value:o,onChange:s,disabled:c});case`object`:return(0,W.jsx)(`div`,{className:`border rounded-md p-3 ml-1`,children:(0,W.jsx)(a3,{schema:i,value:s3(o)?o:{},onChange:e=>s(Object.keys(e).length===0?void 0:e),disabled:c})});case`json`:return(0,W.jsx)(JPt,{id:e,value:o,onChange:s,disabled:c})}};function HPt(e,t){if(!t&&!(typeof e.default!=`string`||e.default===``)&&!(typeof e.minLength==`number`&&e.minLength>=1)&&!e.pattern)return e.default}var UPt=({id:e,name:t,descriptionId:n,schema:r,required:i,value:a,onChange:o,disabled:s})=>{let c=(0,U.useId)(),l=typeof r.default==`string`?r.default:void 0,u=HPt(r,i),d=u!==void 0,f=d&&a===``,p=d&&a===void 0,m=typeof a==`string`?a:``,h=[n,d?c:void 0].filter(Boolean).join(` `)||void 0;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(o3,{id:e,value:m,placeholder:a===``?void 0:l,describedById:h,onValueChange:e=>o(e===``?void 0:e),disabled:s}),d&&(0,W.jsx)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 text-xs text-muted-foreground`,children:f?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{id:c,children:[`Empty value set. The default (`,u,`) is not applied.`]}),!s&&(0,W.jsx)(Y,{variant:`link`,size:`xs`,className:`h-auto p-0 text-xs`,"aria-label":`Use the default for ${t}`,onClick:()=>o(void 0),children:`Use the default`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{id:c,children:[`Leave blank to use the default (`,u,`).`]}),p&&!s&&(0,W.jsx)(Y,{variant:`link`,size:`xs`,className:`h-auto p-0 text-xs`,"aria-label":`Use an empty value for ${t}`,onClick:()=>o(``),children:`Use an empty value`})]})})]})},WPt=({id:e,descriptionId:t,value:n,onChange:r,disabled:i})=>{let a=YPt(n);return(0,W.jsx)(Lw,{id:e,"aria-describedby":t,value:a,rows:6,onChange:e=>{let t=e.target.value;r(t===``?void 0:t)},disabled:i})},o3=({id:e,value:t,placeholder:n,onValueChange:r,disabled:i,describedById:a})=>{let o=(0,U.useContext)(r3),s=FPt(),c=o&&s&&!i;return(0,W.jsx)(IPt,{isEnabled:c,onInject:(e,t)=>r(t),children:(0,W.jsx)(nE,{id:e,value:t,placeholder:n,"aria-describedby":a,onChange:e=>r(e.target.value),disabled:i,className:G(c&&`pr-10`)})})},GPt=({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,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(o3,{value:e,onValueChange:e=>{let n=[...r];n[t]=e,i(n)},disabled:n}),(0,W.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":`Remove item`,onClick:()=>i(r.filter((e,n)=>n!==t)),disabled:n,children:(0,W.jsx)(Up,{className:`size-4`})})]},t)),(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>i([...r,``]),disabled:n,children:[(0,W.jsx)(Op,{className:`size-4`}),`Add item`]})]})},KPt=({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,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a.map((e,t)=>(0,W.jsxs)(`div`,{className:`relative border rounded-md p-3 pr-10`,children:[(0,W.jsx)(a3,{schema:i,value:s3(e)?e:{},onChange:e=>{let n=[...a];n[t]=e,o(n)},disabled:r}),(0,W.jsx)(Y,{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,W.jsx)(Up,{className:`size-4`})})]},t)),(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>o([...a,{}]),disabled:r,children:[(0,W.jsx)(Op,{className:`size-4`}),`Add item`]})]}):null},qPt=({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,U.useState)(()=>s3(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,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(nE,{value:e.key,placeholder:`Key`,onChange:n=>{let r=[...o];r[t]={...e,key:n.target.value},c(r)},disabled:r}),a?(0,W.jsx)(nE,{value:e.value,placeholder:`Value`,type:`number`,onChange:n=>{let r=[...o];r[t]={...e,value:n.target.value},c(r)},disabled:r}):(0,W.jsx)(o3,{value:e.value,placeholder:`Value`,onValueChange:n=>{let r=[...o];r[t]={...e,value:n},c(r)},disabled:r}),(0,W.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":`Remove entry`,onClick:()=>c(o.filter((e,n)=>n!==t)),disabled:r,children:(0,W.jsx)(Up,{className:`size-4`})})]},t)),(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>c([...o,{key:``,value:``}]),disabled:r,children:[(0,W.jsx)(Op,{className:`size-4`}),`Add entry`]})]})},JPt=({id:e,value:t,onChange:n,disabled:r})=>{let[i,a]=(0,U.useState)(()=>t===void 0?``:JSON.stringify(t,void 0,2)),[o,s]=(0,U.useState)(!1);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(Lw,{id:e,className:G(`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,W.jsx)(`span`,{className:`text-xs text-destructive`,children:`Invalid JSON — the last valid value will be saved.`})]})};function s3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function YPt(e){return typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`
|
|
489
489
|
`):``}var XPt=({designConfig:e,policyType:t,defaultHandler:n,isReadOnly:r,hasError:i,codeTabLabel:a,documentationSrc:o,designerContext:s,ref:c})=>{let{logEvent:l}=H(),u=DPt(e?.id),d=dst(u?void 0:e?.optionsSchemaUrl),f=kPt(u??d.data),p=!!f,m=!!o,h=wPt(t),g=!!h,[_,v]=(0,U.useState)(n),[y,b]=(0,U.useState)(),[x,S]=(0,U.useState)(null),C=(0,U.useRef)(void 0),w=y??(g?`designer`:p?`form`:`code`),T=()=>{let e=C.current?.getValue();if(!e)throw Error(`The policy configuration is empty`);return JSON.parse(e)};(0,U.useImperativeHandle)(c,()=>({getHandler:()=>w===`code`?T():_}));let E=t=>{if(t!==w){if(w===`code`)try{v(T())}catch(e){S(`Fix the JSON before switching: ${e instanceof Error?e.message:`Unknown error`}`);return}t===`code`&&C.current?.setValue(JSON.stringify(_,void 0,2)),S(null),b(t),l(`policy-form-editor-mode-switched`,{policy:e?.id,mode:t})}};if(d.isLoading)return(0,W.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,W.jsx)(TP,{className:`w-5 h-5 border-2`})});let D=g||p;return(0,W.jsxs)(`div`,{className:`flex flex-col min-h-0 min-w-0 h-full`,children:[(0,W.jsx)(`div`,{className:`flex items-center gap-2 border-b p-2`,children:(0,W.jsx)(PD,{variant:`outline`,type:`single`,value:w,onValueChange:e=>{e&&E(e)},children:[...g?[{value:`designer`,label:`Designer`}]:[],...p?[{value:`form`,label:`Form`}]:[],{value:`code`,label:D?`Code`:a},...m?[{value:`docs`,label:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(zf,{}),`Docs`]})}]:[]].map(({value:e,label:t})=>(0,W.jsx)(FD,{value:e,variant:`outline`,size:`xs`,className:`gap-1 px-2`,children:t},e))})}),x&&(0,W.jsx)(`p`,{className:`text-sm text-red-500 mx-3 mt-2`,children:x}),h&&(0,W.jsx)(`div`,{className:G(`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,w!==`designer`&&`hidden`),children:(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,W.jsx)(TP,{className:`w-5 h-5 border-2`})}),children:(0,W.jsx)(h,{options:_.options,onChange:e=>v({..._,options:e}),isReadOnly:r,operation:s?.operation,policyManager:s?.policyManager})})}),p&&w===`form`&&f&&(0,W.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,W.jsx)(a3,{schema:f,value:ZPt(_.options)?_.options:{},onChange:e=>v({..._,options:e}),disabled:r})}),(0,W.jsx)(`div`,{className:G(`flex-1 min-h-0 min-w-0`,w!==`code`&&`hidden`),children:(0,W.jsx)(MP,{options:{...pQ,readOnly:r,automaticLayout:!0},className:G({"border border-red-500":i}),width:`100%`,height:`100%`,language:`json`,onMount:e=>{C.current=e},defaultValue:JSON.stringify(_,void 0,2)})}),m&&w===`docs`&&o&&(0,W.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,W.jsx)(xPt,{documentationSrc:o})})]})};function ZPt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var c3=({designConfig:e,policyType:t,defaultHandler:n,initialName:r,policies:i,isReadOnly:a=!1,nameDisabled:o=!1,codeTabLabel:s=`Configuration`,designerContext:c,ref:l})=>{let[u,d]=(0,U.useState)(r),[f,p]=(0,U.useState)(null),m=(0,U.useRef)(null);return(0,U.useImperativeHandle)(l,()=>({getPolicyConfig:()=>{let e=OSt(u,i);if(e)throw p(e),Error(e);if(!m.current)throw Error(`The policy editor is not ready`);try{let e=m.current.getHandler();return p(null),{name:u,handler:e}}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw p(t),Error(t)}}})),(0,W.jsxs)(`div`,{className:`flex flex-col w-full h-full min-h-0`,children:[(0,W.jsx)(e3,{name:u,onChangeName:d,disabled:o,policies:i}),(0,W.jsx)(`div`,{className:`border rounded overflow-hidden mt-4 flex-1 min-h-0 min-w-0`,children:(0,W.jsx)(XPt,{ref:m,designConfig:e,policyType:t,defaultHandler:n,isReadOnly:a,hasError:!!f,codeTabLabel:s,documentationSrc:e?.exampleHtml,designerContext:c})}),f&&(0,W.jsx)(`p`,{className:`text-red-500 ml-2 mt-1`,children:f})]})},QPt=`Invalid Rewrite URL provided`,$Pt=`Tip: Use the API Test Console to test the behavior of request properties and environment variables.`,eFt=e=>`${e} is not a valid pattern`,tFt=e=>`Failed to parse component(s), rewrite result: ${e}`,nFt=e=>`${e} is not a valid URL`,l3=new Proxy({},{get(e,t){return typeof t==`symbol`?()=>`superProxy.toString()`:l3}}),rFt=e=>{if(e===``)return{errorType:`Error`,message:QPt};let t={url:new URL(`https://www.zuplo.com`),host:``,hostname:``,origin:``,port:``,protocol:``,headers:new Headers({}),params:{},pathname:``,method:``,query:{},search:``,env:l3,request:l3,e:encodeURIComponent,context:l3},n=(e,t={})=>Function(`vars`,[`const tagged = ( ${Object.keys(t).join(`, `)} ) =>`,`\`${e}\``,`return tagged(...Object.values(vars))`].join(`
|
|
@@ -1566,7 +1566,7 @@ In some cases, you need to provide options to alter GraphQL's execution behavior
|
|
|
1566
1566
|
`+t+`)`}function x8(e){let t=f8(e.defaultValue,e.type),n=e.name+`: `+String(e.type);return t&&(n+=` = ${On(t)}`),n+S8(e.deprecationReason)}function LHt(e){return C8(e)+`directive @`+e.name+IHt(e.args)+(e.isRepeatable?` repeatable`:``)+` on `+e.locations.join(` | `)}function S8(e){return e==null?``:e===`No longer supported`?` @deprecated`:` @deprecated(reason: ${On({kind:ar.STRING,value:e})})`}function RHt(e){return e.specifiedByURL==null?``:` @specifiedBy(url: ${On({kind:ar.STRING,value:e.specifiedByURL})})`}function C8(e,t=``,n=!0){let{description:r}=e;if(r==null)return``;let i=On({kind:ar.STRING,value:r,block:nee(r)});return(t&&!n?`
|
|
1567
1567
|
`+t:t)+i.replace(/\n/g,`
|
|
1568
1568
|
`+t)+`
|
|
1569
|
-
`}var w8=`/docs/schema.graphql`,zHt=()=>JSON.stringify({query:bHt()}),BHt=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`${SHt(xHt(t.data))}\n`}catch(e){throw Error(`Could not build a schema from the introspection result: ${e instanceof Error?e.message:String(e)}`)}},VHt=({endpointUrl:e,rewriteUrl:t,ape:n,onClose:r})=>{let{logEvent:i}=H(),a=em(),o=vX(),s=oF(),[c,l]=(0,U.useState)(t??e),[u,d]=(0,U.useState)([{key:``,value:``}]),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.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:zHt()},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=BHt(l.body);f=`save`,await o.mutateAsync({file:{path:w8,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 ${w8}`),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,W.jsx)(tT,{open:!0,onOpenChange:e=>!e&&!f&&r(),children:(0,W.jsxs)(iT,{className:`sm:max-w-2xl`,children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:`Download GraphQL schema`}),(0,W.jsxs)(cT,{children:[`Run an introspection query against this endpoint. On success the schema is stored in `,(0,W.jsx)(`code`,{children:w8}),`.`]})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(rE,{htmlFor:`graphql-introspection-endpoint`,children:`Endpoint`}),e&&e!==c&&(0,W.jsx)(Y,{variant:`link`,size:`xs`,type:`button`,className:`h-auto p-0`,disabled:f,onClick:()=>l(e),children:`Use gateway URL`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(nE,{id:`graphql-introspection-endpoint`,value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com/graphql`,disabled:f,"data-op-ignore":!0}),(0,W.jsx)(EP,{textToCopy:c})]})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(rE,{children:`Headers (optional)`}),(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(nE,{placeholder:`Header name`,value:e.key,onChange:e=>g(t,`key`,e.target.value),"data-op-ignore":!0}),(0,W.jsx)(nE,{placeholder:`Value`,value:e.value,onChange:e=>g(t,`value`,e.target.value),"data-op-ignore":!0}),(0,W.jsx)(Y,{variant:`ghost`,size:`icon`,type:`button`,"aria-label":`Remove header`,onClick:()=>v(t),children:(0,W.jsx)(Rp,{className:`size-4`})})]},t))}),(0,W.jsx)(`div`,{children:(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,type:`button`,onClick:_,children:[(0,W.jsx)(Op,{className:`size-4`}),(0,W.jsx)(`span`,{children:`Add header`})]})})]}),m&&(0,W.jsxs)(sb,{variant:`destructive`,children:[(0,W.jsx)(np,{}),(0,W.jsx)(cb,{children:`Introspection failed`}),(0,W.jsx)(lb,{className:`break-words`,children:m})]})]}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(rT,{asChild:!0,children:(0,W.jsx)(Y,{variant:`outline`,type:`button`,disabled:f,children:`Cancel`})}),(0,W.jsx)(Y,{variant:`brand`,type:`button`,onClick:y,disabled:f||c.trim().length===0,children:f?`Running…`:`Run introspection`})]})]})})},HHt=({path:e,rewriteUrl:t})=>{let n=nm(),r=lc(),{logEvent:i}=H(),[a,o]=(0,U.useState)(!1),s=sF(n.environment),c=s?new URL(e,s).toString():void 0;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(pq,{children:[(0,W.jsx)(mq,{asChild:!0,children:(0,W.jsxs)(Y,{variant:`outline`,children:[(0,W.jsx)(D1,{className:`size-4 shrink-0`}),(0,W.jsx)(`span`,{children:`Schema`}),(0,W.jsx)(Zf,{className:`size-4 shrink-0`})]})}),(0,W.jsxs)(hq,{align:`end`,children:[(0,W.jsxs)(_q,{onSelect:()=>{i(`graphql-schema-open`,{account:n.account.name,project:n.project.name,environment:n.environment.name}),r({pathname:fo(Cb.Code,{account:n.account.name,project:n.project.name,environment:encodeURIComponent(n.environment.urlParameter)}),search:`?path=${w8}`})},children:[(0,W.jsx)(gp,{className:`size-4`}),(0,W.jsx)(`span`,{children:`Open Schema`})]}),(0,W.jsxs)(_q,{disabled:!c,onSelect:()=>o(!0),children:[(0,W.jsx)(cp,{className:`size-4`}),(0,W.jsx)(`span`,{children:`Download Schema`})]})]})]}),a&&c&&(0,W.jsx)(VHt,{endpointUrl:c,rewriteUrl:t,ape:n,onClose:()=>o(!1)})]})},UHt=({operationTags:e,onTagsChanged:t})=>{let{isReadOnly:n}=YZ(),r=g1(),[i,a]=(0,U.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,W.jsxs)(IT,{children:[(0,W.jsx)(LT,{asChild:!0,children:(0,W.jsxs)(S6,{children:[(0,W.jsx)(Ip,{size:16}),e.length===1?(0,W.jsx)(`span`,{className:`truncate max-w-[12ch]`,title:e[0],children:e[0]}):`${e.length} Tags`]})}),(0,W.jsxs)(RT,{className:`w-64 p-0 z-100`,align:`end`,children:[(0,W.jsx)(`div`,{className:`px-3 pt-3 pb-2`,children:(0,W.jsx)(`h4`,{className:`text-sm font-medium`,children:`Operation Tags`})}),o.length>0&&(0,W.jsx)(`div`,{className:`border-t max-h-48 overflow-y-auto`,children:o.map(t=>(0,W.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,W.jsx)(`span`,{className:`truncate`,children:t}),(0,W.jsx)(Xf,{size:14,className:G(`shrink-0`,!e.includes(t)&&`invisible`)})]},t))}),!n&&(0,W.jsx)(`div`,{className:`border-t p-2`,children:(0,W.jsxs)(`form`,{className:`flex gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,W.jsx)(nE,{value:i,onChange:e=>a(e.target.value),placeholder:`New tag...`,className:`h-7 text-xs`}),(0,W.jsx)(Y,{type:`submit`,variant:`outline`,size:`icon-sm`,disabled:!i.trim(),children:(0,W.jsx)(Op,{size:14})})]})})]})]})},WHt=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 T8(e,t){try{return e.startsWith(`#`)?WHt.get(t,e.replace(`#`,``)):WHt.get(t,e)}catch(e){console.error(`Error resolving schema reference. Reference may be invalid or referencing an external document.`,e);return}}var GHt=(e,t)=>{let n=e;return!n||`$ref`in n&&(n=T8(n.$ref,t),!n)?``:n.example?n.example:n.examples&&n.examples.length>0?n.examples[0]:n.default?n.default:``},KHt=(e,t)=>{if(e.examples&&Object.keys(e.examples).length>0){let n=Object.values(e.examples)[0];if(`$ref`in n){let e=T8(n.$ref,t);if(!e)return``;n=e}return n.value}if(e.example)return e.example;let n=e.schema;return GHt(n,t)},qHt=(e,t)=>{let n=e.requestBody;if(!n)return``;if(`$ref`in n){let e=T8(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=T8(e.$ref,t);if(!n)return``;e=n}return e.value}let a=i.schema;return GHt(a,t)},JHt=JSON.stringify({query:`{ __schema { queryType { name } } }`},null,2),YHt=new ZGe,XHt=e=>e.additionalOperationContext.method.split(`,`).map(e=>e.toUpperCase()),E8=e=>{let{oasFilePath:t,method:n,path:r}=e.additionalOperationContext;return`${t}::${e.operationId??`${n} ${r}`}`},ZHt=({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=XHt(t)[0],i=t[KX]===!0,a=ZX(t),o=qHt(t,n),s=YHt.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]:KHt(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?ZP:i?JHt: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,U.useState)(n),[f,p]=(0,U.useState)(()=>l(n,r)),[m,h]=(0,U.useState)(o),g=cm(e=>e.setTestResponse),_=fm(),v=s??_,y=(0,U.useMemo)(()=>({...v,[n.additionalOperationContext.oasFilePath]:r}),[v,n.additionalOperationContext.oasFilePath,r]),b=(0,U.useMemo)(()=>Object.entries(y).flatMap(([e,t])=>h1(e,t)),[y]),x=(0,U.useMemo)(()=>b.map(e=>({id:E8(e),method:e.additionalOperationContext.method,path:e.additionalOperationContext.path,summary:e.summary,file:e.additionalOperationContext.oasFilePath})),[b]);return(0,U.useEffect)(()=>{g(void 0)},[]),(0,W.jsx)(`div`,{className:`flex h-[650px] max-h-[70vh] flex-col`,children:(0,W.jsx)(xat,{ape:e,apiTest:f,showRebuildWarning:i,allowedMethods:XHt(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:E8(u),onSelectEndpoint:e=>{if(e===E8(u))return;let t=b.find(t=>E8(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},E8(u))})},QHt=({envUrl:e,ape:t,operation:n,openApiDocument:r,showRebuildWarning:i,entries:a,onClose:o,defaultEndpointsPanelOpen:s})=>(0,W.jsx)(xY.Provider,{value:{entries:a},children:(0,W.jsx)(`div`,{className:`w-full text-muted-foreground`,children:(0,W.jsx)(ZHt,{openApiDocument:r,ape:t,envUrl:e,showRebuildWarning:i,operation:n,onClose:o,defaultEndpointsPanelOpen:s})})}),$Ht=({open:e,onOpenChange:t,onProceed:n})=>{let{saveAndDeploy:r,isPending:i}=fht();return(0,W.jsx)(tT,{open:e,onOpenChange:t,children:(0,W.jsxs)(iT,{className:`sm:max-w-md`,children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:`Unsaved changes`}),(0,W.jsx)(cT,{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,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`ghost`,onClick:n,disabled:i,children:`Continue without saving`}),(0,W.jsx)(Y,{variant:`default`,onClick:async()=>{try{await r()}catch{return}n()},disabled:i,children:(0,W.jsx)(CP,{loading:i,children:`Save changes`})})]})]})})},eUt=(0,U.lazy)(()=>Cn(()=>import(`./GraphiQLConsole-DXGTvWaz.js`),__vite__mapDeps([9,1,2,8,10,11,12]))),tUt=({path:e,method:t,summary:n,operationData:r,hasFileChanged:i,isGraphql:a})=>{let{logEvent:o}=H(),s=nm(),c=g1().getOpenApiDataEnforced(),{entries:l}=(0,U.useContext)(xY),u=sF(s.environment),[d,f]=(0,U.useState)(null),p=u?new URL(e,u).toString():void 0,m=Sne({mutationKey:nst})>0,[h,g]=I$(()=>(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,W.jsx)(tT,{open:!0,onOpenChange:e=>!e&&g(),children:(0,W.jsxs)(iT,{showCloseButton:!1,className:`max-w-6xl! w-full gap-0 overflow-hidden p-0`,children:[(0,W.jsx)(sT,{className:`sr-only`,children:`Test route`}),(0,W.jsx)(QHt,{envUrl:u??``,showRebuildWarning:i,ape:s,entries:l,operation:r,openApiDocument:c,onClose:g})]})})),[e,t,n,r,l,a]),[_,v]=I$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:`POST`,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:`graphiql`}),(0,W.jsx)(tT,{open:!0,onOpenChange:e=>!e&&v(),children:(0,W.jsxs)(iT,{className:`max-w-6xl! w-full p-0 overflow-hidden`,children:[(0,W.jsx)(sT,{className:`sr-only`,children:`GraphiQL`}),(0,W.jsx)(`div`,{className:`h-[80vh] w-full`,children:(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:`Loading GraphiQL…`}),children:(0,W.jsx)(eUt,{url:p??``,ape:s})})})]})})),[p,s]),y=e=>{e===`graphiql`?_():h()},b=e=>{if(i){f(e);return}y(e)},x=(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{children:`Saving`}),(0,W.jsx)(SP,{color:`current`})]}),S=m?`Saving`:`Test Route`;return(0,W.jsxs)(W.Fragment,{children:[a?(0,W.jsxs)(pq,{children:[(0,W.jsx)(mq,{asChild:!0,children:(0,W.jsx)(Y,{variant:`brand`,disabled:m,"aria-label":S,children:(0,W.jsxs)(CP,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,W.jsx)(Wp,{className:`shrink-0 fill-current`}),(0,W.jsx)(`span`,{children:`Test Route`}),(0,W.jsx)(Zf,{className:`size-4 shrink-0`})]})})}),(0,W.jsxs)(hq,{align:`end`,children:[(0,W.jsxs)(_q,{onSelect:()=>b(`playground`),children:[(0,W.jsx)(Wp,{className:`size-4`}),(0,W.jsx)(`span`,{children:`Playground`})]}),(0,W.jsxs)(_q,{disabled:!p,onSelect:()=>b(`graphiql`),children:[(0,W.jsx)(D1,{className:`size-4`}),(0,W.jsx)(`span`,{children:`GraphiQL`})]})]})]}):(0,W.jsx)(Y,{variant:`brand`,disabled:m,"aria-label":S,onClick:()=>b(`playground`),children:(0,W.jsxs)(CP,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,W.jsx)(Wp,{className:`shrink-0 fill-current`}),(0,W.jsx)(`span`,{children:`Test Route`})]})}),(0,W.jsx)(U.Suspense,{fallback:null,children:(0,W.jsx)($Ht,{open:d!==null,onOpenChange:e=>{e||f(null)},onProceed:()=>{let e=d;f(null),e&&y(e)}})})]})},nUt=({onRequestHandlerChange:e,isReadOnly:t,routeHandler:n})=>{let r=k1(n),i=(t,i)=>{e({...n,options:{...r.options,[t]:i}})};return(0,W.jsxs)(lk,{className:`p-4 bg-surface-sunken`,children:[(0,W.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-base font-medium`,children:`MCP Server Options`}),(0,W.jsx)(tE,{showIcon:!0,href:`https://docs.zuplo.com/handlers/mcp-server`,className:`text-sm text-zuplo-pink`,children:`MCP Server Docs`})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-12 gap-4 col-span-full items-center`,children:[(0,W.jsx)(`div`,{className:`col-span-8`,children:(0,W.jsx)(b6,{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,W.jsx)(`div`,{className:`col-span-4`,children:(0,W.jsx)(b6,{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,W.jsxs)(`div`,{className:`col-span-12 mt-2`,children:[(0,W.jsx)(rE,{className:`text-sm mb-2 block`,children:`Advanced Options`}),(0,W.jsx)(`div`,{className:G(`flex gap-4`,t&&`opacity-50`),children:(0,W.jsxs)(`label`,{className:`text-sm flex items-center gap-2`,children:[(0,W.jsx)(PY,{"data-test":`mcp-debug-mode`,checked:!!r.options.debugMode,onCheckedChange:e=>{i(`debugMode`,e)},disabled:t}),`Debug Mode`]})})]})]})]})},rUt=({routeHandler:e,operation:t,isReadOnly:n,onRequestHandlerChange:r})=>{let{captureRaw:i}=H(),a=Pxt(),o=k1(e),s=typeof o.options.rewritePattern==`string`?o.options.rewritePattern:``,c=_zt(()=>{i(`mcp-gateway-upstream-url-edited`)});return(0,W.jsx)(lk,{className:`p-4`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground font-medium`,children:`Upstream MCP server`}),!!(a&&t)&&(0,W.jsxs)(Y,{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,W.jsx)(jp,{className:`w-3.5 h-3.5`}),`Edit MCP Server Policy`]})]}),(0,W.jsx)(d3,{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 iUt(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 aUt({operationData:e,addRouteMenuProps:t}){return e?(0,W.jsx)(`div`,{className:`w-full h-full min-h-0 overflow-y-auto px-4 pt-2 pb-4`,children:(0,W.jsx)(sUt,{operationData:e})}):(0,W.jsx)(zbt,{...t})}var oUt=()=>{let e=dm(),t=fm(),n=(0,U.useMemo)(()=>e.flatMap(e=>{let n=t[e.path];return n?h1(e.path,n).filter(e=>ZX(e)).map(t=>[e,t]):[]}),[e,t]);return{getLinkedMcpServers:(e,t)=>n.filter(([,n])=>{let r=n[JX]?.handler;return YX(r)?r.options?.operations?.some(n=>E1(n.file)===e&&n.id===t):!1})}},sUt=({operationData:e})=>{let[t]=SY(`path`);if(!t)throw Error(`Open API file path not found in URL`);let n=dht(t),r=nm(),{logEvent:i}=H(),{additionalOperationContext:a,...o}=e,{path:s,method:c}=a,l=g1(),u=em(),d=j1(),{isReadOnly:f}=YZ(),[p,m]=(0,U.useState)(),[h,g]=(0,U.useState)();oUt();let _=l.openApiData?.servers?.at(0)?.url,v=o[JX]??v1(_??`https://echo.zuplo.io`),y=o[GX]===!0,b=o.deprecated===!0,x=o[KX]===!0,S=l.openApiFileModel.saveState!==eu.unmodified,C=v.handler,w=YX(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,[JX]:{...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,[GX]: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[KX]=!0,Cbt(d),n[JX]=Sbt(v,!0)):(delete n[KX],o[JX]&&(n[JX]=Sbt(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,[JX]: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,[qX]:a}),i(`route-path-mode-changed`,{pathMode:n,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},L=()=>{n(eu.modified)};return(0,W.jsxs)(`div`,{className:`mb-4 flex flex-col gap-6`,children:[(0,W.jsxs)(lk,{className:`bg-neutral-50 dark:bg-transparent`,children:[(0,W.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,W.jsxs)(uk,{children:[(0,W.jsx)(dk,{children:`Request Handling`}),(0,W.jsx)(fk,{})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 p-6`,children:[x&&(0,W.jsx)(HHt,{path:s,rewriteUrl:typeof C.options?.rewritePattern==`string`?C.options?.rewritePattern:void 0}),(0,W.jsx)(gVt,{operationData:e}),(0,W.jsx)(tUt,{path:s,method:c,summary:o.summary??``,operationData:e,hasFileChanged:S,isGraphql:x})]})]}),(0,W.jsxs)(pk,{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,W.jsx)(EVt,{isReadOnly:f,initialPath:s,method:c,onChangeMethod:N,pathMode:e.additionalOperationContext.pathZuploConfig?.pathMode,hasError:p!=null,onPathChange:M,onPathModeChange:I,onFieldModified:L,isMcpToolHandler:YX(C)||XX(C)}),p&&(0,W.jsx)(sb,{"data-test":`path-error`,className:`col-span-full p-2`,variant:`destructive`,children:(0,W.jsx)(lb,{children:p})}),w&&(0,W.jsx)(sb,{className:`col-span-full p-2 py-1`,variant:`destructive`,children:(0,W.jsxs)(lb,{"data-test":`request-handler-error`,className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{children:w}),(0,W.jsx)(Y,{onClick:()=>N(`post`),size:`xs`,variant:`outline`,className:`border-none`,children:`Switch to POST method`})]})}),(0,W.jsx)(KFt,{isReadOnly:f,initialSummary:o.summary,onSummaryChange:E,onFieldModified:L}),(0,W.jsx)(_Vt,{isReadOnly:f,defaultOperationId:e.operationId,openApiManager:l,path:s,method:c,operationData:e})]}),(0,W.jsxs)(mk,{className:`flex flex-wrap gap-2 px-3 py-1.5 bg-card justify-end`,children:[(0,W.jsx)(UHt,{operationTags:o.tags??[],onTagsChanged:F}),(0,W.jsx)(Yzt,{isReadOnly:f,selectedCorsPolicy:v.corsPolicy,corsPolicies:d.corsPolicyList??[],onSelectionChanged:P}),!YX(v.handler)&&!XX(v.handler)&&(0,W.jsx)(SVt,{operation:e,defaultValues:iUt(v.mcp),onSubmit:e=>{let t={...v,mcp:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[JX]:t}})}}),(0,W.jsx)(WBt,{isExcludedFromDocs:y,onVisibilityChanged:O}),(0,W.jsx)(DVt,{isGraphql:x,onGraphqlChanged:A,isDeprecated:b,onDeprecatedChanged:k})]})]}),(0,W.jsx)(uzt,{inboundPolicies:v.policies?.inbound??[],outboundPolicies:v.policies?.outbound??[],operation:e,children:(0,W.jsx)(cUt,{isReadOnly:f,operationData:e,handler:v.handler,firstServerUrl:_,onRequestHandlerChange:T})}),(0,W.jsx)(UBt,{initialDescription:o.description??``,onChange:D,path:s,method:c,oasFilePath:t})]})},cUt=({operationData:e,handler:t,firstServerUrl:n,isReadOnly:r,onRequestHandlerChange:i})=>{let a=(e[JX]??v1(n??`https://echo.zuplo.io`)).handler;switch(t.export){case`mcpServerHandler`:return(0,W.jsx)(nUt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i});case`McpProxyHandler`:case`McpVirtualServerHandler`:case`mcpVirtualServerHandler`:return(0,W.jsx)(rUt,{routeHandler:a,operation:e,isReadOnly:r,onRequestHandlerChange:i});default:return(0,W.jsx)(Gzt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i})}},lUt=Me()(e=>({updateLinkedMcpServers:void 0,setUpdateLinkedMcpServers:t=>e({updateLinkedMcpServers:t})})),uUt=()=>{let e=F(lUt,e=>e.updateLinkedMcpServers),t=lQ(),n=()=>{lUt.setState({updateLinkedMcpServers:void 0})};return(0,W.jsx)(tT,{open:!!e,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(iT,{children:[(0,W.jsx)(sT,{children:`MCP Server Links`}),(0,W.jsx)(cT,{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,W.jsx)(`div`,{className:`flex gap-2 items-center justify-center`,children:e?.linkedMcpServers.map(([,e])=>(0,W.jsx)(qT,{children:e},e))}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`outline`,onClick:n,children:`Cancel`}),(0,W.jsx)(Y,{onClick:()=>{e?.linkedMcpServers.forEach(([n,r])=>{let i=new lbt(n,t),a=i.getOperationById(r);if(!a)return;let o=a[JX];if(!o)return;let s=o.handler;if(YX(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:K$(t,`operationId`,e.newOperationId)})}i.updateOperation({path:a?.additionalOperationContext.path,method:a.additionalOperationContext.method,newOperationObject:K$(a,`${JX}.handler.options.operations`,s.options?.operations?.map(t=>E1(t.file)===n.path?{...t,id:t.id===e.oldOperationId?e.newOperationId:t.id}:t))})}})},children:`Update`})]})]})})},dUt=`$import(@zuplo/runtime)`,fUt=`${dUt}::urlForwardHandler`,pUt=`${dUt}::urlRewriteHandler`,mUt=(e,t)=>{let n=e.options?.[t],r=typeof n==`string`?n.trim():``;return r.length>0?r:void 0},hUt=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)},gUt=e=>{if(e){let t=`${e.module}::${e.export}`,n=t===fUt?mUt(e,`baseUrl`):t===pUt?mUt(e,`rewritePattern`):void 0;if(n){let e=hUt(n);return{key:`target:${e}`,label:e,mono:!0,icon:bp,collapsible:!0}}}return{...Sxt(e),collapsible:!1}};function _Ut(){let e=g1(),{captureRaw:t}=H(),n=nm(),r=oQ();return i=>{e.updateInfo(i),t(`openapi-info-updated`);let{projectTreeNodes:a,filesByPath:o}=cm.getState(),s=a.map(e=>e.path?o[e.path]:void 0).filter(e=>!!e&&e.saveState===eu.modified);s.length!==0&&r.mutateAsync({environmentName:n.environment.name,accountName:n.account.name,projectName:n.project.name,files:s}).catch(()=>{})}}var D8=`Document Order`,vUt=[`Document Order`,`Path`,`Summary`],O8=`Untagged`,yUt=[{value:`none`,label:`None`},{value:`path`,label:`Path`},{value:`handler`,label:`Handler type`},{value:`target`,label:`Target`}],bUt=new Set([`handler`,`target`]);function xUt(e){return`${e}-${fe().split(`-`).at(0)}`}function k8(e){return new Set(e.getPolicyListEnforced().map(e=>e.name))}function SUt(e){if(!e)return;let t=LFt(e.getPolicyListEnforced());if(t)return t.name;let n=v3(FFt,k8(e));return e.createPolicy(IFt(n)),n}var CUt=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}},wUt=e=>t=>{if(e.length===0)return!0;let n=t.tags;return!n||n.length===0?e.includes(O8):n.some(t=>e.includes(t))},TUt=({onNavigateToOpenApiFileTab:e})=>{let{logEvent:t,captureRaw:n}=H(),[r,i]=yit(`tags`,[]),[a,o]=BT(`open-api-designer-group-by`,`none`);(0,U.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,U.useState)(!1),[l,u]=(0,U.useState)(`details`),[d,f]=(0,U.useState)(!1),p=_Ut(),m=(0,U.useRef)(null);(0,U.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,U.useState)(),[_,v]=(0,U.useState)(),[y,b]=(0,U.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,U.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}=YZ(),[E,D]=SY(`operation`),[O,k]=BT(`default-sort-routes`,D8),[A,j]=SY(`sort`,O);(0,U.useEffect)(()=>{A&&k(A)},[k,A]),(0,U.useEffectEvent)(()=>{if(E)try{document.querySelector(`#op-${E}`)?.scrollIntoView()}catch{}});let[M,N]=(0,U.useState)(void 0),P=g1(),F=j1(),I=kP(),L=uQ(Cxt),R=dQ(),z=()=>{if(L)return Txt(L.content??``)?`ok`:`manual`;let e=wxt,t={path:Cxt,content:e,type:$l.File,saveState:eu.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:eu.modified}),`ok`},{results:B,setSearchTerm:V,searchTerm:ee}=rxt(P.operationArray?.filter(wUt(r)).sort(CUt(A))??[],{keys:[e=>e.additionalOperationContext.path,e=>e.summary??``,e=>e.operationId,e=>e.additionalOperationContext.method]});(0,U.useEffect)(()=>{let e=ee?.trim()??``;if(e.length===0)return;let n=setTimeout(()=>{t(`route-search-used`,{view:`routes`,query:e,queryLength:e.length})},600);return()=>clearTimeout(n)},[ee,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[JX]?.handler,c=a===`target`?gUt(e):{...Sxt(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,U.useState)(),[ie,ae]=(0,U.useState)(),[oe,se]=(0,U.useState)(!1),ce=(0,U.useMemo)(()=>{if(!_)return[];let e=(P.operationArray?.find(e=>e.additionalOperationContext.path===_.path&&e.additionalOperationContext.method===_.method))?.[JX]?.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,U.useState)(()=>new Set);(0,U.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})},pe=()=>{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),me())}v(void 0),se(!1)},[me,he]=I$(()=>{let t=()=>{N(void 0),he()};return(0,W.jsx)(SQ,{alertType:`ERROR`,bodyText:M??``,onPrimaryButtonClick:e,onSecondaryButtonClick:t,primaryButtonText:`Edit file directly`,secondaryButtonText:`Cancel`,hideModal:t,title:`Error`})},[M]),[ge,_e]=I$(()=>(0,W.jsx)(SQ,{alertType:`CAUTION`,bodyText:`Cannot reorder in this view — view by Document Order to reorganize the order of operations.`,onPrimaryButtonClick:()=>{j(D8),_e()},onSecondaryButtonClick:_e,primaryButtonText:`Switch to Document Order`,secondaryButtonText:`Cancel`,hideModal:_e,title:`Cannot reorder`})),[ve,ye]=I$(()=>(0,W.jsx)(Dxt,{open:!0,onOpenChange:e=>{e||ye()}})),be=(e,t)=>{if(A!==D8){ge();return}P.movePathInDocument(e,t)};if(!P.openApiData)throw Error(`Invalid State - no OpenApiData`);let xe=P.openApiData.info,Se=P.openApiData.tags?.map(e=>({value:e.name,label:e.name}));Se?.push({value:O8,label:O8});let Ce=()=>{let e=C1.OpenAPIV3.HttpMethods.GET,n=P.openApiData?.servers?.at(0)?.url,r=bbt(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),me())}t(`route-added`)},we=(e,n,r)=>{let i=P.openApiData?.servers?.at(0)?.url,a=bbt(i??`https://echo.zuplo.io`),o=r?.[JX],s=a[JX];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),me())}t(`route-added`)},Te=()=>{let e=C1.OpenAPIV3.HttpMethods.POST,n=xUt(`mcp`),r=P.addOperation(`/mcp`,e,{summary:`MCP Server`,description:`Default MCP Server`,[JX]:{corsPolicy:`none`,handler:{export:`mcpServerHandler`,module:`$import(@zuplo/runtime)`,options:{operations:[]}},policies:{inbound:[]}},operationId:n},{avoidConflict:!0});r&&D(r),t(`route-added`)},Ee=()=>{let e=C1.OpenAPIV3.HttpMethods.POST,n=wbt(`https://rickandmortyapi.com/graphql`);try{Cbt(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),me())}t(`route-added`)},De=()=>{let e=C1.OpenAPIV3.HttpMethods.GET,n=Tbt();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),me())}t(`route-added`)},[Oe,ke]=(0,U.useState)(!1),[Ae,je]=(0,U.useState)(),[Me,Ne]=(0,U.useState)(0),Pe=(0,U.useMemo)(()=>{let e=new Set(Object.keys(P.openApiData?.paths??{}));return Ae&&e.delete(Ae.path),e},[P.openApiData?.paths,Ae]),Fe=async e=>{let n;try{n=z()}catch(e){if(e instanceof Error){N(e.message),me();return}throw e}let r;try{r=zFt({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),me();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),me())}t(`route-added`),t(`mcp-gateway-create-virtual-mcp-submitted`,BFt(e)),n===`manual`&&ve()},Ie=()=>{Ne(e=>e+1),ke(!0)},Le=e=>{let t=EFt({operationPath:e.additionalOperationContext.path,operation:e,policyList:F?.getPolicyListEnforced()??[]});t&&(Ne(e=>e+1),je({initialResult:t,path:e.additionalOperationContext.path,method:e.additionalOperationContext.method,operationId:e.operationId}))},Re=async e=>{let t=Ae;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){je(void 0);return}let s;try{s=z()}catch(e){if(e instanceof Error){N(e.message),me();return}throw e}let c=NFt(e.step1.name),l=o0(e.step1.mcpUrl),u=l?.protectedResourceMetadataUrl??RFt(e.step1.mcpUrl),d=o[JX]?.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===Z4),g=m.find(e=>e.policyType===Q4),_=m.find(e=>e.policyType===`remove-headers-inbound`&&$4(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),me();return}}else if(F){y=v3(`mcp-upstream-${c}`,k8(F));try{F.createPolicy({name:y,policyType:Z4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpTokenExchangeInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),me();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),me();return}}}let x;if(e.step2.catalogMode===`curated`){let t=G4(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),me();return}}else if(F){x=v3(`mcp-filter-${c}`,k8(F));try{F.createPolicy({name:x,policyType:Q4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpCapabilityFilterInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),me();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),me();return}}let C;if(e.step1.authMode===`none`&&e.step1.noAuthBehavior===`strip`)try{C=_?.name??SUt(F)}catch(e){if(e instanceof Error){N(e.message),me();return}}let w=[S,x,y,b,C].filter(e=>!!e),T=o[JX],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})`,[JX]:{...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),me();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}),je(void 0),s===`manual`&&ve()},ze=(0,U.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,U.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-${fe().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),me())}t(`route-added`,{httpPath:o,httpMethod:n,duplicate:!0})},Ve=()=>{f(!0),u(`tags`),c(!0)},He=Ae!==void 0,Ue=(0,W.jsx)(DFt,{isOpen:Oe||He,existingPaths:Pe,mode:He?`edit`:`create`,initialResult:Ae?.initialResult,onClose:()=>{ke(!1),je(void 0)},onFinish:He?Re:Fe},`mcp-wizard-${Me}`),We={onAddRest:Ce,onAddGraphql:Ee,onAddWebSocket:De,onAddMcpVirtual:Ie,onAddMcpServer:Te,onAddTag:Ve};return P.operationArray?.length===0&&(!ee||ee.trim().length===0)?(0,W.jsxs)(W.Fragment,{children:[Ue,(0,W.jsx)(zbt,{...We})]}):(0,W.jsxs)(`div`,{className:`ms-2 grid grid-cols-3 h-full grow`,children:[(0,W.jsx)(N$,{open:oe,onOpenChange:e=>{se(e),e||v(void 0)},onClickDelete:pe,title:`Delete`,deleteButtonText:`Confirm`,children:ce.length===0?`Are you sure you want to delete this operation?`:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.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,W.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,W.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2`,children:[(0,W.jsx)(PY,{id:t,checked:le.has(e.name),onCheckedChange:t=>de(e.name,t===!0),className:`mt-0.5`}),(0,W.jsxs)(`label`,{htmlFor:t,className:`flex flex-col gap-0.5 text-left cursor-pointer min-w-0`,children:[(0,W.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.name}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e.policyType})]})]},e.name)})})]})}),(0,W.jsx)(uUt,{}),Ue,xe&&(0,W.jsx)(WFt,{open:s,onOpenChange:c,info:xe,onSave:p,defaultTab:l,tagsAutoCreate:d,onTagsAutoCreateConsumed:()=>f(!1)}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 justify-start h-full pt-2 min-h-0`,children:[(0,W.jsxs)(`div`,{className:`flex justify-between gap-x-2`,children:[(0,W.jsx)(`div`,{className:`flex gap-1`,children:(0,W.jsxs)(pq,{children:[(0,W.jsx)(mq,{className:`flex group select-none`,asChild:!0,children:(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,title:`Filter and sort routes`,children:[(0,W.jsx)(pte,{size:16}),`Filter`]})}),(0,W.jsxs)(hq,{className:`min-w-[220px]`,align:`start`,children:[(0,W.jsx)(xq,{children:`Sort by`}),(0,W.jsx)(gq,{children:vUt.map(e=>(0,W.jsxs)(_q,{onClick:()=>j(e),className:`justify-between`,children:[e,(0,W.jsx)(Xf,{className:G(`mr-2`,e!==A&&`invisible`),size:16})]},e))}),(0,W.jsx)(Sq,{}),(0,W.jsx)(xq,{children:`Filter by tag`}),(0,W.jsx)(gq,{className:`max-h-60 overflow-y-auto`,children:Se?.map(e=>(0,W.jsxs)(_q,{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,W.jsx)(Xf,{className:G(`mr-2`,!r.includes(e.value)&&`invisible`),size:18})]},e.label))}),(0,W.jsx)(Sq,{}),(0,W.jsx)(xq,{children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Ete,{size:16}),`Group by`]})}),(0,W.jsx)(gq,{children:yUt.map(e=>(0,W.jsxs)(_q,{onClick:t=>{t.stopPropagation(),t.preventDefault(),o(e.value)},className:`justify-between`,children:[e.label,(0,W.jsx)(Xf,{className:G(`mr-2`,a!==e.value&&`invisible`),size:16})]},e.value))})]})]})}),T?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>{f(!1),u(`details`),c(!0)},"aria-label":`API Settings`,title:`API Settings`,children:(0,W.jsx)(Dp,{size:16})}),(0,W.jsxs)(pq,{children:[(0,W.jsx)(mq,{asChild:!0,children:(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,"data-test":`add-route-btn`,className:`relative gap-0.5!`,children:[(0,W.jsx)(`div`,{className:`absolute w-1.5 h-1.5 rounded-full -top-0.5 -right-[3px] bg-zuplo-700`}),(0,W.jsx)(Op,{"aria-hidden":`true`,className:`size-3.5`}),`Add`]})}),(0,W.jsx)(hq,{children:(0,W.jsx)(Rbt,{...We})})]})]})]}),(0,W.jsx)(kY,{onClearValue:()=>V(``),value:ee,showClearButton:!!ee&&ee.length>0,children:(0,W.jsx)(nE,{ref:m,value:ee,onChange:e=>V(e.target.value),placeholder:`Search Routes`,className:`px-8`})}),r.length>0&&(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,W.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,W.jsx)(Ip,{size:11,className:`shrink-0 text-muted-foreground`}),(0,W.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,W.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-surface-emphasis hover:text-neutral-900 dark:hover:text-foreground`,children:(0,W.jsx)(Up,{size:11})})]},e))}),(0,W.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,W.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,W.jsxs)(`div`,{children:[e.collapsible?(0,W.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,W.jsx)(Zf,{size:15,className:`shrink-0 text-muted-foreground`}):(0,W.jsx)(Qf,{size:15,className:`shrink-0 text-muted-foreground`}),o&&(0,W.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,W.jsx)(`span`,{className:`truncate font-mono`,title:e.label,children:e.label}),s]}):a!==`none`&&(0,W.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,W.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,W.jsx)(`span`,{className:G(`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[JX]?.handler,s=YX(o),c=XX(o),l=s?o.options?.operations?.length??0:0,u=l>0,d=y.has(r.operationId);return(0,W.jsxs)(U.Fragment,{children:[(0,W.jsx)(uxt,{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:we,onDuplicate:()=>Be(e.path,e.method,r),onMoveUp:bUt.has(a)?void 0:()=>be(e.path,`up`),onMoveDown:bUt.has(a)?void 0:()=>be(e.path,`down`),isFirstPath:A===D8&&t===0,isLastPath:A===D8&&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,W.jsx)(Mxt,{handler:o,operation:{...r,additionalOperationContext:e}})]},r.operationId)})]},e.key)})})]}),(0,W.jsx)(`div`,{className:`col-span-2 flex flex-col h-full overflow-y-auto`,children:(0,W.jsx)(y3.Provider,{value:{setPath:re,setSummary:ae},children:(0,W.jsx)(Nxt.Provider,{value:Le,children:(0,W.jsx)(aUt,{operationData:ze,addRouteMenuProps:We})})})})]})},EUt={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`}},A8=({icon:e,operations:t,title:n,tone:r})=>{let i=EUt[r];return(0,W.jsxs)(`section`,{className:`rounded-2xl p-4 shadow-sm ${i.shell}`,"aria-label":`${n} operations`,children:[(0,W.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-semibold text-foreground`,children:[(0,W.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-xl ${i.icon}`,children:e}),n,` operations`]}),(0,W.jsx)(`div`,{className:`rounded-full px-2.5 py-1 text-xs font-medium tabular-nums ${i.count}`,children:t.size})]}),(0,W.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,W.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,W.jsx)(AY,{className:`w-14`,method:n}),(0,W.jsx)(`span`,{className:`break-all text-foreground/90`,children:r})]},e)})})]})},DUt=({openApiFileModel:e,onOpenApiFileSynced:t,setIsOpen:n})=>{let[r,i]=(0,U.useState)(),a=em(),o=e=>{i(e)},s=async()=>{if(!r)throw Error(`No file selected`);let i=e.content?JSON.parse(e.content):null;t(i?Aft(i,r.content):r.content),n(!1),a.success(`OpenAPI file merged successfully`,{icon:(0,W.jsx)(Jhe,{className:`h-4 w-4`})})};if(r){let t=Fft(JSON.parse(e.content??`{}`),r.content);return(0,W.jsx)(b1,{isOpen:!0,setIsOpen:n,title:`Review OpenAPI import`,className:`sm:max-w-4xl max-h-[88vh] overflow-y-auto`,icon:(0,W.jsx)(Py,{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,W.jsxs)(`div`,{className:`mt-6 text-left text-sm`,children:[(0,W.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,W.jsxs)(`div`,{className:`rounded-[calc(1.5rem-1px)] bg-background p-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[1fr_auto_1fr] md:items-center`,children:[(0,W.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-brand/10 text-brand`,children:(0,W.jsx)(yge,{className:`h-5 w-5`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Import file`}),(0,W.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:r.name})]})]})}),(0,W.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,W.jsx)(Py,{className:`h-5 w-5`})}),(0,W.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.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,W.jsx)(By,{className:`h-5 w-5`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Current API`}),(0,W.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:e.path})]})]})})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2 text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:`Operations are matched by`}),(0,W.jsx)(qT,{variant:`outline`,children:`Path + method`}),(0,W.jsx)(`span`,{children:`so existing Zuplo extensions and policies stay in place.`})]})]})}),(0,W.jsxs)(`div`,{className:`mt-6 flex items-end justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:`Import summary`}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Review what will change before applying this file.`})]}),(0,W.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,W.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,W.jsx)(A8,{icon:(0,W.jsx)(zge,{className:`h-4 w-4`}),title:`Create`,tone:`create`,operations:t.created}):null,t.merged.size>0?(0,W.jsx)(A8,{icon:(0,W.jsx)(Ige,{className:`h-4 w-4`}),title:`Update`,tone:`update`,operations:t.merged}):null,t.retained.size>0?(0,W.jsx)(A8,{icon:(0,W.jsx)(Yhe,{className:`h-4 w-4`}),title:`Keep`,tone:`keep`,operations:t.retained}):null]})]})})}return(0,W.jsx)(Mbt,{title:`Import OpenAPI`,onValidFileSelected:o,setIsOpen:n})},OUt=()=>{let e=P(),t=I({mutationFn:t=>e.fetch(V.users.updatePreferences(t))}),{data:n}=Ob(R.user.preferences());return{preferences:n,updatePreferences:t.mutate,updatePreferencesMutation:t}},kUt=!1;function j8(){let e=Je(),{preferences:t,updatePreferencesMutation:n}=OUt();return{isFileTreeOpen:t.fileTreeOpen??kUt,setIsFileTreeOpen:r=>{let i=[R.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 AUt(){let e=cQ(),{logEvent:t}=H(),[n,r]=SY(`v`,`designer`),{isFileTreeOpen:i}=j8(),a=e?.path.split(`/`).pop()??`JSON`,o=lQ(),s=Pbt(),[c,l]=I$(()=>{if(!e)throw Error(`File model not found`);return t(`merge-open-api`),(0,W.jsx)(DUt,{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,W.jsx)(mxt,{children:(0,W.jsx)(dbt,{children:(0,W.jsxs)(tA,{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,W.jsxs)(nA,{className:`rounded-none border-b w-full justify-start`,children:[(0,W.jsx)(rA,{value:`designer`,children:`Route Designer`}),(0,W.jsx)(rA,{value:`raw`,children:a??`Raw`}),(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:c,className:`ml-4`,children:[(0,W.jsx)(qge,{className:`w-4 h-4`}),` Import`]})]}),(0,W.jsx)(iA,{value:`designer`,className:`grow h-full overflow-y-auto`,children:(0,W.jsx)(ybt,{onNavigateToOpenApiFileTab:()=>r(`raw`),children:(0,W.jsx)(TUt,{onNavigateToOpenApiFileTab:()=>r(`raw`)})})}),(0,W.jsx)(iA,{value:`raw`,className:`grow h-full overflow-y-auto`,forceMount:!0,children:(0,W.jsx)(xQ,{})})]})})})}function jUt({title:e,description:t,folder:n,icon:r,emptyText:i,newLabel:a,onCreate:o}){let s=cm(e=>e.projectTreeNodes),[c,l]=Hl(),{isReadOnly:u}=YZ(),d=n.endsWith(`/`)?n:`${n}/`,f=(0,U.useMemo)(()=>s.filter(e=>e.type===$l.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,W.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:e}),(0,W.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:t})]}),!u&&(0,W.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:o,className:`shrink-0`,children:[(0,W.jsx)(Op,{className:`size-4`}),a]})]}),(0,W.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:f.length===0?(0,W.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,W.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:G(`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,W.jsx)(r,{className:`size-4 shrink-0 text-neutral-500 group-hover:text-brand`}),(0,W.jsx)(`span`,{className:`truncate text-sm font-medium text-neutral-800 dark:text-neutral-200`,children:t})]},e.path)})})]})})}function MUt(){let e=cm(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=j8();return(0,W.jsx)(jUt,{title:`Custom Modules`,description:`TypeScript modules in your project's modules/ folder — request handlers, policies, and other custom code.`,folder:`/modules`,icon:Pte,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 NUt(){let e=cm(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=j8();return(0,W.jsx)(jUt,{title:`Schemas`,description:`JSON schemas in your project's schemas/ folder, used to validate requests and responses.`,folder:`/schemas`,icon:hp,emptyText:`No schemas yet. Create one to validate request or response bodies.`,newLabel:`New Schema`,onCreate:()=>{t(!0),e({strategyFolder:`/schemas`,template:`Schema`})}})}var PUt=()=>{let[e,t]=(0,U.useState)(),{isReadOnly:n}=YZ(),r=j1(),i=r.policiesUsageInfo,{logEvent:a}=H(),o=nm([`account`,`project`,`environment`]),[s,c]=I$(()=>e?(0,W.jsx)(szt,{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,W.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:`Policies`}),(0,W.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,W.jsxs)(pq,{modal:!1,children:[(0,W.jsx)(mq,{asChild:!0,children:(0,W.jsxs)(Y,{variant:`secondary`,size:`sm`,className:`shrink-0`,children:[(0,W.jsx)(Op,{className:`size-4`}),`New Policy`]})}),(0,W.jsxs)(hq,{align:`end`,children:[(0,W.jsxs)(_q,{onClick:()=>l(`inbound`),children:[(0,W.jsx)(Af,{className:`mr-2 size-4`}),`Inbound Policy`]}),(0,W.jsxs)(_q,{onClick:()=>l(`outbound`),children:[(0,W.jsx)(Ff,{className:`mr-2 size-4`}),`Outbound Policy`]})]})]})]}),(0,W.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:u.length===0?(0,W.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,W.jsx)(tE,{href:`https://zuplo.com/docs/overview/policies`,children:`read the docs`}),`.`]}):u.map(e=>(0,W.jsx)(ezt,{policy:e},e.name))})]})})},FUt=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={}))})),IUt=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={}))})),LUt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),RUt=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`})),zUt=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})),BUt=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})),VUt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isValidProjectName=e.MAX_PRETTY_BRANCH_LENGTH=e.MAX_HASH_LENGTH=void 0;var t=BUt();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})),HUt=i({$defs:()=>L8,$id:()=>N8,$schema:()=>M8,additionalProperties:()=>!1,default:()=>UUt,description:()=>``,properties:()=>R8,required:()=>I8,title:()=>P8,type:()=>F8}),M8,N8,P8,F8,I8,L8,R8,UUt,WUt=n((()=>{M8=`https://json-schema.org/draft/2020-12/schema`,N8=`http://schemas.zuplo.com/route.json`,P8=`Route Config File`,F8=`object`,I8=[`routes`,`versions`],L8={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`}]}}}},R8={$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`}},UUt={$schema:M8,$id:N8,title:P8,description:``,type:F8,additionalProperties:!1,required:I8,$defs:L8,properties:R8}})),GUt=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}}})),z8=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})),KUt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=z8(),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}}})),B8=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=z8(),n=KUt(),r=z8();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=KUt();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?`
|
|
1569
|
+
`}var w8=`/docs/schema.graphql`,zHt=()=>JSON.stringify({query:bHt()}),BHt=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`${SHt(xHt(t.data))}\n`}catch(e){throw Error(`Could not build a schema from the introspection result: ${e instanceof Error?e.message:String(e)}`)}},VHt=({endpointUrl:e,rewriteUrl:t,ape:n,onClose:r})=>{let{logEvent:i}=H(),a=em(),o=vX(),s=oF(),[c,l]=(0,U.useState)(t??e),[u,d]=(0,U.useState)([{key:``,value:``}]),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.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:zHt()},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=BHt(l.body);f=`save`,await o.mutateAsync({file:{path:w8,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 ${w8}`),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,W.jsx)(tT,{open:!0,onOpenChange:e=>!e&&!f&&r(),children:(0,W.jsxs)(iT,{className:`sm:max-w-2xl`,children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:`Download GraphQL schema`}),(0,W.jsxs)(cT,{children:[`Run an introspection query against this endpoint. On success the schema is stored in `,(0,W.jsx)(`code`,{children:w8}),`.`]})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(rE,{htmlFor:`graphql-introspection-endpoint`,children:`Endpoint`}),e&&e!==c&&(0,W.jsx)(Y,{variant:`link`,size:`xs`,type:`button`,className:`h-auto p-0`,disabled:f,onClick:()=>l(e),children:`Use gateway URL`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(nE,{id:`graphql-introspection-endpoint`,value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com/graphql`,disabled:f,"data-op-ignore":!0}),(0,W.jsx)(EP,{textToCopy:c})]})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(rE,{children:`Headers (optional)`}),(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(nE,{placeholder:`Header name`,value:e.key,onChange:e=>g(t,`key`,e.target.value),"data-op-ignore":!0}),(0,W.jsx)(nE,{placeholder:`Value`,value:e.value,onChange:e=>g(t,`value`,e.target.value),"data-op-ignore":!0}),(0,W.jsx)(Y,{variant:`ghost`,size:`icon`,type:`button`,"aria-label":`Remove header`,onClick:()=>v(t),children:(0,W.jsx)(Rp,{className:`size-4`})})]},t))}),(0,W.jsx)(`div`,{children:(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,type:`button`,onClick:_,children:[(0,W.jsx)(Op,{className:`size-4`}),(0,W.jsx)(`span`,{children:`Add header`})]})})]}),m&&(0,W.jsxs)(sb,{variant:`destructive`,children:[(0,W.jsx)(np,{}),(0,W.jsx)(cb,{children:`Introspection failed`}),(0,W.jsx)(lb,{className:`break-words`,children:m})]})]}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(rT,{asChild:!0,children:(0,W.jsx)(Y,{variant:`outline`,type:`button`,disabled:f,children:`Cancel`})}),(0,W.jsx)(Y,{variant:`brand`,type:`button`,onClick:y,disabled:f||c.trim().length===0,children:f?`Running…`:`Run introspection`})]})]})})},HHt=({path:e,rewriteUrl:t})=>{let n=nm(),r=lc(),{logEvent:i}=H(),[a,o]=(0,U.useState)(!1),s=sF(n.environment),c=s?new URL(e,s).toString():void 0;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(pq,{children:[(0,W.jsx)(mq,{asChild:!0,children:(0,W.jsxs)(Y,{variant:`outline`,children:[(0,W.jsx)(D1,{className:`size-4 shrink-0`}),(0,W.jsx)(`span`,{children:`Schema`}),(0,W.jsx)(Zf,{className:`size-4 shrink-0`})]})}),(0,W.jsxs)(hq,{align:`end`,children:[(0,W.jsxs)(_q,{onSelect:()=>{i(`graphql-schema-open`,{account:n.account.name,project:n.project.name,environment:n.environment.name}),r({pathname:fo(Cb.Code,{account:n.account.name,project:n.project.name,environment:encodeURIComponent(n.environment.urlParameter)}),search:`?path=${w8}`})},children:[(0,W.jsx)(gp,{className:`size-4`}),(0,W.jsx)(`span`,{children:`Open Schema`})]}),(0,W.jsxs)(_q,{disabled:!c,onSelect:()=>o(!0),children:[(0,W.jsx)(cp,{className:`size-4`}),(0,W.jsx)(`span`,{children:`Download Schema`})]})]})]}),a&&c&&(0,W.jsx)(VHt,{endpointUrl:c,rewriteUrl:t,ape:n,onClose:()=>o(!1)})]})},UHt=({operationTags:e,onTagsChanged:t})=>{let{isReadOnly:n}=YZ(),r=g1(),[i,a]=(0,U.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,W.jsxs)(IT,{children:[(0,W.jsx)(LT,{asChild:!0,children:(0,W.jsxs)(S6,{children:[(0,W.jsx)(Ip,{size:16}),e.length===1?(0,W.jsx)(`span`,{className:`truncate max-w-[12ch]`,title:e[0],children:e[0]}):`${e.length} Tags`]})}),(0,W.jsxs)(RT,{className:`w-64 p-0 z-100`,align:`end`,children:[(0,W.jsx)(`div`,{className:`px-3 pt-3 pb-2`,children:(0,W.jsx)(`h4`,{className:`text-sm font-medium`,children:`Operation Tags`})}),o.length>0&&(0,W.jsx)(`div`,{className:`border-t max-h-48 overflow-y-auto`,children:o.map(t=>(0,W.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,W.jsx)(`span`,{className:`truncate`,children:t}),(0,W.jsx)(Xf,{size:14,className:G(`shrink-0`,!e.includes(t)&&`invisible`)})]},t))}),!n&&(0,W.jsx)(`div`,{className:`border-t p-2`,children:(0,W.jsxs)(`form`,{className:`flex gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,W.jsx)(nE,{value:i,onChange:e=>a(e.target.value),placeholder:`New tag...`,className:`h-7 text-xs`}),(0,W.jsx)(Y,{type:`submit`,variant:`outline`,size:`icon-sm`,disabled:!i.trim(),children:(0,W.jsx)(Op,{size:14})})]})})]})]})},WHt=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 T8(e,t){try{return e.startsWith(`#`)?WHt.get(t,e.replace(`#`,``)):WHt.get(t,e)}catch(e){console.error(`Error resolving schema reference. Reference may be invalid or referencing an external document.`,e);return}}var GHt=(e,t)=>{let n=e;return!n||`$ref`in n&&(n=T8(n.$ref,t),!n)?``:n.example?n.example:n.examples&&n.examples.length>0?n.examples[0]:n.default?n.default:``},KHt=(e,t)=>{if(e.examples&&Object.keys(e.examples).length>0){let n=Object.values(e.examples)[0];if(`$ref`in n){let e=T8(n.$ref,t);if(!e)return``;n=e}return n.value}if(e.example)return e.example;let n=e.schema;return GHt(n,t)},qHt=(e,t)=>{let n=e.requestBody;if(!n)return``;if(`$ref`in n){let e=T8(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=T8(e.$ref,t);if(!n)return``;e=n}return e.value}let a=i.schema;return GHt(a,t)},JHt=JSON.stringify({query:`{ __schema { queryType { name } } }`},null,2),YHt=new ZGe,XHt=e=>e.additionalOperationContext.method.split(`,`).map(e=>e.toUpperCase()),E8=e=>{let{oasFilePath:t,method:n,path:r}=e.additionalOperationContext;return`${t}::${e.operationId??`${n} ${r}`}`},ZHt=({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=XHt(t)[0],i=t[KX]===!0,a=ZX(t),o=qHt(t,n),s=YHt.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]:KHt(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?ZP:i?JHt: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,U.useState)(n),[f,p]=(0,U.useState)(()=>l(n,r)),[m,h]=(0,U.useState)(o),g=cm(e=>e.setTestResponse),_=fm(),v=s??_,y=(0,U.useMemo)(()=>({...v,[n.additionalOperationContext.oasFilePath]:r}),[v,n.additionalOperationContext.oasFilePath,r]),b=(0,U.useMemo)(()=>Object.entries(y).flatMap(([e,t])=>h1(e,t)),[y]),x=(0,U.useMemo)(()=>b.map(e=>({id:E8(e),method:e.additionalOperationContext.method,path:e.additionalOperationContext.path,summary:e.summary,file:e.additionalOperationContext.oasFilePath})),[b]);return(0,U.useEffect)(()=>{g(void 0)},[]),(0,W.jsx)(`div`,{className:`flex h-[650px] max-h-[70vh] flex-col`,children:(0,W.jsx)(xat,{ape:e,apiTest:f,showRebuildWarning:i,allowedMethods:XHt(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:E8(u),onSelectEndpoint:e=>{if(e===E8(u))return;let t=b.find(t=>E8(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},E8(u))})},QHt=({envUrl:e,ape:t,operation:n,openApiDocument:r,showRebuildWarning:i,entries:a,onClose:o,defaultEndpointsPanelOpen:s})=>(0,W.jsx)(xY.Provider,{value:{entries:a},children:(0,W.jsx)(`div`,{className:`w-full text-muted-foreground`,children:(0,W.jsx)(ZHt,{openApiDocument:r,ape:t,envUrl:e,showRebuildWarning:i,operation:n,onClose:o,defaultEndpointsPanelOpen:s})})}),$Ht=({open:e,onOpenChange:t,onProceed:n})=>{let{saveAndDeploy:r,isPending:i}=fht();return(0,W.jsx)(tT,{open:e,onOpenChange:t,children:(0,W.jsxs)(iT,{className:`sm:max-w-md`,children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:`Unsaved changes`}),(0,W.jsx)(cT,{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,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`ghost`,onClick:n,disabled:i,children:`Continue without saving`}),(0,W.jsx)(Y,{variant:`default`,onClick:async()=>{try{await r()}catch{return}n()},disabled:i,children:(0,W.jsx)(CP,{loading:i,children:`Save changes`})})]})]})})},eUt=(0,U.lazy)(()=>Cn(()=>import(`./GraphiQLConsole-DwFr-ErF.js`),__vite__mapDeps([9,1,2,8,10,11,12]))),tUt=({path:e,method:t,summary:n,operationData:r,hasFileChanged:i,isGraphql:a})=>{let{logEvent:o}=H(),s=nm(),c=g1().getOpenApiDataEnforced(),{entries:l}=(0,U.useContext)(xY),u=sF(s.environment),[d,f]=(0,U.useState)(null),p=u?new URL(e,u).toString():void 0,m=Sne({mutationKey:nst})>0,[h,g]=I$(()=>(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,W.jsx)(tT,{open:!0,onOpenChange:e=>!e&&g(),children:(0,W.jsxs)(iT,{showCloseButton:!1,className:`max-w-6xl! w-full gap-0 overflow-hidden p-0`,children:[(0,W.jsx)(sT,{className:`sr-only`,children:`Test route`}),(0,W.jsx)(QHt,{envUrl:u??``,showRebuildWarning:i,ape:s,entries:l,operation:r,openApiDocument:c,onClose:g})]})})),[e,t,n,r,l,a]),[_,v]=I$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:`POST`,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:`graphiql`}),(0,W.jsx)(tT,{open:!0,onOpenChange:e=>!e&&v(),children:(0,W.jsxs)(iT,{className:`max-w-6xl! w-full p-0 overflow-hidden`,children:[(0,W.jsx)(sT,{className:`sr-only`,children:`GraphiQL`}),(0,W.jsx)(`div`,{className:`h-[80vh] w-full`,children:(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:`Loading GraphiQL…`}),children:(0,W.jsx)(eUt,{url:p??``,ape:s})})})]})})),[p,s]),y=e=>{e===`graphiql`?_():h()},b=e=>{if(i){f(e);return}y(e)},x=(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{children:`Saving`}),(0,W.jsx)(SP,{color:`current`})]}),S=m?`Saving`:`Test Route`;return(0,W.jsxs)(W.Fragment,{children:[a?(0,W.jsxs)(pq,{children:[(0,W.jsx)(mq,{asChild:!0,children:(0,W.jsx)(Y,{variant:`brand`,disabled:m,"aria-label":S,children:(0,W.jsxs)(CP,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,W.jsx)(Wp,{className:`shrink-0 fill-current`}),(0,W.jsx)(`span`,{children:`Test Route`}),(0,W.jsx)(Zf,{className:`size-4 shrink-0`})]})})}),(0,W.jsxs)(hq,{align:`end`,children:[(0,W.jsxs)(_q,{onSelect:()=>b(`playground`),children:[(0,W.jsx)(Wp,{className:`size-4`}),(0,W.jsx)(`span`,{children:`Playground`})]}),(0,W.jsxs)(_q,{disabled:!p,onSelect:()=>b(`graphiql`),children:[(0,W.jsx)(D1,{className:`size-4`}),(0,W.jsx)(`span`,{children:`GraphiQL`})]})]})]}):(0,W.jsx)(Y,{variant:`brand`,disabled:m,"aria-label":S,onClick:()=>b(`playground`),children:(0,W.jsxs)(CP,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,W.jsx)(Wp,{className:`shrink-0 fill-current`}),(0,W.jsx)(`span`,{children:`Test Route`})]})}),(0,W.jsx)(U.Suspense,{fallback:null,children:(0,W.jsx)($Ht,{open:d!==null,onOpenChange:e=>{e||f(null)},onProceed:()=>{let e=d;f(null),e&&y(e)}})})]})},nUt=({onRequestHandlerChange:e,isReadOnly:t,routeHandler:n})=>{let r=k1(n),i=(t,i)=>{e({...n,options:{...r.options,[t]:i}})};return(0,W.jsxs)(lk,{className:`p-4 bg-surface-sunken`,children:[(0,W.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-base font-medium`,children:`MCP Server Options`}),(0,W.jsx)(tE,{showIcon:!0,href:`https://docs.zuplo.com/handlers/mcp-server`,className:`text-sm text-zuplo-pink`,children:`MCP Server Docs`})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-12 gap-4 col-span-full items-center`,children:[(0,W.jsx)(`div`,{className:`col-span-8`,children:(0,W.jsx)(b6,{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,W.jsx)(`div`,{className:`col-span-4`,children:(0,W.jsx)(b6,{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,W.jsxs)(`div`,{className:`col-span-12 mt-2`,children:[(0,W.jsx)(rE,{className:`text-sm mb-2 block`,children:`Advanced Options`}),(0,W.jsx)(`div`,{className:G(`flex gap-4`,t&&`opacity-50`),children:(0,W.jsxs)(`label`,{className:`text-sm flex items-center gap-2`,children:[(0,W.jsx)(PY,{"data-test":`mcp-debug-mode`,checked:!!r.options.debugMode,onCheckedChange:e=>{i(`debugMode`,e)},disabled:t}),`Debug Mode`]})})]})]})]})},rUt=({routeHandler:e,operation:t,isReadOnly:n,onRequestHandlerChange:r})=>{let{captureRaw:i}=H(),a=Pxt(),o=k1(e),s=typeof o.options.rewritePattern==`string`?o.options.rewritePattern:``,c=_zt(()=>{i(`mcp-gateway-upstream-url-edited`)});return(0,W.jsx)(lk,{className:`p-4`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground font-medium`,children:`Upstream MCP server`}),!!(a&&t)&&(0,W.jsxs)(Y,{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,W.jsx)(jp,{className:`w-3.5 h-3.5`}),`Edit MCP Server Policy`]})]}),(0,W.jsx)(d3,{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 iUt(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 aUt({operationData:e,addRouteMenuProps:t}){return e?(0,W.jsx)(`div`,{className:`w-full h-full min-h-0 overflow-y-auto px-4 pt-2 pb-4`,children:(0,W.jsx)(sUt,{operationData:e})}):(0,W.jsx)(zbt,{...t})}var oUt=()=>{let e=dm(),t=fm(),n=(0,U.useMemo)(()=>e.flatMap(e=>{let n=t[e.path];return n?h1(e.path,n).filter(e=>ZX(e)).map(t=>[e,t]):[]}),[e,t]);return{getLinkedMcpServers:(e,t)=>n.filter(([,n])=>{let r=n[JX]?.handler;return YX(r)?r.options?.operations?.some(n=>E1(n.file)===e&&n.id===t):!1})}},sUt=({operationData:e})=>{let[t]=SY(`path`);if(!t)throw Error(`Open API file path not found in URL`);let n=dht(t),r=nm(),{logEvent:i}=H(),{additionalOperationContext:a,...o}=e,{path:s,method:c}=a,l=g1(),u=em(),d=j1(),{isReadOnly:f}=YZ(),[p,m]=(0,U.useState)(),[h,g]=(0,U.useState)();oUt();let _=l.openApiData?.servers?.at(0)?.url,v=o[JX]??v1(_??`https://echo.zuplo.io`),y=o[GX]===!0,b=o.deprecated===!0,x=o[KX]===!0,S=l.openApiFileModel.saveState!==eu.unmodified,C=v.handler,w=YX(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,[JX]:{...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,[GX]: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[KX]=!0,Cbt(d),n[JX]=Sbt(v,!0)):(delete n[KX],o[JX]&&(n[JX]=Sbt(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,[JX]: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,[qX]:a}),i(`route-path-mode-changed`,{pathMode:n,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},L=()=>{n(eu.modified)};return(0,W.jsxs)(`div`,{className:`mb-4 flex flex-col gap-6`,children:[(0,W.jsxs)(lk,{className:`bg-neutral-50 dark:bg-transparent`,children:[(0,W.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,W.jsxs)(uk,{children:[(0,W.jsx)(dk,{children:`Request Handling`}),(0,W.jsx)(fk,{})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 p-6`,children:[x&&(0,W.jsx)(HHt,{path:s,rewriteUrl:typeof C.options?.rewritePattern==`string`?C.options?.rewritePattern:void 0}),(0,W.jsx)(gVt,{operationData:e}),(0,W.jsx)(tUt,{path:s,method:c,summary:o.summary??``,operationData:e,hasFileChanged:S,isGraphql:x})]})]}),(0,W.jsxs)(pk,{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,W.jsx)(EVt,{isReadOnly:f,initialPath:s,method:c,onChangeMethod:N,pathMode:e.additionalOperationContext.pathZuploConfig?.pathMode,hasError:p!=null,onPathChange:M,onPathModeChange:I,onFieldModified:L,isMcpToolHandler:YX(C)||XX(C)}),p&&(0,W.jsx)(sb,{"data-test":`path-error`,className:`col-span-full p-2`,variant:`destructive`,children:(0,W.jsx)(lb,{children:p})}),w&&(0,W.jsx)(sb,{className:`col-span-full p-2 py-1`,variant:`destructive`,children:(0,W.jsxs)(lb,{"data-test":`request-handler-error`,className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{children:w}),(0,W.jsx)(Y,{onClick:()=>N(`post`),size:`xs`,variant:`outline`,className:`border-none`,children:`Switch to POST method`})]})}),(0,W.jsx)(KFt,{isReadOnly:f,initialSummary:o.summary,onSummaryChange:E,onFieldModified:L}),(0,W.jsx)(_Vt,{isReadOnly:f,defaultOperationId:e.operationId,openApiManager:l,path:s,method:c,operationData:e})]}),(0,W.jsxs)(mk,{className:`flex flex-wrap gap-2 px-3 py-1.5 bg-card justify-end`,children:[(0,W.jsx)(UHt,{operationTags:o.tags??[],onTagsChanged:F}),(0,W.jsx)(Yzt,{isReadOnly:f,selectedCorsPolicy:v.corsPolicy,corsPolicies:d.corsPolicyList??[],onSelectionChanged:P}),!YX(v.handler)&&!XX(v.handler)&&(0,W.jsx)(SVt,{operation:e,defaultValues:iUt(v.mcp),onSubmit:e=>{let t={...v,mcp:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[JX]:t}})}}),(0,W.jsx)(WBt,{isExcludedFromDocs:y,onVisibilityChanged:O}),(0,W.jsx)(DVt,{isGraphql:x,onGraphqlChanged:A,isDeprecated:b,onDeprecatedChanged:k})]})]}),(0,W.jsx)(uzt,{inboundPolicies:v.policies?.inbound??[],outboundPolicies:v.policies?.outbound??[],operation:e,children:(0,W.jsx)(cUt,{isReadOnly:f,operationData:e,handler:v.handler,firstServerUrl:_,onRequestHandlerChange:T})}),(0,W.jsx)(UBt,{initialDescription:o.description??``,onChange:D,path:s,method:c,oasFilePath:t})]})},cUt=({operationData:e,handler:t,firstServerUrl:n,isReadOnly:r,onRequestHandlerChange:i})=>{let a=(e[JX]??v1(n??`https://echo.zuplo.io`)).handler;switch(t.export){case`mcpServerHandler`:return(0,W.jsx)(nUt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i});case`McpProxyHandler`:case`McpVirtualServerHandler`:case`mcpVirtualServerHandler`:return(0,W.jsx)(rUt,{routeHandler:a,operation:e,isReadOnly:r,onRequestHandlerChange:i});default:return(0,W.jsx)(Gzt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i})}},lUt=Me()(e=>({updateLinkedMcpServers:void 0,setUpdateLinkedMcpServers:t=>e({updateLinkedMcpServers:t})})),uUt=()=>{let e=F(lUt,e=>e.updateLinkedMcpServers),t=lQ(),n=()=>{lUt.setState({updateLinkedMcpServers:void 0})};return(0,W.jsx)(tT,{open:!!e,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(iT,{children:[(0,W.jsx)(sT,{children:`MCP Server Links`}),(0,W.jsx)(cT,{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,W.jsx)(`div`,{className:`flex gap-2 items-center justify-center`,children:e?.linkedMcpServers.map(([,e])=>(0,W.jsx)(qT,{children:e},e))}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`outline`,onClick:n,children:`Cancel`}),(0,W.jsx)(Y,{onClick:()=>{e?.linkedMcpServers.forEach(([n,r])=>{let i=new lbt(n,t),a=i.getOperationById(r);if(!a)return;let o=a[JX];if(!o)return;let s=o.handler;if(YX(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:K$(t,`operationId`,e.newOperationId)})}i.updateOperation({path:a?.additionalOperationContext.path,method:a.additionalOperationContext.method,newOperationObject:K$(a,`${JX}.handler.options.operations`,s.options?.operations?.map(t=>E1(t.file)===n.path?{...t,id:t.id===e.oldOperationId?e.newOperationId:t.id}:t))})}})},children:`Update`})]})]})})},dUt=`$import(@zuplo/runtime)`,fUt=`${dUt}::urlForwardHandler`,pUt=`${dUt}::urlRewriteHandler`,mUt=(e,t)=>{let n=e.options?.[t],r=typeof n==`string`?n.trim():``;return r.length>0?r:void 0},hUt=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)},gUt=e=>{if(e){let t=`${e.module}::${e.export}`,n=t===fUt?mUt(e,`baseUrl`):t===pUt?mUt(e,`rewritePattern`):void 0;if(n){let e=hUt(n);return{key:`target:${e}`,label:e,mono:!0,icon:bp,collapsible:!0}}}return{...Sxt(e),collapsible:!1}};function _Ut(){let e=g1(),{captureRaw:t}=H(),n=nm(),r=oQ();return i=>{e.updateInfo(i),t(`openapi-info-updated`);let{projectTreeNodes:a,filesByPath:o}=cm.getState(),s=a.map(e=>e.path?o[e.path]:void 0).filter(e=>!!e&&e.saveState===eu.modified);s.length!==0&&r.mutateAsync({environmentName:n.environment.name,accountName:n.account.name,projectName:n.project.name,files:s}).catch(()=>{})}}var D8=`Document Order`,vUt=[`Document Order`,`Path`,`Summary`],O8=`Untagged`,yUt=[{value:`none`,label:`None`},{value:`path`,label:`Path`},{value:`handler`,label:`Handler type`},{value:`target`,label:`Target`}],bUt=new Set([`handler`,`target`]);function xUt(e){return`${e}-${fe().split(`-`).at(0)}`}function k8(e){return new Set(e.getPolicyListEnforced().map(e=>e.name))}function SUt(e){if(!e)return;let t=LFt(e.getPolicyListEnforced());if(t)return t.name;let n=v3(FFt,k8(e));return e.createPolicy(IFt(n)),n}var CUt=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}},wUt=e=>t=>{if(e.length===0)return!0;let n=t.tags;return!n||n.length===0?e.includes(O8):n.some(t=>e.includes(t))},TUt=({onNavigateToOpenApiFileTab:e})=>{let{logEvent:t,captureRaw:n}=H(),[r,i]=yit(`tags`,[]),[a,o]=BT(`open-api-designer-group-by`,`none`);(0,U.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,U.useState)(!1),[l,u]=(0,U.useState)(`details`),[d,f]=(0,U.useState)(!1),p=_Ut(),m=(0,U.useRef)(null);(0,U.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,U.useState)(),[_,v]=(0,U.useState)(),[y,b]=(0,U.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,U.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}=YZ(),[E,D]=SY(`operation`),[O,k]=BT(`default-sort-routes`,D8),[A,j]=SY(`sort`,O);(0,U.useEffect)(()=>{A&&k(A)},[k,A]),(0,U.useEffectEvent)(()=>{if(E)try{document.querySelector(`#op-${E}`)?.scrollIntoView()}catch{}});let[M,N]=(0,U.useState)(void 0),P=g1(),F=j1(),I=kP(),L=uQ(Cxt),R=dQ(),z=()=>{if(L)return Txt(L.content??``)?`ok`:`manual`;let e=wxt,t={path:Cxt,content:e,type:$l.File,saveState:eu.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:eu.modified}),`ok`},{results:B,setSearchTerm:V,searchTerm:ee}=rxt(P.operationArray?.filter(wUt(r)).sort(CUt(A))??[],{keys:[e=>e.additionalOperationContext.path,e=>e.summary??``,e=>e.operationId,e=>e.additionalOperationContext.method]});(0,U.useEffect)(()=>{let e=ee?.trim()??``;if(e.length===0)return;let n=setTimeout(()=>{t(`route-search-used`,{view:`routes`,query:e,queryLength:e.length})},600);return()=>clearTimeout(n)},[ee,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[JX]?.handler,c=a===`target`?gUt(e):{...Sxt(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,U.useState)(),[ie,ae]=(0,U.useState)(),[oe,se]=(0,U.useState)(!1),ce=(0,U.useMemo)(()=>{if(!_)return[];let e=(P.operationArray?.find(e=>e.additionalOperationContext.path===_.path&&e.additionalOperationContext.method===_.method))?.[JX]?.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,U.useState)(()=>new Set);(0,U.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})},pe=()=>{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),me())}v(void 0),se(!1)},[me,he]=I$(()=>{let t=()=>{N(void 0),he()};return(0,W.jsx)(SQ,{alertType:`ERROR`,bodyText:M??``,onPrimaryButtonClick:e,onSecondaryButtonClick:t,primaryButtonText:`Edit file directly`,secondaryButtonText:`Cancel`,hideModal:t,title:`Error`})},[M]),[ge,_e]=I$(()=>(0,W.jsx)(SQ,{alertType:`CAUTION`,bodyText:`Cannot reorder in this view — view by Document Order to reorganize the order of operations.`,onPrimaryButtonClick:()=>{j(D8),_e()},onSecondaryButtonClick:_e,primaryButtonText:`Switch to Document Order`,secondaryButtonText:`Cancel`,hideModal:_e,title:`Cannot reorder`})),[ve,ye]=I$(()=>(0,W.jsx)(Dxt,{open:!0,onOpenChange:e=>{e||ye()}})),be=(e,t)=>{if(A!==D8){ge();return}P.movePathInDocument(e,t)};if(!P.openApiData)throw Error(`Invalid State - no OpenApiData`);let xe=P.openApiData.info,Se=P.openApiData.tags?.map(e=>({value:e.name,label:e.name}));Se?.push({value:O8,label:O8});let Ce=()=>{let e=C1.OpenAPIV3.HttpMethods.GET,n=P.openApiData?.servers?.at(0)?.url,r=bbt(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),me())}t(`route-added`)},we=(e,n,r)=>{let i=P.openApiData?.servers?.at(0)?.url,a=bbt(i??`https://echo.zuplo.io`),o=r?.[JX],s=a[JX];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),me())}t(`route-added`)},Te=()=>{let e=C1.OpenAPIV3.HttpMethods.POST,n=xUt(`mcp`),r=P.addOperation(`/mcp`,e,{summary:`MCP Server`,description:`Default MCP Server`,[JX]:{corsPolicy:`none`,handler:{export:`mcpServerHandler`,module:`$import(@zuplo/runtime)`,options:{operations:[]}},policies:{inbound:[]}},operationId:n},{avoidConflict:!0});r&&D(r),t(`route-added`)},Ee=()=>{let e=C1.OpenAPIV3.HttpMethods.POST,n=wbt(`https://rickandmortyapi.com/graphql`);try{Cbt(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),me())}t(`route-added`)},De=()=>{let e=C1.OpenAPIV3.HttpMethods.GET,n=Tbt();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),me())}t(`route-added`)},[Oe,ke]=(0,U.useState)(!1),[Ae,je]=(0,U.useState)(),[Me,Ne]=(0,U.useState)(0),Pe=(0,U.useMemo)(()=>{let e=new Set(Object.keys(P.openApiData?.paths??{}));return Ae&&e.delete(Ae.path),e},[P.openApiData?.paths,Ae]),Fe=async e=>{let n;try{n=z()}catch(e){if(e instanceof Error){N(e.message),me();return}throw e}let r;try{r=zFt({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),me();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),me())}t(`route-added`),t(`mcp-gateway-create-virtual-mcp-submitted`,BFt(e)),n===`manual`&&ve()},Ie=()=>{Ne(e=>e+1),ke(!0)},Le=e=>{let t=EFt({operationPath:e.additionalOperationContext.path,operation:e,policyList:F?.getPolicyListEnforced()??[]});t&&(Ne(e=>e+1),je({initialResult:t,path:e.additionalOperationContext.path,method:e.additionalOperationContext.method,operationId:e.operationId}))},Re=async e=>{let t=Ae;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){je(void 0);return}let s;try{s=z()}catch(e){if(e instanceof Error){N(e.message),me();return}throw e}let c=NFt(e.step1.name),l=o0(e.step1.mcpUrl),u=l?.protectedResourceMetadataUrl??RFt(e.step1.mcpUrl),d=o[JX]?.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===Z4),g=m.find(e=>e.policyType===Q4),_=m.find(e=>e.policyType===`remove-headers-inbound`&&$4(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),me();return}}else if(F){y=v3(`mcp-upstream-${c}`,k8(F));try{F.createPolicy({name:y,policyType:Z4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpTokenExchangeInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),me();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),me();return}}}let x;if(e.step2.catalogMode===`curated`){let t=G4(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),me();return}}else if(F){x=v3(`mcp-filter-${c}`,k8(F));try{F.createPolicy({name:x,policyType:Q4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpCapabilityFilterInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),me();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),me();return}}let C;if(e.step1.authMode===`none`&&e.step1.noAuthBehavior===`strip`)try{C=_?.name??SUt(F)}catch(e){if(e instanceof Error){N(e.message),me();return}}let w=[S,x,y,b,C].filter(e=>!!e),T=o[JX],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})`,[JX]:{...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),me();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}),je(void 0),s===`manual`&&ve()},ze=(0,U.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,U.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-${fe().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),me())}t(`route-added`,{httpPath:o,httpMethod:n,duplicate:!0})},Ve=()=>{f(!0),u(`tags`),c(!0)},He=Ae!==void 0,Ue=(0,W.jsx)(DFt,{isOpen:Oe||He,existingPaths:Pe,mode:He?`edit`:`create`,initialResult:Ae?.initialResult,onClose:()=>{ke(!1),je(void 0)},onFinish:He?Re:Fe},`mcp-wizard-${Me}`),We={onAddRest:Ce,onAddGraphql:Ee,onAddWebSocket:De,onAddMcpVirtual:Ie,onAddMcpServer:Te,onAddTag:Ve};return P.operationArray?.length===0&&(!ee||ee.trim().length===0)?(0,W.jsxs)(W.Fragment,{children:[Ue,(0,W.jsx)(zbt,{...We})]}):(0,W.jsxs)(`div`,{className:`ms-2 grid grid-cols-3 h-full grow`,children:[(0,W.jsx)(N$,{open:oe,onOpenChange:e=>{se(e),e||v(void 0)},onClickDelete:pe,title:`Delete`,deleteButtonText:`Confirm`,children:ce.length===0?`Are you sure you want to delete this operation?`:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.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,W.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,W.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2`,children:[(0,W.jsx)(PY,{id:t,checked:le.has(e.name),onCheckedChange:t=>de(e.name,t===!0),className:`mt-0.5`}),(0,W.jsxs)(`label`,{htmlFor:t,className:`flex flex-col gap-0.5 text-left cursor-pointer min-w-0`,children:[(0,W.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.name}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e.policyType})]})]},e.name)})})]})}),(0,W.jsx)(uUt,{}),Ue,xe&&(0,W.jsx)(WFt,{open:s,onOpenChange:c,info:xe,onSave:p,defaultTab:l,tagsAutoCreate:d,onTagsAutoCreateConsumed:()=>f(!1)}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 justify-start h-full pt-2 min-h-0`,children:[(0,W.jsxs)(`div`,{className:`flex justify-between gap-x-2`,children:[(0,W.jsx)(`div`,{className:`flex gap-1`,children:(0,W.jsxs)(pq,{children:[(0,W.jsx)(mq,{className:`flex group select-none`,asChild:!0,children:(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,title:`Filter and sort routes`,children:[(0,W.jsx)(pte,{size:16}),`Filter`]})}),(0,W.jsxs)(hq,{className:`min-w-[220px]`,align:`start`,children:[(0,W.jsx)(xq,{children:`Sort by`}),(0,W.jsx)(gq,{children:vUt.map(e=>(0,W.jsxs)(_q,{onClick:()=>j(e),className:`justify-between`,children:[e,(0,W.jsx)(Xf,{className:G(`mr-2`,e!==A&&`invisible`),size:16})]},e))}),(0,W.jsx)(Sq,{}),(0,W.jsx)(xq,{children:`Filter by tag`}),(0,W.jsx)(gq,{className:`max-h-60 overflow-y-auto`,children:Se?.map(e=>(0,W.jsxs)(_q,{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,W.jsx)(Xf,{className:G(`mr-2`,!r.includes(e.value)&&`invisible`),size:18})]},e.label))}),(0,W.jsx)(Sq,{}),(0,W.jsx)(xq,{children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Ete,{size:16}),`Group by`]})}),(0,W.jsx)(gq,{children:yUt.map(e=>(0,W.jsxs)(_q,{onClick:t=>{t.stopPropagation(),t.preventDefault(),o(e.value)},className:`justify-between`,children:[e.label,(0,W.jsx)(Xf,{className:G(`mr-2`,a!==e.value&&`invisible`),size:16})]},e.value))})]})]})}),T?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>{f(!1),u(`details`),c(!0)},"aria-label":`API Settings`,title:`API Settings`,children:(0,W.jsx)(Dp,{size:16})}),(0,W.jsxs)(pq,{children:[(0,W.jsx)(mq,{asChild:!0,children:(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,"data-test":`add-route-btn`,className:`relative gap-0.5!`,children:[(0,W.jsx)(`div`,{className:`absolute w-1.5 h-1.5 rounded-full -top-0.5 -right-[3px] bg-zuplo-700`}),(0,W.jsx)(Op,{"aria-hidden":`true`,className:`size-3.5`}),`Add`]})}),(0,W.jsx)(hq,{children:(0,W.jsx)(Rbt,{...We})})]})]})]}),(0,W.jsx)(kY,{onClearValue:()=>V(``),value:ee,showClearButton:!!ee&&ee.length>0,children:(0,W.jsx)(nE,{ref:m,value:ee,onChange:e=>V(e.target.value),placeholder:`Search Routes`,className:`px-8`})}),r.length>0&&(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,W.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,W.jsx)(Ip,{size:11,className:`shrink-0 text-muted-foreground`}),(0,W.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,W.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-surface-emphasis hover:text-neutral-900 dark:hover:text-foreground`,children:(0,W.jsx)(Up,{size:11})})]},e))}),(0,W.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,W.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,W.jsxs)(`div`,{children:[e.collapsible?(0,W.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,W.jsx)(Zf,{size:15,className:`shrink-0 text-muted-foreground`}):(0,W.jsx)(Qf,{size:15,className:`shrink-0 text-muted-foreground`}),o&&(0,W.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,W.jsx)(`span`,{className:`truncate font-mono`,title:e.label,children:e.label}),s]}):a!==`none`&&(0,W.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,W.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,W.jsx)(`span`,{className:G(`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[JX]?.handler,s=YX(o),c=XX(o),l=s?o.options?.operations?.length??0:0,u=l>0,d=y.has(r.operationId);return(0,W.jsxs)(U.Fragment,{children:[(0,W.jsx)(uxt,{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:we,onDuplicate:()=>Be(e.path,e.method,r),onMoveUp:bUt.has(a)?void 0:()=>be(e.path,`up`),onMoveDown:bUt.has(a)?void 0:()=>be(e.path,`down`),isFirstPath:A===D8&&t===0,isLastPath:A===D8&&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,W.jsx)(Mxt,{handler:o,operation:{...r,additionalOperationContext:e}})]},r.operationId)})]},e.key)})})]}),(0,W.jsx)(`div`,{className:`col-span-2 flex flex-col h-full overflow-y-auto`,children:(0,W.jsx)(y3.Provider,{value:{setPath:re,setSummary:ae},children:(0,W.jsx)(Nxt.Provider,{value:Le,children:(0,W.jsx)(aUt,{operationData:ze,addRouteMenuProps:We})})})})]})},EUt={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`}},A8=({icon:e,operations:t,title:n,tone:r})=>{let i=EUt[r];return(0,W.jsxs)(`section`,{className:`rounded-2xl p-4 shadow-sm ${i.shell}`,"aria-label":`${n} operations`,children:[(0,W.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-semibold text-foreground`,children:[(0,W.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-xl ${i.icon}`,children:e}),n,` operations`]}),(0,W.jsx)(`div`,{className:`rounded-full px-2.5 py-1 text-xs font-medium tabular-nums ${i.count}`,children:t.size})]}),(0,W.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,W.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,W.jsx)(AY,{className:`w-14`,method:n}),(0,W.jsx)(`span`,{className:`break-all text-foreground/90`,children:r})]},e)})})]})},DUt=({openApiFileModel:e,onOpenApiFileSynced:t,setIsOpen:n})=>{let[r,i]=(0,U.useState)(),a=em(),o=e=>{i(e)},s=async()=>{if(!r)throw Error(`No file selected`);let i=e.content?JSON.parse(e.content):null;t(i?Aft(i,r.content):r.content),n(!1),a.success(`OpenAPI file merged successfully`,{icon:(0,W.jsx)(Jhe,{className:`h-4 w-4`})})};if(r){let t=Fft(JSON.parse(e.content??`{}`),r.content);return(0,W.jsx)(b1,{isOpen:!0,setIsOpen:n,title:`Review OpenAPI import`,className:`sm:max-w-4xl max-h-[88vh] overflow-y-auto`,icon:(0,W.jsx)(Py,{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,W.jsxs)(`div`,{className:`mt-6 text-left text-sm`,children:[(0,W.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,W.jsxs)(`div`,{className:`rounded-[calc(1.5rem-1px)] bg-background p-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[1fr_auto_1fr] md:items-center`,children:[(0,W.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-brand/10 text-brand`,children:(0,W.jsx)(yge,{className:`h-5 w-5`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Import file`}),(0,W.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:r.name})]})]})}),(0,W.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,W.jsx)(Py,{className:`h-5 w-5`})}),(0,W.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.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,W.jsx)(By,{className:`h-5 w-5`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Current API`}),(0,W.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:e.path})]})]})})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2 text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:`Operations are matched by`}),(0,W.jsx)(qT,{variant:`outline`,children:`Path + method`}),(0,W.jsx)(`span`,{children:`so existing Zuplo extensions and policies stay in place.`})]})]})}),(0,W.jsxs)(`div`,{className:`mt-6 flex items-end justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:`Import summary`}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Review what will change before applying this file.`})]}),(0,W.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,W.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,W.jsx)(A8,{icon:(0,W.jsx)(zge,{className:`h-4 w-4`}),title:`Create`,tone:`create`,operations:t.created}):null,t.merged.size>0?(0,W.jsx)(A8,{icon:(0,W.jsx)(Ige,{className:`h-4 w-4`}),title:`Update`,tone:`update`,operations:t.merged}):null,t.retained.size>0?(0,W.jsx)(A8,{icon:(0,W.jsx)(Yhe,{className:`h-4 w-4`}),title:`Keep`,tone:`keep`,operations:t.retained}):null]})]})})}return(0,W.jsx)(Mbt,{title:`Import OpenAPI`,onValidFileSelected:o,setIsOpen:n})},OUt=()=>{let e=P(),t=I({mutationFn:t=>e.fetch(V.users.updatePreferences(t))}),{data:n}=Ob(R.user.preferences());return{preferences:n,updatePreferences:t.mutate,updatePreferencesMutation:t}},kUt=!1;function j8(){let e=Je(),{preferences:t,updatePreferencesMutation:n}=OUt();return{isFileTreeOpen:t.fileTreeOpen??kUt,setIsFileTreeOpen:r=>{let i=[R.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 AUt(){let e=cQ(),{logEvent:t}=H(),[n,r]=SY(`v`,`designer`),{isFileTreeOpen:i}=j8(),a=e?.path.split(`/`).pop()??`JSON`,o=lQ(),s=Pbt(),[c,l]=I$(()=>{if(!e)throw Error(`File model not found`);return t(`merge-open-api`),(0,W.jsx)(DUt,{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,W.jsx)(mxt,{children:(0,W.jsx)(dbt,{children:(0,W.jsxs)(tA,{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,W.jsxs)(nA,{className:`rounded-none border-b w-full justify-start`,children:[(0,W.jsx)(rA,{value:`designer`,children:`Route Designer`}),(0,W.jsx)(rA,{value:`raw`,children:a??`Raw`}),(0,W.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:c,className:`ml-4`,children:[(0,W.jsx)(qge,{className:`w-4 h-4`}),` Import`]})]}),(0,W.jsx)(iA,{value:`designer`,className:`grow h-full overflow-y-auto`,children:(0,W.jsx)(ybt,{onNavigateToOpenApiFileTab:()=>r(`raw`),children:(0,W.jsx)(TUt,{onNavigateToOpenApiFileTab:()=>r(`raw`)})})}),(0,W.jsx)(iA,{value:`raw`,className:`grow h-full overflow-y-auto`,forceMount:!0,children:(0,W.jsx)(xQ,{})})]})})})}function jUt({title:e,description:t,folder:n,icon:r,emptyText:i,newLabel:a,onCreate:o}){let s=cm(e=>e.projectTreeNodes),[c,l]=Hl(),{isReadOnly:u}=YZ(),d=n.endsWith(`/`)?n:`${n}/`,f=(0,U.useMemo)(()=>s.filter(e=>e.type===$l.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,W.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:e}),(0,W.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:t})]}),!u&&(0,W.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:o,className:`shrink-0`,children:[(0,W.jsx)(Op,{className:`size-4`}),a]})]}),(0,W.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:f.length===0?(0,W.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,W.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:G(`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,W.jsx)(r,{className:`size-4 shrink-0 text-neutral-500 group-hover:text-brand`}),(0,W.jsx)(`span`,{className:`truncate text-sm font-medium text-neutral-800 dark:text-neutral-200`,children:t})]},e.path)})})]})})}function MUt(){let e=cm(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=j8();return(0,W.jsx)(jUt,{title:`Custom Modules`,description:`TypeScript modules in your project's modules/ folder — request handlers, policies, and other custom code.`,folder:`/modules`,icon:Pte,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 NUt(){let e=cm(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=j8();return(0,W.jsx)(jUt,{title:`Schemas`,description:`JSON schemas in your project's schemas/ folder, used to validate requests and responses.`,folder:`/schemas`,icon:hp,emptyText:`No schemas yet. Create one to validate request or response bodies.`,newLabel:`New Schema`,onCreate:()=>{t(!0),e({strategyFolder:`/schemas`,template:`Schema`})}})}var PUt=()=>{let[e,t]=(0,U.useState)(),{isReadOnly:n}=YZ(),r=j1(),i=r.policiesUsageInfo,{logEvent:a}=H(),o=nm([`account`,`project`,`environment`]),[s,c]=I$(()=>e?(0,W.jsx)(szt,{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,W.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:`Policies`}),(0,W.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,W.jsxs)(pq,{modal:!1,children:[(0,W.jsx)(mq,{asChild:!0,children:(0,W.jsxs)(Y,{variant:`secondary`,size:`sm`,className:`shrink-0`,children:[(0,W.jsx)(Op,{className:`size-4`}),`New Policy`]})}),(0,W.jsxs)(hq,{align:`end`,children:[(0,W.jsxs)(_q,{onClick:()=>l(`inbound`),children:[(0,W.jsx)(Af,{className:`mr-2 size-4`}),`Inbound Policy`]}),(0,W.jsxs)(_q,{onClick:()=>l(`outbound`),children:[(0,W.jsx)(Ff,{className:`mr-2 size-4`}),`Outbound Policy`]})]})]})]}),(0,W.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:u.length===0?(0,W.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,W.jsx)(tE,{href:`https://zuplo.com/docs/overview/policies`,children:`read the docs`}),`.`]}):u.map(e=>(0,W.jsx)(ezt,{policy:e},e.name))})]})})},FUt=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={}))})),IUt=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={}))})),LUt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),RUt=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`})),zUt=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})),BUt=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})),VUt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isValidProjectName=e.MAX_PRETTY_BRANCH_LENGTH=e.MAX_HASH_LENGTH=void 0;var t=BUt();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})),HUt=i({$defs:()=>L8,$id:()=>N8,$schema:()=>M8,additionalProperties:()=>!1,default:()=>UUt,description:()=>``,properties:()=>R8,required:()=>I8,title:()=>P8,type:()=>F8}),M8,N8,P8,F8,I8,L8,R8,UUt,WUt=n((()=>{M8=`https://json-schema.org/draft/2020-12/schema`,N8=`http://schemas.zuplo.com/route.json`,P8=`Route Config File`,F8=`object`,I8=[`routes`,`versions`],L8={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`}]}}}},R8={$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`}},UUt={$schema:M8,$id:N8,title:P8,description:``,type:F8,additionalProperties:!1,required:I8,$defs:L8,properties:R8}})),GUt=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}}})),z8=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})),KUt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=z8(),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}}})),B8=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=z8(),n=KUt(),r=z8();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=KUt();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?`
|
|
1570
1570
|
`:``},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})`}})),V8=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=B8(),n=z8();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})),H8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=B8();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`)}})),U8=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=B8(),n=V8(),r=H8();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])}})),qUt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=U8(),n=B8(),r=H8(),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)}})),JUt=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})),YUt=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})),W8=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=JUt(),n=YUt(),r=U8(),i=B8(),a=V8(),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
|
|
1571
1571
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
1572
1572
|
|| (${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"
|
|
@@ -1577,7 +1577,7 @@ In some cases, you need to provide options to alter GraphQL's execution behavior
|
|
|
1577
1577
|
git clone ${i.sourceRepoUrl}
|
|
1578
1578
|
cd ${i.sourceRepoUrl.split(`/`).pop()}
|
|
1579
1579
|
npm install
|
|
1580
|
-
npm run dev`.trim()})]})]}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`ghost`,onClick:()=>t(!1),children:`Later`}),(0,W.jsx)(Y,{ref:o,onClick:()=>{s(`working-copy-create-clicked`,{account:r.name,project:i.name}),l.mutate({accountName:r.name,projectName:i.name})},children:(0,W.jsx)(CP,{loading:l.isPending,alternative:(0,W.jsx)(TP,{className:`w-4 h-4 border-2 border-white`}),children:`Create working copy`})})]})]})})},lKt=()=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-amber-200 bg-amber-100 px-4 py-1.5 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-200`,"data-test":`read-only-banner`,children:[(0,W.jsx)(dKt,{className:`min-w-0 flex-1`}),(0,W.jsx)(uKt,{className:`ml-auto shrink-0`})]}),uKt=({switchLabel:e,className:t,onActionClick:n})=>{let{project:r}=nm([`project`]);return yD(r)?(0,W.jsx)(iKt,{className:t,onOpenClick:n}):(0,W.jsx)(fKt,{label:e,className:t,onSwitchClick:n})},dKt=({className:e})=>{let t=nm(),n=t.environment.branchName??null,r=VP(t.environment.environmentType,BP.PRODUCTION),i=yD(t.project);return(0,W.jsxs)(`span`,{className:G(`flex items-center gap-x-2 text-xs`,e),"data-test":`read-only-hint`,children:[(0,W.jsx)(fp,{size:14,className:`shrink-0`,"aria-hidden":!0}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`font-semibold`,children:`Read-only`}),` — you are viewing`,` `,n?(0,W.jsxs)(W.Fragment,{children:[`the `,(0,W.jsx)(`span`,{className:`font-medium`,children:n}),` branch`]}):r?`the deployed Production environment`:`a deployed environment`,`.`,` `,i?`To make changes, set up local development.`:`To make changes, switch to Development.`]})]})},fKt=({label:e=`Switch to Development`,variant:t=`outline`,size:n=`sm`,className:r,onSwitchClick:i})=>{let a=nm(),o=y7(),{logEvent:s}=H(),c=sKt(),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(!1),p=qP(a.account.name,a.project.name).data?.find(e=>VP(e.environmentType,BP.WORKING_COPY)),m=a.environment.branchName??null,h=!!(a.project.sourceRepoUrl&&m&&a.project.hasCurrentUserWorkingCopy&&p),g=c||a.project.hasCurrentUserWorkingCopy,_=c||!!p;return g?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Y,{size:n,variant:t,className:r,onClick:()=>{if(i?.(),s(`read-only-banner-switch-to-development-clicked`,{account:a.account.name,project:a.project.name,environment:a.environment.name,action:c?`setup-working-copy`:h?`checkout-dialog`:`navigate`}),c){f(!0);return}if(h){u(!0);return}p&&o({environment:p})},disabled:!_,"data-test":`read-only-switch-to-development`,children:[(0,W.jsx)(Uy,{size:14}),e]}),(0,W.jsx)(cKt,{open:d,onOpenChange:f}),h&&m&&p&&(0,W.jsx)(pKt,{open:l,onOpenChange:u,branchName:m,workingCopyEnvironment:p})]}):null},pKt=({open:e,onOpenChange:t,branchName:n,workingCopyEnvironment:r})=>{let i=nm(),a=em(),o=y7(),{logEvent:s}=H(),c=Lyt(),{data:l,isLoading:u}=ist(r.name,{enabled:e}),d=oKt(l,i.project.defaultBranch,!1,`Checking out`),f=d?.hasLocalWork??!1,p=()=>{s(`read-only-banner-keep-working-copy-clicked`,{account:i.account.name,project:i.project.name,environment:i.environment.name,branch:n}),t(!1),o({environment:r})},m=Iyt({onSuccess:()=>{c(i.account.name,i.project.name),t(!1),a.success(`Checked out ${n} in your working copy`,{title:`Success`,icon:(0,W.jsx)(Xf,{className:`h-4 w-4`})}),o({environment:r})}});return(0,W.jsx)(tT,{open:e,onOpenChange:e=>{m.isPending||t(e)},children:(0,W.jsxs)(iT,{"data-test":`checkout-branch-dialog`,children:[(0,W.jsx)(aT,{children:(0,W.jsx)(sT,{children:`Switch to Development`})}),(0,W.jsxs)(cT,{children:[`Development is your editable working copy. Keep it as it is now, or check out the `,(0,W.jsx)(qT,{variant:`outline`,children:n}),` branch to replace your working copy's files with the latest version of this branch.`]}),d?.hasLocalWork&&(0,W.jsxs)(sb,{variant:`warning`,"data-test":`checkout-working-copy-warning`,children:[(0,W.jsx)(Bp,{}),(0,W.jsx)(cb,{children:d.title}),(0,W.jsxs)(lb,{children:[d.detail,` Keep your working copy to switch with them intact.`]})]}),(0,W.jsx)(ck,{error:m.error}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`ghost`,className:`sm:mr-auto`,onClick:()=>{s(`read-only-banner-switch-cancelled`,{account:i.account.name,project:i.project.name,environment:i.environment.name,branch:n}),t(!1)},disabled:m.isPending,"data-test":`checkout-branch-cancel`,children:`Cancel`}),(0,W.jsx)(Y,{variant:`outline`,onClick:p,disabled:m.isPending,"data-test":`checkout-branch-keep`,children:`Just switch`}),(0,W.jsx)(Y,{variant:f?`destructive`:`default`,disabled:m.isPending||u,onClick:()=>{s(`read-only-banner-checkout-branch-confirmed`,{account:i.account.name,project:i.project.name,environment:i.environment.name,branch:n,hasLocalWork:f}),m.mutate({accountName:i.account.name,projectName:i.project.name,branchName:n})},"data-test":`checkout-branch-confirm`,children:(0,W.jsx)(CP,{loading:m.isPending,children:`Checkout & switch`})})]})]})})},mKt=({item:e,isSelected:t,onSelect:n})=>{let r=new Date(e.createdOn),i=AFe(r)?`${eO(r,`H:mm:ss`)} Today`:kFe(r)?`${eO(r,`H:mm:ss ccc d, MMM`)}`:`${eO(r,`H:mm:ss ccc d`)} ${eO(r,`MMM yyy`)}`;return(0,W.jsxs)(`div`,{className:(0,bP.default)(`flex items-center gap-2 px-3 cursor-pointer h-10 border-border border-b`,{"bg-accent text-accent-foreground":t,"hover:bg-accent/50":!t}),onClick:()=>n(),children:[(0,W.jsx)(`div`,{className:`flex justify-center items-center w-5 shrink-0`,children:(0,W.jsx)(UG,{deployment:e})}),(0,W.jsx)(`span`,{className:`w-full text-sm truncate`,children:i})]})},hKt={"in-progress":`Building`,success:`Finished`,failed:`Failed`,skipped:`Skipped`},gKt=({status:e})=>hKt[e],_Kt={lint:`Lint`,build:`Build`,deploy:`Deploy`},vKt=({step:e})=>_Kt[e]??e,x7=r(a(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}))(),1);function yKt({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}var bKt=yKt();function xKt(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(bKt,``)}var SKt=({logs:e,children:t,className:n})=>(0,W.jsx)(`div`,{className:G(`grid grid-cols-[auto_1fr] auto-rows-min gap-x-5 py-4 text-xs h-full overflow-auto`,`bg-neutral-950 font-mono text-white`,n),children:t||(e.length>0?e.map(({timestamp:e,severity:t,message:n},r)=>(0,W.jsxs)(`div`,{className:G(`grid grid-cols-subgrid col-span-full px-4 py-1 hover:bg-neutral-800 text-neutral-200`,{"text-red-400":t===`error`,"text-yellow-400":t===`warn`,"text-green-500":/^\x1b\[32m/.test(n)}),children:[(0,W.jsx)(`div`,{className:`select-none`,children:(0,x7.default)(e).format(`HH:mm:ss.SSS`)}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:(0,W.jsx)(jFe,{text:xKt(n).trim()})})]},`${e}-${r}`)):(0,W.jsx)(`div`,{className:`text-neutral-300 italic px-4`,children:`No logs available`}))}),CKt=({stage:e,buildLogs:t,isLoading:n})=>(0,W.jsx)(`div`,{className:`divide-y divide-neutral-800`,children:[...e.steps??[]].sort((e,t)=>e.ordinal-t.ordinal).map(r=>{let i=att(t,e.stage,r.step),a=qG(i);return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-xs font-medium bg-neutral-900 text-neutral-300`,children:[(0,W.jsx)(u1,{status:r.status}),(0,W.jsx)(vKt,{step:r.step}),a>0&&(0,W.jsxs)(qT,{variant:`warn`,children:[a,` warning`,a>1?`s`:``]})]}),(0,W.jsx)(SKt,{logs:i,children:n&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5 col-span-full px-4`,children:[(0,W.jsx)(wD,{className:`h-4 w-3/6 bg-white/20`}),(0,W.jsx)(wD,{className:`h-4 w-2/6 bg-white/20`})]})})]},r.id)})}),wKt=(e,t)=>e?t(e):void 0,TKt=({deployment:e,defaultOpen:t})=>{let{environment:n}=nm([`environment`]),r=git(n.name,e.id,{});return r.isPending?(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,W.jsx)(wD,{className:`h-10 w-full`}),(0,W.jsx)(wD,{className:`h-10 w-full`})]}):r.isError?(0,W.jsx)(sb,{variant:`warning`,children:(0,W.jsx)(lb,{className:`text-center`,children:(0,W.jsx)(`div`,{className:`text-neutral-600 text-lg`,children:r.error?r.error.status===401||r.error.status===403?`You don't have permission to view build logs for this deployment.`:r.error.status===404?`Deployment not found. The selected deployment may have been deleted or doesn't exist.`:r.error.status===500?`Server error occurred while loading build logs. Please try again or contact support if the problem persists.`:`Unable to load build logs. Please try again or contact support if the problem persists.`:`Could not load logs. Please try again or contact support if the problem persists.`})})}):(0,W.jsx)(lk,{className:`divide-y overflow-hidden`,children:e.stages.map((n,i)=>(0,W.jsx)(EKt,{stage:n,stageIndex:i,stageCount:e.stages.length,buildLogs:r.data,isLoading:r.isLoading,defaultOpen:t},n.id))})},EKt=({stage:e,stageIndex:t,stageCount:n,buildLogs:r,isLoading:i,defaultOpen:a})=>{let o=e.steps&&e.steps.length>0;return(0,W.jsxs)(QT,{defaultOpen:a,children:[(0,W.jsx)($T,{asChild:!0,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 p-2 w-full hover:bg-accent cursor-pointer group`,children:[(0,W.jsx)(u1,{status:e.status}),(0,W.jsxs)(`div`,{className:`font-medium`,children:[(0,W.jsxs)(`span`,{className:`font-mono text-xs me-2`,children:[`(`,t+1,`/`,n,`)`]}),`Building `,(0,W.jsx)(Pyt,{stage:e.stage})]}),(0,W.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:(0,W.jsx)(gKt,{status:e.status})}),(0,W.jsx)(`div`,{className:`text-xs text-amber-400`,children:wKt(qG(JG(r,e.stage)),e=>(0,W.jsxs)(qT,{variant:`warn`,children:[e,` warning`,e>1?`s`:``]}))}),(0,W.jsx)(`div`,{className:`ms-2 flex items-center justify-center`,children:(0,W.jsx)(Zf,{className:`w-4 h-4 transition-transform group-data-[state=closed]:-rotate-90`})})]})}),(0,W.jsx)(eE,{children:o?(0,W.jsx)(CKt,{stage:e,buildLogs:r,isLoading:i}):(0,W.jsx)(SKt,{logs:JG(r,e.stage),children:i&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5 col-span-full px-4`,children:[(0,W.jsx)(wD,{className:`h-4 w-3/6 bg-white/20`}),(0,W.jsx)(wD,{className:`h-4 w-2/6 bg-white/20`})]})})})]})},DKt=({build:e})=>(0,W.jsx)(`div`,{className:`p-4 w-full`,children:(0,W.jsx)(TKt,{deployment:e,defaultOpen:!0})}),OKt=()=>{let[e,t]=SY(`build`),{environment:n}=nm([`account`,`project`,`environment`]),{data:r}=wGe(n.name),i=r?.data?.find(t=>t.id===e);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(RJ,{}),(0,W.jsxs)(LJ,{className:`min-h-36 shadow-[rgb(215_215_215/15%)_0px_-4px_3px_0px] dark:shadow-[rgb(0_0_0/40%)_0px_-4px_3px_0px]`,defaultSize:30,children:[(0,W.jsxs)(`div`,{className:`flex gap-2 border-b h-8 items-center justify-between group bg-surface-muted px-3`,children:[(0,W.jsx)(`div`,{className:`divide-neutral-200`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 group rounded-none relative text-xs font-medium`,title:e,children:[(0,W.jsx)(ete,{size:16}),e?`Build ${e.slice(0,8)}`:`Builds`]})}),(0,W.jsx)(`div`,{className:`flex flex-row gap-2`,children:(0,W.jsx)(Y,{variant:`ghost`,size:`icon-xs`,onClick:()=>t(void 0),children:(0,W.jsx)(Up,{size:18})})})]}),(0,W.jsxs)(`div`,{className:`h-[calc(100%-2rem)]`,children:[r?.data?.length===0&&(0,W.jsx)(`div`,{className:`p-3 text-sm`,children:`Start changing your local copy to see build information.`}),(0,W.jsxs)(`div`,{className:`divide-x grid grid-cols-[min-content_1fr] w-full h-full`,children:[(0,W.jsx)(`div`,{className:`overflow-y-auto`,children:r?.data?.map(n=>(0,W.jsx)(mKt,{item:n,isSelected:n.id===e,onSelect:()=>t(n.id)},`${n.id}`))}),(0,W.jsx)(`div`,{className:`overflow-y-auto`,children:e&&i?(0,W.jsx)(DKt,{build:i}):(0,W.jsx)(`div`,{className:`p-3 text-sm`,children:`Select a build to view more information.`})})]})]})]})]})},kKt=5e3,AKt=3*6e4,jKt=2e4,MKt=e=>{let[t,n]=(0,U.useState)(null),[r,i]=(0,U.useState)(!1);return(0,U.useEffect)(()=>{i(!1),n(e?Date.now()+AKt:null)},[e]),(0,U.useEffect)(()=>{if(t===null)return;let e=setTimeout(()=>i(!0),Math.max(t-Date.now(),0));return()=>clearTimeout(e)},[t]),{isPolling:e&&!r,restartPoll:()=>{i(!1),n(Date.now()+AKt)}}},S7=`/modules`,C7=`/schemas`;function NKt({showReadOnlyBanner:e=!0}={}){let t=nm(),{editStrategies:n}=x6(),[r,i]=SY(`path`),[a]=SY(`build`),{monaco:o,reloadFiles:s}=v7(),c=lF(s.execute),l=t.environment.name,{isReadOnly:u}=YZ(),{isFileTreeOpen:d,setIsFileTreeOpen:f}=j8(),p=cm(e=>e.projectTreeNodes),m=fne(),[h,g]=Hl(),_=e=>{let t=new URLSearchParams(h);t.set(`path`,e),t.delete(`v`),t.delete(`line`),g(t)},v=`${t.account.name}/${t.project.name}/${t.environment.name}`,[y,b]=(0,U.useState)(!1),[x,S]=(0,U.useState)(v);x!==v&&(S(v),b(!1)),(0,U.useEffect)(()=>{if(y)return;if(r){b(!0);return}if(!m||p.length===0)return;let e=p.find(e=>e.path&&um.test(e.path));b(!0),e&&i(e.path)},[r,p,i,y,m]);let C=p.length===0,w=!r&&(C||!y),T=p.find(e=>e.path&&um.test(e.path))?.path,E=r??``,D=[{label:`Routes`,testId:`sidebar-routes`,icon:(0,W.jsx)(hht,{className:`size-[18px]`}),isActive:um.test(E),disabled:!T,onClick:()=>T&&_(T)},{label:`Policies`,testId:`sidebar-policies`,icon:(0,W.jsx)(Mp,{size:18}),isActive:E===`/config/policies.json`,disabled:!1,onClick:()=>_(`/config/policies.json`)},{label:`Modules`,testId:`sidebar-modules`,icon:(0,W.jsx)(Pte,{size:18}),isActive:E===S7,disabled:!1,onClick:()=>_(S7)},{label:`Schemas`,testId:`sidebar-schemas`,icon:(0,W.jsx)(hp,{size:18}),isActive:E===C7,disabled:!1,onClick:()=>_(C7)}],{isError:O,error:k,isFetched:A,isFetching:j,refetch:M}=je({queryKey:[`reloadFiles`,t.account.name,t.project.name,t.environment.name],queryFn:async({signal:e})=>(await c.current({accountName:t.account.name,projectName:t.project.name,environmentName:t.environment.name},e),!0),refetchOnWindowFocus:!1,enabled:!!o&&!!l}),{isPolling:N,restartPoll:P}=MKt(!1),F=ast(l,{enabled:N,refetchInterval:kKt}),I=F.isError,L=!I&&F.data?.ready!==!0,R=I?jKt:kKt;if((0,U.useEffect)(()=>{if(!N||L)return;let e=()=>{document.visibilityState===`visible`&&M({cancelRefetch:!1})};e();let t=setInterval(e,R);return()=>clearInterval(t)},[N,L,M,R]),O&&k instanceof He)return(0,W.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,W.jsxs)(sb,{className:`max-w-md`,children:[(0,W.jsx)(cb,{children:k.title}),(0,W.jsxs)(lb,{className:`flex flex-col gap-2`,children:[Fb(k),(0,W.jsx)(XGt,{})]})]})});let z=(0,W.jsxs)(IJ,{direction:`vertical`,autoSaveId:`bottom-pane`,className:`relative`,children:[(0,W.jsx)(LJ,{minSize:10,children:r?(0,W.jsx)(VY,{blastRadius:`feature-dead`,fallback:e=>(0,W.jsx)(obt,{...e}),children:(0,W.jsx)(PKt,{})}):w?(0,W.jsx)(FKt,{}):null}),a!==void 0&&(0,W.jsx)(OKt,{})]});return(0,W.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[e&&u&&(0,W.jsx)(lKt,{}),(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[!d&&(0,W.jsxs)(`div`,{className:`flex flex-col items-center bg-surface-sunken border-r shrink-0 w-12 py-2 gap-1`,children:[(0,W.jsx)(IKt,{label:`Expand file tree`,onClick:()=>f(!0),testId:`expand-file-tree`,children:(0,W.jsx)(Ite,{size:18})}),(0,W.jsx)(`div`,{className:`my-1 h-px w-6 bg-surface-emphasis`,"aria-hidden":!0}),D.map(e=>(0,W.jsx)(IKt,{label:e.label,onClick:e.onClick,testId:e.testId,isActive:e.isActive,disabled:e.disabled,children:e.icon},e.label)),(0,W.jsx)(`div`,{className:`flex-1`}),(0,W.jsx)(`span`,{className:`text-[10px] font-medium text-neutral-500 uppercase tracking-wider select-none pb-1`,style:{writingMode:`vertical-rl`},children:`Files`})]}),d?(0,W.jsxs)(IJ,{direction:`horizontal`,autoSaveId:`file-tree`,className:`flex-1 min-w-0`,children:[(0,W.jsx)(LJ,{minSize:10,defaultSize:20,className:`bg-surface-sunken min-w-[270px]`,children:(0,W.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between h-10 px-2 border-b shrink-0`,children:[(0,W.jsx)(`span`,{className:`text-xs font-medium text-neutral-600 dark:text-neutral-400 uppercase tracking-wide pl-1`,children:`Files`}),(0,W.jsx)(Y,{variant:`ghost`,size:`icon-xs`,onClick:()=>f(!1),"aria-label":`Collapse file tree`,title:`Collapse file tree`,children:(0,W.jsx)(Fte,{size:14})})]}),(0,W.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,W.jsx)(ibt,{directoryStrategies:n,isAwaitingFiles:!1})})]})}),(0,W.jsx)(RJ,{}),(0,W.jsx)(LJ,{minSize:70,children:z})]}):(0,W.jsx)(`div`,{className:`flex-1 min-w-0`,children:z})]})]})}var PKt=()=>{let[e]=SY(`path`);if(!e)throw Error(`Invalid state - FileViewer should not be displayed if no path`);let t=e.toLowerCase();if(t===S7)return(0,W.jsx)(MUt,{});if(t===C7)return(0,W.jsx)(NUt,{});if(t===`/docs/sidebar.json`)return(0,W.jsx)(b_t,{});if(t.includes(`.oas.json`))return(0,W.jsx)(AUt,{});if(t===`/config/policies.json`)return(0,W.jsx)(HGt,{});if(t.endsWith(`.md`)||t.endsWith(`.mdx`)){let e=t.split(`/`),n=e[e.length-1];return(0,W.jsx)(y_t,{fileName:n})}return t.endsWith(`.ts`)||t.endsWith(`.css`)?(0,W.jsx)(xQ,{maxHeightVh:100}):t.startsWith(`/schemas`)&&t.endsWith(`.json`)?(0,W.jsx)(xQ,{}):t===`/config/dev-portal.json`?(0,W.jsxs)(`div`,{className:`size-full`,children:[(0,W.jsx)(`div`,{className:`p-4`,children:(0,W.jsx)(KGt,{})}),(0,W.jsx)(xQ,{})]}):(0,W.jsx)(xQ,{})},FKt=()=>(0,W.jsxs)(`div`,{className:`p-6 flex flex-col gap-2`,"data-test":`editor-loading`,children:[(0,W.jsx)(wD,{className:`w-40 h-4`}),(0,W.jsx)(wD,{className:`w-56 h-4`}),(0,W.jsx)(wD,{className:`w-28 h-4`}),(0,W.jsx)(wD,{className:`w-64 h-4`}),(0,W.jsx)(wD,{className:`w-56 h-4`}),(0,W.jsx)(wD,{className:`w-56 h-4`}),(0,W.jsx)(wD,{className:`w-56 h-4`})]}),IKt=({label:e,onClick:t,testId:n,isActive:r=!1,disabled:i=!1,children:a})=>(0,W.jsx)(Pw,{content:e,side:`right`,children:(0,W.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e,"aria-current":r?`page`:void 0,disabled:i,"data-test":n,className:G(`group flex items-center justify-center size-9 rounded-md transition-colors ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,i?`text-neutral-300 dark:text-neutral-700 cursor-not-allowed`:`cursor-pointer`,!i&&(r?`bg-brand/10 text-brand`:`text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 hover:bg-neutral-200 dark:hover:bg-neutral-800`)),children:a})});function LKt(){return(0,W.jsxs)(nmt,{children:[(0,W.jsx)(NKt,{}),(0,W.jsx)(mht,{})]})}var RKt=`/static/img/hero-Ct8-h_EN.svg`,zKt=`/static/img/hero-dark-Z9HfvwEQ.svg`,BKt=[{label:`Monetization`,value:`monetization`,badge:`Beta`,items:[{title:`Monetization Overview`,description:`Learn more about our first-party metering and billing solution built directly into the Zuplo platform.`,icon:ky,link:{href:{web:`https://zuplo.com/docs/articles/monetization/index`,local:`https://zuplo.com/docs/articles/monetization/index`},text:`Read the docs`}},{title:`Monetization Quickstart`,description:`Get up and running with API monetization in minutes using Zuplo's built-in billing and metering.`,icon:Ly,link:{href:{web:`https://zuplo.com/docs/articles/monetization/quickstart`,local:`https://zuplo.com/docs/articles/monetization/quickstart`},text:`Get Started`}},{title:`Pricing Models`,description:`Explore the different pricing models available for monetizing your APIs with Zuplo.`,icon:Ay,link:{href:{web:`https://zuplo.com/docs/articles/monetization/pricing-models`,local:`https://zuplo.com/docs/articles/monetization/pricing-models`},text:`Read the docs`}}]},{label:`MCP`,value:`mcp`,items:[{title:`Installing the MCP Inspector`,description:`Set up the MCP Inspector locally and start testing your MCP server with ease.`,icon:My,link:{href:{web:`https://zuplo.com/docs/handlers/mcp-server#mcp-inspector`,local:`https://zuplo.com/docs/handlers/mcp-server#mcp-inspector`},text:`Get Started`}},{title:`MCP Quickstart`,description:`Learn how to start using Model Context Protocol to pass context into any model call.`,icon:Ly,link:{href:{web:`https://zuplo.com/docs/articles/mcp-quickstart`,local:`https://zuplo.com/docs/articles/mcp-quickstart`},text:`Get Started`}},{title:`Using OAuth with MCP`,description:`Authenticate users securely by integrating OAuth flows into your Model Context Protocol setup.`,icon:Iy,link:{href:{web:`https://zuplo.com/docs/articles/configuring-auth0-for-mcp-auth`,local:`https://zuplo.com/docs/articles/configuring-auth0-for-mcp-auth`},text:`Get Started`}}]},{label:`Rate Limiting`,value:`rate-limiting`,items:[{title:`Adding Rate Limiting`,description:`Control traffic and protect your APIs by setting up flexible, customizable rate limits.`,icon:Ay,link:{href:{web:`https://zuplo.com/docs/articles/step-2-add-rate-limiting`,local:`https://zuplo.com/docs/articles/step-2-add-rate-limiting-local`},text:`Get Started`}},{title:`Complex Rate Limiting`,description:`Implement advanced rules to rate limit by user, IP, plan, or custom logic.`,icon:jy,link:{href:{web:`https://zuplo.com/docs/policies/complex-rate-limit-inbound`,local:`https://zuplo.com/docs/policies/complex-rate-limit-inbound`},text:`Get Started`}},{title:`Dynamic Rate Limits`,description:`Set rate limits that adapt in real-time based on headers, tokens, or user context.`,icon:Tge,link:{href:{web:`https://zuplo.com/examples/dynamic-rate-limits`,local:`https://zuplo.com/examples/dynamic-rate-limits`},text:`Get Started`}}]},{label:`Authentication`,value:`authentication`,items:[{title:`Using API Keys`,description:`Authenticate and manage access to your APIs with simple, secure API key workflows.`,icon:Age,link:{href:{web:`https://zuplo.com/docs/policies/api-key-inbound`,local:`https://zuplo.com/docs/policies/api-key-inbound`},text:`Get Started`}},{title:`Using Auth0`,description:`Connect your APIs to Auth0 for streamlined authentication and powerful identity management.`,icon:Vy,link:{href:{web:`https://zuplo.com/docs/policies/auth0-jwt-auth-inbound`,local:`https://zuplo.com/docs/policies/auth0-jwt-auth-inbound`},text:`Get Started`}},{title:`Using Okta`,description:`Integrate Okta with your APIs to enable secure, enterprise-grade authentication and authorization.`,icon:Ny,link:{href:{web:`https://zuplo.com/docs/policies/okta-jwt-auth-inbound`,local:`https://zuplo.com/docs/policies/okta-jwt-auth-inbound`},text:`Get Started`}}]},{label:`Dev Portal`,value:`dev-portal`,items:[{title:`Setup your API Reference`,description:`Instantly generate an interactive reference by importing your OpenAPI spec—no manual work needed.`,icon:jhe,link:{href:{web:`https://zuplo.com/docs/dev-portal/zudoku/configuration/api-reference`,local:`https://zuplo.com/docs/dev-portal/zudoku/configuration/api-reference`},text:`Get Started`}},{title:`Adding Authentication`,description:`Guide users through secure API access by adding auth flows to your developer portal.`,icon:Ry,link:{href:{web:`https://zuplo.com/docs/dev-portal/zudoku/configuration/authentication`,local:`https://zuplo.com/docs/dev-portal/zudoku/configuration/authentication`},text:`Get Started`}},{title:`Creating API Catalogs`,description:`Organize your APIs into searchable, user-friendly catalogs for easier discovery and onboarding.`,icon:ky,link:{href:{web:`https://zuplo.com/docs/dev-portal/zudoku/guides/using-multiple-apis`,local:`https://zuplo.com/docs/dev-portal/zudoku/guides/using-multiple-apis`},text:`Get Started`}}]}],VKt=({mode:e=`web`})=>(0,W.jsxs)(Zk,{defaultValue:`monetization`,className:`flex flex-col my-8`,children:[(0,W.jsx)(Qk,{className:`flex gap-8 border-b border-surface-border mb-8 ml-1`,children:BKt.map(e=>(0,W.jsxs)($k,{value:e.value,className:`relative py-2 text-sm font-medium text-gray-600 dark:text-neutral-400 hover:text-gray-900 dark:hover:text-neutral-100 data-[state=active]:text-gray-900 dark:data-[state=active]:text-neutral-100 border-b-2 border-transparent data-[state=active]:border-black dark:data-[state=active]:border-white transition-colors`,children:[e.label,`badge`in e&&e.badge&&(0,W.jsx)(qT,{variant:`invert`,className:`ml-2`,children:e.badge})]},e.value))}),BKt.map(t=>(0,W.jsx)(eA,{value:t.value,className:`grid grid-cols-3 gap-4`,children:t.items.map(t=>(0,W.jsxs)(lk,{className:`flex flex-col gap-2 text-muted-foreground`,children:[(0,W.jsxs)(uk,{className:`flex gap-2`,children:[(0,W.jsx)(t.icon,{size:24,weight:`duotone`,className:`[&_[opacity='0.2']]:fill-pink-500`}),(0,W.jsx)(dk,{className:`gap-x-2 text-lg font-semibold`,children:t.title})]}),(0,W.jsx)(pk,{children:t.description}),(0,W.jsx)(mk,{className:`flex-1 items-end! border-0 mb-4`,children:(0,W.jsx)(Y,{variant:`outline`,className:`w-full`,asChild:!0,children:(0,W.jsx)(tE,{href:t.link.href[e],variant:`ghost`,children:t.link.text})})})]},t.title))},t.value))]}),HKt=({title:e,url:t,className:n})=>{let{copyToClipboard:r,state:i}=zw(t??``);return(0,W.jsxs)(lk,{className:G(`col-span-full md:col-span-5 py-2 px-4 flex items-center text-sm gap-x-2`,n),children:[(0,W.jsx)(`div`,{className:`bg-green-600 rounded-full w-4 h-4 p-0.5`,children:(0,W.jsx)(Xf,{className:`text-white`,size:12})}),(0,W.jsx)(`span`,{className:`font-semibold`,children:e}),(0,W.jsx)(`div`,{className:`flex-1`,children:t?(0,W.jsx)(tE,{href:t,className:`ml-2 font-medium line-clamp-1 break-all`,children:t}):(0,W.jsx)(wD,{className:`ml-2 h-4 w-8/12`})}),(0,W.jsx)(Iw,{copied:i===`copied`,children:(0,W.jsx)(Y,{variant:`secondary`,size:`sm`,onClick:r,children:(0,W.jsxs)(CP,{loading:i===`copied`,alternative:(0,W.jsx)(Xf,{size:12,className:`text-green-600`,strokeWidth:3}),className:`flex`,children:[(0,W.jsx)(sp,{size:16,className:`mr-2`,strokeWidth:1.5}),(0,W.jsx)(X,{children:`Copy URL`})]})})})]})},UKt=({size:e=24,...t})=>(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,fill:`none`,viewBox:`0 0 16 16`,...t,children:(0,W.jsx)(`path`,{fill:`currentColor`,d:`m7.47 12.412 3.348-.592.031-.007-1.722-2.049a291.474 291.474 0 0 1-1.723-2.058c0-.01 1.779-4.909 1.789-4.926a788.95 788.95 0 0 1 2.934 5.066l2.95 5.115.023.039-10.948-.001 3.317-.587zM.9 11.788c0-.003.811-1.412 1.803-3.131L4.507 5.53l2.102-1.764C7.765 2.797 8.714 2 8.717 2a.37.37 0 0 1-.033.085L6.4 6.981l-2.24 4.808-1.63.002c-.897.001-1.63 0-1.63-.003z`})}),WKt=({className:e,size:t=24})=>(0,W.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,W.jsx)(`path`,{d:`M.778 1.211c-.424-.006-.772.334-.778.758 0 .045.002.09.01.134l3.263 19.811c.084.499.515.867 1.022.872H19.95c.382.004.708-.271.77-.646l3.27-20.03c.068-.418-.216-.813-.635-.881-.045-.008-.089-.011-.133-.01L.778 1.211zM14.52 15.528H9.522L8.17 8.464h7.561l-1.211 7.064z`})}),GKt=({className:e,size:t=24})=>(0,W.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,W.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 2C6.477 2 2 6.463 2 11.97c0 4.404 2.865 8.14 6.839 9.458.5.092.682-.216.682-.48 0-.236-.008-.864-.013-1.695-2.782.602-3.369-1.337-3.369-1.337-.454-1.151-1.11-1.458-1.11-1.458-.908-.618.069-.606.069-.606 1.003.07 1.531 1.027 1.531 1.027.892 1.524 2.341 1.084 2.91.828.092-.643.35-1.083.636-1.332-2.22-.251-4.555-1.107-4.555-4.927 0-1.088.39-1.979 1.029-2.675-.103-.252-.446-1.266.098-2.638 0 0 .84-.268 2.75 1.022A9.606 9.606 0 0112 6.82c.85.004 1.705.114 2.504.336 1.909-1.29 2.747-1.022 2.747-1.022.546 1.372.202 2.386.1 2.638.64.696 1.028 1.587 1.028 2.675 0 3.83-2.339 4.673-4.566 4.92.359.307.678.915.678 1.846 0 1.332-.012 2.407-.012 2.734 0 .267.18.577.688.48C19.137 20.107 22 16.373 22 11.969 22 6.463 17.522 2 12 2z`})}),KKt=({className:e,size:t=24})=>(0,W.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,W.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M22.65 14.39L12 22.13 1.35 14.39a.84.84 0 0 1-.3-.94l1.22-3.78 2.44-7.51A.42.42 0 0 1 4.82 2a.43.43 0 0 1 .58 0 .42.42 0 0 1 .11.18l2.44 7.49h8.1l2.44-7.51A.42.42 0 0 1 18.6 2a.43.43 0 0 1 .58 0 .42.42 0 0 1 .11.18l2.44 7.51L23 13.45a.84.84 0 0 1-.35.94z`})});function w7({providerName:e,className:t,size:n=24}){switch(e?.toLowerCase()){case`gitlab`:return(0,W.jsx)(KKt,{className:t,size:n});case`bitbucket`:return(0,W.jsx)(WKt,{className:t,size:n});case`azure`:return(0,W.jsx)(UKt,{className:t,size:n});default:return(0,W.jsx)(GKt,{className:t,size:n})}}var qKt=({onSuccess:e}={})=>{let t=P(),{logEvent:n,captureException:r}=H();return I({mutationFn:async e=>(await t.fetch(V.accounts.createCustomDomain({accountName:e.accountName,isAlias:e.isAlias,projectName:e.projectName,hostname:e.hostname,deploymentName:e.deploymentName,stage:e.stage}))).json(),onSuccess:(t,r)=>{n(`account-custom-domain-creation-success`,{account:r.accountName}),e?.(t)},onError:e=>{n(`account-custom-domain-creation-failed`),r(e)}})},JKt=()=>{let e=P();return I({mutationFn:async t=>{await e.fetch(V.accounts.editCustomDomain({accountName:t.accountName,projectName:t.projectName,hostname:t.hostname,deploymentName:t.deploymentName}))}})},YKt=()=>{let e=P();return I({mutationFn:async t=>{await e.fetch(V.accounts.deleteCustomDomain({accountName:t.accountName,projectName:t.projectName,hostname:t.hostname,deploymentName:t.deploymentName}))}})},XKt=(e,t)=>kb(R.customDomains(e,t),{extractData:!0}),ZKt=(0,U.forwardRef)(({icon:e,label:t,count:n,expanded:r,onToggle:i,children:a},o)=>(0,W.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-surface-border bg-surface shadow-xs`,children:[(0,W.jsxs)(`button`,{ref:o,type:`button`,onClick:i,"aria-expanded":r,className:`flex w-full items-center justify-between gap-2 px-3.5 py-2 text-sm transition hover:bg-gray-50 dark:hover:bg-neutral-800`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-2 font-medium text-gray-800 dark:text-neutral-200`,children:[(0,W.jsx)(e,{size:14,className:`text-gray-500 dark:text-neutral-400`,strokeWidth:2}),t]}),(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(qT,{variant:`secondary`,size:`sm`,className:`px-1.5 font-mono`,children:n??0}),r?(0,W.jsx)($f,{size:14,className:`text-gray-500 dark:text-neutral-400`}):(0,W.jsx)(Zf,{size:14,className:`text-gray-400 dark:text-neutral-500`})]})]}),r?(0,W.jsx)(`div`,{className:`border-t border-gray-100 dark:border-neutral-800`,children:a}):null]}));ZKt.displayName=`ExpandableNode`;var QKt=({selected:e,onChange:t,options:n,listLabel:r,className:i,classNameOptions:a,testId:o,placeholder:s,disabled:c,isLoadingData:l=!1})=>{let u=(0,U.useId)(),d=n.filter(e=>String(e.value)!==``);return(0,W.jsxs)(gY,{value:e?String(e.value):``,onValueChange:e=>{let n=d.find(t=>String(t.value)===e);n&&t(n)},disabled:c,children:[r?(0,W.jsx)(`span`,{id:u,className:`mb-1 block text-sm font-medium text-foreground`,children:r}):null,(0,W.jsx)(vY,{"data-test":o,className:G(`w-full`,i),"aria-labelledby":r?u:void 0,"aria-label":r?void 0:s,children:l&&e?.icon?(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(TP,{className:`h-4 w-4`,borderPositionAndSize:`border-l-2`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.label})]}):(0,W.jsx)(_Y,{placeholder:s})}),(0,W.jsx)(yY,{align:`start`,className:G(`max-h-72`,a),children:d.map((e,t)=>(0,W.jsx)(bY,{"data-test":`${o}-${t}`,value:String(e.value),disabled:e.disabled??!1,description:e.description,children:e.icon?(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.icon,e.label]}):e.label},`${t}-${e.value}`))})]})};function $Kt(e,t=500){let[n,r]=(0,U.useState)(e);return(0,U.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>{clearTimeout(n)}},[e,t]),n}var eqt=({projects:e,isLoadingProjects:t,selectedProject:n,onProjectChange:r})=>(0,W.jsx)(QKt,{testId:`project-selector`,placeholder:`Select Project`,options:(e||[]).map(e=>({label:e.name,value:e.id,icon:(0,W.jsx)(vp,{className:`mr-1.5`,size:16})})),selected:n,onChange:r,className:`flex-1 items-center w-full h-9`,isLoadingData:t});function tqt({title:e,className:t}){return(0,W.jsx)(`div`,{className:G(`text-2xl font-medium`,t),children:e})}var nqt=({showHeader:e})=>(0,W.jsxs)(W.Fragment,{children:[e&&(0,W.jsx)(tqt,{title:`Source Control Settings`}),(0,W.jsxs)(`div`,{className:`w-full sm:max-w-md md:max-w-2xl lg:max-w-5xl animate-pulse`,children:[e&&(0,W.jsx)(`div`,{className:`h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 mb-9 mt-7 w-[650px]`}),(0,W.jsxs)(`div`,{className:`flex flex-col md:flex-row lg:flex-row sm:gap-4`,children:[(0,W.jsx)(`div`,{className:`inline-block w-full max-w-sm md:max-w-xs mr-4 h-10 bg-gray-200 rounded-md dark:bg-gray-700`}),(0,W.jsx)(`div`,{className:`inline-block w-full max-w-sm md:max-w-xs mr-4 h-10 bg-gray-200 rounded-md dark:bg-gray-700`}),(0,W.jsx)(`div`,{className:`inline-block w-full max-w-sm md:max-w-xs right-0 h-10 bg-gray-200 rounded-md dark:bg-gray-700`})]}),(0,W.jsx)(`div`,{className:`h-5 mt-5 mb-3`,children:(0,W.jsx)(`div`,{className:`h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 mb-9 mt-7 w-[650px]`})}),(0,W.jsx)(`div`,{className:`mt-5 h-96 relative bg-gray-200 rounded-md dark:bg-gray-700`})]})]}),T7=`GITLAB`,E7=`GITHUB`,D7=`BITBUCKET`,O7=`AZURE`,rqt=({installUrl:e,selectedOrg:t,projectName:n,className:r,provider:i=E7,disabled:a,repoDescription:o=`Zuplo API Gateway`,onContinue:s})=>{let{logEvent:c}=H(),[l,u]=(0,U.useState)(!1),d=e=>{c(`source-control-create-repo-continue-clicked`,{sourceControlNamespace:e??`none`,sourceControlProvider:i,project:n}),s?.();let t;switch(i){case O7:t=e?`https://dev.azure.com/${e}/_createproject`:`https://dev.azure.com/`;break;case T7:t=e?`https://gitlab.com/projects/new?namespace_id=${e}`:`https://gitlab.com/projects/new`;break;case D7:t=e?`https://bitbucket.org/repo/create?owner=${e}`:`https://bitbucket.org/repo/create`;break;default:{let r=encodeURIComponent(o);t=e===null?`https://github.com/new?name=${n}&description=${r}`:`https://github.com/organizations/${e}/repositories/new?owner=${e}&name=${n}&description=${r}`;break}}window.open(t),u(!1)};return(0,W.jsxs)(tT,{open:l,onOpenChange:u,children:[(0,W.jsx)(nT,{asChild:!0,children:(0,W.jsx)(Y,{className:r,disabled:a,children:`Create new repository`})}),(0,W.jsxs)(iT,{className:`max-w-xl! w-full`,children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:`Create new repository`}),(0,W.jsx)(cT,{})]}),(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`We're about to help you create a new repository in`,` `,Pb(i),`.`]}),(0,W.jsxs)(`div`,{className:`rounded-md bg-muted/50 p-3 text-sm space-y-2 border`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`What you'll need to do:`}),i===`AZURE`&&(0,W.jsxs)(`ul`,{className:`list-disc list-inside space-y-1 text-muted-foreground`,children:[(0,W.jsx)(`li`,{children:`Create a project and repository in Azure DevOps`}),(0,W.jsx)(`li`,{children:`Return to Zuplo to connect it`})]}),i===`GITHUB`&&(0,W.jsxs)(`ul`,{className:`list-disc list-inside space-y-1 text-muted-foreground`,children:[(0,W.jsx)(`li`,{children:`Create your new repository on GitHub`}),(0,W.jsxs)(`li`,{children:[`Ensure the`,` `,(0,W.jsx)(tE,{href:e,children:`Zuplo GitHub App`}),` `,`has access to your new repo`]}),(0,W.jsx)(`li`,{children:`Return to Zuplo to see and connect it`})]}),(i===`GITLAB`||i===`BITBUCKET`)&&(0,W.jsxs)(`ul`,{className:`list-disc list-inside space-y-1 text-muted-foreground`,children:[(0,W.jsxs)(`li`,{children:[`Create your repository in `,Pb(i)]}),(0,W.jsx)(`li`,{children:`Return to Zuplo to connect it`})]})]}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Need help?`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/source-control`,children:`View our troubleshooting guide`})]})]}),(0,W.jsx)(oT,{children:(0,W.jsxs)(Y,{"data-test":`navigate-new-${i.toLowerCase()}-repo`,onClick:()=>d(t),children:[`Continue to `,Pb(i)]})})]})]})},iqt=e=>e instanceof He&&e.type===`https://zup.fail/github-integration-monorepo-detected`,aqt=`The GitHub integration connects a repository with a single Zuplo project at its root, so it can't connect this repository. You can still deploy it using the Zuplo CLI in your CI/CD pipeline.`,k7={linkAnyway:{title:`Link existing Zuplo project`,description:`Looks like Zuplo was set up here before, so we'll link your project to the existing repository instead of pushing a new one. Nothing is pushed or pulled automatically; you can commit and push from the portal whenever you're ready.`,actionLabel:`Link project`},monorepo:{title:`This looks like a monorepo`,description:aqt,actionLabel:`Manual setup`},nonEmpty:{title:`This repository isn't empty`,description:aqt,actionLabel:`Manual setup`},pullRequestOpened:{title:`We opened a pull request`,description:`Your default branch requires changes to go through a pull request, so we pushed your project to a setup branch and opened one. Merge the pull request to finish setup and land your project on the default branch.`,actionLabel:`Open pull request`}},A7=`https://zuplo.com/docs/articles/monorepo-deployment`,oqt=new Set([`https://zup.fail/github-integration-invalid-repo`,`https://zup.fail/github-integration-package-json-missing-repo`,`https://zup.fail/create-project-invalid-git-repo`,`https://zup.fail/azure-integration-invalid-repo`]),sqt=e=>iqt(e)?`monorepo`:e instanceof He&&typeof e.type==`string`&&oqt.has(e.type)?`invalidRepo`:`other`,cqt=({accountName:e,projectName:t,orgName:n,repositoryUrl:r,provider:i,handleErrors:a})=>{let{logEvent:o,captureException:s}=H(),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(null),f=wAe(e,t),p={account:e,project:t,sourceControlNamespace:n},m=async(e,t,n)=>{try{if(e===null)throw Error(`Invalid ${Pb(i)} account/organization selected, please try again.`);if(t===null)throw Error(`Invalid repository selected, please try again.`);let r=await(await f.mutateAsync({orgName:e,repositoryURL:t,defaultBranch:`main`,forceConnect:n})).json();r.connected?r.pullRequestUrl?(d(r.pullRequestUrl),o(`source-control-repo-connected-via-pr`,p),l(`pullRequestOpened`)):(o(`source-control-repo-connected`,p),l(null)):r.emptyRepository===!1&&(a(``),o(`source-control-existing-repo-confirm-shown`,p),l(`linkAnyway`))}catch(e){let t=Fb(e);switch(sqt(e)){case`monorepo`:a(``),o(`source-control-monorepo-detected`,p),l(`monorepo`);break;case`invalidRepo`:a(``),o(`source-control-nonempty-repo-detected`,p),l(`nonEmpty`);break;default:s(e),o(`source-control-repo-connection-failed`,{...p,errorMessage:t,...N_e(e)}),a(t),l(null)}}};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(FP,{open:c===`linkAnyway`,onOpenChange:e=>{e||(o(`source-control-existing-repo-confirm-cancelled`,p),l(null))},title:k7.linkAnyway.title,description:(0,W.jsxs)(W.Fragment,{children:[k7.linkAnyway.description,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/source-control`,children:`Learn more about source control`})]}),actionLabel:k7.linkAnyway.actionLabel,isPending:f.isPending,onConfirm:()=>{o(`source-control-existing-repo-confirm-confirmed`,p),m(n,r,!0)}}),(0,W.jsx)(FP,{open:c===`monorepo`,onOpenChange:e=>{e||(o(`source-control-monorepo-cancelled`,p),l(null))},title:k7.monorepo.title,description:(0,W.jsxs)(W.Fragment,{children:[k7.monorepo.description,` `,(0,W.jsx)(tE,{href:A7,children:`Learn how to deploy from a monorepo`})]}),actionLabel:k7.monorepo.actionLabel,onConfirm:()=>{o(`source-control-monorepo-manual-setup-clicked`,p),l(null),window.open(A7,`_blank`,`noopener,noreferrer`)}}),(0,W.jsx)(FP,{open:c===`nonEmpty`,onOpenChange:e=>{e||(o(`source-control-nonempty-repo-cancelled`,p),l(null))},title:k7.nonEmpty.title,description:(0,W.jsxs)(W.Fragment,{children:[k7.nonEmpty.description,` `,(0,W.jsx)(tE,{href:A7,children:`Learn how to deploy from a monorepo`})]}),actionLabel:k7.nonEmpty.actionLabel,onConfirm:()=>{o(`source-control-nonempty-repo-manual-setup-clicked`,p),l(null),window.open(A7,`_blank`,`noopener,noreferrer`)}}),(0,W.jsx)(FP,{open:c===`pullRequestOpened`,onOpenChange:e=>{e||l(null)},title:k7.pullRequestOpened.title,description:k7.pullRequestOpened.description,actionLabel:k7.pullRequestOpened.actionLabel,onConfirm:()=>{o(`source-control-pr-opened-view-clicked`,p),l(null),u&&window.open(u,`_blank`,`noopener,noreferrer`)}}),(0,W.jsx)(Y,{"data-test":`connect-repo-button`,variant:`outline`,size:`sm`,onClick:()=>{o(`source-control-connect-button-clicked`,{...p,sourceControlProvider:i}),m(n,r,!1)},children:(0,W.jsx)(CP,{loading:f.isPending,children:`Connect`})})]})},lqt=({repositories:e,account:t,project:n,selectedNamespace:r,provider:i,maxItems:a=5,onConnectError:o,newRepoIds:s})=>{let c=i===`azure`;return(0,W.jsx)(W.Fragment,{children:e.slice(0,a).map((e,a)=>(0,W.jsxs)(`div`,{className:(0,bP.default)(`flex flex-row items-center justify-center h-16 border-border px-5 lg:gap-5 gap-2 transition-colors duration-700`,{"border-t":a!==0},{"bg-emerald-50 dark:bg-emerald-950/30":s?.has(e.id)}),children:[(0,W.jsxs)(`div`,{className:`flex text-sm flex-1 gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-medium line-clamp-1`,children:e.name}),s?.has(e.id)&&(0,W.jsx)(`span`,{className:`rounded bg-emerald-100 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300`,children:`New`})]}),c&&e.metadata?.projectName?(0,W.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Project: `,e.metadata.projectName]}):(0,W.jsxs)(`span`,{className:`text-muted-foreground hidden md:inline-block lg:inline-block`,children:[`Updated on`,` `,new Date(e.updatedAt).toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})]})]}),e.private&&(0,W.jsxs)(`div`,{className:`flex justify-center items-center text-muted-foreground gap-1`,children:[(0,W.jsx)(Tp,{className:`h-4 w-4`,"aria-hidden":`false`,"aria-label":`Private Git repository`}),(0,W.jsx)(`span`,{className:`hidden lg:block`,children:`Private Repository`})]})]}),(0,W.jsx)(cqt,{accountName:t.name,projectName:n.name,orgName:r?.label||``,repositoryUrl:e.url,provider:i,handleErrors:o})]},e.id))})},uqt={[E7]:{name:`GitHub`,icon:(e=20)=>(0,W.jsx)(GKt,{className:`mr-1.5`,size:e}),supportsProjects:!1,placeholder:{namespace:`Select GitHub Account`,search:`Search repositories`},messages:{noRepoAtHand:`No repository at hand? We can help you create a new one.`,selectAccount:`Make sure to select a Git account or organization on the top left.`,grantAccess:`Make sure to grant Zuplo access to the Git account & its repositories you'd like to connect to.`}},[O7]:{name:`Azure DevOps`,icon:(e=20)=>(0,W.jsx)(UKt,{className:`mr-1.5`,size:e}),supportsProjects:!0,placeholder:{namespace:`Select Organization`,project:`Select Project`,search:`Search repositories`},messages:{noRepoInProject:`No repository in this project? Create a new one.`,noRepoAtHand:`No project at hand? We can help you create one.`,selectAccount:`Please select a project to view repositories.`,grantAccess:`No repositories in this project yet.`}},[T7]:{name:`GitLab`,icon:(e=20)=>(0,W.jsx)(yp,{className:`mr-1.5`,size:e}),supportsProjects:!1,placeholder:{namespace:`Select GitLab Group`,search:`Search repositories`},messages:{noRepoAtHand:`No repository at hand? Create a new one.`,selectAccount:`Select a GitLab group or namespace.`,grantAccess:`Connect your GitLab account to see repositories.`}},[D7]:{name:`Bitbucket`,icon:(e=20)=>(0,W.jsx)(Wee,{className:`mr-1.5`,size:e}),supportsProjects:!1,placeholder:{namespace:`Select Bitbucket Project`,search:`Search repositories`},messages:{noRepoAtHand:`No repository at hand? Create a new one.`,selectAccount:`Select a Bitbucket project.`,grantAccess:`Connect your Bitbucket account to see repositories.`}}},dqt=e=>uqt[e]||uqt.GITHUB,j7=({account:e,project:t})=>{let{logEvent:n}=H(),r=CAe(e.name),[i,a]=(0,U.useState)(t.name),[o,s]=(0,U.useState)(!1);return{newRepoName:i,setNewRepoName:a,showCreateRepoForm:o,setShowCreateRepoForm:s,createRepoMutation:r,isCreating:r.isPending,handleCreateRepo:async({namespace:o,repoName:c,otherParams:l})=>{let u=c||i||t.name;await r.mutateAsync({projectName:t.name,orgName:o,repositoryName:u,defaultBranch:`main`,otherParams:l}),n(`source-control-repo-created`,{sourceControlRepository:u,sourceControlNamespace:o,account:e.name,project:t.name}),a(``),s(!1)},reset:()=>{s(!1),a(t.name)},transformRepoToRepository:(e,t)=>({id:e.url,url:e.url,provider:t,name:e.name,slug:e.name,defaultBranch:e.defaultBranch,namespace:e.organization,owner:{id:0,name:e.organization},private:!0,updatedAt:new Date().toISOString(),ownerType:e.isUserRepo?`user`:`team`,metadata:e.metadata}),logEvent:n}},fqt=e=>{let{account:t,project:n,sourceControlConfig:r,selectedNamespace:i,searchTerm:a}=e,o=j7(e),[s,c]=(0,U.useState)(null),l=r.provider===O7,{data:u,isLoading:d}=Byt(t.name,i?.value||``,{enabled:l&&!!i}),{data:f,isLoading:p}=Ryt(t.name),m=o.transformRepoToRepository;return{repositories:(0,U.useMemo)(()=>!f?.data||!i||!s?[]:(f.data[i.label]||[]).filter(e=>e.metadata?.projectName===s.label).filter(e=>!a||e.name.toLowerCase().includes(a.toLowerCase())).map(e=>m(e,`azure`)),[f,i,s,a,m]),isLoadingRepos:p&&!!s,projects:u?.data,selectedProject:s,isLoadingProjects:d,onProjectChange:e=>{c(e),o.logEvent(`source-control-project-selected`,{account:t.name,project:n.name,sourceControlProvider:r.provider})},reset:()=>{c(null),o.reset()}}},pqt=e=>{let{account:t,sourceControlConfig:n,selectedNamespace:r,searchTerm:i}=e,a=j7(e),o=n.provider===D7,{data:s,isLoading:c,refetch:l}=Vyt(t.name,r?r.value:``,i,{enabled:o&&r!==null});return{repositories:s?.repositories||[],isLoadingRepos:c,onCreateRepo:async()=>{if(!r)throw Error(`Please select a project`);await a.handleCreateRepo({namespace:r.value}),l()},reset:a.reset,showCreateRepoForm:a.showCreateRepoForm,setShowCreateRepoForm:a.setShowCreateRepoForm,newRepoName:a.newRepoName,setNewRepoName:a.setNewRepoName,isCreating:a.isCreating}},mqt=e=>{let{account:t,sourceControlConfig:n,selectedNamespace:r,searchTerm:i}=e,a=j7(e),o=n.provider===E7,{data:s,isLoading:c}=Vyt(t.name,r?r.value:``,i,{enabled:o&&r!==null});return{...a,repositories:s?.repositories||[],isLoadingRepos:c,reset:a.reset}},hqt=e=>{let{account:t,selectedNamespace:n,searchTerm:r}=e,i=j7(e),{data:a}=zyt(t.name),{data:o,isLoading:s,refetch:c}=Ryt(t.name),l=i.transformRepoToRepository;return{repositories:(0,U.useMemo)(()=>{if(!o?.data||!n)return[];let e=a?.find(e=>e.installationId===Number(n.value))?.slug||n.label;return(o.data[e]||[]).filter(e=>!r||e.name.toLowerCase().includes(r.toLowerCase())).map(e=>l(e,`gitlab`))},[o,n,r,a,l]),isLoadingRepos:s,onCreateRepo:async()=>{if(!n)throw Error(`Please select a namespace`);await i.handleCreateRepo({namespace:n.value}),c()},reset:i.reset,showCreateRepoForm:i.showCreateRepoForm,setShowCreateRepoForm:i.setShowCreateRepoForm,newRepoName:i.newRepoName,setNewRepoName:i.setNewRepoName,isCreating:i.isCreating}},gqt=250,_qt=({account:e,project:t,sourceControlConfig:n})=>{let{logEvent:r}=H(),i=n.provider,a=dqt(i),[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(``),f=$Kt(u,gqt),p=(0,U.useRef)(new Set),m=(0,U.useRef)(null),h=(0,U.useRef)(!1),[g,_]=(0,U.useState)(new Set),[v,y]=(0,U.useState)(!1),{data:b,isLoading:x,isFetching:S,error:C}=zyt(e.name),w=C instanceof He&&C.type===on.type,T={account:e,project:t,sourceControlConfig:n,selectedNamespace:c,searchTerm:f},E=fqt(T),D=hqt(T),O=pqt(T),k=mqt(T),A=(()=>{switch(i){case O7:return E;case T7:return D;case D7:return O;default:return k}})();(0,U.useEffect)(()=>{if(b&&b.length>0){let e=b[0];l({label:e.name,value:i===`AZURE`?e.slug:e.installationId.toString(),icon:a.icon(20)})}},[b,i,a]),(0,U.useEffect)(()=>{if(f!==``||A.isLoadingRepos)return;let e=c?.value?.toString()??null,t=A.repositories.map(e=>e.id);if(m.current!==e){m.current=e,p.current=new Set(t),_(new Set),y(!1);return}let n=t.filter(e=>!p.current.has(e));if(n.length>0){for(let e of n)p.current.add(e);h.current=!1,y(!1),_(new Set(n))}else h.current&&(h.current=!1,y(!0))},[A.repositories,A.isLoadingRepos,f,c]);let j=a=>{if(a.value===`add-github-account`){r(`source-control-add-account-selected`,{sourceControlNamespace:a.value,account:e.name,project:t.name,sourceControlProvider:i}),n.installUrl&&(h.current=!0,window.open(n.installUrl));return}r(`source-control-namespace-selected`,{sourceControlNamespace:a.value,sourceControlProvider:i,account:e.name,project:t.name}),s(``),l(a),A.reset()},M=[];b?.forEach(e=>{M.push({label:e.name,value:String(i===`AZURE`?e.slug:e.installationId),icon:a.icon(20)})}),i===`GITHUB`&&M.push({label:`Add GitHub Account`,value:`add-github-account`,icon:(0,W.jsx)(Op,{className:`mr-1.5`,size:16})});let N=()=>a.supportsProjects&&A.selectedProject?A.repositories.length>0?`Showing ${A.repositories.length} repositories from project: ${A.selectedProject.label}`:a.messages.grantAccess:!a.supportsProjects&&A.repositories.length>0?`Showing ${Math.min(A.repositories.length,5)} repositories`:a.supportsProjects&&!A.selectedProject?a.messages.selectAccount:`Select an account to view repositories`,P=()=>(0,W.jsx)(rqt,{installUrl:n.installUrl??``,selectedOrg:c?.label??``,projectName:t.name,provider:i,repoDescription:yD(t)?`Zuplo AI Gateway`:void 0,className:`w-full md:w-auto`,onContinue:()=>{h.current=!0}}),F=x||A.isLoadingRepos,I=!a.supportsProjects||A.selectedProject;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[w?(0,W.jsxs)(sb,{variant:`destructive`,children:[(0,W.jsx)(cb,{children:`Reconnect GitHub`}),(0,W.jsxs)(lb,{children:[(0,W.jsx)(`p`,{children:`Your saved GitHub credentials are no longer valid. Revoke the connection from your profile, then connect GitHub again.`}),(0,W.jsx)(Y,{asChild:!0,variant:`outline`,size:`sm`,className:`mt-2`,children:(0,W.jsx)(Pl,{to:Cb.Profile,children:`Go to profile`})})]})]}):(0,W.jsx)(ck,{error:C}),(0,W.jsx)(ck,{error:o}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-col gap-3 rounded-lg border p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,W.jsxs)(`div`,{className:`text-sm`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`Start fresh with a new repository`}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`We'll set up a ready-to-deploy Zuplo project so GitOps works right away.`})]}),P()]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 my-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,W.jsx)(`span`,{className:`h-px flex-1 bg-border`}),(0,W.jsx)(`span`,{children:`Or connect an existing repository`}),(0,W.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`We'll link this project to your repo. You'll push and pull changes manually.`})]}),F&&c===null&&(0,W.jsx)(nqt,{showHeader:!1}),!x&&(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(QKt,{testId:`namespace-selector`,placeholder:a.placeholder.namespace,options:M,selected:c,onChange:j,className:`flex-1 items-center h-9`,isLoadingData:S}),i===`AZURE`&&c&&(0,W.jsx)(eqt,{projects:A.projects,isLoadingProjects:A.isLoadingProjects||!1,selectedProject:A.selectedProject||null,onProjectChange:A.onProjectChange||(()=>{})}),(0,W.jsxs)(ZY,{className:`flex-2 w-full`,children:[(0,W.jsx)($Y,{value:u,onChange:e=>d(e.target.value),placeholder:a.placeholder.search}),(0,W.jsx)(QY,{align:`inline-start`,children:(0,W.jsx)(Ap,{className:`opacity-75`})}),u&&(0,W.jsx)(QY,{align:`inline-end`,children:(0,W.jsx)(Y,{variant:`ghost`,size:`icon-sm`,onClick:()=>d(``),children:(0,W.jsx)(Up,{})})})]})]}),(0,W.jsx)(lk,{className:`flex flex-col`,children:A.isLoadingRepos&&I?(0,W.jsxs)(`div`,{className:`flex flex-row items-center p-2 justify-center align-middle h-80`,children:[(0,W.jsx)(TP,{className:`w-4 h-4 mr-2`,borderPositionAndSize:`border-l-2`}),(0,W.jsx)(`span`,{children:`Loading repositories...`})]}):I&&A.repositories.length>0?(0,W.jsx)(lqt,{repositories:A.repositories,account:e,project:t,selectedNamespace:c,provider:i,onConnectError:s,newRepoIds:g}):I?(0,W.jsxs)(`div`,{className:`flex flex-col text-sm text-center gap-2 items-center justify-center h-80`,children:[(0,W.jsx)(`h2`,{className:`text-base`,children:`No Results Found`}),(0,W.jsx)(`p`,{children:u?`Your search for "${u}" did not return any results.`:a.messages.grantAccess})]}):(0,W.jsx)(`div`,{className:`flex items-center justify-center h-80`,children:(0,W.jsx)(`p`,{children:a.messages.selectAccount})})}),i===`GITHUB`&&n.installUrl&&(v?(0,W.jsxs)(sb,{variant:`info`,children:[(0,W.jsx)(cb,{children:`Don't see your repository?`}),(0,W.jsxs)(lb,{children:[`Check that you selected the right account above, and that you granted the Zuplo GitHub App access to that repository.`,` `,(0,W.jsx)(tE,{href:n.installUrl,onClick:()=>{h.current=!0},children:`Manage repository access →`})]})]}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-dashed p-3 text-sm sm:flex-row sm:items-center sm:justify-between`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`span`,{className:`font-medium`,children:`Missing repositories? `}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Zuplo only shows repositories you've granted the Zuplo GitHub App access to.`})]}),(0,W.jsx)(tE,{href:n.installUrl,className:`whitespace-nowrap`,onClick:()=>{h.current=!0},children:`Manage repository access →`})]})),(0,W.jsxs)(`div`,{className:`flex whitespace-pre-line text-gray-500 text-sm justify-between gap-4`,children:[(0,W.jsx)(`span`,{children:N()}),(i===`GITLAB`||i===`BITBUCKET`)&&n.installUrl&&(0,W.jsxs)(tE,{href:n.installUrl,className:`whitespace-pre`,children:[`Adjust `,a.name,` Permissions →`]})]})]})},vqt=({provider:e,url:t,org:n,name:r,children:i})=>(0,W.jsx)(lk,{className:`flex gap-2 flex-col`,offset:`md`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(w7,{providerName:e}),(0,W.jsx)(`div`,{className:`flex flex-col flex-1`,children:(0,W.jsxs)(`a`,{className:`text-sm font-semibold hover:text-zuplo-pink-hover underline flex gap-1 items-center`,href:t,target:`_blank`,rel:`noopener noreferrer`,children:[n,`/`,r,(0,W.jsx)(up,{className:`h-4 w-4`})]})}),i]})}),yqt=({account:e,project:t})=>{let{logEvent:n}=H(),r=nm([`account`,`project`]);if(!t.sourceRepoUrl)throw Error(`No sourceRepoUrl on project '${r.account.name}'`);let i=t.sourceRepoUrl.replace(`.git`,``),a,o,s=!1;try{s=new URL(t.sourceRepoUrl).hostname===`dev.azure.com`}catch{s=!1}if(s){let e=t.sourceRepoUrl.match(/^https:\/\/dev\.azure\.com\/([^/]+)\/([^/]+)\/_git\/([^/]+)/);if(e){a=e[1];let t=e[2],n=e[3].replace(`.git`,``);a=`${e[1]}/${t}`,o=n}else{let e=t.sourceRepoUrl.split(`/`);a=e[e.length-2],o=e[e.length-1]}}else{let e=t.sourceRepoUrl.split(`/`);a=e[e.length-2],o=e[e.length-1]}let c=TAe(e.name,t.name),l=async()=>{await c.mutateAsync(),n(`source-control-repo-disconnected`,{account:r.account.name,project:r.project.name})};return(0,W.jsx)(vqt,{org:a,name:o,url:i,provider:t.sourceControlProvider.toLowerCase(),children:(0,W.jsx)(Y,{"data-test":`disconnect-repo-button`,onClick:l,variant:`secondary`,className:`self-end`,disabled:c.isPending,children:(0,W.jsx)(CP,{className:`flex items-center gap-1`,loading:c.isPending,children:`Disconnect`})})})},bqt=({provider:e,onClose:t})=>{if(!e)return null;let n=Pb(e);return(0,W.jsx)(tT,{open:!!e,onOpenChange:e=>!e&&t(),children:(0,W.jsxs)(iT,{children:[(0,W.jsxs)(aT,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(w7,{providerName:e.toLowerCase(),size:28}),(0,W.jsxs)(sT,{children:[n,` Integration`]})]}),(0,W.jsxs)(cT,{className:`pt-2`,children:[n,` source control integration is available on Enterprise plans. Contact our sales team or book a demo to learn more about connecting your `,n,` repositories to Zuplo.`]})]}),(0,W.jsxs)(oT,{className:`mt-2`,children:[(0,W.jsx)(Y,{variant:`outline`,asChild:!0,children:(0,W.jsx)(tE,{href:`mailto:${xb}?subject=${encodeURIComponent(`${n} Source Control Integration`)}`,variant:`ghost`,children:`Contact Sales`})}),(0,W.jsx)(Y,{asChild:!0,children:(0,W.jsx)(tE,{href:bb,variant:`ghost`,children:`Book a Demo`})})]})]})})},M7=`sourceControlConnect`,xqt=`sourceControlConnectError`,Sqt=`sourceControlConnectSuccess`,Cqt=3e5,wqt=1e3;function Tqt(e){if(e.key!==`sourceControlConnectSuccess`&&e.key!==`sourceControlConnectError`||!e.newValue)return null;try{return JSON.parse(e.newValue)}catch{return null}}var Eqt=()=>{let{logEvent:e}=H(),{error:t}=em(),n=Je(),[r,i]=(0,U.useState)(!1),a=(0,U.useRef)(null),o=(0,U.useRef)(null);return(0,U.useEffect)(()=>()=>a.current?.(),[]),{connect:(r,s,c)=>{let{id:l,provider:u,clientId:d,scopes:f,redirectUri:p,providerUrl:m}=s;e(`source-control-provider-clicked`,{provider:u});let h=`${r}::${l}::${crypto.randomUUID()}`;localStorage.removeItem(M7),localStorage.removeItem(xqt),localStorage.removeItem(Sqt),localStorage.setItem(M7,h),i(!0);let g;if(u===`GITHUB`?g=f===``?`https://github.com/login/oauth/authorize?client_id=${d}`:`https://github.com/login/oauth/authorize?client_id=${d}&scope=${f}`:u===`GITLAB`?g=`${m}/oauth/authorize?client_id=${d}&redirect_uri=${p}&response_type=code&scope=${f}`:u===`BITBUCKET`?g=`${m}/site/oauth2/authorize?client_id=${d}&response_type=code`:u===`AZURE`&&(g=`https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=${d}&redirect_uri=${encodeURIComponent(p)}&response_type=code&response_mode=query&scope=${encodeURIComponent(f)}`),!g){i(!1),localStorage.removeItem(M7);return}let _=window.open(g),v=!1,y,b,x;function S(i){let a=Tqt(i);if(!(!a||a.connect!==h)){if(i.key===`sourceControlConnectSuccess`){w(()=>{e(`source-control-access-granted`,{account:r,sourceControlProvider:u}),n.invalidateQueries({queryKey:[R.accountsSourceControlConfigurations().url],exact:!1})});return}i.key===`sourceControlConnectError`&&w(()=>{t(a.message??``),c?.onFailure?.()})}}function C(){window.removeEventListener(`storage`,S),y!==void 0&&clearInterval(y),b!==void 0&&clearTimeout(b),x!==void 0&&clearTimeout(x),localStorage.removeItem(M7),localStorage.removeItem(xqt),localStorage.removeItem(Sqt),a.current=null,o.current=null}function w(e){v||(v=!0,i(!1),C(),e?.())}if(window.addEventListener(`storage`,S,!1),!_){w(()=>{t(`Couldn't open the ${Pb(u)} sign-in window. Your browser may be blocking pop-ups; allow them for this site and try again.`),e(`source-control-connect-popup-blocked`,{account:r,sourceControlProvider:u}),c?.onFailure?.()});return}y=setInterval(()=>{let n=!1;try{n=_.closed}catch{return}n&&(y!==void 0&&clearInterval(y),b=setTimeout(()=>{w(()=>{t(`We didn't get a response from the ${Pb(u)} sign-in window. Please try again.`),e(`source-control-connect-abandoned`,{account:r,sourceControlProvider:u}),c?.onFailure?.()})},wqt))},500),x=setTimeout(()=>{w(()=>{t(`Connecting to ${Pb(u)} timed out. Please try again.`),e(`source-control-connect-timeout`,{account:r,sourceControlProvider:u}),c?.onFailure?.()})},Cqt),a.current=C,o.current={account:r,provider:u}},isConnecting:r,cancel:()=>{let t=o.current;t&&e(`source-control-connect-abandoned`,{account:t.account,sourceControlProvider:t.provider}),a.current?.(),i(!1)}}},Dqt=({accountName:e,sourceControlConfig:t})=>{let{connect:n,isConnecting:r,cancel:i}=Eqt(),{provider:a}=t;return(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Y,{variant:`outline`,className:`gap-2`,disabled:r,onClick:()=>n(e,t),children:(0,W.jsx)(CP,{loading:r,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(w7,{providerName:a}),(0,W.jsx)(`span`,{children:`Connect to ${Pb(a)}`})]})})}),r&&(0,W.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:i,children:`Cancel`})]})},Oqt=[{key:T7,label:`GitLab`},{key:D7,label:`Bitbucket`}],kqt=({account:e,project:t,sourceControlConfig:n})=>{let{logEvent:r}=H(),[i,a]=(0,U.useState)(null);if(n?.userHasCredentials&&t.sourceRepoUrl)return(0,W.jsx)(yqt,{account:e,project:t});if(n&&!t.sourceRepoUrl&&n.userHasCredentials)return(0,W.jsx)(_qt,{account:e,project:t,sourceControlConfig:n});let o=n?Pb(n.provider):null;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(lk,{offset:`md`,className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`text-sm whitespace-pre-line text-gray-500`,children:[n&&t.sourceRepoUrl&&(0,W.jsxs)(`p`,{className:`mb-3`,children:[`This project is currently associated with a `,o,` `,`repository but you have not connected to your `,o,` `,`account.`]}),(0,W.jsx)(`p`,{children:`Connect to a source control provider to enable source control on your project.`})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n&&(0,W.jsx)(Dqt,{accountName:e.name,sourceControlConfig:n}),Oqt.map(({key:e,label:t})=>(0,W.jsxs)(Y,{variant:`outline`,className:`gap-2`,onClick:()=>{r(`source-control-provider-clicked`,{provider:e}),a(e)},children:[(0,W.jsx)(w7,{providerName:e.toLowerCase(),size:20}),(0,W.jsxs)(`span`,{children:[`Connect to `,t]})]},e))]})]}),(0,W.jsx)(bqt,{provider:i,onClose:()=>a(null)})]})},Aqt=()=>kb(R.accountsSourceControlConfigurations()),jqt=()=>{let{account:e,project:t}=nm([`account`,`project`]),{logEvent:n}=H();return(0,W.jsxs)(`div`,{className:`flex flex-col space-y-4`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Support`}),(0,W.jsx)(lk,{offset:`md`,className:`p-6`,children:(0,W.jsxs)(`div`,{className:`flex w-full gap-4 items-center`,children:[(0,W.jsx)(`div`,{className:`rounded-lg bg-gray-100 dark:bg-neutral-800 w-20 h-20 grid place-items-center`,children:(0,W.jsx)(Rte,{size:38,strokeWidth:1.6,fill:`#FF99E5`,fillOpacity:.2})}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(dk,{className:`text-base`,children:`Talk to an API expert`}),(0,W.jsx)(fk,{children:`Get a free technical consultation with one of our API experts.`})]}),(0,W.jsx)(Y,{onClick:()=>{n(`getting-started-book-a-meeting-clicked`,{account:e.name}),window.open(bb,`_blank`)},className:`min-w-40`,variant:`secondary`,asChild:!0,children:(0,W.jsxs)(tE,{href:bb,variant:`ghost`,children:[(0,W.jsx)(Jf,{}),`Book a Meeting`]})})]})}),(0,W.jsx)(lk,{offset:`md`,className:`p-6`,children:(0,W.jsxs)(`div`,{className:`flex w-full gap-4 items-center`,children:[(0,W.jsx)(`div`,{className:`rounded-lg bg-gray-100 dark:bg-neutral-800 w-20 h-20 grid place-items-center`,children:(0,W.jsx)(Cp,{size:38,strokeWidth:1.6,fill:`#FF99E5`,fillOpacity:.2})}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(dk,{className:`text-base`,children:`Feeling Stuck?`}),(0,W.jsx)(fk,{children:`Check out our various support options to get help with your API`})]}),(0,W.jsx)(Y,{className:`min-w-40`,variant:`secondary`,asChild:!0,children:(0,W.jsxs)(Pl,{to:Cb.Support,children:[(0,W.jsx)(Cp,{}),`Get Help`]})})]})}),(0,W.jsx)(lk,{offset:`md`,className:`p-6`,children:(0,W.jsxs)(`div`,{className:`flex w-full gap-4 items-center`,children:[(0,W.jsx)(`div`,{className:`rounded-lg bg-gray-100 dark:bg-neutral-800 w-20 h-20 grid place-items-center`,children:(0,W.jsx)(Rte,{size:38,strokeWidth:1.6,fill:`#FF99E5`,fillOpacity:.2})}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(dk,{className:`text-base`,children:`Join the Zuplo API Community`}),(0,W.jsx)(fk,{children:`Come chat with fellow Zuplo users and the Zuplo team in our Discord channel.`})]}),(0,W.jsx)(Y,{onClick:()=>{n(`getting-started-join-discord-clicked`,{account:e.name,project:t.name}),window.open(vb,`_blank`)},className:`min-w-40`,variant:`secondary`,asChild:!0,children:(0,W.jsxs)(tE,{href:vb,variant:`ghost`,children:[(0,W.jsx)(Ate,{size:16}),`Join Us`]})})]})})]})},Mqt=()=>{let{account:e,project:t,environment:n}=Ab([`account`,`project`,`environment`]);return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(uk,{children:[(0,W.jsx)(dk,{className:`text-base`,children:`Welcome to your Gateway`}),(0,W.jsx)(fk,{className:`text-base`,children:`You can get started by configuring your routes and setting up policies in our visual Route Designer.`})]}),(0,W.jsxs)(mk,{className:`border-0 gap-2 py-6`,children:[(0,W.jsx)(Y,{asChild:!0,size:`sm`,className:`gap-2 px-8`,variant:`brand-outline`,children:(0,W.jsxs)(Pl,{to:fo(Cb.Code,{account:e,project:t,environment:n}),children:[(0,W.jsx)(op,{size:16}),`Start Building`]})}),(0,W.jsx)(Y,{className:`px-8`,variant:`secondary`,size:`sm`,asChild:!0,children:(0,W.jsxs)(tE,{variant:`ghost`,href:`https://zuplo.com/docs/articles/step-1-setup-basic-gateway`,children:[(0,W.jsx)(gp,{size:16}),`Quickstart`]})})]})]})},Nqt=()=>{let[e,t]=(0,U.useState)(!1);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(lk,{className:`col-span-full md:col-span-3 py-2 px-4 flex items-center text-sm gap-x-2`,children:[(0,W.jsx)(`div`,{className:`rounded-full w-4 h-4 p-0.5 bg-gray-500`,children:(0,W.jsx)(ap,{className:`text-white`,size:12})}),(0,W.jsx)(`span`,{className:`font-semibold flex-1 line-clamp-1 break-all`,children:`Developer Portal`}),(0,W.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>t(!0),children:[(0,W.jsx)(gp,{}),`Open\xA0Portal`]})]}),(0,W.jsx)(tT,{open:e,onOpenChange:t,children:(0,W.jsxs)(iT,{children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:`Run Developer Portal Locally`}),(0,W.jsx)(cT,{children:`To view and edit your API documentation, you need to run the developer portal locally.`})]}),(0,W.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-sm font-semibold`,children:`Steps to run the portal:`}),(0,W.jsxs)(`ol`,{className:`list-decimal list-inside space-y-2 text-sm text-gray-600`,children:[(0,W.jsxs)(`li`,{children:[`Open a terminal in the`,` `,(0,W.jsx)(`code`,{className:`bg-gray-100 px-1 rounded-sm`,children:`/docs`}),` `,`folder of your Zuplo project`]}),(0,W.jsxs)(`li`,{children:[`Run`,` `,(0,W.jsx)(`code`,{className:`bg-gray-100 px-1 rounded-sm`,children:`npm run dev`})]}),(0,W.jsx)(`li`,{children:`The portal will open in your browser automatically`})]})]}),(0,W.jsx)(`div`,{className:`bg-info-muted border border-blue-200 dark:border-blue-800 rounded-md p-3`,children:(0,W.jsxs)(`p`,{className:`text-xs text-blue-800 dark:text-blue-200`,children:[(0,W.jsx)(`strong`,{children:`Tip:`}),` The developer portal will automatically reload when you make changes to your OpenAPI documentation.`]})})]}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`secondary`,onClick:()=>t(!1),children:`Close`}),(0,W.jsx)(Y,{asChild:!0,variant:`outline`,children:(0,W.jsx)(tE,{href:`https://zuplo.com/docs/dev-portal`,children:`View Documentation`})})]})]})})]})},Pqt=()=>{let{project:e,environment:t}=nm(),n=sF(t);return(0,W.jsx)(`div`,{className:`bg-neutral-50 dark:bg-neutral-950 h-full overflow-y-auto`,children:(0,W.jsxs)(`div`,{className:`pt-4 max-w-6xl pb-16 m-auto px-5 flex flex-col gap-4`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e.name}),(0,W.jsxs)(`div`,{className:`grid grid-cols-8 gap-3`,children:[(0,W.jsx)(HKt,{title:`Gateway`,url:n}),(0,W.jsx)(Nqt,{})]}),(0,W.jsxs)(lk,{className:`relative grid md:grid-cols-2 overflow-hidden min-h-[220px]`,children:[(0,W.jsx)(Mqt,{}),(0,W.jsxs)(`div`,{className:`hidden md:block self-end h-full w-full`,children:[(0,W.jsx)(`img`,{src:RKt,alt:e.name,className:`w-full h-full object-cover object-left dark:hidden`}),(0,W.jsx)(`img`,{src:zKt,alt:``,"aria-hidden":!0,className:`hidden w-full h-full object-cover object-left dark:block`})]})]}),(0,W.jsx)(VKt,{mode:`local`}),(0,W.jsx)(jqt,{})]})})},Fqt=()=>Ft().brand,Iqt=({account:e,accountLabel:t,navigateTo:n})=>{let{data:r,isLoading:i}=VT(e),a=vDe(e),o=i||a.isLoading,s=t||e,c=xDe(r,a).sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase()));return o?(0,W.jsx)(pT,{heading:s,forceMount:!0,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground`,"aria-live":`polite`,children:[(0,W.jsx)(wp,{className:`h-4 w-4 animate-spin`}),(0,W.jsx)(`span`,{children:`Loading projects...`})]})}):(0,W.jsx)(pT,{heading:s,children:c.map(r=>(0,W.jsxs)(mT,{value:`${e}/${r.name}`,keywords:t?[r.name,e,t]:[r.name,e],onSelect:()=>n(fo(Cb.Overview,{account:e,project:r.name})),children:[(0,W.jsx)(Uf,{className:`mr-3 h-4 w-4 text-neutral-600`}),(0,W.jsx)(`span`,{children:r.name})]},r.id))})},Lqt=({accounts:e,navigateTo:t})=>{let n=e?.map(e=>e.name)??[],r=yAe(n),i=yDe(n),a=[...e??[]].sort((e,t)=>(e.label||e.name).toLowerCase().localeCompare((t.label||t.name).toLowerCase())),o=(e??[]).flatMap((e,t)=>i[t]?xDe(r[t]?.data,i[t]).map(t=>({account:e,project:t})):[]).sort((e,t)=>e.project.name.toLowerCase().localeCompare(t.project.name.toLowerCase()));return(0,W.jsxs)(pT,{children:[a.map(e=>(0,W.jsxs)(mT,{value:e.name,keywords:[e.label||e.name,e.name],onSelect:()=>t(fo(Cb.AccountProjects,{account:e.name})),children:[(0,W.jsx)(qf,{className:`mr-3 h-4 w-4 text-neutral-600`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.label||e.name}),e.label&&e.label!==e.name&&(0,W.jsx)(`span`,{className:`ml-2 truncate text-xs text-muted-foreground`,children:e.name}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 pl-3 text-xs text-muted-foreground`,children:`Account`})]},`account:${e.name}`)),o.map(({account:e,project:n})=>(0,W.jsxs)(mT,{value:`${e.name}/${n.name}`,keywords:e.label?[n.name,e.name,e.label]:[n.name,e.name],onSelect:()=>t(fo(Cb.Overview,{account:e.name,project:n.name})),children:[(0,W.jsx)(Uf,{className:`mr-3 h-4 w-4 text-neutral-600`}),(0,W.jsx)(`span`,{className:`truncate`,children:n.name}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 pl-3 text-xs text-muted-foreground`,children:e.label||e.name})]},n.id))]})},Rqt=({accounts:e,navigateTo:t,search:n})=>n.trim()?(0,W.jsx)(Lqt,{accounts:e,navigateTo:t}):(0,W.jsxs)(W.Fragment,{children:[e?.map(e=>(0,W.jsx)(Iqt,{navigateTo:t,account:e.name,accountLabel:e.label},`projects-${e.name}`)),(0,W.jsx)(pT,{heading:`Accounts`,children:e?.map(e=>(0,W.jsxs)(mT,{keywords:[e.label||e.name,e.name],onSelect:()=>{t(fo(Cb.AccountProjects,{account:e.name}))},children:[(0,W.jsx)(qf,{className:`mr-2 h-4 w-4`}),(0,W.jsx)(`span`,{children:e.label||e.name}),e.label&&e.label!==e.name&&(0,W.jsx)(`span`,{className:`ml-2 truncate text-xs text-muted-foreground`,children:e.name})]},e.name))})]}),zqt=`__zuplo_commander_ask_ai__`,Bqt=.5,Vqt=(e,t,n)=>{if(e===`__zuplo_commander_ask_ai__`)return Bqt;let[r=e,...i]=n??[],a=qw(r,t);if(a>0)return 2+a;let o=i.reduce((e,n)=>Math.max(e,qw(n,t)),0);return o>0?1+o:0},Hqt=({query:e,onSelected:t})=>{let n=Ipt(),{logEvent:r}=H();if(!n?.enabled)return null;let i=e.trim();return(0,W.jsx)(pT,{children:(0,W.jsxs)(mT,{value:zqt,onSelect:()=>{r(`agent-z-panel-opened`,{source:`command-palette`}),n.openWithPrompt(i),t()},children:[(0,W.jsx)(`div`,{className:`mr-2`,children:(0,W.jsx)(Hy,{weight:`fill`,"aria-hidden":!0})}),(0,W.jsx)(`span`,{children:`Ask AI`}),i&&(0,W.jsx)(`span`,{className:`ml-2 truncate text-xs text-muted-foreground`,children:`"${i}"`})]})})},Uqt=({account:e,navigateTo:t,project:n,environment:r})=>(0,W.jsx)(pT,{heading:`Files`,children:cm(e=>e.projectTreeNodes).filter(e=>e.path&&e.type===$l.File).map(i=>(0,W.jsxs)(mT,{onSelect:()=>t(fo(`${Cb.Code}?path=${i.path}`,{account:e,project:n,environment:r})),children:[(0,W.jsx)(`div`,{className:`mr-3`,children:(0,W.jsx)(_p,{className:`h-4 w-4 text-neutral-500`})}),(0,W.jsx)(`span`,{className:`line-clamp-1`,children:i.path.substring(1)})]},i.path))}),Wqt=({children:e,className:t})=>(0,W.jsx)(`div`,{className:G(`bg-surface-sunken`,t),children:e}),Gqt=({children:e,className:t})=>(0,W.jsx)(`div`,{className:G(`pt-4 max-w-6xl pb-16 m-auto px-5 w-full`,t),children:e}),Kqt=({children:e,className:t,muted:n})=>(0,W.jsx)(`div`,{className:G(`bg-background`,n&&`bg-surface-sunken`),children:(0,W.jsx)(`div`,{className:G(`py-6 max-w-6xl mx-auto px-5 min-h-20 flex items-center w-full`,t),children:e})}),qqt=({children:e,className:t})=>(0,W.jsx)(`div`,{className:G(`text-sm text-foreground`,t),elementtiming:`page-description`,children:e}),Jqt=({children:e,className:t})=>(0,W.jsx)(`h1`,{className:G(`text-2xl font-semibold tracking-tight`,t),elementtiming:`page-title`,children:e});(0,U.createContext)(void 0);var Yqt=cF(`div`,`grid grid-cols-subgrid col-span-full w-full items-center border-b px-4 py-3 last:border-0`),Xqt=cF(`div`,`grid grid-cols-subgrid col-span-full w-full items-center border-b px-4 py-2.5 text-xs font-medium uppercase tracking-wide text-muted-foreground`),N7=({title:e,description:t,action:n,children:r,contentClassName:i})=>(0,W.jsxs)(Wqt,{className:`min-h-full`,children:[(0,W.jsx)(`div`,{className:`border-b`,children:(0,W.jsx)(Kqt,{muted:!0,children:(0,W.jsxs)(`div`,{className:`flex w-full flex-wrap items-start justify-between gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,W.jsx)(Jqt,{children:e}),t&&(0,W.jsx)(qqt,{className:`text-muted-foreground`,children:t})]}),n]})})}),(0,W.jsx)(Gqt,{className:G(`flex flex-col gap-5`,i),children:r})]}),Zqt=sk(alt),Qqt=(e,t)=>!!(e.models?.completions?.includes(t)||e.models?.embeddings?.includes(t)),$qt=(e,t)=>e.modelPrices&&Object.fromEntries(Object.entries(e.modelPrices).filter(([n])=>{let r=t(n);return r!==void 0&&Qqt(e,r)}));function eJt({assignment:e,children:t,onOpenChange:n}){let[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(!1),{startOpening:s,renderTrigger:c}=mlt(),l=(0,U.useCallback)(()=>{o(!1),n?.(!1),i(!1)},[n]),u=LP(a,l);return(0,W.jsxs)(tT,{open:r,onOpenChange:e=>{e?(n?.(!0),s(()=>i(!0))):u.guardedClose()},children:[(0,W.jsx)(nT,{asChild:!0,children:c(t)}),(0,W.jsxs)(iT,{className:`sm:max-w-4xl max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:(0,W.jsx)(X,{children:`Edit AI Provider`})}),(0,W.jsx)(cT,{children:(0,W.jsxs)(X,{children:[`The Provider Name is the routing address used in`,` `,(0,W.jsx)(`code`,{className:`font-mono`,translate:`no`,children:`providerName/model`}),` `,`references and cannot be changed.`]})})]}),(0,W.jsx)(tJt,{assignment:e,onDirtyChange:o,onClose:l})]}),(0,W.jsx)(IP,{open:u.showConfirm,onOpenChange:u.setShowConfirm,onDiscard:u.handleDiscard})]})}var tJt=({assignment:e,onDirtyChange:t,onClose:n})=>{let r=XY(),{logEvent:i}=H(),a=em(),o=CX(),s=(0,U.useRef)(null),c=P(),{account:l,project:u}=Ab([`account`,`project`]),{project:d}=nm([`project`]),{t:f}=ha(),p=Je(),m=oe(),h=e.provider!==`Custom`,g=R.bucketAiProviderAssignments(o).url,_={queryKey:[g,!0],queryFn:()=>Eb(g,m,{extractData:!0}).catch(e=>{if(e instanceof He)return null;throw e})};h&&!p.getQueryState(_.queryKey)&&p.prefetchQuery(_),(0,U.useEffect)(()=>()=>{p.removeQueries({queryKey:[g,!0],exact:!0})},[p,g]);let{data:v,providers:y}=kX().data,b=bne({queries:h?[_]:[]})[0]?.data,x=e.provider===`Custom`?e.customProviderName??e.provider:e.provider,S=y[x],C=S?.isCustom===!0,[w]=(0,U.useState)(()=>b?lct(b.find(({id:t})=>t===e.id)):void 0),T=(0,U.useRef)(w),E=(0,U.useMemo)(()=>[...v[x]??[]].sort((e,t)=>jX(e.model,t.model)),[v,x]),D=(0,U.useCallback)(e=>E.find(({id:t})=>t===e)?.model,[E]),O=(0,U.useMemo)(()=>{try{return JSON.parse(e.metadata)}catch{return{}}},[e.metadata]),k=ok({defaultValues:{provider:x,customProviderName:e.customProviderName,label:e.label,apiKey:``,envVarName:e.envVarName,region:jNe(e.endpointUrl)??FNe(e.endpointUrl)??UNe(e.endpointUrl)??``,awsAccessKeyId:``,awsSecretAccessKey:``,gcpProjectId:e.gcpProjectId??``,azureResourceName:nPe(e.endpointUrl)?.resourceName??``,azureHostSuffix:nPe(e.endpointUrl)?.hostSuffix??`openai.azure.com`,deploymentModels:iPe(e.deploymentModels),models:{completions:O.models?.completions??[],embeddings:O.models?.embeddings??[]},...w?{modelPrices:uct(w)}:{},...C?{customModels:E.map(e=>({modelId:e.id,name:e.model,kind:e.kind,status:e.status===`deprecated`?`deprecated`:`active`,inputCostPerToken:e.inputCostPerToken,outputCostPerToken:e.outputCostPerToken,cachedInputCostPerToken:e.cachedInputCostPerToken,cacheWriteCostPerToken:e.cacheWriteCostPerToken}))}:{}},mode:`onChange`,resolver:(e,t,n)=>Zqt({...e,modelPrices:$qt(e,D)},t,n),shouldFocusError:!1}),{isDirty:A}=OO(k);(0,U.useEffect)(()=>{t(A)},[A,t]);let j=I({mutationFn:async t=>{if(C&&S?.id){let e=xct(E,t.customModels);for(let t of e.deleted)await c.fetch(V.ai.deleteAiProviderModel(o,S.id,t));for(let t of e.repriced)await c.fetch(V.ai.updateAiProviderModel(o,S.id,t.id,{inputCostPerToken:t.inputCostPerToken,outputCostPerToken:t.outputCostPerToken,cachedInputCostPerToken:t.cachedInputCostPerToken,cacheWriteCostPerToken:t.cacheWriteCostPerToken}));for(let t of e.created)await c.fetch(V.ai.createAiProviderModel(o,S.id,{model:t.name,kind:t.kind,inputCostPerToken:t.inputCostPerToken,outputCostPerToken:t.outputCostPerToken,cachedInputCostPerToken:t.cachedInputCostPerToken,cacheWriteCostPerToken:t.cacheWriteCostPerToken,status:`active`}))}let n=GNe(t),r=KNe(t),i=await c.fetch(V.ai.updateAiProviderAssignment(l,u,e.id,{envVarName:t.envVarName,...r?{value:r}:{},...n?{endpointUrl:n}:{},...t.provider===`VertexAI`&&t.gcpProjectId?.trim()?{gcpProjectId:t.gcpProjectId.trim()}:{},...t.provider===`AzureAI`?{deploymentModels:rPe(t.deploymentModels)??{}}:{},metadata:{models:Sct(t,C)}}));if(r&&(k.setValue(`apiKey`,``),k.setValue(`awsAccessKeyId`,``),k.setValue(`awsSecretAccessKey`,``)),yD(d)&&r&&a.success((0,W.jsx)(X,{children:`Key updated. Your gateway is redeploying — this usually takes a minute or two.`}),{duration:DNe}),T.current){let n=pct(T.current,t.modelPrices,e=>Qqt(t,e),D);for(let t of n)try{let n=await c.fetch(V.ai.updateAiProviderAssignmentModelPrice(o,e.id,t.modelId,t.body,t.revision));T.current={...T.current,[t.modelId]:cct(n)}}catch(e){throw e instanceof He&&e.status===412?Error(f(`The price of {{model}} changed since it was read. Reload to see the current prices, then try again.`,{model:t.model})):e}}return i},onSuccess:()=>{k.reset(k.getValues()),n()},onSettled:(t,n)=>r(`provider.updated`,n?`failed`:`succeeded`,{provider:e.provider})});return(0,W.jsx)(HY,{...k,children:(0,W.jsxs)(`form`,{onSubmit:k.handleSubmit(e=>j.mutate(e),t=>i(`ai-gateway-update-ai-provider-invalid`,{provider:e.provider,fields:llt(t)})),className:`flex flex-col flex-1 min-h-0`,children:[(0,W.jsx)(ck,{error:j.error,className:`mb-4 break-all`}),(0,W.jsx)(plt,{form:k,scrollAreaRef:s,title:(0,W.jsx)(X,{children:`Your changes weren't saved.`}),className:`mb-4`}),(0,W.jsx)(`div`,{ref:s,className:`flex-1 min-h-0 overflow-y-auto px-1 space-y-4`,children:(0,W.jsx)(Oct,{form:k,mode:`edit`,providerDisabled:!0,assignmentPrices:w,pricesUnavailable:h&&!w})}),(0,W.jsxs)(oT,{className:`mt-4`,children:[(0,W.jsx)(Y,{type:`button`,variant:`ghost`,onClick:n,disabled:j.isPending,children:(0,W.jsx)(X,{children:`Cancel`})}),(0,W.jsx)(Y,{type:`submit`,disabled:j.isPending,children:(0,W.jsx)(CP,{loading:j.isPending,children:(0,W.jsx)(X,{children:`Save`})})})]})]})})},nJt=e=>e.label,P7=12,rJt=(0,W.jsx)(X,{children:`Connect API keys for providers like OpenAI and Anthropic and choose which models your gateway is allowed to route to.`}),iJt=()=>(0,W.jsx)(U.Suspense,{fallback:null,children:(0,W.jsx)(HX,{children:(0,W.jsxs)(Y,{children:[(0,W.jsx)(Op,{size:16}),(0,W.jsx)(X,{children:`Add Provider`})]})})}),aJt=()=>(0,W.jsx)(PX,{source:`providers-page`,children:(0,W.jsxs)(Y,{variant:`outline`,children:[(0,W.jsx)(Mte,{size:16}),(0,W.jsx)(X,{children:`Request a provider or model`})]})}),oJt=()=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,W.jsx)(aJt,{}),(0,W.jsx)(iJt,{})]}),sJt=()=>(0,W.jsx)(W.Fragment,{children:[0,1].map(e=>(0,W.jsxs)(lk,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-5`,children:[(0,W.jsx)(wD,{className:`size-10 rounded-lg`}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(wD,{className:`h-5 w-48`}),(0,W.jsx)(wD,{className:`h-3 w-32`})]})]}),(0,W.jsx)(`div`,{className:`border-t`}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 p-5`,children:[(0,W.jsx)(wD,{className:`h-3 w-24`}),(0,W.jsx)(wD,{className:`h-4 w-full max-w-2xl`})]})]},e))}),cJt=()=>{let e=XY(),{account:t,project:n}=Ab([`account`,`project`]),r=Ob(R.aiProviderAssignments(t,n)),i=P(),a=I({mutationFn:async e=>i.fetch(V.ai.deleteAiProviderAssignment(t,n,e)),onSettled:(t,n)=>e(`provider.deleted`,n?`failed`:`succeeded`)}),o=r.data;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ck,{error:a.error}),o.length>0?o.map(e=>(0,W.jsx)(uJt,{assignment:e,onDelete:()=>a.mutate(e.id)},e.id)):(0,W.jsx)(lk,{children:(0,W.jsxs)(db,{children:[(0,W.jsxs)(fb,{children:[(0,W.jsx)(pb,{variant:`icon`,children:(0,W.jsx)(Gf,{})}),(0,W.jsx)(mb,{children:(0,W.jsx)(X,{children:`No AI providers yet`})}),(0,W.jsx)(hb,{children:(0,W.jsx)(X,{children:`Connect API keys for providers like OpenAI and Anthropic so your gateway can route requests to their models.`})})]}),(0,W.jsx)(gb,{children:(0,W.jsx)(HX,{})})]})})]})},lJt=({assignment:e})=>(0,W.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-zuplo-100 text-lg font-semibold text-zuplo-700 dark:bg-zuplo-950/50 dark:text-zuplo-300`,children:(e.label||e.provider||`?`).trim().charAt(0).toUpperCase()}),uJt=({assignment:e,onDelete:t})=>{let[n,r]=(0,U.useState)(!1),i=(0,U.useCallback)(()=>r(!0),[]),{completions:a,embeddings:o}=(0,U.useMemo)(()=>{try{let t=JSON.parse(e.metadata);return{completions:t.models?.completions??[],embeddings:t.models?.embeddings??[]}}catch{return{completions:[],embeddings:[]}}},[e.metadata]),s=a.length+o.length,c=nJt(e),l=e.provider===`Custom`,u=e.provider===qNe,d=a.length>P7||o.length>P7;return(0,W.jsxs)(lk,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4 p-5`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,W.jsx)(lJt,{assignment:e}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`truncate text-lg font-medium`,children:e.label}),(0,W.jsx)(qT,{variant:`outline`,size:`default`,children:l?e.customProviderName===e.label?e.customProviderName:(0,W.jsx)(X,{children:`Custom`}):u?JNe:e.provider})]}),u?(0,W.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 text-xs text-amber-700 dark:text-amber-400`,children:[(0,W.jsx)(Bp,{size:12}),(0,W.jsx)(`span`,{className:`truncate`,children:(0,W.jsx)(X,{children:`Demo provider — not for production`})})]}):(0,W.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,W.jsx)(Sp,{size:12}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:e.envVarName})]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(eJt,{assignment:e,children:(0,W.jsx)(Y,{variant:`ghost`,size:`icon`,title:`Edit provider`,"aria-label":`Edit provider`,children:(0,W.jsx)(Dp,{size:16})})}),(0,W.jsx)(xvt,{onConfirm:t,description:(0,W.jsx)(X,{children:`Are you sure you want to delete this provider? Apps using its models will stop working.`}),children:(0,W.jsx)(Y,{variant:`ghost`,size:`icon`,title:`Delete provider`,"aria-label":`Delete provider`,className:`text-muted-foreground hover:text-destructive-foreground`,children:(0,W.jsx)(zp,{size:16})})})]})]}),(0,W.jsx)(`div`,{className:`border-t`}),s===0?(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4 p-5`,children:[(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,W.jsx)(X,{children:`No models are enabled for this provider yet.`})}),(0,W.jsx)(eJt,{assignment:e,children:(0,W.jsx)(Y,{variant:`outline`,size:`sm`,children:(0,W.jsx)(X,{children:`Select models`})})})]}):(0,W.jsxs)(`div`,{className:`space-y-4 p-5`,children:[(0,W.jsx)(dJt,{icon:(0,W.jsx)(Nte,{size:14}),title:(0,W.jsx)(X,{children:`Chat`}),models:a,referenceKey:c,expanded:n,onReveal:i}),(0,W.jsx)(dJt,{icon:(0,W.jsx)(xte,{size:14}),title:(0,W.jsx)(X,{children:`Embeddings`}),models:o,referenceKey:c,expanded:n,onReveal:i}),d&&(0,W.jsx)(Y,{variant:`link`,size:`sm`,className:`h-auto px-0`,onClick:()=>r(e=>!e),children:n?(0,W.jsx)(X,{children:`Show fewer models`}):(0,W.jsxs)(X,{children:[`Show all `,{count:s},` models`]})})]})]})},dJt=({icon:e,title:t,models:n,referenceKey:r,expanded:i,onReveal:a})=>{if(n.length===0)return null;let o=n.slice(P7);return(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[e,(0,W.jsx)(`span`,{children:t}),(0,W.jsx)(`span`,{className:`text-muted-foreground/70`,children:`·`}),(0,W.jsx)(`span`,{className:`text-muted-foreground/70`,children:n.length})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(fJt,{models:n.slice(0,P7),referenceKey:r}),o.length>0&&(0,W.jsx)(mJt,{hidden:!i,onReveal:a,children:(0,W.jsx)(fJt,{models:o,referenceKey:r,className:`mt-1`})})]})]})},fJt=({models:e,referenceKey:t,className:n})=>(0,W.jsx)(`ul`,{className:G(`grid grid-cols-1 gap-x-6 gap-y-1 font-mono text-xs sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,n),children:e.map(e=>(0,W.jsx)(pJt,{model:e,referenceKey:t},e))}),pJt=({model:e,referenceKey:t})=>{let n=t?`${t}/${e}`:e,{copyToClipboard:r,state:i}=zw(n);return(0,W.jsx)(`li`,{className:`min-w-0`,children:(0,W.jsx)(Iw,{copied:i===`copied`,delayDuration:300,hint:(0,W.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,W.jsx)(`span`,{className:`font-mono`,children:n}),(0,W.jsx)(`span`,{className:`text-background/70`,children:(0,W.jsx)(X,{children:`Click to copy full name`})})]}),children:(0,W.jsx)(`button`,{type:`button`,onClick:()=>void r(),"aria-label":`Copy ${n}`,className:`block w-full cursor-pointer truncate rounded-xs text-left outline-none hover:underline hover:decoration-dotted hover:underline-offset-4 focus-visible:ring-2 focus-visible:ring-ring`,children:e})})})},mJt=({hidden:e,onReveal:t,children:n})=>{let r=(0,U.useRef)(null);return(0,U.useLayoutEffect)(()=>{let t=r.current;t&&(e?t.setAttribute(`hidden`,`until-found`):t.removeAttribute(`hidden`))},[e]),(0,U.useEffect)(()=>{let e=r.current;if(e)return e.addEventListener(`beforematch`,t),()=>e.removeEventListener(`beforematch`,t)},[t]),(0,W.jsx)(`div`,{ref:r,children:n})},hJt=()=>(0,W.jsx)(N7,{title:`AI Gateway`,description:rJt,action:(0,W.jsx)(oJt,{}),children:(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(sJt,{}),children:(0,W.jsx)(cJt,{})})}),gJt=e=>e.plan===`FREE_V1`,_Jt=({account:e,className:t,source:n})=>{let r=e.customDomainsInUse,i=e.entitlements.customDomains,a=gJt(e),o=`${fo(Cb.AccountSettings,{account:e.name})}/upgrade-billing?source=${n}`;return(0,W.jsxs)(lk,{variant:`default`,className:t,children:[(0,W.jsx)(uk,{children:a?`Custom domains require a paid plan`:`Custom domain limit reached`}),(0,W.jsx)(pk,{className:`text-sm leading-relaxed`,children:a?(0,W.jsx)(`p`,{children:`Custom domains let you serve your APIs and developer portal from your own domain. Upgrade to the Builder plan to add custom domains to your account.`}):(0,W.jsxs)(`p`,{children:[`Your account is using`,` `,(0,W.jsxs)(`span`,{className:`font-medium`,children:[r,` of `,i]}),` `,`custom domains. Contact our team to increase your limit.`]})}),(0,W.jsxs)(mk,{className:`flex flex-wrap items-center gap-2`,children:[a?(0,W.jsx)(Y,{asChild:!0,children:(0,W.jsx)(ub,{variant:`ghost`,to:o,children:`Upgrade to Builder`})}):(0,W.jsx)(Y,{asChild:!0,children:(0,W.jsx)(tE,{href:bb,variant:`ghost`,children:`Contact Sales`})}),(0,W.jsx)(Y,{variant:`outline`,asChild:!0,children:(0,W.jsx)(ub,{variant:`ghost`,to:o,children:`View Plans`})})]})]})},vJt=({used:e,max:t,label:n,account:r,navigationSource:i,className:a,hideAtLimit:o=!1})=>{if(t<=0)return null;let s=e>=t,c=r.plan.startsWith(`FREE`),l=`${fo(Cb.AccountSettings,{account:r.name})}/upgrade-billing${i?`?source=${i}`:``}`;return s?o?null:(0,W.jsxs)(sb,{variant:`warning`,className:a,children:[(0,W.jsx)(Bp,{}),(0,W.jsx)(lb,{children:(0,W.jsxs)(`p`,{children:[`You've reached the limit of `,t,` `,n,` on your plan (`,e,` of`,` `,t,` used).`,` `,c?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ub,{to:l,className:`hover:text-zuplo-pink-hover text-zuplo-pink underline`,children:`Upgrade your plan`}),` `,`to add more.`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tE,{href:`mailto:${xb}`,className:`text-zuplo-pink hover:text-zuplo-pink-hover underline`,children:`Contact sales`}),` `,`to increase your limit.`]})]})})]}):(0,W.jsxs)(`p`,{className:G(`text-sm text-muted-foreground`,a),children:[`Using `,e,` of `,t,` `,n,`.`]})},yJt=({className:e})=>(0,W.jsxs)(lk,{variant:`info`,className:e,children:[(0,W.jsx)(uk,{children:`Managed Dedicated Project`}),(0,W.jsx)(pk,{className:`flex-1 leading-loose mt-1 text-sm`,children:(0,W.jsxs)(`p`,{className:`leading-loose`,children:[`This project uses Akamai managed dedicated hosting. Custom domains for Akamai must be configured through Akamai CDN. See`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/dedicated/akamai/cdn`,children:`Akamai custom domain documentation`}),`.`]})})]}),F7=`Switch`,[bJt,xJt]=we(F7),[SJt,CJt]=bJt(F7),wJt=U.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=U.useState(null),m=L(t,e=>p(e)),h=U.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=B({prop:i,defaultProp:a??!1,onChange:l,caller:F7});return(0,W.jsxs)(SJt,{scope:n,checked:_,disabled:s,children:[(0,W.jsx)(pu.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":kJt(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:su(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,W.jsx)(OJt,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});wJt.displayName=F7;var TJt=`SwitchThumb`,EJt=U.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=CJt(TJt,n);return(0,W.jsx)(pu.span,{"data-state":kJt(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});EJt.displayName=TJt;var DJt=`SwitchBubbleInput`,OJt=U.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=U.useRef(null),s=L(o,a),c=BJ(n),l=bn(t);return U.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,W.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});OJt.displayName=DJt;function kJt(e){return e?`checked`:`unchecked`}var AJt=wJt,jJt=EJt;function MJt({className:e,...t}){return(0,W.jsx)(AJt,{"data-slot":`switch`,className:G(`peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,W.jsx)(jJt,{"data-slot":`switch-thumb`,className:G(`bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}var I7=({customDomain:e,cname:t,documentationUrl:n=`https://www.zuplo.com/docs/guides/custom-domain-setup`})=>(0,W.jsxs)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[(0,W.jsx)(`p`,{children:`We've set things up on our end, now you need to configure your DNS with a new entry.`}),(0,W.jsx)(`br`,{}),(0,W.jsx)(lk,{variant:`muted`,className:`font-mono p-4 text-sm`,children:(0,W.jsxs)(`ol`,{children:[(0,W.jsx)(`li`,{className:`leading-6`,children:`Type: CNAME`}),(0,W.jsxs)(`li`,{className:`leading-6`,children:[`Name: `,e,` `,(0,W.jsx)(EP,{textToCopy:e??``})]}),(0,W.jsxs)(`li`,{className:`leading-6`,children:[`Value: `,t,` `,(0,W.jsx)(EP,{textToCopy:t??``})]}),(0,W.jsx)(`li`,{className:`leading-6`,children:`TTL: 60s or auto`})]})}),(0,W.jsx)(`br`,{}),(0,W.jsx)(`p`,{children:`Note that it does sometimes take a few hours for records to propagate and for the SSL certificate to be created.`}),(0,W.jsx)(`br`,{}),(0,W.jsxs)(`p`,{children:[`For more information see our`,` `,(0,W.jsx)(tE,{href:n,children:`documentation on custom domains`}),`.`]})]});function NJt({projectType:e,defaultConfiguration:t}){return e===`managed-dedicated`&&t.some(e=>!!e.managedDedicatedConfiguration)}function PJt({stage:e,isManagedDedicatedProject:t,isAkamaiManagedDedicatedProject:n,formIsAlias:r}){return e===`dev-portal`?!1:n?!0:t?!1:r??!1}function FJt({projectType:e,defaultConfiguration:t}){return e===`managed-dedicated`&&t.some(e=>e.managedDedicatedConfiguration?.vendor===`akamai`)}function IJt({project:e,isAkamaiManagedDedicatedProject:t}){return t||!e?!1:!yD(e)}var L7=()=>(0,W.jsxs)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[(0,W.jsx)(`p`,{children:`This custom domain is setup with an advanced configuration. In order to make changes to this domain, please contact support.`}),(0,W.jsx)(`br`,{}),(0,W.jsxs)(`p`,{children:[`For more information see our`,` `,(0,W.jsx)(tE,{href:`https://www.zuplo.com/docs/guides/custom-domain-setup`,children:`documentation on custom domains`}),`.`]})]}),LJt=/^(?!https?:\/\/)[a-zA-Z0-9.-]*\.[a-zA-Z]+$/,RJt=`https://zuplo.com/docs/dedicated/custom-domains`,zJt=Dh({project:Ch().min(1),hostname:Ch().regex(LJt,`Please enter a valid domain name (e.g. api.example.com)`),environment:Ch().min(1),stage:kh([`api`,`dev-portal`]),isAlias:Th().optional()}),BJt=({account:e,projectName:t,disabled:n=!1,isManagedDedicatedProject:r=!1,isAkamaiManagedDedicatedProject:i=!1})=>{let a=t===void 0,o=lc(),s=ok({resolver:sk(zJt),defaultValues:{project:t??``,hostname:``,environment:``,stage:`api`,isAlias:i}}),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(`project`),[f,p,m]=s.watch([`isAlias`,`stage`,`project`]),{data:h,isLoading:g}=qP(e.name,m,{enabled:!!m}),{aliasDomains:_}=e.entitlements,{data:v}=VT(e.name),y=v?.find(e=>e.name===m),b=y?DFe(new Date(Number(y.createdOn)),new Date(`2025-04-01`)):!1,x=(v??[]).filter(e=>e.type!==`self-hosted`&&e.deployedEnvironmentCount>0).sort((e,t)=>e.name.localeCompare(t.name)),{data:S,isLoading:C}=HT(e.name,m,{enabled:a&&!!m}),w=a?NJt({projectType:y?.type,defaultConfiguration:S?.defaultConfiguration??[]}):r,T=a?FJt({projectType:y?.type,defaultConfiguration:S?.defaultConfiguration??[]}):i,E=IJt({project:y,isAkamaiManagedDedicatedProject:T}),D=h?h.filter(e=>e.environmentType!==BP.WORKING_COPY):[],O=qKt({onSuccess:()=>{PJt({stage:p,isManagedDedicatedProject:w,isAkamaiManagedDedicatedProject:T,formIsAlias:f})&&!a&&l(!1)}}),k=(0,U.useCallback)(()=>{s.reset(),O.isSuccess&&O.reset(),d(`project`),l(!1)},[s,O]),A=LP(s.formState.isDirty&&!O.isSuccess,k),j=()=>{l(!1),o(`${fo(Cb.Settings,{account:e.name,project:m})}/custom-domain`)},M=a&&v!==void 0&&x.length===0,N=!a||u===`details`,P=g||C;return(0,W.jsxs)(tT,{open:c,onOpenChange:e=>{e?l(!0):A.guardedClose()},children:[(0,W.jsx)(nT,{asChild:!0,children:(0,W.jsx)(Y,{"data-test":`create-custom-domain-modal-btn`,disabled:n,title:n?`You reached the limit of custom domains`:``,children:`Add Custom Domain`})}),(0,W.jsxs)(iT,{children:[(0,W.jsx)(aT,{children:(0,W.jsx)(sT,{children:`Add Custom Domain`})}),(0,W.jsx)(`div`,{className:`space-y-4`,children:O.isSuccess?(0,W.jsxs)(W.Fragment,{children:[w&&!f&&p===`api`?O.data?.cname?(0,W.jsx)(I7,{customDomain:s.getValues(`hostname`),cname:O.data.cname,documentationUrl:RJt}):(0,W.jsx)(L7,{}):!_&&O.data?.cname&&(0,W.jsx)(I7,{customDomain:s.getValues(`hostname`),cname:O.data?.cname}),!w&&!_&&!O.data?.cname&&p===`api`&&(0,W.jsx)(L7,{}),(0,W.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[a&&(0,W.jsx)(Y,{type:`button`,variant:`secondary`,"data-test":`view-custom-domain-btn`,onClick:j,children:`View in project`}),(0,W.jsx)(rT,{asChild:!0,children:(0,W.jsx)(Y,{"data-test":`ok-create-custom-domain-btn`,children:`Done`})})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ck,{error:O.error}),(0,W.jsx)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:(0,W.jsxs)(HY,{...s,children:[N&&T&&(0,W.jsx)(sb,{variant:`info`,children:(0,W.jsx)(lb,{children:`Make sure this hostname is already configured in your Akamai CDN. Registering it here records the alias domain with Zuplo so your public URLs match the client-facing domain.`})}),N&&b&&E&&(0,W.jsxs)(sb,{variant:`warning`,children:[(0,W.jsx)(cb,{children:`Preview Notice`}),(0,W.jsxs)(lb,{children:[`Custom domains for the Dev Portal are currently in preview and only available after the migration to our preview version.`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/custom-domains`,target:`_blank`,children:`Learn more`})]})]}),(0,W.jsx)(`form`,{onSubmit:s.handleSubmit(async t=>{await O.mutateAsync({accountName:e.name,projectName:t.project,isAlias:PJt({stage:t.stage,isManagedDedicatedProject:w,isAkamaiManagedDedicatedProject:T,formIsAlias:t.isAlias}),hostname:t.hostname,deploymentName:t.environment,stage:t.stage})}),children:a&&u===`project`?(0,W.jsxs)(W.Fragment,{children:[M?(0,W.jsx)(`p`,{className:`mt-2`,children:`You don't have any projects that can use a custom domain yet. Custom domains require a project with a deployed (edge) environment.`}):(0,W.jsx)(UY,{control:s.control,name:`project`,render:({field:e})=>(0,W.jsxs)(GY,{className:`mt-2`,children:[(0,W.jsx)(rE,{className:`block`,htmlFor:`project-field`,children:`Which project is this domain for?`}),(0,W.jsxs)(gY,{value:e.value,onValueChange:t=>{e.onChange(t),s.setValue(`environment`,``),s.setValue(`stage`,`api`),s.setValue(`isAlias`,!1)},disabled:O.isPending,children:[(0,W.jsx)(vY,{id:`project-field`,"data-test":`project-field`,className:`w-full`,children:(0,W.jsx)(_Y,{placeholder:`Select a project`})}),(0,W.jsx)(yY,{children:x.map(e=>(0,W.jsx)(bY,{value:e.name,children:e.name},e.id))})]}),(0,W.jsx)(YY,{})]})}),(0,W.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[(0,W.jsx)(rT,{asChild:!0,children:(0,W.jsx)(Y,{type:`button`,variant:`secondary`,"data-test":`cancel-create-custom-domain-btn`,children:`Cancel`})}),!M&&(0,W.jsx)(Y,{type:`button`,"data-test":`continue-create-custom-domain-btn`,disabled:!m||P,onClick:()=>d(`details`),children:(0,W.jsx)(CP,{loading:!!m&&P,children:`Continue`})})]})]}):(0,W.jsxs)(W.Fragment,{children:[a&&(0,W.jsxs)(`div`,{className:`mt-2 mb-1 flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Project:`,` `,(0,W.jsx)(`span`,{className:`font-medium text-foreground`,children:m})]}),(0,W.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,"data-test":`change-project-custom-domain-btn`,onClick:()=>d(`project`),disabled:O.isPending,children:`Change`})]}),g?(0,W.jsx)(wD,{className:`h-9 mt-4`}):D.length>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(UY,{control:s.control,name:`environment`,render:({field:e})=>(0,W.jsxs)(GY,{className:`mt-2`,children:[(0,W.jsx)(rE,{htmlFor:`environment-field`,children:`Which environment do you want to apply your new domain to?`}),(0,W.jsx)(WP,{id:`environment-field`,"data-test":`environment-field`,environments:D,value:e.value,onValueChange:e.onChange,disabled:O.isPending,placeholder:`Select an environment`}),(0,W.jsx)(YY,{})]})}),E&&(0,W.jsx)(UY,{control:s.control,name:`stage`,render:({field:e})=>(0,W.jsxs)(GY,{className:`mt-2`,children:[(0,W.jsx)(rE,{className:`block`,htmlFor:`stage-field`,children:`What do you want the custom domain to be assigned to?`}),(0,W.jsxs)(gY,{onValueChange:t=>{(t===`api`||t===`dev-portal`)&&e.onChange(t)},disabled:O.isPending,...e,children:[(0,W.jsx)(vY,{id:`stage-field`,className:`w-full`,children:(0,W.jsx)(_Y,{placeholder:`Select a stage`})}),(0,W.jsxs)(yY,{children:[(0,W.jsx)(bY,{value:`api`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(bp,{size:16}),` Gateway`]})}),(0,W.jsx)(bY,{value:`dev-portal`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Qte,{size:16}),` Dev Portal`,(0,W.jsx)(qT,{className:``,variant:`info`,children:`New`})]})})]})]}),(0,W.jsx)(YY,{})]})}),(0,W.jsx)(UY,{control:s.control,name:`hostname`,render:({field:e})=>(0,W.jsxs)(GY,{className:`mt-2`,children:[(0,W.jsx)(rE,{htmlFor:`hostname-field`,children:`Your custom domain (e.g. example.com or api.example.com)`}),(0,W.jsx)(nE,{type:`text`,autoComplete:`off`,placeholder:`api.example.com`,id:`hostname-field`,"data-test":`hostname-field`,...e,disabled:O.isPending}),(0,W.jsx)(YY,{})]})}),(0,W.jsx)(UY,{control:s.control,name:`isAlias`,render:({field:e})=>(0,W.jsx)(GY,{className:G((!_||p===`dev-portal`||w)&&`hidden`,`mt-2`),children:(0,W.jsxs)(lk,{className:`p-4 flex items-center gap-3`,children:[(0,W.jsxs)(rE,{className:`flex flex-col gap-2`,htmlFor:`isAlias`,children:[`Is this an alias domain?`,(0,W.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`If your API Gateway is behind a CDN or WAF, your clients may use a different domain. Use an`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/custom-domains#alias-domains`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`alias domain`}),` `,`so public URLs like docs and OpenAPI match the client-facing domain.`]})]}),(0,W.jsx)(MJt,{className:`mx-3`,id:`isAlias`,"data-test":`isAlias`,checked:e.value??!1,onCheckedChange:e.onChange,disabled:O.isPending}),(0,W.jsx)(YY,{})]})})}),(0,W.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[a?(0,W.jsx)(Y,{type:`button`,variant:`secondary`,"data-test":`back-create-custom-domain-btn`,disabled:O.isPending,onClick:()=>d(`project`),children:`Back`}):(0,W.jsx)(rT,{asChild:!0,children:(0,W.jsx)(Y,{type:`button`,"data-test":`cancel-create-custom-domain-btn`,disabled:O.isPending,variant:`secondary`,children:`Cancel`})}),(0,W.jsx)(Y,{type:`submit`,"data-test":`create-custom-domain-btn`,disabled:O.isPending,children:(0,W.jsx)(CP,{loading:O.isPending,children:`Create`})})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`mt-4`,children:`Custom domains can only be configured on edge deployment environments and this project only has a working-copy environment.`}),(0,W.jsx)(`br`,{}),(0,W.jsxs)(`p`,{children:[` `,`For more information on this see our`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/environments`,children:`documentation on environments`}),`.`]}),a&&(0,W.jsx)(`div`,{className:`mt-5 sm:mt-4 flex justify-end`,children:(0,W.jsx)(Y,{type:`button`,variant:`secondary`,"data-test":`back-create-custom-domain-btn`,onClick:()=>d(`project`),children:`Back`})})]})]})})]})})]})})]}),(0,W.jsx)(IP,{open:A.showConfirm,onOpenChange:A.setShowConfirm,onDiscard:A.handleDiscard})]})},VJt=`https://zuplo.com/docs/dedicated/custom-domains`,HJt=({customDomain:e,isManagedDedicatedProject:t,isAkamaiManagedDedicatedProject:n})=>{let[r,i]=(0,U.useState)(void 0),a=()=>{s(),i(void 0)},[o,s]=I$(()=>{let i=r?.deployments.at(0)?.stage,o=r?.deployments.at(0)?.cname,s=typeof o==`string`&&o.length>0;return(0,W.jsx)(HP,{onClose:a,isOpen:!0,title:`Configure your custom domain`,children:(0,W.jsx)(`div`,{className:`space-y-4`,children:n?(0,W.jsx)(yJt,{}):t&&i===`api`?s?(0,W.jsx)(I7,{customDomain:r?.hostname,cname:o,documentationUrl:VJt}):(0,W.jsx)(L7,{}):e.provider===`custom`?(0,W.jsx)(L7,{}):e.provider===`amazon`?s?(0,W.jsx)(I7,{customDomain:r?.hostname,cname:o,documentationUrl:VJt}):(0,W.jsx)(L7,{}):s?(0,W.jsx)(I7,{customDomain:r?.hostname,cname:o}):(0,W.jsx)(L7,{})})})},[r]),c=e=>{i(e),o()};return(0,W.jsx)(Y,{onClick:()=>{c(e)},"data-test":`view-domain-configuration-btn`,title:`View Configuration`,variant:`ghost`,size:`icon`,children:(0,W.jsx)(xp,{size:18})})},UJt=/held zone/i;function WJt(e){return!!e?.some(e=>UJt.test(e))}var GJt=new Set([`pending`,`pending_migration`,`pending_provisioned`,`active_redeploying`,`provisioned`]),KJt=new Set([`blocked`,`pending_blocked`,`moved`,`deleted`,`pending_deletion`,`test_blocked`,`test_failed`]),qJt=new Set([`initializing`,`pending_validation`,`pending_issuance`,`pending_deployment`,`pending_cleanup`,`staging_deployment`,`holding_deployment`]),JJt=new Set([`expired`,`deactivating`,`inactive`,`initializing_timed_out`,`validation_timed_out`,`issuance_timed_out`,`deployment_timed_out`,`deletion_timed_out`,`deleted`,`pending_deletion`,`pending_expiration`]);function YJt(e){if(e.provider===`alias`)return null;if(e.provider===`custom`||e.provider===`amazon`)return{level:`unknown`,label:`Externally managed`,description:`This domain's status isn't reported to Zuplo — verification and certificates are handled by your dedicated infrastructure provider.`};let t=e.verificationErrors&&e.verificationErrors.length>0,n=e.status??null,r=e.sslStatus??null;if(!n&&!r&&!t)return{level:`pending`,label:`Initializing`,description:`We're waiting for the domain provider to report a status. This usually takes a few seconds after the domain is created.`};if(WJt(e.verificationErrors))return{level:`error`,label:`Zone hold`,description:`Cloudflare is blocking this hostname because the parent domain has a zone hold on another Cloudflare account. The zone owner needs to release the hold before we can finish provisioning.`,helpUrl:`https://developers.cloudflare.com/fundamentals/account/account-security/zone-holds/`,helpLabel:`How to release a zone hold`};if(t)return{level:`error`,label:`Needs attention`,description:`The domain provider reported verification errors. Review the details to resolve them.`};if(n&&KJt.has(n))return{level:`error`,label:R7(n),description:`The domain is in a state that prevents it from serving traffic. Contact support if this persists.`};if(r&&JJt.has(r))return{level:`error`,label:`SSL error`,description:`The SSL certificate is in the "${R7(r)}" state. The domain may not serve HTTPS traffic until this is resolved.`};let i=n===`active`||n===`test_active`||n===`test_active_apex`;return i&&(r===`active`||r===`staging_active`||r===`backup_issued`)?{level:`active`,label:`Active`,description:`The domain is verified and serving traffic over HTTPS.`}:i&&r&&qJt.has(r)?{level:`pending`,label:`Issuing certificate`,description:`The domain is verified. We're still provisioning the SSL certificate — this usually takes a few minutes.`}:n&&GJt.has(n)?{level:`pending`,label:`Verifying domain`,description:`We're waiting for DNS verification. Double-check the CNAME record at your DNS provider.`}:n||r?{level:`pending`,label:R7(n??r??`pending`),description:`The domain is still being set up. If this state persists, contact support.`}:{level:`unknown`,label:`Unknown`,description:`No status information is available for this domain.`}}function R7(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var XJt={active:{dot:`bg-green-500`,pulse:!1,pill:`bg-green-50 text-green-700 border-green-200 hover:bg-green-100 dark:bg-green-950 dark:text-green-300 dark:border-green-800 dark:hover:bg-green-900`},pending:{dot:`bg-amber-500`,pulse:!0,pill:`bg-amber-50 text-amber-800 border-amber-200 hover:bg-amber-100 dark:bg-amber-950 dark:text-amber-300 dark:border-amber-800 dark:hover:bg-amber-900`},error:{dot:`bg-red-500`,pulse:!1,pill:`bg-red-50 text-red-700 border-red-200 hover:bg-red-100 dark:bg-red-950 dark:text-red-300 dark:border-red-800 dark:hover:bg-red-900`},unknown:{dot:`bg-gray-400`,pulse:!1,pill:`bg-gray-50 text-gray-700 border-gray-200 hover:bg-gray-100 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-700`}},ZJt=({domain:e})=>{let t=YJt(e);if(!t)return null;let n=XJt[t.level],r=e.verificationErrors??[];return(0,W.jsxs)(IT,{children:[(0,W.jsx)(LT,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:G(`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,n.pill),"aria-label":`${e.hostname} status: ${t.label}`,children:[(0,W.jsxs)(`span`,{className:`relative flex size-2 items-center justify-center`,children:[n.pulse&&(0,W.jsx)(`span`,{className:G(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,n.dot)}),(0,W.jsx)(`span`,{className:G(`relative inline-flex size-2 rounded-full`,n.dot)})]}),t.label]})}),(0,W.jsx)(RT,{align:`start`,className:`w-96`,children:(0,W.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:G(`inline-flex size-2 rounded-full`,n.dot)}),(0,W.jsx)(`span`,{className:`font-medium`,children:t.label})]}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:t.description}),t.helpUrl&&(0,W.jsx)(tE,{href:t.helpUrl,className:`text-xs`,children:t.helpLabel??`Learn more`}),r.length>0&&(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Verification errors`}),(0,W.jsx)(`ul`,{className:`list-disc pl-5 space-y-1 text-destructive-foreground`,children:r.map(e=>(0,W.jsx)(`li`,{children:e},e))})]})]})})]})},QJt=({account:e,currentDomainConfig:t})=>{let{logEvent:n,captureException:r}=H(),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(``),c=e=>{let t=e.target.value;a(t)},l=YKt(),u=async()=>{try{if(s(``),!t.hostname||t.hostname.trim()===``){s(`The current domain configuration does not have a hostname associated with it`);return}await l.mutateAsync({accountName:e.name,projectName:t.projectName??``,hostname:t.hostname,deploymentName:t.deployments[0]?.deploymentName}),n(`account-custom-domain-delete-success`,{account:e.name}),d()}catch(t){r(t);let i=Fb(t);s(i),n(`account-custom-domain-delete-failed`,{account:e.name,errorMessage:i})}},d=()=>{p(),a(``),s(``)},[f,p]=I$(()=>(0,W.jsx)(HP,{onClose:d,isOpen:!0,title:`Delete custom domain`,className:`sm:max-w-xl`,children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(ck,{error:o,className:`mb-3`}),(0,W.jsxs)(`div`,{className:`text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[(0,W.jsxs)(`div`,{className:`relative bg-yellow-100 dark:bg-yellow-950/40 rounded-sm p-4 text-yellow-900 dark:text-yellow-200 text-sm whitespace-pre-line w-full mb-2`,children:[(0,W.jsxs)(`div`,{className:`flex space-x-2 items-center`,children:[(0,W.jsx)(np,{className:`h-5 w-5 text-yellow-900 dark:text-yellow-200`}),(0,W.jsx)(`span`,{className:`text-sm font-medium antialiased mt-0.5`,children:`Caution: Your project will no longer be accessible with this domain.`})]}),(0,W.jsxs)(`p`,{className:`px-2 mt-4`,children:[`You are about to delete the custom domain`,` `,(0,W.jsx)(`span`,{className:`font-medium antialiased`,children:t.hostname}),` `,`from your project. Requests using it will no longer reach your zup.`]})]}),(0,W.jsx)(`br`,{}),(0,W.jsxs)(`label`,{className:`block mb-2`,htmlFor:`hostname-field`,children:[`Please type`,` `,(0,W.jsx)(`span`,{className:`font-medium antialiased`,children:t.hostname}),` `,`to confirm.`]}),(0,W.jsx)(nE,{className:`mb-4`,type:`text`,autoComplete:`off`,value:i,onChange:c,id:`hostname-field`,"data-test":`hostname-field`}),(0,W.jsx)(`div`,{className:` text-red-500`,children:`I understand the consequences, delete this custom domain`})]}),(0,W.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[(0,W.jsx)(Y,{onClick:d,"data-test":`cancel-delete-custom-domain-btn`,variant:`outline`,disabled:l.isPending,children:`Cancel`}),(0,W.jsx)(Y,{"data-test":`delete-custom-domain-btn`,onClick:u,disabled:l.isPending||i!==t.hostname,children:(0,W.jsx)(CP,{loading:l.isPending,children:`Delete`})})]})]})}),[l.isPending,o,t,i]);return(0,W.jsx)(Y,{type:`button`,title:`Delete Custom Domain`,onClick:f,"data-test-id":`delete-custom-domain-btn`,variant:`ghost`,size:`icon-sm`,children:(0,W.jsx)(CP,{loading:l.isPending,children:(0,W.jsx)(zp,{size:18})})})},$Jt=/^(?!https?:\/\/)[a-zA-Z0-9.-]*\.[a-zA-Z]+$/,eYt=({account:e,projectName:t,currentDomainConfig:n})=>{let{logEvent:r,captureException:i}=H(),[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(n.deployments[0]?.deploymentName),d=n.hostname,{data:f,error:p}=qP(e.name,t),m=Fb(p);(0,U.useEffect)(()=>{m&&o(m)},[m]);let h=f?f.filter(e=>e.environmentType!==BP.WORKING_COPY):[],g=JKt(),_=async n=>{if(n.preventDefault(),!l||l.trim()===``){o(`Please select an environment from the options available`);return}if(!d||d.trim()===``){o(`Please provide a value on the custom domain field.`);return}if(d&&!$Jt.test(d)){o(`A custom domain value should only be the domain name. It should not start with 'http(s)' and should end with an alpha character.`);return}try{o(``),await g.mutateAsync({accountName:e.name,projectName:t,hostname:d,deploymentName:l}),c(!0),r(`account-custom-domain-edit-success`,{account:e.name})}catch(t){i(t);let n=Fb(t);r(`account-custom-domain-edit-failed`,{account:e.name,errorMessage:n}),o(n),c(!1)}},v=()=>{b(),u(n.deployments[0]?.deploymentName),o(``),c(!1)},[y,b]=I$(()=>(0,W.jsx)(HP,{onClose:v,isOpen:!0,title:`Edit your custom domain`,children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(ck,{error:a}),(0,W.jsxs)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[s===!1&&(0,W.jsxs)(`form`,{onSubmit:_,children:[(0,W.jsx)(`label`,{className:`block mb-2`,htmlFor:`environment-field`,children:`Which environment do you want to apply your custom domain to ?`}),(0,W.jsx)(`div`,{className:`mb-9`,children:(0,W.jsx)(WP,{id:`environment-field`,"data-test":`environment-field`,environments:h,value:l??``,onValueChange:e=>u(e),disabled:g.isPending,placeholder:`Select an environment`})}),(0,W.jsx)(`label`,{className:`block mb-2`,htmlFor:`hostname-field`,children:`Your custom domain`}),(0,W.jsx)(nE,{className:`mb-9`,type:`text`,autoComplete:`off`,placeholder:`api.example.com`,id:`hostname-field`,value:d,disabled:!0,"data-test":`hostname-field`}),(0,W.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[(0,W.jsx)(Y,{variant:`outline`,type:`button`,onClick:v,"data-test":`cancel-edit-custom-domain-btn`,disabled:g.isPending,children:`Cancel`}),(0,W.jsx)(Y,{"data-test":`save-edit-custom-domain-btn`,type:`submit`,disabled:g.isPending||l===n.deployments[0]?.deploymentName,children:(0,W.jsx)(CP,{loading:g.isPending,children:`Save`})})]})]}),s===!0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:(0,W.jsxs)(`p`,{children:[`Successfully edited custom domain`,` `,(0,W.jsx)(tE,{href:`https://${d}`,children:d}),` `,`to map to deployment `,l]})}),(0,W.jsx)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:(0,W.jsx)(Y,{variant:`outline`,className:`w-24 justify-center`,type:`button`,onClick:v,"data-test":`ok-edit-custom-domain-btn`,disabled:!s,children:`OK`})})]})]})]})}),[h,a]),x=()=>{y()};return(0,W.jsx)(Y,{onClick:()=>x(),title:`Edit Custom Domain`,"data-test-id":`edit-custom-domain-btn`,variant:`ghost`,size:`icon-sm`,children:(0,W.jsx)(CP,{loading:g.isPending,children:(0,W.jsx)(cte,{size:18})})})},tYt=({classNames:e,projectType:t,feature:n,helpUrl:r})=>(0,W.jsxs)(lk,{variant:`danger`,className:e,children:[(0,W.jsx)(uk,{children:t===`managed-dedicated`?`Managed Dedicated Project`:t===`self-hosted`?`Self Hosted Project`:`Managed Edge Project`}),(0,W.jsx)(pk,{className:`flex-1 leading-loose mt-1 text-sm`,children:(0,W.jsxs)(`p`,{className:`leading-loose`,children:[`Your project is running on a `,t===`managed-dedicated`?`managed dedicated`:t===`self-hosted`?`self hosted`:`managed edge hosted`,` environment. For information on how to setup up `,n,`, please refer to`,` `,(0,W.jsx)(tE,{href:r,children:`the documentation`}),`.`]})})]});function nYt(){return(0,W.jsx)(`button`,{type:`button`,disabled:!0,title:`Locked custom domain`,className:`items-center justify-center p-2 hover:bg-gray-100 rounded-sm cursor-pointer`,children:(0,W.jsx)(Tp,{className:`h-5 w-5 mx-auto`,"aria-hidden":`true`})})}var rYt=`Custom Domains`,iYt=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/custom-domains`,children:`Custom domains`}),` `,`allow you to use your own domain name for your API and developer portal. For complex custom domain configurations, please contact us at`,` `,(0,W.jsx)(tE,{href:`mailto:${yb}`,children:yb}),` `,`or use the chat widget at the bottom right.`]}),aYt=()=>{let e=nm([`account`,`project`]),t=XKt(e.account.name,e.project.name),n=HT(e.account.name,e.project.name);if(!t.data||!n.data)return(0,W.jsx)(N7,{title:rYt,description:iYt,children:(0,W.jsx)(p1,{})});let r=t.data?.filter(t=>t.projectName&&t.projectName===e.project.name&&t.deployments[0]).sort((e,t)=>e.deployments[0].deploymentName.localeCompare(t.deployments[0].deploymentName)),i=e.account.customDomainsInUse>=e.account.entitlements.customDomains,a=FJt({projectType:e.project.type,defaultConfiguration:n.data.defaultConfiguration}),o=NJt({projectType:e.project.type,defaultConfiguration:n.data.defaultConfiguration}),s=e.project.type!==`self-hosted`&&(a?!!e.account.entitlements.aliasDomains:e.account.entitlements.customDomains>0);return(0,W.jsxs)(N7,{title:rYt,description:iYt,action:s?(0,W.jsx)(BJt,{disabled:!a&&i,account:e.account,projectName:e.project.name,isManagedDedicatedProject:o,isAkamaiManagedDedicatedProject:a}):void 0,children:[i&&e.account.entitlements.customDomains>0&&e.project.type!==`self-hosted`&&!a&&(0,W.jsx)(_Jt,{account:e.account,source:`custom-domain-limit`}),!i&&e.project.type!==`self-hosted`&&!a&&(0,W.jsx)(vJt,{used:e.account.customDomainsInUse,max:e.account.entitlements.customDomains,label:`custom domains`,account:e.account,hideAtLimit:!0}),a&&!!e.account.entitlements.aliasDomains&&(0,W.jsx)(sb,{variant:`info`,className:`text-sm`,children:(0,W.jsx)(lb,{children:(0,W.jsxs)(`p`,{children:[`This project uses Akamai managed dedicated hosting. Configure the hostname in your Akamai CDN first — see the`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/dedicated/akamai/cdn`,children:`Akamai custom domain documentation`}),`. Once it's set up there, add the domain using the button above to register it with Zuplo.`]})})}),r.length>0?(0,W.jsx)(lk,{className:`overflow-hidden`,children:r.map(t=>{let n=t.deployments[0],r=o&&n?.stage===`api`,i=t.provider===`custom`&&!r,s=t.provider===`alias`,c=n.stage===`dev-portal`,l=a&&!s||i;return(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border-b px-4 py-3 last:border-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`shrink-0 flex size-9 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:c?(0,W.jsx)(Qte,{className:`size-4`}):(0,W.jsx)(bp,{className:`size-4`})}),(0,W.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,W.jsxs)(`a`,{href:`https://${t.hostname}`,target:`_blank`,rel:`noreferrer`,className:`font-medium text-sm text-foreground hover:underline inline-flex items-center gap-1 truncate`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:t.hostname}),(0,W.jsx)(up,{className:`size-3 shrink-0 opacity-60`})]}),(0,W.jsx)(ZJt,{domain:t}),n.isDefault&&(0,W.jsx)(qT,{variant:`outline`,className:`text-xs`,children:`Default`}),s&&(0,W.jsx)(qT,{variant:`outline`,className:`text-xs`,children:`Alias`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:c?`Dev Portal`:`API`}),(0,W.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(rGe,{env:n.environmentType??null}),` `,`(`,n.deploymentName,`)`]}),n.branch&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono`,children:[(0,W.jsx)(yp,{className:`size-3`}),n.branch]})]})]})]})]}),(0,W.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1`,children:[!s&&(0,W.jsx)(HJt,{customDomain:t,isManagedDedicatedProject:o,isAkamaiManagedDedicatedProject:a}),l?(0,W.jsx)(nYt,{}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(eYt,{account:e.account,projectName:e.project.name,currentDomainConfig:t}),(0,W.jsx)(QJt,{account:e.account,currentDomainConfig:t})]})]})]},t.id)})}):s?(0,W.jsx)(lk,{children:(0,W.jsxs)(db,{children:[(0,W.jsxs)(fb,{children:[(0,W.jsx)(pb,{variant:`icon`,children:(0,W.jsx)(bp,{})}),(0,W.jsx)(mb,{children:`No custom domains yet`}),(0,W.jsx)(hb,{children:`Serve your API and developer portal from your own domain name.`})]}),(0,W.jsx)(gb,{children:(0,W.jsx)(BJt,{disabled:!a&&i,account:e.account,projectName:e.project.name,isManagedDedicatedProject:o,isAkamaiManagedDedicatedProject:a})})]})}):null,e.project.type===`self-hosted`?(0,W.jsx)(tYt,{classNames:``,feature:`custom domains`,helpUrl:`https://zuplo.com/docs/dedicated/custom-domains`,projectType:e.project.type}):a&&!e.account.entitlements.aliasDomains?(0,W.jsx)(yJt,{}):!a&&e.account.entitlements.customDomains<=0?(0,W.jsx)(_Jt,{account:e.account,source:`custom-domain`}):null]})},oYt=e=>{let t=document.createRange();return t.selectNodeContents(e),t.getBoundingClientRect().width>e.getBoundingClientRect().width},sYt=()=>{let[e,t]=(0,U.useState)(!1);return{tooltipProps:(0,U.useMemo)(()=>{if(!e)return{open:!1}},[e]),triggerProps:(0,U.useMemo)(()=>({ref:e=>{e&&t(oYt(e))}}),[])}};function cYt({isSecret:e}){return e?(0,W.jsx)(Tp,{className:`h-4 w-auto`}):(0,W.jsx)(op,{className:`h-4 w-auto`})}var lYt=({variable:e,asIcon:t=!1})=>(0,W.jsxs)(vzt,{children:[(0,W.jsx)(yzt,{asChild:!0,children:t?(0,W.jsx)(Y,{variant:`ghost`,size:`icon`,className:`flex items-center`,children:(0,W.jsx)(op,{className:`w-4 h-4`})}):(0,W.jsxs)(Y,{variant:`secondary`,size:`default`,className:`flex items-center gap-2`,children:[(0,W.jsx)(op,{className:`w-4 h-4`}),`Get Code Snippet`]})}),(0,W.jsxs)(y6,{side:`right`,className:`sm:max-w-none w-1/3 min-w-[500px]`,children:[(0,W.jsx)(`div`,{className:`text-lg font-semibold border-b`,children:`Code Snippets`}),(0,W.jsx)(`p`,{className:`my-2 text-sm`,children:`Use this Code Snippet anywhere in your modules to access your environment variable.`}),(0,W.jsx)(lk,{offset:`md`,className:`bg-gray-200 text-xs `,children:(0,W.jsxs)(`pre`,{id:`codePre`,"data-lang":`typescript`,className:`font-mono text-gray-900 overflow-x-auto`,children:[`import `,`{`,` environment `,`}`,` from "@zuplo/runtime";`,`\r
|
|
1580
|
+
npm run dev`.trim()})]})]}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`ghost`,onClick:()=>t(!1),children:`Later`}),(0,W.jsx)(Y,{ref:o,onClick:()=>{s(`working-copy-create-clicked`,{account:r.name,project:i.name}),l.mutate({accountName:r.name,projectName:i.name})},children:(0,W.jsx)(CP,{loading:l.isPending,alternative:(0,W.jsx)(TP,{className:`w-4 h-4 border-2 border-white`}),children:`Create working copy`})})]})]})})},lKt=()=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-amber-200 bg-amber-100 px-4 py-1.5 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-200`,"data-test":`read-only-banner`,children:[(0,W.jsx)(dKt,{className:`min-w-0 flex-1`}),(0,W.jsx)(uKt,{className:`ml-auto shrink-0`})]}),uKt=({switchLabel:e,className:t,onActionClick:n})=>{let{project:r}=nm([`project`]);return yD(r)?(0,W.jsx)(iKt,{className:t,onOpenClick:n}):(0,W.jsx)(fKt,{label:e,className:t,onSwitchClick:n})},dKt=({className:e})=>{let t=nm(),n=t.environment.branchName??null,r=VP(t.environment.environmentType,BP.PRODUCTION),i=yD(t.project);return(0,W.jsxs)(`span`,{className:G(`flex items-center gap-x-2 text-xs`,e),"data-test":`read-only-hint`,children:[(0,W.jsx)(fp,{size:14,className:`shrink-0`,"aria-hidden":!0}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`font-semibold`,children:`Read-only`}),` — you are viewing`,` `,n?(0,W.jsxs)(W.Fragment,{children:[`the `,(0,W.jsx)(`span`,{className:`font-medium`,children:n}),` branch`]}):r?`the deployed Production environment`:`a deployed environment`,`.`,` `,i?`To make changes, set up local development.`:`To make changes, switch to Development.`]})]})},fKt=({label:e=`Switch to Development`,variant:t=`outline`,size:n=`sm`,className:r,onSwitchClick:i})=>{let a=nm(),o=y7(),{logEvent:s}=H(),c=sKt(),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(!1),p=qP(a.account.name,a.project.name).data?.find(e=>VP(e.environmentType,BP.WORKING_COPY)),m=a.environment.branchName??null,h=!!(a.project.sourceRepoUrl&&m&&a.project.hasCurrentUserWorkingCopy&&p),g=c||a.project.hasCurrentUserWorkingCopy,_=c||!!p;return g?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Y,{size:n,variant:t,className:r,onClick:()=>{if(i?.(),s(`read-only-banner-switch-to-development-clicked`,{account:a.account.name,project:a.project.name,environment:a.environment.name,action:c?`setup-working-copy`:h?`checkout-dialog`:`navigate`}),c){f(!0);return}if(h){u(!0);return}p&&o({environment:p})},disabled:!_,"data-test":`read-only-switch-to-development`,children:[(0,W.jsx)(Uy,{size:14}),e]}),(0,W.jsx)(cKt,{open:d,onOpenChange:f}),h&&m&&p&&(0,W.jsx)(pKt,{open:l,onOpenChange:u,branchName:m,workingCopyEnvironment:p})]}):null},pKt=({open:e,onOpenChange:t,branchName:n,workingCopyEnvironment:r})=>{let i=nm(),a=em(),o=y7(),{logEvent:s}=H(),c=Lyt(),{data:l,isLoading:u}=ist(r.name,{enabled:e}),d=oKt(l,i.project.defaultBranch,!1,`Checking out`),f=d?.hasLocalWork??!1,p=()=>{s(`read-only-banner-keep-working-copy-clicked`,{account:i.account.name,project:i.project.name,environment:i.environment.name,branch:n}),t(!1),o({environment:r})},m=Iyt({onSuccess:()=>{c(i.account.name,i.project.name),t(!1),a.success(`Checked out ${n} in your working copy`,{title:`Success`,icon:(0,W.jsx)(Xf,{className:`h-4 w-4`})}),o({environment:r})}});return(0,W.jsx)(tT,{open:e,onOpenChange:e=>{m.isPending||t(e)},children:(0,W.jsxs)(iT,{"data-test":`checkout-branch-dialog`,children:[(0,W.jsx)(aT,{children:(0,W.jsx)(sT,{children:`Switch to Development`})}),(0,W.jsxs)(cT,{children:[`Development is your editable working copy. Keep it as it is now, or check out the `,(0,W.jsx)(qT,{variant:`outline`,children:n}),` branch to replace your working copy's files with the latest version of this branch.`]}),d?.hasLocalWork&&(0,W.jsxs)(sb,{variant:`warning`,"data-test":`checkout-working-copy-warning`,children:[(0,W.jsx)(Bp,{}),(0,W.jsx)(cb,{children:d.title}),(0,W.jsxs)(lb,{children:[d.detail,` Keep your working copy to switch with them intact.`]})]}),(0,W.jsx)(ck,{error:m.error}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`ghost`,className:`sm:mr-auto`,onClick:()=>{s(`read-only-banner-switch-cancelled`,{account:i.account.name,project:i.project.name,environment:i.environment.name,branch:n}),t(!1)},disabled:m.isPending,"data-test":`checkout-branch-cancel`,children:`Cancel`}),(0,W.jsx)(Y,{variant:`outline`,onClick:p,disabled:m.isPending,"data-test":`checkout-branch-keep`,children:`Just switch`}),(0,W.jsx)(Y,{variant:f?`destructive`:`default`,disabled:m.isPending||u,onClick:()=>{s(`read-only-banner-checkout-branch-confirmed`,{account:i.account.name,project:i.project.name,environment:i.environment.name,branch:n,hasLocalWork:f}),m.mutate({accountName:i.account.name,projectName:i.project.name,branchName:n})},"data-test":`checkout-branch-confirm`,children:(0,W.jsx)(CP,{loading:m.isPending,children:`Checkout & switch`})})]})]})})},mKt=({item:e,isSelected:t,onSelect:n})=>{let r=new Date(e.createdOn),i=AFe(r)?`${eO(r,`H:mm:ss`)} Today`:kFe(r)?`${eO(r,`H:mm:ss ccc d, MMM`)}`:`${eO(r,`H:mm:ss ccc d`)} ${eO(r,`MMM yyy`)}`;return(0,W.jsxs)(`div`,{className:(0,bP.default)(`flex items-center gap-2 px-3 cursor-pointer h-10 border-border border-b`,{"bg-accent text-accent-foreground":t,"hover:bg-accent/50":!t}),onClick:()=>n(),children:[(0,W.jsx)(`div`,{className:`flex justify-center items-center w-5 shrink-0`,children:(0,W.jsx)(UG,{deployment:e})}),(0,W.jsx)(`span`,{className:`w-full text-sm truncate`,children:i})]})},hKt={"in-progress":`Building`,success:`Finished`,failed:`Failed`,skipped:`Skipped`},gKt=({status:e})=>hKt[e],_Kt={lint:`Lint`,build:`Build`,deploy:`Deploy`},vKt=({step:e})=>_Kt[e]??e,x7=r(a(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}))(),1);function yKt({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}var bKt=yKt();function xKt(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(bKt,``)}var SKt=({logs:e,children:t,className:n})=>(0,W.jsx)(`div`,{className:G(`grid grid-cols-[auto_1fr] auto-rows-min gap-x-5 py-4 text-xs h-full overflow-auto`,`bg-neutral-950 font-mono text-white`,n),children:t||(e.length>0?e.map(({timestamp:e,severity:t,message:n},r)=>(0,W.jsxs)(`div`,{className:G(`grid grid-cols-subgrid col-span-full px-4 py-1 hover:bg-neutral-800 text-neutral-200`,{"text-red-400":t===`error`,"text-yellow-400":t===`warn`,"text-green-500":/^\x1b\[32m/.test(n)}),children:[(0,W.jsx)(`div`,{className:`select-none`,children:(0,x7.default)(e).format(`HH:mm:ss.SSS`)}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:(0,W.jsx)(jFe,{text:xKt(n).trim()})})]},`${e}-${r}`)):(0,W.jsx)(`div`,{className:`text-neutral-300 italic px-4`,children:`No logs available`}))}),CKt=({stage:e,buildLogs:t,isLoading:n})=>(0,W.jsx)(`div`,{className:`divide-y divide-neutral-800`,children:[...e.steps??[]].sort((e,t)=>e.ordinal-t.ordinal).map(r=>{let i=att(t,e.stage,r.step),a=qG(i);return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-xs font-medium bg-neutral-900 text-neutral-300`,children:[(0,W.jsx)(u1,{status:r.status}),(0,W.jsx)(vKt,{step:r.step}),a>0&&(0,W.jsxs)(qT,{variant:`warn`,children:[a,` warning`,a>1?`s`:``]})]}),(0,W.jsx)(SKt,{logs:i,children:n&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5 col-span-full px-4`,children:[(0,W.jsx)(wD,{className:`h-4 w-3/6 bg-white/20`}),(0,W.jsx)(wD,{className:`h-4 w-2/6 bg-white/20`})]})})]},r.id)})}),wKt=(e,t)=>e?t(e):void 0,TKt=({deployment:e,defaultOpen:t})=>{let{environment:n}=nm([`environment`]),r=git(n.name,e.id,{});return r.isPending?(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,W.jsx)(wD,{className:`h-10 w-full`}),(0,W.jsx)(wD,{className:`h-10 w-full`})]}):r.isError?(0,W.jsx)(sb,{variant:`warning`,children:(0,W.jsx)(lb,{className:`text-center`,children:(0,W.jsx)(`div`,{className:`text-neutral-600 text-lg`,children:r.error?r.error.status===401||r.error.status===403?`You don't have permission to view build logs for this deployment.`:r.error.status===404?`Deployment not found. The selected deployment may have been deleted or doesn't exist.`:r.error.status===500?`Server error occurred while loading build logs. Please try again or contact support if the problem persists.`:`Unable to load build logs. Please try again or contact support if the problem persists.`:`Could not load logs. Please try again or contact support if the problem persists.`})})}):(0,W.jsx)(lk,{className:`divide-y overflow-hidden`,children:e.stages.map((n,i)=>(0,W.jsx)(EKt,{stage:n,stageIndex:i,stageCount:e.stages.length,buildLogs:r.data,isLoading:r.isLoading,defaultOpen:t},n.id))})},EKt=({stage:e,stageIndex:t,stageCount:n,buildLogs:r,isLoading:i,defaultOpen:a})=>{let o=e.steps&&e.steps.length>0;return(0,W.jsxs)(QT,{defaultOpen:a,children:[(0,W.jsx)($T,{asChild:!0,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 p-2 w-full hover:bg-accent cursor-pointer group`,children:[(0,W.jsx)(u1,{status:e.status}),(0,W.jsxs)(`div`,{className:`font-medium`,children:[(0,W.jsxs)(`span`,{className:`font-mono text-xs me-2`,children:[`(`,t+1,`/`,n,`)`]}),`Building `,(0,W.jsx)(Pyt,{stage:e.stage})]}),(0,W.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:(0,W.jsx)(gKt,{status:e.status})}),(0,W.jsx)(`div`,{className:`text-xs text-amber-400`,children:wKt(qG(JG(r,e.stage)),e=>(0,W.jsxs)(qT,{variant:`warn`,children:[e,` warning`,e>1?`s`:``]}))}),(0,W.jsx)(`div`,{className:`ms-2 flex items-center justify-center`,children:(0,W.jsx)(Zf,{className:`w-4 h-4 transition-transform group-data-[state=closed]:-rotate-90`})})]})}),(0,W.jsx)(eE,{children:o?(0,W.jsx)(CKt,{stage:e,buildLogs:r,isLoading:i}):(0,W.jsx)(SKt,{logs:JG(r,e.stage),children:i&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5 col-span-full px-4`,children:[(0,W.jsx)(wD,{className:`h-4 w-3/6 bg-white/20`}),(0,W.jsx)(wD,{className:`h-4 w-2/6 bg-white/20`})]})})})]})},DKt=({build:e})=>(0,W.jsx)(`div`,{className:`p-4 w-full`,children:(0,W.jsx)(TKt,{deployment:e,defaultOpen:!0})}),OKt=()=>{let[e,t]=SY(`build`),{environment:n}=nm([`account`,`project`,`environment`]),{data:r}=wGe(n.name),i=r?.data?.find(t=>t.id===e);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(RJ,{}),(0,W.jsxs)(LJ,{className:`min-h-36 shadow-[rgb(215_215_215/15%)_0px_-4px_3px_0px] dark:shadow-[rgb(0_0_0/40%)_0px_-4px_3px_0px]`,defaultSize:30,children:[(0,W.jsxs)(`div`,{className:`flex gap-2 border-b h-8 items-center justify-between group bg-surface-muted px-3`,children:[(0,W.jsx)(`div`,{className:`divide-neutral-200`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 group rounded-none relative text-xs font-medium`,title:e,children:[(0,W.jsx)(ete,{size:16}),e?`Build ${e.slice(0,8)}`:`Builds`]})}),(0,W.jsx)(`div`,{className:`flex flex-row gap-2`,children:(0,W.jsx)(Y,{variant:`ghost`,size:`icon-xs`,onClick:()=>t(void 0),children:(0,W.jsx)(Up,{size:18})})})]}),(0,W.jsxs)(`div`,{className:`h-[calc(100%-2rem)]`,children:[r?.data?.length===0&&(0,W.jsx)(`div`,{className:`p-3 text-sm`,children:`Start changing your local copy to see build information.`}),(0,W.jsxs)(`div`,{className:`divide-x grid grid-cols-[min-content_1fr] w-full h-full`,children:[(0,W.jsx)(`div`,{className:`overflow-y-auto`,children:r?.data?.map(n=>(0,W.jsx)(mKt,{item:n,isSelected:n.id===e,onSelect:()=>t(n.id)},`${n.id}`))}),(0,W.jsx)(`div`,{className:`overflow-y-auto`,children:e&&i?(0,W.jsx)(DKt,{build:i}):(0,W.jsx)(`div`,{className:`p-3 text-sm`,children:`Select a build to view more information.`})})]})]})]})]})},kKt=5e3,AKt=3*6e4,jKt=2e4,MKt=e=>{let[t,n]=(0,U.useState)(null),[r,i]=(0,U.useState)(!1);return(0,U.useEffect)(()=>{i(!1),n(e?Date.now()+AKt:null)},[e]),(0,U.useEffect)(()=>{if(t===null)return;let e=setTimeout(()=>i(!0),Math.max(t-Date.now(),0));return()=>clearTimeout(e)},[t]),{isPolling:e&&!r,restartPoll:()=>{i(!1),n(Date.now()+AKt)}}},S7=`/modules`,C7=`/schemas`;function NKt({showReadOnlyBanner:e=!0}={}){let t=nm(),{editStrategies:n}=x6(),[r,i]=SY(`path`),[a]=SY(`build`),{monaco:o,reloadFiles:s}=v7(),c=lF(s.execute),l=t.environment.name,{isReadOnly:u}=YZ(),{isFileTreeOpen:d,setIsFileTreeOpen:f}=j8(),p=cm(e=>e.projectTreeNodes),m=fne(),[h,g]=Hl(),_=e=>{let t=new URLSearchParams(h);t.set(`path`,e),t.delete(`v`),t.delete(`line`),g(t)},v=`${t.account.name}/${t.project.name}/${t.environment.name}`,[y,b]=(0,U.useState)(!1),[x,S]=(0,U.useState)(v);x!==v&&(S(v),b(!1)),(0,U.useEffect)(()=>{if(y)return;if(r){b(!0);return}if(!m||p.length===0)return;let e=p.find(e=>e.path&&um.test(e.path));b(!0),e&&i(e.path)},[r,p,i,y,m]);let C=p.length===0,w=!r&&(C||!y),T=p.find(e=>e.path&&um.test(e.path))?.path,E=r??``,D=[{label:`Routes`,testId:`sidebar-routes`,icon:(0,W.jsx)(hht,{className:`size-[18px]`}),isActive:um.test(E),disabled:!T,onClick:()=>T&&_(T)},{label:`Policies`,testId:`sidebar-policies`,icon:(0,W.jsx)(Mp,{size:18}),isActive:E===`/config/policies.json`,disabled:!1,onClick:()=>_(`/config/policies.json`)},{label:`Modules`,testId:`sidebar-modules`,icon:(0,W.jsx)(Pte,{size:18}),isActive:E===S7,disabled:!1,onClick:()=>_(S7)},{label:`Schemas`,testId:`sidebar-schemas`,icon:(0,W.jsx)(hp,{size:18}),isActive:E===C7,disabled:!1,onClick:()=>_(C7)}],{isError:O,error:k,isFetched:A,isFetching:j,refetch:M}=je({queryKey:[`reloadFiles`,t.account.name,t.project.name,t.environment.name],queryFn:async({signal:e})=>(await c.current({accountName:t.account.name,projectName:t.project.name,environmentName:t.environment.name},e),!0),refetchOnWindowFocus:!1,enabled:!!o&&!!l}),{isPolling:N,restartPoll:P}=MKt(!1),F=ast(l,{enabled:N,refetchInterval:kKt}),I=F.isError,L=!I&&F.data?.ready!==!0,R=I?jKt:kKt;if((0,U.useEffect)(()=>{if(!N||L)return;let e=()=>{document.visibilityState===`visible`&&M({cancelRefetch:!1})};e();let t=setInterval(e,R);return()=>clearInterval(t)},[N,L,M,R]),O&&k instanceof He)return(0,W.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,W.jsxs)(sb,{className:`max-w-md`,children:[(0,W.jsx)(cb,{children:k.title}),(0,W.jsxs)(lb,{className:`flex flex-col gap-2`,children:[Fb(k),(0,W.jsx)(XGt,{})]})]})});let z=(0,W.jsxs)(IJ,{direction:`vertical`,autoSaveId:`bottom-pane`,className:`relative`,children:[(0,W.jsx)(LJ,{minSize:10,children:r?(0,W.jsx)(VY,{blastRadius:`feature-dead`,fallback:e=>(0,W.jsx)(obt,{...e}),children:(0,W.jsx)(PKt,{})}):w?(0,W.jsx)(FKt,{}):null}),a!==void 0&&(0,W.jsx)(OKt,{})]});return(0,W.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[e&&u&&(0,W.jsx)(lKt,{}),(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[!d&&(0,W.jsxs)(`div`,{className:`flex flex-col items-center bg-surface-sunken border-r shrink-0 w-12 py-2 gap-1`,children:[(0,W.jsx)(IKt,{label:`Expand file tree`,onClick:()=>f(!0),testId:`expand-file-tree`,children:(0,W.jsx)(Ite,{size:18})}),(0,W.jsx)(`div`,{className:`my-1 h-px w-6 bg-surface-emphasis`,"aria-hidden":!0}),D.map(e=>(0,W.jsx)(IKt,{label:e.label,onClick:e.onClick,testId:e.testId,isActive:e.isActive,disabled:e.disabled,children:e.icon},e.label)),(0,W.jsx)(`div`,{className:`flex-1`}),(0,W.jsx)(`span`,{className:`text-[10px] font-medium text-neutral-500 uppercase tracking-wider select-none pb-1`,style:{writingMode:`vertical-rl`},children:`Files`})]}),d?(0,W.jsxs)(IJ,{direction:`horizontal`,autoSaveId:`file-tree`,className:`flex-1 min-w-0`,children:[(0,W.jsx)(LJ,{minSize:10,defaultSize:20,className:`bg-surface-sunken min-w-[270px]`,children:(0,W.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between h-10 px-2 border-b shrink-0`,children:[(0,W.jsx)(`span`,{className:`text-xs font-medium text-neutral-600 dark:text-neutral-400 uppercase tracking-wide pl-1`,children:`Files`}),(0,W.jsx)(Y,{variant:`ghost`,size:`icon-xs`,onClick:()=>f(!1),"aria-label":`Collapse file tree`,title:`Collapse file tree`,children:(0,W.jsx)(Fte,{size:14})})]}),(0,W.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,W.jsx)(ibt,{directoryStrategies:n,isAwaitingFiles:!1})})]})}),(0,W.jsx)(RJ,{}),(0,W.jsx)(LJ,{minSize:70,children:z})]}):(0,W.jsx)(`div`,{className:`flex-1 min-w-0`,children:z})]})]})}var PKt=()=>{let[e]=SY(`path`);if(!e)throw Error(`Invalid state - FileViewer should not be displayed if no path`);let t=e.toLowerCase();if(t===S7)return(0,W.jsx)(MUt,{});if(t===C7)return(0,W.jsx)(NUt,{});if(t===`/docs/sidebar.json`)return(0,W.jsx)(b_t,{});if(t.includes(`.oas.json`))return(0,W.jsx)(AUt,{});if(t===`/config/policies.json`)return(0,W.jsx)(HGt,{});if(t.endsWith(`.md`)||t.endsWith(`.mdx`)){let e=t.split(`/`),n=e[e.length-1];return(0,W.jsx)(y_t,{fileName:n})}return t.endsWith(`.ts`)||t.endsWith(`.css`)?(0,W.jsx)(xQ,{maxHeightVh:100}):t.startsWith(`/schemas`)&&t.endsWith(`.json`)?(0,W.jsx)(xQ,{}):t===`/config/dev-portal.json`?(0,W.jsxs)(`div`,{className:`size-full`,children:[(0,W.jsx)(`div`,{className:`p-4`,children:(0,W.jsx)(KGt,{})}),(0,W.jsx)(xQ,{})]}):(0,W.jsx)(xQ,{})},FKt=()=>(0,W.jsxs)(`div`,{className:`p-6 flex flex-col gap-2`,"data-test":`editor-loading`,children:[(0,W.jsx)(wD,{className:`w-40 h-4`}),(0,W.jsx)(wD,{className:`w-56 h-4`}),(0,W.jsx)(wD,{className:`w-28 h-4`}),(0,W.jsx)(wD,{className:`w-64 h-4`}),(0,W.jsx)(wD,{className:`w-56 h-4`}),(0,W.jsx)(wD,{className:`w-56 h-4`}),(0,W.jsx)(wD,{className:`w-56 h-4`})]}),IKt=({label:e,onClick:t,testId:n,isActive:r=!1,disabled:i=!1,children:a})=>(0,W.jsx)(Pw,{content:e,side:`right`,children:(0,W.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e,"aria-current":r?`page`:void 0,disabled:i,"data-test":n,className:G(`group flex items-center justify-center size-9 rounded-md transition-colors ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,i?`text-neutral-300 dark:text-neutral-700 cursor-not-allowed`:`cursor-pointer`,!i&&(r?`bg-brand/10 text-brand`:`text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 hover:bg-neutral-200 dark:hover:bg-neutral-800`)),children:a})});function LKt(){return(0,W.jsxs)(nmt,{className:`flex flex-col`,children:[(0,W.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,W.jsx)(NKt,{})}),(0,W.jsx)(mht,{})]})}var RKt=`/static/img/hero-Ct8-h_EN.svg`,zKt=`/static/img/hero-dark-Z9HfvwEQ.svg`,BKt=[{label:`Monetization`,value:`monetization`,badge:`Beta`,items:[{title:`Monetization Overview`,description:`Learn more about our first-party metering and billing solution built directly into the Zuplo platform.`,icon:ky,link:{href:{web:`https://zuplo.com/docs/articles/monetization/index`,local:`https://zuplo.com/docs/articles/monetization/index`},text:`Read the docs`}},{title:`Monetization Quickstart`,description:`Get up and running with API monetization in minutes using Zuplo's built-in billing and metering.`,icon:Ly,link:{href:{web:`https://zuplo.com/docs/articles/monetization/quickstart`,local:`https://zuplo.com/docs/articles/monetization/quickstart`},text:`Get Started`}},{title:`Pricing Models`,description:`Explore the different pricing models available for monetizing your APIs with Zuplo.`,icon:Ay,link:{href:{web:`https://zuplo.com/docs/articles/monetization/pricing-models`,local:`https://zuplo.com/docs/articles/monetization/pricing-models`},text:`Read the docs`}}]},{label:`MCP`,value:`mcp`,items:[{title:`Installing the MCP Inspector`,description:`Set up the MCP Inspector locally and start testing your MCP server with ease.`,icon:My,link:{href:{web:`https://zuplo.com/docs/handlers/mcp-server#mcp-inspector`,local:`https://zuplo.com/docs/handlers/mcp-server#mcp-inspector`},text:`Get Started`}},{title:`MCP Quickstart`,description:`Learn how to start using Model Context Protocol to pass context into any model call.`,icon:Ly,link:{href:{web:`https://zuplo.com/docs/articles/mcp-quickstart`,local:`https://zuplo.com/docs/articles/mcp-quickstart`},text:`Get Started`}},{title:`Using OAuth with MCP`,description:`Authenticate users securely by integrating OAuth flows into your Model Context Protocol setup.`,icon:Iy,link:{href:{web:`https://zuplo.com/docs/articles/configuring-auth0-for-mcp-auth`,local:`https://zuplo.com/docs/articles/configuring-auth0-for-mcp-auth`},text:`Get Started`}}]},{label:`Rate Limiting`,value:`rate-limiting`,items:[{title:`Adding Rate Limiting`,description:`Control traffic and protect your APIs by setting up flexible, customizable rate limits.`,icon:Ay,link:{href:{web:`https://zuplo.com/docs/articles/step-2-add-rate-limiting`,local:`https://zuplo.com/docs/articles/step-2-add-rate-limiting-local`},text:`Get Started`}},{title:`Complex Rate Limiting`,description:`Implement advanced rules to rate limit by user, IP, plan, or custom logic.`,icon:jy,link:{href:{web:`https://zuplo.com/docs/policies/complex-rate-limit-inbound`,local:`https://zuplo.com/docs/policies/complex-rate-limit-inbound`},text:`Get Started`}},{title:`Dynamic Rate Limits`,description:`Set rate limits that adapt in real-time based on headers, tokens, or user context.`,icon:Tge,link:{href:{web:`https://zuplo.com/examples/dynamic-rate-limits`,local:`https://zuplo.com/examples/dynamic-rate-limits`},text:`Get Started`}}]},{label:`Authentication`,value:`authentication`,items:[{title:`Using API Keys`,description:`Authenticate and manage access to your APIs with simple, secure API key workflows.`,icon:Age,link:{href:{web:`https://zuplo.com/docs/policies/api-key-inbound`,local:`https://zuplo.com/docs/policies/api-key-inbound`},text:`Get Started`}},{title:`Using Auth0`,description:`Connect your APIs to Auth0 for streamlined authentication and powerful identity management.`,icon:Vy,link:{href:{web:`https://zuplo.com/docs/policies/auth0-jwt-auth-inbound`,local:`https://zuplo.com/docs/policies/auth0-jwt-auth-inbound`},text:`Get Started`}},{title:`Using Okta`,description:`Integrate Okta with your APIs to enable secure, enterprise-grade authentication and authorization.`,icon:Ny,link:{href:{web:`https://zuplo.com/docs/policies/okta-jwt-auth-inbound`,local:`https://zuplo.com/docs/policies/okta-jwt-auth-inbound`},text:`Get Started`}}]},{label:`Dev Portal`,value:`dev-portal`,items:[{title:`Setup your API Reference`,description:`Instantly generate an interactive reference by importing your OpenAPI spec—no manual work needed.`,icon:jhe,link:{href:{web:`https://zuplo.com/docs/dev-portal/zudoku/configuration/api-reference`,local:`https://zuplo.com/docs/dev-portal/zudoku/configuration/api-reference`},text:`Get Started`}},{title:`Adding Authentication`,description:`Guide users through secure API access by adding auth flows to your developer portal.`,icon:Ry,link:{href:{web:`https://zuplo.com/docs/dev-portal/zudoku/configuration/authentication`,local:`https://zuplo.com/docs/dev-portal/zudoku/configuration/authentication`},text:`Get Started`}},{title:`Creating API Catalogs`,description:`Organize your APIs into searchable, user-friendly catalogs for easier discovery and onboarding.`,icon:ky,link:{href:{web:`https://zuplo.com/docs/dev-portal/zudoku/guides/using-multiple-apis`,local:`https://zuplo.com/docs/dev-portal/zudoku/guides/using-multiple-apis`},text:`Get Started`}}]}],VKt=({mode:e=`web`})=>(0,W.jsxs)(Zk,{defaultValue:`monetization`,className:`flex flex-col my-8`,children:[(0,W.jsx)(Qk,{className:`flex gap-8 border-b border-surface-border mb-8 ml-1`,children:BKt.map(e=>(0,W.jsxs)($k,{value:e.value,className:`relative py-2 text-sm font-medium text-gray-600 dark:text-neutral-400 hover:text-gray-900 dark:hover:text-neutral-100 data-[state=active]:text-gray-900 dark:data-[state=active]:text-neutral-100 border-b-2 border-transparent data-[state=active]:border-black dark:data-[state=active]:border-white transition-colors`,children:[e.label,`badge`in e&&e.badge&&(0,W.jsx)(qT,{variant:`invert`,className:`ml-2`,children:e.badge})]},e.value))}),BKt.map(t=>(0,W.jsx)(eA,{value:t.value,className:`grid grid-cols-3 gap-4`,children:t.items.map(t=>(0,W.jsxs)(lk,{className:`flex flex-col gap-2 text-muted-foreground`,children:[(0,W.jsxs)(uk,{className:`flex gap-2`,children:[(0,W.jsx)(t.icon,{size:24,weight:`duotone`,className:`[&_[opacity='0.2']]:fill-pink-500`}),(0,W.jsx)(dk,{className:`gap-x-2 text-lg font-semibold`,children:t.title})]}),(0,W.jsx)(pk,{children:t.description}),(0,W.jsx)(mk,{className:`flex-1 items-end! border-0 mb-4`,children:(0,W.jsx)(Y,{variant:`outline`,className:`w-full`,asChild:!0,children:(0,W.jsx)(tE,{href:t.link.href[e],variant:`ghost`,children:t.link.text})})})]},t.title))},t.value))]}),HKt=({title:e,url:t,className:n})=>{let{copyToClipboard:r,state:i}=zw(t??``);return(0,W.jsxs)(lk,{className:G(`col-span-full md:col-span-5 py-2 px-4 flex items-center text-sm gap-x-2`,n),children:[(0,W.jsx)(`div`,{className:`bg-green-600 rounded-full w-4 h-4 p-0.5`,children:(0,W.jsx)(Xf,{className:`text-white`,size:12})}),(0,W.jsx)(`span`,{className:`font-semibold`,children:e}),(0,W.jsx)(`div`,{className:`flex-1`,children:t?(0,W.jsx)(tE,{href:t,className:`ml-2 font-medium line-clamp-1 break-all`,children:t}):(0,W.jsx)(wD,{className:`ml-2 h-4 w-8/12`})}),(0,W.jsx)(Iw,{copied:i===`copied`,children:(0,W.jsx)(Y,{variant:`secondary`,size:`sm`,onClick:r,children:(0,W.jsxs)(CP,{loading:i===`copied`,alternative:(0,W.jsx)(Xf,{size:12,className:`text-green-600`,strokeWidth:3}),className:`flex`,children:[(0,W.jsx)(sp,{size:16,className:`mr-2`,strokeWidth:1.5}),(0,W.jsx)(X,{children:`Copy URL`})]})})})]})},UKt=({size:e=24,...t})=>(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,fill:`none`,viewBox:`0 0 16 16`,...t,children:(0,W.jsx)(`path`,{fill:`currentColor`,d:`m7.47 12.412 3.348-.592.031-.007-1.722-2.049a291.474 291.474 0 0 1-1.723-2.058c0-.01 1.779-4.909 1.789-4.926a788.95 788.95 0 0 1 2.934 5.066l2.95 5.115.023.039-10.948-.001 3.317-.587zM.9 11.788c0-.003.811-1.412 1.803-3.131L4.507 5.53l2.102-1.764C7.765 2.797 8.714 2 8.717 2a.37.37 0 0 1-.033.085L6.4 6.981l-2.24 4.808-1.63.002c-.897.001-1.63 0-1.63-.003z`})}),WKt=({className:e,size:t=24})=>(0,W.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,W.jsx)(`path`,{d:`M.778 1.211c-.424-.006-.772.334-.778.758 0 .045.002.09.01.134l3.263 19.811c.084.499.515.867 1.022.872H19.95c.382.004.708-.271.77-.646l3.27-20.03c.068-.418-.216-.813-.635-.881-.045-.008-.089-.011-.133-.01L.778 1.211zM14.52 15.528H9.522L8.17 8.464h7.561l-1.211 7.064z`})}),GKt=({className:e,size:t=24})=>(0,W.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,W.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 2C6.477 2 2 6.463 2 11.97c0 4.404 2.865 8.14 6.839 9.458.5.092.682-.216.682-.48 0-.236-.008-.864-.013-1.695-2.782.602-3.369-1.337-3.369-1.337-.454-1.151-1.11-1.458-1.11-1.458-.908-.618.069-.606.069-.606 1.003.07 1.531 1.027 1.531 1.027.892 1.524 2.341 1.084 2.91.828.092-.643.35-1.083.636-1.332-2.22-.251-4.555-1.107-4.555-4.927 0-1.088.39-1.979 1.029-2.675-.103-.252-.446-1.266.098-2.638 0 0 .84-.268 2.75 1.022A9.606 9.606 0 0112 6.82c.85.004 1.705.114 2.504.336 1.909-1.29 2.747-1.022 2.747-1.022.546 1.372.202 2.386.1 2.638.64.696 1.028 1.587 1.028 2.675 0 3.83-2.339 4.673-4.566 4.92.359.307.678.915.678 1.846 0 1.332-.012 2.407-.012 2.734 0 .267.18.577.688.48C19.137 20.107 22 16.373 22 11.969 22 6.463 17.522 2 12 2z`})}),KKt=({className:e,size:t=24})=>(0,W.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,W.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M22.65 14.39L12 22.13 1.35 14.39a.84.84 0 0 1-.3-.94l1.22-3.78 2.44-7.51A.42.42 0 0 1 4.82 2a.43.43 0 0 1 .58 0 .42.42 0 0 1 .11.18l2.44 7.49h8.1l2.44-7.51A.42.42 0 0 1 18.6 2a.43.43 0 0 1 .58 0 .42.42 0 0 1 .11.18l2.44 7.51L23 13.45a.84.84 0 0 1-.35.94z`})});function w7({providerName:e,className:t,size:n=24}){switch(e?.toLowerCase()){case`gitlab`:return(0,W.jsx)(KKt,{className:t,size:n});case`bitbucket`:return(0,W.jsx)(WKt,{className:t,size:n});case`azure`:return(0,W.jsx)(UKt,{className:t,size:n});default:return(0,W.jsx)(GKt,{className:t,size:n})}}var qKt=({onSuccess:e}={})=>{let t=P(),{logEvent:n,captureException:r}=H();return I({mutationFn:async e=>(await t.fetch(V.accounts.createCustomDomain({accountName:e.accountName,isAlias:e.isAlias,projectName:e.projectName,hostname:e.hostname,deploymentName:e.deploymentName,stage:e.stage}))).json(),onSuccess:(t,r)=>{n(`account-custom-domain-creation-success`,{account:r.accountName}),e?.(t)},onError:e=>{n(`account-custom-domain-creation-failed`),r(e)}})},JKt=()=>{let e=P();return I({mutationFn:async t=>{await e.fetch(V.accounts.editCustomDomain({accountName:t.accountName,projectName:t.projectName,hostname:t.hostname,deploymentName:t.deploymentName}))}})},YKt=()=>{let e=P();return I({mutationFn:async t=>{await e.fetch(V.accounts.deleteCustomDomain({accountName:t.accountName,projectName:t.projectName,hostname:t.hostname,deploymentName:t.deploymentName}))}})},XKt=(e,t)=>kb(R.customDomains(e,t),{extractData:!0}),ZKt=(0,U.forwardRef)(({icon:e,label:t,count:n,expanded:r,onToggle:i,children:a},o)=>(0,W.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-surface-border bg-surface shadow-xs`,children:[(0,W.jsxs)(`button`,{ref:o,type:`button`,onClick:i,"aria-expanded":r,className:`flex w-full items-center justify-between gap-2 px-3.5 py-2 text-sm transition hover:bg-gray-50 dark:hover:bg-neutral-800`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-2 font-medium text-gray-800 dark:text-neutral-200`,children:[(0,W.jsx)(e,{size:14,className:`text-gray-500 dark:text-neutral-400`,strokeWidth:2}),t]}),(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(qT,{variant:`secondary`,size:`sm`,className:`px-1.5 font-mono`,children:n??0}),r?(0,W.jsx)($f,{size:14,className:`text-gray-500 dark:text-neutral-400`}):(0,W.jsx)(Zf,{size:14,className:`text-gray-400 dark:text-neutral-500`})]})]}),r?(0,W.jsx)(`div`,{className:`border-t border-gray-100 dark:border-neutral-800`,children:a}):null]}));ZKt.displayName=`ExpandableNode`;var QKt=({selected:e,onChange:t,options:n,listLabel:r,className:i,classNameOptions:a,testId:o,placeholder:s,disabled:c,isLoadingData:l=!1})=>{let u=(0,U.useId)(),d=n.filter(e=>String(e.value)!==``);return(0,W.jsxs)(gY,{value:e?String(e.value):``,onValueChange:e=>{let n=d.find(t=>String(t.value)===e);n&&t(n)},disabled:c,children:[r?(0,W.jsx)(`span`,{id:u,className:`mb-1 block text-sm font-medium text-foreground`,children:r}):null,(0,W.jsx)(vY,{"data-test":o,className:G(`w-full`,i),"aria-labelledby":r?u:void 0,"aria-label":r?void 0:s,children:l&&e?.icon?(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(TP,{className:`h-4 w-4`,borderPositionAndSize:`border-l-2`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.label})]}):(0,W.jsx)(_Y,{placeholder:s})}),(0,W.jsx)(yY,{align:`start`,className:G(`max-h-72`,a),children:d.map((e,t)=>(0,W.jsx)(bY,{"data-test":`${o}-${t}`,value:String(e.value),disabled:e.disabled??!1,description:e.description,children:e.icon?(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.icon,e.label]}):e.label},`${t}-${e.value}`))})]})};function $Kt(e,t=500){let[n,r]=(0,U.useState)(e);return(0,U.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>{clearTimeout(n)}},[e,t]),n}var eqt=({projects:e,isLoadingProjects:t,selectedProject:n,onProjectChange:r})=>(0,W.jsx)(QKt,{testId:`project-selector`,placeholder:`Select Project`,options:(e||[]).map(e=>({label:e.name,value:e.id,icon:(0,W.jsx)(vp,{className:`mr-1.5`,size:16})})),selected:n,onChange:r,className:`flex-1 items-center w-full h-9`,isLoadingData:t});function tqt({title:e,className:t}){return(0,W.jsx)(`div`,{className:G(`text-2xl font-medium`,t),children:e})}var nqt=({showHeader:e})=>(0,W.jsxs)(W.Fragment,{children:[e&&(0,W.jsx)(tqt,{title:`Source Control Settings`}),(0,W.jsxs)(`div`,{className:`w-full sm:max-w-md md:max-w-2xl lg:max-w-5xl animate-pulse`,children:[e&&(0,W.jsx)(`div`,{className:`h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 mb-9 mt-7 w-[650px]`}),(0,W.jsxs)(`div`,{className:`flex flex-col md:flex-row lg:flex-row sm:gap-4`,children:[(0,W.jsx)(`div`,{className:`inline-block w-full max-w-sm md:max-w-xs mr-4 h-10 bg-gray-200 rounded-md dark:bg-gray-700`}),(0,W.jsx)(`div`,{className:`inline-block w-full max-w-sm md:max-w-xs mr-4 h-10 bg-gray-200 rounded-md dark:bg-gray-700`}),(0,W.jsx)(`div`,{className:`inline-block w-full max-w-sm md:max-w-xs right-0 h-10 bg-gray-200 rounded-md dark:bg-gray-700`})]}),(0,W.jsx)(`div`,{className:`h-5 mt-5 mb-3`,children:(0,W.jsx)(`div`,{className:`h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 mb-9 mt-7 w-[650px]`})}),(0,W.jsx)(`div`,{className:`mt-5 h-96 relative bg-gray-200 rounded-md dark:bg-gray-700`})]})]}),T7=`GITLAB`,E7=`GITHUB`,D7=`BITBUCKET`,O7=`AZURE`,rqt=({installUrl:e,selectedOrg:t,projectName:n,className:r,provider:i=E7,disabled:a,repoDescription:o=`Zuplo API Gateway`,onContinue:s})=>{let{logEvent:c}=H(),[l,u]=(0,U.useState)(!1),d=e=>{c(`source-control-create-repo-continue-clicked`,{sourceControlNamespace:e??`none`,sourceControlProvider:i,project:n}),s?.();let t;switch(i){case O7:t=e?`https://dev.azure.com/${e}/_createproject`:`https://dev.azure.com/`;break;case T7:t=e?`https://gitlab.com/projects/new?namespace_id=${e}`:`https://gitlab.com/projects/new`;break;case D7:t=e?`https://bitbucket.org/repo/create?owner=${e}`:`https://bitbucket.org/repo/create`;break;default:{let r=encodeURIComponent(o);t=e===null?`https://github.com/new?name=${n}&description=${r}`:`https://github.com/organizations/${e}/repositories/new?owner=${e}&name=${n}&description=${r}`;break}}window.open(t),u(!1)};return(0,W.jsxs)(tT,{open:l,onOpenChange:u,children:[(0,W.jsx)(nT,{asChild:!0,children:(0,W.jsx)(Y,{className:r,disabled:a,children:`Create new repository`})}),(0,W.jsxs)(iT,{className:`max-w-xl! w-full`,children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:`Create new repository`}),(0,W.jsx)(cT,{})]}),(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`We're about to help you create a new repository in`,` `,Pb(i),`.`]}),(0,W.jsxs)(`div`,{className:`rounded-md bg-muted/50 p-3 text-sm space-y-2 border`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`What you'll need to do:`}),i===`AZURE`&&(0,W.jsxs)(`ul`,{className:`list-disc list-inside space-y-1 text-muted-foreground`,children:[(0,W.jsx)(`li`,{children:`Create a project and repository in Azure DevOps`}),(0,W.jsx)(`li`,{children:`Return to Zuplo to connect it`})]}),i===`GITHUB`&&(0,W.jsxs)(`ul`,{className:`list-disc list-inside space-y-1 text-muted-foreground`,children:[(0,W.jsx)(`li`,{children:`Create your new repository on GitHub`}),(0,W.jsxs)(`li`,{children:[`Ensure the`,` `,(0,W.jsx)(tE,{href:e,children:`Zuplo GitHub App`}),` `,`has access to your new repo`]}),(0,W.jsx)(`li`,{children:`Return to Zuplo to see and connect it`})]}),(i===`GITLAB`||i===`BITBUCKET`)&&(0,W.jsxs)(`ul`,{className:`list-disc list-inside space-y-1 text-muted-foreground`,children:[(0,W.jsxs)(`li`,{children:[`Create your repository in `,Pb(i)]}),(0,W.jsx)(`li`,{children:`Return to Zuplo to connect it`})]})]}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Need help?`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/source-control`,children:`View our troubleshooting guide`})]})]}),(0,W.jsx)(oT,{children:(0,W.jsxs)(Y,{"data-test":`navigate-new-${i.toLowerCase()}-repo`,onClick:()=>d(t),children:[`Continue to `,Pb(i)]})})]})]})},iqt=e=>e instanceof He&&e.type===`https://zup.fail/github-integration-monorepo-detected`,aqt=`The GitHub integration connects a repository with a single Zuplo project at its root, so it can't connect this repository. You can still deploy it using the Zuplo CLI in your CI/CD pipeline.`,k7={linkAnyway:{title:`Link existing Zuplo project`,description:`Looks like Zuplo was set up here before, so we'll link your project to the existing repository instead of pushing a new one. Nothing is pushed or pulled automatically; you can commit and push from the portal whenever you're ready.`,actionLabel:`Link project`},monorepo:{title:`This looks like a monorepo`,description:aqt,actionLabel:`Manual setup`},nonEmpty:{title:`This repository isn't empty`,description:aqt,actionLabel:`Manual setup`},pullRequestOpened:{title:`We opened a pull request`,description:`Your default branch requires changes to go through a pull request, so we pushed your project to a setup branch and opened one. Merge the pull request to finish setup and land your project on the default branch.`,actionLabel:`Open pull request`}},A7=`https://zuplo.com/docs/articles/monorepo-deployment`,oqt=new Set([`https://zup.fail/github-integration-invalid-repo`,`https://zup.fail/github-integration-package-json-missing-repo`,`https://zup.fail/create-project-invalid-git-repo`,`https://zup.fail/azure-integration-invalid-repo`]),sqt=e=>iqt(e)?`monorepo`:e instanceof He&&typeof e.type==`string`&&oqt.has(e.type)?`invalidRepo`:`other`,cqt=({accountName:e,projectName:t,orgName:n,repositoryUrl:r,provider:i,handleErrors:a})=>{let{logEvent:o,captureException:s}=H(),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(null),f=wAe(e,t),p={account:e,project:t,sourceControlNamespace:n},m=async(e,t,n)=>{try{if(e===null)throw Error(`Invalid ${Pb(i)} account/organization selected, please try again.`);if(t===null)throw Error(`Invalid repository selected, please try again.`);let r=await(await f.mutateAsync({orgName:e,repositoryURL:t,defaultBranch:`main`,forceConnect:n})).json();r.connected?r.pullRequestUrl?(d(r.pullRequestUrl),o(`source-control-repo-connected-via-pr`,p),l(`pullRequestOpened`)):(o(`source-control-repo-connected`,p),l(null)):r.emptyRepository===!1&&(a(``),o(`source-control-existing-repo-confirm-shown`,p),l(`linkAnyway`))}catch(e){let t=Fb(e);switch(sqt(e)){case`monorepo`:a(``),o(`source-control-monorepo-detected`,p),l(`monorepo`);break;case`invalidRepo`:a(``),o(`source-control-nonempty-repo-detected`,p),l(`nonEmpty`);break;default:s(e),o(`source-control-repo-connection-failed`,{...p,errorMessage:t,...N_e(e)}),a(t),l(null)}}};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(FP,{open:c===`linkAnyway`,onOpenChange:e=>{e||(o(`source-control-existing-repo-confirm-cancelled`,p),l(null))},title:k7.linkAnyway.title,description:(0,W.jsxs)(W.Fragment,{children:[k7.linkAnyway.description,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/source-control`,children:`Learn more about source control`})]}),actionLabel:k7.linkAnyway.actionLabel,isPending:f.isPending,onConfirm:()=>{o(`source-control-existing-repo-confirm-confirmed`,p),m(n,r,!0)}}),(0,W.jsx)(FP,{open:c===`monorepo`,onOpenChange:e=>{e||(o(`source-control-monorepo-cancelled`,p),l(null))},title:k7.monorepo.title,description:(0,W.jsxs)(W.Fragment,{children:[k7.monorepo.description,` `,(0,W.jsx)(tE,{href:A7,children:`Learn how to deploy from a monorepo`})]}),actionLabel:k7.monorepo.actionLabel,onConfirm:()=>{o(`source-control-monorepo-manual-setup-clicked`,p),l(null),window.open(A7,`_blank`,`noopener,noreferrer`)}}),(0,W.jsx)(FP,{open:c===`nonEmpty`,onOpenChange:e=>{e||(o(`source-control-nonempty-repo-cancelled`,p),l(null))},title:k7.nonEmpty.title,description:(0,W.jsxs)(W.Fragment,{children:[k7.nonEmpty.description,` `,(0,W.jsx)(tE,{href:A7,children:`Learn how to deploy from a monorepo`})]}),actionLabel:k7.nonEmpty.actionLabel,onConfirm:()=>{o(`source-control-nonempty-repo-manual-setup-clicked`,p),l(null),window.open(A7,`_blank`,`noopener,noreferrer`)}}),(0,W.jsx)(FP,{open:c===`pullRequestOpened`,onOpenChange:e=>{e||l(null)},title:k7.pullRequestOpened.title,description:k7.pullRequestOpened.description,actionLabel:k7.pullRequestOpened.actionLabel,onConfirm:()=>{o(`source-control-pr-opened-view-clicked`,p),l(null),u&&window.open(u,`_blank`,`noopener,noreferrer`)}}),(0,W.jsx)(Y,{"data-test":`connect-repo-button`,variant:`outline`,size:`sm`,onClick:()=>{o(`source-control-connect-button-clicked`,{...p,sourceControlProvider:i}),m(n,r,!1)},children:(0,W.jsx)(CP,{loading:f.isPending,children:`Connect`})})]})},lqt=({repositories:e,account:t,project:n,selectedNamespace:r,provider:i,maxItems:a=5,onConnectError:o,newRepoIds:s})=>{let c=i===`azure`;return(0,W.jsx)(W.Fragment,{children:e.slice(0,a).map((e,a)=>(0,W.jsxs)(`div`,{className:(0,bP.default)(`flex flex-row items-center justify-center h-16 border-border px-5 lg:gap-5 gap-2 transition-colors duration-700`,{"border-t":a!==0},{"bg-emerald-50 dark:bg-emerald-950/30":s?.has(e.id)}),children:[(0,W.jsxs)(`div`,{className:`flex text-sm flex-1 gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-medium line-clamp-1`,children:e.name}),s?.has(e.id)&&(0,W.jsx)(`span`,{className:`rounded bg-emerald-100 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300`,children:`New`})]}),c&&e.metadata?.projectName?(0,W.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Project: `,e.metadata.projectName]}):(0,W.jsxs)(`span`,{className:`text-muted-foreground hidden md:inline-block lg:inline-block`,children:[`Updated on`,` `,new Date(e.updatedAt).toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})]})]}),e.private&&(0,W.jsxs)(`div`,{className:`flex justify-center items-center text-muted-foreground gap-1`,children:[(0,W.jsx)(Tp,{className:`h-4 w-4`,"aria-hidden":`false`,"aria-label":`Private Git repository`}),(0,W.jsx)(`span`,{className:`hidden lg:block`,children:`Private Repository`})]})]}),(0,W.jsx)(cqt,{accountName:t.name,projectName:n.name,orgName:r?.label||``,repositoryUrl:e.url,provider:i,handleErrors:o})]},e.id))})},uqt={[E7]:{name:`GitHub`,icon:(e=20)=>(0,W.jsx)(GKt,{className:`mr-1.5`,size:e}),supportsProjects:!1,placeholder:{namespace:`Select GitHub Account`,search:`Search repositories`},messages:{noRepoAtHand:`No repository at hand? We can help you create a new one.`,selectAccount:`Make sure to select a Git account or organization on the top left.`,grantAccess:`Make sure to grant Zuplo access to the Git account & its repositories you'd like to connect to.`}},[O7]:{name:`Azure DevOps`,icon:(e=20)=>(0,W.jsx)(UKt,{className:`mr-1.5`,size:e}),supportsProjects:!0,placeholder:{namespace:`Select Organization`,project:`Select Project`,search:`Search repositories`},messages:{noRepoInProject:`No repository in this project? Create a new one.`,noRepoAtHand:`No project at hand? We can help you create one.`,selectAccount:`Please select a project to view repositories.`,grantAccess:`No repositories in this project yet.`}},[T7]:{name:`GitLab`,icon:(e=20)=>(0,W.jsx)(yp,{className:`mr-1.5`,size:e}),supportsProjects:!1,placeholder:{namespace:`Select GitLab Group`,search:`Search repositories`},messages:{noRepoAtHand:`No repository at hand? Create a new one.`,selectAccount:`Select a GitLab group or namespace.`,grantAccess:`Connect your GitLab account to see repositories.`}},[D7]:{name:`Bitbucket`,icon:(e=20)=>(0,W.jsx)(Wee,{className:`mr-1.5`,size:e}),supportsProjects:!1,placeholder:{namespace:`Select Bitbucket Project`,search:`Search repositories`},messages:{noRepoAtHand:`No repository at hand? Create a new one.`,selectAccount:`Select a Bitbucket project.`,grantAccess:`Connect your Bitbucket account to see repositories.`}}},dqt=e=>uqt[e]||uqt.GITHUB,j7=({account:e,project:t})=>{let{logEvent:n}=H(),r=CAe(e.name),[i,a]=(0,U.useState)(t.name),[o,s]=(0,U.useState)(!1);return{newRepoName:i,setNewRepoName:a,showCreateRepoForm:o,setShowCreateRepoForm:s,createRepoMutation:r,isCreating:r.isPending,handleCreateRepo:async({namespace:o,repoName:c,otherParams:l})=>{let u=c||i||t.name;await r.mutateAsync({projectName:t.name,orgName:o,repositoryName:u,defaultBranch:`main`,otherParams:l}),n(`source-control-repo-created`,{sourceControlRepository:u,sourceControlNamespace:o,account:e.name,project:t.name}),a(``),s(!1)},reset:()=>{s(!1),a(t.name)},transformRepoToRepository:(e,t)=>({id:e.url,url:e.url,provider:t,name:e.name,slug:e.name,defaultBranch:e.defaultBranch,namespace:e.organization,owner:{id:0,name:e.organization},private:!0,updatedAt:new Date().toISOString(),ownerType:e.isUserRepo?`user`:`team`,metadata:e.metadata}),logEvent:n}},fqt=e=>{let{account:t,project:n,sourceControlConfig:r,selectedNamespace:i,searchTerm:a}=e,o=j7(e),[s,c]=(0,U.useState)(null),l=r.provider===O7,{data:u,isLoading:d}=Byt(t.name,i?.value||``,{enabled:l&&!!i}),{data:f,isLoading:p}=Ryt(t.name),m=o.transformRepoToRepository;return{repositories:(0,U.useMemo)(()=>!f?.data||!i||!s?[]:(f.data[i.label]||[]).filter(e=>e.metadata?.projectName===s.label).filter(e=>!a||e.name.toLowerCase().includes(a.toLowerCase())).map(e=>m(e,`azure`)),[f,i,s,a,m]),isLoadingRepos:p&&!!s,projects:u?.data,selectedProject:s,isLoadingProjects:d,onProjectChange:e=>{c(e),o.logEvent(`source-control-project-selected`,{account:t.name,project:n.name,sourceControlProvider:r.provider})},reset:()=>{c(null),o.reset()}}},pqt=e=>{let{account:t,sourceControlConfig:n,selectedNamespace:r,searchTerm:i}=e,a=j7(e),o=n.provider===D7,{data:s,isLoading:c,refetch:l}=Vyt(t.name,r?r.value:``,i,{enabled:o&&r!==null});return{repositories:s?.repositories||[],isLoadingRepos:c,onCreateRepo:async()=>{if(!r)throw Error(`Please select a project`);await a.handleCreateRepo({namespace:r.value}),l()},reset:a.reset,showCreateRepoForm:a.showCreateRepoForm,setShowCreateRepoForm:a.setShowCreateRepoForm,newRepoName:a.newRepoName,setNewRepoName:a.setNewRepoName,isCreating:a.isCreating}},mqt=e=>{let{account:t,sourceControlConfig:n,selectedNamespace:r,searchTerm:i}=e,a=j7(e),o=n.provider===E7,{data:s,isLoading:c}=Vyt(t.name,r?r.value:``,i,{enabled:o&&r!==null});return{...a,repositories:s?.repositories||[],isLoadingRepos:c,reset:a.reset}},hqt=e=>{let{account:t,selectedNamespace:n,searchTerm:r}=e,i=j7(e),{data:a}=zyt(t.name),{data:o,isLoading:s,refetch:c}=Ryt(t.name),l=i.transformRepoToRepository;return{repositories:(0,U.useMemo)(()=>{if(!o?.data||!n)return[];let e=a?.find(e=>e.installationId===Number(n.value))?.slug||n.label;return(o.data[e]||[]).filter(e=>!r||e.name.toLowerCase().includes(r.toLowerCase())).map(e=>l(e,`gitlab`))},[o,n,r,a,l]),isLoadingRepos:s,onCreateRepo:async()=>{if(!n)throw Error(`Please select a namespace`);await i.handleCreateRepo({namespace:n.value}),c()},reset:i.reset,showCreateRepoForm:i.showCreateRepoForm,setShowCreateRepoForm:i.setShowCreateRepoForm,newRepoName:i.newRepoName,setNewRepoName:i.setNewRepoName,isCreating:i.isCreating}},gqt=250,_qt=({account:e,project:t,sourceControlConfig:n})=>{let{logEvent:r}=H(),i=n.provider,a=dqt(i),[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(``),f=$Kt(u,gqt),p=(0,U.useRef)(new Set),m=(0,U.useRef)(null),h=(0,U.useRef)(!1),[g,_]=(0,U.useState)(new Set),[v,y]=(0,U.useState)(!1),{data:b,isLoading:x,isFetching:S,error:C}=zyt(e.name),w=C instanceof He&&C.type===on.type,T={account:e,project:t,sourceControlConfig:n,selectedNamespace:c,searchTerm:f},E=fqt(T),D=hqt(T),O=pqt(T),k=mqt(T),A=(()=>{switch(i){case O7:return E;case T7:return D;case D7:return O;default:return k}})();(0,U.useEffect)(()=>{if(b&&b.length>0){let e=b[0];l({label:e.name,value:i===`AZURE`?e.slug:e.installationId.toString(),icon:a.icon(20)})}},[b,i,a]),(0,U.useEffect)(()=>{if(f!==``||A.isLoadingRepos)return;let e=c?.value?.toString()??null,t=A.repositories.map(e=>e.id);if(m.current!==e){m.current=e,p.current=new Set(t),_(new Set),y(!1);return}let n=t.filter(e=>!p.current.has(e));if(n.length>0){for(let e of n)p.current.add(e);h.current=!1,y(!1),_(new Set(n))}else h.current&&(h.current=!1,y(!0))},[A.repositories,A.isLoadingRepos,f,c]);let j=a=>{if(a.value===`add-github-account`){r(`source-control-add-account-selected`,{sourceControlNamespace:a.value,account:e.name,project:t.name,sourceControlProvider:i}),n.installUrl&&(h.current=!0,window.open(n.installUrl));return}r(`source-control-namespace-selected`,{sourceControlNamespace:a.value,sourceControlProvider:i,account:e.name,project:t.name}),s(``),l(a),A.reset()},M=[];b?.forEach(e=>{M.push({label:e.name,value:String(i===`AZURE`?e.slug:e.installationId),icon:a.icon(20)})}),i===`GITHUB`&&M.push({label:`Add GitHub Account`,value:`add-github-account`,icon:(0,W.jsx)(Op,{className:`mr-1.5`,size:16})});let N=()=>a.supportsProjects&&A.selectedProject?A.repositories.length>0?`Showing ${A.repositories.length} repositories from project: ${A.selectedProject.label}`:a.messages.grantAccess:!a.supportsProjects&&A.repositories.length>0?`Showing ${Math.min(A.repositories.length,5)} repositories`:a.supportsProjects&&!A.selectedProject?a.messages.selectAccount:`Select an account to view repositories`,P=()=>(0,W.jsx)(rqt,{installUrl:n.installUrl??``,selectedOrg:c?.label??``,projectName:t.name,provider:i,repoDescription:yD(t)?`Zuplo AI Gateway`:void 0,className:`w-full md:w-auto`,onContinue:()=>{h.current=!0}}),F=x||A.isLoadingRepos,I=!a.supportsProjects||A.selectedProject;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[w?(0,W.jsxs)(sb,{variant:`destructive`,children:[(0,W.jsx)(cb,{children:`Reconnect GitHub`}),(0,W.jsxs)(lb,{children:[(0,W.jsx)(`p`,{children:`Your saved GitHub credentials are no longer valid. Revoke the connection from your profile, then connect GitHub again.`}),(0,W.jsx)(Y,{asChild:!0,variant:`outline`,size:`sm`,className:`mt-2`,children:(0,W.jsx)(Pl,{to:Cb.Profile,children:`Go to profile`})})]})]}):(0,W.jsx)(ck,{error:C}),(0,W.jsx)(ck,{error:o}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-col gap-3 rounded-lg border p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,W.jsxs)(`div`,{className:`text-sm`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`Start fresh with a new repository`}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`We'll set up a ready-to-deploy Zuplo project so GitOps works right away.`})]}),P()]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 my-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,W.jsx)(`span`,{className:`h-px flex-1 bg-border`}),(0,W.jsx)(`span`,{children:`Or connect an existing repository`}),(0,W.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`We'll link this project to your repo. You'll push and pull changes manually.`})]}),F&&c===null&&(0,W.jsx)(nqt,{showHeader:!1}),!x&&(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(QKt,{testId:`namespace-selector`,placeholder:a.placeholder.namespace,options:M,selected:c,onChange:j,className:`flex-1 items-center h-9`,isLoadingData:S}),i===`AZURE`&&c&&(0,W.jsx)(eqt,{projects:A.projects,isLoadingProjects:A.isLoadingProjects||!1,selectedProject:A.selectedProject||null,onProjectChange:A.onProjectChange||(()=>{})}),(0,W.jsxs)(ZY,{className:`flex-2 w-full`,children:[(0,W.jsx)($Y,{value:u,onChange:e=>d(e.target.value),placeholder:a.placeholder.search}),(0,W.jsx)(QY,{align:`inline-start`,children:(0,W.jsx)(Ap,{className:`opacity-75`})}),u&&(0,W.jsx)(QY,{align:`inline-end`,children:(0,W.jsx)(Y,{variant:`ghost`,size:`icon-sm`,onClick:()=>d(``),children:(0,W.jsx)(Up,{})})})]})]}),(0,W.jsx)(lk,{className:`flex flex-col`,children:A.isLoadingRepos&&I?(0,W.jsxs)(`div`,{className:`flex flex-row items-center p-2 justify-center align-middle h-80`,children:[(0,W.jsx)(TP,{className:`w-4 h-4 mr-2`,borderPositionAndSize:`border-l-2`}),(0,W.jsx)(`span`,{children:`Loading repositories...`})]}):I&&A.repositories.length>0?(0,W.jsx)(lqt,{repositories:A.repositories,account:e,project:t,selectedNamespace:c,provider:i,onConnectError:s,newRepoIds:g}):I?(0,W.jsxs)(`div`,{className:`flex flex-col text-sm text-center gap-2 items-center justify-center h-80`,children:[(0,W.jsx)(`h2`,{className:`text-base`,children:`No Results Found`}),(0,W.jsx)(`p`,{children:u?`Your search for "${u}" did not return any results.`:a.messages.grantAccess})]}):(0,W.jsx)(`div`,{className:`flex items-center justify-center h-80`,children:(0,W.jsx)(`p`,{children:a.messages.selectAccount})})}),i===`GITHUB`&&n.installUrl&&(v?(0,W.jsxs)(sb,{variant:`info`,children:[(0,W.jsx)(cb,{children:`Don't see your repository?`}),(0,W.jsxs)(lb,{children:[`Check that you selected the right account above, and that you granted the Zuplo GitHub App access to that repository.`,` `,(0,W.jsx)(tE,{href:n.installUrl,onClick:()=>{h.current=!0},children:`Manage repository access →`})]})]}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-dashed p-3 text-sm sm:flex-row sm:items-center sm:justify-between`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`span`,{className:`font-medium`,children:`Missing repositories? `}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Zuplo only shows repositories you've granted the Zuplo GitHub App access to.`})]}),(0,W.jsx)(tE,{href:n.installUrl,className:`whitespace-nowrap`,onClick:()=>{h.current=!0},children:`Manage repository access →`})]})),(0,W.jsxs)(`div`,{className:`flex whitespace-pre-line text-gray-500 text-sm justify-between gap-4`,children:[(0,W.jsx)(`span`,{children:N()}),(i===`GITLAB`||i===`BITBUCKET`)&&n.installUrl&&(0,W.jsxs)(tE,{href:n.installUrl,className:`whitespace-pre`,children:[`Adjust `,a.name,` Permissions →`]})]})]})},vqt=({provider:e,url:t,org:n,name:r,children:i})=>(0,W.jsx)(lk,{className:`flex gap-2 flex-col`,offset:`md`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(w7,{providerName:e}),(0,W.jsx)(`div`,{className:`flex flex-col flex-1`,children:(0,W.jsxs)(`a`,{className:`text-sm font-semibold hover:text-zuplo-pink-hover underline flex gap-1 items-center`,href:t,target:`_blank`,rel:`noopener noreferrer`,children:[n,`/`,r,(0,W.jsx)(up,{className:`h-4 w-4`})]})}),i]})}),yqt=({account:e,project:t})=>{let{logEvent:n}=H(),r=nm([`account`,`project`]);if(!t.sourceRepoUrl)throw Error(`No sourceRepoUrl on project '${r.account.name}'`);let i=t.sourceRepoUrl.replace(`.git`,``),a,o,s=!1;try{s=new URL(t.sourceRepoUrl).hostname===`dev.azure.com`}catch{s=!1}if(s){let e=t.sourceRepoUrl.match(/^https:\/\/dev\.azure\.com\/([^/]+)\/([^/]+)\/_git\/([^/]+)/);if(e){a=e[1];let t=e[2],n=e[3].replace(`.git`,``);a=`${e[1]}/${t}`,o=n}else{let e=t.sourceRepoUrl.split(`/`);a=e[e.length-2],o=e[e.length-1]}}else{let e=t.sourceRepoUrl.split(`/`);a=e[e.length-2],o=e[e.length-1]}let c=TAe(e.name,t.name),l=async()=>{await c.mutateAsync(),n(`source-control-repo-disconnected`,{account:r.account.name,project:r.project.name})};return(0,W.jsx)(vqt,{org:a,name:o,url:i,provider:t.sourceControlProvider.toLowerCase(),children:(0,W.jsx)(Y,{"data-test":`disconnect-repo-button`,onClick:l,variant:`secondary`,className:`self-end`,disabled:c.isPending,children:(0,W.jsx)(CP,{className:`flex items-center gap-1`,loading:c.isPending,children:`Disconnect`})})})},bqt=({provider:e,onClose:t})=>{if(!e)return null;let n=Pb(e);return(0,W.jsx)(tT,{open:!!e,onOpenChange:e=>!e&&t(),children:(0,W.jsxs)(iT,{children:[(0,W.jsxs)(aT,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(w7,{providerName:e.toLowerCase(),size:28}),(0,W.jsxs)(sT,{children:[n,` Integration`]})]}),(0,W.jsxs)(cT,{className:`pt-2`,children:[n,` source control integration is available on Enterprise plans. Contact our sales team or book a demo to learn more about connecting your `,n,` repositories to Zuplo.`]})]}),(0,W.jsxs)(oT,{className:`mt-2`,children:[(0,W.jsx)(Y,{variant:`outline`,asChild:!0,children:(0,W.jsx)(tE,{href:`mailto:${xb}?subject=${encodeURIComponent(`${n} Source Control Integration`)}`,variant:`ghost`,children:`Contact Sales`})}),(0,W.jsx)(Y,{asChild:!0,children:(0,W.jsx)(tE,{href:bb,variant:`ghost`,children:`Book a Demo`})})]})]})})},M7=`sourceControlConnect`,xqt=`sourceControlConnectError`,Sqt=`sourceControlConnectSuccess`,Cqt=3e5,wqt=1e3;function Tqt(e){if(e.key!==`sourceControlConnectSuccess`&&e.key!==`sourceControlConnectError`||!e.newValue)return null;try{return JSON.parse(e.newValue)}catch{return null}}var Eqt=()=>{let{logEvent:e}=H(),{error:t}=em(),n=Je(),[r,i]=(0,U.useState)(!1),a=(0,U.useRef)(null),o=(0,U.useRef)(null);return(0,U.useEffect)(()=>()=>a.current?.(),[]),{connect:(r,s,c)=>{let{id:l,provider:u,clientId:d,scopes:f,redirectUri:p,providerUrl:m}=s;e(`source-control-provider-clicked`,{provider:u});let h=`${r}::${l}::${crypto.randomUUID()}`;localStorage.removeItem(M7),localStorage.removeItem(xqt),localStorage.removeItem(Sqt),localStorage.setItem(M7,h),i(!0);let g;if(u===`GITHUB`?g=f===``?`https://github.com/login/oauth/authorize?client_id=${d}`:`https://github.com/login/oauth/authorize?client_id=${d}&scope=${f}`:u===`GITLAB`?g=`${m}/oauth/authorize?client_id=${d}&redirect_uri=${p}&response_type=code&scope=${f}`:u===`BITBUCKET`?g=`${m}/site/oauth2/authorize?client_id=${d}&response_type=code`:u===`AZURE`&&(g=`https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=${d}&redirect_uri=${encodeURIComponent(p)}&response_type=code&response_mode=query&scope=${encodeURIComponent(f)}`),!g){i(!1),localStorage.removeItem(M7);return}let _=window.open(g),v=!1,y,b,x;function S(i){let a=Tqt(i);if(!(!a||a.connect!==h)){if(i.key===`sourceControlConnectSuccess`){w(()=>{e(`source-control-access-granted`,{account:r,sourceControlProvider:u}),n.invalidateQueries({queryKey:[R.accountsSourceControlConfigurations().url],exact:!1})});return}i.key===`sourceControlConnectError`&&w(()=>{t(a.message??``),c?.onFailure?.()})}}function C(){window.removeEventListener(`storage`,S),y!==void 0&&clearInterval(y),b!==void 0&&clearTimeout(b),x!==void 0&&clearTimeout(x),localStorage.removeItem(M7),localStorage.removeItem(xqt),localStorage.removeItem(Sqt),a.current=null,o.current=null}function w(e){v||(v=!0,i(!1),C(),e?.())}if(window.addEventListener(`storage`,S,!1),!_){w(()=>{t(`Couldn't open the ${Pb(u)} sign-in window. Your browser may be blocking pop-ups; allow them for this site and try again.`),e(`source-control-connect-popup-blocked`,{account:r,sourceControlProvider:u}),c?.onFailure?.()});return}y=setInterval(()=>{let n=!1;try{n=_.closed}catch{return}n&&(y!==void 0&&clearInterval(y),b=setTimeout(()=>{w(()=>{t(`We didn't get a response from the ${Pb(u)} sign-in window. Please try again.`),e(`source-control-connect-abandoned`,{account:r,sourceControlProvider:u}),c?.onFailure?.()})},wqt))},500),x=setTimeout(()=>{w(()=>{t(`Connecting to ${Pb(u)} timed out. Please try again.`),e(`source-control-connect-timeout`,{account:r,sourceControlProvider:u}),c?.onFailure?.()})},Cqt),a.current=C,o.current={account:r,provider:u}},isConnecting:r,cancel:()=>{let t=o.current;t&&e(`source-control-connect-abandoned`,{account:t.account,sourceControlProvider:t.provider}),a.current?.(),i(!1)}}},Dqt=({accountName:e,sourceControlConfig:t})=>{let{connect:n,isConnecting:r,cancel:i}=Eqt(),{provider:a}=t;return(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Y,{variant:`outline`,className:`gap-2`,disabled:r,onClick:()=>n(e,t),children:(0,W.jsx)(CP,{loading:r,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(w7,{providerName:a}),(0,W.jsx)(`span`,{children:`Connect to ${Pb(a)}`})]})})}),r&&(0,W.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:i,children:`Cancel`})]})},Oqt=[{key:T7,label:`GitLab`},{key:D7,label:`Bitbucket`}],kqt=({account:e,project:t,sourceControlConfig:n})=>{let{logEvent:r}=H(),[i,a]=(0,U.useState)(null);if(n?.userHasCredentials&&t.sourceRepoUrl)return(0,W.jsx)(yqt,{account:e,project:t});if(n&&!t.sourceRepoUrl&&n.userHasCredentials)return(0,W.jsx)(_qt,{account:e,project:t,sourceControlConfig:n});let o=n?Pb(n.provider):null;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(lk,{offset:`md`,className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`text-sm whitespace-pre-line text-gray-500`,children:[n&&t.sourceRepoUrl&&(0,W.jsxs)(`p`,{className:`mb-3`,children:[`This project is currently associated with a `,o,` `,`repository but you have not connected to your `,o,` `,`account.`]}),(0,W.jsx)(`p`,{children:`Connect to a source control provider to enable source control on your project.`})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n&&(0,W.jsx)(Dqt,{accountName:e.name,sourceControlConfig:n}),Oqt.map(({key:e,label:t})=>(0,W.jsxs)(Y,{variant:`outline`,className:`gap-2`,onClick:()=>{r(`source-control-provider-clicked`,{provider:e}),a(e)},children:[(0,W.jsx)(w7,{providerName:e.toLowerCase(),size:20}),(0,W.jsxs)(`span`,{children:[`Connect to `,t]})]},e))]})]}),(0,W.jsx)(bqt,{provider:i,onClose:()=>a(null)})]})},Aqt=()=>kb(R.accountsSourceControlConfigurations()),jqt=()=>{let{account:e,project:t}=nm([`account`,`project`]),{logEvent:n}=H();return(0,W.jsxs)(`div`,{className:`flex flex-col space-y-4`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Support`}),(0,W.jsx)(lk,{offset:`md`,className:`p-6`,children:(0,W.jsxs)(`div`,{className:`flex w-full gap-4 items-center`,children:[(0,W.jsx)(`div`,{className:`rounded-lg bg-gray-100 dark:bg-neutral-800 w-20 h-20 grid place-items-center`,children:(0,W.jsx)(Rte,{size:38,strokeWidth:1.6,fill:`#FF99E5`,fillOpacity:.2})}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(dk,{className:`text-base`,children:`Talk to an API expert`}),(0,W.jsx)(fk,{children:`Get a free technical consultation with one of our API experts.`})]}),(0,W.jsx)(Y,{onClick:()=>{n(`getting-started-book-a-meeting-clicked`,{account:e.name}),window.open(bb,`_blank`)},className:`min-w-40`,variant:`secondary`,asChild:!0,children:(0,W.jsxs)(tE,{href:bb,variant:`ghost`,children:[(0,W.jsx)(Jf,{}),`Book a Meeting`]})})]})}),(0,W.jsx)(lk,{offset:`md`,className:`p-6`,children:(0,W.jsxs)(`div`,{className:`flex w-full gap-4 items-center`,children:[(0,W.jsx)(`div`,{className:`rounded-lg bg-gray-100 dark:bg-neutral-800 w-20 h-20 grid place-items-center`,children:(0,W.jsx)(Cp,{size:38,strokeWidth:1.6,fill:`#FF99E5`,fillOpacity:.2})}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(dk,{className:`text-base`,children:`Feeling Stuck?`}),(0,W.jsx)(fk,{children:`Check out our various support options to get help with your API`})]}),(0,W.jsx)(Y,{className:`min-w-40`,variant:`secondary`,asChild:!0,children:(0,W.jsxs)(Pl,{to:Cb.Support,children:[(0,W.jsx)(Cp,{}),`Get Help`]})})]})}),(0,W.jsx)(lk,{offset:`md`,className:`p-6`,children:(0,W.jsxs)(`div`,{className:`flex w-full gap-4 items-center`,children:[(0,W.jsx)(`div`,{className:`rounded-lg bg-gray-100 dark:bg-neutral-800 w-20 h-20 grid place-items-center`,children:(0,W.jsx)(Rte,{size:38,strokeWidth:1.6,fill:`#FF99E5`,fillOpacity:.2})}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(dk,{className:`text-base`,children:`Join the Zuplo API Community`}),(0,W.jsx)(fk,{children:`Come chat with fellow Zuplo users and the Zuplo team in our Discord channel.`})]}),(0,W.jsx)(Y,{onClick:()=>{n(`getting-started-join-discord-clicked`,{account:e.name,project:t.name}),window.open(vb,`_blank`)},className:`min-w-40`,variant:`secondary`,asChild:!0,children:(0,W.jsxs)(tE,{href:vb,variant:`ghost`,children:[(0,W.jsx)(Ate,{size:16}),`Join Us`]})})]})})]})},Mqt=()=>{let{account:e,project:t,environment:n}=Ab([`account`,`project`,`environment`]);return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(uk,{children:[(0,W.jsx)(dk,{className:`text-base`,children:`Welcome to your Gateway`}),(0,W.jsx)(fk,{className:`text-base`,children:`You can get started by configuring your routes and setting up policies in our visual Route Designer.`})]}),(0,W.jsxs)(mk,{className:`border-0 gap-2 py-6`,children:[(0,W.jsx)(Y,{asChild:!0,size:`sm`,className:`gap-2 px-8`,variant:`brand-outline`,children:(0,W.jsxs)(Pl,{to:fo(Cb.Code,{account:e,project:t,environment:n}),children:[(0,W.jsx)(op,{size:16}),`Start Building`]})}),(0,W.jsx)(Y,{className:`px-8`,variant:`secondary`,size:`sm`,asChild:!0,children:(0,W.jsxs)(tE,{variant:`ghost`,href:`https://zuplo.com/docs/articles/step-1-setup-basic-gateway`,children:[(0,W.jsx)(gp,{size:16}),`Quickstart`]})})]})]})},Nqt=()=>{let[e,t]=(0,U.useState)(!1);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(lk,{className:`col-span-full md:col-span-3 py-2 px-4 flex items-center text-sm gap-x-2`,children:[(0,W.jsx)(`div`,{className:`rounded-full w-4 h-4 p-0.5 bg-gray-500`,children:(0,W.jsx)(ap,{className:`text-white`,size:12})}),(0,W.jsx)(`span`,{className:`font-semibold flex-1 line-clamp-1 break-all`,children:`Developer Portal`}),(0,W.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>t(!0),children:[(0,W.jsx)(gp,{}),`Open\xA0Portal`]})]}),(0,W.jsx)(tT,{open:e,onOpenChange:t,children:(0,W.jsxs)(iT,{children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:`Run Developer Portal Locally`}),(0,W.jsx)(cT,{children:`To view and edit your API documentation, you need to run the developer portal locally.`})]}),(0,W.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-sm font-semibold`,children:`Steps to run the portal:`}),(0,W.jsxs)(`ol`,{className:`list-decimal list-inside space-y-2 text-sm text-gray-600`,children:[(0,W.jsxs)(`li`,{children:[`Open a terminal in the`,` `,(0,W.jsx)(`code`,{className:`bg-gray-100 px-1 rounded-sm`,children:`/docs`}),` `,`folder of your Zuplo project`]}),(0,W.jsxs)(`li`,{children:[`Run`,` `,(0,W.jsx)(`code`,{className:`bg-gray-100 px-1 rounded-sm`,children:`npm run dev`})]}),(0,W.jsx)(`li`,{children:`The portal will open in your browser automatically`})]})]}),(0,W.jsx)(`div`,{className:`bg-info-muted border border-blue-200 dark:border-blue-800 rounded-md p-3`,children:(0,W.jsxs)(`p`,{className:`text-xs text-blue-800 dark:text-blue-200`,children:[(0,W.jsx)(`strong`,{children:`Tip:`}),` The developer portal will automatically reload when you make changes to your OpenAPI documentation.`]})})]}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(Y,{variant:`secondary`,onClick:()=>t(!1),children:`Close`}),(0,W.jsx)(Y,{asChild:!0,variant:`outline`,children:(0,W.jsx)(tE,{href:`https://zuplo.com/docs/dev-portal`,children:`View Documentation`})})]})]})})]})},Pqt=()=>{let{project:e,environment:t}=nm(),n=sF(t);return(0,W.jsx)(`div`,{className:`bg-neutral-50 dark:bg-neutral-950 h-full overflow-y-auto`,children:(0,W.jsxs)(`div`,{className:`pt-4 max-w-6xl pb-16 m-auto px-5 flex flex-col gap-4`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e.name}),(0,W.jsxs)(`div`,{className:`grid grid-cols-8 gap-3`,children:[(0,W.jsx)(HKt,{title:`Gateway`,url:n}),(0,W.jsx)(Nqt,{})]}),(0,W.jsxs)(lk,{className:`relative grid md:grid-cols-2 overflow-hidden min-h-[220px]`,children:[(0,W.jsx)(Mqt,{}),(0,W.jsxs)(`div`,{className:`hidden md:block self-end h-full w-full`,children:[(0,W.jsx)(`img`,{src:RKt,alt:e.name,className:`w-full h-full object-cover object-left dark:hidden`}),(0,W.jsx)(`img`,{src:zKt,alt:``,"aria-hidden":!0,className:`hidden w-full h-full object-cover object-left dark:block`})]})]}),(0,W.jsx)(VKt,{mode:`local`}),(0,W.jsx)(jqt,{})]})})},Fqt=()=>Ft().brand,Iqt=({account:e,accountLabel:t,navigateTo:n})=>{let{data:r,isLoading:i}=VT(e),a=vDe(e),o=i||a.isLoading,s=t||e,c=xDe(r,a).sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase()));return o?(0,W.jsx)(pT,{heading:s,forceMount:!0,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground`,"aria-live":`polite`,children:[(0,W.jsx)(wp,{className:`h-4 w-4 animate-spin`}),(0,W.jsx)(`span`,{children:`Loading projects...`})]})}):(0,W.jsx)(pT,{heading:s,children:c.map(r=>(0,W.jsxs)(mT,{value:`${e}/${r.name}`,keywords:t?[r.name,e,t]:[r.name,e],onSelect:()=>n(fo(Cb.Overview,{account:e,project:r.name})),children:[(0,W.jsx)(Uf,{className:`mr-3 h-4 w-4 text-neutral-600`}),(0,W.jsx)(`span`,{children:r.name})]},r.id))})},Lqt=({accounts:e,navigateTo:t})=>{let n=e?.map(e=>e.name)??[],r=yAe(n),i=yDe(n),a=[...e??[]].sort((e,t)=>(e.label||e.name).toLowerCase().localeCompare((t.label||t.name).toLowerCase())),o=(e??[]).flatMap((e,t)=>i[t]?xDe(r[t]?.data,i[t]).map(t=>({account:e,project:t})):[]).sort((e,t)=>e.project.name.toLowerCase().localeCompare(t.project.name.toLowerCase()));return(0,W.jsxs)(pT,{children:[a.map(e=>(0,W.jsxs)(mT,{value:e.name,keywords:[e.label||e.name,e.name],onSelect:()=>t(fo(Cb.AccountProjects,{account:e.name})),children:[(0,W.jsx)(qf,{className:`mr-3 h-4 w-4 text-neutral-600`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.label||e.name}),e.label&&e.label!==e.name&&(0,W.jsx)(`span`,{className:`ml-2 truncate text-xs text-muted-foreground`,children:e.name}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 pl-3 text-xs text-muted-foreground`,children:`Account`})]},`account:${e.name}`)),o.map(({account:e,project:n})=>(0,W.jsxs)(mT,{value:`${e.name}/${n.name}`,keywords:e.label?[n.name,e.name,e.label]:[n.name,e.name],onSelect:()=>t(fo(Cb.Overview,{account:e.name,project:n.name})),children:[(0,W.jsx)(Uf,{className:`mr-3 h-4 w-4 text-neutral-600`}),(0,W.jsx)(`span`,{className:`truncate`,children:n.name}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 pl-3 text-xs text-muted-foreground`,children:e.label||e.name})]},n.id))]})},Rqt=({accounts:e,navigateTo:t,search:n})=>n.trim()?(0,W.jsx)(Lqt,{accounts:e,navigateTo:t}):(0,W.jsxs)(W.Fragment,{children:[e?.map(e=>(0,W.jsx)(Iqt,{navigateTo:t,account:e.name,accountLabel:e.label},`projects-${e.name}`)),(0,W.jsx)(pT,{heading:`Accounts`,children:e?.map(e=>(0,W.jsxs)(mT,{keywords:[e.label||e.name,e.name],onSelect:()=>{t(fo(Cb.AccountProjects,{account:e.name}))},children:[(0,W.jsx)(qf,{className:`mr-2 h-4 w-4`}),(0,W.jsx)(`span`,{children:e.label||e.name}),e.label&&e.label!==e.name&&(0,W.jsx)(`span`,{className:`ml-2 truncate text-xs text-muted-foreground`,children:e.name})]},e.name))})]}),zqt=`__zuplo_commander_ask_ai__`,Bqt=.5,Vqt=(e,t,n)=>{if(e===`__zuplo_commander_ask_ai__`)return Bqt;let[r=e,...i]=n??[],a=qw(r,t);if(a>0)return 2+a;let o=i.reduce((e,n)=>Math.max(e,qw(n,t)),0);return o>0?1+o:0},Hqt=({query:e,onSelected:t})=>{let n=Ipt(),{logEvent:r}=H();if(!n?.enabled)return null;let i=e.trim();return(0,W.jsx)(pT,{children:(0,W.jsxs)(mT,{value:zqt,onSelect:()=>{r(`agent-z-panel-opened`,{source:`command-palette`}),n.openWithPrompt(i),t()},children:[(0,W.jsx)(`div`,{className:`mr-2`,children:(0,W.jsx)(Hy,{weight:`fill`,"aria-hidden":!0})}),(0,W.jsx)(`span`,{children:`Ask AI`}),i&&(0,W.jsx)(`span`,{className:`ml-2 truncate text-xs text-muted-foreground`,children:`"${i}"`})]})})},Uqt=({account:e,navigateTo:t,project:n,environment:r})=>(0,W.jsx)(pT,{heading:`Files`,children:cm(e=>e.projectTreeNodes).filter(e=>e.path&&e.type===$l.File).map(i=>(0,W.jsxs)(mT,{onSelect:()=>t(fo(`${Cb.Code}?path=${i.path}`,{account:e,project:n,environment:r})),children:[(0,W.jsx)(`div`,{className:`mr-3`,children:(0,W.jsx)(_p,{className:`h-4 w-4 text-neutral-500`})}),(0,W.jsx)(`span`,{className:`line-clamp-1`,children:i.path.substring(1)})]},i.path))}),Wqt=({children:e,className:t})=>(0,W.jsx)(`div`,{className:G(`bg-surface-sunken`,t),children:e}),Gqt=({children:e,className:t})=>(0,W.jsx)(`div`,{className:G(`pt-4 max-w-6xl pb-16 m-auto px-5 w-full`,t),children:e}),Kqt=({children:e,className:t,muted:n})=>(0,W.jsx)(`div`,{className:G(`bg-background`,n&&`bg-surface-sunken`),children:(0,W.jsx)(`div`,{className:G(`py-6 max-w-6xl mx-auto px-5 min-h-20 flex items-center w-full`,t),children:e})}),qqt=({children:e,className:t})=>(0,W.jsx)(`div`,{className:G(`text-sm text-foreground`,t),elementtiming:`page-description`,children:e}),Jqt=({children:e,className:t})=>(0,W.jsx)(`h1`,{className:G(`text-2xl font-semibold tracking-tight`,t),elementtiming:`page-title`,children:e});(0,U.createContext)(void 0);var Yqt=cF(`div`,`grid grid-cols-subgrid col-span-full w-full items-center border-b px-4 py-3 last:border-0`),Xqt=cF(`div`,`grid grid-cols-subgrid col-span-full w-full items-center border-b px-4 py-2.5 text-xs font-medium uppercase tracking-wide text-muted-foreground`),N7=({title:e,description:t,action:n,children:r,contentClassName:i})=>(0,W.jsxs)(Wqt,{className:`min-h-full`,children:[(0,W.jsx)(`div`,{className:`border-b`,children:(0,W.jsx)(Kqt,{muted:!0,children:(0,W.jsxs)(`div`,{className:`flex w-full flex-wrap items-start justify-between gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,W.jsx)(Jqt,{children:e}),t&&(0,W.jsx)(qqt,{className:`text-muted-foreground`,children:t})]}),n]})})}),(0,W.jsx)(Gqt,{className:G(`flex flex-col gap-5`,i),children:r})]}),Zqt=sk(alt),Qqt=(e,t)=>!!(e.models?.completions?.includes(t)||e.models?.embeddings?.includes(t)),$qt=(e,t)=>e.modelPrices&&Object.fromEntries(Object.entries(e.modelPrices).filter(([n])=>{let r=t(n);return r!==void 0&&Qqt(e,r)}));function eJt({assignment:e,children:t,onOpenChange:n}){let[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(!1),{startOpening:s,renderTrigger:c}=mlt(),l=(0,U.useCallback)(()=>{o(!1),n?.(!1),i(!1)},[n]),u=LP(a,l);return(0,W.jsxs)(tT,{open:r,onOpenChange:e=>{e?(n?.(!0),s(()=>i(!0))):u.guardedClose()},children:[(0,W.jsx)(nT,{asChild:!0,children:c(t)}),(0,W.jsxs)(iT,{className:`sm:max-w-4xl max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{children:(0,W.jsx)(X,{children:`Edit AI Provider`})}),(0,W.jsx)(cT,{children:(0,W.jsxs)(X,{children:[`The Provider Name is the routing address used in`,` `,(0,W.jsx)(`code`,{className:`font-mono`,translate:`no`,children:`providerName/model`}),` `,`references and cannot be changed.`]})})]}),(0,W.jsx)(tJt,{assignment:e,onDirtyChange:o,onClose:l})]}),(0,W.jsx)(IP,{open:u.showConfirm,onOpenChange:u.setShowConfirm,onDiscard:u.handleDiscard})]})}var tJt=({assignment:e,onDirtyChange:t,onClose:n})=>{let r=XY(),{logEvent:i}=H(),a=em(),o=CX(),s=(0,U.useRef)(null),c=P(),{account:l,project:u}=Ab([`account`,`project`]),{project:d}=nm([`project`]),{t:f}=ha(),p=Je(),m=oe(),h=e.provider!==`Custom`,g=R.bucketAiProviderAssignments(o).url,_={queryKey:[g,!0],queryFn:()=>Eb(g,m,{extractData:!0}).catch(e=>{if(e instanceof He)return null;throw e})};h&&!p.getQueryState(_.queryKey)&&p.prefetchQuery(_),(0,U.useEffect)(()=>()=>{p.removeQueries({queryKey:[g,!0],exact:!0})},[p,g]);let{data:v,providers:y}=kX().data,b=bne({queries:h?[_]:[]})[0]?.data,x=e.provider===`Custom`?e.customProviderName??e.provider:e.provider,S=y[x],C=S?.isCustom===!0,[w]=(0,U.useState)(()=>b?lct(b.find(({id:t})=>t===e.id)):void 0),T=(0,U.useRef)(w),E=(0,U.useMemo)(()=>[...v[x]??[]].sort((e,t)=>jX(e.model,t.model)),[v,x]),D=(0,U.useCallback)(e=>E.find(({id:t})=>t===e)?.model,[E]),O=(0,U.useMemo)(()=>{try{return JSON.parse(e.metadata)}catch{return{}}},[e.metadata]),k=ok({defaultValues:{provider:x,customProviderName:e.customProviderName,label:e.label,apiKey:``,envVarName:e.envVarName,region:jNe(e.endpointUrl)??FNe(e.endpointUrl)??UNe(e.endpointUrl)??``,awsAccessKeyId:``,awsSecretAccessKey:``,gcpProjectId:e.gcpProjectId??``,azureResourceName:nPe(e.endpointUrl)?.resourceName??``,azureHostSuffix:nPe(e.endpointUrl)?.hostSuffix??`openai.azure.com`,deploymentModels:iPe(e.deploymentModels),models:{completions:O.models?.completions??[],embeddings:O.models?.embeddings??[]},...w?{modelPrices:uct(w)}:{},...C?{customModels:E.map(e=>({modelId:e.id,name:e.model,kind:e.kind,status:e.status===`deprecated`?`deprecated`:`active`,inputCostPerToken:e.inputCostPerToken,outputCostPerToken:e.outputCostPerToken,cachedInputCostPerToken:e.cachedInputCostPerToken,cacheWriteCostPerToken:e.cacheWriteCostPerToken}))}:{}},mode:`onChange`,resolver:(e,t,n)=>Zqt({...e,modelPrices:$qt(e,D)},t,n),shouldFocusError:!1}),{isDirty:A}=OO(k);(0,U.useEffect)(()=>{t(A)},[A,t]);let j=I({mutationFn:async t=>{if(C&&S?.id){let e=xct(E,t.customModels);for(let t of e.deleted)await c.fetch(V.ai.deleteAiProviderModel(o,S.id,t));for(let t of e.repriced)await c.fetch(V.ai.updateAiProviderModel(o,S.id,t.id,{inputCostPerToken:t.inputCostPerToken,outputCostPerToken:t.outputCostPerToken,cachedInputCostPerToken:t.cachedInputCostPerToken,cacheWriteCostPerToken:t.cacheWriteCostPerToken}));for(let t of e.created)await c.fetch(V.ai.createAiProviderModel(o,S.id,{model:t.name,kind:t.kind,inputCostPerToken:t.inputCostPerToken,outputCostPerToken:t.outputCostPerToken,cachedInputCostPerToken:t.cachedInputCostPerToken,cacheWriteCostPerToken:t.cacheWriteCostPerToken,status:`active`}))}let n=GNe(t),r=KNe(t),i=await c.fetch(V.ai.updateAiProviderAssignment(l,u,e.id,{envVarName:t.envVarName,...r?{value:r}:{},...n?{endpointUrl:n}:{},...t.provider===`VertexAI`&&t.gcpProjectId?.trim()?{gcpProjectId:t.gcpProjectId.trim()}:{},...t.provider===`AzureAI`?{deploymentModels:rPe(t.deploymentModels)??{}}:{},metadata:{models:Sct(t,C)}}));if(r&&(k.setValue(`apiKey`,``),k.setValue(`awsAccessKeyId`,``),k.setValue(`awsSecretAccessKey`,``)),yD(d)&&r&&a.success((0,W.jsx)(X,{children:`Key updated. Your gateway is redeploying — this usually takes a minute or two.`}),{duration:DNe}),T.current){let n=pct(T.current,t.modelPrices,e=>Qqt(t,e),D);for(let t of n)try{let n=await c.fetch(V.ai.updateAiProviderAssignmentModelPrice(o,e.id,t.modelId,t.body,t.revision));T.current={...T.current,[t.modelId]:cct(n)}}catch(e){throw e instanceof He&&e.status===412?Error(f(`The price of {{model}} changed since it was read. Reload to see the current prices, then try again.`,{model:t.model})):e}}return i},onSuccess:()=>{k.reset(k.getValues()),n()},onSettled:(t,n)=>r(`provider.updated`,n?`failed`:`succeeded`,{provider:e.provider})});return(0,W.jsx)(HY,{...k,children:(0,W.jsxs)(`form`,{onSubmit:k.handleSubmit(e=>j.mutate(e),t=>i(`ai-gateway-update-ai-provider-invalid`,{provider:e.provider,fields:llt(t)})),className:`flex flex-col flex-1 min-h-0`,children:[(0,W.jsx)(ck,{error:j.error,className:`mb-4 break-all`}),(0,W.jsx)(plt,{form:k,scrollAreaRef:s,title:(0,W.jsx)(X,{children:`Your changes weren't saved.`}),className:`mb-4`}),(0,W.jsx)(`div`,{ref:s,className:`flex-1 min-h-0 overflow-y-auto px-1 space-y-4`,children:(0,W.jsx)(Oct,{form:k,mode:`edit`,providerDisabled:!0,assignmentPrices:w,pricesUnavailable:h&&!w})}),(0,W.jsxs)(oT,{className:`mt-4`,children:[(0,W.jsx)(Y,{type:`button`,variant:`ghost`,onClick:n,disabled:j.isPending,children:(0,W.jsx)(X,{children:`Cancel`})}),(0,W.jsx)(Y,{type:`submit`,disabled:j.isPending,children:(0,W.jsx)(CP,{loading:j.isPending,children:(0,W.jsx)(X,{children:`Save`})})})]})]})})},nJt=e=>e.label,P7=12,rJt=(0,W.jsx)(X,{children:`Connect API keys for providers like OpenAI and Anthropic and choose which models your gateway is allowed to route to.`}),iJt=()=>(0,W.jsx)(U.Suspense,{fallback:null,children:(0,W.jsx)(HX,{children:(0,W.jsxs)(Y,{children:[(0,W.jsx)(Op,{size:16}),(0,W.jsx)(X,{children:`Add Provider`})]})})}),aJt=()=>(0,W.jsx)(PX,{source:`providers-page`,children:(0,W.jsxs)(Y,{variant:`outline`,children:[(0,W.jsx)(Mte,{size:16}),(0,W.jsx)(X,{children:`Request a provider or model`})]})}),oJt=()=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,W.jsx)(aJt,{}),(0,W.jsx)(iJt,{})]}),sJt=()=>(0,W.jsx)(W.Fragment,{children:[0,1].map(e=>(0,W.jsxs)(lk,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-5`,children:[(0,W.jsx)(wD,{className:`size-10 rounded-lg`}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(wD,{className:`h-5 w-48`}),(0,W.jsx)(wD,{className:`h-3 w-32`})]})]}),(0,W.jsx)(`div`,{className:`border-t`}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 p-5`,children:[(0,W.jsx)(wD,{className:`h-3 w-24`}),(0,W.jsx)(wD,{className:`h-4 w-full max-w-2xl`})]})]},e))}),cJt=()=>{let e=XY(),{account:t,project:n}=Ab([`account`,`project`]),r=Ob(R.aiProviderAssignments(t,n)),i=P(),a=I({mutationFn:async e=>i.fetch(V.ai.deleteAiProviderAssignment(t,n,e)),onSettled:(t,n)=>e(`provider.deleted`,n?`failed`:`succeeded`)}),o=r.data;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ck,{error:a.error}),o.length>0?o.map(e=>(0,W.jsx)(uJt,{assignment:e,onDelete:()=>a.mutate(e.id)},e.id)):(0,W.jsx)(lk,{children:(0,W.jsxs)(db,{children:[(0,W.jsxs)(fb,{children:[(0,W.jsx)(pb,{variant:`icon`,children:(0,W.jsx)(Gf,{})}),(0,W.jsx)(mb,{children:(0,W.jsx)(X,{children:`No AI providers yet`})}),(0,W.jsx)(hb,{children:(0,W.jsx)(X,{children:`Connect API keys for providers like OpenAI and Anthropic so your gateway can route requests to their models.`})})]}),(0,W.jsx)(gb,{children:(0,W.jsx)(HX,{})})]})})]})},lJt=({assignment:e})=>(0,W.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-zuplo-100 text-lg font-semibold text-zuplo-700 dark:bg-zuplo-950/50 dark:text-zuplo-300`,children:(e.label||e.provider||`?`).trim().charAt(0).toUpperCase()}),uJt=({assignment:e,onDelete:t})=>{let[n,r]=(0,U.useState)(!1),i=(0,U.useCallback)(()=>r(!0),[]),{completions:a,embeddings:o}=(0,U.useMemo)(()=>{try{let t=JSON.parse(e.metadata);return{completions:t.models?.completions??[],embeddings:t.models?.embeddings??[]}}catch{return{completions:[],embeddings:[]}}},[e.metadata]),s=a.length+o.length,c=nJt(e),l=e.provider===`Custom`,u=e.provider===qNe,d=a.length>P7||o.length>P7;return(0,W.jsxs)(lk,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4 p-5`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,W.jsx)(lJt,{assignment:e}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`truncate text-lg font-medium`,children:e.label}),(0,W.jsx)(qT,{variant:`outline`,size:`default`,children:l?e.customProviderName===e.label?e.customProviderName:(0,W.jsx)(X,{children:`Custom`}):u?JNe:e.provider})]}),u?(0,W.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 text-xs text-amber-700 dark:text-amber-400`,children:[(0,W.jsx)(Bp,{size:12}),(0,W.jsx)(`span`,{className:`truncate`,children:(0,W.jsx)(X,{children:`Demo provider — not for production`})})]}):(0,W.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,W.jsx)(Sp,{size:12}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:e.envVarName})]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(eJt,{assignment:e,children:(0,W.jsx)(Y,{variant:`ghost`,size:`icon`,title:`Edit provider`,"aria-label":`Edit provider`,children:(0,W.jsx)(Dp,{size:16})})}),(0,W.jsx)(xvt,{onConfirm:t,description:(0,W.jsx)(X,{children:`Are you sure you want to delete this provider? Apps using its models will stop working.`}),children:(0,W.jsx)(Y,{variant:`ghost`,size:`icon`,title:`Delete provider`,"aria-label":`Delete provider`,className:`text-muted-foreground hover:text-destructive-foreground`,children:(0,W.jsx)(zp,{size:16})})})]})]}),(0,W.jsx)(`div`,{className:`border-t`}),s===0?(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4 p-5`,children:[(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,W.jsx)(X,{children:`No models are enabled for this provider yet.`})}),(0,W.jsx)(eJt,{assignment:e,children:(0,W.jsx)(Y,{variant:`outline`,size:`sm`,children:(0,W.jsx)(X,{children:`Select models`})})})]}):(0,W.jsxs)(`div`,{className:`space-y-4 p-5`,children:[(0,W.jsx)(dJt,{icon:(0,W.jsx)(Nte,{size:14}),title:(0,W.jsx)(X,{children:`Chat`}),models:a,referenceKey:c,expanded:n,onReveal:i}),(0,W.jsx)(dJt,{icon:(0,W.jsx)(xte,{size:14}),title:(0,W.jsx)(X,{children:`Embeddings`}),models:o,referenceKey:c,expanded:n,onReveal:i}),d&&(0,W.jsx)(Y,{variant:`link`,size:`sm`,className:`h-auto px-0`,onClick:()=>r(e=>!e),children:n?(0,W.jsx)(X,{children:`Show fewer models`}):(0,W.jsxs)(X,{children:[`Show all `,{count:s},` models`]})})]})]})},dJt=({icon:e,title:t,models:n,referenceKey:r,expanded:i,onReveal:a})=>{if(n.length===0)return null;let o=n.slice(P7);return(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[e,(0,W.jsx)(`span`,{children:t}),(0,W.jsx)(`span`,{className:`text-muted-foreground/70`,children:`·`}),(0,W.jsx)(`span`,{className:`text-muted-foreground/70`,children:n.length})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(fJt,{models:n.slice(0,P7),referenceKey:r}),o.length>0&&(0,W.jsx)(mJt,{hidden:!i,onReveal:a,children:(0,W.jsx)(fJt,{models:o,referenceKey:r,className:`mt-1`})})]})]})},fJt=({models:e,referenceKey:t,className:n})=>(0,W.jsx)(`ul`,{className:G(`grid grid-cols-1 gap-x-6 gap-y-1 font-mono text-xs sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,n),children:e.map(e=>(0,W.jsx)(pJt,{model:e,referenceKey:t},e))}),pJt=({model:e,referenceKey:t})=>{let n=t?`${t}/${e}`:e,{copyToClipboard:r,state:i}=zw(n);return(0,W.jsx)(`li`,{className:`min-w-0`,children:(0,W.jsx)(Iw,{copied:i===`copied`,delayDuration:300,hint:(0,W.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,W.jsx)(`span`,{className:`font-mono`,children:n}),(0,W.jsx)(`span`,{className:`text-background/70`,children:(0,W.jsx)(X,{children:`Click to copy full name`})})]}),children:(0,W.jsx)(`button`,{type:`button`,onClick:()=>void r(),"aria-label":`Copy ${n}`,className:`block w-full cursor-pointer truncate rounded-xs text-left outline-none hover:underline hover:decoration-dotted hover:underline-offset-4 focus-visible:ring-2 focus-visible:ring-ring`,children:e})})})},mJt=({hidden:e,onReveal:t,children:n})=>{let r=(0,U.useRef)(null);return(0,U.useLayoutEffect)(()=>{let t=r.current;t&&(e?t.setAttribute(`hidden`,`until-found`):t.removeAttribute(`hidden`))},[e]),(0,U.useEffect)(()=>{let e=r.current;if(e)return e.addEventListener(`beforematch`,t),()=>e.removeEventListener(`beforematch`,t)},[t]),(0,W.jsx)(`div`,{ref:r,children:n})},hJt=()=>(0,W.jsx)(N7,{title:`AI Gateway`,description:rJt,action:(0,W.jsx)(oJt,{}),children:(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(sJt,{}),children:(0,W.jsx)(cJt,{})})}),gJt=e=>e.plan===`FREE_V1`,_Jt=({account:e,className:t,source:n})=>{let r=e.customDomainsInUse,i=e.entitlements.customDomains,a=gJt(e),o=`${fo(Cb.AccountSettings,{account:e.name})}/upgrade-billing?source=${n}`;return(0,W.jsxs)(lk,{variant:`default`,className:t,children:[(0,W.jsx)(uk,{children:a?`Custom domains require a paid plan`:`Custom domain limit reached`}),(0,W.jsx)(pk,{className:`text-sm leading-relaxed`,children:a?(0,W.jsx)(`p`,{children:`Custom domains let you serve your APIs and developer portal from your own domain. Upgrade to the Builder plan to add custom domains to your account.`}):(0,W.jsxs)(`p`,{children:[`Your account is using`,` `,(0,W.jsxs)(`span`,{className:`font-medium`,children:[r,` of `,i]}),` `,`custom domains. Contact our team to increase your limit.`]})}),(0,W.jsxs)(mk,{className:`flex flex-wrap items-center gap-2`,children:[a?(0,W.jsx)(Y,{asChild:!0,children:(0,W.jsx)(ub,{variant:`ghost`,to:o,children:`Upgrade to Builder`})}):(0,W.jsx)(Y,{asChild:!0,children:(0,W.jsx)(tE,{href:bb,variant:`ghost`,children:`Contact Sales`})}),(0,W.jsx)(Y,{variant:`outline`,asChild:!0,children:(0,W.jsx)(ub,{variant:`ghost`,to:o,children:`View Plans`})})]})]})},vJt=({used:e,max:t,label:n,account:r,navigationSource:i,className:a,hideAtLimit:o=!1})=>{if(t<=0)return null;let s=e>=t,c=r.plan.startsWith(`FREE`),l=`${fo(Cb.AccountSettings,{account:r.name})}/upgrade-billing${i?`?source=${i}`:``}`;return s?o?null:(0,W.jsxs)(sb,{variant:`warning`,className:a,children:[(0,W.jsx)(Bp,{}),(0,W.jsx)(lb,{children:(0,W.jsxs)(`p`,{children:[`You've reached the limit of `,t,` `,n,` on your plan (`,e,` of`,` `,t,` used).`,` `,c?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ub,{to:l,className:`hover:text-zuplo-pink-hover text-zuplo-pink underline`,children:`Upgrade your plan`}),` `,`to add more.`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tE,{href:`mailto:${xb}`,className:`text-zuplo-pink hover:text-zuplo-pink-hover underline`,children:`Contact sales`}),` `,`to increase your limit.`]})]})})]}):(0,W.jsxs)(`p`,{className:G(`text-sm text-muted-foreground`,a),children:[`Using `,e,` of `,t,` `,n,`.`]})},yJt=({className:e})=>(0,W.jsxs)(lk,{variant:`info`,className:e,children:[(0,W.jsx)(uk,{children:`Managed Dedicated Project`}),(0,W.jsx)(pk,{className:`flex-1 leading-loose mt-1 text-sm`,children:(0,W.jsxs)(`p`,{className:`leading-loose`,children:[`This project uses Akamai managed dedicated hosting. Custom domains for Akamai must be configured through Akamai CDN. See`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/dedicated/akamai/cdn`,children:`Akamai custom domain documentation`}),`.`]})})]}),F7=`Switch`,[bJt,xJt]=we(F7),[SJt,CJt]=bJt(F7),wJt=U.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=U.useState(null),m=L(t,e=>p(e)),h=U.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=B({prop:i,defaultProp:a??!1,onChange:l,caller:F7});return(0,W.jsxs)(SJt,{scope:n,checked:_,disabled:s,children:[(0,W.jsx)(pu.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":kJt(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:su(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,W.jsx)(OJt,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});wJt.displayName=F7;var TJt=`SwitchThumb`,EJt=U.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=CJt(TJt,n);return(0,W.jsx)(pu.span,{"data-state":kJt(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});EJt.displayName=TJt;var DJt=`SwitchBubbleInput`,OJt=U.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=U.useRef(null),s=L(o,a),c=BJ(n),l=bn(t);return U.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,W.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});OJt.displayName=DJt;function kJt(e){return e?`checked`:`unchecked`}var AJt=wJt,jJt=EJt;function MJt({className:e,...t}){return(0,W.jsx)(AJt,{"data-slot":`switch`,className:G(`peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,W.jsx)(jJt,{"data-slot":`switch-thumb`,className:G(`bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}var I7=({customDomain:e,cname:t,documentationUrl:n=`https://www.zuplo.com/docs/guides/custom-domain-setup`})=>(0,W.jsxs)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[(0,W.jsx)(`p`,{children:`We've set things up on our end, now you need to configure your DNS with a new entry.`}),(0,W.jsx)(`br`,{}),(0,W.jsx)(lk,{variant:`muted`,className:`font-mono p-4 text-sm`,children:(0,W.jsxs)(`ol`,{children:[(0,W.jsx)(`li`,{className:`leading-6`,children:`Type: CNAME`}),(0,W.jsxs)(`li`,{className:`leading-6`,children:[`Name: `,e,` `,(0,W.jsx)(EP,{textToCopy:e??``})]}),(0,W.jsxs)(`li`,{className:`leading-6`,children:[`Value: `,t,` `,(0,W.jsx)(EP,{textToCopy:t??``})]}),(0,W.jsx)(`li`,{className:`leading-6`,children:`TTL: 60s or auto`})]})}),(0,W.jsx)(`br`,{}),(0,W.jsx)(`p`,{children:`Note that it does sometimes take a few hours for records to propagate and for the SSL certificate to be created.`}),(0,W.jsx)(`br`,{}),(0,W.jsxs)(`p`,{children:[`For more information see our`,` `,(0,W.jsx)(tE,{href:n,children:`documentation on custom domains`}),`.`]})]});function NJt({projectType:e,defaultConfiguration:t}){return e===`managed-dedicated`&&t.some(e=>!!e.managedDedicatedConfiguration)}function PJt({stage:e,isManagedDedicatedProject:t,isAkamaiManagedDedicatedProject:n,formIsAlias:r}){return e===`dev-portal`?!1:n?!0:t?!1:r??!1}function FJt({projectType:e,defaultConfiguration:t}){return e===`managed-dedicated`&&t.some(e=>e.managedDedicatedConfiguration?.vendor===`akamai`)}function IJt({project:e,isAkamaiManagedDedicatedProject:t}){return t||!e?!1:!yD(e)}var L7=()=>(0,W.jsxs)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[(0,W.jsx)(`p`,{children:`This custom domain is setup with an advanced configuration. In order to make changes to this domain, please contact support.`}),(0,W.jsx)(`br`,{}),(0,W.jsxs)(`p`,{children:[`For more information see our`,` `,(0,W.jsx)(tE,{href:`https://www.zuplo.com/docs/guides/custom-domain-setup`,children:`documentation on custom domains`}),`.`]})]}),LJt=/^(?!https?:\/\/)[a-zA-Z0-9.-]*\.[a-zA-Z]+$/,RJt=`https://zuplo.com/docs/dedicated/custom-domains`,zJt=Dh({project:Ch().min(1),hostname:Ch().regex(LJt,`Please enter a valid domain name (e.g. api.example.com)`),environment:Ch().min(1),stage:kh([`api`,`dev-portal`]),isAlias:Th().optional()}),BJt=({account:e,projectName:t,disabled:n=!1,isManagedDedicatedProject:r=!1,isAkamaiManagedDedicatedProject:i=!1})=>{let a=t===void 0,o=lc(),s=ok({resolver:sk(zJt),defaultValues:{project:t??``,hostname:``,environment:``,stage:`api`,isAlias:i}}),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(`project`),[f,p,m]=s.watch([`isAlias`,`stage`,`project`]),{data:h,isLoading:g}=qP(e.name,m,{enabled:!!m}),{aliasDomains:_}=e.entitlements,{data:v}=VT(e.name),y=v?.find(e=>e.name===m),b=y?DFe(new Date(Number(y.createdOn)),new Date(`2025-04-01`)):!1,x=(v??[]).filter(e=>e.type!==`self-hosted`&&e.deployedEnvironmentCount>0).sort((e,t)=>e.name.localeCompare(t.name)),{data:S,isLoading:C}=HT(e.name,m,{enabled:a&&!!m}),w=a?NJt({projectType:y?.type,defaultConfiguration:S?.defaultConfiguration??[]}):r,T=a?FJt({projectType:y?.type,defaultConfiguration:S?.defaultConfiguration??[]}):i,E=IJt({project:y,isAkamaiManagedDedicatedProject:T}),D=h?h.filter(e=>e.environmentType!==BP.WORKING_COPY):[],O=qKt({onSuccess:()=>{PJt({stage:p,isManagedDedicatedProject:w,isAkamaiManagedDedicatedProject:T,formIsAlias:f})&&!a&&l(!1)}}),k=(0,U.useCallback)(()=>{s.reset(),O.isSuccess&&O.reset(),d(`project`),l(!1)},[s,O]),A=LP(s.formState.isDirty&&!O.isSuccess,k),j=()=>{l(!1),o(`${fo(Cb.Settings,{account:e.name,project:m})}/custom-domain`)},M=a&&v!==void 0&&x.length===0,N=!a||u===`details`,P=g||C;return(0,W.jsxs)(tT,{open:c,onOpenChange:e=>{e?l(!0):A.guardedClose()},children:[(0,W.jsx)(nT,{asChild:!0,children:(0,W.jsx)(Y,{"data-test":`create-custom-domain-modal-btn`,disabled:n,title:n?`You reached the limit of custom domains`:``,children:`Add Custom Domain`})}),(0,W.jsxs)(iT,{children:[(0,W.jsx)(aT,{children:(0,W.jsx)(sT,{children:`Add Custom Domain`})}),(0,W.jsx)(`div`,{className:`space-y-4`,children:O.isSuccess?(0,W.jsxs)(W.Fragment,{children:[w&&!f&&p===`api`?O.data?.cname?(0,W.jsx)(I7,{customDomain:s.getValues(`hostname`),cname:O.data.cname,documentationUrl:RJt}):(0,W.jsx)(L7,{}):!_&&O.data?.cname&&(0,W.jsx)(I7,{customDomain:s.getValues(`hostname`),cname:O.data?.cname}),!w&&!_&&!O.data?.cname&&p===`api`&&(0,W.jsx)(L7,{}),(0,W.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[a&&(0,W.jsx)(Y,{type:`button`,variant:`secondary`,"data-test":`view-custom-domain-btn`,onClick:j,children:`View in project`}),(0,W.jsx)(rT,{asChild:!0,children:(0,W.jsx)(Y,{"data-test":`ok-create-custom-domain-btn`,children:`Done`})})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ck,{error:O.error}),(0,W.jsx)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:(0,W.jsxs)(HY,{...s,children:[N&&T&&(0,W.jsx)(sb,{variant:`info`,children:(0,W.jsx)(lb,{children:`Make sure this hostname is already configured in your Akamai CDN. Registering it here records the alias domain with Zuplo so your public URLs match the client-facing domain.`})}),N&&b&&E&&(0,W.jsxs)(sb,{variant:`warning`,children:[(0,W.jsx)(cb,{children:`Preview Notice`}),(0,W.jsxs)(lb,{children:[`Custom domains for the Dev Portal are currently in preview and only available after the migration to our preview version.`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/custom-domains`,target:`_blank`,children:`Learn more`})]})]}),(0,W.jsx)(`form`,{onSubmit:s.handleSubmit(async t=>{await O.mutateAsync({accountName:e.name,projectName:t.project,isAlias:PJt({stage:t.stage,isManagedDedicatedProject:w,isAkamaiManagedDedicatedProject:T,formIsAlias:t.isAlias}),hostname:t.hostname,deploymentName:t.environment,stage:t.stage})}),children:a&&u===`project`?(0,W.jsxs)(W.Fragment,{children:[M?(0,W.jsx)(`p`,{className:`mt-2`,children:`You don't have any projects that can use a custom domain yet. Custom domains require a project with a deployed (edge) environment.`}):(0,W.jsx)(UY,{control:s.control,name:`project`,render:({field:e})=>(0,W.jsxs)(GY,{className:`mt-2`,children:[(0,W.jsx)(rE,{className:`block`,htmlFor:`project-field`,children:`Which project is this domain for?`}),(0,W.jsxs)(gY,{value:e.value,onValueChange:t=>{e.onChange(t),s.setValue(`environment`,``),s.setValue(`stage`,`api`),s.setValue(`isAlias`,!1)},disabled:O.isPending,children:[(0,W.jsx)(vY,{id:`project-field`,"data-test":`project-field`,className:`w-full`,children:(0,W.jsx)(_Y,{placeholder:`Select a project`})}),(0,W.jsx)(yY,{children:x.map(e=>(0,W.jsx)(bY,{value:e.name,children:e.name},e.id))})]}),(0,W.jsx)(YY,{})]})}),(0,W.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[(0,W.jsx)(rT,{asChild:!0,children:(0,W.jsx)(Y,{type:`button`,variant:`secondary`,"data-test":`cancel-create-custom-domain-btn`,children:`Cancel`})}),!M&&(0,W.jsx)(Y,{type:`button`,"data-test":`continue-create-custom-domain-btn`,disabled:!m||P,onClick:()=>d(`details`),children:(0,W.jsx)(CP,{loading:!!m&&P,children:`Continue`})})]})]}):(0,W.jsxs)(W.Fragment,{children:[a&&(0,W.jsxs)(`div`,{className:`mt-2 mb-1 flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Project:`,` `,(0,W.jsx)(`span`,{className:`font-medium text-foreground`,children:m})]}),(0,W.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,"data-test":`change-project-custom-domain-btn`,onClick:()=>d(`project`),disabled:O.isPending,children:`Change`})]}),g?(0,W.jsx)(wD,{className:`h-9 mt-4`}):D.length>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(UY,{control:s.control,name:`environment`,render:({field:e})=>(0,W.jsxs)(GY,{className:`mt-2`,children:[(0,W.jsx)(rE,{htmlFor:`environment-field`,children:`Which environment do you want to apply your new domain to?`}),(0,W.jsx)(WP,{id:`environment-field`,"data-test":`environment-field`,environments:D,value:e.value,onValueChange:e.onChange,disabled:O.isPending,placeholder:`Select an environment`}),(0,W.jsx)(YY,{})]})}),E&&(0,W.jsx)(UY,{control:s.control,name:`stage`,render:({field:e})=>(0,W.jsxs)(GY,{className:`mt-2`,children:[(0,W.jsx)(rE,{className:`block`,htmlFor:`stage-field`,children:`What do you want the custom domain to be assigned to?`}),(0,W.jsxs)(gY,{onValueChange:t=>{(t===`api`||t===`dev-portal`)&&e.onChange(t)},disabled:O.isPending,...e,children:[(0,W.jsx)(vY,{id:`stage-field`,className:`w-full`,children:(0,W.jsx)(_Y,{placeholder:`Select a stage`})}),(0,W.jsxs)(yY,{children:[(0,W.jsx)(bY,{value:`api`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(bp,{size:16}),` Gateway`]})}),(0,W.jsx)(bY,{value:`dev-portal`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Qte,{size:16}),` Dev Portal`,(0,W.jsx)(qT,{className:``,variant:`info`,children:`New`})]})})]})]}),(0,W.jsx)(YY,{})]})}),(0,W.jsx)(UY,{control:s.control,name:`hostname`,render:({field:e})=>(0,W.jsxs)(GY,{className:`mt-2`,children:[(0,W.jsx)(rE,{htmlFor:`hostname-field`,children:`Your custom domain (e.g. example.com or api.example.com)`}),(0,W.jsx)(nE,{type:`text`,autoComplete:`off`,placeholder:`api.example.com`,id:`hostname-field`,"data-test":`hostname-field`,...e,disabled:O.isPending}),(0,W.jsx)(YY,{})]})}),(0,W.jsx)(UY,{control:s.control,name:`isAlias`,render:({field:e})=>(0,W.jsx)(GY,{className:G((!_||p===`dev-portal`||w)&&`hidden`,`mt-2`),children:(0,W.jsxs)(lk,{className:`p-4 flex items-center gap-3`,children:[(0,W.jsxs)(rE,{className:`flex flex-col gap-2`,htmlFor:`isAlias`,children:[`Is this an alias domain?`,(0,W.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`If your API Gateway is behind a CDN or WAF, your clients may use a different domain. Use an`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/custom-domains#alias-domains`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`alias domain`}),` `,`so public URLs like docs and OpenAPI match the client-facing domain.`]})]}),(0,W.jsx)(MJt,{className:`mx-3`,id:`isAlias`,"data-test":`isAlias`,checked:e.value??!1,onCheckedChange:e.onChange,disabled:O.isPending}),(0,W.jsx)(YY,{})]})})}),(0,W.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[a?(0,W.jsx)(Y,{type:`button`,variant:`secondary`,"data-test":`back-create-custom-domain-btn`,disabled:O.isPending,onClick:()=>d(`project`),children:`Back`}):(0,W.jsx)(rT,{asChild:!0,children:(0,W.jsx)(Y,{type:`button`,"data-test":`cancel-create-custom-domain-btn`,disabled:O.isPending,variant:`secondary`,children:`Cancel`})}),(0,W.jsx)(Y,{type:`submit`,"data-test":`create-custom-domain-btn`,disabled:O.isPending,children:(0,W.jsx)(CP,{loading:O.isPending,children:`Create`})})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`mt-4`,children:`Custom domains can only be configured on edge deployment environments and this project only has a working-copy environment.`}),(0,W.jsx)(`br`,{}),(0,W.jsxs)(`p`,{children:[` `,`For more information on this see our`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/environments`,children:`documentation on environments`}),`.`]}),a&&(0,W.jsx)(`div`,{className:`mt-5 sm:mt-4 flex justify-end`,children:(0,W.jsx)(Y,{type:`button`,variant:`secondary`,"data-test":`back-create-custom-domain-btn`,onClick:()=>d(`project`),children:`Back`})})]})]})})]})})]})})]}),(0,W.jsx)(IP,{open:A.showConfirm,onOpenChange:A.setShowConfirm,onDiscard:A.handleDiscard})]})},VJt=`https://zuplo.com/docs/dedicated/custom-domains`,HJt=({customDomain:e,isManagedDedicatedProject:t,isAkamaiManagedDedicatedProject:n})=>{let[r,i]=(0,U.useState)(void 0),a=()=>{s(),i(void 0)},[o,s]=I$(()=>{let i=r?.deployments.at(0)?.stage,o=r?.deployments.at(0)?.cname,s=typeof o==`string`&&o.length>0;return(0,W.jsx)(HP,{onClose:a,isOpen:!0,title:`Configure your custom domain`,children:(0,W.jsx)(`div`,{className:`space-y-4`,children:n?(0,W.jsx)(yJt,{}):t&&i===`api`?s?(0,W.jsx)(I7,{customDomain:r?.hostname,cname:o,documentationUrl:VJt}):(0,W.jsx)(L7,{}):e.provider===`custom`?(0,W.jsx)(L7,{}):e.provider===`amazon`?s?(0,W.jsx)(I7,{customDomain:r?.hostname,cname:o,documentationUrl:VJt}):(0,W.jsx)(L7,{}):s?(0,W.jsx)(I7,{customDomain:r?.hostname,cname:o}):(0,W.jsx)(L7,{})})})},[r]),c=e=>{i(e),o()};return(0,W.jsx)(Y,{onClick:()=>{c(e)},"data-test":`view-domain-configuration-btn`,title:`View Configuration`,variant:`ghost`,size:`icon`,children:(0,W.jsx)(xp,{size:18})})},UJt=/held zone/i;function WJt(e){return!!e?.some(e=>UJt.test(e))}var GJt=new Set([`pending`,`pending_migration`,`pending_provisioned`,`active_redeploying`,`provisioned`]),KJt=new Set([`blocked`,`pending_blocked`,`moved`,`deleted`,`pending_deletion`,`test_blocked`,`test_failed`]),qJt=new Set([`initializing`,`pending_validation`,`pending_issuance`,`pending_deployment`,`pending_cleanup`,`staging_deployment`,`holding_deployment`]),JJt=new Set([`expired`,`deactivating`,`inactive`,`initializing_timed_out`,`validation_timed_out`,`issuance_timed_out`,`deployment_timed_out`,`deletion_timed_out`,`deleted`,`pending_deletion`,`pending_expiration`]);function YJt(e){if(e.provider===`alias`)return null;if(e.provider===`custom`||e.provider===`amazon`)return{level:`unknown`,label:`Externally managed`,description:`This domain's status isn't reported to Zuplo — verification and certificates are handled by your dedicated infrastructure provider.`};let t=e.verificationErrors&&e.verificationErrors.length>0,n=e.status??null,r=e.sslStatus??null;if(!n&&!r&&!t)return{level:`pending`,label:`Initializing`,description:`We're waiting for the domain provider to report a status. This usually takes a few seconds after the domain is created.`};if(WJt(e.verificationErrors))return{level:`error`,label:`Zone hold`,description:`Cloudflare is blocking this hostname because the parent domain has a zone hold on another Cloudflare account. The zone owner needs to release the hold before we can finish provisioning.`,helpUrl:`https://developers.cloudflare.com/fundamentals/account/account-security/zone-holds/`,helpLabel:`How to release a zone hold`};if(t)return{level:`error`,label:`Needs attention`,description:`The domain provider reported verification errors. Review the details to resolve them.`};if(n&&KJt.has(n))return{level:`error`,label:R7(n),description:`The domain is in a state that prevents it from serving traffic. Contact support if this persists.`};if(r&&JJt.has(r))return{level:`error`,label:`SSL error`,description:`The SSL certificate is in the "${R7(r)}" state. The domain may not serve HTTPS traffic until this is resolved.`};let i=n===`active`||n===`test_active`||n===`test_active_apex`;return i&&(r===`active`||r===`staging_active`||r===`backup_issued`)?{level:`active`,label:`Active`,description:`The domain is verified and serving traffic over HTTPS.`}:i&&r&&qJt.has(r)?{level:`pending`,label:`Issuing certificate`,description:`The domain is verified. We're still provisioning the SSL certificate — this usually takes a few minutes.`}:n&&GJt.has(n)?{level:`pending`,label:`Verifying domain`,description:`We're waiting for DNS verification. Double-check the CNAME record at your DNS provider.`}:n||r?{level:`pending`,label:R7(n??r??`pending`),description:`The domain is still being set up. If this state persists, contact support.`}:{level:`unknown`,label:`Unknown`,description:`No status information is available for this domain.`}}function R7(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var XJt={active:{dot:`bg-green-500`,pulse:!1,pill:`bg-green-50 text-green-700 border-green-200 hover:bg-green-100 dark:bg-green-950 dark:text-green-300 dark:border-green-800 dark:hover:bg-green-900`},pending:{dot:`bg-amber-500`,pulse:!0,pill:`bg-amber-50 text-amber-800 border-amber-200 hover:bg-amber-100 dark:bg-amber-950 dark:text-amber-300 dark:border-amber-800 dark:hover:bg-amber-900`},error:{dot:`bg-red-500`,pulse:!1,pill:`bg-red-50 text-red-700 border-red-200 hover:bg-red-100 dark:bg-red-950 dark:text-red-300 dark:border-red-800 dark:hover:bg-red-900`},unknown:{dot:`bg-gray-400`,pulse:!1,pill:`bg-gray-50 text-gray-700 border-gray-200 hover:bg-gray-100 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-700`}},ZJt=({domain:e})=>{let t=YJt(e);if(!t)return null;let n=XJt[t.level],r=e.verificationErrors??[];return(0,W.jsxs)(IT,{children:[(0,W.jsx)(LT,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:G(`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,n.pill),"aria-label":`${e.hostname} status: ${t.label}`,children:[(0,W.jsxs)(`span`,{className:`relative flex size-2 items-center justify-center`,children:[n.pulse&&(0,W.jsx)(`span`,{className:G(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,n.dot)}),(0,W.jsx)(`span`,{className:G(`relative inline-flex size-2 rounded-full`,n.dot)})]}),t.label]})}),(0,W.jsx)(RT,{align:`start`,className:`w-96`,children:(0,W.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:G(`inline-flex size-2 rounded-full`,n.dot)}),(0,W.jsx)(`span`,{className:`font-medium`,children:t.label})]}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:t.description}),t.helpUrl&&(0,W.jsx)(tE,{href:t.helpUrl,className:`text-xs`,children:t.helpLabel??`Learn more`}),r.length>0&&(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Verification errors`}),(0,W.jsx)(`ul`,{className:`list-disc pl-5 space-y-1 text-destructive-foreground`,children:r.map(e=>(0,W.jsx)(`li`,{children:e},e))})]})]})})]})},QJt=({account:e,currentDomainConfig:t})=>{let{logEvent:n,captureException:r}=H(),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(``),c=e=>{let t=e.target.value;a(t)},l=YKt(),u=async()=>{try{if(s(``),!t.hostname||t.hostname.trim()===``){s(`The current domain configuration does not have a hostname associated with it`);return}await l.mutateAsync({accountName:e.name,projectName:t.projectName??``,hostname:t.hostname,deploymentName:t.deployments[0]?.deploymentName}),n(`account-custom-domain-delete-success`,{account:e.name}),d()}catch(t){r(t);let i=Fb(t);s(i),n(`account-custom-domain-delete-failed`,{account:e.name,errorMessage:i})}},d=()=>{p(),a(``),s(``)},[f,p]=I$(()=>(0,W.jsx)(HP,{onClose:d,isOpen:!0,title:`Delete custom domain`,className:`sm:max-w-xl`,children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(ck,{error:o,className:`mb-3`}),(0,W.jsxs)(`div`,{className:`text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[(0,W.jsxs)(`div`,{className:`relative bg-yellow-100 dark:bg-yellow-950/40 rounded-sm p-4 text-yellow-900 dark:text-yellow-200 text-sm whitespace-pre-line w-full mb-2`,children:[(0,W.jsxs)(`div`,{className:`flex space-x-2 items-center`,children:[(0,W.jsx)(np,{className:`h-5 w-5 text-yellow-900 dark:text-yellow-200`}),(0,W.jsx)(`span`,{className:`text-sm font-medium antialiased mt-0.5`,children:`Caution: Your project will no longer be accessible with this domain.`})]}),(0,W.jsxs)(`p`,{className:`px-2 mt-4`,children:[`You are about to delete the custom domain`,` `,(0,W.jsx)(`span`,{className:`font-medium antialiased`,children:t.hostname}),` `,`from your project. Requests using it will no longer reach your zup.`]})]}),(0,W.jsx)(`br`,{}),(0,W.jsxs)(`label`,{className:`block mb-2`,htmlFor:`hostname-field`,children:[`Please type`,` `,(0,W.jsx)(`span`,{className:`font-medium antialiased`,children:t.hostname}),` `,`to confirm.`]}),(0,W.jsx)(nE,{className:`mb-4`,type:`text`,autoComplete:`off`,value:i,onChange:c,id:`hostname-field`,"data-test":`hostname-field`}),(0,W.jsx)(`div`,{className:` text-red-500`,children:`I understand the consequences, delete this custom domain`})]}),(0,W.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[(0,W.jsx)(Y,{onClick:d,"data-test":`cancel-delete-custom-domain-btn`,variant:`outline`,disabled:l.isPending,children:`Cancel`}),(0,W.jsx)(Y,{"data-test":`delete-custom-domain-btn`,onClick:u,disabled:l.isPending||i!==t.hostname,children:(0,W.jsx)(CP,{loading:l.isPending,children:`Delete`})})]})]})}),[l.isPending,o,t,i]);return(0,W.jsx)(Y,{type:`button`,title:`Delete Custom Domain`,onClick:f,"data-test-id":`delete-custom-domain-btn`,variant:`ghost`,size:`icon-sm`,children:(0,W.jsx)(CP,{loading:l.isPending,children:(0,W.jsx)(zp,{size:18})})})},$Jt=/^(?!https?:\/\/)[a-zA-Z0-9.-]*\.[a-zA-Z]+$/,eYt=({account:e,projectName:t,currentDomainConfig:n})=>{let{logEvent:r,captureException:i}=H(),[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(n.deployments[0]?.deploymentName),d=n.hostname,{data:f,error:p}=qP(e.name,t),m=Fb(p);(0,U.useEffect)(()=>{m&&o(m)},[m]);let h=f?f.filter(e=>e.environmentType!==BP.WORKING_COPY):[],g=JKt(),_=async n=>{if(n.preventDefault(),!l||l.trim()===``){o(`Please select an environment from the options available`);return}if(!d||d.trim()===``){o(`Please provide a value on the custom domain field.`);return}if(d&&!$Jt.test(d)){o(`A custom domain value should only be the domain name. It should not start with 'http(s)' and should end with an alpha character.`);return}try{o(``),await g.mutateAsync({accountName:e.name,projectName:t,hostname:d,deploymentName:l}),c(!0),r(`account-custom-domain-edit-success`,{account:e.name})}catch(t){i(t);let n=Fb(t);r(`account-custom-domain-edit-failed`,{account:e.name,errorMessage:n}),o(n),c(!1)}},v=()=>{b(),u(n.deployments[0]?.deploymentName),o(``),c(!1)},[y,b]=I$(()=>(0,W.jsx)(HP,{onClose:v,isOpen:!0,title:`Edit your custom domain`,children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(ck,{error:a}),(0,W.jsxs)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:[s===!1&&(0,W.jsxs)(`form`,{onSubmit:_,children:[(0,W.jsx)(`label`,{className:`block mb-2`,htmlFor:`environment-field`,children:`Which environment do you want to apply your custom domain to ?`}),(0,W.jsx)(`div`,{className:`mb-9`,children:(0,W.jsx)(WP,{id:`environment-field`,"data-test":`environment-field`,environments:h,value:l??``,onValueChange:e=>u(e),disabled:g.isPending,placeholder:`Select an environment`})}),(0,W.jsx)(`label`,{className:`block mb-2`,htmlFor:`hostname-field`,children:`Your custom domain`}),(0,W.jsx)(nE,{className:`mb-9`,type:`text`,autoComplete:`off`,placeholder:`api.example.com`,id:`hostname-field`,value:d,disabled:!0,"data-test":`hostname-field`}),(0,W.jsxs)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:[(0,W.jsx)(Y,{variant:`outline`,type:`button`,onClick:v,"data-test":`cancel-edit-custom-domain-btn`,disabled:g.isPending,children:`Cancel`}),(0,W.jsx)(Y,{"data-test":`save-edit-custom-domain-btn`,type:`submit`,disabled:g.isPending||l===n.deployments[0]?.deploymentName,children:(0,W.jsx)(CP,{loading:g.isPending,children:`Save`})})]})]}),s===!0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`text-left text-sm text-foreground whitespace-pre-line w-full mb-2`,children:(0,W.jsxs)(`p`,{children:[`Successfully edited custom domain`,` `,(0,W.jsx)(tE,{href:`https://${d}`,children:d}),` `,`to map to deployment `,l]})}),(0,W.jsx)(`div`,{className:`mt-5 sm:mt-4 flex justify-end gap-x-4`,children:(0,W.jsx)(Y,{variant:`outline`,className:`w-24 justify-center`,type:`button`,onClick:v,"data-test":`ok-edit-custom-domain-btn`,disabled:!s,children:`OK`})})]})]})]})}),[h,a]),x=()=>{y()};return(0,W.jsx)(Y,{onClick:()=>x(),title:`Edit Custom Domain`,"data-test-id":`edit-custom-domain-btn`,variant:`ghost`,size:`icon-sm`,children:(0,W.jsx)(CP,{loading:g.isPending,children:(0,W.jsx)(cte,{size:18})})})},tYt=({classNames:e,projectType:t,feature:n,helpUrl:r})=>(0,W.jsxs)(lk,{variant:`danger`,className:e,children:[(0,W.jsx)(uk,{children:t===`managed-dedicated`?`Managed Dedicated Project`:t===`self-hosted`?`Self Hosted Project`:`Managed Edge Project`}),(0,W.jsx)(pk,{className:`flex-1 leading-loose mt-1 text-sm`,children:(0,W.jsxs)(`p`,{className:`leading-loose`,children:[`Your project is running on a `,t===`managed-dedicated`?`managed dedicated`:t===`self-hosted`?`self hosted`:`managed edge hosted`,` environment. For information on how to setup up `,n,`, please refer to`,` `,(0,W.jsx)(tE,{href:r,children:`the documentation`}),`.`]})})]});function nYt(){return(0,W.jsx)(`button`,{type:`button`,disabled:!0,title:`Locked custom domain`,className:`items-center justify-center p-2 hover:bg-gray-100 rounded-sm cursor-pointer`,children:(0,W.jsx)(Tp,{className:`h-5 w-5 mx-auto`,"aria-hidden":`true`})})}var rYt=`Custom Domains`,iYt=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/custom-domains`,children:`Custom domains`}),` `,`allow you to use your own domain name for your API and developer portal. For complex custom domain configurations, please contact us at`,` `,(0,W.jsx)(tE,{href:`mailto:${yb}`,children:yb}),` `,`or use the chat widget at the bottom right.`]}),aYt=()=>{let e=nm([`account`,`project`]),t=XKt(e.account.name,e.project.name),n=HT(e.account.name,e.project.name);if(!t.data||!n.data)return(0,W.jsx)(N7,{title:rYt,description:iYt,children:(0,W.jsx)(p1,{})});let r=t.data?.filter(t=>t.projectName&&t.projectName===e.project.name&&t.deployments[0]).sort((e,t)=>e.deployments[0].deploymentName.localeCompare(t.deployments[0].deploymentName)),i=e.account.customDomainsInUse>=e.account.entitlements.customDomains,a=FJt({projectType:e.project.type,defaultConfiguration:n.data.defaultConfiguration}),o=NJt({projectType:e.project.type,defaultConfiguration:n.data.defaultConfiguration}),s=e.project.type!==`self-hosted`&&(a?!!e.account.entitlements.aliasDomains:e.account.entitlements.customDomains>0);return(0,W.jsxs)(N7,{title:rYt,description:iYt,action:s?(0,W.jsx)(BJt,{disabled:!a&&i,account:e.account,projectName:e.project.name,isManagedDedicatedProject:o,isAkamaiManagedDedicatedProject:a}):void 0,children:[i&&e.account.entitlements.customDomains>0&&e.project.type!==`self-hosted`&&!a&&(0,W.jsx)(_Jt,{account:e.account,source:`custom-domain-limit`}),!i&&e.project.type!==`self-hosted`&&!a&&(0,W.jsx)(vJt,{used:e.account.customDomainsInUse,max:e.account.entitlements.customDomains,label:`custom domains`,account:e.account,hideAtLimit:!0}),a&&!!e.account.entitlements.aliasDomains&&(0,W.jsx)(sb,{variant:`info`,className:`text-sm`,children:(0,W.jsx)(lb,{children:(0,W.jsxs)(`p`,{children:[`This project uses Akamai managed dedicated hosting. Configure the hostname in your Akamai CDN first — see the`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/dedicated/akamai/cdn`,children:`Akamai custom domain documentation`}),`. Once it's set up there, add the domain using the button above to register it with Zuplo.`]})})}),r.length>0?(0,W.jsx)(lk,{className:`overflow-hidden`,children:r.map(t=>{let n=t.deployments[0],r=o&&n?.stage===`api`,i=t.provider===`custom`&&!r,s=t.provider===`alias`,c=n.stage===`dev-portal`,l=a&&!s||i;return(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border-b px-4 py-3 last:border-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`shrink-0 flex size-9 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:c?(0,W.jsx)(Qte,{className:`size-4`}):(0,W.jsx)(bp,{className:`size-4`})}),(0,W.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,W.jsxs)(`a`,{href:`https://${t.hostname}`,target:`_blank`,rel:`noreferrer`,className:`font-medium text-sm text-foreground hover:underline inline-flex items-center gap-1 truncate`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:t.hostname}),(0,W.jsx)(up,{className:`size-3 shrink-0 opacity-60`})]}),(0,W.jsx)(ZJt,{domain:t}),n.isDefault&&(0,W.jsx)(qT,{variant:`outline`,className:`text-xs`,children:`Default`}),s&&(0,W.jsx)(qT,{variant:`outline`,className:`text-xs`,children:`Alias`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:c?`Dev Portal`:`API`}),(0,W.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(rGe,{env:n.environmentType??null}),` `,`(`,n.deploymentName,`)`]}),n.branch&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono`,children:[(0,W.jsx)(yp,{className:`size-3`}),n.branch]})]})]})]})]}),(0,W.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1`,children:[!s&&(0,W.jsx)(HJt,{customDomain:t,isManagedDedicatedProject:o,isAkamaiManagedDedicatedProject:a}),l?(0,W.jsx)(nYt,{}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(eYt,{account:e.account,projectName:e.project.name,currentDomainConfig:t}),(0,W.jsx)(QJt,{account:e.account,currentDomainConfig:t})]})]})]},t.id)})}):s?(0,W.jsx)(lk,{children:(0,W.jsxs)(db,{children:[(0,W.jsxs)(fb,{children:[(0,W.jsx)(pb,{variant:`icon`,children:(0,W.jsx)(bp,{})}),(0,W.jsx)(mb,{children:`No custom domains yet`}),(0,W.jsx)(hb,{children:`Serve your API and developer portal from your own domain name.`})]}),(0,W.jsx)(gb,{children:(0,W.jsx)(BJt,{disabled:!a&&i,account:e.account,projectName:e.project.name,isManagedDedicatedProject:o,isAkamaiManagedDedicatedProject:a})})]})}):null,e.project.type===`self-hosted`?(0,W.jsx)(tYt,{classNames:``,feature:`custom domains`,helpUrl:`https://zuplo.com/docs/dedicated/custom-domains`,projectType:e.project.type}):a&&!e.account.entitlements.aliasDomains?(0,W.jsx)(yJt,{}):!a&&e.account.entitlements.customDomains<=0?(0,W.jsx)(_Jt,{account:e.account,source:`custom-domain`}):null]})},oYt=e=>{let t=document.createRange();return t.selectNodeContents(e),t.getBoundingClientRect().width>e.getBoundingClientRect().width},sYt=()=>{let[e,t]=(0,U.useState)(!1);return{tooltipProps:(0,U.useMemo)(()=>{if(!e)return{open:!1}},[e]),triggerProps:(0,U.useMemo)(()=>({ref:e=>{e&&t(oYt(e))}}),[])}};function cYt({isSecret:e}){return e?(0,W.jsx)(Tp,{className:`h-4 w-auto`}):(0,W.jsx)(op,{className:`h-4 w-auto`})}var lYt=({variable:e,asIcon:t=!1})=>(0,W.jsxs)(vzt,{children:[(0,W.jsx)(yzt,{asChild:!0,children:t?(0,W.jsx)(Y,{variant:`ghost`,size:`icon`,className:`flex items-center`,children:(0,W.jsx)(op,{className:`w-4 h-4`})}):(0,W.jsxs)(Y,{variant:`secondary`,size:`default`,className:`flex items-center gap-2`,children:[(0,W.jsx)(op,{className:`w-4 h-4`}),`Get Code Snippet`]})}),(0,W.jsxs)(y6,{side:`right`,className:`sm:max-w-none w-1/3 min-w-[500px]`,children:[(0,W.jsx)(`div`,{className:`text-lg font-semibold border-b`,children:`Code Snippets`}),(0,W.jsx)(`p`,{className:`my-2 text-sm`,children:`Use this Code Snippet anywhere in your modules to access your environment variable.`}),(0,W.jsx)(lk,{offset:`md`,className:`bg-gray-200 text-xs `,children:(0,W.jsxs)(`pre`,{id:`codePre`,"data-lang":`typescript`,className:`font-mono text-gray-900 overflow-x-auto`,children:[`import `,`{`,` environment `,`}`,` from "@zuplo/runtime";`,`\r
|
|
1581
1581
|
\r
|
|
1582
1582
|
`,`const ${e.name} = environment.${e.name};\r\n`]})})]})]}),uYt=e=>{let t=[];return e.targets.includes(`production`)&&t.push(`production`),e.targets.includes(`preview`)&&t.push(e.targetBranch??`preview`),e.targets.includes(`working-copy`)&&t.push(`development`),t.join(`, `)};function dYt({variable:e,account:t,project:n,previewEnvironments:r,environmentsLoaded:i}){let a=vGe(),{logEvent:o}=H(),[s,c]=(0,U.useState)(),[l,u]=(0,U.useState)(!1),{tooltipProps:d,triggerProps:f}=sYt(),{tooltipProps:p,triggerProps:m}=sYt(),[h,g]=I$(()=>{let r=async()=>{g(),await a.mutateAsync({accountName:t,projectName:n.name,id:e.id}),o(`env-var-deleted`,{account:t,project:n.name,id:e.id})},i=`Error deleting Environment Variable`,c=`We found an error trying to remove the variable.`;return s instanceof He&&(i=s.title??i,c=s.detail??c),(0,W.jsx)(SQ,{alertType:`ERROR`,bodyText:c,onPrimaryButtonClick:r,onSecondaryButtonClick:g,primaryButtonText:`Try again`,secondaryButtonText:`Cancel`,hideModal:g,title:i})},[e,r,s]),_=async()=>{try{await a.mutateAsync({accountName:t,projectName:n.name,id:e.id}),o(`env-var-deleted`,{account:t,project:n.name,id:e.id}),u(!1)}catch(r){o(`env-var-deletion-failed`,{account:t,project:n.name,id:e.id}),u(!1),c(r instanceof Error?r:Error(r)),h()}},[v,y]=I$(()=>(0,W.jsx)(yGe,{project:n,variable:e,previewEnvironments:r,environmentsLoaded:i,onClose:y,account:t}),[e,r,i]),b=e.personalValue??e.value;return(0,W.jsxs)(`div`,{className:`grid grid-cols-subgrid col-span-full gap-4 items-center border-b px-4 py-3 last:border-0`,children:[(0,W.jsxs)(N$,{open:l,onOpenChange:u,onClickDelete:_,isPending:a.isPending,deleteButtonText:`Confirm`,children:[`Are you sure you want to delete the variable '`,e.name,`'`]}),(0,W.jsx)(`div`,{className:`rounded-full border w-10 h-10 flex items-center justify-center`,children:(0,W.jsx)(cYt,{isSecret:e.type===`secret`})}),(0,W.jsxs)(`div`,{className:`flex flex-row justify-between items-center truncate`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col truncate`,children:[(0,W.jsxs)(Aw,{...p,delayDuration:0,children:[(0,W.jsx)(jw,{...m,asChild:!0,children:(0,W.jsx)(`span`,{className:`font-mono text-sm truncate`,"data-test":`env-variable-name`,children:e.name})}),(0,W.jsxs)(Mw,{className:`font-mono`,children:[(0,W.jsx)(Nw,{}),e.name]})]}),(0,W.jsx)(`div`,{className:`text-sm text-neutral-500 line-clamp-2`,children:uYt(e)})]}),e.personalValue&&(0,W.jsx)(`div`,{className:`bg-zuplo-highlight rounded-full text-2xs text-white px-2 py-1 mx-2 flex-none`,children:`PERSONAL`})]}),(0,W.jsx)(`div`,{"data-test":`env-variable-value`,className:`truncate flex text-xs font-mono`,children:b?(0,W.jsxs)(Aw,{...d,children:[(0,W.jsx)(jw,{asChild:!0,...f,children:(0,W.jsx)(`div`,{className:`bg-muted p-1 px-2 rounded-sm max-w-96 truncate`,children:e.type===`config`?b:`************`})}),(0,W.jsxs)(Mw,{className:`text-xs`,children:[(0,W.jsx)(Nw,{}),b]})]}):(0,W.jsx)(qT,{variant:`outline`,children:`No value`})}),(0,W.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,W.jsx)(lYt,{variable:e,asIcon:!0}),(0,W.jsx)(Y,{size:`icon`,variant:`ghost`,type:`button`,"data-test":`env-variable-edit`,onClick:()=>{v()},children:(0,W.jsx)(jp,{size:18})}),(0,W.jsx)(Y,{size:`icon`,variant:`ghost`,"data-test":`env-variable-delete`,onClick:()=>{u(!0)},children:a.isPending?(0,W.jsx)(TP,{className:`w-4 h-4`,borderPositionAndSize:`border-2`}):(0,W.jsx)(zp,{size:18})})]})]},e.name)}var z7=`___EMPTY___`,B7=`Environment Variables`,V7=`Configuration and secrets available to your environments at build and runtime. Changes take effect on the next deployment.`;function fYt(){let e=nm([`account`,`project`]),{logEvent:t}=H(),n=KP(e.account.name,e.project.name),r=!!e.project.sourceRepoUrl,i=qP(e.account.name,e.project.name),a=[{label:`All`,value:z7},{label:`Production`,value:`production`},{label:`Preview (other branches)`,value:`preview`},{label:`Development`,value:`working-copy`}],[o,s]=(0,U.useState)(z7),[c,l]=(0,U.useState)(z7),[u,d]=(0,U.useState)(``),f=i.data?.filter(e=>!VP(e.environmentType,BP.PRODUCTION,BP.WORKING_COPY))??[],p=i.data!==void 0,m=f.map(e=>e.branchName),h=(0,U.useMemo)(()=>[z7,...m],[m]),g=(0,U.useMemo)(()=>n.data??[],[n.data]),_=(0,U.useMemo)(()=>g.filter(e=>o===z7||e.targets.includes(o)),[g,o]),v=dX(u,(0,U.useMemo)(()=>o!==`preview`||c===z7?_:_.filter(e=>e.targets.includes(`preview`)&&e.targetBranch===c),[_,o,c]),{key:`id`,getText:e=>[e.name,e.type,e.value,...e.targets,e.targetBranch].filter(Boolean)}),[y,b]=I$(()=>(0,W.jsx)(CGe,{account:e.account.name,project:e.project,previewEnvironments:f,onClose:b}),[f]);if(n.isError)return(0,W.jsx)(N7,{title:B7,description:V7,children:(0,W.jsx)(PWe,{error:n.error})});if(!n.data||r&&!i.data)return(0,W.jsx)(N7,{title:B7,description:V7,children:(0,W.jsx)(p1,{})});let x=o!==z7||c!==z7&&c!==``||u!==``;return(0,W.jsxs)(N7,{title:B7,description:V7,action:(0,W.jsxs)(Y,{onClick:y,children:[(0,W.jsx)(Op,{size:16}),`Add variable`]}),children:[(0,W.jsxs)(`div`,{className:`flex flex-row items-center gap-3`,children:[(0,W.jsx)(nE,{type:`search`,placeholder:`Search variables`,className:`max-w-xs`,value:u,onChange:n=>{d(n.currentTarget.value),t(`env-var-filter-changed`,{account:e.account.name,project:e.project.name,query:n.currentTarget.value})}}),(0,W.jsxs)(gY,{value:o,onValueChange:e=>{s(e),e!==`preview`&&l(``)},children:[(0,W.jsx)(vY,{className:`w-52`,"data-test":`env-variable-filter`,children:(0,W.jsx)(_Y,{})}),(0,W.jsx)(yY,{className:`w-52`,children:a.map((e,t)=>(0,W.jsx)(bY,{value:e.value,"data-test":`env-variable-filter-${t}`,children:e.label},e.value))})]}),o===`preview`?(0,W.jsxs)(gY,{value:c,onValueChange:e=>{l(e)},children:[(0,W.jsx)(vY,{className:`w-52`,"data-test":`env-variable-branch-filter`,children:(0,W.jsx)(_Y,{})}),(0,W.jsx)(yY,{className:`w-52`,children:h.map(e=>(0,W.jsx)(bY,{value:e,children:e===z7?`All branches`:e},e))})]}):null]}),v.length>0?(0,W.jsx)(lk,{className:`grid grid-cols-[min-content_minmax(auto,250px)_1fr_auto] overflow-hidden`,children:v.map(t=>(0,W.jsx)(dYt,{account:e.account.name,project:e.project,previewEnvironments:f,environmentsLoaded:p,variable:t},t.id))}):(0,W.jsx)(lk,{children:x?(0,W.jsxs)(db,{children:[(0,W.jsxs)(fb,{children:[(0,W.jsx)(pb,{variant:`icon`,children:(0,W.jsx)(Gte,{})}),(0,W.jsx)(mb,{children:`No matching variables`}),(0,W.jsx)(hb,{children:`No environment variables match the current search or filter.`})]}),(0,W.jsx)(gb,{children:(0,W.jsx)(Y,{variant:`outline`,onClick:()=>{d(``),s(z7),l(z7)},children:`Clear filters`})})]}):(0,W.jsxs)(db,{children:[(0,W.jsxs)(fb,{children:[(0,W.jsx)(pb,{variant:`icon`,children:(0,W.jsx)($te,{})}),(0,W.jsx)(mb,{children:`No environment variables yet`}),(0,W.jsxs)(hb,{className:`max-w-md`,children:[`Variables you add here are provided to your environments during build and at runtime.`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/deployments/environment-variables`,children:`Read the docs`}),`.`]})]}),(0,W.jsx)(gb,{children:(0,W.jsxs)(Y,{onClick:y,children:[(0,W.jsx)(Op,{size:16}),`Add your first variable`]})})]})})]})}var pYt=({projectName:e,closeModalAction:t,accountName:n,onFinishDeletion:r})=>{let{logEvent:i,captureException:a}=H(),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(null),u=t=>{s(t.target.value===e)},d=xAe(n,e);return(0,W.jsx)(S_t,{alertType:`DELETE`,isOpen:!0,title:`Delete Project`,setIsOpen:t,secondaryButtonContent:`Cancel`,secondaryButtonTestID:`project-list-close-delete-project-modal`,onSecondaryButtonClick:t,primaryButtonTestID:`project-list-delete-project-button`,secondaryButtonDisabled:d.isPending,primaryButtonDisabled:!o||d.isPending,primaryButtonContent:`Delete`,onPrimaryButtonClick:async()=>{try{l(null),await d.mutateAsync(),i(`project-deleted`,{account:n,project:e}),r?.(),t()}catch(t){i(`project-deletion-failed`,{account:n,project:e}),a(t),l(Fb(t))}},bodyElement:(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(ck,{error:c}),(0,W.jsx)(`p`,{className:`text-sm`,children:`This cannot be undone! Your GitHub repository will be untouched.`}),(0,W.jsxs)(`p`,{className:`text-sm`,children:[`Please type `,(0,W.jsx)(`strong`,{onDoubleClick:e=>{let t=e.currentTarget,n=new Range;n.setStart(t,0),n.setEnd(t,1),document.getSelection()?.removeAllRanges(),document.getSelection()?.addRange(n)},children:e}),` `,`to confirm.`]}),(0,W.jsx)(nE,{disabled:d.isPending,type:`text`,className:`mt-2`,autoFocus:!0,autoComplete:`off`,onChange:u})]})})};function mYt(){let e=Ab([`account`,`project`]),t=lc(),[n,r]=I$(()=>(0,W.jsx)(pYt,{projectName:e.project,accountName:e.account,closeModalAction:r,onFinishDeletion:()=>t(`/`)}),[]);return(0,W.jsxs)(lk,{variant:`danger`,children:[(0,W.jsxs)(uk,{children:[(0,W.jsx)(dk,{children:`Delete Project`}),(0,W.jsx)(fk,{children:`Permanently delete this project and all associated data. This cannot be undone, there is no going back.`})]}),(0,W.jsx)(pk,{className:`leading-loose text-sm`,children:`Your GitHub repository will remain untouched.`}),(0,W.jsx)(mk,{variant:`danger`,className:`justify-end`,children:(0,W.jsxs)(Y,{"data-test":`delete-button`,variant:`destructive`,onClick:n,children:[(0,W.jsx)(zp,{size:16}),`Delete Project`]})})]})}var hYt=({children:e,copyValue:t})=>{let{logEvent:n}=H();return(0,W.jsxs)(`div`,{className:`mb-2 md:mb-0`,children:[e,t&&(0,W.jsx)(EP,{className:`relative top-1`,onClick:()=>{n(`project-information-property-copied`)},textToCopy:t})]})},gYt=()=>{let{logEvent:e}=H(),t=nm([`account`,`project`]);if(!qP(t.account.name,t.project.name).data)return(0,W.jsx)(`div`,{className:`p-6`,children:(0,W.jsx)(p1,{})});let n=[];return n.push({label:`Project Name`,value:t.project.name}),n.push({label:`Account Name`,value:t.account.name}),(0,W.jsxs)(lk,{children:[(0,W.jsxs)(uk,{children:[(0,W.jsx)(dk,{children:`Project Information`}),(0,W.jsx)(fk,{})]}),(0,W.jsx)(pk,{children:(0,W.jsx)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[150px_1fr] text-sm mt-2`,children:n.map(t=>(0,W.jsxs)(U.Fragment,{children:[(0,W.jsx)(`div`,{className:`font-medium`,children:t.label}),(0,W.jsx)(hYt,{copyValue:t.value,children:t.isLink?(0,W.jsx)(tE,{href:t.value,onClick:()=>{e(`project-information-link-clicked`,{label:t.label,value:t.value})},className:`break-all`,children:t.value}):t.value})]},t.value))})})]})},_Yt=()=>(0,W.jsxs)(N7,{title:`General`,description:`Project name, identifiers, and lifecycle.`,children:[(0,W.jsx)(gYt,{}),(0,W.jsx)(mYt,{})]}),vYt={admin:`Admin`,developer:`Developer`,member:`Member`,"ai-user":`AI User`,"no-access":`No Access`},H7=(e,t)=>e!==`no-access`&&(t||e===`admin`),yYt=({value:e,hiddenRoles:t=[],aiProject:n=!1,...r})=>{let i=em(),a=nm([`account`]).account.entitlements.rbacEnabled,o=Rw.filter(r=>!t.concat([`no-access`]).includes(r)&&(r!==`ai-user`||n&&(a||e===`ai-user`)));return(0,W.jsxs)(gY,{...r,value:e,onValueChange:e=>{H7(e,a)?r.onValueChange?.(e):i.toast((0,W.jsxs)(W.Fragment,{children:[`This role is not available for your account. Please upgrade to the Enterprise plan.`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/accounts/roles-and-permissions`,target:`_blank`,children:`Learn more about roles and permissions.`})]}))},children:[(0,W.jsx)(vY,{className:`min-w-40`,children:(0,W.jsx)(_Y,{placeholder:`Select a role`})}),(0,W.jsx)(yY,{className:`min-w-40`,children:o.map(e=>(0,W.jsx)(bY,{value:e,onClick:t=>{H7(e,a)||(t.preventDefault(),t.stopPropagation(),window.open(`https://zuplo.com/docs/articles/accounts/roles-and-permissions`,`_blank`))},children:(0,W.jsxs)(`div`,{className:`grid grid-cols-2`,children:[vYt[e],!H7(e,a)&&(0,W.jsx)(qT,{variant:`outline`,className:``,children:`Enterprise`})]})},e))})]})},bYt={zuplo:{viewBox:[0,0,308,308],ink:[41.36,259.74],Glyph:()=>(0,W.jsxs)(`g`,{fillRule:`nonzero`,fill:`none`,children:[(0,W.jsx)(`path`,{d:`M0 0h308v308H0z`}),(0,W.jsx)(`path`,{d:`M214.523 182.007h-74.088l78.939-79.076a5.34 5.34 0 0 0-.807-8.204 5.314 5.314 0 0 0-2.957-.899H90.239V41.364h137.515a53.31 53.31 0 0 1 28.617 7.922 53.444 53.444 0 0 1 19.967 22.011 52.117 52.117 0 0 1 4.221 31.194 52.062 52.062 0 0 1-14.508 27.924l-51.528 51.592Z`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M90.24 119.097h74.092l-78.781 78.917a5.431 5.431 0 0 0-1.172 5.912 5.423 5.423 0 0 0 5.001 3.351h125.017v52.464H77.016a53.322 53.322 0 0 1-28.616-7.923 53.453 53.453 0 0 1-19.968-22.011 52.109 52.109 0 0 1-4.219-31.194 52.059 52.059 0 0 1 14.51-27.924l51.517-51.592Z`,fill:`currentColor`})]})},akamai:{viewBox:[344.42,285.18,451,489.75],ink:[285.18,774.93],Glyph:()=>(0,W.jsxs)(`g`,{fill:`currentColor`,children:[(0,W.jsx)(`path`,{d:`M592.85,764.11c-100.8-30.77-174.12-123.92-174.12-234.05s74.88-205.29,177.4-235.02c10.48-3.06,7.73-9.86-4.91-9.86-136.28,0-246.8,109.69-246.8,244.89s110.51,244.86,246.8,244.86c12.63,0,13.14-7.3,1.63-10.81Z`}),(0,W.jsx)(`path`,{d:`M465.48,587.42c-.68-6.58-1.01-13.23-1.01-19.94,0-107.36,87.05-194.39,194.43-194.39,101.52,0,132,45.31,135.78,42.35,4.12-3.26-36.84-93.07-156.05-93.07-107.39,0-194.44,87.03-194.44,194.39,0,24.84,4.65,48.52,13.13,70.31,3.58,9.14,9.08,9.22,8.17.35Z`}),(0,W.jsx)(`path`,{d:`M546.92,447.31c50.53-22.03,114.01-22.7,176.42-.89,41.91,14.62,66.2,35.5,68.19,34.64,3.31-1.43-24.38-45.28-74.36-64.24-60.51-22.93-125.69-10.93-173.18,26.32-5.22,4.11-3.25,6.87,2.93,4.17Z`})]})}},xYt=({mark:e,...t})=>(0,W.jsx)(`svg`,{viewBox:e.viewBox.join(` `),xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,W.jsx)(e.Glyph,{})}),SYt=({viewBox:[e,t,n,r],ink:[i,a]})=>{let o=n/2,s=(a-i)*.07,c=o/2,l=e-o,u=e+n+o,d=t+r+s;return{surface:`M${l} ${t}${Array.from({length:Math.round((u-l)/c)},(e,t)=>`q${c/2} ${t%2==0?-2*s:2*s} ${c} 0`).join(``)}L${u} ${d}L${l} ${d}Z`,period:o,empty:a-t+s,full:i-t-s}},CYt=({mark:e})=>{let t=(0,U.useId)(),[n,r,i,a]=e.viewBox,{surface:o,period:s,empty:c,full:l}=SYt(e);return(0,W.jsxs)(`svg`,{viewBox:e.viewBox.join(` `),xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,className:`absolute inset-0 size-full text-zuplo-pink`,style:{"--logo-fill-empty":`${c}px`,"--logo-fill-full":`${l}px`,"--logo-fill-period":`${s}px`},children:[(0,W.jsx)(`mask`,{id:t,maskUnits:`userSpaceOnUse`,x:n,y:r,width:i,height:a,children:(0,W.jsxs)(`g`,{className:`logo-fill-level`,children:[(0,W.jsx)(`path`,{className:`logo-fill-wave`,d:o,fill:`#fff`}),(0,W.jsx)(`path`,{className:`logo-fill-wave`,d:o,fill:`#fff`})]})}),(0,W.jsx)(`g`,{mask:`url(#${t})`,children:(0,W.jsx)(e.Glyph,{})})]})},wYt=({variant:e=`full`,className:t,width:n,height:r,fillOnHover:i=!1})=>{let a=Fqt();if(e===`mark`){let e=bYt[a.id],o=(0,W.jsx)(xYt,{mark:e,className:t,width:n,height:r,role:`img`,"aria-label":a.logoAlt});return i?(0,W.jsxs)(`span`,{className:`group relative flex`,children:[o,(0,W.jsx)(CYt,{mark:e})]}):o}return e===`full`&&a.logoDark?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`img`,{src:a.logo,alt:a.logoAlt,className:G(t,`dark:hidden`),width:n,height:r}),(0,W.jsx)(`img`,{src:a.logoDark,alt:a.logoAlt,className:G(t,`hidden dark:inline`),width:n,height:r})]}):(0,W.jsx)(`img`,{src:e===`white`?a.logoWhite:a.logo,alt:a.logoAlt,className:G(t),width:n,height:r})},TYt=()=>(0,W.jsx)(`div`,{className:`h-0 flex flex-col items-center -translate-y-14 mb-2`,children:(0,W.jsx)(wYt,{variant:`white`,className:`h-17 w-auto rounded-full bg-zuplo-pink p-4 shadow-xs`})}),EYt=(e,t,n)=>{let[r,i]=(0,U.useState)(t),a=lF(n);return[e===void 0?r:e,(0,U.useCallback)(t=>{e===void 0?i(t):a.current?.(t)},[e,a])]},DYt=Dh({email:Ch().email(`Invalid email address`),role:kh([`admin`,`developer`,`member`,`ai-user`])}),OYt=({inviteOnly:e=!1,account:t,project:n,pool:r,description:i,hiddenRoles:a,children:o,open:s,onOpenChange:c,excludeUserIds:l,changeRoleForUserIds:u})=>{let d=nm([`account`]),{logEvent:f}=H(),[p,m]=EYt(s,!1,c),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(!1),y=P(),{onError:b,onSuccess:x}=RP(),S=d.account.entitlements.rbacEnabled,C=ok({resolver:sk(DYt),defaultValues:{email:``,role:S?`member`:`admin`}}),w=S?`member`:`admin`,T=kb(R.authAccountUsersRoles(t),{extractData:!0}),E=C.watch(`email`),D=lF(()=>{C.reset(),g(!1)});(0,U.useEffect)(()=>{p||D.current()},[p,D]);let O=I({mutationFn:({email:e,role:i})=>{let a=r&&n?{account:{role:w},project:{name:n,role:w},team:{...r,role:i}}:n?{account:{role:w},project:{name:n,role:i}}:{account:{role:i}},o=T?.data?.find(t=>t.email===e)?.id;return!h&&o&&u?.includes(o)?y.fetch(V.auth.updateUsersRole({accountName:t,projectName:n,userId:o,role:i})):y.fetch(V.accountInvite.createAccountInvite(t,e,a))},onError:b,onSuccess:()=>{x(h?`Invitation sent to ${C.getValues(`email`)}`:`Member added to ${d.account.label??d.account.name}`),m(!1)}}),k=dX(E,(T?.data??[]).filter(e=>!l||!l.includes(e.id)&&!l.includes(e.sub)),{getText:e=>[e.name,e.email],key:`email`}),A=e=>{f(`account-invite-submitted`,{role:e.role,teamId:r?.id??``,project:n,account:t}),O.mutate({email:e.email,role:e.role})};return(0,W.jsxs)(tT,{open:p,onOpenChange:e=>{e||C.reset(),m(e)},children:[o&&(0,W.jsx)(nT,{asChild:!0,children:o}),(0,W.jsxs)(iT,{className:`max-w-md`,children:[(0,W.jsx)(iAe,{}),(0,W.jsx)(TYt,{}),(0,W.jsxs)(aT,{className:`mt-2`,children:[(0,W.jsxs)(sT,{children:[`Invite to `,d.account.label??d.account.name]}),(0,W.jsx)(cT,{className:`opacity-75`,children:i??`Once you invite someone to your account, they can be granted access to account projects.`})]}),(0,W.jsx)(HY,{...C,children:(0,W.jsxs)(`form`,{onSubmit:C.handleSubmit(A),className:`mt-2 space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,W.jsx)(UY,{control:C.control,name:`email`,render:({field:t})=>(0,W.jsxs)(GY,{className:`w-full`,children:[(0,W.jsx)(KY,{children:`Member`}),(0,W.jsx)(qY,{children:(0,W.jsx)(`div`,{className:`relative`,children:(0,W.jsx)(IT,{open:_&&E.length>0,onOpenChange:v,modal:!1,children:(0,W.jsxs)(lT,{shouldFilter:!1,loop:!0,children:[(0,W.jsx)(NT,{asChild:!0,children:(0,W.jsx)(Xw.Input,{asChild:!0,value:E,onValueChange:t.onChange,onKeyDown:e=>{if(e.key===`Enter`&&_===!1){e.currentTarget.form?.requestSubmit(),e.preventDefault();return}v(e.key!==`Escape`)},onMouseDown:()=>v(e=>!!E||!e),onFocus:()=>v(!0),onBlur:()=>v(!1),children:(0,W.jsx)(nE,{placeholder:`Email address or member name`})})}),!open&&(0,W.jsx)(dT,{"aria-hidden":`true`,className:`hidden`}),(0,W.jsx)(RT,{asChild:!0,align:`start`,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{e.target instanceof Element&&e.target.hasAttribute(`cmdk-input`)&&e.preventDefault()},className:`w-(--radix-popover-trigger-width) p-0`,children:(0,W.jsxs)(dT,{className:`max-h-[200px] overflow-y-auto`,children:[(0,W.jsx)(fT,{children:`No members found.`}),(0,W.jsxs)(pT,{children:[!e&&k.map((e,n)=>(0,W.jsx)(mT,{value:n.toString(),onSelect:()=>{t.onChange(e.email),g(!1),v(!1)},children:(0,W.jsx)(`span`,{children:e.name})},e.id)),E.length>0&&(0,W.jsxs)(mT,{value:k.length.toString(),onSelect:()=>{g(!0),v(!1)},children:[(0,W.jsx)(nte,{size:16,className:`mr-2`}),` `,`Invite "`,E.includes(`@`)?E:`${E}@example.com`,`" to Account`]})]})]})})]})})})}),(0,W.jsx)(YY,{})]})}),(0,W.jsx)(UY,{control:C.control,name:`role`,render:({field:e})=>(0,W.jsxs)(GY,{children:[(0,W.jsx)(KY,{children:`Role`}),(0,W.jsx)(qY,{children:(0,W.jsxs)(Aw,{children:[(0,W.jsx)(jw,{asChild:!0,children:(0,W.jsx)(yYt,{aiProject:!!(n&&!r&&d.project&&yD(d.project)),value:e.value,onValueChange:e.onChange,hiddenRoles:a})}),(0,W.jsx)(Mw,{children:S?(0,W.jsx)(`p`,{children:`New users will be assigned the member role. You can change their role later.`}):(0,W.jsx)(`p`,{children:`New users will be assigned the admin role. You can change their role later.`})})]})}),(0,W.jsx)(YY,{})]})})]}),(0,W.jsx)(oT,{children:(0,W.jsx)(Y,{type:`submit`,className:`justify-end`,children:(0,W.jsxs)(CP,{loading:O.isPending,children:[h?`Send Invite`:`Add member`,(0,W.jsx)(_Ke,{className:`bg-white/20`,children:(0,W.jsx)(gKe,{onPress:C.handleSubmit(A),hotkey:`meta+Enter`})})]})})})]})})]})]})},kYt=()=>{let{account:e}=nm([`account`]);return e.entitlements.rbacEnabled?null:(0,W.jsxs)(sb,{variant:`info`,className:`text-sm`,children:[(0,W.jsx)(Gee,{size:22}),(0,W.jsx)(lb,{children:(0,W.jsxs)(`p`,{children:[`Role-based access control (RBAC) is not enabled for this account.`,` `,(0,W.jsx)(ub,{to:`mailto:${xb}?subject=Fine-grain%20access%20control`,children:`Contact sales`}),` `,`for more information.`]})})]})},AYt=({name:e,sub:t,email:n})=>{let{copyToClipboard:r,state:i}=zw(t??n??``);return(0,W.jsx)(Iw,{copied:i===`copied`,hint:(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ute,{size:16}),(0,W.jsxs)(X,{children:[`Sub `,(0,W.jsx)(Fw,{children:{sub:t}})]})]}),n&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(kte,{size:16}),(0,W.jsxs)(X,{children:[`Email `,(0,W.jsx)(Fw,{children:{email:n}})]})]})]}),children:(0,W.jsx)(`button`,{type:`button`,onDoubleClick:()=>{r()},className:`text-left`,children:e})})},jYt=r(a(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_plugin_relativeTime=r()})(e,(function(){return function(e,t,n){e||={};var r=t.prototype,i={future:`in %s`,past:`%s ago`,s:`a few seconds`,m:`a minute`,mm:`%d minutes`,h:`an hour`,hh:`%d hours`,d:`a day`,dd:`%d days`,M:`a month`,MM:`%d months`,y:`a year`,yy:`%d years`};function a(e,t,n,i){return r.fromToBase(e,t,n,i)}n.en.relativeTime=i,r.fromToBase=function(t,r,a,o,s){for(var c,l,u,d=a.$locale().relativeTime||i,f=e.thresholds||[{l:`s`,r:44,d:`second`},{l:`m`,r:89},{l:`mm`,r:44,d:`minute`},{l:`h`,r:89},{l:`hh`,r:21,d:`hour`},{l:`d`,r:35},{l:`dd`,r:25,d:`day`},{l:`M`,r:45},{l:`MM`,r:10,d:`month`},{l:`y`,r:17},{l:`yy`,d:`year`}],p=f.length,m=0;m<p;m+=1){var h=f[m];h.d&&(c=o?n(t).diff(a,h.d,!0):a.diff(t,h.d,!0));var g=(e.rounding||Math.round)(Math.abs(c));if(u=c>0,g<=h.r||!h.r){g<=1&&m>0&&(h=f[m-1]);var _=d[h.l];s&&(g=s(``+g)),l=typeof _==`string`?_.replace(`%d`,g):_(g,r,h.l,u);break}}if(r)return l;var v=u?d.future:d.past;return typeof v==`function`?v(l):v.replace(`%s`,l)},r.to=function(e,t){return a(e,t,this,!0)},r.from=function(e,t){return a(e,t,this)};var o=function(e){return e.$u?n.utc():n()};r.toNow=function(e){return this.to(o(this),e)},r.fromNow=function(e){return this.from(o(this),e)}}}))}))());function MYt({accountName:e,invite:t}){let n=em(),[r,i]=(0,U.useState)(!1),a=F_e();return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Y,{size:`icon`,variant:`ghost`,title:`Remove invitation`,disabled:a.isPending,onClick:()=>i(!0),children:(0,W.jsx)(zp,{size:18})}),(0,W.jsxs)(N$,{open:r,onOpenChange:i,title:`Delete account invite`,deleteButtonText:`Delete invitation`,isPending:a.isPending,onClickDelete:async()=>{try{await a.mutateAsync({accountName:e,inviteId:t.id}),n.success(`Invitation was removed`),i(!1)}catch(e){n.error(Fb(e))}},children:[`You are about to delete the account invite sent to `,t.email,`. The invitation can no longer be used to join your account.`]})]})}function NYt({accountName:e,invite:t}){let n=em(),r=I_e(),[i,a]=(0,U.useState)(!1);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Aw,{children:[(0,W.jsx)(jw,{asChild:!0,children:(0,W.jsx)(Y,{size:`icon`,variant:`ghost`,disabled:r.isPending,onClick:()=>a(!0),children:(0,W.jsx)(bte,{size:18})})}),(0,W.jsx)(Mw,{children:`Resend invitation`})]}),(0,W.jsx)(FP,{open:i,onOpenChange:a,title:`Do you want to resend the invitation?`,description:`You are about to resend the account membership invite for "${t.email}" to join "${e}".`,actionLabel:`Resend invitation`,isPending:r.isPending,onConfirm:async()=>{try{await r.mutateAsync({accountName:e,inviteId:t.id}),n.success(`Invitation has been resent`),a(!1)}catch(e){n.error(Fb(e)),a(!1)}}})]})}var PYt=({date:e,withTime:t})=>(0,W.jsxs)(`span`,{children:[e.toLocaleDateString(),t&&` ${e.toLocaleTimeString()}`]}),FYt=({email:e,className:t})=>{let{copyToClipboard:n,state:r}=zw(e);return(0,W.jsx)(Iw,{copied:r===`copied`,hint:(0,W.jsxs)(X,{children:[`Copy`,` `,(0,W.jsxs)(`span`,{className:`font-mono`,children:[`"`,(0,W.jsx)(Fw,{children:{email:e}}),`"`]}),` `,`to clipboard`]}),children:(0,W.jsx)(`button`,{type:`button`,onDoubleClick:()=>void n(),className:G(`cursor-pointer`,t),children:e})})};x7.default.extend(jYt.default);function IYt(){let{account:e}=Ab([`account`]),t=P_e(e).data??[];return t.length===0?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`text-lg font-medium`,children:`Pending account invitations`}),(0,W.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,children:t.map(t=>(0,W.jsxs)(L$,{variant:`outline`,size:`sm`,className:G(`col-span-full grid grid-cols-subgrid justify-between py-1`,(0,x7.default)().diff((0,x7.default)(t.createdOn),`minutes`)<5&&`bg-zuplo-50/50`),children:[(0,W.jsx)(`div`,{className:`text-ellipsis overflow-hidden truncate`,children:(0,W.jsxs)(Aw,{children:[(0,W.jsx)(jw,{children:(0,W.jsxs)(qT,{variant:`outline`,children:[`Invited `,(0,x7.default)(t.createdOn).fromNow()]})}),(0,W.jsx)(Mw,{children:(0,W.jsx)(PYt,{date:new Date(t.createdOn),withTime:!0})})]})}),(0,W.jsx)(FYt,{email:t.email,className:`text-left text-ellipsis overflow-hidden truncate`}),(0,W.jsxs)(`div`,{className:`flex justify-end col-span-2`,children:[(0,W.jsx)(NYt,{accountName:e,invite:t}),(0,W.jsx)(MYt,{accountName:e,invite:t})]})]},t.id))})]})}var LYt=5,RYt=`Members & Access`,zYt=(0,W.jsxs)(W.Fragment,{children:[`Manage who can access this project. Account members can create or be added to projects.`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/add-project-collaborators`,children:`Learn more`}),`.`]});function BYt(){let e=nm([`account`,`project`]),{canViewMembers:t,role:n,error:r}=gDe(e.account.name,e.project.name);return n?t?(0,W.jsx)(VYt,{}):(0,W.jsx)(`p`,{className:`p-6`,children:`You do not have access to project membership.`}):r?(0,W.jsxs)(`div`,{role:`alert`,className:`p-6 flex items-center gap-3`,children:[(0,W.jsx)(`p`,{children:`We couldn’t check your project access.`}),(0,W.jsx)(Y,{variant:`outline`,onClick:()=>window.location.reload(),children:`Reload to retry`})]}):(0,W.jsx)(`output`,{"aria-label":`Loading project access`,className:`p-6 flex justify-center items-center`,children:(0,W.jsx)(SP,{color:`primary`})})}function VYt(){let e=nm([`account`,`project`]),t=em(),{user:n}=N(),r=P(),i=I({mutationFn:({userId:t,role:n})=>r.fetch(V.auth.updateUsersRole({accountName:e.account.name,projectName:e.project.name,userId:t,role:n})),onError:e=>t.error(Fb(e))}),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),l=Ob(R.accountMemberInvites(e.account.name)),u=Ob(R.authProjectUsersRoles(e.account.name,e.project.name,{includeInheritedRoles:!1}),{extractData:!0}),d=u.data?.map(e=>e.id),f=Ob(R.authProjectUsersRoles(e.account.name,e.project.name,{includeInheritedRoles:!0}),{extractData:!0}),p=f.data?.filter(e=>!d?.includes(e.id)),m=u.data?.filter(e=>e.project.role!==`no-access`),h=e.account.entitlements.rbacEnabled,g=(m?.map(({id:e})=>e)??[]).concat(h?[]:p?.map(({id:e})=>e)??[]);return(0,W.jsxs)(N7,{title:RYt,description:zYt,action:(0,W.jsx)(OYt,{account:e.account.name,project:e.project.name,changeRoleForUserIds:f.data?.map(({id:e})=>e)??[],excludeUserIds:g,open:s,onOpenChange:c,description:`Inviting a user to a project will grant them access to the project and add them to the account as a member.`,children:(0,W.jsxs)(Y,{children:[(0,W.jsx)(Op,{size:16}),`Add to project`]})}),children:[(0,W.jsxs)(`section`,{className:`flex flex-col gap-3 text-sm`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Members with inherited access`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Account Admins and developers automatically have access to all projects.`})]}),(p?.length??0)>0&&(0,W.jsx)(lk,{className:`overflow-hidden`,children:p?.slice(0,a?void 0:LYt).map(e=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border-b px-4 py-3 last:border-0`,children:[(0,W.jsx)(AYt,{name:e.name,email:e.email}),(0,W.jsxs)(Aw,{children:[(0,W.jsx)(jw,{children:(0,W.jsx)(qT,{variant:`outline`,children:e.project.role===`admin`?`Full access`:`Read only`})}),(0,W.jsx)(Mw,{children:vYt[e.project.role]})]})]},e.id))}),(p?.length??0)>LYt&&(0,W.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>{o(!a)},children:a?`Show less`:`Show more`})]}),l.data?.length>0&&(0,W.jsx)(IYt,{}),(0,W.jsxs)(`section`,{className:`flex flex-col gap-3 text-sm`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Members with project access`}),(0,W.jsx)(ck,{error:u.error}),i.isError&&(0,W.jsx)(kYt,{}),m?.length===0&&(0,W.jsx)(lk,{children:(0,W.jsxs)(db,{children:[(0,W.jsxs)(fb,{children:[(0,W.jsx)(pb,{variant:`icon`,children:(0,W.jsx)(Vp,{})}),(0,W.jsx)(mb,{children:`No project members yet`}),(0,W.jsx)(hb,{children:`No members have been added directly to this project yet.`})]}),(0,W.jsx)(gb,{children:(0,W.jsxs)(Y,{onClick:()=>c(!0),children:[(0,W.jsx)(Op,{size:16}),`Add to project`]})})]})}),(m?.length??0)>0&&(0,W.jsxs)(lk,{className:`grid grid-cols-[1fr_auto_auto] gap-x-4 overflow-hidden text-sm`,children:[(0,W.jsxs)(Xqt,{children:[(0,W.jsx)(`div`,{children:`Member`}),(0,W.jsx)(`div`,{children:`Role`}),(0,W.jsx)(`div`,{})]}),!u.isError&&m?.map(t=>(0,W.jsxs)(Yqt,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(AYt,{name:t.name,sub:t.sub}),t.sub===n?.sub&&(0,W.jsx)(qT,{variant:`outline`,className:`ml-4`,children:`You`})]}),(0,W.jsx)(`div`,{className:G(`text-ellipsis overflow-hidden truncate`,t.email===t.name&&`hidden`),title:t.email,children:t.email})]}),(0,W.jsx)(`div`,{className:`max-w-60 w-full`,children:(0,W.jsx)(yYt,{aiProject:yD(e.project),hiddenRoles:e.account.entitlements.rbacEnabled?[]:[`member`,`developer`],value:t.project.role,disabled:!!(t.sub===n?.sub||i.isPending),onValueChange:e=>{if(!Rw.includes(e))throw Error(`Invalid role`);i.mutate({userId:t.id,role:e})}})}),(0,W.jsx)(`div`,{className:`flex justify-end`,children:(0,W.jsx)(Y,{variant:`ghost`,size:`icon-lg`,onClick:()=>{i.mutate({role:`no-access`,userId:t.id})},children:(0,W.jsx)(zp,{size:16})})})]},t.sub))]})]})]})}cF(`div`,`grid grid-cols-subgrid col-span-full w-full border-b px-4 py-3 items-center`);var HYt=({accountName:e,projectName:t,sourceRepoUrl:n,defaultBranch:r})=>{let{logEvent:i,captureException:a}=H(),[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(r),[u,d]=(0,U.useState)(!1),f=EAe(e,t);(0,U.useEffect)(()=>{u||(s(``),l(r))},[u,r]);let p=n.split(`/`),m=p[p.length-2],h=p[p.length-1],g=async()=>{try{if(s(``),!c||c===r){s(`Select a new default branch.`);return}await f.mutateAsync({defaultBranch:c,sourceRepoUrl:n}),i(`project-update-default-branch-success`,{account:e}),d(!1)}catch(t){a(t);let n=Fb(t);s(n),i(`project-update-default-branch-failed`,{account:e,errorMessage:n})}};return(0,W.jsxs)(lk,{children:[(0,W.jsx)(uk,{children:`Default Branch`}),(0,W.jsxs)(pk,{className:`mt-1 text-sm`,children:[(0,W.jsx)(fk,{children:`The default branch is considered the “base” branch in your repository, against which all pull requests and code commits are automatically made. This is the branch used for your project's production deployments.`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(nE,{type:`text`,autoComplete:`off`,id:`default-branch-field`,value:r??`main`,disabled:!0,className:`max-w-52`,"data-test":`default-branch-field`}),(0,W.jsxs)(tT,{onOpenChange:e=>d(e),open:u,children:[(0,W.jsx)(nT,{children:(0,W.jsx)(Y,{type:`button`,"data-test":`update-default-branch`,variant:`outline`,children:`Update`})}),(0,W.jsxs)(iT,{children:[(0,W.jsx)(aT,{children:(0,W.jsx)(sT,{children:`Switch default branch to another branch`})}),(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(ck,{error:o}),(0,W.jsxs)(cT,{className:`text-foreground`,children:[`Choose another branch in`,` `,(0,W.jsxs)(tE,{href:n,children:[m,`/`,h]}),` `,`to use as the default branch of the project instead of`,` `,r,`.`,(0,W.jsx)(nE,{type:`text`,autoComplete:`off`,placeholder:`Type a branch name`,id:`default-branch-field`,className:`mt-4`,"data-test":`default-branch-field`,value:c,onChange:e=>l(e.target.value)})]})]}),(0,W.jsxs)(oT,{children:[(0,W.jsx)(rT,{children:(0,W.jsx)(Y,{"data-test":`cancel-update-default-branch-btn`,disabled:f.isPending,variant:`ghost`,children:`Cancel`})}),(0,W.jsx)(Y,{"data-test":`update-default-branch-btn`,type:`button`,onClick:g,disabled:f.isPending,variant:`outline`,children:(0,W.jsx)(CP,{loading:f.isPending,alternative:`Updating...`,children:`Switch branch`})})]})]})]})]})]})]})},UYt=`Source Control`,WYt=(0,W.jsxs)(W.Fragment,{children:[`Connect a Git repository to deploy your project. Learn more about deploying with source control in our`,` `,(0,W.jsx)(tE,{href:`https://zuplo.com/docs/articles/step-4-deploying-to-the-edge`,showIcon:!0,children:`documentation`}),`.`]}),GYt=()=>{let e=nm([`account`,`project`]),{logEvent:t}=H(),n=Aqt();if((0,U.useEffect)(()=>{t(`source-control-settings-viewed`,{account:e.account.name,project:e.project.name})},[e.account.name,e.project.name,t]),!n.data)return(0,W.jsx)(N7,{title:UYt,description:WYt,children:(0,W.jsx)(nqt,{showHeader:!1})});let r=M_e(e.account.name,n.data);return(0,W.jsxs)(N7,{title:UYt,description:WYt,children:[e.project.sourceRepoUrl!==null&&(0,W.jsx)(HYt,{accountName:e.account.name,projectName:e.project.name,sourceRepoUrl:e.project.sourceRepoUrl,defaultBranch:e.project.defaultBranch??void 0}),(0,W.jsxs)(lk,{children:[(0,W.jsxs)(uk,{children:[(0,W.jsx)(dk,{children:`Connected Git Repository`}),(0,W.jsx)(fk,{children:`Seamlessly create Environments for every branch and deployments for any commits pushed to your Git repository.`})]}),(0,W.jsx)(pk,{children:(0,W.jsx)(kqt,{account:e.account,project:e.project,sourceControlConfig:r})})]})]})},KYt=e=>e.sourceRepoUrl!=null||ENe(e),qYt=()=>{let{account:e,project:t}=Ab([`account`,`project`]);return(0,W.jsx)(Bc,{to:fo(Cb.Environments,{account:e,project:t})})},JYt=({to:e})=>(0,W.jsx)(Bc,{to:`/accounts/${nm([`account`]).account.name}/settings/${e}`,replace:!0}),YYt=[{key:`general`,group:`project`,icon:(0,W.jsx)(Fp,{className:`w-4 h-4`}),name:`General`,view:(0,W.jsx)(_Yt,{}),testID:`settings-general`},{key:`share-project`,group:`project`,icon:(0,W.jsx)(Vp,{className:`w-4 h-4`}),name:`Members & Access`,view:(0,W.jsx)(BYt,{}),testID:`settings-share-project`},{key:`source-control-settings`,group:`project`,icon:(0,W.jsx)(hte,{className:`w-4 h-4`}),name:`Source Control`,view:(0,W.jsx)(GYt,{}),testID:`settings-source-control-settings`},{key:`environment-variables`,group:`configuration`,icon:(0,W.jsx)($te,{className:`w-4 h-4`}),name:`Environment Variables`,view:(0,W.jsx)(fYt,{}),testID:`settings-environment-variables`},{key:`custom-domain`,group:`configuration`,icon:(0,W.jsx)(Cte,{className:`w-4 h-4`}),name:`Custom Domains`,view:(0,W.jsx)(aYt,{}),testID:`settings-custom-domain`},{key:`ai-providers`,group:`configuration`,icon:(0,W.jsx)(Gf,{className:`w-4 h-4`}),name:`AI Gateway`,view:(0,W.jsx)(hJt,{}),testID:`settings-ai-providers`},{key:`upgrade-billing`,group:`account`,icon:(0,W.jsx)(Gee,{className:`w-4 h-4`}),name:`Billing`,view:(0,W.jsx)(JYt,{to:`upgrade-billing`}),outbound:!0,testID:`settings-upgrade-billing`},{key:`zuplo-api-keys`,group:`account`,icon:(0,W.jsx)(Sp,{className:`w-4 h-4`}),name:`Zuplo API Keys`,view:(0,W.jsx)(JYt,{to:`api-keys`}),outbound:!0,testID:`settings-zuplo-api-keys`},{key:`api-key-consumers`,group:`configuration`,icon:(0,W.jsx)(Sp,{className:`w-4 h-4`}),name:`API Key Consumers`,view:(0,W.jsx)(()=>{let e=nm([`account`,`project`]);return(0,W.jsx)(Bc,{to:fo(Cb.ProjectServices,{account:e.account.name,project:e.project.name}),replace:!0})},{}),hidden:!0},{key:`environments`,group:`account`,icon:(0,W.jsx)(Fp,{className:`w-4 h-4`}),name:`Environments`,view:(0,W.jsx)(qYt,{}),hidden:!0}];function XYt({project:e,hideEnvironmentVariables:t}){return YYt.filter(n=>n.hidden?!1:n.key===`ai-providers`?yD(e):n.key===`source-control-settings`?!yD(e)||KYt(e):n.key===`environment-variables`?!t:!0)}var ZYt=({account:e,project:t,environment:n,navigateTo:r})=>{let{data:i}=bAe(e??``,t);return!e||!t||!n?null:(0,W.jsx)(pT,{heading:`Settings`,children:XYt({project:i??{productType:`standard`},hideEnvironmentVariables:!1}).map(n=>(0,W.jsxs)(mT,{onSelect:()=>r(fo(`${Cb.Settings}/${n.key}`,{account:e,project:t})),children:[n.icon,(0,W.jsx)(`span`,{className:`ml-3`,children:n.name})]},n.key))})},QYt={GET:`bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950 dark:text-emerald-300 dark:border-emerald-800`,POST:`bg-sky-50 text-sky-700 border-sky-200 dark:bg-sky-950 dark:text-sky-300 dark:border-sky-800`,PUT:`bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-950 dark:text-amber-300 dark:border-amber-800`,PATCH:`bg-orange-50 text-orange-700 border-orange-200 dark:bg-orange-950 dark:text-orange-300 dark:border-orange-800`,DELETE:`bg-red-50 text-red-700 border-red-200 dark:bg-red-950 dark:text-red-300 dark:border-red-800`},$Yt=({account:e,project:t,environment:n,navigateTo:r})=>{let i=qP(e,t).data?.find(e=>e.urlParameter===n)?.name,a=Kft(i??``,{enabled:i!==void 0}).data?.model;if(!a||a.routes.length===0)return null;let o=new Map(a.handlers.map(e=>[e.key,e])),s=fo(Cb.Code,{account:e,project:t,environment:n}),c=e=>`${s}?path=${encodeURIComponent(e.filePath)}${e.operationId?`&operation=${encodeURIComponent(e.operationId)}`:``}`;return(0,W.jsx)(pT,{heading:`Routes`,children:a.routes.map(e=>{let t=e.handlerKey?o.get(e.handlerKey):void 0;return(0,W.jsxs)(mT,{value:e.id,keywords:[`${e.method} ${e.path}`,...[e.operationId,e.summary,t?.name].filter(e=>!!e),...e.inboundPolicies,...e.outboundPolicies],onSelect:()=>r(c(e)),className:`gap-2`,children:[(0,W.jsx)(`span`,{className:G(`w-14 shrink-0 rounded-sm border px-1 py-0.5 text-center font-mono text-[10px] font-semibold uppercase leading-4`,QYt[e.method]??`bg-neutral-50 text-neutral-600 border-neutral-200 dark:bg-neutral-900 dark:text-neutral-300 dark:border-neutral-700`),children:e.method}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:e.path}),e.summary&&(0,W.jsx)(`span`,{className:`ml-auto truncate pl-3 text-xs text-muted-foreground`,children:e.summary})]},e.id)})})},U7=({path:e,children:t,navigateTo:n,...r})=>(0,W.jsxs)(mT,{onSelect:()=>n(fo(e,r)),children:[(0,W.jsx)(`div`,{className:`mr-2`,children:t??(0,W.jsx)(Nf,{className:` h-4 w-4`})}),(0,W.jsx)(`span`,{children:Object.entries(Cb).find(([,t])=>t===e)?.at(0)})]}),eXt=({account:e,navigateTo:t})=>{let{isAiUser:n,isLoading:r}=vDe(e);return n||r?null:(0,W.jsx)(U7,{path:Cb.AccountSettings,navigateTo:t,account:e,children:(0,W.jsx)(Jte,{})})};function tXt(){let{isAuthenticated:e}=N(),t=Fqt(),{account:n,project:r,environment:i}=fc(),a=lc(),o=n&&r&&i,s={account:n,project:r,environment:i},[c,l]=(0,U.useState)(``),u=(0,U.useRef)(null),d=e=>{l(e),u.current?.scrollTo({top:0})},f=Ib({enabled:e});yAe(e?f.data?.map(e=>e.name)??[]:[]);let[p,m]=(0,U.useState)(!1);fF(`meta+k`,()=>{m(!0)});let h=e=>{m(e),e||l(``)},g=e=>{a(e),h(!1)};return(0,W.jsxs)(sOe,{open:p,onOpenChange:h,filter:Vqt,children:[(0,W.jsx)(uT,{placeholder:`What do you want to do?`,onValueChange:d}),(0,W.jsxs)(dT,{ref:u,children:[(0,W.jsx)(fT,{children:(0,W.jsxs)(`div`,{className:`text-muted-foreground my-3`,children:[`No results found "`,c,`".`]})}),o&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)($Yt,{navigateTo:g,account:n,project:r,environment:i}),(0,W.jsx)(Uqt,{navigateTo:g,account:n,project:r,environment:i})]}),n&&r&&i&&(0,W.jsx)(ZYt,{navigateTo:g,...s}),e&&(0,W.jsx)(Rqt,{navigateTo:g,accounts:f.data,search:c}),(0,W.jsxs)(pT,{title:t.shortName,children:[(0,W.jsx)(U7,{path:Cb.Profile,navigateTo:g,children:(0,W.jsx)(ine,{})}),(0,W.jsx)(U7,{path:Cb.Logout,navigateTo:g,children:(0,W.jsx)(Ote,{})}),n&&r&&(0,W.jsx)(U7,{path:Cb.Settings,navigateTo:g,account:n,project:r,children:(0,W.jsx)(Jte,{})}),n&&e&&(0,W.jsx)(eXt,{account:n,navigateTo:g})]}),(0,W.jsx)(Hqt,{query:c,onSelected:()=>h(!1)})]})]})}var nXt=Date.now(),rXt=300*1e3,iXt=14400*1e3,aXt=1440*60*1e3,oXt=async e=>{try{let t=await fetch(e,{method:`HEAD`,cache:`no-cache`});if(!t.ok)return!1;let n=t.headers.get(`date`),r=t.headers.get(`last-modified`);if(!n||!r)return!1;let i=new Date(n).getTime(),a=new Date(r).getTime();if(Number.isNaN(i)||Number.isNaN(a))return!1;let o=i-a>=aXt;return a>nXt&&i>nXt&&o}catch{return!1}},sXt=({enabled:e})=>{let t=(0,U.useRef)(0),n=re(),{data:r}=je({enabled:e,refetchInterval:rXt,refetchIntervalInBackground:!1,networkMode:`online`,retry:!1,queryFn:async()=>{let e=await oXt(window.location.href),r=Date.now();return e&&r-t.current>=iXt?(t.current=r,n.capture(`show-update-toast`),!0):!1},queryKey:[`update-check`]});return(0,W.jsxs)(Jp,{open:r??!1,duration:1/0,children:[(0,W.jsxs)(qp,{children:[(0,W.jsx)(Zp,{children:`Update available`}),(0,W.jsx)(Qp,{children:`A new version of the Zuplo Portal is available. Click to reload.`})]}),(0,W.jsx)(Yp,{altText:`Reload`,children:(0,W.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:`Reload`})}),(0,W.jsx)(Xp,{})]})},cXt=e=>e.handle?.preserveScroll===!0,lXt=(e,t)=>{for(let t=e.length-1;t>=0;t--)if(!cXt(e[t]))return e[t].pathname;return t},uXt=`[data-scroll-reset]`,W7=()=>Array.from(document.querySelectorAll(uXt)),dXt=e=>{if(!e)return!1;try{let t=document.getElementById(decodeURIComponent(e.slice(1)));return t?.scrollIntoView(),t!==null}catch{return!1}},fXt=e=>{let t=W7(),n=0,r=()=>{let i=!0;t.forEach((t,n)=>{let r=e[n]??0;t.scrollTop=r,Math.abs(t.scrollTop-r)>1&&(i=!1)}),!i&&++n<30&&requestAnimationFrame(r)};r()};function pXt(){let{key:e,pathname:t,hash:n}=ac(),r=oc(),i=lXt(Ec(),t),a=(0,U.useRef)(i),o=(0,U.useRef)(e),s=(0,U.useRef)(new Map);return(0,U.useEffect)(()=>{let e=e=>{e.target instanceof Element&&e.target.matches(uXt)&&s.current.set(o.current,W7().map(e=>e.scrollTop))};return document.addEventListener(`scroll`,e,{capture:!0,passive:!0}),()=>document.removeEventListener(`scroll`,e,{capture:!0})},[]),(0,U.useLayoutEffect)(()=>{let t=a.current!==i;if(a.current=i,o.current=e,t&&r===`POP`)fXt(s.current.get(e)??[]);else if(t&&!dXt(n)){window.scrollTo(0,0);for(let e of W7())e.scrollTop=0}s.current.has(e)||s.current.set(e,W7().map(e=>e.scrollTop))},[e,i,n,r]),null}var mXt=({enableUpdateNotifications:e})=>(0,W.jsx)(Ovt,{children:(0,W.jsxs)(Gp,{children:[(0,W.jsx)(pXt,{}),(0,W.jsx)(sXt,{enabled:e}),(0,W.jsx)(tXt,{}),(0,W.jsx)(cne,{}),(0,W.jsx)(Vc,{}),(0,W.jsx)(Kp,{})]})});function hXt(){return(0,W.jsx)(`div`,{className:`m-auto`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 my-5`,children:[(0,W.jsx)(`div`,{children:(0,W.jsx)(qT,{variant:`outline`,children:`404`})}),(0,W.jsx)(`span`,{className:`text-2xl font-medium`,children:`Oops! Page not found.`}),(0,W.jsx)(`span`,{children:`Sorry, we could not find the page you were looking for.`}),(0,W.jsx)(`div`,{className:`h-2`}),(0,W.jsx)(Bpt,{hasGoHome:!0})]})})}var gXt=()=>{let{environment:e}=Ab([`environment`]),[t,n]=(0,U.useState)(null),r=cm(e=>e.updateFile),i=cm(e=>e.filesByPath);return{conflict:t,checkForConflictsBeforeSave:(0,U.useCallback)(async(t,r)=>{let a=i[t];try{let i=await ru(e,t);return a.lastModified&&i.lastModified&&i.lastModified>a.lastModified?(Ye.warn(`File ${t} was modified on disk. Showing conflict dialog before save.`),new Promise(e=>{n({filePath:t,localContent:a.content??``,remoteContent:i.content??``,remoteLastModified:i.lastModified,onProceed:async()=>{await r(),e(!0)}})})):(await r(),!0)}catch(e){return Ye.error(`Error checking for conflicts`,{error:e}),await r(),!0}},[e,i]),showConflict:(0,U.useCallback)(e=>{Ye.info(`Showing conflict dialog for ${e.filePath}`),n(e)},[]),resolveConflict:(0,U.useCallback)(async a=>{if(!t)return;let o=i[t.filePath];if(!o){n(null);return}if(a===`remote`)r({...o,content:t.remoteContent,lastModified:t.remoteLastModified,saveState:eu.unmodified}),Ye.info(`Using disk version for ${t.filePath}, canceling save`),n(null);else if(Ye.info(`User chose local version for ${t.filePath}${t.onProceed?`, proceeding with save`:`, saving to disk`}`),t.onProceed)await t.onProceed(),n(null);else try{await au(e,{path:o.path,content:o.content},{forceSave:!0});let i=await ru(e,t.filePath);r({...o,lastModified:i.lastModified,saveState:eu.unmodified}),Ye.info(`Successfully saved local version for ${t.filePath}`),n(null)}catch(e){Ye.error(`Error saving local version for ${t.filePath}`,{error:e}),r({...o,saveState:eu.modified})}},[t,i,r,e]),cancelConflict:(0,U.useCallback)(async()=>{if(!t)return;let a=i[t.filePath];if(a){let n=await ru(e,t.filePath);r({...a,lastModified:n.lastModified,saveState:eu.modified}),Ye.info(`Conflict dialog canceled for ${t.filePath}, file marked as modified`)}n(null)},[t,i,r,e])}};function _Xt({open:e,filePath:t,localContent:n,remoteContent:r,onResolve:i,onCancel:a}){let[o,s]=(0,U.useState)(`local`),c=_X(t);return(0,W.jsx)(tT,{open:e,onOpenChange:e=>!e&&a(),children:(0,W.jsxs)(iT,{className:`max-w-7xl max-h-[90vh] p-0`,showCloseButton:!1,children:[(0,W.jsx)(`div`,{className:`p-6 pb-0`,children:(0,W.jsxs)(aT,{children:[(0,W.jsx)(sT,{className:`text-lg font-semibold text-left mb-1`,children:`File Conflict Detected`}),(0,W.jsxs)(`p`,{className:`text-sm text-muted-foreground text-left`,children:[(0,W.jsx)(`span`,{className:`font-mono font-semibold`,children:t}),` has been modified both locally and on disk`]})]})}),(0,W.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col px-6`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex flex-col py-3 cursor-pointer transition-all border-t-4 border-x ${o===`local`?`border-t-pink-500 border-x-pink-200 bg-pink-50`:`border-t-border border-x-border bg-gray-50 dark:bg-neutral-900 hover:bg-gray-100 dark:hover:bg-neutral-800`}`,style:{paddingLeft:`26px`,paddingRight:`24px`},onClick:()=>s(`local`),"aria-pressed":o===`local`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-sm`,children:`Browser Version`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Current editor content`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`flex flex-col px-6 py-3 cursor-pointer transition-all border-t-4 border-x ${o===`remote`?`border-t-pink-500 border-x-pink-200 bg-pink-50`:`border-t-border border-x-border bg-gray-50 dark:bg-neutral-900 hover:bg-gray-100 dark:hover:bg-neutral-800`}`,onClick:()=>s(`remote`),"aria-pressed":o===`remote`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-sm`,children:`Disk Version`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`File on disk`})]})]}),(0,W.jsx)(`div`,{className:`border border-t-0 overflow-hidden shadow-xs flex-1 min-h-[55vh]`,children:(0,W.jsx)(UUe,{original:n,modified:r,language:c,options:{readOnly:!0,renderSideBySide:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,wordWrap:`off`}})})]}),(0,W.jsxs)(oT,{className:`px-6 pb-6 flex-row justify-between items-center`,children:[(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o===`local`?(0,W.jsx)(W.Fragment,{children:`Browser version will be saved to disk`}):(0,W.jsx)(W.Fragment,{children:`Disk version will replace browser content`})}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(Y,{variant:`ghost`,onClick:a,children:`Cancel`}),(0,W.jsxs)(Y,{variant:`default`,onClick:()=>i(o),children:[`Apply `,o===`local`?`Browser`:`Disk`,` Version`]})]})]})]})})}function vXt(){let{environment:e}=Ab([`environment`]),{conflict:t,showConflict:n,resolveConflict:r,cancelConflict:i}=gXt(),a=cm(e=>e.filesByPath),o=cm(e=>e.saveConflictPath),s=cm(e=>e.clearSaveConflict);return(0,U.useEffect)(()=>{if(o){Ye.info(`Save conflict detected for ${o}`);let t=a[o];t?ru(e,o).then(e=>{n({filePath:o,localContent:t.content??``,remoteContent:e.content??``,remoteLastModified:e.lastModified})}).catch(e=>{Ye.error(`Error fetching file for conflict dialog`,{error:e})}):Ye.warn(`No file model found for ${o}`),s()}},[o,a,s,n,e]),t?(0,W.jsx)(_Xt,{open:!0,filePath:t.filePath,localContent:t.localContent,remoteContent:t.remoteContent,onResolve:r,onCancel:i}):null}var yXt=()=>{let e=nm(),{monaco:t,reloadFiles:n}=v7(),r=lF(n.execute),i=e.environment.name,{error:a}=je({queryKey:[`reloadFiles`,e.account.name,e.project.name,i],queryFn:async()=>{try{return await r.current({accountName:e.account.name,projectName:e.project.name,environmentName:e.environment.name}),!0}catch(e){throw Ye.error(`Failed to reload files`,{error:e}),e}},refetchOnWindowFocus:!1,enabled:!!t&&!!i,retry:3,retryDelay:e=>Math.min(1e3*2**e,3e4)});return a?(0,W.jsx)(`div`,{className:`flex items-center justify-center h-full bg-gray-50`,children:(0,W.jsxs)(`div`,{className:`text-center p-8 max-w-lg`,children:[(0,W.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:`Failed to Load Files`}),(0,W.jsx)(`p`,{className:`text-gray-600 mb-4`,children:`Unable to load project files from the local server. Please check that the dev server is running and try again.`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`px-4 py-2 bg-blue-600 text-white rounded-sm hover:bg-blue-700`,children:`Retry`})]})}):null},bXt=()=>{let{account:e,project:t}=Ab([`account`,`project`]),n=cm(e=>e.resetStore);return(0,U.useEffect)(()=>{n()},[t,e,n]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(yXt,{}),(0,W.jsx)(vXt,{}),(0,W.jsx)(WGt,{}),(0,W.jsx)(Vc,{})]})};U.createContext({en:{translations:{archiveNotification:`Archive this notification`,archiveRead:`Archive Read`,markAllAsRead:`Mark all as read`,notifications:`Notifications`,emptyFeedTitle:`No notifications yet`,emptyFeedBody:`We'll let you know when we've got something new for you.`,all:`All`,unread:`Unread`,read:`Read`,unseen:`Unseen`,msTeamsChannelSetError:`Error setting channel.`,msTeamsConnect:`Connect to Microsoft Teams`,msTeamsConnected:`Connected`,msTeamsConnecting:`Connecting to Microsoft Teams…`,msTeamsConnectionErrorExists:`Try reconnecting to Microsoft Teams to find and select channels from your teams.`,msTeamsConnectionErrorOccurred:`There was an error connecting to Microsoft Teams. Try reconnecting to find and select channels from your teams.`,msTeamsConnectContainerDescription:`Connect to get notifications in Microsoft Teams`,msTeamsDisconnect:`Disconnect`,msTeamsDisconnecting:`Disconnecting from Microsoft Teams…`,msTeamsError:`Error`,msTeamsReconnect:`Reconnect`,msTeamsTenantIdNotSet:`Microsoft Teams tenant ID not set.`,slackConnectChannel:`Connect channel`,slackChannelId:`Slack channel ID`,slackConnecting:`Connecting to Slack...`,slackDisconnecting:`Disconnecting...`,slackConnect:`Connect to Slack`,slackConnected:`Connected`,slackConnectContainerDescription:`Connect to get notifications in your Slack workspace.`,slackSearchbarDisconnected:`Slack is not connected.`,slackSearchbarNoChannelsConnected:`Search channels`,slackSearchbarNoChannelsFound:`No slack channels.`,slackSearchbarChannelsError:`Error fetching channels.`,slackSearchChannels:`Search channels`,slackConnectionErrorExists:`Try reconnecting to Slack to find and select channels from your workspace.`,slackConnectionErrorOccurred:`There was an error connecting to Slack. Try reconnecting to find and select channels from your workspace.`,slackChannelAlreadyConnected:`Error: already connected`,slackError:`Error`,slackDisconnect:`Disconnect`,slackChannelSetError:`Error setting channel.`,slackAccessTokenNotSet:`Access token not set.`,slackReconnect:`Reconnect`},locale:`en`},de:{translations:{archiveNotification:`Benachrichtigung archivieren`,archiveRead:`Gelesenes Archivieren`,markAllAsRead:`Alle als gelesen markieren`,notifications:`Benachrichtigungen`,emptyFeedTitle:`Noch keine Benachrichtigungen`,emptyFeedBody:`Wir werden dich benachrichtigen, sobald wir etwas Neues für dich haben.`,all:`Alle`,unread:`Ungelesen`,read:`Gelesen`,unseen:`Ungesehen`,slackConnectChannel:`Kanal verbinden`,slackChannelId:`Slack Kanal ID`,slackConnecting:`Verbinden mit Slack...`,slackDisconnecting:`Trennen der Verbindung...`,slackConnect:`Mit Slack verbinden`,slackConnected:`Verbunden`,slackConnectContainerDescription:`Verbinden, um Benachrichtigungen in Ihrem Slack-Arbeitsbereich zu erhalten.`,slackSearchbarDisconnected:`Slack ist nicht verbunden.`,slackSearchbarNoChannelsConnected:`Suchkanäle`,slackSearchbarNoChannelsFound:`Keine schlaffen Kanäle.`,slackSearchbarChannelsError:`Fehler beim Abrufen von Kanälen.`,slackSearchChannels:`Suchkanäle`,slackConnectionErrorExists:`Versuchen Sie, sich erneut mit Slack zu verbinden, um Kanäle in Ihrem Arbeitsbereich zu finden und auszuwählen.`,slackConnectionErrorOccurred:`Es ist ein Fehler beim Verbinden mit Slack aufgetreten. Versuchen Sie, sich erneut zu verbinden, um Kanäle in Ihrem Arbeitsbereich zu finden und auszuwählen.`,slackChannelAlreadyConnected:`Fehler: bereits verbunden`,slackError:`Fehler`,slackDisconnect:`Trennen Sie die Verbindung.`,slackChannelSetError:`Fehlereinstellung Kanal.`,slackAccessTokenNotSet:`Zugriffstoken nicht gesetzt.`,slackReconnect:`Neu verbinden`},locale:`de`}}.en),a(((e,t)=>{(function(n){var r=Object.hasOwnProperty,i=Array.isArray?Array.isArray:function(e){return Object.prototype.toString.call(e)===`[object Array]`},a=10,o=typeof process==`object`&&typeof process.nextTick==`function`,s=typeof Symbol==`function`,c=typeof Reflect==`object`,l=typeof setImmediate==`function`?setImmediate:setTimeout,u=s?c&&typeof Reflect.ownKeys==`function`?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function d(){this._events={},this._conf&&f.call(this,this._conf)}function f(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==n&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function p(e,t){var n=`(node) warning: possible EventEmitter memory leak detected. `+e+` listeners added. Use emitter.setMaxListeners() to increase limit.`;if(this.verboseMemoryLeak&&(n+=` Event name: `+t+`.`),typeof process<`u`&&process.emitWarning){var r=Error(n);r.name=`MaxListenersExceededWarning`,r.emitter=this,r.count=e,process.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var m=function(e,t,n){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,n];default:for(var i=Array(r);r--;)i[r]=arguments[r];return i}};function h(e,t){for(var r={},i,a=e.length,o=t?t.length:0,s=0;s<a;s++)i=e[s],r[i]=s<o?t[s]:n;return r}function g(e,t,n){this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0;var r,i;if((n.on||n.off)&&(r=n.on,i=n.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error(`target does not implement any known event API`);if(typeof r!=`function`)throw TypeError(`on method must be a function`);if(typeof i!=`function`)throw TypeError(`off method must be a function`);this._on=r,this._off=i;var a=e._observers;a?a.push(this):e._observers=[this]}Object.assign(g.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,a=this._emitter,o=this._listeners,s=function(){var r=m.apply(null,arguments),o={data:r,name:t,original:e};if(n){n.call(i,o)!==!1&&a.emit.apply(a,[o.name].concat(r));return}a.emit.apply(a,[t].concat(r))};if(o[e])throw Error(`Event '`+e+`' is already listening`);this._listenersCount++,a._newListener&&a._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&o[e]===null&&(o[e]=s,r._on.call(i,e,s))},a.on(`newListener`,this._onNewListener),this._onRemoveListener=function(n){n===t&&!a.hasListeners(n)&&o[e]&&(o[e]=null,r._off.call(i,e,s))},o[e]=null,a.on(`removeListener`,this._onRemoveListener)):(o[e]=s,r._on.call(i,e,s))},unsubscribe:function(e){var t=this,n=this._listeners,r=this._emitter,i,a,o=this._off,s=this._target,c;if(e&&typeof e!=`string`)throw TypeError(`event must be a string`);function l(){t._onNewListener&&(r.off(`newListener`,t._onNewListener),r.off(`removeListener`,t._onRemoveListener),t._onNewListener=null,t._onRemoveListener=null);var e=C.call(r,t);r._observers.splice(e,1)}if(e){if(i=n[e],!i)return;o.call(s,e,i),delete n[e],--this._listenersCount||l()}else{for(a=u(n),c=a.length;c-- >0;)e=a[c],o.call(s,e,n[e]);this._listeners={},this._listenersCount=0,l()}}});function _(e,t,i,a){var o=Object.assign({},t);if(!e)return o;if(typeof e!=`object`)throw TypeError(`options must be an object`);var s=Object.keys(e),c=s.length,l,u,d;function f(e){throw Error(`Invalid "`+l+`" option value`+(e?`. Reason: `+e:``))}for(var p=0;p<c;p++){if(l=s[p],!a&&!r.call(t,l))throw Error(`Unknown "`+l+`" option`);u=e[l],u!==n&&(d=i[l],o[l]=d?d(u,f):u)}return o}function v(e,t){return(typeof e!=`function`||!e.hasOwnProperty(`prototype`))&&t(`value must be a constructor`),e}function y(e){var t=`value must be type of `+e.join(`|`),n=e.length,r=e[0],i=e[1];return n===1?function(e,n){if(typeof e===r)return e;n(t)}:n===2?function(e,n){var a=typeof e;if(a===r||a===i)return e;n(t)}:function(r,i){for(var a=typeof r,o=n;o-- >0;)if(a===e[o])return r;i(t)}}var b=y([`function`]),x=y([`object`,`function`]);function S(e,t,n){var r,i,a=0,o,s=new e(function(c,l,u){n=_(n,{timeout:0,overload:!1},{timeout:function(e,t){return e*=1,(typeof e!=`number`||e<0||!Number.isFinite(e))&&t(`timeout must be a positive number`),e}}),r=!n.overload&&typeof e.prototype.cancel==`function`&&typeof u==`function`;function d(){i&&=null,a&&=(clearTimeout(a),0)}var f=function(e){d(),c(e)},p=function(e){d(),l(e)};r?t(f,p,u):(i=[function(e){p(e||Error(`canceled`))}],t(f,p,function(e){if(o)throw Error(`Unable to subscribe on cancel event asynchronously`);if(typeof e!=`function`)throw TypeError(`onCancel callback must be a function`);i.push(e)}),o=!0),n.timeout>0&&(a=setTimeout(function(){var e=Error(`timeout`);e.code=`ETIMEDOUT`,a=0,s.cancel(e),l(e)},n.timeout))});return r||(s.cancel=function(e){if(i){for(var t=i.length,n=1;n<t;n++)i[n](e);i[0](e),i=null}}),s}function C(e){var t=this._observers;if(!t)return-1;for(var n=t.length,r=0;r<n;r++)if(t[r]._target===e)return r;return-1}function w(e,t,n,r,i){if(!n)return null;if(r===0){var a=typeof t;if(a===`string`){var o,s,c=0,l=0,d=this.delimiter,f=d.length;if((s=t.indexOf(d))!==-1){o=[,,,,,];do o[c++]=t.slice(l,s),l=s+f;while((s=t.indexOf(d,l))!==-1);o[c++]=t.slice(l),t=o,i=c}else t=[t],i=1}else a===`object`?i=t.length:(t=[t],i=1)}var p=null,m,h,g,_,v,y=t[r],b=t[r+1],x,S;if(r===i)n._listeners&&(typeof n._listeners==`function`?(e&&e.push(n._listeners),p=[n]):(e&&e.push.apply(e,n._listeners),p=[n]));else if(y===`*`){for(x=u(n),s=x.length;s-- >0;)m=x[s],m!==`_listeners`&&(S=w(e,t,n[m],r+1,i),S&&(p?p.push.apply(p,S):p=S));return p}else if(y===`**`){for(v=r+1===i||r+2===i&&b===`*`,v&&n._listeners&&(p=w(e,t,n,i,i)),x=u(n),s=x.length;s-- >0;)m=x[s],m!==`_listeners`&&(m===`*`||m===`**`?(n[m]._listeners&&!v&&(S=w(e,t,n[m],i,i),S&&(p?p.push.apply(p,S):p=S)),S=w(e,t,n[m],r,i)):S=m===b?w(e,t,n[m],r+2,i):w(e,t,n[m],r,i),S&&(p?p.push.apply(p,S):p=S));return p}else n[y]&&(p=w(e,t,n[y],r+1,i));if(h=n[`*`],h&&w(e,t,h,r+1,i),g=n[`**`],g)if(r<i)for(g._listeners&&w(e,t,g,i,i),x=u(g),s=x.length;s-- >0;)m=x[s],m!==`_listeners`&&(m===b?w(e,t,g[m],r+2,i):m===y?w(e,t,g[m],r+1,i):(_={},_[m]=g[m],w(e,t,{"**":_},r+1,i)));else g._listeners?w(e,t,g,i,i):g[`*`]&&g[`*`]._listeners&&w(e,t,g[`*`],i,i);return p}function T(e,t,n){var r=0,i=0,a,o=this.delimiter,s=o.length,c;if(typeof e==`string`)if((a=e.indexOf(o))!==-1){c=[,,,,,];do c[r++]=e.slice(i,a),i=a+s;while((a=e.indexOf(o,i))!==-1);c[r++]=e.slice(i)}else c=[e],r=1;else c=e,r=e.length;if(r>1){for(a=0;a+1<r;a++)if(c[a]===`**`&&c[a+1]===`**`)return}var l=this.listenerTree,u;for(a=0;a<r;a++)if(u=c[a],l=l[u]||(l[u]={}),a===r-1)return l._listeners?(typeof l._listeners==`function`&&(l._listeners=[l._listeners]),n?l._listeners.unshift(t):l._listeners.push(t),!l._listeners.warned&&this._maxListeners>0&&l._listeners.length>this._maxListeners&&(l._listeners.warned=!0,p.call(this,l._listeners.length,u))):l._listeners=t,!0;return!0}function E(e,t,n,r){for(var i=u(e),a=i.length,o,s,c,l=e._listeners,d;a-- >0;)s=i[a],o=e[s],c=s===`_listeners`?n:n?n.concat(s):[s],d=r||typeof s==`symbol`,l&&t.push(d?c:c.join(this.delimiter)),typeof o==`object`&&E.call(this,o,t,c,d);return t}function D(e){for(var t=u(e),n=t.length,r,i,a;n-- >0;)i=t[n],r=e[i],r&&(a=!0,i!==`_listeners`&&!D(r)&&delete e[i]);return a}function O(e,t,n){this.emitter=e,this.event=t,this.listener=n}O.prototype.off=function(){return this.emitter.off(this.event,this.listener),this};function k(e,t,r){if(r===!0)a=!0;else if(r===!1)i=!0;else{if(!r||typeof r!=`object`)throw TypeError(`options should be an object or true`);var i=r.async,a=r.promisify,s=r.nextTick,c=r.objectify}if(i||s||a){var u=t,d=t._origin||t;if(s&&!o)throw Error(`process.nextTick is not supported`);a===n&&(a=t.constructor.name===`AsyncFunction`),t=function(){var e=arguments,t=this,n=this.event;return a?s?Promise.resolve():new Promise(function(e){l(e)}).then(function(){return t.event=n,u.apply(t,e)}):(s?process.nextTick:l)(function(){t.event=n,u.apply(t,e)})},t._async=!0,t._origin=d}return[t,c?new O(this,e,t):this]}function A(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,f.call(this,e)}A.EventEmitter2=A,A.prototype.listenTo=function(e,t,r){if(typeof e!=`object`)throw TypeError(`target musts be an object`);var a=this;r=_(r,{on:n,off:n,reducers:n},{on:b,off:b,reducers:x});function o(t){if(typeof t!=`object`)throw TypeError(`events must be an object`);for(var n=r.reducers,i=C.call(a,e),o=i===-1?new g(a,e,r):a._observers[i],s=u(t),c=s.length,l,d=typeof n==`function`,f=0;f<c;f++)l=s[f],o.subscribe(l,t[l]||l,d?n:n&&n[l])}return i(t)?o(h(t)):o(typeof t==`string`?h(t.split(/\s+/)):t),this},A.prototype.stopListeningTo=function(e,t){var n=this._observers;if(!n)return!1;var r=n.length,i,a=!1;if(e&&typeof e!=`object`)throw TypeError(`target should be an object`);for(;r-- >0;)i=n[r],(!e||i._target===e)&&(i.unsubscribe(t),a=!0);return a},A.prototype.delimiter=`.`,A.prototype.setMaxListeners=function(e){e!==n&&(this._maxListeners=e,this._conf||={},this._conf.maxListeners=e)},A.prototype.getMaxListeners=function(){return this._maxListeners},A.prototype.event=``,A.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},A.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},A.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},A.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},A.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},A.prototype._many=function(e,t,n,r,i){var a=this;if(typeof n!=`function`)throw Error(`many only accepts instances of Function`);function o(){return--t===0&&a.off(e,o),n.apply(this,arguments)}return o._origin=n,this._on(e,o,r,i)},A.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||d.call(this);var e=arguments[0],t,n=this.wildcard,r,i,a,o,c;if(e===`newListener`&&!this._newListener&&!this._events.newListener)return!1;if(n&&(t=e,e!==`newListener`&&e!==`removeListener`&&typeof e==`object`)){if(i=e.length,s){for(a=0;a<i;a++)if(typeof e[a]==`symbol`){c=!0;break}}c||(e=e.join(this.delimiter))}var l=arguments.length,u;if(this._all&&this._all.length)for(u=this._all.slice(),a=0,i=u.length;a<i;a++)switch(this.event=e,l){case 1:u[a].call(this,e);break;case 2:u[a].call(this,e,arguments[1]);break;case 3:u[a].call(this,e,arguments[1],arguments[2]);break;default:u[a].apply(this,arguments)}if(n)u=[],w.call(this,u,t,this.listenerTree,0,i);else if(u=this._events[e],typeof u==`function`){switch(this.event=e,l){case 1:u.call(this);break;case 2:u.call(this,arguments[1]);break;case 3:u.call(this,arguments[1],arguments[2]);break;default:for(r=Array(l-1),o=1;o<l;o++)r[o-1]=arguments[o];u.apply(this,r)}return!0}else u&&=u.slice();if(u&&u.length){if(l>3)for(r=Array(l-1),o=1;o<l;o++)r[o-1]=arguments[o];for(a=0,i=u.length;a<i;a++)switch(this.event=e,l){case 1:u[a].call(this);break;case 2:u[a].call(this,arguments[1]);break;case 3:u[a].call(this,arguments[1],arguments[2]);break;default:u[a].apply(this,r)}return!0}else if(!this.ignoreErrors&&!this._all&&e===`error`)throw arguments[1]instanceof Error?arguments[1]:Error(`Uncaught, unspecified 'error' event.`);return!!this._all},A.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||d.call(this);var e=arguments[0],t=this.wildcard,n,r,i,a,o,c;if(e===`newListener`&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(t&&(n=e,e!==`newListener`&&e!==`removeListener`&&typeof e==`object`)){if(a=e.length,s){for(o=0;o<a;o++)if(typeof e[o]==`symbol`){r=!0;break}}r||(e=e.join(this.delimiter))}var l=[],u=arguments.length,f;if(this._all)for(o=0,a=this._all.length;o<a;o++)switch(this.event=e,u){case 1:l.push(this._all[o].call(this,e));break;case 2:l.push(this._all[o].call(this,e,arguments[1]));break;case 3:l.push(this._all[o].call(this,e,arguments[1],arguments[2]));break;default:l.push(this._all[o].apply(this,arguments))}if(t?(f=[],w.call(this,f,n,this.listenerTree,0)):f=this._events[e],typeof f==`function`)switch(this.event=e,u){case 1:l.push(f.call(this));break;case 2:l.push(f.call(this,arguments[1]));break;case 3:l.push(f.call(this,arguments[1],arguments[2]));break;default:for(i=Array(u-1),c=1;c<u;c++)i[c-1]=arguments[c];l.push(f.apply(this,i))}else if(f&&f.length){if(f=f.slice(),u>3)for(i=Array(u-1),c=1;c<u;c++)i[c-1]=arguments[c];for(o=0,a=f.length;o<a;o++)switch(this.event=e,u){case 1:l.push(f[o].call(this));break;case 2:l.push(f[o].call(this,arguments[1]));break;case 3:l.push(f[o].call(this,arguments[1],arguments[2]));break;default:l.push(f[o].apply(this,i))}}else if(!this.ignoreErrors&&!this._all&&e===`error`)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject(`Uncaught, unspecified 'error' event.`);return Promise.all(l)},A.prototype.on=function(e,t,n){return this._on(e,t,!1,n)},A.prototype.prependListener=function(e,t,n){return this._on(e,t,!0,n)},A.prototype.onAny=function(e){return this._onAny(e,!1)},A.prototype.prependAny=function(e){return this._onAny(e,!0)},A.prototype.addListener=A.prototype.on,A.prototype._onAny=function(e,t){if(typeof e!=`function`)throw Error(`onAny only accepts instances of Function`);return this._all||=[],t?this._all.unshift(e):this._all.push(e),this},A.prototype._on=function(e,t,r,i){if(typeof e==`function`)return this._onAny(e,t),this;if(typeof t!=`function`)throw Error(`on only accepts instances of Function`);this._events||d.call(this);var a=this,o;return i!==n&&(o=k.call(this,e,t,i),t=o[0],a=o[1]),this._newListener&&this.emit(`newListener`,e,t),this.wildcard?(T.call(this,e,t,r),a):(this._events[e]?(typeof this._events[e]==`function`&&(this._events[e]=[this._events[e]]),r?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,p.call(this,this._events[e].length,e))):this._events[e]=t,a)},A.prototype.off=function(e,t){if(typeof t!=`function`)throw Error(`removeListener only takes instances of Function`);var n,r=[];if(this.wildcard){var a=typeof e==`string`?e.split(this.delimiter):e.slice();if(r=w.call(this,null,a,this.listenerTree,0),!r)return this}else{if(!this._events[e])return this;n=this._events[e],r.push({_listeners:n})}for(var o=0;o<r.length;o++){var s=r[o];if(n=s._listeners,i(n)){for(var c=-1,l=0,u=n.length;l<u;l++)if(n[l]===t||n[l].listener&&n[l].listener===t||n[l]._origin&&n[l]._origin===t){c=l;break}if(c<0)continue;return this.wildcard?s._listeners.splice(c,1):this._events[e].splice(c,1),n.length===0&&(this.wildcard?delete s._listeners:delete this._events[e]),this._removeListener&&this.emit(`removeListener`,e,t),this}else (n===t||n.listener&&n.listener===t||n._origin&&n._origin===t)&&(this.wildcard?delete s._listeners:delete this._events[e],this._removeListener&&this.emit(`removeListener`,e,t))}return this.listenerTree&&D(this.listenerTree),this},A.prototype.offAny=function(e){var t=0,n=0,r;if(e&&this._all&&this._all.length>0){for(r=this._all,t=0,n=r.length;t<n;t++)if(e===r[t])return r.splice(t,1),this._removeListener&&this.emit(`removeListenerAny`,e),this}else{if(r=this._all,this._removeListener)for(t=0,n=r.length;t<n;t++)this.emit(`removeListenerAny`,r[t]);this._all=[]}return this},A.prototype.removeListener=A.prototype.off,A.prototype.removeAllListeners=function(e){if(e===n)return!this._events||d.call(this),this;if(this.wildcard){var t=w.call(this,null,e,this.listenerTree,0),r,i;if(!t)return this;for(i=0;i<t.length;i++)r=t[i],r._listeners=null;this.listenerTree&&D(this.listenerTree)}else this._events&&(this._events[e]=null);return this},A.prototype.listeners=function(e){var t=this._events,r,i,a,o,s;if(e===n){if(this.wildcard)throw Error(`event name required for wildcard emitter`);if(!t)return[];for(r=u(t),o=r.length,a=[];o-- >0;)i=t[r[o]],typeof i==`function`?a.push(i):a.push.apply(a,i);return a}else{if(this.wildcard){if(s=this.listenerTree,!s)return[];var c=[],l=typeof e==`string`?e.split(this.delimiter):e.slice();return w.call(this,c,l,s,0),c}return!t||(i=t[e],!i)?[]:typeof i==`function`?[i]:i}},A.prototype.eventNames=function(e){var t=this._events;return this.wildcard?E.call(this,this.listenerTree,[],null,e):t?u(t):[]},A.prototype.listenerCount=function(e){return this.listeners(e).length},A.prototype.hasListeners=function(e){if(this.wildcard){var t=[],r=typeof e==`string`?e.split(this.delimiter):e.slice();return w.call(this,t,r,this.listenerTree,0),t.length>0}var i=this._events,a=this._all;return!!(a&&a.length||i&&(e===n?u(i).length:i[e]))},A.prototype.listenersAny=function(){return this._all?this._all:[]},A.prototype.waitFor=function(e,t){var r=this,i=typeof t;return i===`number`?t={timeout:t}:i===`function`&&(t={filter:t}),t=_(t,{timeout:0,filter:n,handleError:!1,Promise,overload:!1},{filter:b,Promise:v}),S(t.Promise,function(n,i,a){function o(){var a=t.filter;if(!(a&&!a.apply(r,arguments)))if(r.off(e,o),t.handleError){var s=arguments[0];s?i(s):n(m.apply(null,arguments).slice(1))}else n(m.apply(null,arguments))}a(function(){r.off(e,o)}),r._on(e,o,!1)},{timeout:t.timeout,overload:t.overload})};function j(e,t,n){n=_(n,{Promise,timeout:0,overload:!1},{Promise:v});var r=n.Promise;return S(r,function(n,r,i){var a;if(typeof e.addEventListener==`function`){a=function(){n(m.apply(null,arguments))},i(function(){e.removeEventListener(t,a)}),e.addEventListener(t,a,{once:!0});return}var o=function(){s&&e.removeListener(`error`,s),n(m.apply(null,arguments))},s;t!==`error`&&(s=function(n){e.removeListener(t,o),r(n)},e.once(`error`,s)),i(function(){s&&e.removeListener(`error`,s),e.removeListener(t,o)}),e.once(t,o)},{timeout:n.timeout,overload:n.overload})}var M=A.prototype;if(Object.defineProperties(A,{defaultMaxListeners:{get:function(){return M._maxListeners},set:function(e){if(typeof e!=`number`||e<0||Number.isNaN(e))throw TypeError(`n must be a non-negative number`);M._maxListeners=e},enumerable:!0},once:{value:j,writable:!0,configurable:!0}}),Object.defineProperties(M,{_maxListeners:{value:a,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),typeof define==`function`&&define.amd)define(function(){return A});else if(typeof e==`object`)t.exports=A;else{var N=Function(``,`return this`)();N.EventEmitter2=A}})()}))();var xXt=(e=>(e.loading=`loading`,e.fetchMore=`fetchMore`,e.ready=`ready`,e.error=`error`,e))(xXt||{}),G7=new WeakMap,K7=new WeakMap,q7={current:[]},J7=!1,SXt=0,Y7=new Set,X7=new Map;function CXt(e){let t=Array.from(e).sort((e,t)=>e instanceof kXt&&e.options.deps.includes(t)?1:t instanceof kXt&&t.options.deps.includes(e)?-1:0);for(let e of t){if(q7.current.includes(e))continue;q7.current.push(e),e.recompute();let t=K7.get(e);if(t)for(let e of t){let t=G7.get(e);t&&CXt(t)}}}function wXt(e){let t={prevVal:e.prevState,currentVal:e.state};for(let n of e.listeners)n(t)}function TXt(e){let t={prevVal:e.prevState,currentVal:e.state};for(let n of e.listeners)n(t)}function EXt(e){if(SXt>0&&!X7.has(e)&&X7.set(e,e.prevState),Y7.add(e),!(SXt>0)&&!J7)try{for(J7=!0;Y7.size>0;){let e=Array.from(Y7);Y7.clear();for(let t of e)t.prevState=X7.get(t)??t.prevState,wXt(t);for(let t of e){let e=G7.get(t);e&&(q7.current.push(t),CXt(e))}for(let t of e){let e=G7.get(t);if(e)for(let t of e)TXt(t)}}}finally{J7=!1,q7.current=[],X7.clear()}}function DXt(e){return typeof e==`function`}var OXt=class{constructor(e,t){this.listeners=new Set,this.subscribe=e=>{var t;this.listeners.add(e);let n=((t=this.options)?.onSubscribe)?.call(t,e,this);return()=>{this.listeners.delete(e),n?.()}},this.prevState=e,this.state=e,this.options=t}setState(e){var t,n;this.prevState=this.state,this.options?.updateFn?this.state=this.options.updateFn(this.prevState)(e):DXt(e)?this.state=e(this.prevState):this.state=e,(n=(t=this.options)?.onUpdate)==null||n.call(t),EXt(this)}},kXt=class e{constructor(t){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{let e=this.options.deps.length,t=Array(e),n=Array(e);for(let r=0;r<e;r++){let e=this.options.deps[r];t[r]=e.prevState,n[r]=e.state}return this.lastSeenDepValues=n,{prevDepVals:t,currDepVals:n,prevVal:this.prevState??void 0}},this.recompute=()=>{var e,t;this.prevState=this.state;let n=this.getDepVals();this.state=this.options.fn(n),(t=(e=this.options).onUpdate)==null||t.call(e)},this.checkIfRecalculationNeededDeeply=()=>{for(let t of this.options.deps)t instanceof e&&t.checkIfRecalculationNeededDeeply();let t=!1,n=this.lastSeenDepValues,{currDepVals:r}=this.getDepVals();for(let e=0;e<r.length;e++)if(r[e]!==n[e]){t=!0;break}t&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(let e of this._subscriptions)e()}),this.subscribe=e=>{var t;this.listeners.add(e);let n=(t=this.options).onSubscribe?.call(t,e,this);return()=>{this.listeners.delete(e),n?.()}},this.options=t,this.state=t.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(t=this.options.deps){for(let n of t)if(n instanceof e)n.registerOnGraph(),this.registerOnGraph(n.options.deps);else if(n instanceof OXt){let e=G7.get(n);e||(e=new Set,G7.set(n,e)),e.add(this);let t=K7.get(this);t||(t=new Set,K7.set(this,t)),t.add(n)}}unregisterFromGraph(t=this.options.deps){for(let n of t)if(n instanceof e)this.unregisterFromGraph(n.options.deps);else if(n instanceof OXt){let e=G7.get(n);e&&e.delete(this);let t=K7.get(this);t&&t.delete(n)}}};({NewMessage:`new-message`}).NewMessage,xXt.ready;var AXt=class extends Error{};AXt.prototype.name=`InvalidTokenError`;function jXt(e,t){return function(){return e.apply(t,arguments)}}var{toString:MXt}=Object.prototype,{getPrototypeOf:Z7}=Object,{iterator:Q7,toStringTag:NXt}=Symbol,$7=(e=>t=>{let n=MXt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),e9=e=>(e=e.toLowerCase(),t=>$7(t)===e),t9=e=>t=>typeof t===e,{isArray:n9}=Array,r9=t9(`undefined`);function i9(e){return e!==null&&!r9(e)&&e.constructor!==null&&!r9(e.constructor)&&a9(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var PXt=e9(`ArrayBuffer`);function FXt(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&PXt(e.buffer),t}var IXt=t9(`string`),a9=t9(`function`),LXt=t9(`number`),o9=e=>typeof e==`object`&&!!e,RXt=e=>e===!0||e===!1,s9=e=>{if($7(e)!==`object`)return!1;let t=Z7(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(NXt in e)&&!(Q7 in e)},zXt=e=>{if(!o9(e)||i9(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},BXt=e9(`Date`),VXt=e9(`File`),HXt=e9(`Blob`),UXt=e9(`FileList`),WXt=e=>o9(e)&&a9(e.pipe),GXt=e=>{let t;return e&&(typeof FormData==`function`&&e instanceof FormData||a9(e.append)&&((t=$7(e))===`formdata`||t===`object`&&a9(e.toString)&&e.toString()===`[object FormData]`))},KXt=e9(`URLSearchParams`),[qXt,JXt,YXt,XXt]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(e9),ZXt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function c9(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),n9(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(i9(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length,o;for(r=0;r<a;r++)o=i[r],t.call(null,e[o],o,e)}}function QXt(e,t){if(i9(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,i;for(;r-- >0;)if(i=n[r],t===i.toLowerCase())return i;return null}var l9=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,$Xt=e=>!r9(e)&&e!==l9;function u9(){let{caseless:e,skipUndefined:t}=$Xt(this)&&this||{},n={},r=(r,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=e&&QXt(n,i)||i;s9(n[a])&&s9(r)?n[a]=u9(n[a],r):s9(r)?n[a]=u9({},r):n9(r)?n[a]=r.slice():(!t||!r9(r))&&(n[a]=r)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&c9(arguments[e],r);return n}var eZt=(e,t,n,{allOwnKeys:r}={})=>(c9(t,(t,r)=>{n&&a9(t)?Object.defineProperty(e,r,{value:jXt(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),tZt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),nZt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,`constructor`,{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`super`,{value:t.prototype}),n&&Object.assign(e.prototype,n)},rZt=(e,t,n,r)=>{let i,a,o,s={};if(t||={},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!r||r(o,e,t))&&!s[o]&&(t[o]=e[o],s[o]=!0);e=n!==!1&&Z7(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},iZt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},aZt=e=>{if(!e)return null;if(n9(e))return e;let t=e.length;if(!LXt(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},oZt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&Z7(Uint8Array)),sZt=(e,t)=>{let n=(e&&e[Q7]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},cZt=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},lZt=e9(`HTMLFormElement`),uZt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),dZt=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),fZt=e9(`RegExp`),pZt=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};c9(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},mZt=e=>{pZt(e,(t,n)=>{if(a9(e)&&[`arguments`,`caller`,`callee`].indexOf(n)!==-1)return!1;let r=e[n];if(a9(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},hZt=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return n9(e)?r(e):r(String(e).split(t)),n},gZt=()=>{},_Zt=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function vZt(e){return!!(e&&a9(e.append)&&e[NXt]===`FormData`&&e[Q7])}var yZt=e=>{let t=Array(10),n=(e,r)=>{if(o9(e)){if(t.indexOf(e)>=0)return;if(i9(e))return e;if(!(`toJSON`in e)){t[r]=e;let i=n9(e)?[]:{};return c9(e,(e,t)=>{let a=n(e,r+1);!r9(a)&&(i[t]=a)}),t[r]=void 0,i}}return e};return n(e,0)},bZt=e9(`AsyncFunction`),xZt=e=>e&&(o9(e)||a9(e))&&a9(e.then)&&a9(e.catch),SZt=((e,t)=>e?setImmediate:t?((e,t)=>(l9.addEventListener(`message`,({source:n,data:r})=>{n===l9&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),l9.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,a9(l9.postMessage)),$={isArray:n9,isArrayBuffer:PXt,isBuffer:i9,isFormData:GXt,isArrayBufferView:FXt,isString:IXt,isNumber:LXt,isBoolean:RXt,isObject:o9,isPlainObject:s9,isEmptyObject:zXt,isReadableStream:qXt,isRequest:JXt,isResponse:YXt,isHeaders:XXt,isUndefined:r9,isDate:BXt,isFile:VXt,isBlob:HXt,isRegExp:fZt,isFunction:a9,isStream:WXt,isURLSearchParams:KXt,isTypedArray:oZt,isFileList:UXt,forEach:c9,merge:u9,extend:eZt,trim:ZXt,stripBOM:tZt,inherits:nZt,toFlatObject:rZt,kindOf:$7,kindOfTest:e9,endsWith:iZt,toArray:aZt,forEachEntry:sZt,matchAll:cZt,isHTMLForm:lZt,hasOwnProperty:dZt,hasOwnProp:dZt,reduceDescriptors:pZt,freezeMethods:mZt,toObjectSet:hZt,toCamelCase:uZt,noop:gZt,toFiniteNumber:_Zt,findKey:QXt,global:l9,isContextDefined:$Xt,isSpecCompliantForm:vZt,toJSONObject:yZt,isAsyncFn:bZt,isThenable:xZt,setImmediate:SZt,asap:typeof queueMicrotask<`u`?queueMicrotask.bind(l9):typeof process<`u`&&process.nextTick||SZt,isIterable:e=>e!=null&&a9(e[Q7])},d9=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return s.cause=t,s.name=t.name,o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:$.toJSONObject(this.config),code:this.code,status:this.status}}};d9.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,d9.ERR_BAD_OPTION=`ERR_BAD_OPTION`,d9.ECONNABORTED=`ECONNABORTED`,d9.ETIMEDOUT=`ETIMEDOUT`,d9.ERR_NETWORK=`ERR_NETWORK`,d9.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,d9.ERR_DEPRECATED=`ERR_DEPRECATED`,d9.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,d9.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,d9.ERR_CANCELED=`ERR_CANCELED`,d9.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,d9.ERR_INVALID_URL=`ERR_INVALID_URL`;function f9(e){return $.isPlainObject(e)||$.isArray(e)}function CZt(e){return $.endsWith(e,`[]`)?e.slice(0,-2):e}function wZt(e,t,n){return e?e.concat(t).map(function(e,t){return e=CZt(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function TZt(e){return $.isArray(e)&&!e.some(f9)}var EZt=$.toFlatObject($,{},null,function(e){return/^is[A-Z]/.test(e)});function p9(e,t,n){if(!$.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=$.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!$.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||l,a=n.dots,o=n.indexes,s=(n.Blob||typeof Blob<`u`&&Blob)&&$.isSpecCompliantForm(t);if(!$.isFunction(i))throw TypeError(`visitor must be a function`);function c(e){if(e===null)return``;if($.isDate(e))return e.toISOString();if($.isBoolean(e))return e.toString();if(!s&&$.isBlob(e))throw new d9(`Blob is not supported. Use a Buffer instead.`);return $.isArrayBuffer(e)||$.isTypedArray(e)?s&&typeof Blob==`function`?new Blob([e]):Buffer.from(e):e}function l(e,n,i){let s=e;if(e&&!i&&typeof e==`object`){if($.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if($.isArray(e)&&TZt(e)||($.isFileList(e)||$.endsWith(n,`[]`))&&(s=$.toArray(e)))return n=CZt(n),s.forEach(function(e,r){!($.isUndefined(e)||e===null)&&t.append(o===!0?wZt([n],r,a):o===null?n:n+`[]`,c(e))}),!1}return f9(e)?!0:(t.append(wZt(i,n,a),c(e)),!1)}let u=[],d=Object.assign(EZt,{defaultVisitor:l,convertValue:c,isVisitable:f9});function f(e,n){if(!$.isUndefined(e)){if(u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),$.forEach(e,function(e,r){(!($.isUndefined(e)||e===null)&&i.call(t,e,$.isString(r)?r.trim():r,n,d))===!0&&f(e,n?n.concat(r):[r])}),u.pop()}}if(!$.isObject(e))throw TypeError(`data must be an object`);return f(e),t}function DZt(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`,"%00":`\0`};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function m9(e,t){this._pairs=[],e&&p9(e,this,t)}var OZt=m9.prototype;OZt.append=function(e,t){this._pairs.push([e,t])},OZt.toString=function(e){let t=e?function(t){return e.call(this,t,DZt)}:DZt;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function kZt(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function AZt(e,t,n){if(!t)return e;let r=n&&n.encode||kZt,i=$.isFunction(n)?{serialize:n}:n,a=i&&i.serialize,o;if(o=a?a(t,i):$.isURLSearchParams(t)?t.toString():new m9(t,i).toString(r),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var jZt=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){$.forEach(this.handlers,function(t){t!==null&&e(t)})}},h9={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},MZt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:m9,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},NZt=i({hasBrowserEnv:()=>g9,hasStandardBrowserEnv:()=>PZt,hasStandardBrowserWebWorkerEnv:()=>FZt,navigator:()=>_9,origin:()=>IZt}),g9=typeof window<`u`&&typeof document<`u`,_9=typeof navigator==`object`&&navigator||void 0,PZt=g9&&(!_9||[`ReactNative`,`NativeScript`,`NS`].indexOf(_9.product)<0),FZt=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,IZt=g9&&window.location.href||`http://localhost`,v9={...NZt,...MZt};function LZt(e,t){return p9(e,new v9.classes.URLSearchParams,{visitor:function(e,t,n,r){return v9.isNode&&$.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}function RZt(e){return $.matchAll(/\w+|\[(\w*)]/g,e).map(e=>e[0]===`[]`?``:e[1]||e[0])}function zZt(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r<i;r++)a=n[r],t[a]=e[a];return t}function BZt(e){function t(e,n,r,i){let a=e[i++];if(a===`__proto__`)return!0;let o=Number.isFinite(+a),s=i>=e.length;return a=!a&&$.isArray(r)?r.length:a,s?($.hasOwnProp(r,a)?r[a]=[r[a],n]:r[a]=n,!o):((!r[a]||!$.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&$.isArray(r[a])&&(r[a]=zZt(r[a])),!o)}if($.isFormData(e)&&$.isFunction(e.entries)){let n={};return $.forEachEntry(e,(e,r)=>{t(RZt(e),r,n,0)}),n}return null}function VZt(e,t,n){if($.isString(e))try{return(t||JSON.parse)(e),$.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var y9={transitional:h9,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=$.isObject(e);if(i&&$.isHTMLForm(e)&&(e=new FormData(e)),$.isFormData(e))return r?JSON.stringify(BZt(e)):e;if($.isArrayBuffer(e)||$.isBuffer(e)||$.isStream(e)||$.isFile(e)||$.isBlob(e)||$.isReadableStream(e))return e;if($.isArrayBufferView(e))return e.buffer;if($.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return LZt(e,this.formSerializer).toString();if((a=$.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let t=this.env&&this.env.FormData;return p9(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType(`application/json`,!1),VZt(e)):e}],transformResponse:[function(e){let t=this.transitional||y9.transitional,n=t&&t.forcedJSONParsing,r=this.responseType===`json`;if($.isResponse(e)||$.isReadableStream(e))return e;if(e&&$.isString(e)&&(n&&!this.responseType||r)){let n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n)throw e.name===`SyntaxError`?d9.from(e,d9.ERR_BAD_RESPONSE,this,null,this.response):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:v9.classes.FormData,Blob:v9.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};$.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`],e=>{y9.headers[e]={}});var HZt=$.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),UZt=e=>{let t={},n,r,i;return e&&e.split(`
|
|
1583
1583
|
`).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&HZt[n])&&(n===`set-cookie`?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+`, `+r:r)}),t},WZt=Symbol(`internals`);function b9(e){return e&&String(e).trim().toLowerCase()}function x9(e){return e===!1||e==null?e:$.isArray(e)?e.map(x9):String(e)}function GZt(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var KZt=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function S9(e,t,n,r,i){if($.isFunction(r))return r.call(this,t,n);if(i&&(t=n),$.isString(t)){if($.isString(r))return t.indexOf(r)!==-1;if($.isRegExp(r))return r.test(t)}}function qZt(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function JZt(e,t){let n=$.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var C9=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=b9(t);if(!i)throw Error(`header name must be a non-empty string`);let a=$.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(r[a||t]=x9(e))}let a=(e,t)=>$.forEach(e,(e,n)=>i(e,n,t));if($.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if($.isString(e)&&(e=e.trim())&&!KZt(e))a(UZt(e),t);else if($.isObject(e)&&$.isIterable(e)){let n={},r,i;for(let t of e){if(!$.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);n[i=t[0]]=(r=n[i])?$.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=b9(e),e){let n=$.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return GZt(e);if($.isFunction(t))return t.call(this,e,n);if($.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=b9(e),e){let n=$.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||S9(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=b9(e),e){let i=$.findKey(n,e);i&&(!t||S9(n,n[i],i,t))&&(delete n[i],r=!0)}}return $.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||S9(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return $.forEach(this,(r,i)=>{let a=$.findKey(n,i);if(a){t[a]=x9(r),delete t[i];return}let o=e?qZt(i):String(i).trim();o!==i&&delete t[i],t[o]=x9(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return $.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&$.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(`
|