@zuplo/editor 1.0.33159753119 → 1.0.33162667821

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.
@@ -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-DB3wLpXJ.js","static/js/dist-DSg6bEGY.js","static/js/GraphiQLConsole-BKzVJZ-7.js","static/js/esm-BMCX5KFO.js","static/js/definition-C7QrKMH2.js","static/css/GraphiQLConsole-C4zv7lh0.css"])))=>i.map(i=>d[i]);
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-6l45_xy_.js","static/js/dist-DSg6bEGY.js","static/js/GraphiQLConsole-Ck-5k6YD.js","static/js/esm-B-O-HyWw.js","static/js/definition-C7QrKMH2.js","static/css/GraphiQLConsole-C4zv7lh0.css"])))=>i.map(i=>d[i]);
2
2
  import{a as e,i as t,n,o as r,r as i,t as a}from"./chunk-6hGRweTZ.js";import{$ as o,$n as s,$t as c,A as l,An as u,At as d,B as f,Bn as p,Bt as m,C as h,Cn as g,Ct as _,D as v,Dn as y,Dt as b,E as x,En as S,Et as C,F as w,Fn as T,Ft as E,G as D,Gn as O,Gt as k,H as A,Hn as j,Ht as M,I as N,In as P,It as F,J as I,Jn as L,Jt as R,K as z,Kn as B,Kt as ee,L as V,Ln as te,Lt as ne,M as re,Mn as ie,Mt as ae,N as oe,Nn as se,Nt as ce,O as le,On as ue,Ot as de,P as fe,Pn as pe,Q as me,Qn as he,Qt as ge,R as _e,Rn as ve,Rt as ye,S as be,Sn as xe,St as Se,T as Ce,Tn as we,Tt as Te,U as Ee,Un as De,Ut as Oe,V as ke,Vn as Ae,Vt as je,W as Me,Wn as Ne,Wt as Pe,X as Fe,Xn as Ie,Xt as Le,Y as Re,Yn as ze,Yt as Be,Z as Ve,Zn as He,Zt as Ue,_n as We,_t as Ge,a as Ke,an as qe,ar as Je,at as Ye,b as Xe,bn as Ze,bt as Qe,c as $e,cn as et,ct as tt,d as nt,dn as rt,dt as it,en as at,er as ot,et as st,f as ct,fn as lt,ft as ut,gn as dt,gt as ft,hn as pt,ht as mt,i as ht,in as gt,ir as _t,it as vt,j as yt,jn as bt,jt as xt,k as St,kn as Ct,kt as wt,l as Tt,ln as Et,lt as Dt,mn as Ot,mt as kt,n as At,nn as jt,nr as Mt,nt as Nt,o as Pt,on as Ft,ot as It,pn as Lt,pt as Rt,q as zt,qn as Bt,qt as Vt,r as Ht,rn as Ut,rr as Wt,rt as Gt,s as Kt,sn as qt,st as Jt,t as Yt,tn as Xt,tr as Zt,tt as Qt,u as $t,un as en,ut as tn,vn as nn,vt as rn,w as an,wn as on,wt as sn,x as cn,xn as ln,xt as un,yn as dn,yt as fn,z as pn,zn as mn,zt as hn}from"./dist-DSg6bEGY.js";import{t as gn}from"./preload-helper-DxkSl20Q.js";import{$ as _n,C as vn,E as yn,F as bn,G as xn,I as Sn,J as Cn,K as wn,M as Tn,O as En,P as Dn,Q as On,S as kn,V as An,X as jn,Y as Mn,Z as Nn,_ as Pn,a as Fn,at as In,b as Ln,c as eee,ct as Rn,d as zn,et as Bn,f as Vn,h as Hn,i as Un,k as Wn,l as Gn,lt as Kn,m as qn,n as Jn,nt as Yn,o as Xn,p as tee,r as nee,rt as Zn,s as Qn,st as $n,t as er,tt as tr,ut as nr,w as rr,x as ir,y as ar}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 or=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}}}})),ree=a(((e,t)=>{t.exports=or()})),sr=a((e=>{var t=ree(),n=Je(),r=_t();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function R(e){return{current:e}}function z(e){0>L||(e.current=I[L],I[L]=null,L--)}function B(e,t){L++,I[L]=e.current,e.current=t}var ee=R(null),V=R(null),te=R(null),ne=R(null);function re(e,t){switch(B(te,t),B(V,e),B(ee,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Od(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Od(t),e=kd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(ee),B(ee,e)}function ie(){z(ee),z(V),z(te)}function ae(e){e.memoizedState!==null&&B(ne,e);var t=ee.current,n=kd(t,e.type);t!==n&&(B(V,e),B(ee,n))}function oe(e){V.current===e&&(z(ee),z(V)),ne.current===e&&(z(ne),Pf._currentValue=F)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+se+e+ce}var ue=!1;function de(e,t){if(!e||ue)return``;ue=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -314,7 +314,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
314
314
  `);return n===-1?null:(this.position+=n+1,t.slice(0,n))}isBufferTooLong(e){return this.position===e.length&&e.length>262144}}var Dt;(function(e){e[e.CONNECTING=0]=`CONNECTING`,e[e.OPEN=1]=`OPEN`,e[e.CLOSED=3]=`CLOSED`})(Dt||={});var Ot=Dt,kt=1;class At{constructor(e,t){this.hooks=e,this.session=Ft(1e3)+`/`+It(8),this.location=jt(t),this.readyState=Ot.CONNECTING,this.openStream()}send(e){return this.sendRaw(JSON.stringify([e]))}ping(){this.hooks.sendHeartbeat(this)}close(e,t){this.onClose(e,t,!0)}sendRaw(e){if(this.readyState===Ot.OPEN)try{return Ht.createSocketRequest(`POST`,Nt(Mt(this.location,this.session))).start(e),!0}catch{return!1}else return!1}reconnect(){this.closeStream(),this.openStream()}onClose(e,t,n){this.closeStream(),this.readyState=Ot.CLOSED,this.onclose&&this.onclose({code:e,reason:t,wasClean:n})}onChunk(e){if(e.status===200){this.readyState===Ot.OPEN&&this.onActivity();var t;switch(e.data.slice(0,1)){case`o`:t=JSON.parse(e.data.slice(1)||`{}`),this.onOpen(t);break;case`a`:t=JSON.parse(e.data.slice(1)||`[]`);for(var n=0;n<t.length;n++)this.onEvent(t[n]);break;case`m`:t=JSON.parse(e.data.slice(1)||`null`),this.onEvent(t);break;case`h`:this.hooks.onHeartbeat(this);break;case`c`:t=JSON.parse(e.data.slice(1)||`[]`),this.onClose(t[0],t[1],!0);break}}}onOpen(e){this.readyState===Ot.CONNECTING?(e&&e.hostname&&(this.location.base=Pt(this.location.base,e.hostname)),this.readyState=Ot.OPEN,this.onopen&&this.onopen()):this.onClose(1006,`Server lost session`,!0)}onEvent(e){this.readyState===Ot.OPEN&&this.onmessage&&this.onmessage({data:e})}onActivity(){this.onactivity&&this.onactivity()}onError(e){this.onerror&&this.onerror(e)}openStream(){this.stream=Ht.createSocketRequest(`POST`,Nt(this.hooks.getReceiveURL(this.location,this.session))),this.stream.bind(`chunk`,e=>{this.onChunk(e)}),this.stream.bind(`finished`,e=>{this.hooks.onFinished(this,e)}),this.stream.bind(`buffer_too_long`,()=>{this.reconnect()});try{this.stream.start()}catch(e){R.defer(()=>{this.onError(e),this.onClose(1006,`Could not start streaming`,!1)})}}closeStream(){this.stream&&=(this.stream.unbind_all(),this.stream.close(),null)}}function jt(e){var t=/([^\?]*)\/*(\??.*)/.exec(e);return{base:t[1],queryString:t[2]}}function Mt(e,t){return e.base+`/`+t+`/xhr_send`}function Nt(e){return e+(e.indexOf(`?`)===-1?`?`:`&`)+`t=`+ +new Date+`&n=`+ kt++}function Pt(e,t){var n=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(e);return n[1]+t+n[3]}function Ft(e){return Ht.randomInt(e)}function It(e){for(var t=[],n=0;n<e;n++)t.push(Ft(32).toString(32));return t.join(``)}var Lt=At,Rt={getReceiveURL:function(e,t){return e.base+`/`+t+`/xhr_streaming`+e.queryString},onHeartbeat:function(e){e.sendRaw(`[]`)},sendHeartbeat:function(e){e.sendRaw(`[]`)},onFinished:function(e,t){e.onClose(1006,`Connection interrupted (`+t+`)`,!1)}},zt={getReceiveURL:function(e,t){return e.base+`/`+t+`/xhr`+e.queryString},onHeartbeat:function(){},sendHeartbeat:function(e){e.sendRaw(`[]`)},onFinished:function(e,t){t===200?e.reconnect():e.onClose(1006,`Connection interrupted (`+t+`)`,!1)}},Bt={getRequest:function(e){var t=new(Ht.getXHRAPI());return t.onreadystatechange=t.onprogress=function(){switch(t.readyState){case 3:t.responseText&&t.responseText.length>0&&e.onChunk(t.status,t.responseText);break;case 4:t.responseText&&t.responseText.length>0&&e.onChunk(t.status,t.responseText),e.emit(`finished`,t.status),e.close();break}},t},abortRequest:function(e){e.onreadystatechange=null,e.abort()}},Vt={createStreamingSocket(e){return this.createSocket(Rt,e)},createPollingSocket(e){return this.createSocket(zt,e)},createSocket(e,t){return new Lt(e,t)},createXHR(e,t){return this.createRequest(Bt,e,t)},createRequest(e,t,n){return new Et(e,t,n)}};Vt.createXDR=function(e,t){return this.createRequest(Tt,e,t)};var Ht={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:i,DependenciesReceivers:s,getDefaultStrategy:Ct,Transports:Ve,transportConnectionInitializer:wt,HTTPFactory:Vt,TimelineTransport:be,getXHRAPI(){return window.XMLHttpRequest},getWebSocketAPI(){return window.WebSocket||window.MozWebSocket},setup(e){window.Pusher=e;var t=()=>{this.onDocumentBody(e.ready)};window.JSON?t():c.load(`json2`,{},t)},getDocument(){return document},getProtocol(){return this.getDocument().location.protocol},getAuthorizers(){return{ajax:x,jsonp:_e}},onDocumentBody(e){document.body?e():setTimeout(()=>{this.onDocumentBody(e)},0)},createJSONPRequest(e,t){return new ye(e,t)},createScriptRequest(e){return new ve(e)},getLocalStorage(){try{return window.localStorage}catch{return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR(){return new ActiveXObject(`Microsoft.XMLHTTP`)},getNetwork(){return Ue},createWebSocket(e){return new(this.getWebSocketAPI())(e)},createSocketRequest(e,t){if(this.isXHRSupported())return this.HTTPFactory.createXHR(e,t);if(this.isXDRSupported(t.indexOf(`https:`)===0))return this.HTTPFactory.createXDR(e,t);throw`Cross-origin HTTP requests are not supported`},isXHRSupported(){var e=this.getXHRAPI();return!!e&&new e().withCredentials!==void 0},isXDRSupported(e){var t=e?`https:`:`http:`,n=this.getProtocol();return!!window.XDomainRequest&&n===t},addUnloadListener(e){window.addEventListener===void 0?window.attachEvent!==void 0&&window.attachEvent(`onunload`,e):window.addEventListener(`unload`,e,!1)},removeUnloadListener(e){window.addEventListener===void 0?window.detachEvent!==void 0&&window.detachEvent(`onunload`,e):window.removeEventListener(`unload`,e,!1)},randomInt(e){return Math.floor(function(){return(window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/2**32}()*e)}},Ut;(function(e){e[e.ERROR=3]=`ERROR`,e[e.INFO=6]=`INFO`,e[e.DEBUG=7]=`DEBUG`})(Ut||={});var Wt=Ut;class Gt{constructor(e,t,n){this.key=e,this.session=t,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(e,t){e<=this.options.level&&(this.events.push(z({},t,{timestamp:R.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(e){this.log(Wt.ERROR,e)}info(e){this.log(Wt.INFO,e)}debug(e){this.log(Wt.DEBUG,e)}isEmpty(){return this.events.length===0}send(e,t){var n=z({session:this.session,bundle:this.sent+1,key:this.key,lib:`js`,version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],e(n,(e,n)=>{e||this.sent++,t&&t(e,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class Kt{constructor(e,t,n,r){this.name=e,this.priority=t,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(e,t){if(!this.isSupported())return qt(new y,t);if(this.priority<e)return qt(new h,t);var n=!1,r=this.transport.createConnection(this.name,this.priority,this.options.key,this.options),i=null,a=function(){r.unbind(`initialized`,a),r.connect()},o=function(){i=st.createHandshake(r,function(e){n=!0,l(),t(null,e)})},s=function(e){l(),t(e)},c=function(){l(),t(new g(me(r)))},l=function(){r.unbind(`initialized`,a),r.unbind(`open`,o),r.unbind(`error`,s),r.unbind(`closed`,c)};return r.bind(`initialized`,a),r.bind(`open`,o),r.bind(`error`,s),r.bind(`closed`,c),r.initialize(),{abort:()=>{n||(l(),i?i.close():r.close())},forceMinPriority:e=>{n||this.priority<e&&(i?i.close():r.close())}}}}function qt(e,t){return R.defer(function(){t(e)}),{abort:function(){},forceMinPriority:function(){}}}let{Transports:Jt}=Ht;var Yt=function(e,t,n,r,i,a){var o=Jt[n];if(!o)throw new v(n);var s=(!e.enabledTransports||ee(e.enabledTransports,t)!==-1)&&(!e.disabledTransports||ee(e.disabledTransports,t)===-1),c;return s?(i=Object.assign({ignoreNullOrigin:e.ignoreNullOrigin},i),c=new Kt(t,r,a?a.getAssistant(o):o,i)):c=Xt,c},Xt={isSupported:function(){return!1},connect:function(e,t){var n=R.defer(function(){t(new y)});return{abort:function(){n.ensureAborted()},forceMinPriority:function(){}}}};function Zt(e){if(e==null)throw`You must pass an options object`;if(e.cluster==null)throw`Options object must provide a cluster`;`disableStats`in e&&ge.warn(`The disableStats option is deprecated in favor of enableStats`)}let Qt=(e,t)=>{var n=`socket_id=`+encodeURIComponent(e.socketId);for(var r in t.params)n+=`&`+encodeURIComponent(r)+`=`+encodeURIComponent(t.params[r]);if(t.paramsProvider!=null){let e=t.paramsProvider();for(var r in e)n+=`&`+encodeURIComponent(r)+`=`+encodeURIComponent(e[r])}return n};var $t=e=>{if(Ht.getAuthorizers()[e.transport]===void 0)throw`'${e.transport}' is not a recognized auth transport`;return(t,n)=>{let r=Qt(t,e);Ht.getAuthorizers()[e.transport](Ht,r,e,d.UserAuthentication,n)}};let en=(e,t)=>{var n=`socket_id=`+encodeURIComponent(e.socketId);for(var r in n+=`&channel_name=`+encodeURIComponent(e.channelName),t.params)n+=`&`+encodeURIComponent(r)+`=`+encodeURIComponent(t.params[r]);if(t.paramsProvider!=null){let e=t.paramsProvider();for(var r in e)n+=`&`+encodeURIComponent(r)+`=`+encodeURIComponent(e[r])}return n};var tn=e=>{if(Ht.getAuthorizers()[e.transport]===void 0)throw`'${e.transport}' is not a recognized auth transport`;return(t,n)=>{let r=en(t,e);Ht.getAuthorizers()[e.transport](Ht,r,e,d.ChannelAuthorization,n)}};let nn=(e,t,n)=>{let r={authTransport:t.transport,authEndpoint:t.endpoint,auth:{params:t.params,headers:t.headers}};return(t,i)=>{n(e.channel(t.channelName),r).authorize(t.socketId,i)}};function rn(e,t){let n={activityTimeout:e.activityTimeout||a.activityTimeout,cluster:e.cluster,httpPath:e.httpPath||a.httpPath,httpPort:e.httpPort||a.httpPort,httpsPort:e.httpsPort||a.httpsPort,pongTimeout:e.pongTimeout||a.pongTimeout,statsHost:e.statsHost||a.stats_host,unavailableTimeout:e.unavailableTimeout||a.unavailableTimeout,wsPath:e.wsPath||a.wsPath,wsPort:e.wsPort||a.wsPort,wssPort:e.wssPort||a.wssPort,enableStats:ln(e),httpHost:an(e),useTLS:cn(e),wsHost:on(e),userAuthenticator:un(e),channelAuthorizer:fn(e,t)};return`disabledTransports`in e&&(n.disabledTransports=e.disabledTransports),`enabledTransports`in e&&(n.enabledTransports=e.enabledTransports),`ignoreNullOrigin`in e&&(n.ignoreNullOrigin=e.ignoreNullOrigin),`timelineParams`in e&&(n.timelineParams=e.timelineParams),`nacl`in e&&(n.nacl=e.nacl),n}function an(e){return e.httpHost?e.httpHost:e.cluster?`sockjs-${e.cluster}.pusher.com`:a.httpHost}function on(e){return e.wsHost?e.wsHost:sn(e.cluster)}function sn(e){return`ws-${e}.pusher.com`}function cn(e){return Ht.getProtocol()===`https:`?!0:e.forceTLS!==!1}function ln(e){return`enableStats`in e?e.enableStats:`disableStats`in e?!e.disableStats:!1}function un(e){let t=Object.assign(Object.assign({},a.userAuthentication),e.userAuthentication);return`customHandler`in t&&t.customHandler!=null?t.customHandler:$t(t)}function dn(e,t){let n;return`channelAuthorization`in e?n=Object.assign(Object.assign({},a.channelAuthorization),e.channelAuthorization):(n={transport:e.authTransport||a.authTransport,endpoint:e.authEndpoint||a.authEndpoint},`auth`in e&&(`params`in e.auth&&(n.params=e.auth.params),`headers`in e.auth&&(n.headers=e.auth.headers)),`authorizer`in e&&(n.customHandler=nn(t,n,e.authorizer))),n}function fn(e,t){let n=dn(e,t);return`customHandler`in n&&n.customHandler!=null?n.customHandler:tn(n)}class pn extends Oe{constructor(e){super(function(e,t){ge.debug(`No callbacks on watchlist events for ${e}`)}),this.pusher=e,this.bindWatchlistInternalEvent()}handleEvent(e){e.data.events.forEach(e=>{this.emit(e.name,e)})}bindWatchlistInternalEvent(){this.pusher.connection.bind(`message`,e=>{e.event===`pusher_internal:watchlist_events`&&this.handleEvent(e)})}}function mn(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var hn=mn;class gn extends Oe{constructor(e){super(function(e,t){ge.debug(`No callbacks on user for `+e)}),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(e,t)=>{if(e){ge.warn(`Error during signin: ${e}`),this._cleanup();return}this.pusher.send_event(`pusher:signin`,{auth:t.auth,user_data:t.user_data})},this.pusher=e,this.pusher.connection.bind(`state_change`,({previous:e,current:t})=>{e!==`connected`&&t===`connected`&&this._signin(),e===`connected`&&t!==`connected`&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new pn(e),this.pusher.connection.bind(`message`,e=>{e.event===`pusher:signin_success`&&this._onSigninSuccess(e.data),this.serverToUserChannel&&this.serverToUserChannel.name===e.channel&&this.serverToUserChannel.handleEvent(e)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),this.pusher.connection.state===`connected`&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(e){try{this.user_data=JSON.parse(e.user_data)}catch{ge.error(`Failed parsing user data after signin: ${e.user_data}`),this._cleanup();return}if(typeof this.user_data.id!=`string`||this.user_data.id===``){ge.error(`user_data doesn't contain an id. user_data: ${this.user_data}`),this._cleanup();return}this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new Xe(`#server-to-user-${this.user_data.id}`,this.pusher),this.serverToUserChannel.bind_global((e,t)=>{e.indexOf(`pusher_internal:`)===0||e.indexOf(`pusher:`)===0||this.emit(e,t)}),(e=>{e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():!e.subscriptionPending&&this.pusher.connection.state===`connected`&&e.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&=(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested||this.signinDonePromise&&!this.signinDonePromise.done)return;let{promise:e,resolve:t,reject:n}=hn();e.done=!1;let r=()=>{e.done=!0};e.then(r).catch(r),this.signinDonePromise=e,this._signinDoneResolve=t}}class _n{static ready(){_n.isReady=!0;for(var e=0,t=_n.instances.length;e<t;e++)_n.instances[e].connect()}static getClientFeatures(){return te(se({ws:Ht.Transports.ws},function(e){return e.isSupported({})}))}constructor(e,t){yn(e),Zt(t),this.key=e,this.config=rn(t,this),this.channels=st.createChannels(),this.global_emitter=new Oe,this.sessionID=Ht.randomInt(1e9),this.timeline=new Gt(this.key,this.sessionID,{cluster:this.config.cluster,features:_n.getClientFeatures(),params:this.config.timelineParams||{},limit:50,level:Wt.INFO,version:a.VERSION}),this.config.enableStats&&(this.timelineSender=st.createTimelineSender(this.timeline,{host:this.config.statsHost,path:`/timeline/v2/`+Ht.TimelineTransport.name})),this.connection=st.createConnectionManager(this.key,{getStrategy:e=>Ht.getDefaultStrategy(this.config,e,Yt),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:!!this.config.useTLS}),this.connection.bind(`connected`,()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind(`message`,e=>{var t=e.event.indexOf(`pusher_internal:`)===0;if(e.channel){var n=this.channel(e.channel);n&&n.handleEvent(e)}t||this.global_emitter.emit(e.event,e.data)}),this.connection.bind(`connecting`,()=>{this.channels.disconnect()}),this.connection.bind(`disconnected`,()=>{this.channels.disconnect()}),this.connection.bind(`error`,e=>{ge.warn(e)}),_n.instances.push(this),this.timeline.info({instances:_n.instances.length}),this.user=new gn(this),_n.isReady&&this.connect()}channel(e){return this.channels.find(e)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var e=this.connection.isUsingTLS(),t=this.timelineSender;this.timelineSenderTimer=new L(6e4,function(){t.send(e)})}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&=(this.timelineSenderTimer.ensureAborted(),null)}bind(e,t,n){return this.global_emitter.bind(e,t,n),this}unbind(e,t,n){return this.global_emitter.unbind(e,t,n),this}bind_global(e){return this.global_emitter.bind_global(e),this}unbind_global(e){return this.global_emitter.unbind_global(e),this}unbind_all(e){return this.global_emitter.unbind_all(),this}subscribeAll(){for(var e in this.channels.channels)this.channels.channels.hasOwnProperty(e)&&this.subscribe(e)}subscribe(e){var t=this.channels.add(e,this);return t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():!t.subscriptionPending&&this.connection.state===`connected`&&t.subscribe(),t}unsubscribe(e){var t=this.channels.find(e);t&&t.subscriptionPending?t.cancelSubscription():(t=this.channels.remove(e),t&&t.subscribed&&t.unsubscribe())}send_event(e,t,n){return this.connection.send_event(e,t,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}_n.instances=[],_n.isReady=!1,_n.logToConsole=!1,_n.Runtime=Ht,_n.ScriptReceivers=Ht.ScriptReceivers,_n.DependenciesReceivers=Ht.DependenciesReceivers,_n.auth_callbacks=Ht.auth_callbacks;var vn=t.default=_n;function yn(e){if(e==null)throw`You must pass your app key when you instantiate Pusher.`}Ht.setup(_n)})])})}))();var Ket=(e,t,n={})=>pb(mt.buildLogs(e,t),{extractData:!0,...n}),qet=()=>{let e=Dt();return je({mutationFn:async t=>e.fetch(tn.logs.sourcemap(t))})},SJ=H.createContext({entries:[]});function CJ(){return new URLSearchParams(qa().search)}function wJ(e,t){let[n,r]=As(),i=Object.fromEntries(n);return[n.get(e)??t,t=>r(t===void 0?Object.fromEntries(Object.entries(i).filter(([t])=>t!==e)):{...i,[e]:t})]}function Jet(e,t){let[n,r]=As();return[n.get(e)?n.getAll(e):t,t=>r({...Object.fromEntries(n),[e]:t})]}var TJ=e=>{if(e==null)return e===void 0?`undefined`:`null`;switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:return`${e}`;case`object`:return JSON.stringify(e,null,` `);default:return`Unable to convert input to string`}};function Yet(e){let t=e.split(`
315
315
  `).filter(e=>e.trim());if(t.length===0)return e;let n=[],r=t[0],i=r.match(/^(\w+Error:?\s*.+)/);i?n.push(i[1]):n.push(r);for(let e=1;e<t.length;e++){let r=t[e].trim();if(r.startsWith(`at `)){let e=r.match(/at\s+(.+?)(?:\s+\((.+?)\))?$/);if(e){let[,t,r]=e;r?n.push(` at ${t} (${r})`):n.push(` at ${t}`)}else n.push(` ${r}`)}else r.match(/^\s*(throw|return|const|let|var|if|for|while|function)/)}return n.join(`
316
316
  `)}var Xet=({stack:e,buildId:t})=>{let n=hp([`account`]),[r]=wJ(`env`),i=qet(),[a,o]=(0,H.useState)(0),s=(0,H.useRef)(``),c=n.environment?.name??r,{mutate:l}=i;(0,H.useEffect)(()=>{if(!c||!t||!e)return;let n=`${c}-${t}-${e}`;s.current!==n&&(s.current=n,l({deploymentName:c,buildId:t,stack:e}))},[c,t,e,l]),(0,H.useEffect)(()=>{if(!i.isPending)return;let e=setInterval(()=>{o(e=>(e+1)%4)},200);return()=>clearInterval(e)},[i.isPending]);let u=[`⠋`,`⠙`,`⠹`,`⠸`];return(0,U.jsx)(`pre`,{className:`text-xs py-2 px-2 rounded-t rounded-l`,children:(0,H.useMemo)(()=>i.isPending?`${u[a]} Mapping stacktrace...`:i.data?.stack?Yet(TJ(i.data.stack)):TJ(e),[i.isPending,i.data?.stack,e,a])})},EJ={trace:`text-blue-800 dark:text-blue-300`,debug:`text-blue-600 dark:text-blue-400`,info:`text-good`,warn:`text-warning`,error:`text-red-500`};function Zet(e){try{return JSON.parse(e)}catch{return}}var Qet={trace:(0,U.jsx)(cd,{size:14,className:EJ.trace}),debug:(0,U.jsx)(Zu,{size:14,className:EJ.debug}),info:(0,U.jsx)(ef,{size:14,className:W(EJ.info,`opacity-0`)}),warn:(0,U.jsx)(Jf,{size:14,className:EJ.warn}),error:(0,U.jsx)(md,{size:14,className:EJ.error})},$et=({logs:e,className:t})=>(0,U.jsx)(`div`,{className:W(`font-mono text-xs border-b divide-y`,t),children:e.map(e=>(0,U.jsx)(`div`,{className:`grid grid-cols-[min-content_minmax(0,1fr)] col-span-full`,children:(Array.isArray(e.messages)?e.messages:[e.messages]).map((t,n)=>{let r=t.startsWith(`{`)?Zet(t):void 0,i=typeof r==`object`&&`stack`in r&&r.stack;return(0,U.jsxs)(`div`,{className:W(`px-4 col-span-full grid grid-cols-subgrid`,{"bg-red-50 dark:bg-red-950/30":e.severity===`error`,"bg-yellow-50 dark:bg-yellow-950/30":e.severity===`warn`,"bg-neutral-50 dark:bg-neutral-800/50":e.severity===`info`}),children:[(0,U.jsx)(`div`,{className:`mt-2`,children:Qet[e.severity]}),(0,U.jsxs)(`div`,{className:`flex flex-col relative group`,children:[i?(0,U.jsx)(Xet,{buildId:e.buildId,stack:i}):(0,U.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs py-2 px-2 rounded-t rounded-l`,children:TJ(t)}),(0,U.jsx)(`div`,{className:`absolute top-2 right-2 group-hover:opacity-100 opacity-0`,children:(0,U.jsx)(sM,{textToCopy:TJ(t)})})]})]},`${e.logId}-${n}`)})},`${e.logId}`))}),ett={lineNumbers:`on`,lineDecorationsWidth:8,lineNumbersMinChars:3,minimap:{enabled:!1},readOnly:!0,renderLineHighlight:`none`,scrollBeyondLastLine:!1,automaticLayout:!0,wordWrap:`on`,folding:!0,padding:{top:8,bottom:8}},ttt=e=>e<1024?`${e} B`:`${(e/1024).toFixed(e<10240?1:0)} KB`,DJ=`rounded-md px-2.5 py-1 text-sm font-medium text-muted-foreground data-[state=active]:bg-accent data-[state=active]:text-foreground data-[state=active]:shadow-none`,OJ={raw:`RAW`,json:`JSON`,html:`HTML`,xml:`XML`,yaml:`YAML`},ntt={raw:`text`,json:`json`,html:`html`,xml:`xml`,yaml:`yaml`},rtt={raw:`txt`,json:`json`,html:`html`,xml:`xml`,yaml:`yaml`},kJ=e=>{let t=e.toLowerCase();return t.includes(`json`)?`json`:t.includes(`html`)?`html`:t.includes(`xml`)?`xml`:t.includes(`yaml`)||t.includes(`yml`)?`yaml`:`raw`},itt=({result:e,requestId:t,durationMs:n,onClear:r})=>{let{entries:i}=(0,H.useContext)(SJ),a=i.filter(e=>e.requestId===t),o=(0,H.useRef)(null),s=(0,H.useMemo)(()=>Object.entries(e.headers).find(([e])=>e.toLowerCase()===`content-type`)?.[1]??``,[e.headers]),c=(0,H.useMemo)(()=>{let t=e.body;if(!t)return t??``;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}},[e.body]),l=(0,H.useMemo)(()=>new Blob([e.body??``]).size,[e.body]),u=Object.keys(e.headers).length,[d,f]=(0,H.useState)(`body`),[p,m]=(0,H.useState)(()=>kJ(s));(0,H.useEffect)(()=>{m(kJ(s))},[s]);let h=p===`json`?c:e.body??``,g=e=>{o.current=e},_=e=>{navigator.clipboard?.writeText(e)},v=Object.entries(e.headers).map(([e,t])=>`${e}: ${t}`).join(`
317
- `),y=()=>_(`HTTP/1.1 ${e.status} ${e.statusText}\n${v}\n\n${e.body??``}`),b=()=>{let t=new Blob([e.body??``],{type:s||`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`response.${rtt[p]}`,r.click(),URL.revokeObjectURL(n)},x=()=>{f(`body`),window.setTimeout(()=>{o.current?.focus(),o.current?.getAction(`actions.find`)?.run()},0)};return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2.5 font-mono text-sm`,children:[(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`HTTP/1.1`}),(0,U.jsx)(`span`,{className:`font-semibold`,children:(0,U.jsx)(xJ,{code:e.status,icon:!1,statusText:e.statusText})})]}),(0,U.jsxs)(AO,{value:d,onValueChange:f,className:`flex min-h-0 grow flex-col`,children:[(0,U.jsxs)(jO,{className:`h-auto justify-start gap-1 self-start bg-transparent px-3 pt-1`,children:[(0,U.jsx)(MO,{value:`body`,"data-test":`test-result-body`,className:DJ,children:`Body`}),(0,U.jsxs)(MO,{value:`headers`,"data-test":`test-result-headers`,className:DJ,children:[`Headers (`,u,`)`]}),(0,U.jsxs)(MO,{value:`logs`,"data-test":`test-result-logs`,className:DJ,children:[`Logs (`,a.length,`)`]})]}),(0,U.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:[(0,U.jsx)(NO,{value:`body`,className:`mt-0 h-full data-[state=active]:flex`,children:(0,U.jsx)(`div`,{className:`h-full w-full`,children:(0,U.jsx)(yM,{options:ett,language:ntt[p],value:h,onMount:g})})}),(0,U.jsx)(NO,{value:`headers`,className:`mt-0 px-4 pt-2`,children:(0,U.jsxs)(`table`,{className:`w-full table-fixed border-collapse text-sm`,children:[(0,U.jsx)(`thead`,{children:(0,U.jsxs)(`tr`,{className:`text-left text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:[(0,U.jsx)(`th`,{className:`w-2/5 py-1.5 pr-4 font-medium`,children:`Header`}),(0,U.jsx)(`th`,{className:`py-1.5 font-medium`,children:`Value`})]})}),(0,U.jsx)(`tbody`,{children:Object.entries(e.headers).map(([e,t])=>(0,U.jsxs)(`tr`,{className:`border-t border-border/60 align-top`,children:[(0,U.jsx)(`td`,{className:`py-1.5 pr-4 font-mono break-words text-muted-foreground`,children:e}),(0,U.jsx)(`td`,{className:`py-1.5 font-mono break-words`,children:t})]},e))})]})}),(0,U.jsx)(NO,{value:`logs`,className:`mt-0 h-full`,children:(0,U.jsx)(`div`,{className:`h-full min-h-[300px]`,children:(0,U.jsx)($et,{logs:a})})})]})]}),(0,U.jsxs)(`div`,{className:`flex h-7 items-center justify-between border-t border-border px-2 font-mono text-xs text-muted-foreground`,children:[(0,U.jsxs)(mJ,{value:p,onValueChange:e=>m(e),children:[(0,U.jsx)(_J,{size:`xs`,"aria-label":`Response rendering`,className:`w-24 border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent dark:hover:bg-transparent`,children:OJ[p]}),(0,U.jsx)(vJ,{align:`start`,children:Object.keys(OJ).map(e=>(0,U.jsx)(bJ,{value:e,children:OJ[e]},e))})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{children:[ttt(l),n==null?``:`, ${n}ms`]}),(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{"aria-label":`Response actions`,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,U.jsx)(Od,{className:`size-4`})}),(0,U.jsxs)(XG,{align:`end`,children:[(0,U.jsxs)(QG,{onSelect:y,children:[(0,U.jsx)(_d,{className:`size-4`}),`Copy all`]}),(0,U.jsxs)(QG,{onSelect:()=>_(v),children:[(0,U.jsx)(Sd,{className:`size-4`}),`Copy headers`]}),(0,U.jsxs)(QG,{onSelect:()=>_(e.body??``),children:[(0,U.jsx)(Sd,{className:`size-4`}),`Copy body`]}),(0,U.jsxs)(QG,{onSelect:b,children:[(0,U.jsx)(Dd,{className:`size-4`}),`Save body…`]}),r?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rK,{}),(0,U.jsxs)(QG,{onSelect:r,children:[(0,U.jsx)(Kf,{className:`size-4`}),`Clear`]})]}):null,(0,U.jsx)(rK,{}),(0,U.jsxs)(QG,{onSelect:x,children:[(0,U.jsx)(kf,{className:`size-4`}),`Search`]})]})]})]})]})]})},att={[GM.PRODUCTION]:`Production`,[GM.PREVIEW]:`Preview`,[GM.WORKING_COPY]:`Working copy`},ott=e=>e.externalUsers?.[0]?.email||e.sub,AJ=e=>e.apiKeys?.find(e=>e.expiresOn===void 0||e.expiresOn===null||Date.parse(e.expiresOn)>Date.now())?.key,stt=({ape:e,onSelectKey:t,initialBucketId:n,initialConsumerSub:r})=>{let i=_T(e.account.name,e.project.name),a=(0,H.useMemo)(()=>(i.data?.defaultConfiguration??[]).flatMap(e=>e.apiKeyBucket?[{id:e.apiKeyBucket,env:e.environmentType}]:[]),[i.data]),o=(0,H.useMemo)(()=>a.find(t=>t.env===e.environment.environmentType)?.id??a[0]?.id,[a,e.environment.environmentType]),[s,c]=(0,H.useState)(n),l=s??o,[u,d]=(0,H.useState)(r),f=BM(l??``,{limit:100},{enabled:!!l}),p=f.data?.data??[],m=VM(l??``,u??``,{enabled:!!l&&!!u});return(0,H.useEffect)(()=>{if(m.data&&l&&u){let e=AJ(m.data);e&&t(e,{bucketId:l,consumerSub:u})}},[m.data]),i.isLoading?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading API key services…`}):a.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No API Key Service is configured for this project.`}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:`auth-api-key-service`,className:`text-xs font-medium text-muted-foreground`,children:`API Key Service`}),(0,U.jsxs)(mJ,{value:l,onValueChange:e=>{c(e),d(void 0)},children:[(0,U.jsx)(_J,{id:`auth-api-key-service`,className:`w-full`,children:(0,U.jsx)(gJ,{placeholder:`Select a service`})}),(0,U.jsx)(vJ,{children:a.map(e=>(0,U.jsx)(bJ,{value:e.id,children:att[e.env]??e.env},e.id))})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:`auth-api-key-consumer`,className:`text-xs font-medium text-muted-foreground`,children:`API Key`}),(0,U.jsxs)(mJ,{value:u,onValueChange:d,disabled:f.isLoading||p.length===0,children:[(0,U.jsx)(_J,{id:`auth-api-key-consumer`,className:`w-full`,children:(0,U.jsx)(gJ,{placeholder:f.isLoading?`Loading consumers…`:p.length===0?`No consumers in this service`:`Select a consumer`})}),(0,U.jsx)(vJ,{children:p.map(e=>(0,U.jsx)(bJ,{value:e.sub,children:ott(e)},e.sub))})]}),u&&m.isLoading?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading key…`}):u&&m.data&&!AJ(m.data)?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:`This consumer has no active key.`}):null]}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Sent as`,` `,(0,U.jsx)(`code`,{className:`font-mono text-foreground`,children:`Authorization: Bearer …`}),` `,`on every request.`]})]})},jJ=`Authorization`,MJ={none:`None`,basic:`Basic auth`,bearer:`Bearer token`,apiKey:`Zuplo API Key`},NJ=e=>Object.keys(e).find(e=>e.toLowerCase()===`authorization`),ctt=(e,t)=>{try{return btoa(`${e}:${t}`)}catch{return``}},PJ=e=>{let t=NJ(e),n=t?e[t]??``:``,r=n.match(/^\s*Bearer\s+(.*)$/i);if(r)return{type:`bearer`,token:r[1],username:``,password:``};let i=n.match(/^\s*Basic\s+(.*)$/i);if(i)try{let[e,...t]=atob(i[1]).split(`:`);return{type:`basic`,token:``,username:e,password:t.join(`:`)}}catch{}return{type:t?`bearer`:`none`,token:t?n:``,username:``,password:``}},ltt=({ape:e,headers:t,onChange:n,onPersist:r,authSelection:i,testId:a,allowApiKeyService:o=!0})=>{let s=Object.keys(MJ).filter(e=>o||e!==`apiKey`),c=PJ(t),[l,u]=(0,H.useState)(i?`apiKey`:c.type),[d,f]=(0,H.useState)(c.token),[p,m]=(0,H.useState)(c.username),[h,g]=(0,H.useState)(c.password),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(c.type!==`none`)return;let e=requestAnimationFrame(()=>b(!0));return()=>cancelAnimationFrame(e)},[]),(0,H.useEffect)(()=>{let e=PJ(t);u(i?`apiKey`:e.type),f(e.token),m(e.username),g(e.password)},[a]);let x=()=>{let e={...t},n=NJ(e);return n&&delete e[n],e},S=e=>{let n=x();return n[NJ(t)??jJ]=e,n},C=(e,r)=>{let i=x();e&&(i[NJ(t)??jJ]=e),n(i,r)},w=(e,t)=>C(e.trim()?`Bearer ${e}`:null,t),T=(e,t,n)=>C(e||t?`Basic ${ctt(e,t)}`:null,n),E=e=>{u(e),e===`none`?n(x(),!0):e===`bearer`?w(d,!0):e===`basic`&&T(p,h,!0)};return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,children:[(0,U.jsx)(`div`,{className:`min-h-0 grow overflow-y-auto p-4`,children:l===`none`?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This request won't send an authorization header.`}):l===`apiKey`?(0,U.jsx)(stt,{ape:e,initialBucketId:i?.bucketId,initialConsumerSub:i?.consumerSub,onSelectKey:(e,t)=>{f(e),n(S(`Bearer ${e}`),!0,t)}}):l===`basic`?(0,U.jsxs)(`div`,{className:`flex max-w-sm flex-col gap-3`,children:[(0,U.jsx)(iM,{type:`text`,placeholder:`Username`,value:p,autoComplete:`off`,"data-op-ignore":!0,onChange:e=>{m(e.target.value),T(e.target.value,h,!1)},onBlur:()=>r()}),(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(iM,{type:_?`text`:`password`,className:`pr-9`,placeholder:`Password`,value:h,autoComplete:`off`,"data-op-ignore":!0,onChange:e=>{g(e.target.value),T(p,e.target.value,!1)},onBlur:()=>r()}),(0,U.jsx)(`button`,{type:`button`,"aria-label":_?`Hide password`:`Show password`,className:`absolute right-1 top-1/2 -translate-y-1/2 rounded-sm p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground`,onClick:()=>v(e=>!e),children:_?(0,U.jsx)(Ad,{className:`size-4`}):(0,U.jsx)(jd,{className:`size-4`})})]})]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 pb-2`,children:[(0,U.jsx)(nf,{className:`size-4 shrink-0 text-muted-foreground`}),(0,U.jsx)(`input`,{type:_?`text`:`password`,className:W(`min-w-0 grow border-0 bg-transparent p-0 font-mono text-sm shadow-none outline-none focus:ring-0 placeholder:text-muted-foreground`),placeholder:`Paste a bearer token`,value:d,autoComplete:`off`,"data-op-ignore":!0,onChange:e=>{f(e.target.value),w(e.target.value,!1)},onBlur:()=>r()}),(0,U.jsx)(`button`,{type:`button`,"aria-label":_?`Hide token`:`Show token`,className:`shrink-0 rounded-sm p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,onClick:()=>v(e=>!e),children:_?(0,U.jsx)(Ad,{className:`size-4`}):(0,U.jsx)(jd,{className:`size-4`})})]})}),(0,U.jsx)(`div`,{className:`flex h-7 items-center border-t border-border px-2`,children:(0,U.jsxs)(JG,{modal:!1,open:y,onOpenChange:b,children:[(0,U.jsxs)(YG,{"aria-label":`Authorization type`,className:`flex h-6 w-40 items-center justify-between gap-1 rounded-md bg-transparent px-2 text-xs outline-none focus-visible:ring-0`,children:[MJ[l],(0,U.jsx)(td,{className:`size-3.5 opacity-50`})]}),(0,U.jsx)(XG,{align:`start`,side:`top`,className:`min-w-40`,children:(0,U.jsx)(eK,{value:l,onValueChange:e=>E(e),children:s.map(e=>(0,U.jsx)(tK,{value:e,trailingIndicator:!0,children:MJ[e]},e))})})]})})]})},FJ=({children:e,onClearValue:t,className:n,showClearButton:r,value:i})=>(0,U.jsxs)(`div`,{className:W(`relative`,n),children:[(0,U.jsx)(kf,{size:16,className:`absolute left-2.5 top-1/2 -translate-y-1/2 pb-0.5 text-muted-foreground`}),e,r&&i&&(0,U.jsx)(X,{variant:`ghost`,size:`icon-sm`,type:`button`,onClick:t,className:`absolute right-2 top-1/2 -translate-y-1/2`,children:(0,U.jsx)(ep,{size:16,className:`text-muted-foreground`})})]}),IJ={get:`text-blue-600 dark:text-blue-400`,head:`text-pink-600 dark:text-pink-400`,post:`text-green-600 dark:text-green-400`,put:`text-yellow-600 dark:text-yellow-400`,delete:`text-red-600 dark:text-red-400`,connect:`text-orange-600 dark:text-orange-400`,options:`text-teal-600 dark:text-teal-400`,trace:`text-fuchsia-600 dark:text-fuchsia-400`,patch:`text-orange-600 dark:text-orange-400`,multiple:`text-zuplo-600 dark:text-zuplo-400`},utt={get:`bg-blue-200 dark:bg-blue-900/40`,head:`bg-pink-200 dark:bg-pink-900/40`,post:`bg-green-200 dark:bg-green-900/40`,put:`bg-yellow-200 dark:bg-yellow-900/40`,delete:`bg-red-200 dark:bg-red-900/40`,connect:`bg-orange-200 dark:bg-orange-900/40`,options:`bg-teal-200 dark:bg-teal-900/40`,trace:`bg-fuchsia-200 dark:bg-fuchsia-900/40`,patch:`bg-orange-200 dark:bg-orange-900/40`,multiple:`bg-zuplo-200/75 dark:bg-zuplo-900/40`},LJ={get:`bg-blue-500`,head:`bg-pink-500`,post:`bg-green-500`,put:`bg-yellow-500`,delete:`bg-red-500`,connect:`bg-orange-500`,options:`bg-teal-500`,trace:`bg-fuchsia-500`,patch:`bg-orange-500`,multiple:`bg-zuplo-500`},RJ=({method:e,className:t})=>{let n=e.includes(`,`)?`multiple`:e;return(0,U.jsx)(`div`,{className:W(`rounded-lg text-center items-center flex justify-center h-5 px-2`,`text-xs font-semibold`,IJ[n],utt[n],t),"data-test":`route-method`,children:e.includes(`,`)?`MULTI`:e.toUpperCase()})},dtt=e=>e.split(`/`).pop()||e,ftt=({endpoints:e,selectedEndpointId:t,onSelect:n,isLoading:r})=>{let[i,a]=(0,H.useState)(``),o=(0,H.useMemo)(()=>{let t=i.trim().toLowerCase();return t?e.filter(e=>e.path.toLowerCase().includes(t)||e.method.toLowerCase().includes(t)||(e.summary?.toLowerCase().includes(t)??!1)):e},[e,i]),s=(0,H.useMemo)(()=>{let e=new Map;for(let t of o){let n=e.get(t.file);n?n.push(t):e.set(t.file,[t])}return[...e.entries()]},[o]),c=s.length>1;return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,U.jsx)(`div`,{className:`shrink-0 border-b border-border p-2`,children:(0,U.jsx)(FJ,{value:i,onClearValue:()=>a(``),showClearButton:i.length>0,children:(0,U.jsx)(iM,{value:i,size:`sm`,placeholder:`Filter endpoints…`,"aria-label":`Filter endpoints`,onChange:e=>a(e.target.value),className:`pl-8`})})}),(0,U.jsx)(`div`,{className:`min-h-0 grow overflow-y-auto p-1.5`,children:o.length===0?(0,U.jsx)(`div`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:r?`Loading endpoints…`:i?`No endpoints match your filter.`:`No routes to test.`}):(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map(([e,r])=>(0,U.jsxs)(`div`,{children:[c&&(0,U.jsx)(`div`,{title:e,className:`truncate px-2 py-1 font-medium text-[11px] text-muted-foreground uppercase tracking-wide`,children:dtt(e)}),(0,U.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r.map(e=>{let r=e.id===t;return(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-current":r,title:e.summary??e.path,className:W(`flex w-full flex-col gap-1 rounded-md px-2 py-1.5 text-left outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring`,r?`bg-accent text-foreground`:`hover:bg-accent/60`),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(RJ,{method:e.method,className:`shrink-0`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-foreground`,children:e.path})]}),e.summary?(0,U.jsx)(`span`,{className:`truncate pl-0.5 text-xs text-muted-foreground`,children:e.summary}):null]})},e.id)})})]},e))})})]})},zJ=e=>{try{return Array.from(new URLSearchParams(e??``).entries())}catch{return[]}},ptt=e=>{let t=new URLSearchParams;for(let[n,r]of e)n!==``&&t.append(n,r);return t.toString()},BJ=e=>{let t=e[e.length-1];return!t||t[0]!==``||t[1]!==``?[...e,[``,``]]:e},mtt=({value:e,onChange:t,onPersist:n,testId:r})=>{let[i,a]=(0,H.useState)(()=>BJ(zJ(e)));(0,H.useEffect)(()=>{a(BJ(zJ(e)))},[r]);let o=(e,r)=>{let i=BJ(e);a(i),t(ptt(i)),r&&n()},s=(e,t,n)=>{o(i.map((r,i)=>i===e?[t,n]:r),!1)},c=e=>{o(i.filter((t,n)=>n!==e),!0)};return(0,U.jsx)(`div`,{className:`flex flex-col gap-y-2 p-4`,children:i.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex flex-row gap-x-2`,children:[(0,U.jsx)(iM,{type:`text`,className:`grow`,placeholder:`Key`,value:e[0],onChange:n=>s(t,n.target.value,e[1]),onBlur:()=>n()}),(0,U.jsx)(iM,{type:`text`,className:`grow`,placeholder:`Value`,value:e[1],onChange:n=>s(t,e[0],n.target.value),onBlur:()=>n()}),(0,U.jsx)(`button`,{type:`button`,className:`rounded-sm p-2 enabled:hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>c(t),disabled:t===i.length-1,"aria-label":`Delete field`,children:(0,U.jsx)(Ed,{className:`h-4 w-4`})})]},t))})},htt=e=>{try{let t=JSON.parse(e);if(t&&typeof t==`object`&&`query`in t)return{query:typeof t.query==`string`?t.query:``,variables:t.variables===void 0?``:JSON.stringify(t.variables,null,2)}}catch{}return{query:e??``,variables:``}},gtt=({value:e,onChange:t,isReadOnly:n})=>{let r=(0,H.useRef)(htt(e)).current,[i,a]=(0,H.useState)(r.query),[o,s]=(0,H.useState)(r.variables),c=(e,n)=>{let r=n.trim(),i={query:e};if(r)try{i={query:e,variables:JSON.parse(r)}}catch{}t(JSON.stringify(i,null,2))};return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex min-h-0 grow flex-col`,children:[(0,U.jsx)(`div`,{className:`px-3 py-1 text-xs font-medium text-muted-foreground`,children:`Query`}),(0,U.jsx)(`div`,{className:`min-h-0 grow`,children:(0,U.jsx)(yM,{defaultValue:r.query,language:`graphql`,options:{readOnly:n,lineNumbers:`on`,minimap:{enabled:!1}},onChange:e=>{a(e??``),c(e??``,o)}})})]}),(0,U.jsxs)(`div`,{className:`flex h-2/5 min-h-0 flex-col border-t border-border`,children:[(0,U.jsx)(`div`,{className:`px-3 py-1 text-xs font-medium text-muted-foreground`,children:`Variables`}),(0,U.jsx)(`div`,{className:`min-h-0 grow`,children:(0,U.jsx)(yM,{defaultValue:r.variables,language:`json`,options:{readOnly:n,lineNumbers:`off`,minimap:{enabled:!1}},onChange:e=>{s(e??``),c(i,e??``)}})})]})]})},VJ=`Checkbox`,[_tt,vtt]=T(VJ),[ytt,btt]=_tt(VJ),HJ=H.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=H.useState(null),m=ve(t,e=>p(e)),h=H.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=Ct({prop:i,defaultProp:a??!1,onChange:l,caller:VJ}),y=H.useRef(_);return H.useEffect(()=>{let e=f?.form;if(e){let t=()=>v(y.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[f,v]),(0,U.jsxs)(ytt,{scope:n,state:_,disabled:s,children:[(0,U.jsx)(ac.button,{type:`button`,role:`checkbox`,"aria-checked":KJ(_)?`mixed`:_,"aria-required":o,"data-state":qJ(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onKeyDown:Xs(e.onKeyDown,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:Xs(e.onClick,e=>{v(e=>KJ(e)?!0:!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,U.jsx)(GJ,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`},defaultChecked:KJ(a)?!1:a})]})});HJ.displayName=VJ;var UJ=`CheckboxIndicator`,WJ=H.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,a=btt(UJ,n);return(0,U.jsx)(uc,{present:r||KJ(a.state)||a.state===!0,children:(0,U.jsx)(ac.span,{"data-state":qJ(a.state),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})});WJ.displayName=UJ;var xtt=`CheckboxBubbleInput`,GJ=H.forwardRef(({__scopeCheckbox:e,control:t,checked:n,bubbles:r=!0,defaultChecked:i,...a},o)=>{let s=H.useRef(null),c=ve(s,o),l=xq(n),u=Ce(t);H.useEffect(()=>{let e=s.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(l!==n&&i){let t=new Event(`click`,{bubbles:r});e.indeterminate=KJ(n),i.call(e,KJ(n)?!1:n),e.dispatchEvent(t)}},[l,n,r]);let d=H.useRef(KJ(n)?!1:n);return(0,U.jsx)(ac.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:i??d.current,...a,tabIndex:-1,ref:c,style:{...a.style,...u,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});GJ.displayName=xtt;function KJ(e){return e===`indeterminate`}function qJ(e){return KJ(e)?`indeterminate`:e?`checked`:`unchecked`}var JJ=HJ,Stt=WJ,YJ=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(JJ,{ref:n,className:W(`peer h-4 w-4 shrink-0 rounded-sm border shadow-xs border-input ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-zuplo-600 data-[state=checked]:border-zuplo-500 data-[state=checked]:text-primary-foreground data-[state=indeterminate]:bg-zuplo-600 data-[state=indeterminate]:border-zuplo-500 data-[state=indeterminate]:text-primary-foreground`,e),...t,children:(0,U.jsx)(Stt,{className:W(`flex items-center justify-center text-current`),children:t.checked===`indeterminate`?(0,U.jsx)(hf,{size:12,strokeWidth:3.5}):(0,U.jsx)(ed,{size:12,strokeWidth:3.5})})}));YJ.displayName=JJ.displayName;var XJ=e=>[...Object.entries(e).map(([e,t])=>({enabled:!0,key:e,value:t})),{enabled:!0,key:``,value:``}],Ctt=e=>{let t=e[e.length-1];return!t||t.key!==``||t.value!==``?[...e,{enabled:!0,key:``,value:``}]:e},ZJ=e=>{let t={};for(let n of e)n.enabled&&n.key!==``&&(t[n.key]=n.value);return t},QJ=({value:e,onChange:t,testId:n,keyPlaceholder:r=`name`,valuePlaceholder:i=`value`})=>{let[a,o]=(0,H.useState)(()=>XJ(e));(0,H.useEffect)(()=>{o(XJ(e))},[n]);let s=(e,n)=>{let r=Ctt(e);o(r),t(ZJ(r),n)},c=(e,t)=>{s(a.map((n,r)=>r===e?{...n,...t}:n),!1)},l=e=>{s(a.map((t,n)=>n===e?{...t,enabled:!t.enabled}:t),!0)},u=e=>{s(a.filter((t,n)=>n!==e),!0)};return(0,U.jsx)(`div`,{className:`flex flex-col`,children:a.map((e,n)=>{let o=n===a.length-1,s=e.key===``&&e.value===``;return(0,U.jsxs)(`div`,{className:`group flex items-center gap-2 border-b border-border/60 py-1 pr-1`,children:[(0,U.jsx)(YJ,{"aria-label":`Enabled`,className:`shrink-0`,checked:e.enabled&&!(o&&s),disabled:o&&s,onCheckedChange:()=>l(n)}),(0,U.jsx)(`input`,{type:`text`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,placeholder:r,value:e.key,onChange:e=>c(n,{key:e.target.value}),onBlur:()=>t(ZJ(a),!0),className:W(`w-2/5 shrink-0 border-0 bg-transparent p-0 font-mono text-sm text-foreground shadow-none outline-none focus:ring-0 placeholder:text-muted-foreground/60`,!e.enabled&&`line-through opacity-50`)}),(0,U.jsx)(`input`,{type:`text`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,placeholder:i,value:e.value,onChange:e=>c(n,{value:e.target.value}),onBlur:()=>t(ZJ(a),!0),className:W(`min-w-0 grow border-0 bg-transparent p-0 font-mono text-sm text-foreground shadow-none outline-none focus:ring-0 placeholder:text-muted-foreground/60`,!e.enabled&&`line-through opacity-50`)}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Delete`,onClick:()=>u(n),className:W(`shrink-0 rounded-sm p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,o&&s?`invisible`:`opacity-0 group-hover:opacity-100`),children:(0,U.jsx)(ep,{className:`size-3.5`})})]},n)})})},$J=({size:e,...t})=>(0,U.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e??`1em`,height:e??`1em`,fill:`currentColor`,fillRule:`evenodd`,viewBox:`0 0 24 24`,...t,children:[(0,U.jsx)(`title`,{children:`Model Context Protocol`}),(0,U.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 0 0-3.61 0l-9.626 9.44a.863.863 0 0 1-1.203 0 .823.823 0 0 1 0-1.18l9.626-9.44a4.313 4.313 0 0 1 6.016 0 4.116 4.116 0 0 1 1.204 3.54 4.3 4.3 0 0 1 3.609 1.18l.05.05a4.115 4.115 0 0 1 0 5.9l-8.706 8.537a.274.274 0 0 0 0 .393l1.788 1.754a.823.823 0 0 1 0 1.18.863.863 0 0 1-1.203 0l-1.788-1.753a1.92 1.92 0 0 1 0-2.754l8.706-8.538a2.47 2.47 0 0 0 0-3.54l-.05-.049a2.588 2.588 0 0 0-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 0 1-1.204 0 .823.823 0 0 1 0-1.18l7.273-7.133a2.47 2.47 0 0 0-.003-3.537z`}),(0,U.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 0 0 0-1.18.863.863 0 0 0-1.204 0l-7.119 6.982a4.115 4.115 0 0 0 0 5.9 4.314 4.314 0 0 0 6.016 0l7.12-6.982a.823.823 0 0 0 0-1.18.863.863 0 0 0-1.204 0l-7.119 6.982a2.588 2.588 0 0 1-3.61 0 2.47 2.47 0 0 1 0-3.54l7.12-6.982z`})]}),eY=`flex h-6 items-center gap-1 rounded-md border border-input bg-background px-2 text-xs outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30`,wtt=({value:e,onChange:t,isReadOnly:n,listMcpTools:r})=>{let i=(0,H.useRef)(qN(e)?e:KN).current,[a,o]=(0,H.useState)(i),[s,c]=(0,H.useState)(0),[l,u]=(0,H.useState)({status:`idle`,tools:[]});(0,H.useEffect)(()=>{qN(e)||t(i)},[]);let d=e=>{o(e),c(e=>e+1),t(e)};return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 px-3 py-2`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,U.jsx)($J,{className:`size-3.5`}),`MCP request`]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r?(0,U.jsxs)(JG,{onOpenChange:e=>{!e||!r||l.status===`loading`||(u({status:`loading`,tools:[]}),r().then(e=>{u(e.ok?{status:`loaded`,tools:e.tools}:{status:`error`,tools:[],error:e.error})}))},children:[(0,U.jsxs)(YG,{disabled:n,className:eY,children:[`Call a tool`,(0,U.jsx)(td,{className:`size-3.5 opacity-50`})]}),(0,U.jsx)(XG,{align:`end`,className:`max-w-xs`,children:l.status===`loading`?(0,U.jsxs)(QG,{disabled:!0,className:`justify-center gap-2`,children:[(0,U.jsx)(cf,{className:`size-3.5 animate-spin`}),`Loading tools…`]}):l.status===`error`?(0,U.jsx)(QG,{disabled:!0,className:`whitespace-normal`,children:l.error??`Couldn't load tools.`}):l.tools.length===0?(0,U.jsx)(QG,{disabled:!0,children:`No tools found.`}):l.tools.map(e=>(0,U.jsxs)(QG,{className:`flex-col items-start gap-0.5`,onSelect:()=>d(QVe(e)),children:[(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),e.description?(0,U.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:e.description}):null]},e.name))})]}):null,(0,U.jsxs)(JG,{children:[(0,U.jsxs)(YG,{disabled:n,className:eY,children:[`Insert request`,(0,U.jsx)(td,{className:`size-3.5 opacity-50`})]}),(0,U.jsx)(XG,{align:`end`,children:WN.map(e=>(0,U.jsxs)(QG,{onSelect:()=>d(GN(e)),children:[(0,U.jsx)(`span`,{className:`flex-1`,children:e.label}),(0,U.jsx)(`span`,{className:`ml-4 font-mono text-xs text-muted-foreground`,children:e.method})]},e.id))})]})]})]}),(0,U.jsx)(`div`,{className:`min-h-0 grow`,children:(0,U.jsx)(yM,{defaultValue:a,language:`json`,options:{readOnly:n,lineNumbers:`on`,minimap:{enabled:!1}},onChange:e=>{o(e??``),t(e??``)}},s)})]})},Ttt=({labelClassName:e,label:t,fieldName:n,span:r,children:i})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:n,className:(0,eM.default)(`col-span-1 block text-sm font-medium text-foreground text-right`,e),children:t}),(0,U.jsx)(`div`,{className:`col-span-${r} flex flex-row items-center`,children:i})]}),Ett=({isReadOnly:e,requestBody:t,language:n,onBodyChange:r,onPersist:i,bare:a=!1})=>{let[o,s]=(0,H.useState)(t),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(),[f,p]=(0,H.useState)();(0,H.useEffect)(()=>{f?.dispose();let e=u?.onDidBlurEditorText(()=>{i()});p(e),r(t),l(!1)},[u,t,o]);let m=(0,U.jsx)(yM,{defaultValue:t,onMount:e=>{d(e)},options:{readOnly:e,lineNumbers:`off`,minimap:{enabled:!1},language:n},onChange:e=>{c||l(JSON.stringify(e)!==JSON.stringify(t)),(c||JSON.stringify(e)!==JSON.stringify(t))&&(r(e),s(e))}});return a?(0,U.jsx)(`div`,{className:`h-full w-full`,children:m}):(0,U.jsx)(Ttt,{label:`Body`,fieldName:`Body`,span:5,children:(0,U.jsx)(`div`,{className:`w-full h-40 rounded-sm border-border border p-2`,children:m})})},Dtt=e=>{let t=[],n=e.match(/^[a-zA-Z][\w+.-]*:\/\//),r=e;n&&(t.push({text:n[0],className:`text-sky-600 dark:text-sky-400`}),r=e.slice(n[0].length));let i=r.indexOf(`?`),a=i===-1?r:r.slice(0,i),o=i===-1?``:r.slice(i),s=a.indexOf(`/`),c=s===-1?a:a.slice(0,s),l=s===-1?``:a.slice(s);if(c&&t.push({text:c,className:`text-foreground`}),l&&t.push({text:l,className:`text-emerald-600 dark:text-emerald-400`}),o){t.push({text:`?`,className:`text-muted-foreground`});let e=!0;for(let n of o.slice(1).split(/([&=])/))n===`&`?(t.push({text:`&`,className:`text-muted-foreground`}),e=!0):n===`=`?(t.push({text:`=`,className:`text-muted-foreground`}),e=!1):n!==``&&t.push({text:n,className:e?`text-violet-600 dark:text-violet-400`:`text-amber-600 dark:text-amber-400`})}return t},Ott=({value:e,onChange:t,onBlur:n})=>{let r=(0,H.useRef)(null),i=(0,H.useRef)(null),a=()=>{i.current&&r.current&&(i.current.scrollLeft=r.current.scrollLeft)};return(0,U.jsxs)(`div`,{className:`relative flex min-w-0 grow items-center`,children:[(0,U.jsx)(`div`,{ref:i,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 flex items-center overflow-hidden whitespace-pre px-3 font-mono text-sm`,children:Dtt(e).map((e,t)=>(0,U.jsx)(`span`,{className:e.className,children:e.text},t))}),(0,U.jsx)(`input`,{ref:r,type:`text`,name:`url`,"aria-label":`Request URL`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),onBlur:()=>n(),onScroll:a,className:`min-w-0 grow border-0 bg-transparent px-3 font-mono text-sm text-transparent caret-foreground shadow-none outline-none focus:ring-0`})]})},tY=`rounded-md px-2.5 py-1 text-sm font-medium text-muted-foreground data-[state=active]:bg-accent data-[state=active]:text-foreground data-[state=active]:shadow-none`,ktt=({phase:e,onSkip:t})=>(0,U.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 px-6 text-center`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Let's wait for the latest version to land…`}),(0,U.jsx)(`ul`,{className:`flex flex-col gap-3 text-sm`,children:(e===`waiting-for-build`?[{label:`Building the gateway`,status:`active`},{label:`Deploying your gateway`,status:`pending`},{label:`Executing test request`,status:`pending`}]:e===`verifying-deployment`?[{label:`Building the gateway`,status:`done`},{label:`Deploying your gateway`,status:`active`},{label:`Executing test request`,status:`pending`}]:[{label:`Building the gateway`,status:`done`},{label:`Deploying your gateway`,status:`done`},{label:`Executing test request`,status:`active`}]).map(n=>(0,U.jsxs)(`li`,{className:`flex items-center gap-2.5`,children:[n.status===`done`?(0,U.jsx)(ld,{className:`size-4 shrink-0 text-green-600 dark:text-green-500`}):n.status===`active`?(0,U.jsx)(cf,{className:`size-4 shrink-0 animate-spin text-foreground`}):(0,U.jsx)(hd,{className:`size-4 shrink-0 text-muted-foreground/40`}),(0,U.jsx)(`span`,{className:W(n.status===`active`?`font-medium text-foreground`:`text-muted-foreground`),children:n.label}),t&&e!==`executing`&&n.label===`Building the gateway`?(0,U.jsx)(`button`,{type:`button`,onClick:t,className:`-my-0.5 rounded px-1.5 py-0.5 text-sm font-normal text-muted-foreground/70 hover:bg-accent hover:text-foreground`,children:`Skip`}):null]},n.label))})]}),Att=({bodyType:e,methodHasBody:t,onBodyTypeChange:n})=>{let[r,i]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{if(!t||e!==`none`)return;let n=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(n)},[]),(0,U.jsxs)(JG,{modal:!1,open:r,onOpenChange:i,children:[(0,U.jsxs)(YG,{"aria-label":`Body type`,disabled:!t,className:`flex h-6 w-28 items-center justify-between gap-1 rounded-md bg-transparent px-2 text-xs outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50`,children:[QN[e],(0,U.jsx)(td,{className:`size-3.5 opacity-50`})]}),(0,U.jsx)(XG,{align:`start`,side:`top`,children:(0,U.jsx)(eK,{value:e,onValueChange:e=>n(e),children:Object.keys(QN).map(e=>(0,U.jsx)(tK,{value:e,trailingIndicator:!0,children:QN[e]},e))})})]})},jtt=({ape:e,url:t,allowedMethods:n,testRequest:r,bodySeedValue:i,urlValue:a,bodyType:o,activeTab:s,onActiveTabChange:c,requesting:l,buildReadinessPhase:u=`idle`,error:d,testResponse:f,durationMs:p,requestId:m,isReadOnly:h,shouldAllowLocalSaving:g,shouldSaveLocally:_,showRebuildWarning:v,operationId:y,path:b,headersSeed:x,authSeed:S,paramsSeed:C,allowApiKeyService:w=!0,history:T,onRestoreFromHistory:E,onClearHistory:D,listMcpTools:O,onChange:k,onUrlChange:A,onClear:j,onParamsChange:M,onHeadersChangeFromHeaders:N,onHeadersChangeFromAuth:P,onBodyTypeChange:F,onPersist:I,onLocalSaveToggle:L,onSend:R,onStop:z,onSkipBuildWait:B,onClearResponse:ee,onClose:V,buildBadge:te,endpoints:ne,selectedEndpointId:re,onSelectEndpoint:ie,isEndpointPanelOpen:ae=!1,onToggleEndpointPanel:oe,endpointsLoading:se=!1})=>{let[ce,le]=(0,H.useState)(!1),ue=!!ie&&!!oe&&(!!ne?.length||se),de=e=>{navigator.clipboard?.writeText(e)},fe=r.headers??{},pe=Object.keys(r.headers??{}).length,me=Object.keys(r.headers??{}).some(e=>e.toLowerCase()===`authorization`),he=ZN(r.method),ge=rHe[o],_e=Object.fromEntries(new URLSearchParams((r.pathname??``).split(`?`)[1]??``)),ve=Object.keys(_e).length,ye=(()=>{if(!t)return null;try{let e=new URL(t);return`${e.pathname}${e.search}`}catch{return null}})(),be=ye!=null&&(r.pathname??``)!==ye||ve>0||pe>0||(r.body??``).length>0,xe=(0,U.jsx)(`span`,{className:`size-1.5 rounded-full bg-current opacity-70`}),Se=(0,U.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,U.jsxs)(AO,{value:s,onValueChange:c,className:`flex min-h-0 grow flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 pt-2.5`,children:[(0,U.jsxs)(jO,{className:`h-auto gap-1 bg-transparent p-0`,children:[(0,U.jsxs)(MO,{value:`params`,className:`${tY} gap-1.5`,children:[`Params`,ve?(0,U.jsx)(XD,{variant:`secondary`,size:`sm`,className:`rounded-full`,children:ve}):null]}),(0,U.jsxs)(MO,{value:`headers`,className:`${tY} gap-1.5`,children:[`Headers`,pe?(0,U.jsx)(XD,{variant:`secondary`,size:`sm`,className:`rounded-full`,children:pe}):null]}),(0,U.jsxs)(MO,{value:`auth`,className:`${tY} gap-1.5`,children:[`Auth `,me?xe:null]}),(0,U.jsxs)(MO,{value:`body`,className:`${tY} gap-1.5`,children:[`Body `,he&&o!==`none`?xe:null]})]}),g&&(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{"aria-label":`More options`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,U.jsx)(Od,{className:`size-4`})}),(0,U.jsx)(XG,{align:`end`,children:(0,U.jsx)($G,{checked:_,onCheckedChange:L,children:`Save request in browser storage`})})]})]}),(0,U.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:[(0,U.jsx)(NO,{value:`params`,className:`mt-0 px-3 pt-2`,children:(0,U.jsx)(QJ,{value:_e,onChange:M,testId:`${b??y}:p${C}`})}),(0,U.jsx)(NO,{value:`headers`,className:`mt-0 px-3 pt-2`,children:(0,U.jsx)(QJ,{value:r.headers,onChange:N,testId:`${b??y}:h${x}`})}),(0,U.jsx)(NO,{value:`auth`,className:`mt-0 h-full data-[state=active]:flex`,children:(0,U.jsx)(ltt,{ape:e,headers:r.headers,onChange:P,authSelection:r.authSelection,testId:`${b??y}:a${S}`,onPersist:I,allowApiKeyService:w})}),(0,U.jsxs)(NO,{value:`body`,className:`mt-0 h-full data-[state=active]:flex data-[state=active]:flex-col`,children:[(0,U.jsx)(`div`,{className:`min-h-0 grow overflow-hidden`,children:he?o===`none`?(0,U.jsx)(`div`,{className:`flex h-full w-full items-center justify-center px-4 text-center text-sm text-muted-foreground`,children:`This request does not send a body.`}):o===`form`?(0,U.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,U.jsx)(mtt,{value:r.body??``,onChange:e=>k(`body`,e),onPersist:I,testId:b??y})}):o===`graphql`?(0,U.jsx)(gtt,{value:r.body??``,onChange:e=>k(`body`,e),isReadOnly:h&&!g},`gql-${b??y}`):o===`mcp`?(0,U.jsx)(wtt,{value:r.body??``,onChange:e=>k(`body`,e),isReadOnly:h&&!g,listMcpTools:O},`mcp-${b??y}`):(0,U.jsx)(Ett,{bare:!0,requestBody:i,onBodyChange:e=>k(`body`,e),isReadOnly:h&&!g,language:ge,onPersist:I}):(0,U.jsxs)(`div`,{className:`flex h-full w-full items-center justify-center px-4 text-center text-sm text-muted-foreground`,children:[r.method,` requests don't send a body.`]})}),(0,U.jsx)(`div`,{className:`flex h-7 shrink-0 items-center border-t border-border px-2`,children:(0,U.jsx)(Att,{bodyType:o,methodHasBody:he,onBodyTypeChange:F})})]})]})]})}),Ce=d?(0,U.jsxs)(`div`,{className:`flex h-full items-center justify-center p-4 text-center text-red-600`,children:[(0,U.jsx)(od,{className:`mr-2 size-4 shrink-0`}),(0,U.jsxs)(`span`,{children:[`Error: `,d]})]}):l&&u!==`idle`?(0,U.jsx)(ktt,{phase:u,onSkip:B}):l?(0,U.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,U.jsx)(jf,{className:`mr-2 size-4 animate-pulse`}),`Sending request…`]}):f?(0,U.jsx)(itt,{result:f,requestId:m,durationMs:p,onClear:ee}):(0,U.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 px-6 text-center text-muted-foreground`,children:[(0,U.jsx)(jf,{className:`size-6 opacity-60`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Send your request to see the response here.`})]});return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,U.jsx)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-border p-2`,children:(0,U.jsxs)(`div`,{className:`flex items-stretch gap-2`,children:[(0,U.jsxs)(`div`,{className:`relative flex h-10 min-w-0 grow items-stretch overflow-hidden rounded-lg border border-input bg-background transition-shadow focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 dark:bg-input/30`,children:[T&&(0,U.jsxs)(dT,{open:ce,onOpenChange:le,children:[(0,U.jsx)(fT,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Request history`,title:`Request history`,className:`flex h-full w-10 shrink-0 items-center justify-center border-r border-input text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-0`,children:(0,U.jsx)(Qd,{className:`size-4`})})}),(0,U.jsx)(pT,{align:`start`,className:`w-96 p-0`,children:(0,U.jsx)(Get,{entries:[...T].reverse(),onRestore:e=>{E?.(e),le(!1)},onClear:D})})]}),(0,U.jsxs)(mJ,{value:r.method??`GET`,onValueChange:e=>k(`method`,e,!0),children:[(0,U.jsx)(_J,{"aria-label":`Method`,className:`h-full! w-24 shrink-0 justify-center gap-1 rounded-none border-0 border-r border-input bg-transparent px-3 font-mono font-semibold shadow-none focus-visible:ring-0 dark:bg-transparent`,children:(0,U.jsx)(`span`,{className:XN[r.method]??``,children:r.method??`GET`})}),(0,U.jsx)(vJ,{align:`start`,className:`font-mono`,children:YN.map(e=>(0,U.jsxs)(bJ,{value:e,children:[(0,U.jsx)(`span`,{className:XN[e]??``,children:e}),n.includes(e)?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:` *`}):null]},e))})]}),(0,U.jsx)(Ott,{value:a,onChange:A,onBlur:I}),be&&(0,U.jsx)(`button`,{type:`button`,"aria-label":`Clear request`,title:`Clear the request`,onClick:j,className:`flex shrink-0 items-center px-2 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(xpe,{className:`size-4`})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Copy URL`,title:`Copy URL`,onClick:()=>de(a),className:`flex shrink-0 items-center pr-0.5 pl-2 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(Sd,{className:`size-4`})}),(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{"aria-label":`Copy request as…`,title:`Copy as…`,className:`flex shrink-0 items-center pr-2 pl-0.5 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground`,children:(0,U.jsx)(td,{className:`size-3.5`})}),(0,U.jsxs)(XG,{align:`end`,children:[(0,U.jsxs)(QG,{onSelect:()=>de(oHe(r.method,a,fe,r.body)),children:[(0,U.jsx)(Wf,{className:`size-4`}),`Copy as cURL`]}),(0,U.jsxs)(QG,{onSelect:()=>de(sHe(r.method,a,fe,r.body)),children:[(0,U.jsx)(vd,{className:`size-4`}),`Copy as fetch`]}),(0,U.jsxs)(QG,{onSelect:()=>de(cHe(r.method,a,fe,r.body)),children:[(0,U.jsx)(Nd,{className:`size-4`}),`Copy as HTTP`]})]})]}),(0,U.jsxs)(`button`,{type:`button`,disabled:l&&!z,onClick:l&&z?z:R,"aria-label":l&&z?`Stop request`:void 0,className:`relative flex h-full shrink-0 items-center justify-center border-l border-input bg-brand px-4 text-sm font-medium text-brand-foreground transition-colors hover:bg-brand/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[(0,U.jsxs)(`span`,{className:W(`flex items-center gap-2`,l&&`invisible`),children:[`Send`,(0,U.jsxs)(aK,{className:`max-sm:hidden`,children:[(0,U.jsx)(iK,{className:`bg-brand-foreground/15 text-brand-foreground`,children:fP(`meta`)}),(0,U.jsx)(iK,{className:`bg-brand-foreground/15 text-brand-foreground`,children:`↵`})]})]}),l&&(0,U.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:z?(0,U.jsx)(Bf,{className:`size-3.5 fill-current`}):(0,U.jsx)(cf,{className:`size-4 animate-spin`})})]})]}),V&&(0,U.jsx)(`button`,{type:`button`,"aria-label":`Close`,onClick:V,className:`flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,U.jsx)(ep,{className:`size-4`})})]})}),(0,U.jsxs)(`div`,{className:`flex min-h-0 min-w-0 grow gap-2 bg-muted p-2`,children:[ue&&ae&&ie&&(0,U.jsx)(`div`,{className:`w-64 shrink-0 overflow-hidden rounded-lg border border-border bg-background`,children:(0,U.jsx)(ftt,{endpoints:ne??[],selectedEndpointId:re,onSelect:ie,isLoading:se})}),(0,U.jsx)(`div`,{className:`h-full min-h-0 min-w-0 grow overflow-hidden rounded-lg border border-border bg-background`,children:(0,U.jsxs)(_q,{direction:`horizontal`,children:[(0,U.jsx)(vq,{defaultSize:50,minSize:30,children:Se}),(0,U.jsx)(yq,{}),(0,U.jsx)(vq,{defaultSize:50,minSize:30,children:Ce})]})})]}),(ue||v||te)&&(0,U.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-3 border-t border-border px-3 text-xs text-muted-foreground`,children:[ue&&(0,U.jsxs)(`button`,{type:`button`,onClick:oe,"aria-pressed":ae,title:ae?`Hide endpoints`:`Show endpoints`,className:`-ml-1 flex items-center gap-1.5 rounded-md px-1.5 py-1 outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[ae?(0,U.jsx)(_f,{className:`size-3.5`}):(0,U.jsx)(vf,{className:`size-3.5`}),`Endpoints`]}),v&&(0,U.jsxs)(`span`,{className:`flex items-center text-zuplo-600`,children:[(0,U.jsx)(hd,{className:`mr-1 size-2 shrink-0 fill-zuplo-highlight text-zuplo-600`}),`Undeployed changes. Press`,(0,U.jsxs)(aK,{className:`mx-1.5 text-foreground`,children:[(0,U.jsx)(iK,{children:fP(`meta`)}),(0,U.jsx)(`span`,{children:`+`}),(0,U.jsx)(iK,{children:`S`})]}),`to deploy.`]}),te&&(0,U.jsx)(`div`,{className:`ml-auto flex items-center`,children:te})]})]})},nY=new aP,Mtt=`The latest build failed, so your changes aren't live yet. Check the build logs, fix the error, and redeploy before testing.`,Ntt=`Timed out waiting for the gateway build to go live. It may be stuck — check the build status and try again.`,rY=({ape:e,url:t,apiTest:n,allowedMethods:r=YN,shouldAllowLocalSaving:i,operationId:a,path:o,onRequestChange:s,onBeforeFire:c,onTestDirtied:l,showRebuildWarning:u,onClose:d,endpoints:f,selectedEndpointId:p,onSelectEndpoint:m,isEndpointPanelOpen:h,onToggleEndpointPanel:g,endpointsLoading:_})=>{if(i&&!a)throw Error(`operationId is required to save locally`);let v=(a?nY.getTest(e.account.name,e.project.name,e.environment.name,a):void 0)?.shouldSaveTest!==!1,y=gHe(e.environment),{phase:b,awaitReady:x,skip:S}=bHe(e.environment,y),C=(y??``).replace(/\/$/,``),w=Cp(e=>e.testResponse),T=Cp(e=>e.setTestResponse),[E,D]=(0,H.useState)(n),[O,k]=(0,H.useState)(`${C}${n.pathname??``}`),[A,j]=(0,H.useState)(null),M=Cp(e=>e.appendExecutionHistory),N=Cp(e=>e.clearExecutionHistory),P=o??``,F=Cp(xp(t=>t.executionHistory.filter(t=>t.account===e.account.name&&t.project===e.project.name&&t.environment===e.environment.name&&t.path===P))),[I,L]=(0,H.useState)(!1),R=(0,H.useRef)(null),[z,B]=(0,H.useState)(),[ee,V]=(0,H.useState)(),[te,ne]=(0,H.useState)(v),[re,ie]=(0,H.useState)(ZN(n.method)?`body`:`headers`),[ae,oe]=(0,H.useState)(()=>$N(n)),[se,ce]=(0,H.useState)(0),[le,ue]=(0,H.useState)(0),[de,fe]=(0,H.useState)(0),pe=e.environment.environmentType!==GM.WORKING_COPY,{celebrate:me}=uHe(),{logEvent:he,captureException:ge}=on(),_e=oP();(0,H.useEffect)(()=>{D(n),oe($N(n)),k(`${C}${n.pathname??``}`)},[o]),(0,H.useEffect)(()=>{k(`${C}${E.pathname??``}`)},[C]);let ve=(0,H.useCallback)(async()=>{let t={...E.headers},n=Object.keys(t).find(e=>e.toLowerCase()===`content-type`)??`content-type`;t[n]=`application/json`;let r=Object.keys(t).find(e=>e.toLowerCase()===`accept`)??`accept`;t[r]=`application/json, text/event-stream`;let i={...E,method:`POST`,headers:t,body:KN};try{let t=await(await _e({environmentName:e.environment.name,testRequest:i,overrideUrl:y})).json(),n=tHe(t.body??``);return n.ok?n:typeof t.status==`number`&&t.status>=400?{ok:!1,error:`The MCP server responded ${t.status}${t.statusText?` ${t.statusText}`:``}.`}:n}catch(e){return{ok:!1,error:e instanceof Error?e.message:`Request failed`}}},[E,_e,e,y]),ye=async()=>{let t=y;if(!t){j(it);return}let n=new AbortController;R.current=n;let{signal:r}=n;L(!0),T(void 0),j(null);let i=await x(r);if(r.aborted)return;if(i===`build-failed`){L(!1),j(Mtt);return}if(i===`timeout`){L(!1),j(Ntt);return}let a=`zuplo-request-id`,o={...E.headers},s={...E,headers:o};if([`GET`,`HEAD`].includes(s.method))delete s.body;else if(ae===`graphql`&&s.body?.trim()){let e=!1;try{let t=JSON.parse(s.body);e=!!t&&typeof t==`object`&&`query`in t}catch{e=!1}e||(s.body=JSON.stringify({query:s.body}))}let l=s.headers[a]??Ne();s.headers[a]=l,B(l),c?.(l);let u=Date.now(),d=performance.now(),f=DHe(t);try{let n=await(await _e({environmentName:e.environment.name,testRequest:s,overrideUrl:t})).json();if(r.aborted)return;let i=Math.round(performance.now()-d);he(`test-console-fired`,{account:e.account.name,project:e.project.name,environment:e.environment.name,environmentType:e.environment.environmentType,httpMethod:s.method,httpStatusCode:n.status,durationMs:i,targetHost:f,cloudflareErrorCode:THe(n.body),edgeServer:EHe(n.headers,`server`)}),L(!1),V(i),T(n),me(`FIRST_200_TEST`,n),M({id:`${u}-${l}`,account:e.account.name,project:e.project.name,path:P,environment:e.environment.name,status:n.status,timestamp:u,durationMs:i,bodyType:ae,request:{...E,headers:{...E.headers}}})}catch(t){if(r.aborted)return;let n=Math.round(performance.now()-d),i=t instanceof ut,a=t instanceof Error?t.message:`Unknown error`;L(!1),j(a),he(`test-console-fired-error`,{account:e.account.name,project:e.project.name,environment:e.environment.name,environmentType:e.environment.environmentType,httpMethod:s.method,durationMs:n,targetHost:f,errorMessage:a,testProxyError:i,testProxyErrorCode:i?t.code:void 0}),ge(t)}},be=()=>{ye()},xe=()=>{R.current?.abort(),L(!1),j(null)},Se=()=>{I?xe():be()},Ce=t=>{let n={...t.request,headers:{...t.request.headers}};D(n),oe(t.bodyType??$N(n)),k(`${C}${n.pathname??``}`),fe(e=>e+1),ce(e=>e+1),ue(e=>e+1),j(null),T(void 0),je(n),he(`test-console-history-restored`,{account:e.account.name,project:e.project.name,environment:e.environment.name,httpMethod:n.method})},we=()=>{N(t=>t.account===e.account.name&&t.project===e.project.name&&t.environment===e.environment.name&&t.path===P)};pP(`meta+enter`,Se);let Te=(e,t,n)=>{let r={...E,[e]:t};D(r),n?je(r):l?.()},Ee=e=>{k(e),Te(`pathname`,tP(e,C)),fe(e=>e+1)},De=()=>{let e=t?tP(t,C):(E.pathname??``).split(`?`)[0],n={...E,headers:{},body:``,pathname:e,authSelection:void 0};D(n),k(`${C}${e}`),oe(`none`),fe(e=>e+1),ce(e=>e+1),ue(e=>e+1),je(n)},Oe=(e,t)=>{let n=(E.pathname??``).split(`?`)[0],r=new URLSearchParams(e).toString(),i=r?`${n}?${r}`:n;k(`${C}${i}`),Te(`pathname`,i,t)},ke=(e,t)=>{Te(`headers`,e,t),ue(e=>e+1)},Ae=(e,t,n)=>{let r={...E,headers:e,authSelection:n??void 0};D(r),t?je(r):l?.(),ce(e=>e+1)},je=t=>{let n=t??E;te&&a&&nY.writeTest({account:e.account.name,project:e.project.name,environment:e.environment.name,operationId:a,test:n}),s(n)};return(0,U.jsx)(jtt,{ape:e,url:t,allowedMethods:r,testRequest:E,bodySeedValue:n.body,urlValue:O,bodyType:ae,activeTab:re,onActiveTabChange:ie,requesting:I,buildReadinessPhase:b,error:A,testResponse:w,durationMs:ee,requestId:z,isReadOnly:pe,shouldAllowLocalSaving:i,shouldSaveLocally:te,showRebuildWarning:u,operationId:a,path:o,headersSeed:se,authSeed:le,paramsSeed:de,history:F,onRestoreFromHistory:Ce,onClearHistory:we,listMcpTools:ve,onChange:Te,onUrlChange:Ee,onClear:De,onParamsChange:Oe,onHeadersChangeFromHeaders:ke,onHeadersChangeFromAuth:Ae,onBodyTypeChange:e=>{oe(e);let t={...E.headers},n=Object.keys(t).find(e=>e.toLowerCase()===`content-type`),r=nHe[e];r?t[n??`content-type`]=r:n&&delete t[n];let i={...E,headers:t};if(e===`none`)i.body=``;else if(e===`mcp`){let e=Object.keys(t).find(e=>e.toLowerCase()===`accept`)??`accept`;t[e]=`application/json, text/event-stream`,qN(i.body)||(i.body=KN)}D(i),ce(e=>e+1),je(i)},onPersist:je,onLocalSaveToggle:t=>{ne(!te),he(te?`test-console-local-save-enable-clicked`:`test-console-local-save-disable-clicked`,{account:e.account.name,project:e.project.name,environment:e.environment.name}),!t&&a&&nY.optTestOutOfLocalSaving(e.account.name,e.project.name,e.environment.name,a)},onSend:be,onStop:xe,onSkipBuildWait:S,onClearResponse:()=>T(void 0),onClose:d,buildBadge:(0,U.jsx)(J5e,{deploymentUrl:y,environmentName:e.environment.name}),endpoints:f,selectedEndpointId:p,onSelectEndpoint:m,isEndpointPanelOpen:h,onToggleEndpointPanel:g,endpointsLoading:_})};function Ptt(e){if(typeof e!=`object`||!e)return null;let t=e,n=e=>typeof e==`string`?e:void 0;return{path:n(t.path),method:n(t.method),body:n(t.body),environment:n(t.environment),description:n(t.description)}}function Ftt({data:e}){let[t,n]=(0,H.useState)(!1),{logEvent:r}=on(),{account:i,project:a,environment:o}=lb([]),s=!!(i&&a),c=Cp(e=>e.setTestResponse),l=vb({enabled:t&&!!i,throwOnError:!1,refetchOnMount:!1,refetchOnWindowFocus:!1}),u=l.data?.find(e=>e.name===i),d=gT(i??``,{enabled:t&&s,throwOnError:!1,refetchOnMount:!1,refetchOnWindowFocus:!1}),f=d.data?.find(e=>e.name===a),p=zN(i??``,a??``,{enabled:t&&s,throwOnError:!1,refetchOnMount:!1,refetchOnWindowFocus:!1}),m=p.data,h=e=>e?m?.find(t=>t.urlParameter===e):void 0,g=[h(e.environment),h(o),m?.find(e=>e.environmentType===GM.PRODUCTION),...m??[]].filter(e=>!!e),_=g.find(e=>sP(e))??g[0],v=_?(sP(_)??``).replace(/\/$/,``):``,y=t&&!p.isFetching&&!!m&&!v,b=t&&(!l.isFetching&&l.isError||!d.isFetching&&d.isError||!p.isFetching&&p.isError),x=t&&!b&&!y&&!(u&&f&&_&&v),S=e.path?.trim()??``,C=e.method?.trim().toUpperCase(),w=C&&YN.includes(C)?C:`GET`,T={description:e.description??``,pathname:S,method:w,headers:{},body:e.body},E=()=>{n(!1),c(void 0)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Hje,{method:w,path:S||void 0,description:e.description,loading:x,disabled:!s,errorText:y?`No deployed environment to test against yet — deploy the project first.`:b?`Couldn’t open the test console — please try again.`:void 0,onOpen:()=>{s&&(r(`agent-z-test-console-card-clicked`,{account:i,project:a}),c(void 0),n(!0),l.isError&&l.refetch(),d.isError&&d.refetch(),(p.isError||y)&&p.refetch())}}),t&&u&&f&&_&&v?(0,U.jsx)(tb,{open:!0,onOpenChange:e=>{e||E()},children:(0,U.jsxs)(ib,{showCloseButton:!1,className:`max-w-6xl! w-full gap-0 overflow-hidden p-0`,children:[(0,U.jsx)(sb,{className:`sr-only`,children:`Test console`}),(0,U.jsx)(`div`,{className:`flex h-[650px] max-h-[70vh] flex-col`,children:(0,U.jsx)(rY,{ape:{account:u,project:f,environment:_},apiTest:T,url:`${v}${S}`,path:S||null,showRebuildWarning:!1,shouldAllowLocalSaving:!1,onRequestChange:()=>{},onClose:E})})]})}):null]})}function Itt({data:e}){let t=Xa(),{account:n,project:r}=lb([]),{logEvent:i}=on(),a=!!(n&&r);return(0,U.jsx)(Gje,{name:e.name,description:e.description,disabled:!a,onOpen:()=>{if(!n||!r)return;i(`agent-z-ai-app-card-clicked`,{account:n,project:r,hasTeam:!!e.teamId});let a=new URLSearchParams;e.name&&a.set(`name`,e.name),e.teamId&&a.set(`team`,e.teamId);let o=a.toString();t(`/${n}/${r}/ai/apps/new${o?`?${o}`:``}`)}})}var Ltt=(0,H.createContext)(null),iY={didCatch:!1,error:null},Rtt=class extends H.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=iY}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;t!==null&&(this.props.onReset?.({args:e,reason:`imperative-api`}),this.setState(iY))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&ztt(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(iY))}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:a}=this.state,o=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof t==`function`)o=t(e);else if(n)o=(0,H.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,H.createElement)(Ltt.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function ztt(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}function aY(e,t,n,r){let i;try{i=y(t,n,r)}catch{i={blastRadius:n}}oY(()=>S.captureRaw(`portal-error-shown`,i)),oY(()=>S.captureException(t,i)),oY(()=>Btt(e,i,t,n))}function Btt(e,t,n,r){((r===`app-dead`||r===`page-dead`)&&t.errorExpected!==!0?ot.error:ot.warn)(e,{...t,error:n})}function oY(e){try{e()}catch{}}var sY=({children:e,fallback:t,blastRadius:n=`page-dead`})=>(0,U.jsx)(Rtt,{onError:(e,t)=>{aY(`Portal error boundary caught an error`,e,n,{componentStack:t.componentStack})},fallbackRender:({error:e,resetErrorBoundary:n})=>t({error:e,resetError:n}),children:e}),cY=()=>{let{account:e,project:t}=lb([`account`,`project`]);return fb(mt.project(e,t),{extractData:!1}).data},Vtt=`Label`,lY=H.forwardRef((e,t)=>(0,U.jsx)(ac.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));lY.displayName=Vtt;var uY=lY,Htt=Ou(`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`),dY=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(uY,{ref:n,className:W(Htt(),e),...t}));dY.displayName=uY.displayName;var fY=mD,pY=H.createContext({}),mY=({...e})=>(0,U.jsx)(pY.Provider,{value:{name:e.name},children:(0,U.jsx)(yD,{...e})}),hY=()=>{let e=H.useContext(pY),t=H.useContext(gY),{getFieldState:n,formState:r}=pD(),i=n(e.name,r);if(!e)throw Error(`useFormField should be used within <FormField>`);let{id:a}=t;return{id:a,name:e.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...i}},gY=H.createContext({}),_Y=H.forwardRef(({className:e,...t},n)=>{let r=H.useId();return(0,U.jsx)(gY.Provider,{value:{id:r},children:(0,U.jsx)(`div`,{ref:n,className:W(`space-y-1`,e),...t})})});_Y.displayName=`FormItem`;var vY=H.forwardRef(({className:e,...t},n)=>{let{error:r,formItemId:i}=hY();return(0,U.jsx)(dY,{ref:n,className:W(r&&`text-destructive`,e),htmlFor:i,...t})});vY.displayName=`FormLabel`;var yY=H.forwardRef(({...e},t)=>{let{error:n,formItemId:r,formDescriptionId:i,formMessageId:a}=hY();return(0,U.jsx)(Qs,{ref:t,id:r,"aria-describedby":n?`${i} ${a}`:`${i}`,"aria-invalid":!!n,...e})});yY.displayName=`FormControl`;var bY=H.forwardRef(({className:e,...t},n)=>{let{formDescriptionId:r}=hY();return(0,U.jsx)(`p`,{ref:n,id:r,className:W(`text-sm text-muted-foreground`,e),...t})});bY.displayName=`FormDescription`;var xY=H.forwardRef(({className:e,children:t,...n},r)=>{let{error:i,formMessageId:a}=hY(),o=i?.message?String(i.message):t;return o?(0,U.jsx)(`p`,{ref:r,id:a,className:W(`text-sm font-medium text-destructive`,e),...n,children:o}):null});xY.displayName=`FormMessage`;var Utt=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,Wtt=e=>crypto.getRandomValues(new Uint8Array(e)),Gtt=(e,t,n)=>{let r=(2<<Math.log2(e.length-1))-1,i=-~(1.6*r*t/e.length);return(a=t)=>{let o=``;for(;;){let t=n(i),s=i|0;for(;s--;)if(o+=e[t[s]&r]||``,o.length>=a)return o}}},SY=(e,t=21)=>Gtt(e,t|0,Wtt),Ktt=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Utt[n[e]&63];return t},qtt=(e,t)=>`${e}::${t}`,Jtt={"app.created":{success:`ai-gateway-create-app-success`,failed:`ai-gateway-create-app-failed`},"app.deleted":{success:`ai-gateway-delete-app-success`,failed:`ai-gateway-delete-app-failed`},"app.settings-updated":{success:`ai-gateway-update-app-settings-success`,failed:`ai-gateway-update-app-settings-failed`},"gateway.redeploy-requested":{success:`ai-gateway-redeploy-success`,failed:`ai-gateway-redeploy-failed`},"policy.updated":{success:`ai-gateway-update-policy-success`,failed:`ai-gateway-update-policy-failed`},"provider.created":{success:`ai-gateway-create-ai-provider-success`,failed:`ai-gateway-create-ai-provider-failed`},"provider.deleted":{success:`ai-gateway-delete-ai-provider-success`,failed:`ai-gateway-delete-ai-provider-failed`},"provider.updated":{success:`ai-gateway-update-ai-provider-success`,failed:`ai-gateway-update-ai-provider-failed`},"team.created":{success:`ai-gateway-create-team-success`,failed:`ai-gateway-create-team-failed`},"team.default-created":{success:`ai-gateway-create-default-team-success`,failed:`ai-gateway-create-default-team-failed`},"team.deleted":{success:`ai-gateway-delete-team-success`,failed:`ai-gateway-delete-team-failed`},"team.limits-updated":{success:`ai-gateway-update-team-limits-success`,failed:`ai-gateway-update-team-limits-failed`},"team.member-role-updated":{success:`ai-gateway-update-team-member-role-success`,failed:`ai-gateway-update-team-member-role-failed`},"team.policy-template-updated":{success:`ai-gateway-update-team-policy-template-success`,failed:`ai-gateway-update-team-policy-template-failed`},"team.updated":{success:`ai-gateway-update-team-success`,failed:`ai-gateway-update-team-failed`}},Ytt=(e,t)=>{let n=Jtt[e];return t===`succeeded`?n.success:n.failed},CY=()=>{let{captureRaw:e}=on(),t=(0,H.useContext)(mp)?.project,n=t?KE(t):!1,r=t?qtt(t.accountName,t.name):void 0;return(0,H.useCallback)((t,i,a={})=>{n&&e(Ytt(t,i),{...a,...r?{$groups:{project:r}}:{}})},[e,n,r])};function wY(e){let{account:t,project:n}=lb([`account`,`project`]),r=fb(mt.project(t,n),{extractData:!1}).data.defaultConfiguration.find(e=>e.environmentType===GM.PRODUCTION)?.apiKeyBucket??void 0;if(!r&&!e?.optional)throw Error(`No production bucket found`);return r}var TY=()=>wY(),Xtt=()=>{let{account:e,project:t}=lb([`account`,`project`]);return fb(mt.aiProviderAssignments(e,t))};function EY({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:W(`group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none`,`h-9 min-w-0 has-[>textarea]:h-auto`,`has-[>[data-align=inline-start]]:[&>input]:pl-2`,`has-[>[data-align=inline-end]]:[&>input]:pr-2`,`has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3`,`has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3`,`has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]`,`has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40`,e),...t})}var Ztt=Ou(`text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50`,{variants:{align:{"inline-start":`order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]`,"inline-end":`order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]`,"block-start":`order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5`,"block-end":`order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5`}},defaultVariants:{align:`inline-start`}});function DY({className:e,align:t=`inline-start`,...n}){return(0,U.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:W(Ztt({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}var Qtt=Ou(`text-sm shadow-none flex gap-2 items-center`,{variants:{size:{xs:`h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2`,sm:`h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5`,"icon-xs":`size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function OY({className:e,type:t=`button`,variant:n=`ghost`,size:r=`xs`,...i}){return(0,U.jsx)(X,{type:t,"data-size":r,variant:n,className:W(Qtt({size:r}),e),...i})}function kY({className:e,...t}){return(0,U.jsx)(iM,{"data-slot":`input-group-control`,className:W(`flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent`,e),...t})}var AY=a((e=>{e.__esModule=!0,e.default=i;var t=/[\u0300-\u036f]/g,n=/ł/g,r=/ñ/g;function i(e){return e.toLowerCase().normalize(`NFD`).replace(t,``).replace(n,`l`).replace(r,`n`).trim()}})),jY=a((e=>{e.__esModule=!0,e.aggressiveFuzzyMatch=l,e.createFuzzySearchImpl=p,e.experimentalSmartFuzzyMatch=u,e.fuzzyMatchImpl=f;var t=n(AY());function n(e){return e&&e.__esModule?e:{default:e}}var r=2**53-1,i=function(e,t){return e.score-t.score},a=function(e,t){return e[0]-t[0]},o=new Set(` \xA0[]()-–—'"“”`.split(``));function s(e){return o.has(e)}function c(e,t,n,r,i,o,c){if(e===r)return[0,[[0,e.length-1]]];var d=r.length,f=t.length,p=i.length;if(t===i)return[.1,[[0,f-1]]];if(t.startsWith(i))return[.5,[[0,p-1]]];var m=e.indexOf(r);if(m>-1&&s(e[m-1]))return[.9,[[m,m+d-1]]];var h=t.indexOf(i);if(h>-1&&s(t[h-1]))return[1,[[h,h+d-1]]];var g=o.length;return g>1&&o.every(function(e){return n.has(e)})?[1.5+g*.2,o.map(function(e){var n=t.indexOf(e);return[n,n+e.length-1]}).sort(a)]:h>-1?[2,[[h,h+d-1]]]:c===`aggressive`?l(t,i):c===`smart`?u(t,i):null}function l(e,t){for(var n=e.length,r=t.length,i=0,a=t[i],o=[],s=-1,c=-2,l=0;l<n;l+=1)if(e[l]===a){if(l!==c+1&&(s>=0&&o.push([s,c]),s=l),c=l,i+=1,i===r)return o.push([s,c]),d(o,e);a=t[i]}return null}function u(e,t){for(var n=e.length,r=[],i=0,a=t[i],o=-1,c=-2;;){var l=e.indexOf(a,c+1);if(l===-1)break;if(l===0||s(e[l-1]))o=l;else{var u=t.length-i,f=e.length-l,p=Math.min(3,u,f),m=t.slice(i,i+p);if(e.slice(l,l+p)===m)o=l;else{c+=1;continue}}for(c=o;c<n&&e[c]===a;c+=1)i+=1,a=t[i];if(--c,r.push([o,c]),i===t.length)return d(r,e)}return null}function d(e,t){var n=2;return e.forEach(function(e){var r=e[0],i=e[1],a=i-r+1,o=r===0||t[r]===` `||t[r-1]===` `,s=i===t.length-1||t[i]===` `||t[i+1]===` `;o&&s?n+=.2:o?n+=.4:a>=3?n+=.8:n+=1.6}),[n,e]}function f(e,n){var r=(0,t.default)(n),i=r.split(` `),a=(0,t.default)(e),o=c(e,a,new Set(a.split(` `)),n,r,i,`smart`);return o?{item:e,score:o[0],matches:[o[1]]}:null}function p(e,n){var a=n.strategy,o=a===void 0?`aggressive`:a,s=n.getText,l=e.map(function(e){return[e,(s?s(e):[n.key?e[n.key]:e]).map(function(e){var n=e||``,r=(0,t.default)(n);return[n,r,new Set(r.split(` `))]})]});return function(e){var n=[],a=(0,t.default)(e),s=a.split(` `);return a.length?(l.forEach(function(t){for(var i=t[0],l=t[1],u=r,d=[],f=0,p=l.length;f<p;f+=1){var m=l[f],h=m[0],g=m[1],_=m[2],v=c(h,g,_,e,a,s,o);v?(u=Math.min(u,v[0]),d.push(v[1])):d.push(null)}u<r&&n.push({item:i,score:u,matches:d})}),n.sort(i),n):[]}}})),MY=r(a((e=>{e.__esModule=!0,e.default=n,e.fuzzyMatch=r,e.normalizeText=t(AY()).default;function t(e){return e&&e.__esModule?e:{default:e}}function n(e,t){return t===void 0&&(t={}),jY().createFuzzySearchImpl(e,t)}function r(e,t){return jY().fuzzyMatchImpl(e,t)}}))()),$tt=typeof MY.default==`object`&&MY.default!==null&&MY.__esModule?MY.default.default:MY.default,NY=(e,t,{getText:n,key:r})=>{let i=ub(n),a=(0,H.useMemo)(()=>$tt([...t],{key:r,getText:i.current}),[t,r,i]),o=(0,H.useMemo)(()=>e?a(e).map(({item:e})=>e):t,[e,a,t]);return e?o:t},PY=()=>{let e=wY();return fb(mt.supportedAiProviders(e),{extractData:!1})},FY=1e6,IY=1e-4,LY=e=>new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:e}),RY=e=>e*FY,ent=e=>e/FY,tnt=e=>typeof e!=`number`||!Number.isFinite(e)||e<=0?``:String(Number(RY(e).toPrecision(12))),nnt=e=>{if(typeof e!=`number`||!Number.isFinite(e)||e<0)return;if(e===0)return`Free`;let t=RY(e);return t<IY?`< ${LY(4).format(IY)}`:LY(t<1?4:2).format(t)},rnt=0,int=1,ant=2,ont=3,zY=/-(\d{4})-?(\d{2})-?(\d{2})$/,BY=99;function VY(e,t){return e+t/1e3}function snt(e){let t=e.replace(zY,``),n=t.match(/(?:^|[^\d])(\d+)\.(\d+)/);if(n){let e=Number(n[1]);return e<=BY?VY(e,Number(n[2])):null}if(/(?:^|[^\d])4o(?:$|[^\d])/.test(t))return 4;let r=t.match(/-(\d+)-(\d{1,2})(?:$|-)/);if(r&&Number(r[1])<=BY)return VY(Number(r[1]),Number(r[2]));let i=t.match(/(?:^|[^\d.])(\d+)(?=$|[^\d.bx])/i);if(i){let e=Number(i[1]);if(e<=BY)return e}return null}function cnt(e){return/\bnano\b/.test(e)?ant:/\bmini\b/.test(e)?int:/-(pro|codex|turbo|chat|sol|luna|opus|sonnet|haiku|latest)\b/.test(e)?ont:rnt}function HY(e){let t=snt(e),n=e.match(zY),r=n?Number(`${n[1]}${n[2]}${n[3]}`):0;return{generation:t??-1/0,isLatest:/-latest$/.test(e)?0:1,isSnapshot:r>0?1:0,tier:cnt(e),snapshotDate:r}}function UY(e,t){let n=HY(e),r=HY(t);return n.generation===r.generation?n.generation===-1/0&&r.generation===-1/0&&n.isLatest!==r.isLatest?n.isLatest-r.isLatest:n.tier===r.tier?n.isSnapshot===r.isSnapshot?n.snapshotDate===r.snapshotDate?e.localeCompare(t):r.snapshotDate-n.snapshotDate:n.isSnapshot-r.isSnapshot:n.tier-r.tier:r.generation-n.generation}function WY(e){return[...e].sort(UY)}var lnt=Rm({request:Pm().trim().min(1,`Tell us which provider or model you need`),details:Pm().optional()}),unt=`ai-gateway-request-provider-or-model-submitted`,GY=({children:e,defaultRequest:t,provider:n,source:r})=>{let[i,a]=(0,H.useState)(!1);return(0,U.jsxs)(tb,{open:i,onOpenChange:a,children:[(0,U.jsx)(nb,{asChild:!0,children:e}),(0,U.jsx)(ib,{className:`sm:max-w-md`,children:(0,U.jsx)(dnt,{defaultRequest:t,provider:n,source:r,onClose:()=>a(!1)})})]})},dnt=({defaultRequest:e,provider:t,source:n,onClose:r})=>{let[i,a]=(0,H.useState)(!1),{account:o,project:s}=lb([`account`,`project`]),{logEvent:c}=on(),l=qD({defaultValues:{request:e?.trim()??``,details:``},resolver:JD(lnt)});(0,H.useEffect)(()=>{let e=e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&e.stopPropagation()};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},[]);let u=l.handleSubmit(e=>{let r=e.details?.trim()||void 0;c(unt,{account:o,project:s,source:n,request:e.request.trim(),provider:t?.trim(),details:r,hasDetails:!!r}),a(!0)});return i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Request sent`}),(0,U.jsx)(cb,{children:`Thanks — we read these when deciding which providers and models to add next.`})]}),(0,U.jsx)(ob,{children:(0,U.jsx)(X,{onClick:r,children:`Done`})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Request a provider or model`}),(0,U.jsx)(cb,{children:`Don’t see the provider or model you need? Tell us which one and we’ll look into adding it.`})]}),(0,U.jsx)(fY,{...l,children:(0,U.jsxs)(`form`,{onSubmit:u,className:`space-y-4`,children:[(0,U.jsx)(mY,{control:l.control,name:`request`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Provider or model`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`e.g. Cohere, or gpt-5.1 on OpenAI`,autoFocus:!0,...e})}),(0,U.jsx)(xY,{})]})}),(0,U.jsx)(mY,{control:l.control,name:`details`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Additional details (optional)`}),(0,U.jsx)(yY,{children:(0,U.jsx)(xw,{rows:3,placeholder:`How you'd use it, links, pricing tier, etc.`,...e})}),(0,U.jsx)(xY,{})]})}),(0,U.jsxs)(ob,{children:[(0,U.jsx)(X,{type:`button`,variant:`ghost`,onClick:r,children:`Cancel`}),(0,U.jsx)(X,{type:`submit`,children:`Send request`})]})]})})]})},KY=`sticky top-0 z-10 -mx-1 space-y-2 bg-background px-1 pb-2`;function qY({form:e,mode:t,providerDisabled:n,onProviderChange:r,allowCustomModelEditing:i=!0}){let{data:a,providers:o}=PY().data,s=YE(cY()),c=e.watch(`provider`),l=Object.keys(a).filter(e=>!o[e]?.isCustom&&(s||e!==`ZuploDemo`)),u=c===`ZuploDemo`&&!o[c]?.isCustom;(0,H.useEffect)(()=>{let t=o[c]?.isCustom;e.setValue(`customProviderName`,t?c:void 0)},[c,o,e]),(0,H.useEffect)(()=>{u&&e.setValue(`apiKey`,``)},[u,e]);let d=c===`__custom`||o[c]?.isCustom===!0,f=c===eje,p=c===ije;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(mY,{control:e.control,name:`provider`,render:({field:t})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`AI Provider`}),(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsxs)(mJ,{onValueChange:e=>{t.onChange(e),r?.(e)},value:t.value,disabled:n,children:[(0,U.jsx)(yY,{children:(0,U.jsx)(_J,{className:`w-full`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(gJ,{placeholder:`Choose AI provider…`}),e.watch(`customProviderName`)&&(0,U.jsx)(XD,{variant:`invert`,children:`custom`})]})})}),(0,U.jsxs)(vJ,{className:`max-h-[325px] overflow-y-auto`,children:[l.length>0&&(0,U.jsxs)(hJ,{children:[(0,U.jsx)(yJ,{children:`Default Providers`}),l.map(e=>(0,U.jsx)(bJ,{value:e,children:o[e]?.label||e},e))]}),(0,U.jsxs)(hJ,{children:[(0,U.jsx)(yJ,{children:`Custom Providers`}),o[c]?.isCustom&&(0,U.jsx)(bJ,{value:c,children:o[c]?.label||c}),(0,U.jsx)(bJ,{value:qE,children:`Custom`})]})]})]})}),(0,U.jsx)(xY,{}),(0,U.jsx)(JY,{label:`Missing a provider?`,source:`provider-picker`})]})}),u&&(0,U.jsxs)(Vy,{variant:`warning`,children:[(0,U.jsx)(Jf,{}),(0,U.jsx)(Hy,{children:`Not for production use`}),(0,U.jsx)(Uy,{children:`Zuplo Demo is a free demo provider operated by Zuplo with daily per-account limits. Do not use it for production workloads.`})]}),(0,U.jsx)(mY,{control:e.control,name:`label`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Provider Name`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`e.g. production-openai`,maxLength:64,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,readOnly:t===`edit`,...e})}),(0,U.jsx)(xY,{})]})}),!f&&!p&&(0,U.jsx)(mY,{control:e.control,name:`baseUrl`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`API URL`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:o[c]?.baseUrl??`https://api.example.com`,...e,value:e.value??``,disabled:!d||t===`edit`})}),d&&t!==`edit`&&(0,U.jsx)(bY,{className:`text-xs`,children:`The base URL only — the gateway appends /v1/chat/completions itself. Use https://api.example.com, not https://api.example.com/v1.`}),(0,U.jsx)(xY,{})]})}),f&&(0,U.jsx)(mY,{control:e.control,name:`region`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`AWS Region`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`us-east-1`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,...e,value:e.value??``})}),(0,U.jsx)(bY,{className:`text-xs`,children:`The region Bedrock serves your account from; requests go to bedrock-mantle.<region>.api.aws.`}),(0,U.jsx)(xY,{})]})}),p&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(mY,{control:e.control,name:`region`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Location`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`us-central1`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,...e,value:e.value??``})}),(0,U.jsxs)(bY,{className:`text-xs`,children:[`The Vertex AI location to call; requests go to <location>-aiplatform.googleapis.com. Use`,` `,(0,U.jsx)(`span`,{className:`font-mono`,children:`global`}),` for the global endpoint.`]}),(0,U.jsx)(xY,{})]})}),(0,U.jsx)(mY,{control:e.control,name:`gcpProjectId`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Google Cloud Project ID`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`my-project-123`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,...e,value:e.value??``})}),(0,U.jsx)(bY,{className:`text-xs`,children:`The project with the Vertex AI API enabled. This is the project ID, not the project number.`}),(0,U.jsx)(xY,{})]})})]}),!u&&(0,U.jsx)(mY,{control:e.control,name:`apiKey`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:p?`Service Account Key (JSON)`:`API Key`}),(0,U.jsx)(yY,{children:p?(0,U.jsx)(xw,{placeholder:t===`edit`?`Leave blank to keep the existing service account key`:`{ "type": "service_account", "project_id": "…", "private_key": "…" }`,rows:5,className:`font-mono text-xs`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,...e,value:e.value??``}):(0,U.jsx)(iM,{placeholder:t===`edit`?`Leave blank to keep existing API key`:f?`Enter your long-term Bedrock API key (starts with ABSK)`:`Enter your API Key for this provider`,type:`password`,...e})}),p&&(0,U.jsx)(bY,{className:`text-xs`,children:`Paste the whole JSON key file from the Google Cloud console (IAM & Admin > Service Accounts > Keys). The service account needs the Vertex AI User role on the project.`}),(0,U.jsx)(xY,{})]})}),d&&i?(0,U.jsx)(fnt,{}):(0,U.jsx)(pnt,{modelsData:a,provider:c})]})}var JY=({label:e,defaultRequest:t,provider:n,source:r})=>(0,U.jsx)(GY,{defaultRequest:t,provider:n,source:r,children:(0,U.jsx)(X,{type:`button`,variant:`link`,size:`sm`,className:`h-auto px-0 text-muted-foreground`,children:e})}),YY=({children:e})=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,U.jsx)(`div`,{className:`text-xl font-medium`,children:`Available Models`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`prices per 1M tokens`})]}),e]}),XY=({trailing:e})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(dY,{className:`text-muted-foreground`,children:`Model`}),(0,U.jsx)(dY,{className:`justify-end text-muted-foreground`,children:`Input / 1M`}),(0,U.jsx)(dY,{className:`justify-end text-muted-foreground`,children:`Output / 1M`}),e]}),ZY=({costPerToken:e})=>{let t=nnt(e);return(0,U.jsx)(`div`,{className:W(`text-right text-sm tabular-nums`,t?`text-muted-foreground`:`text-muted-foreground/50`),children:t??`—`})},QY=({name:e,label:t})=>(0,U.jsx)(mY,{control:pD().control,name:e,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(yY,{children:(0,U.jsxs)(EY,{children:[(0,U.jsx)(DY,{align:`inline-start`,children:`$`}),(0,U.jsx)(kY,{type:`number`,step:`any`,min:0,placeholder:`0.00`,"aria-label":t,hideNumberArrows:!0,selectOnFocus:!0,name:e.name,ref:e.ref,onBlur:e.onBlur,defaultValue:tnt(e.value),onChange:t=>e.onChange(ent(Number.parseFloat(t.target.value)||0))}),(0,U.jsx)(DY,{align:`inline-end`,className:`text-muted-foreground/70`,children:`/1M`})]})}),(0,U.jsx)(xY,{})]})}),fnt=()=>{let e=pD(),{fields:t,append:n,remove:r}=WMe({control:e.control,name:`customModels`}),i=t=>!!e.getValues(`customModels.${t}.modelId`);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:KY,children:[(0,U.jsx)(YY,{children:(0,U.jsxs)(X,{type:`button`,variant:`outline`,onClick:()=>{n({name:``,status:`active`,kind:`completions`,inputCostPerToken:0,outputCostPerToken:0})},children:[(0,U.jsx)(Sf,{size:16}),`Add Model`]})}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Custom providers serve chat completions and embeddings only.`}),(0,U.jsx)(mY,{name:`customModels`,control:e.control,render:()=>(0,U.jsx)(xY,{})})]}),(0,U.jsx)(`div`,{className:W(`border rounded-md`,e.formState.errors.customModels&&`border-destructive`),children:t.length===0?(0,U.jsxs)(Gy,{children:[(0,U.jsx)(Jy,{children:`No models added yet`}),(0,U.jsx)(Yy,{children:`Add a model to get started.`})]}):(0,U.jsxs)(`div`,{className:`grid grid-cols-[minmax(8rem,1fr)_8rem_8rem_9.5rem_auto] items-start gap-2 p-4`,children:[(0,U.jsx)(XY,{trailing:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(dY,{className:`text-muted-foreground`,children:`Type`}),(0,U.jsx)(`span`,{})]})}),t.map((t,n)=>(0,U.jsxs)(`div`,{className:`grid grid-cols-subgrid col-span-full items-start gap-2`,children:[(0,U.jsx)(mY,{control:e.control,name:`customModels.${n}.name`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`Model Name`,"aria-label":`Model name`,className:`font-mono`,readOnly:i(n),...e})}),(0,U.jsx)(xY,{})]})}),(0,U.jsx)(QY,{name:`customModels.${n}.inputCostPerToken`,label:`Input cost per million tokens`}),(0,U.jsx)(QY,{name:`customModels.${n}.outputCostPerToken`,label:`Output cost per million tokens`}),(0,U.jsx)(mY,{control:e.control,name:`customModels.${n}.kind`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(yY,{children:(0,U.jsxs)(mJ,{defaultValue:`completions`,onValueChange:e.onChange,value:e.value,disabled:i(n),children:[(0,U.jsx)(_J,{className:`mb-0 w-full`,"aria-label":`Model type`,children:(0,U.jsx)(gJ,{placeholder:`Select Model Type`})}),(0,U.jsxs)(vJ,{children:[(0,U.jsx)(bJ,{value:`completions`,children:`Chat`}),(0,U.jsx)(bJ,{value:`embeddings`,children:`Embeddings`})]})]})}),(0,U.jsx)(xY,{})]})}),(0,U.jsx)(`div`,{className:`flex justify-center items-center size-full max-h-9`,children:(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Remove model`,onClick:()=>{r(n)},children:(0,U.jsx)(ep,{className:`h-4 w-4`})})})]},t.id))]})})]})},pnt=({modelsData:e,provider:t})=>{let n=pD(),[r,i]=(0,H.useState)(``),[a,o]=(0,H.useState)(`all`),s=NY(r,[...e[t]??[]].sort((e,t)=>UY(e.model,t.model)).filter(({kind:e})=>a===`all`?!0:e===a),{getText:({model:e,kind:t})=>[e,t]}),c=n.watch(`models`);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:W(KY,`pt-2`),children:[(0,U.jsx)(YY,{children:(0,U.jsx)(X,{type:`button`,variant:`link`,onClick:()=>{n.setValue(`models`,{completions:WY(e[t]?.filter(({kind:e})=>e===`completions`).map(({model:e})=>e)??[]),embeddings:WY(e[t]?.filter(({kind:e})=>e===`embeddings`).map(({model:e})=>e)??[])})},children:`Select All`})}),(0,U.jsxs)(`div`,{className:`flex justify-stretch gap-2`,children:[(0,U.jsx)(FJ,{onClearValue:()=>i(``),className:`w-8/12`,showClearButton:r.length>0,children:(0,U.jsx)(iM,{placeholder:`Search Models`,className:`px-8`,value:r,onChange:e=>i(e.target.value)})}),(0,U.jsxs)(mJ,{onValueChange:e=>{o(e)},children:[(0,U.jsx)(_J,{className:`w-4/12`,"aria-label":`Filter by model type`,children:(0,U.jsx)(gJ,{placeholder:`All Types`})}),(0,U.jsxs)(vJ,{children:[(0,U.jsx)(bJ,{value:`all`,children:`All Types`}),(0,U.jsx)(bJ,{value:`completions`,children:`Chat`}),(0,U.jsx)(bJ,{value:`embeddings`,children:`Embeddings`})]})]})]})]}),(0,U.jsx)(`div`,{className:`border rounded-md p-4`,children:s?.length===0?(0,U.jsxs)(Gy,{children:[(0,U.jsx)(Jy,{children:`No models match your search`}),(0,U.jsx)(Yy,{children:`Try a different name or model type.`}),(0,U.jsx)(Xy,{children:(0,U.jsx)(GY,{defaultRequest:r,provider:t,source:`model-search-empty`,children:(0,U.jsxs)(X,{type:`button`,variant:`outline`,size:`sm`,children:[(0,U.jsx)(pf,{size:16}),`Request a model`]})})})]}):(0,U.jsxs)(`div`,{className:`grid grid-cols-[min-content_1fr_6rem_6rem_max-content] items-center gap-x-3 gap-y-2`,children:[(0,U.jsx)(`span`,{}),(0,U.jsx)(XY,{trailing:(0,U.jsx)(`span`,{})}),s?.map(({kind:e,model:t,inputCostPerToken:r,outputCostPerToken:i})=>(0,U.jsxs)(`label`,{className:`grid grid-cols-subgrid col-span-full items-center`,children:[(0,U.jsx)(YJ,{checked:c?.[e]?.includes(t),onCheckedChange:r=>{n.setValue(`models`,{...c,[e]:r?[...c?.[e]??[],t]:(c?.[e]??[]).filter(e=>e!==t)})}}),(0,U.jsx)(`div`,{className:`truncate font-mono text-sm`,title:t,children:t}),(0,U.jsx)(ZY,{costPerToken:r}),(0,U.jsx)(ZY,{costPerToken:e===`embeddings`?void 0:i}),(0,U.jsx)(XD,{variant:`outline`,children:e===`completions`?`Chat`:`Embeddings`})]},t))]})}),s?.length!==0&&(0,U.jsx)(JY,{label:`Missing a model?`,defaultRequest:r,provider:t,source:`model-list`})]})},mnt=[[`ß`,`ss`],[`ẞ`,`Ss`],[`ä`,`ae`],[`Ä`,`Ae`],[`ö`,`oe`],[`Ö`,`Oe`],[`ü`,`ue`],[`Ü`,`Ue`],[`À`,`A`],[`Á`,`A`],[`Â`,`A`],[`Ã`,`A`],[`Ä`,`Ae`],[`Å`,`A`],[`Æ`,`AE`],[`Ç`,`C`],[`È`,`E`],[`É`,`E`],[`Ê`,`E`],[`Ë`,`E`],[`Ì`,`I`],[`Í`,`I`],[`Î`,`I`],[`Ï`,`I`],[`Ð`,`D`],[`Ñ`,`N`],[`Ò`,`O`],[`Ó`,`O`],[`Ô`,`O`],[`Õ`,`O`],[`Ö`,`Oe`],[`Ő`,`O`],[`Ø`,`O`],[`Ù`,`U`],[`Ú`,`U`],[`Û`,`U`],[`Ü`,`Ue`],[`Ű`,`U`],[`Ý`,`Y`],[`Þ`,`TH`],[`ß`,`ss`],[`à`,`a`],[`á`,`a`],[`â`,`a`],[`ã`,`a`],[`ä`,`ae`],[`å`,`a`],[`æ`,`ae`],[`ç`,`c`],[`è`,`e`],[`é`,`e`],[`ê`,`e`],[`ë`,`e`],[`ì`,`i`],[`í`,`i`],[`î`,`i`],[`ï`,`i`],[`ð`,`d`],[`ñ`,`n`],[`ò`,`o`],[`ó`,`o`],[`ô`,`o`],[`õ`,`o`],[`ö`,`oe`],[`ő`,`o`],[`ø`,`o`],[`ù`,`u`],[`ú`,`u`],[`û`,`u`],[`ü`,`ue`],[`ű`,`u`],[`ý`,`y`],[`þ`,`th`],[`ÿ`,`y`],[`ẞ`,`SS`],[`à`,`a`],[`À`,`A`],[`á`,`a`],[`Á`,`A`],[`â`,`a`],[`Â`,`A`],[`ã`,`a`],[`Ã`,`A`],[`è`,`e`],[`È`,`E`],[`é`,`e`],[`É`,`E`],[`ê`,`e`],[`Ê`,`E`],[`ì`,`i`],[`Ì`,`I`],[`í`,`i`],[`Í`,`I`],[`ò`,`o`],[`Ò`,`O`],[`ó`,`o`],[`Ó`,`O`],[`ô`,`o`],[`Ô`,`O`],[`õ`,`o`],[`Õ`,`O`],[`ù`,`u`],[`Ù`,`U`],[`ú`,`u`],[`Ú`,`U`],[`ý`,`y`],[`Ý`,`Y`],[`ă`,`a`],[`Ă`,`A`],[`Đ`,`D`],[`đ`,`d`],[`ĩ`,`i`],[`Ĩ`,`I`],[`ũ`,`u`],[`Ũ`,`U`],[`ơ`,`o`],[`Ơ`,`O`],[`ư`,`u`],[`Ư`,`U`],[`ạ`,`a`],[`Ạ`,`A`],[`ả`,`a`],[`Ả`,`A`],[`ấ`,`a`],[`Ấ`,`A`],[`ầ`,`a`],[`Ầ`,`A`],[`ẩ`,`a`],[`Ẩ`,`A`],[`ẫ`,`a`],[`Ẫ`,`A`],[`ậ`,`a`],[`Ậ`,`A`],[`ắ`,`a`],[`Ắ`,`A`],[`ằ`,`a`],[`Ằ`,`A`],[`ẳ`,`a`],[`Ẳ`,`A`],[`ẵ`,`a`],[`Ẵ`,`A`],[`ặ`,`a`],[`Ặ`,`A`],[`ẹ`,`e`],[`Ẹ`,`E`],[`ẻ`,`e`],[`Ẻ`,`E`],[`ẽ`,`e`],[`Ẽ`,`E`],[`ế`,`e`],[`Ế`,`E`],[`ề`,`e`],[`Ề`,`E`],[`ể`,`e`],[`Ể`,`E`],[`ễ`,`e`],[`Ễ`,`E`],[`ệ`,`e`],[`Ệ`,`E`],[`ỉ`,`i`],[`Ỉ`,`I`],[`ị`,`i`],[`Ị`,`I`],[`ọ`,`o`],[`Ọ`,`O`],[`ỏ`,`o`],[`Ỏ`,`O`],[`ố`,`o`],[`Ố`,`O`],[`ồ`,`o`],[`Ồ`,`O`],[`ổ`,`o`],[`Ổ`,`O`],[`ỗ`,`o`],[`Ỗ`,`O`],[`ộ`,`o`],[`Ộ`,`O`],[`ớ`,`o`],[`Ớ`,`O`],[`ờ`,`o`],[`Ờ`,`O`],[`ở`,`o`],[`Ở`,`O`],[`ỡ`,`o`],[`Ỡ`,`O`],[`ợ`,`o`],[`Ợ`,`O`],[`ụ`,`u`],[`Ụ`,`U`],[`ủ`,`u`],[`Ủ`,`U`],[`ứ`,`u`],[`Ứ`,`U`],[`ừ`,`u`],[`Ừ`,`U`],[`ử`,`u`],[`Ử`,`U`],[`ữ`,`u`],[`Ữ`,`U`],[`ự`,`u`],[`Ự`,`U`],[`ỳ`,`y`],[`Ỳ`,`Y`],[`ỵ`,`y`],[`Ỵ`,`Y`],[`ỷ`,`y`],[`Ỷ`,`Y`],[`ỹ`,`y`],[`Ỹ`,`Y`],[`ء`,`e`],[`آ`,`a`],[`أ`,`a`],[`ؤ`,`w`],[`إ`,`i`],[`ئ`,`y`],[`ا`,`a`],[`ب`,`b`],[`ة`,`t`],[`ت`,`t`],[`ث`,`th`],[`ج`,`j`],[`ح`,`h`],[`خ`,`kh`],[`د`,`d`],[`ذ`,`dh`],[`ر`,`r`],[`ز`,`z`],[`س`,`s`],[`ش`,`sh`],[`ص`,`s`],[`ض`,`d`],[`ط`,`t`],[`ظ`,`z`],[`ع`,`e`],[`غ`,`gh`],[`ـ`,`_`],[`ف`,`f`],[`ق`,`q`],[`ك`,`k`],[`ل`,`l`],[`م`,`m`],[`ن`,`n`],[`ه`,`h`],[`و`,`w`],[`ى`,`a`],[`ي`,`y`],[`َ‎`,`a`],[`ُ`,`u`],[`ِ‎`,`i`],[`٠`,`0`],[`١`,`1`],[`٢`,`2`],[`٣`,`3`],[`٤`,`4`],[`٥`,`5`],[`٦`,`6`],[`٧`,`7`],[`٨`,`8`],[`٩`,`9`],[`چ`,`ch`],[`ک`,`k`],[`گ`,`g`],[`پ`,`p`],[`ژ`,`zh`],[`ی`,`y`],[`۰`,`0`],[`۱`,`1`],[`۲`,`2`],[`۳`,`3`],[`۴`,`4`],[`۵`,`5`],[`۶`,`6`],[`۷`,`7`],[`۸`,`8`],[`۹`,`9`],[`ټ`,`p`],[`ځ`,`z`],[`څ`,`c`],[`ډ`,`d`],[`ﺫ`,`d`],[`ﺭ`,`r`],[`ړ`,`r`],[`ﺯ`,`z`],[`ږ`,`g`],[`ښ`,`x`],[`ګ`,`g`],[`ڼ`,`n`],[`ۀ`,`e`],[`ې`,`e`],[`ۍ`,`ai`],[`ٹ`,`t`],[`ڈ`,`d`],[`ڑ`,`r`],[`ں`,`n`],[`ہ`,`h`],[`ھ`,`h`],[`ے`,`e`],[`А`,`A`],[`а`,`a`],[`Б`,`B`],[`б`,`b`],[`В`,`V`],[`в`,`v`],[`Г`,`G`],[`г`,`g`],[`Д`,`D`],[`д`,`d`],[`ъе`,`ye`],[`Ъе`,`Ye`],[`ъЕ`,`yE`],[`ЪЕ`,`YE`],[`Е`,`E`],[`е`,`e`],[`Ё`,`Yo`],[`ё`,`yo`],[`Ж`,`Zh`],[`ж`,`zh`],[`З`,`Z`],[`з`,`z`],[`И`,`I`],[`и`,`i`],[`ый`,`iy`],[`Ый`,`Iy`],[`ЫЙ`,`IY`],[`ыЙ`,`iY`],[`Й`,`Y`],[`й`,`y`],[`К`,`K`],[`к`,`k`],[`Л`,`L`],[`л`,`l`],[`М`,`M`],[`м`,`m`],[`Н`,`N`],[`н`,`n`],[`О`,`O`],[`о`,`o`],[`П`,`P`],[`п`,`p`],[`Р`,`R`],[`р`,`r`],[`С`,`S`],[`с`,`s`],[`Т`,`T`],[`т`,`t`],[`У`,`U`],[`у`,`u`],[`Ф`,`F`],[`ф`,`f`],[`Х`,`Kh`],[`х`,`kh`],[`Ц`,`Ts`],[`ц`,`ts`],[`Ч`,`Ch`],[`ч`,`ch`],[`Ш`,`Sh`],[`ш`,`sh`],[`Щ`,`Sch`],[`щ`,`sch`],[`Ъ`,``],[`ъ`,``],[`Ы`,`Y`],[`ы`,`y`],[`Ь`,``],[`ь`,``],[`Э`,`E`],[`э`,`e`],[`Ю`,`Yu`],[`ю`,`yu`],[`Я`,`Ya`],[`я`,`ya`],[`ă`,`a`],[`Ă`,`A`],[`ș`,`s`],[`Ș`,`S`],[`ț`,`t`],[`Ț`,`T`],[`ţ`,`t`],[`Ţ`,`T`],[`ş`,`s`],[`Ş`,`S`],[`ç`,`c`],[`Ç`,`C`],[`ğ`,`g`],[`Ğ`,`G`],[`ı`,`i`],[`İ`,`I`],[`ա`,`a`],[`Ա`,`A`],[`բ`,`b`],[`Բ`,`B`],[`գ`,`g`],[`Գ`,`G`],[`դ`,`d`],[`Դ`,`D`],[`ե`,`ye`],[`Ե`,`Ye`],[`զ`,`z`],[`Զ`,`Z`],[`է`,`e`],[`Է`,`E`],[`ը`,`y`],[`Ը`,`Y`],[`թ`,`t`],[`Թ`,`T`],[`ժ`,`zh`],[`Ժ`,`Zh`],[`ի`,`i`],[`Ի`,`I`],[`լ`,`l`],[`Լ`,`L`],[`խ`,`kh`],[`Խ`,`Kh`],[`ծ`,`ts`],[`Ծ`,`Ts`],[`կ`,`k`],[`Կ`,`K`],[`հ`,`h`],[`Հ`,`H`],[`ձ`,`dz`],[`Ձ`,`Dz`],[`ղ`,`gh`],[`Ղ`,`Gh`],[`ճ`,`tch`],[`Ճ`,`Tch`],[`մ`,`m`],[`Մ`,`M`],[`յ`,`y`],[`Յ`,`Y`],[`ն`,`n`],[`Ն`,`N`],[`շ`,`sh`],[`Շ`,`Sh`],[`ո`,`vo`],[`Ո`,`Vo`],[`չ`,`ch`],[`Չ`,`Ch`],[`պ`,`p`],[`Պ`,`P`],[`ջ`,`j`],[`Ջ`,`J`],[`ռ`,`r`],[`Ռ`,`R`],[`ս`,`s`],[`Ս`,`S`],[`վ`,`v`],[`Վ`,`V`],[`տ`,`t`],[`Տ`,`T`],[`ր`,`r`],[`Ր`,`R`],[`ց`,`c`],[`Ց`,`C`],[`ու`,`u`],[`ՈՒ`,`U`],[`Ու`,`U`],[`փ`,`p`],[`Փ`,`P`],[`ք`,`q`],[`Ք`,`Q`],[`օ`,`o`],[`Օ`,`O`],[`ֆ`,`f`],[`Ֆ`,`F`],[`և`,`yev`],[`ა`,`a`],[`ბ`,`b`],[`გ`,`g`],[`დ`,`d`],[`ე`,`e`],[`ვ`,`v`],[`ზ`,`z`],[`თ`,`t`],[`ი`,`i`],[`კ`,`k`],[`ლ`,`l`],[`მ`,`m`],[`ნ`,`n`],[`ო`,`o`],[`პ`,`p`],[`ჟ`,`zh`],[`რ`,`r`],[`ს`,`s`],[`ტ`,`t`],[`უ`,`u`],[`ფ`,`ph`],[`ქ`,`q`],[`ღ`,`gh`],[`ყ`,`k`],[`შ`,`sh`],[`ჩ`,`ch`],[`ც`,`ts`],[`ძ`,`dz`],[`წ`,`ts`],[`ჭ`,`tch`],[`ხ`,`kh`],[`ჯ`,`j`],[`ჰ`,`h`],[`č`,`c`],[`ď`,`d`],[`ě`,`e`],[`ň`,`n`],[`ř`,`r`],[`š`,`s`],[`ť`,`t`],[`ů`,`u`],[`ž`,`z`],[`Č`,`C`],[`Ď`,`D`],[`Ě`,`E`],[`Ň`,`N`],[`Ř`,`R`],[`Š`,`S`],[`Ť`,`T`],[`Ů`,`U`],[`Ž`,`Z`],[`ހ`,`h`],[`ށ`,`sh`],[`ނ`,`n`],[`ރ`,`r`],[`ބ`,`b`],[`ޅ`,`lh`],[`ކ`,`k`],[`އ`,`a`],[`ވ`,`v`],[`މ`,`m`],[`ފ`,`f`],[`ދ`,`dh`],[`ތ`,`th`],[`ލ`,`l`],[`ގ`,`g`],[`ޏ`,`gn`],[`ސ`,`s`],[`ޑ`,`d`],[`ޒ`,`z`],[`ޓ`,`t`],[`ޔ`,`y`],[`ޕ`,`p`],[`ޖ`,`j`],[`ޗ`,`ch`],[`ޘ`,`tt`],[`ޙ`,`hh`],[`ޚ`,`kh`],[`ޛ`,`th`],[`ޜ`,`z`],[`ޝ`,`sh`],[`ޞ`,`s`],[`ޟ`,`d`],[`ޠ`,`t`],[`ޡ`,`z`],[`ޢ`,`a`],[`ޣ`,`gh`],[`ޤ`,`q`],[`ޥ`,`w`],[`ަ`,`a`],[`ާ`,`aa`],[`ި`,`i`],[`ީ`,`ee`],[`ު`,`u`],[`ޫ`,`oo`],[`ެ`,`e`],[`ޭ`,`ey`],[`ޮ`,`o`],[`ޯ`,`oa`],[`ް`,``],[`α`,`a`],[`β`,`v`],[`γ`,`g`],[`δ`,`d`],[`ε`,`e`],[`ζ`,`z`],[`η`,`i`],[`θ`,`th`],[`ι`,`i`],[`κ`,`k`],[`λ`,`l`],[`μ`,`m`],[`ν`,`n`],[`ξ`,`ks`],[`ο`,`o`],[`π`,`p`],[`ρ`,`r`],[`σ`,`s`],[`τ`,`t`],[`υ`,`y`],[`φ`,`f`],[`χ`,`x`],[`ψ`,`ps`],[`ω`,`o`],[`ά`,`a`],[`έ`,`e`],[`ί`,`i`],[`ό`,`o`],[`ύ`,`y`],[`ή`,`i`],[`ώ`,`o`],[`ς`,`s`],[`ϊ`,`i`],[`ΰ`,`y`],[`ϋ`,`y`],[`ΐ`,`i`],[`Α`,`A`],[`Β`,`B`],[`Γ`,`G`],[`Δ`,`D`],[`Ε`,`E`],[`Ζ`,`Z`],[`Η`,`I`],[`Θ`,`TH`],[`Ι`,`I`],[`Κ`,`K`],[`Λ`,`L`],[`Μ`,`M`],[`Ν`,`N`],[`Ξ`,`KS`],[`Ο`,`O`],[`Π`,`P`],[`Ρ`,`R`],[`Σ`,`S`],[`Τ`,`T`],[`Υ`,`Y`],[`Φ`,`F`],[`Χ`,`X`],[`Ψ`,`PS`],[`Ω`,`O`],[`Ά`,`A`],[`Έ`,`E`],[`Ί`,`I`],[`Ό`,`O`],[`Ύ`,`Y`],[`Ή`,`I`],[`Ώ`,`O`],[`Ϊ`,`I`],[`Ϋ`,`Y`],[`ā`,`a`],[`ē`,`e`],[`ģ`,`g`],[`ī`,`i`],[`ķ`,`k`],[`ļ`,`l`],[`ņ`,`n`],[`ū`,`u`],[`Ā`,`A`],[`Ē`,`E`],[`Ģ`,`G`],[`Ī`,`I`],[`Ķ`,`K`],[`Ļ`,`L`],[`Ņ`,`N`],[`Ū`,`U`],[`č`,`c`],[`š`,`s`],[`ž`,`z`],[`Č`,`C`],[`Š`,`S`],[`Ž`,`Z`],[`ą`,`a`],[`č`,`c`],[`ę`,`e`],[`ė`,`e`],[`į`,`i`],[`š`,`s`],[`ų`,`u`],[`ū`,`u`],[`ž`,`z`],[`Ą`,`A`],[`Č`,`C`],[`Ę`,`E`],[`Ė`,`E`],[`Į`,`I`],[`Š`,`S`],[`Ų`,`U`],[`Ū`,`U`],[`Ќ`,`Kj`],[`ќ`,`kj`],[`Љ`,`Lj`],[`љ`,`lj`],[`Њ`,`Nj`],[`њ`,`nj`],[`Тс`,`Ts`],[`тс`,`ts`],[`ą`,`a`],[`ć`,`c`],[`ę`,`e`],[`ł`,`l`],[`ń`,`n`],[`ś`,`s`],[`ź`,`z`],[`ż`,`z`],[`Ą`,`A`],[`Ć`,`C`],[`Ę`,`E`],[`Ł`,`L`],[`Ń`,`N`],[`Ś`,`S`],[`Ź`,`Z`],[`Ż`,`Z`],[`Є`,`Ye`],[`І`,`I`],[`Ї`,`Yi`],[`Ґ`,`G`],[`є`,`ye`],[`і`,`i`],[`ї`,`yi`],[`ґ`,`g`],[`IJ`,`IJ`],[`ij`,`ij`],[`¢`,`c`],[`¥`,`Y`],[`߿`,`b`],[`৳`,`t`],[`૱`,`Bo`],[`฿`,`B`],[`₠`,`CE`],[`₡`,`C`],[`₢`,`Cr`],[`₣`,`F`],[`₥`,`m`],[`₦`,`N`],[`₧`,`Pt`],[`₨`,`Rs`],[`₩`,`W`],[`₫`,`s`],[`€`,`E`],[`₭`,`K`],[`₮`,`T`],[`₯`,`Dp`],[`₰`,`S`],[`₱`,`P`],[`₲`,`G`],[`₳`,`A`],[`₴`,`S`],[`₵`,`C`],[`₶`,`tt`],[`₷`,`S`],[`₸`,`T`],[`₹`,`R`],[`₺`,`L`],[`₽`,`P`],[`₿`,`B`],[`﹩`,`$`],[`¢`,`c`],[`¥`,`Y`],[`₩`,`W`],[`𝐀`,`A`],[`𝐁`,`B`],[`𝐂`,`C`],[`𝐃`,`D`],[`𝐄`,`E`],[`𝐅`,`F`],[`𝐆`,`G`],[`𝐇`,`H`],[`𝐈`,`I`],[`𝐉`,`J`],[`𝐊`,`K`],[`𝐋`,`L`],[`𝐌`,`M`],[`𝐍`,`N`],[`𝐎`,`O`],[`𝐏`,`P`],[`𝐐`,`Q`],[`𝐑`,`R`],[`𝐒`,`S`],[`𝐓`,`T`],[`𝐔`,`U`],[`𝐕`,`V`],[`𝐖`,`W`],[`𝐗`,`X`],[`𝐘`,`Y`],[`𝐙`,`Z`],[`𝐚`,`a`],[`𝐛`,`b`],[`𝐜`,`c`],[`𝐝`,`d`],[`𝐞`,`e`],[`𝐟`,`f`],[`𝐠`,`g`],[`𝐡`,`h`],[`𝐢`,`i`],[`𝐣`,`j`],[`𝐤`,`k`],[`𝐥`,`l`],[`𝐦`,`m`],[`𝐧`,`n`],[`𝐨`,`o`],[`𝐩`,`p`],[`𝐪`,`q`],[`𝐫`,`r`],[`𝐬`,`s`],[`𝐭`,`t`],[`𝐮`,`u`],[`𝐯`,`v`],[`𝐰`,`w`],[`𝐱`,`x`],[`𝐲`,`y`],[`𝐳`,`z`],[`𝐴`,`A`],[`𝐵`,`B`],[`𝐶`,`C`],[`𝐷`,`D`],[`𝐸`,`E`],[`𝐹`,`F`],[`𝐺`,`G`],[`𝐻`,`H`],[`𝐼`,`I`],[`𝐽`,`J`],[`𝐾`,`K`],[`𝐿`,`L`],[`𝑀`,`M`],[`𝑁`,`N`],[`𝑂`,`O`],[`𝑃`,`P`],[`𝑄`,`Q`],[`𝑅`,`R`],[`𝑆`,`S`],[`𝑇`,`T`],[`𝑈`,`U`],[`𝑉`,`V`],[`𝑊`,`W`],[`𝑋`,`X`],[`𝑌`,`Y`],[`𝑍`,`Z`],[`𝑎`,`a`],[`𝑏`,`b`],[`𝑐`,`c`],[`𝑑`,`d`],[`𝑒`,`e`],[`𝑓`,`f`],[`𝑔`,`g`],[`𝑖`,`i`],[`𝑗`,`j`],[`𝑘`,`k`],[`𝑙`,`l`],[`𝑚`,`m`],[`𝑛`,`n`],[`𝑜`,`o`],[`𝑝`,`p`],[`𝑞`,`q`],[`𝑟`,`r`],[`𝑠`,`s`],[`𝑡`,`t`],[`𝑢`,`u`],[`𝑣`,`v`],[`𝑤`,`w`],[`𝑥`,`x`],[`𝑦`,`y`],[`𝑧`,`z`],[`𝑨`,`A`],[`𝑩`,`B`],[`𝑪`,`C`],[`𝑫`,`D`],[`𝑬`,`E`],[`𝑭`,`F`],[`𝑮`,`G`],[`𝑯`,`H`],[`𝑰`,`I`],[`𝑱`,`J`],[`𝑲`,`K`],[`𝑳`,`L`],[`𝑴`,`M`],[`𝑵`,`N`],[`𝑶`,`O`],[`𝑷`,`P`],[`𝑸`,`Q`],[`𝑹`,`R`],[`𝑺`,`S`],[`𝑻`,`T`],[`𝑼`,`U`],[`𝑽`,`V`],[`𝑾`,`W`],[`𝑿`,`X`],[`𝒀`,`Y`],[`𝒁`,`Z`],[`𝒂`,`a`],[`𝒃`,`b`],[`𝒄`,`c`],[`𝒅`,`d`],[`𝒆`,`e`],[`𝒇`,`f`],[`𝒈`,`g`],[`𝒉`,`h`],[`𝒊`,`i`],[`𝒋`,`j`],[`𝒌`,`k`],[`𝒍`,`l`],[`𝒎`,`m`],[`𝒏`,`n`],[`𝒐`,`o`],[`𝒑`,`p`],[`𝒒`,`q`],[`𝒓`,`r`],[`𝒔`,`s`],[`𝒕`,`t`],[`𝒖`,`u`],[`𝒗`,`v`],[`𝒘`,`w`],[`𝒙`,`x`],[`𝒚`,`y`],[`𝒛`,`z`],[`𝒜`,`A`],[`𝒞`,`C`],[`𝒟`,`D`],[`𝒢`,`g`],[`𝒥`,`J`],[`𝒦`,`K`],[`𝒩`,`N`],[`𝒪`,`O`],[`𝒫`,`P`],[`𝒬`,`Q`],[`𝒮`,`S`],[`𝒯`,`T`],[`𝒰`,`U`],[`𝒱`,`V`],[`𝒲`,`W`],[`𝒳`,`X`],[`𝒴`,`Y`],[`𝒵`,`Z`],[`𝒶`,`a`],[`𝒷`,`b`],[`𝒸`,`c`],[`𝒹`,`d`],[`𝒻`,`f`],[`𝒽`,`h`],[`𝒾`,`i`],[`𝒿`,`j`],[`𝓀`,`h`],[`𝓁`,`l`],[`𝓂`,`m`],[`𝓃`,`n`],[`𝓅`,`p`],[`𝓆`,`q`],[`𝓇`,`r`],[`𝓈`,`s`],[`𝓉`,`t`],[`𝓊`,`u`],[`𝓋`,`v`],[`𝓌`,`w`],[`𝓍`,`x`],[`𝓎`,`y`],[`𝓏`,`z`],[`𝓐`,`A`],[`𝓑`,`B`],[`𝓒`,`C`],[`𝓓`,`D`],[`𝓔`,`E`],[`𝓕`,`F`],[`𝓖`,`G`],[`𝓗`,`H`],[`𝓘`,`I`],[`𝓙`,`J`],[`𝓚`,`K`],[`𝓛`,`L`],[`𝓜`,`M`],[`𝓝`,`N`],[`𝓞`,`O`],[`𝓟`,`P`],[`𝓠`,`Q`],[`𝓡`,`R`],[`𝓢`,`S`],[`𝓣`,`T`],[`𝓤`,`U`],[`𝓥`,`V`],[`𝓦`,`W`],[`𝓧`,`X`],[`𝓨`,`Y`],[`𝓩`,`Z`],[`𝓪`,`a`],[`𝓫`,`b`],[`𝓬`,`c`],[`𝓭`,`d`],[`𝓮`,`e`],[`𝓯`,`f`],[`𝓰`,`g`],[`𝓱`,`h`],[`𝓲`,`i`],[`𝓳`,`j`],[`𝓴`,`k`],[`𝓵`,`l`],[`𝓶`,`m`],[`𝓷`,`n`],[`𝓸`,`o`],[`𝓹`,`p`],[`𝓺`,`q`],[`𝓻`,`r`],[`𝓼`,`s`],[`𝓽`,`t`],[`𝓾`,`u`],[`𝓿`,`v`],[`𝔀`,`w`],[`𝔁`,`x`],[`𝔂`,`y`],[`𝔃`,`z`],[`𝔄`,`A`],[`𝔅`,`B`],[`𝔇`,`D`],[`𝔈`,`E`],[`𝔉`,`F`],[`𝔊`,`G`],[`𝔍`,`J`],[`𝔎`,`K`],[`𝔏`,`L`],[`𝔐`,`M`],[`𝔑`,`N`],[`𝔒`,`O`],[`𝔓`,`P`],[`𝔔`,`Q`],[`𝔖`,`S`],[`𝔗`,`T`],[`𝔘`,`U`],[`𝔙`,`V`],[`𝔚`,`W`],[`𝔛`,`X`],[`𝔜`,`Y`],[`𝔞`,`a`],[`𝔟`,`b`],[`𝔠`,`c`],[`𝔡`,`d`],[`𝔢`,`e`],[`𝔣`,`f`],[`𝔤`,`g`],[`𝔥`,`h`],[`𝔦`,`i`],[`𝔧`,`j`],[`𝔨`,`k`],[`𝔩`,`l`],[`𝔪`,`m`],[`𝔫`,`n`],[`𝔬`,`o`],[`𝔭`,`p`],[`𝔮`,`q`],[`𝔯`,`r`],[`𝔰`,`s`],[`𝔱`,`t`],[`𝔲`,`u`],[`𝔳`,`v`],[`𝔴`,`w`],[`𝔵`,`x`],[`𝔶`,`y`],[`𝔷`,`z`],[`𝔸`,`A`],[`𝔹`,`B`],[`𝔻`,`D`],[`𝔼`,`E`],[`𝔽`,`F`],[`𝔾`,`G`],[`𝕀`,`I`],[`𝕁`,`J`],[`𝕂`,`K`],[`𝕃`,`L`],[`𝕄`,`M`],[`𝕆`,`N`],[`𝕊`,`S`],[`𝕋`,`T`],[`𝕌`,`U`],[`𝕍`,`V`],[`𝕎`,`W`],[`𝕏`,`X`],[`𝕐`,`Y`],[`𝕒`,`a`],[`𝕓`,`b`],[`𝕔`,`c`],[`𝕕`,`d`],[`𝕖`,`e`],[`𝕗`,`f`],[`𝕘`,`g`],[`𝕙`,`h`],[`𝕚`,`i`],[`𝕛`,`j`],[`𝕜`,`k`],[`𝕝`,`l`],[`𝕞`,`m`],[`𝕟`,`n`],[`𝕠`,`o`],[`𝕡`,`p`],[`𝕢`,`q`],[`𝕣`,`r`],[`𝕤`,`s`],[`𝕥`,`t`],[`𝕦`,`u`],[`𝕧`,`v`],[`𝕨`,`w`],[`𝕩`,`x`],[`𝕪`,`y`],[`𝕫`,`z`],[`𝕬`,`A`],[`𝕭`,`B`],[`𝕮`,`C`],[`𝕯`,`D`],[`𝕰`,`E`],[`𝕱`,`F`],[`𝕲`,`G`],[`𝕳`,`H`],[`𝕴`,`I`],[`𝕵`,`J`],[`𝕶`,`K`],[`𝕷`,`L`],[`𝕸`,`M`],[`𝕹`,`N`],[`𝕺`,`O`],[`𝕻`,`P`],[`𝕼`,`Q`],[`𝕽`,`R`],[`𝕾`,`S`],[`𝕿`,`T`],[`𝖀`,`U`],[`𝖁`,`V`],[`𝖂`,`W`],[`𝖃`,`X`],[`𝖄`,`Y`],[`𝖅`,`Z`],[`𝖆`,`a`],[`𝖇`,`b`],[`𝖈`,`c`],[`𝖉`,`d`],[`𝖊`,`e`],[`𝖋`,`f`],[`𝖌`,`g`],[`𝖍`,`h`],[`𝖎`,`i`],[`𝖏`,`j`],[`𝖐`,`k`],[`𝖑`,`l`],[`𝖒`,`m`],[`𝖓`,`n`],[`𝖔`,`o`],[`𝖕`,`p`],[`𝖖`,`q`],[`𝖗`,`r`],[`𝖘`,`s`],[`𝖙`,`t`],[`𝖚`,`u`],[`𝖛`,`v`],[`𝖜`,`w`],[`𝖝`,`x`],[`𝖞`,`y`],[`𝖟`,`z`],[`𝖠`,`A`],[`𝖡`,`B`],[`𝖢`,`C`],[`𝖣`,`D`],[`𝖤`,`E`],[`𝖥`,`F`],[`𝖦`,`G`],[`𝖧`,`H`],[`𝖨`,`I`],[`𝖩`,`J`],[`𝖪`,`K`],[`𝖫`,`L`],[`𝖬`,`M`],[`𝖭`,`N`],[`𝖮`,`O`],[`𝖯`,`P`],[`𝖰`,`Q`],[`𝖱`,`R`],[`𝖲`,`S`],[`𝖳`,`T`],[`𝖴`,`U`],[`𝖵`,`V`],[`𝖶`,`W`],[`𝖷`,`X`],[`𝖸`,`Y`],[`𝖹`,`Z`],[`𝖺`,`a`],[`𝖻`,`b`],[`𝖼`,`c`],[`𝖽`,`d`],[`𝖾`,`e`],[`𝖿`,`f`],[`𝗀`,`g`],[`𝗁`,`h`],[`𝗂`,`i`],[`𝗃`,`j`],[`𝗄`,`k`],[`𝗅`,`l`],[`𝗆`,`m`],[`𝗇`,`n`],[`𝗈`,`o`],[`𝗉`,`p`],[`𝗊`,`q`],[`𝗋`,`r`],[`𝗌`,`s`],[`𝗍`,`t`],[`𝗎`,`u`],[`𝗏`,`v`],[`𝗐`,`w`],[`𝗑`,`x`],[`𝗒`,`y`],[`𝗓`,`z`],[`𝗔`,`A`],[`𝗕`,`B`],[`𝗖`,`C`],[`𝗗`,`D`],[`𝗘`,`E`],[`𝗙`,`F`],[`𝗚`,`G`],[`𝗛`,`H`],[`𝗜`,`I`],[`𝗝`,`J`],[`𝗞`,`K`],[`𝗟`,`L`],[`𝗠`,`M`],[`𝗡`,`N`],[`𝗢`,`O`],[`𝗣`,`P`],[`𝗤`,`Q`],[`𝗥`,`R`],[`𝗦`,`S`],[`𝗧`,`T`],[`𝗨`,`U`],[`𝗩`,`V`],[`𝗪`,`W`],[`𝗫`,`X`],[`𝗬`,`Y`],[`𝗭`,`Z`],[`𝗮`,`a`],[`𝗯`,`b`],[`𝗰`,`c`],[`𝗱`,`d`],[`𝗲`,`e`],[`𝗳`,`f`],[`𝗴`,`g`],[`𝗵`,`h`],[`𝗶`,`i`],[`𝗷`,`j`],[`𝗸`,`k`],[`𝗹`,`l`],[`𝗺`,`m`],[`𝗻`,`n`],[`𝗼`,`o`],[`𝗽`,`p`],[`𝗾`,`q`],[`𝗿`,`r`],[`𝘀`,`s`],[`𝘁`,`t`],[`𝘂`,`u`],[`𝘃`,`v`],[`𝘄`,`w`],[`𝘅`,`x`],[`𝘆`,`y`],[`𝘇`,`z`],[`𝘈`,`A`],[`𝘉`,`B`],[`𝘊`,`C`],[`𝘋`,`D`],[`𝘌`,`E`],[`𝘍`,`F`],[`𝘎`,`G`],[`𝘏`,`H`],[`𝘐`,`I`],[`𝘑`,`J`],[`𝘒`,`K`],[`𝘓`,`L`],[`𝘔`,`M`],[`𝘕`,`N`],[`𝘖`,`O`],[`𝘗`,`P`],[`𝘘`,`Q`],[`𝘙`,`R`],[`𝘚`,`S`],[`𝘛`,`T`],[`𝘜`,`U`],[`𝘝`,`V`],[`𝘞`,`W`],[`𝘟`,`X`],[`𝘠`,`Y`],[`𝘡`,`Z`],[`𝘢`,`a`],[`𝘣`,`b`],[`𝘤`,`c`],[`𝘥`,`d`],[`𝘦`,`e`],[`𝘧`,`f`],[`𝘨`,`g`],[`𝘩`,`h`],[`𝘪`,`i`],[`𝘫`,`j`],[`𝘬`,`k`],[`𝘭`,`l`],[`𝘮`,`m`],[`𝘯`,`n`],[`𝘰`,`o`],[`𝘱`,`p`],[`𝘲`,`q`],[`𝘳`,`r`],[`𝘴`,`s`],[`𝘵`,`t`],[`𝘶`,`u`],[`𝘷`,`v`],[`𝘸`,`w`],[`𝘹`,`x`],[`𝘺`,`y`],[`𝘻`,`z`],[`𝘼`,`A`],[`𝘽`,`B`],[`𝘾`,`C`],[`𝘿`,`D`],[`𝙀`,`E`],[`𝙁`,`F`],[`𝙂`,`G`],[`𝙃`,`H`],[`𝙄`,`I`],[`𝙅`,`J`],[`𝙆`,`K`],[`𝙇`,`L`],[`𝙈`,`M`],[`𝙉`,`N`],[`𝙊`,`O`],[`𝙋`,`P`],[`𝙌`,`Q`],[`𝙍`,`R`],[`𝙎`,`S`],[`𝙏`,`T`],[`𝙐`,`U`],[`𝙑`,`V`],[`𝙒`,`W`],[`𝙓`,`X`],[`𝙔`,`Y`],[`𝙕`,`Z`],[`𝙖`,`a`],[`𝙗`,`b`],[`𝙘`,`c`],[`𝙙`,`d`],[`𝙚`,`e`],[`𝙛`,`f`],[`𝙜`,`g`],[`𝙝`,`h`],[`𝙞`,`i`],[`𝙟`,`j`],[`𝙠`,`k`],[`𝙡`,`l`],[`𝙢`,`m`],[`𝙣`,`n`],[`𝙤`,`o`],[`𝙥`,`p`],[`𝙦`,`q`],[`𝙧`,`r`],[`𝙨`,`s`],[`𝙩`,`t`],[`𝙪`,`u`],[`𝙫`,`v`],[`𝙬`,`w`],[`𝙭`,`x`],[`𝙮`,`y`],[`𝙯`,`z`],[`𝙰`,`A`],[`𝙱`,`B`],[`𝙲`,`C`],[`𝙳`,`D`],[`𝙴`,`E`],[`𝙵`,`F`],[`𝙶`,`G`],[`𝙷`,`H`],[`𝙸`,`I`],[`𝙹`,`J`],[`𝙺`,`K`],[`𝙻`,`L`],[`𝙼`,`M`],[`𝙽`,`N`],[`𝙾`,`O`],[`𝙿`,`P`],[`𝚀`,`Q`],[`𝚁`,`R`],[`𝚂`,`S`],[`𝚃`,`T`],[`𝚄`,`U`],[`𝚅`,`V`],[`𝚆`,`W`],[`𝚇`,`X`],[`𝚈`,`Y`],[`𝚉`,`Z`],[`𝚊`,`a`],[`𝚋`,`b`],[`𝚌`,`c`],[`𝚍`,`d`],[`𝚎`,`e`],[`𝚏`,`f`],[`𝚐`,`g`],[`𝚑`,`h`],[`𝚒`,`i`],[`𝚓`,`j`],[`𝚔`,`k`],[`𝚕`,`l`],[`𝚖`,`m`],[`𝚗`,`n`],[`𝚘`,`o`],[`𝚙`,`p`],[`𝚚`,`q`],[`𝚛`,`r`],[`𝚜`,`s`],[`𝚝`,`t`],[`𝚞`,`u`],[`𝚟`,`v`],[`𝚠`,`w`],[`𝚡`,`x`],[`𝚢`,`y`],[`𝚣`,`z`],[`𝚤`,`l`],[`𝚥`,`j`],[`𝛢`,`A`],[`𝛣`,`B`],[`𝛤`,`G`],[`𝛥`,`D`],[`𝛦`,`E`],[`𝛧`,`Z`],[`𝛨`,`I`],[`𝛩`,`TH`],[`𝛪`,`I`],[`𝛫`,`K`],[`𝛬`,`L`],[`𝛭`,`M`],[`𝛮`,`N`],[`𝛯`,`KS`],[`𝛰`,`O`],[`𝛱`,`P`],[`𝛲`,`R`],[`𝛳`,`TH`],[`𝛴`,`S`],[`𝛵`,`T`],[`𝛶`,`Y`],[`𝛷`,`F`],[`𝛸`,`x`],[`𝛹`,`PS`],[`𝛺`,`O`],[`𝛻`,`D`],[`𝛼`,`a`],[`𝛽`,`b`],[`𝛾`,`g`],[`𝛿`,`d`],[`𝜀`,`e`],[`𝜁`,`z`],[`𝜂`,`i`],[`𝜃`,`th`],[`𝜄`,`i`],[`𝜅`,`k`],[`𝜆`,`l`],[`𝜇`,`m`],[`𝜈`,`n`],[`𝜉`,`ks`],[`𝜊`,`o`],[`𝜋`,`p`],[`𝜌`,`r`],[`𝜍`,`s`],[`𝜎`,`s`],[`𝜏`,`t`],[`𝜐`,`y`],[`𝜑`,`f`],[`𝜒`,`x`],[`𝜓`,`ps`],[`𝜔`,`o`],[`𝜕`,`d`],[`𝜖`,`E`],[`𝜗`,`TH`],[`𝜘`,`K`],[`𝜙`,`f`],[`𝜚`,`r`],[`𝜛`,`p`],[`𝜜`,`A`],[`𝜝`,`V`],[`𝜞`,`G`],[`𝜟`,`D`],[`𝜠`,`E`],[`𝜡`,`Z`],[`𝜢`,`I`],[`𝜣`,`TH`],[`𝜤`,`I`],[`𝜥`,`K`],[`𝜦`,`L`],[`𝜧`,`M`],[`𝜨`,`N`],[`𝜩`,`KS`],[`𝜪`,`O`],[`𝜫`,`P`],[`𝜬`,`S`],[`𝜭`,`TH`],[`𝜮`,`S`],[`𝜯`,`T`],[`𝜰`,`Y`],[`𝜱`,`F`],[`𝜲`,`X`],[`𝜳`,`PS`],[`𝜴`,`O`],[`𝜵`,`D`],[`𝜶`,`a`],[`𝜷`,`v`],[`𝜸`,`g`],[`𝜹`,`d`],[`𝜺`,`e`],[`𝜻`,`z`],[`𝜼`,`i`],[`𝜽`,`th`],[`𝜾`,`i`],[`𝜿`,`k`],[`𝝀`,`l`],[`𝝁`,`m`],[`𝝂`,`n`],[`𝝃`,`ks`],[`𝝄`,`o`],[`𝝅`,`p`],[`𝝆`,`r`],[`𝝇`,`s`],[`𝝈`,`s`],[`𝝉`,`t`],[`𝝊`,`y`],[`𝝋`,`f`],[`𝝌`,`x`],[`𝝍`,`ps`],[`𝝎`,`o`],[`𝝏`,`a`],[`𝝐`,`e`],[`𝝑`,`i`],[`𝝒`,`k`],[`𝝓`,`f`],[`𝝔`,`r`],[`𝝕`,`p`],[`𝝖`,`A`],[`𝝗`,`B`],[`𝝘`,`G`],[`𝝙`,`D`],[`𝝚`,`E`],[`𝝛`,`Z`],[`𝝜`,`I`],[`𝝝`,`TH`],[`𝝞`,`I`],[`𝝟`,`K`],[`𝝠`,`L`],[`𝝡`,`M`],[`𝝢`,`N`],[`𝝣`,`KS`],[`𝝤`,`O`],[`𝝥`,`P`],[`𝝦`,`R`],[`𝝧`,`TH`],[`𝝨`,`S`],[`𝝩`,`T`],[`𝝪`,`Y`],[`𝝫`,`F`],[`𝝬`,`X`],[`𝝭`,`PS`],[`𝝮`,`O`],[`𝝯`,`D`],[`𝝰`,`a`],[`𝝱`,`v`],[`𝝲`,`g`],[`𝝳`,`d`],[`𝝴`,`e`],[`𝝵`,`z`],[`𝝶`,`i`],[`𝝷`,`th`],[`𝝸`,`i`],[`𝝹`,`k`],[`𝝺`,`l`],[`𝝻`,`m`],[`𝝼`,`n`],[`𝝽`,`ks`],[`𝝾`,`o`],[`𝝿`,`p`],[`𝞀`,`r`],[`𝞁`,`s`],[`𝞂`,`s`],[`𝞃`,`t`],[`𝞄`,`y`],[`𝞅`,`f`],[`𝞆`,`x`],[`𝞇`,`ps`],[`𝞈`,`o`],[`𝞉`,`a`],[`𝞊`,`e`],[`𝞋`,`i`],[`𝞌`,`k`],[`𝞍`,`f`],[`𝞎`,`r`],[`𝞏`,`p`],[`𝞐`,`A`],[`𝞑`,`V`],[`𝞒`,`G`],[`𝞓`,`D`],[`𝞔`,`E`],[`𝞕`,`Z`],[`𝞖`,`I`],[`𝞗`,`TH`],[`𝞘`,`I`],[`𝞙`,`K`],[`𝞚`,`L`],[`𝞛`,`M`],[`𝞜`,`N`],[`𝞝`,`KS`],[`𝞞`,`O`],[`𝞟`,`P`],[`𝞠`,`S`],[`𝞡`,`TH`],[`𝞢`,`S`],[`𝞣`,`T`],[`𝞤`,`Y`],[`𝞥`,`F`],[`𝞦`,`X`],[`𝞧`,`PS`],[`𝞨`,`O`],[`𝞩`,`D`],[`𝞪`,`av`],[`𝞫`,`g`],[`𝞬`,`d`],[`𝞭`,`e`],[`𝞮`,`z`],[`𝞯`,`i`],[`𝞰`,`i`],[`𝞱`,`th`],[`𝞲`,`i`],[`𝞳`,`k`],[`𝞴`,`l`],[`𝞵`,`m`],[`𝞶`,`n`],[`𝞷`,`ks`],[`𝞸`,`o`],[`𝞹`,`p`],[`𝞺`,`r`],[`𝞻`,`s`],[`𝞼`,`s`],[`𝞽`,`t`],[`𝞾`,`y`],[`𝞿`,`f`],[`𝟀`,`x`],[`𝟁`,`ps`],[`𝟂`,`o`],[`𝟃`,`a`],[`𝟄`,`e`],[`𝟅`,`i`],[`𝟆`,`k`],[`𝟇`,`f`],[`𝟈`,`r`],[`𝟉`,`p`],[`𝟊`,`F`],[`𝟋`,`f`],[`⒜`,`(a)`],[`⒝`,`(b)`],[`⒞`,`(c)`],[`⒟`,`(d)`],[`⒠`,`(e)`],[`⒡`,`(f)`],[`⒢`,`(g)`],[`⒣`,`(h)`],[`⒤`,`(i)`],[`⒥`,`(j)`],[`⒦`,`(k)`],[`⒧`,`(l)`],[`⒨`,`(m)`],[`⒩`,`(n)`],[`⒪`,`(o)`],[`⒫`,`(p)`],[`⒬`,`(q)`],[`⒭`,`(r)`],[`⒮`,`(s)`],[`⒯`,`(t)`],[`⒰`,`(u)`],[`⒱`,`(v)`],[`⒲`,`(w)`],[`⒳`,`(x)`],[`⒴`,`(y)`],[`⒵`,`(z)`],[`Ⓐ`,`(A)`],[`Ⓑ`,`(B)`],[`Ⓒ`,`(C)`],[`Ⓓ`,`(D)`],[`Ⓔ`,`(E)`],[`Ⓕ`,`(F)`],[`Ⓖ`,`(G)`],[`Ⓗ`,`(H)`],[`Ⓘ`,`(I)`],[`Ⓙ`,`(J)`],[`Ⓚ`,`(K)`],[`Ⓛ`,`(L)`],[`Ⓝ`,`(N)`],[`Ⓞ`,`(O)`],[`Ⓟ`,`(P)`],[`Ⓠ`,`(Q)`],[`Ⓡ`,`(R)`],[`Ⓢ`,`(S)`],[`Ⓣ`,`(T)`],[`Ⓤ`,`(U)`],[`Ⓥ`,`(V)`],[`Ⓦ`,`(W)`],[`Ⓧ`,`(X)`],[`Ⓨ`,`(Y)`],[`Ⓩ`,`(Z)`],[`ⓐ`,`(a)`],[`ⓑ`,`(b)`],[`ⓒ`,`(b)`],[`ⓓ`,`(c)`],[`ⓔ`,`(e)`],[`ⓕ`,`(f)`],[`ⓖ`,`(g)`],[`ⓗ`,`(h)`],[`ⓘ`,`(i)`],[`ⓙ`,`(j)`],[`ⓚ`,`(k)`],[`ⓛ`,`(l)`],[`ⓜ`,`(m)`],[`ⓝ`,`(n)`],[`ⓞ`,`(o)`],[`ⓟ`,`(p)`],[`ⓠ`,`(q)`],[`ⓡ`,`(r)`],[`ⓢ`,`(s)`],[`ⓣ`,`(t)`],[`ⓤ`,`(u)`],[`ⓥ`,`(v)`],[`ⓦ`,`(w)`],[`ⓧ`,`(x)`],[`ⓨ`,`(y)`],[`ⓩ`,`(z)`],[`Ċ`,`C`],[`ċ`,`c`],[`Ġ`,`G`],[`ġ`,`g`],[`Ħ`,`H`],[`ħ`,`h`],[`Ż`,`Z`],[`ż`,`z`],[`𝟎`,`0`],[`𝟏`,`1`],[`𝟐`,`2`],[`𝟑`,`3`],[`𝟒`,`4`],[`𝟓`,`5`],[`𝟔`,`6`],[`𝟕`,`7`],[`𝟖`,`8`],[`𝟗`,`9`],[`𝟘`,`0`],[`𝟙`,`1`],[`𝟚`,`2`],[`𝟛`,`3`],[`𝟜`,`4`],[`𝟝`,`5`],[`𝟞`,`6`],[`𝟟`,`7`],[`𝟠`,`8`],[`𝟡`,`9`],[`𝟢`,`0`],[`𝟣`,`1`],[`𝟤`,`2`],[`𝟥`,`3`],[`𝟦`,`4`],[`𝟧`,`5`],[`𝟨`,`6`],[`𝟩`,`7`],[`𝟪`,`8`],[`𝟫`,`9`],[`𝟬`,`0`],[`𝟭`,`1`],[`𝟮`,`2`],[`𝟯`,`3`],[`𝟰`,`4`],[`𝟱`,`5`],[`𝟲`,`6`],[`𝟳`,`7`],[`𝟴`,`8`],[`𝟵`,`9`],[`𝟶`,`0`],[`𝟷`,`1`],[`𝟸`,`2`],[`𝟹`,`3`],[`𝟺`,`4`],[`𝟻`,`5`],[`𝟼`,`6`],[`𝟽`,`7`],[`𝟾`,`8`],[`𝟿`,`9`],[`①`,`1`],[`②`,`2`],[`③`,`3`],[`④`,`4`],[`⑤`,`5`],[`⑥`,`6`],[`⑦`,`7`],[`⑧`,`8`],[`⑨`,`9`],[`⑩`,`10`],[`⑪`,`11`],[`⑫`,`12`],[`⑬`,`13`],[`⑭`,`14`],[`⑮`,`15`],[`⑯`,`16`],[`⑰`,`17`],[`⑱`,`18`],[`⑲`,`19`],[`⑳`,`20`],[`⑴`,`1`],[`⑵`,`2`],[`⑶`,`3`],[`⑷`,`4`],[`⑸`,`5`],[`⑹`,`6`],[`⑺`,`7`],[`⑻`,`8`],[`⑼`,`9`],[`⑽`,`10`],[`⑾`,`11`],[`⑿`,`12`],[`⒀`,`13`],[`⒁`,`14`],[`⒂`,`15`],[`⒃`,`16`],[`⒄`,`17`],[`⒅`,`18`],[`⒆`,`19`],[`⒇`,`20`],[`⒈`,`1.`],[`⒉`,`2.`],[`⒊`,`3.`],[`⒋`,`4.`],[`⒌`,`5.`],[`⒍`,`6.`],[`⒎`,`7.`],[`⒏`,`8.`],[`⒐`,`9.`],[`⒑`,`10.`],[`⒒`,`11.`],[`⒓`,`12.`],[`⒔`,`13.`],[`⒕`,`14.`],[`⒖`,`15.`],[`⒗`,`16.`],[`⒘`,`17.`],[`⒙`,`18.`],[`⒚`,`19.`],[`⒛`,`20.`],[`⓪`,`0`],[`⓫`,`11`],[`⓬`,`12`],[`⓭`,`13`],[`⓮`,`14`],[`⓯`,`15`],[`⓰`,`16`],[`⓱`,`17`],[`⓲`,`18`],[`⓳`,`19`],[`⓴`,`20`],[`⓵`,`1`],[`⓶`,`2`],[`⓷`,`3`],[`⓸`,`4`],[`⓹`,`5`],[`⓺`,`6`],[`⓻`,`7`],[`⓼`,`8`],[`⓽`,`9`],[`⓾`,`10`],[`⓿`,`0`],[`🙰`,`&`],[`🙱`,`&`],[`🙲`,`&`],[`🙳`,`&`],[`🙴`,`&`],[`🙵`,`&`],[`🙶`,`"`],[`🙷`,`"`],[`🙸`,`"`],[`‽`,`?!`],[`🙹`,`?!`],[`🙺`,`?!`],[`🙻`,`?!`],[`🙼`,`/`],[`🙽`,`\\`],[`🜇`,`AR`],[`🜈`,`V`],[`🜉`,`V`],[`🜆`,`VR`],[`🜅`,`VF`],[`🜩`,`2`],[`🜪`,`5`],[`🝡`,`f`],[`🝢`,`W`],[`🝣`,`U`],[`🝧`,`V`],[`🝨`,`T`],[`🝪`,`V`],[`🝫`,`MB`],[`🝬`,`VB`],[`🝲`,`3B`],[`🝳`,`3B`],[`💯`,`100`],[`🔙`,`BACK`],[`🔚`,`END`],[`🔛`,`ON!`],[`🔜`,`SOON`],[`🔝`,`TOP`],[`🔞`,`18`],[`🔤`,`abc`],[`🔠`,`ABCD`],[`🔡`,`abcd`],[`🔢`,`1234`],[`🔣`,`T&@%`],[`#️⃣`,`#`],[`*️⃣`,`*`],[`0️⃣`,`0`],[`1️⃣`,`1`],[`2️⃣`,`2`],[`3️⃣`,`3`],[`4️⃣`,`4`],[`5️⃣`,`5`],[`6️⃣`,`6`],[`7️⃣`,`7`],[`8️⃣`,`8`],[`9️⃣`,`9`],[`🔟`,`10`],[`🅰️`,`A`],[`🅱️`,`B`],[`🆎`,`AB`],[`🆑`,`CL`],[`🅾️`,`O`],[`🅿`,`P`],[`🆘`,`SOS`],[`🅲`,`C`],[`🅳`,`D`],[`🅴`,`E`],[`🅵`,`F`],[`🅶`,`G`],[`🅷`,`H`],[`🅸`,`I`],[`🅹`,`J`],[`🅺`,`K`],[`🅻`,`L`],[`🅼`,`M`],[`🅽`,`N`],[`🆀`,`Q`],[`🆁`,`R`],[`🆂`,`S`],[`🆃`,`T`],[`🆄`,`U`],[`🆅`,`V`],[`🆆`,`W`],[`🆇`,`X`],[`🆈`,`Y`],[`🆉`,`Z`]],hnt=(e,t)=>{for(let[n,r]of t)e=e.replace(new RegExp(iw(n),`g`),r);return e};function gnt(e,t){if(typeof e!=`string`)throw TypeError(`Expected a string, got \`${typeof e}\``);t={customReplacements:[],...t};let n=new Map([...mnt,...t.customReplacements]);return e=e.normalize(),e=hnt(e,n),e=e.normalize(`NFD`).replace(/\p{Diacritic}/gu,``).normalize(),e}var _nt=[[`&`,` and `],[`🦄`,` unicorn `],[`♥`,` love `]],vnt=e=>e.replace(/([A-Z]{2,})(\d+)/g,`$1 $2`).replace(/([a-z\d]+)([A-Z]{2,})/g,`$1 $2`).replace(/([a-z\d])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-rt-z\d]+)/g,`$1 $2`),ynt=(e,t)=>{let n=iw(t);return e.replace(RegExp(`${n}{2,}`,`g`),t).replace(RegExp(`^${n}|${n}$`,`g`),``)},bnt=e=>{let t=`a-z\\d`;if(t+=e.lowercase?``:`A-Z`,e.preserveCharacters.length>0)for(let n of e.preserveCharacters){if(n===e.separator)throw Error(`The separator character \`${e.separator}\` cannot be included in preserved characters: ${e.preserveCharacters}`);t+=iw(n)}return RegExp(`[^${t}]+`,`g`)};function $Y(e,t){if(typeof e!=`string`)throw TypeError(`Expected a string, got \`${typeof e}\``);t={separator:`-`,lowercase:!0,decamelize:!0,customReplacements:[],preserveLeadingUnderscore:!1,preserveTrailingDash:!1,preserveCharacters:[],...t};let n=t.preserveLeadingUnderscore&&e.startsWith(`_`),r=t.preserveTrailingDash&&e.endsWith(`-`),i=new Map([..._nt,...t.customReplacements]);e=gnt(e,{customReplacements:i}),t.decamelize&&(e=vnt(e));let a=bnt(t);return t.lowercase&&(e=e.toLowerCase()),e=e.replace(/([a-zA-Z\d]+)'([ts])(\s|$)/g,`$1$2$3`),e=e.replace(a,t.separator),e=e.replace(/\\/g,``),t.separator&&(e=ynt(e,t.separator)),n&&(e=`_${e}`),r&&(e=`${e}-`),e}var eX=e=>$Y(e.toUpperCase(),{lowercase:!1,separator:`_`}),xnt=(e,t,n)=>`API_KEY_${eX(e)||eX(t)||`PROVIDER`}_${n}`,Snt=(e,t)=>{let n=e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[._-]+|[._-]+$/g,``),r=(e===`__custom`?`custom`:n||`provider`).slice(0,64).replace(/[._-]+$/g,``),i=new Set(Array.from(t,e=>e.toLowerCase()));if(!i.has(r))return r;let a=2,o=r;do{let e=`-${a}`;o=`${r.slice(0,64-e.length).replace(/[._-]+$/g,``)}${e}`,a+=1}while(i.has(o));return o},Cnt=(e,t)=>e.length===0||e===t,wnt=Pm().min(1,`Provider Name is required`).max(64,`Provider Name must be 64 characters or fewer`).regex(/^[a-z0-9][a-z0-9._-]*$/,`Use lowercase letters, numbers, periods, underscores, or hyphens, starting with a letter or number`),tX=Rm({provider:Pm().min(1,`Provider is required`),customProviderName:Pm().optional(),label:wnt,apiKey:Pm().optional(),envVarName:Pm().optional(),baseUrl:Pm().url(`Must be a valid URL`).optional(),region:Pm().optional(),gcpProjectId:Pm().optional(),customModels:Lm(Rm({modelId:Pm().optional(),name:Pm().min(1,`Model name is required`),kind:Bm([`completions`,`embeddings`]),inputCostPerToken:Fm().min(0,`Cost must be non-negative`),outputCostPerToken:Fm().min(0,`Cost must be non-negative`),status:Bm([`active`,`deprecated`])})).optional(),models:Rm({completions:Lm(Pm()).optional(),embeddings:Lm(Pm()).optional()}).optional()}),nX=e=>e.refine(e=>e.provider!==`__custom`||(e.baseUrl?.length??0)>0,{message:`API URL is required for custom providers`,path:[`baseUrl`]}).superRefine((e,t)=>{if(e.provider!==`__custom`||!e.baseUrl)return;let n;try{n=new URL(e.baseUrl)}catch{return}let r=e=>t.addIssue({code:Pp.custom,path:[`baseUrl`],message:e});if(n.protocol!==`https:`&&n.protocol!==`http:`){r(`API URL must use http or https — replace '${n.protocol}//' with 'https://'`);return}(n.username||n.password)&&r(`API URL must not embed credentials — the API key belongs in the API Key field. Remove the 'user:password@' part`),n.search&&r(`API URL must not contain a query string. Remove everything from '${n.search}' on`),n.hash&&r(`API URL must not contain a fragment. Remove everything from '${n.hash}' on`);let i=n.pathname.replace(/\/+$/,``),a=/\/v1(?:\/(?:chat\/completions|embeddings))?$/.exec(i);if(a){let e=`${n.origin}${i.slice(0,-a[0].length)}`;r(`The gateway appends /v1/chat/completions itself, so the API URL must not end in '${a[0]}'. Use '${e}'`)}}).refine(e=>e.provider!==`__custom`||(e.customModels?.length??0)>0,{message:`Models are required for custom providers`,path:[`customModels`]}).refine(e=>e.provider!==`BedrockMantle`||(e.region?.trim().length??0)>0,{message:`AWS Region is required for Bedrock Mantle`,path:[`region`]}).refine(e=>e.provider!==`BedrockMantle`||!e.region?.trim()||tje.test(e.region.trim()),{message:`Enter a lowercase AWS region code, like us-east-1`,path:[`region`]}).refine(e=>e.provider!==`BedrockMantle`||!e.apiKey?.trim().startsWith(`bedrock-api-key-`),{message:`This is a short-term Bedrock API key, which expires within 12 hours. Create a long-term key (it starts with ABSK) in the AWS console`,path:[`apiKey`]}).refine(e=>e.provider!==`BedrockMantle`||!e.apiKey?.trim()||e.apiKey.trim().startsWith(`ABSK`),{message:`Bedrock Mantle uses long-term Bedrock API keys, which start with ABSK`,path:[`apiKey`]}).refine(e=>e.provider!==`VertexAI`||(e.region?.trim().length??0)>0,{message:`Location is required for Vertex AI`,path:[`region`]}).refine(e=>e.provider!==`VertexAI`||!e.region?.trim()||oje.test(e.region.trim()),{message:`Enter a lowercase Google Cloud location, like us-central1, or global`,path:[`region`]}).refine(e=>e.provider!==`VertexAI`||(e.gcpProjectId?.trim().length??0)>0,{message:`Google Cloud project ID is required for Vertex AI`,path:[`gcpProjectId`]}).refine(e=>e.provider!==`VertexAI`||!e.gcpProjectId?.trim()||!/^\d+$/.test(e.gcpProjectId.trim()),{message:`This looks like a project number. Use the project ID — the readable identifier next to the project name in the Google Cloud console`,path:[`gcpProjectId`]}).refine(e=>e.provider!==`VertexAI`||!e.gcpProjectId?.trim()||sje.test(e.gcpProjectId.trim()),{message:`Project IDs are 6 to 30 characters: lowercase letters, digits and hyphens, starting with a letter`,path:[`gcpProjectId`]}).refine(e=>e.provider!==`VertexAI`||!e.apiKey?.trim()||uje(e.apiKey.trim()),{message:`Vertex AI authenticates with a service account, not an API key. Paste the whole JSON key file from the Google Cloud console (IAM & Admin > Service Accounts > Keys)`,path:[`apiKey`]}),Tnt=nX(tX),Ent=nX(tX.extend({label:Pm().min(1,`Provider Name is required`)})),Dnt=(e,t=[])=>{let n=new Set(Array.from(e,e=>e.toLowerCase())),r=new Set(Array.from(t,e=>e.toLowerCase()));return Tnt.refine(e=>!n.has(e.label.toLowerCase()),{message:`This Provider Name is already in use`,path:[`label`]}).refine(e=>e.provider!==`__custom`||!r.has(e.label.toLowerCase()),{message:`This custom provider name is already in use`,path:[`label`]})};function rX(){let[e,t]=(0,H.useTransition)();return{startOpening:t,renderTrigger:t=>(0,H.isValidElement)(t)?(0,H.cloneElement)(t,{disabled:t.props.disabled||e,children:(0,U.jsx)(rM,{loading:e,className:`flex items-center justify-center gap-2`,children:t.props.children})}):t}}var Ont=SY(`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`,6),knt=`OpenAI`;function Ant(e){return e===`ZuploDemo`?`Zuplo Demo needs no API key. Select the models you want available.`:e===`VertexAI`?`Vertex AI authenticates with a Google Cloud service account, not an API key. Set the location and project, paste the JSON key file, and select available models.`:`Configure a new AI provider with your API key and select available models.`}var iX=({children:e,onOpenChange:t,defaultOpen:n=!1,initialValues:r})=>{let[i,a]=(0,H.useState)(n),{startOpening:o,renderTrigger:s}=rX(),c=wY(),l=Dt(),{account:u,project:d}=lb([`account`,`project`]),f=cY(),{logEvent:p}=on(),m=CY(),h=Xtt().data,g=(0,H.useCallback)(e=>Snt(e,h.flatMap(t=>[t.label,...e===`__custom`&&t.customProviderName?[t.customProviderName]:[]])),[h]),_=JE(r?.provider)&&!YE(f)?void 0:r,v=_?.provider?.trim()||knt,y=v===qE,b=(0,H.useCallback)(()=>({provider:v,customProviderName:void 0,label:_?.label?.trim()||g(v),apiKey:``,region:``,gcpProjectId:``,models:{completions:_?.models?.completions??[],embeddings:_?.models?.embeddings??[]},...y?{baseUrl:_?.baseUrl?.trim()||void 0,customModels:_?.customModels?.map(e=>({name:e.name,kind:e.kind,status:`active`,inputCostPerToken:e.inputCostPerToken??0,outputCostPerToken:e.outputCostPerToken??0}))}:{}}),[g,_,y,v]),x=(0,H.useMemo)(()=>Dnt(h.map(e=>e.label),h.flatMap(e=>e.customProviderName?[e.customProviderName]:[])),[h]),S=je({mutationFn:async e=>{let t=e.provider===qE,n=t?`Custom`:e.provider;if(t){let t=await l.fetch(tn.ai.createBucketAiProvider(c,{name:e.label,baseURL:e.baseUrl??``}));for(let n of e.customModels??[])await l.fetch(tn.ai.createAiProviderModel(c,t.id,{model:n.name,kind:n.kind,inputCostPerToken:n.inputCostPerToken,outputCostPerToken:n.outputCostPerToken,status:`active`}))}return await l.fetch(tn.ai.createAiProviderAssignment(u,d,{provider:n,customProviderName:t?e.label:void 0,label:e.label,envVarName:xnt(e.label,n,Ont()),...e.apiKey?.trim()?{value:e.apiKey.trim()}:{},endpointUrl:dje(e),...e.provider===`VertexAI`&&e.gcpProjectId?.trim()?{gcpProjectId:e.gcpProjectId.trim()}:{},metadata:{models:e.customModels?{completions:e.customModels.filter(e=>e.kind===`completions`).map(e=>e.name),embeddings:e.customModels.filter(e=>e.kind===`embeddings`).map(e=>e.name)}:{completions:e.models?.completions??[],embeddings:e.models?.embeddings??[]}}}))},onSuccess:()=>{C.reset(),t?.(!1),a(!1)},onSettled:(e,t,n)=>m(`provider.created`,t?`failed`:`succeeded`,{provider:n.provider,completions_models:n.models?.completions?.length??0,embedding_models:n.models?.embeddings?.length??0,custom_models:n.customModels?.length??0})}),C=qD({defaultValues:b(),resolver:JD(x)}),{isDirty:w}=_D(C),T=C.watch(`provider`),E=(0,H.useCallback)(()=>{S.reset(),C.reset(),t?.(!1),a(!1)},[S,C,t]),D=LM(w,E);return(0,U.jsxs)(tb,{open:i,onOpenChange:e=>{e?(C.reset(b()),t?.(!0),o(()=>a(!0))):D.guardedClose()},children:[n?null:(0,U.jsx)(nb,{asChild:!0,children:s(e??(0,U.jsx)(X,{children:`Add Provider`}))}),(0,U.jsxs)(ib,{className:`sm:max-w-3xl max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Add AI Provider`}),(0,U.jsx)(cb,{children:Ant(T)}),(0,U.jsx)(YD,{error:S.error,className:`break-all`})]}),(0,U.jsx)(fY,{...C,children:(0,U.jsxs)(`form`,{onSubmit:C.handleSubmit(e=>{p(`ai-gateway-create-ai-provider-submitted`,{provider:e.provider}),S.mutate(e)}),className:`flex flex-col flex-1 overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto space-y-4 px-1`,children:(0,U.jsx)(qY,{form:C,mode:`create`,onProviderChange:e=>{Cnt(C.getValues(`label`),g(T))&&C.setValue(`label`,g(e),{shouldDirty:!0,shouldValidate:!0})}})}),(0,U.jsxs)(ob,{className:`mt-4`,children:[(0,U.jsx)(X,{type:`button`,variant:`ghost`,onClick:E,disabled:S.isPending,children:`Cancel`}),(0,U.jsx)(X,{type:`submit`,children:(0,U.jsxs)(rM,{loading:S.isPending,children:[`Create`,(0,U.jsx)(hP,{className:`bg-white/20`,children:(0,U.jsx)(mP,{onPress:C.handleSubmit(e=>S.mutate(e)),hotkey:`meta+Enter`})})]})})]})]})})]}),(0,U.jsx)(IM,{open:D.showConfirm,onOpenChange:D.setShowConfirm,onDiscard:D.handleDiscard})]})};function jnt({onFail:e}){return(0,H.useEffect)(()=>{e()},[e]),null}function Mnt({data:e}){let{account:t,project:n}=lb([]);return t&&n&&JE(e.provider)?(0,U.jsx)(sY,{fallback:()=>(0,U.jsx)(aX,{data:e}),children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(ZE,{provider:e.provider,description:e.description,loading:!0,onOpen:()=>{}}),children:(0,U.jsx)(Nnt,{data:e})})}):(0,U.jsx)(aX,{data:e})}function Nnt({data:e}){return YE(cY())?(0,U.jsx)(aX,{data:e}):(0,U.jsx)(ZE,{provider:e.provider,description:e.description,unavailableText:mje,onOpen:()=>{}})}function aX({data:e}){let[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1),a=(0,H.useCallback)(()=>i(!0),[]),{logEvent:o}=on(),{account:s,project:c}=lb([]),l=!!(s&&c);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ZE,{provider:e.provider,description:e.description,loading:t&&!r,disabled:!l,errorText:r?`Couldn’t open the Add AI Provider dialog — please try again.`:void 0,onOpen:()=>{l&&(o(`agent-z-ai-provider-card-clicked`,{account:s,project:c,provider:e.provider}),i(!1),n(!0))}}),t&&!r?(0,U.jsx)(sY,{blastRadius:`feature-dead`,fallback:()=>(0,U.jsx)(jnt,{onFail:a}),children:(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(iX,{defaultOpen:!0,initialValues:{provider:Pnt(e.provider),label:e.label,models:e.models,baseUrl:e.baseUrl,customModels:e.customModels},onOpenChange:e=>{e||n(!1)}})})}):null]})}function Pnt(e){if(e)return e.toLowerCase()===`custom`?qE:e}var Fnt=(e,t=0)=>e.flatMap(e=>[[e,t],...Fnt(e.children,t+1)]),Int=e=>{if(e.length===0)return[];let t=new Map,n=[];for(let n of e)t.set(n.id,{...n,children:[]});for(let r of e){let e=t.get(r.id);if(!e)continue;let i=r.parentId;i&&t.has(i)?t.get(i)?.children.push(e):n.push(e)}return n};function Lnt(e,t){return H.useReducer((e,n)=>t[e][n]??e,e)}var oX=`ScrollArea`,[Rnt,znt]=T(oX),[Bnt,sX]=Rnt(oX),Vnt=H.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=H.useState(null),[l,u]=H.useState(null),[d,f]=H.useState(null),[p,m]=H.useState(null),[h,g]=H.useState(null),[_,v]=H.useState(0),[y,b]=H.useState(0),[x,S]=H.useState(!1),[C,w]=H.useState(!1),T=ve(t,e=>c(e)),E=At(i);return(0,U.jsx)(Bnt,{scope:n,type:r,dir:E,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:x,onScrollbarXEnabledChange:S,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:C,onScrollbarYEnabledChange:w,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,U.jsx)(ce.div,{dir:E,...o,ref:T,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});Vnt.displayName=oX;var Hnt=`ScrollAreaViewport`,Unt=H.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=sX(Hnt,n),s=ve(t,H.useRef(null),o.onViewportChange);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,U.jsx)(ce.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,U.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});Unt.displayName=Hnt;var cX=`ScrollAreaScrollbar`,Wnt=H.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=sX(cX,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return H.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,U.jsx)(Gnt,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,U.jsx)(Knt,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,U.jsx)(qnt,{...r,ref:t,forceMount:n}):i.type===`always`?(0,U.jsx)(lX,{...r,ref:t}):null});Wnt.displayName=cX;var Gnt=H.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=sX(cX,e.__scopeScrollArea),[a,o]=H.useState(!1);return H.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,U.jsx)(xt,{present:n||a,children:(0,U.jsx)(qnt,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Knt=H.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=sX(cX,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=mX(()=>c(`SCROLL_END`),100),[s,c]=Lnt(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return H.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),H.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,U.jsx)(xt,{present:n||s!==`hidden`,children:(0,U.jsx)(lX,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:hn(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:hn(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),qnt=H.forwardRef((e,t)=>{let n=sX(cX,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=H.useState(!1),s=e.orientation===`horizontal`,c=mX(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return hX(n.viewport,c),hX(n.content,c),(0,U.jsx)(xt,{present:r||a,children:(0,U.jsx)(lX,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),lX=H.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=sX(cX,e.__scopeScrollArea),a=H.useRef(null),o=H.useRef(0),[s,c]=H.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=rrt(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return irt(e,o.current,s,t)}return n===`horizontal`?(0,U.jsx)(Jnt,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=art(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,U.jsx)(Ynt,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=art(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),Jnt=H.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=sX(cX,e.__scopeScrollArea),[o,s]=H.useState(),c=H.useRef(null),l=ve(t,c,a.onScrollbarXChange);return H.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,U.jsx)(Qnt,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":pX(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),srt(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:fX(o.paddingLeft),paddingEnd:fX(o.paddingRight)}})}})}),Ynt=H.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=sX(cX,e.__scopeScrollArea),[o,s]=H.useState(),c=H.useRef(null),l=ve(t,c,a.onScrollbarYChange);return H.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,U.jsx)(Qnt,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":pX(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),srt(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:fX(o.paddingTop),paddingEnd:fX(o.paddingBottom)}})}})}),[Xnt,Znt]=Rnt(cX),Qnt=H.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:d,onResize:f,...p}=e,m=sX(cX,n),[h,g]=H.useState(null),_=ve(t,e=>g(e)),v=H.useRef(null),y=H.useRef(``),b=m.viewport,x=r.content-r.viewport,S=u(d),C=u(c),w=mX(f,10);function T(e){v.current&&l({x:e.clientX-v.current.left,y:e.clientY-v.current.top})}return H.useEffect(()=>{let e=e=>{let t=e.target;h?.contains(t)&&S(e,x)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[b,h,x,S]),H.useEffect(C,[r,C]),hX(h,w),hX(m.content,w),(0,U.jsx)(Xnt,{scope:n,scrollbar:h,hasThumb:i,onThumbChange:u(a),onThumbPointerUp:u(o),onThumbPositionChange:C,onThumbPointerDown:u(s),children:(0,U.jsx)(ce.div,{...p,ref:_,style:{position:`absolute`,...p.style},onPointerDown:hn(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),v.current=h.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,m.viewport&&(m.viewport.style.scrollBehavior=`auto`),T(e))}),onPointerMove:hn(e.onPointerMove,T),onPointerUp:hn(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=y.current,m.viewport&&(m.viewport.style.scrollBehavior=``),v.current=null})})})}),uX=`ScrollAreaThumb`,$nt=H.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Znt(uX,e.__scopeScrollArea);return(0,U.jsx)(xt,{present:n||i.hasThumb,children:(0,U.jsx)(ert,{ref:t,...r})})}),ert=H.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=sX(uX,n),o=Znt(uX,n),{onThumbPositionChange:s}=o,c=ve(t,e=>o.onThumbChange(e)),l=H.useRef(void 0),u=mX(()=>{l.current&&=(l.current(),void 0)},100);return H.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=crt(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,U.jsx)(ce.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:hn(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:hn(e.onPointerUp,o.onThumbPointerUp)})});$nt.displayName=uX;var dX=`ScrollAreaCorner`,trt=H.forwardRef((e,t)=>{let n=sX(dX,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,U.jsx)(nrt,{...e,ref:t}):null});trt.displayName=dX;var nrt=H.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=sX(dX,n),[a,o]=H.useState(0),[s,c]=H.useState(0),l=!!(a&&s);return hX(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),hX(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,U.jsx)(ce.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function fX(e){return e?parseInt(e,10):0}function rrt(e,t){let n=e/t;return isNaN(n)?0:n}function pX(e){let t=rrt(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function irt(e,t,n,r=`ltr`){let i=pX(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return ort([c,l],d)(e)}function art(e,t,n=`ltr`){let r=pX(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=bq(e,n===`ltr`?[0,o]:[o*-1,0]);return ort([0,o],[0,s])(c)}function ort(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function srt(e,t){return e>0&&e<t}var crt=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function mX(e,t){let n=u(e),r=H.useRef(0);return H.useEffect(()=>()=>window.clearTimeout(r.current),[]),H.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function hX(e,t){let n=u(t);bt(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var lrt=Vnt,urt=Unt,drt=trt;function frt({className:e,children:t,...n}){return(0,U.jsxs)(lrt,{"data-slot":`scroll-area`,className:W(`relative`,e),...n,children:[(0,U.jsx)(urt,{"data-slot":`scroll-area-viewport`,className:`focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-hidden focus-visible:ring-[3px] focus-visible:outline-1`,children:t}),(0,U.jsx)(prt,{}),(0,U.jsx)(drt,{})]})}function prt({className:e,orientation:t=`vertical`,...n}){return(0,U.jsx)(Wnt,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:W(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,U.jsx)($nt,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var mrt=`device-mobile.robot.broom.browsers.building.briefcase.bug.brain.brackets-curly.brackets-angle.book-open-text.at.android-logo.app-store-logo.angular-logo.bank.asterisk.app-window.wrench.traffic-signal.windows-logo.warning.siren.shield-check.shield-star.seal-check.scan-smiley.pulse.plugs.phone.notepad.network.megaphone.lock-laminated.lock-key.key.house-line.heart.folder-open.flag-checkered.floppy-disk-back.fingerprint.files.file-sql.file-py.file-vue.file-csharp.eyes.download.detective.database.desktop.currency-dollar-simple.cookie.confetti.coins.command.code-simple.code-block.clover.cloud.clock-clockwise.clock.circles-three-plus.circles-three.circles-four.chart-polar.chart-scatter.chart-line-up.chart-line-down.chart-line.chart-bar-horizontal.chart-donut.chat-circle-dots.chat-centered-text`.split(`.`),gX=({icon:e,className:t,size:n})=>{switch(e){case`device-mobile`:return(0,U.jsx)(ome,{weight:`regular`,className:t,size:n});case`robot`:return(0,U.jsx)(Fme,{weight:`regular`,className:t,size:n});case`broom`:return(0,U.jsx)(Ape,{weight:`regular`,className:t,size:n});case`browsers`:return(0,U.jsx)(jpe,{weight:`regular`,className:t,size:n});case`building`:return(0,U.jsx)(Npe,{weight:`regular`,className:t,size:n});case`briefcase`:return(0,U.jsx)(kpe,{weight:`regular`,className:t,size:n});case`bug`:return(0,U.jsx)(Mpe,{weight:`regular`,className:t,size:n});case`brain`:return(0,U.jsx)(Ope,{weight:`regular`,className:t,size:n});case`brackets-curly`:return(0,U.jsx)(Dpe,{weight:`regular`,className:t,size:n});case`brackets-angle`:return(0,U.jsx)(Epe,{weight:`regular`,className:t,size:n});case`book-open-text`:return(0,U.jsx)(ly,{weight:`regular`,className:t,size:n});case`at`:return(0,U.jsx)(Cpe,{weight:`regular`,className:t,size:n});case`android-logo`:return(0,U.jsx)(gpe,{weight:`regular`,className:t,size:n});case`app-store-logo`:return(0,U.jsx)(vpe,{weight:`regular`,className:t,size:n});case`angular-logo`:return(0,U.jsx)(_pe,{weight:`regular`,className:t,size:n});case`bank`:return(0,U.jsx)(wpe,{weight:`regular`,className:t,size:n});case`asterisk`:return(0,U.jsx)(Spe,{weight:`regular`,className:t,size:n});case`app-window`:return(0,U.jsx)(ype,{weight:`regular`,className:t,size:n});case`wrench`:return(0,U.jsx)(Dy,{weight:`regular`,className:t,size:n});case`traffic-signal`:return(0,U.jsx)(Bme,{weight:`regular`,className:t,size:n});case`windows-logo`:return(0,U.jsx)(Hme,{weight:`regular`,className:t,size:n});case`warning`:return(0,U.jsx)(wy,{weight:`regular`,className:t,size:n});case`siren`:return(0,U.jsx)(Rme,{weight:`regular`,className:t,size:n});case`shield-check`:return(0,U.jsx)(by,{weight:`regular`,className:t,size:n});case`shield-star`:return(0,U.jsx)(xy,{weight:`regular`,className:t,size:n});case`seal-check`:return(0,U.jsx)(Lme,{weight:`regular`,className:t,size:n});case`scan-smiley`:return(0,U.jsx)(Ime,{weight:`regular`,className:t,size:n});case`pulse`:return(0,U.jsx)(Pme,{weight:`regular`,className:t,size:n});case`plugs`:return(0,U.jsx)(Mme,{weight:`regular`,className:t,size:n});case`phone`:return(0,U.jsx)(jme,{weight:`regular`,className:t,size:n});case`notepad`:return(0,U.jsx)(kme,{weight:`regular`,className:t,size:n});case`network`:return(0,U.jsx)(Ome,{weight:`regular`,className:t,size:n});case`megaphone`:return(0,U.jsx)(Dme,{weight:`regular`,className:t,size:n});case`lock-laminated`:return(0,U.jsx)(Tme,{weight:`regular`,className:t,size:n});case`lock-key`:return(0,U.jsx)(vy,{weight:`regular`,className:t,size:n});case`key`:return(0,U.jsx)(gy,{weight:`regular`,className:t,size:n});case`house-line`:return(0,U.jsx)(Sme,{weight:`regular`,className:t,size:n});case`heart`:return(0,U.jsx)(xme,{weight:`regular`,className:t,size:n});case`folder-open`:return(0,U.jsx)(vme,{weight:`regular`,className:t,size:n});case`flag-checkered`:return(0,U.jsx)(gme,{weight:`regular`,className:t,size:n});case`floppy-disk-back`:return(0,U.jsx)(_me,{weight:`regular`,className:t,size:n});case`fingerprint`:return(0,U.jsx)(py,{weight:`regular`,className:t,size:n});case`files`:return(0,U.jsx)(hme,{weight:`regular`,className:t,size:n});case`file-sql`:return(0,U.jsx)(fme,{weight:`regular`,className:t,size:n});case`file-py`:return(0,U.jsx)(dme,{weight:`regular`,className:t,size:n});case`file-vue`:return(0,U.jsx)(mme,{weight:`regular`,className:t,size:n});case`file-csharp`:return(0,U.jsx)(ume,{weight:`regular`,className:t,size:n});case`eyes`:return(0,U.jsx)(cme,{weight:`regular`,className:t,size:n});case`download`:return(0,U.jsx)(sme,{weight:`regular`,className:t,size:n});case`detective`:return(0,U.jsx)(ame,{weight:`regular`,className:t,size:n});case`database`:return(0,U.jsx)(rme,{weight:`regular`,className:t,size:n});case`desktop`:return(0,U.jsx)(ime,{weight:`regular`,className:t,size:n});case`currency-dollar-simple`:return(0,U.jsx)(nme,{weight:`regular`,className:t,size:n});case`cookie`:return(0,U.jsx)(tme,{weight:`regular`,className:t,size:n});case`confetti`:return(0,U.jsx)(eme,{weight:`regular`,className:t,size:n});case`coins`:return(0,U.jsx)(Qpe,{weight:`regular`,className:t,size:n});case`command`:return(0,U.jsx)($pe,{weight:`regular`,className:t,size:n});case`code-simple`:return(0,U.jsx)(Zpe,{weight:`regular`,className:t,size:n});case`code-block`:return(0,U.jsx)(fy,{weight:`regular`,className:t,size:n});case`clover`:return(0,U.jsx)(Xpe,{weight:`regular`,className:t,size:n});case`cloud`:return(0,U.jsx)(Ype,{weight:`regular`,className:t,size:n});case`clock-clockwise`:return(0,U.jsx)(Jpe,{weight:`regular`,className:t,size:n});case`clock`:return(0,U.jsx)(qpe,{weight:`regular`,className:t,size:n});case`circles-three-plus`:return(0,U.jsx)(Kpe,{weight:`regular`,className:t,size:n});case`circles-three`:return(0,U.jsx)(Gpe,{weight:`regular`,className:t,size:n});case`circles-four`:return(0,U.jsx)(Wpe,{weight:`regular`,className:t,size:n});case`chart-polar`:return(0,U.jsx)(zpe,{weight:`regular`,className:t,size:n});case`chart-scatter`:return(0,U.jsx)(dy,{weight:`regular`,className:t,size:n});case`chart-line-up`:return(0,U.jsx)(Rpe,{weight:`regular`,className:t,size:n});case`chart-line-down`:return(0,U.jsx)(Lpe,{weight:`regular`,className:t,size:n});case`chart-line`:return(0,U.jsx)(Ipe,{weight:`regular`,className:t,size:n});case`chart-bar-horizontal`:return(0,U.jsx)(Ppe,{weight:`regular`,className:t,size:n});case`chart-donut`:return(0,U.jsx)(Fpe,{weight:`regular`,className:t,size:n});case`chat-circle-dots`:return(0,U.jsx)(Vpe,{weight:`regular`,className:t,size:n});case`chat-centered-text`:return(0,U.jsx)(Bpe,{weight:`regular`,className:t,size:n});default:return null}},hrt=({className:e,iconClassName:t,value:n,onChange:r,open:i,name:a,onOpenChange:o})=>{let[s,c]=(0,H.useState)(``),l=NY(s,mrt,{getText:e=>[e]}),[u,d]=(0,H.useState)(i??!1),f=o??d;return(0,U.jsxs)(dT,{open:u,onOpenChange:f,children:[(0,U.jsx)(fT,{asChild:!0,children:(0,U.jsxs)(X,{variant:`ghost`,className:W(`size-10 shrink-0`,e),children:[(0,U.jsx)(gX,{icon:n??`scan-smiley`,className:t}),(0,U.jsx)(`input`,{type:`hidden`,name:a,value:n})]})}),(0,U.jsxs)(pT,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(EY,{className:`h-8`,children:[(0,U.jsx)(kY,{placeholder:`Search`,autoFocus:!0,value:s,onChange:e=>c(e.target.value)}),(0,U.jsx)(DY,{align:`inline-start`,children:(0,U.jsx)(kf,{})}),s&&(0,U.jsx)(DY,{align:`inline-end`,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon-xs`,onClick:()=>c(``),children:(0,U.jsx)(ep,{})})})]}),(0,U.jsx)(frt,{className:`h-[250px]`,children:(0,U.jsx)(`div`,{className:`grid grid-cols-6 place-items-center-safe`,children:l.map(e=>(0,U.jsx)(X,{variant:`ghost`,size:`icon-lg`,onClick:()=>{r(e),f(!1)},children:(0,U.jsx)(gX,{icon:e,className:`size-5`})},e))})})]})]})},_X=`ai-gateway-auth-v2-inbound`,grt=new Set([_X,`ai-gateway-configuration-loader-v2-inbound`,`ai-gateway-configuration-executor-v2-inbound`]),_rt=e=>grt.has(e),vrt={canEdit:!1,canRemove:!1},yrt=[_X],brt=()=>yrt.map(e=>({name:e,permissions:{...vrt}})),xrt=e=>e.at(0)?.metadata?.deploymentName||void 0,Srt=()=>{let e=TY();return xrt(fb(mt.bucketConfigurations(e)).data??[])},Crt=()=>{let e=TY(),t=fb(mt.bucketConfigurationTeams(e)),n=(0,H.useMemo)(()=>Int(t.data),[t.data]);return{teams:t.data,tree:n}},wrt=`__top-level__`,Trt=.75,Ert=({team:e})=>{let t=e.metadata?.icon;return t?(0,U.jsx)(gX,{icon:t,size:16,className:`shrink-0`}):(0,U.jsx)(Xf,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})},Drt=e=>{let t=[];return e.map(([e,n])=>{t.length=n;let r=[...t];return t[n]=e.label,{team:e,depth:n,path:r}})},Ort=(e,t)=>[...e,t].join(` / `),krt=({options:e,value:t,onChange:n})=>{let[r,i]=(0,H.useState)(!1),a=(0,H.useMemo)(()=>Drt(e),[e]),o=a.find(({team:e})=>e.id===t),s=e=>{n(e),i(!1)};return(0,U.jsxs)(dT,{open:r,onOpenChange:i,modal:!1,children:[(0,U.jsx)(fT,{asChild:!0,children:(0,U.jsxs)(X,{type:`button`,variant:`outline`,role:`combobox`,"aria-label":`Parent team`,"aria-expanded":r,className:`w-full justify-between border-input font-normal`,children:[(0,U.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:o?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ert,{team:o.team}),(0,U.jsx)(`span`,{className:`truncate`,children:o.team.label}),o.path.length>0?(0,U.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[`in `,o.path.join(` / `)]}):null]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hf,{className:`size-4 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`No parent team`})]})}),(0,U.jsx)(td,{className:`ml-2 size-4 shrink-0 opacity-50`})]})}),(0,U.jsx)(pT,{className:`w-(--radix-popover-trigger-width) p-0`,side:`bottom`,align:`start`,children:(0,U.jsxs)(Rw,{children:[(0,U.jsx)(zw,{placeholder:`Search teams...`,className:`h-9`}),(0,U.jsxs)(Bw,{className:`max-h-[280px]`,children:[(0,U.jsx)(Vw,{className:`py-6 text-center text-sm text-muted-foreground`,children:`No teams match.`}),(0,U.jsxs)(Uw,{value:`No parent team top-level`,onSelect:()=>s(wrt),className:`flex cursor-pointer items-center gap-2`,children:[(0,U.jsx)(hf,{className:`size-4 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`flex-1 truncate text-muted-foreground`,children:`No parent team`}),(0,U.jsx)(ed,{className:W(`size-4 shrink-0 text-muted-foreground`,o?`opacity-0`:`opacity-100`)})]}),a.map(({team:e,depth:n,path:r})=>(0,U.jsxs)(Uw,{value:`${Ort(r,e.label)} ${e.id}`,"aria-label":Ort(r,e.label),onSelect:()=>s(e.id),className:`flex cursor-pointer items-center gap-2`,style:{paddingLeft:`${.5+n*Trt}rem`},children:[(0,U.jsx)(Ert,{team:e}),(0,U.jsx)(`span`,{className:`truncate`,children:e.label}),r.length>0?(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:[`in `,r.join(` / `)]}):(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsx)(ed,{className:W(`size-4 shrink-0 text-muted-foreground`,e.id===t?`opacity-100`:`opacity-0`)})]},e.id))]})]})})]})};Rm({teamName:Pm().min(1,`Team name is required`),icon:Pm(),parentTeamId:Pm().optional()});var Art=({children:e,parentId:t,...n})=>{let{project:r}=hp([`project`]);return!(fb(mt.permissionsAiTeam(t??``)).data?.includes(`can_edit`)??!1)&&!n.defaultOpen?(0,U.jsx)(vX,{children:e}):(0,U.jsx)(Prt,{...n,parentId:t,applyPolicyTemplate:KE(r),children:e})},jrt=({children:e,...t})=>{let{account:n,project:r}=lb([`account`,`project`]);return!(fb(mt.permissionsProject(n,r)).data?.includes(`ai_team_editor`)??!1)&&!t.defaultOpen?(0,U.jsx)(vX,{children:e}):(0,U.jsx)(Mrt,{...t,children:e})},Mrt=({children:e,...t})=>{let n=TY(),{project:r}=hp([`project`]),i=fb(mt.bucketConfigurations(n)).data?.at(0)?.id,{tree:a}=Crt(),o=(0,H.useMemo)(()=>Fnt(a),[a]);return i?(0,U.jsx)(Prt,{...t,parentId:i,rootId:i,parentOptions:o,applyPolicyTemplate:KE(r),children:e}):(0,U.jsx)(vX,{reason:`Deploy this gateway to production before adding teams`,children:e})},vX=({children:e,reason:t=`You don't have permission to add teams`})=>{let n=e??(0,U.jsx)(X,{variant:`default`,children:`Create Team`});return(0,U.jsxs)(SN,{children:[(0,U.jsx)(CN,{asChild:!0,children:(0,U.jsx)(`span`,{className:`inline-flex`,children:(0,H.isValidElement)(n)?(0,H.cloneElement)(n,{disabled:!0}):n})}),(0,U.jsx)(wN,{children:t})]})},Nrt=({applyPolicyTemplate:e,parentId:t,rootId:n})=>!e||!t?{}:t===n?{inboundPolicyChain:brt()}:{inheritPolicyTemplate:!0},Prt=({children:e,parentId:t,rootId:n,parentOptions:r,applyPolicyTemplate:i=!1,disabled:a,teamsBasePath:o,defaultOpen:s=!1,initialName:c,onOpenChange:l})=>{let{account:u,project:d}=lb([`account`,`project`]),{logEvent:f}=on(),p=CY(),m=qD({defaultValues:{teamName:c??``,parentTeamId:wrt}}),h=Dt(),g=TY(),_=Srt(),v=Xa(),[y,b]=(0,H.useState)(s),x=je({mutationFn:async e=>{let r=(e.parentTeamId&&e.parentTeamId!==`__top-level__`?e.parentTeamId:void 0)??t;return await h.fetch(tn.ai.createBucketConfiguration(g,{label:e.teamName,parentId:r,metadata:{version:`1`,deploymentName:_,icon:e.icon,...Nrt({applyPolicyTemplate:i,parentId:r,rootId:n})}}))},onSuccess:e=>{m.reset(),l?.(!1),b(!1),v(`${o??`/${u}/${d}/ai/teams`}/${e.id}`)},onSettled:(e,t)=>p(`team.created`,t?`failed`:`succeeded`)});return(0,U.jsxs)(tb,{open:y,onOpenChange:e=>{b(e),l?.(e),e||m.reset()},children:[s?null:(0,U.jsx)(nb,{asChild:!0,disabled:a,children:e??(0,U.jsx)(X,{variant:`default`,children:`Create Team`})}),(0,U.jsxs)(ib,{children:[(0,U.jsx)(fY,{...m,children:(0,U.jsxs)(`form`,{id:`new-team`,onSubmit:m.handleSubmit(e=>{f(`ai-gateway-create-team-submitted`,{teamName:e.teamName,icon:e.icon}),x.mutate(e)}),className:`flex flex-col gap-4`,children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Create Team`}),(0,U.jsx)(cb,{children:`Organize apps and control access across your organization. Teams let you enforce usage limits and manage costs. Create as many as you need.`})]}),(0,U.jsx)(YD,{error:x.error}),(0,U.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,U.jsx)(RDe,{}),(0,U.jsx)(mY,{control:m.control,name:`icon`,render:({field:e})=>(0,U.jsx)(hrt,{onChange:e.onChange,name:`icon`,value:e.value,iconClassName:`size-6`,className:W(`h-auto`,e.value?`border-transparent`:`border-dashed border-border text-neutral-300`)})}),(0,U.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2`,children:[r&&r.length>0?(0,U.jsx)(mY,{control:m.control,name:`parentTeamId`,render:({field:e})=>(0,U.jsx)(krt,{options:r,value:e.value??`__top-level__`,onChange:e.onChange})}):null,(0,U.jsx)(mY,{control:m.control,name:`teamName`,render:({field:e})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(iM,{placeholder:`John's Team`,autoFocus:!0,...e}),(0,U.jsx)(xY,{})]})})]})]})]})}),(0,U.jsxs)(ob,{children:[(0,U.jsx)(rb,{asChild:!0,children:(0,U.jsx)(X,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,U.jsx)(X,{type:`submit`,form:`new-team`,children:(0,U.jsx)(rM,{loading:x.isPending,children:`Create Team`})})]})]})]})};function Frt({data:e}){let[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1),a=(0,H.useCallback)(()=>i(!0),[]),{logEvent:o}=on(),{account:s,project:c}=lb([]),l=!!(s&&c),u=(0,H.useCallback)(e=>{e||n(!1)},[]);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Kje,{name:e.name,isSubTeam:!!e.parentTeamId,description:e.description,loading:t&&!r,disabled:!l,errorText:r?`Couldn’t open the Create Team dialog — please try again, or create it from AI Gateway → Teams.`:void 0,onOpen:()=>{l&&(o(`agent-z-ai-team-card-clicked`,{account:s,project:c,isSubTeam:!!e.parentTeamId}),i(!1),n(!0))}}),t&&!r?(0,U.jsx)(sY,{blastRadius:`feature-dead`,fallback:()=>(0,U.jsx)(jnt,{onFail:a}),children:(0,U.jsx)(H.Suspense,{fallback:null,children:e.parentTeamId?(0,U.jsx)(Art,{parentId:e.parentTeamId,defaultOpen:!0,initialName:e.name,onOpenChange:u}):(0,U.jsx)(jrt,{defaultOpen:!0,initialName:e.name,onOpenChange:u})})}):null]})}var Irt=SY(`0123456789abcdefghijklmnopqrstuvwxyz`,4),yX=(e,{method:t,path:n,existingOperationIds:r})=>{if(!t||!n)return Ktt(6);let i=n.split(`/`).filter(e=>e.length>0).join(`-`),a=(e.summary?$Y(e.summary,{lowercase:!0}):``)||$Y(`${t}-${i}`);return r?.has(a)?`${a}-${Irt()}`:a},Lrt=[`get`,`put`,`post`,`delete`,`options`,`head`,`patch`,`trace`];function Rrt(e,t=new Set){let n=new Set(t);for(let t of Object.values(e.paths??{}))if(t)for(let e of Lrt){let r=t[e];r?.operationId&&n.add(r.operationId)}let r={};for(let[t,i]of Object.entries(e.paths??{})){if(!i){r[t]=i;continue}let e={...i};for(let r of Lrt){let i=e[r];if(i&&!i.operationId){let a=yX(i,{method:r,path:t,existingOperationIds:n});n.add(a),e[r]={...i,operationId:a}}}r[t]=e}return{...e,paths:r}}var zrt=`x-zuplo`,bX=`x-internal`,Brt=`x-mcp-server`,xX=`x-graphql`,SX=`${zrt}-path`,CX=`${zrt}-route`,Vrt=e=>e?.export===`mcpServerHandler`&&(()=>{let t=e.options;if(!t||typeof t!=`object`)return!1;let n=t;return Array.isArray(n.openApiFilePaths)&&n.openApiFilePaths.length>0})(),Hrt=e=>e?.export===`mcpServerHandler`&&(()=>{let t=e.options;if(!t||typeof t!=`object`)return!1;let n=t;return Array.isArray(n.files)&&n.files.length>0})(),wX=e=>e?.export===`mcpServerHandler`,TX=e=>e?.export===`McpProxyHandler`||e?.export===`McpVirtualServerHandler`||e?.export===`mcpVirtualServerHandler`,EX=e=>{let t=e[CX]?.handler;return wX(t)||TX(t)};function Urt(e){return e==null}function Wrt(e){return typeof e==`object`&&!!e}function Grt(e){return Array.isArray(e)?e:Urt(e)?[]:[e]}function Krt(e,t){var n,r,i,a;if(t)for(a=Object.keys(t),n=0,r=a.length;n<r;n+=1)i=a[n],e[i]=t[i];return e}function qrt(e,t){var n=``,r;for(r=0;r<t;r+=1)n+=e;return n}function Jrt(e){return e===0&&1/e==-1/0}var DX={isNothing:Urt,isObject:Wrt,toArray:Grt,repeat:qrt,isNegativeZero:Jrt,extend:Krt};function Yrt(e,t){var n=``,r=e.reason||`(unknown reason)`;return e.mark?(e.mark.name&&(n+=`in "`+e.mark.name+`" `),n+=`(`+(e.mark.line+1)+`:`+(e.mark.column+1)+`)`,!t&&e.mark.snippet&&(n+=`
317
+ `),y=()=>_(`HTTP/1.1 ${e.status} ${e.statusText}\n${v}\n\n${e.body??``}`),b=()=>{let t=new Blob([e.body??``],{type:s||`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`response.${rtt[p]}`,r.click(),URL.revokeObjectURL(n)},x=()=>{f(`body`),window.setTimeout(()=>{o.current?.focus(),o.current?.getAction(`actions.find`)?.run()},0)};return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2.5 font-mono text-sm`,children:[(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`HTTP/1.1`}),(0,U.jsx)(`span`,{className:`font-semibold`,children:(0,U.jsx)(xJ,{code:e.status,icon:!1,statusText:e.statusText})})]}),(0,U.jsxs)(AO,{value:d,onValueChange:f,className:`flex min-h-0 grow flex-col`,children:[(0,U.jsxs)(jO,{className:`h-auto justify-start gap-1 self-start bg-transparent px-3 pt-1`,children:[(0,U.jsx)(MO,{value:`body`,"data-test":`test-result-body`,className:DJ,children:`Body`}),(0,U.jsxs)(MO,{value:`headers`,"data-test":`test-result-headers`,className:DJ,children:[`Headers (`,u,`)`]}),(0,U.jsxs)(MO,{value:`logs`,"data-test":`test-result-logs`,className:DJ,children:[`Logs (`,a.length,`)`]})]}),(0,U.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:[(0,U.jsx)(NO,{value:`body`,className:`mt-0 h-full data-[state=active]:flex`,children:(0,U.jsx)(`div`,{className:`h-full w-full`,children:(0,U.jsx)(yM,{options:ett,language:ntt[p],value:h,onMount:g})})}),(0,U.jsx)(NO,{value:`headers`,className:`mt-0 px-4 pt-2`,children:(0,U.jsxs)(`table`,{className:`w-full table-fixed border-collapse text-sm`,children:[(0,U.jsx)(`thead`,{children:(0,U.jsxs)(`tr`,{className:`text-left text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:[(0,U.jsx)(`th`,{className:`w-2/5 py-1.5 pr-4 font-medium`,children:`Header`}),(0,U.jsx)(`th`,{className:`py-1.5 font-medium`,children:`Value`})]})}),(0,U.jsx)(`tbody`,{children:Object.entries(e.headers).map(([e,t])=>(0,U.jsxs)(`tr`,{className:`border-t border-border/60 align-top`,children:[(0,U.jsx)(`td`,{className:`py-1.5 pr-4 font-mono break-words text-muted-foreground`,children:e}),(0,U.jsx)(`td`,{className:`py-1.5 font-mono break-words`,children:t})]},e))})]})}),(0,U.jsx)(NO,{value:`logs`,className:`mt-0 h-full`,children:(0,U.jsx)(`div`,{className:`h-full min-h-[300px]`,children:(0,U.jsx)($et,{logs:a})})})]})]}),(0,U.jsxs)(`div`,{className:`flex h-7 items-center justify-between border-t border-border px-2 font-mono text-xs text-muted-foreground`,children:[(0,U.jsxs)(mJ,{value:p,onValueChange:e=>m(e),children:[(0,U.jsx)(_J,{size:`xs`,"aria-label":`Response rendering`,className:`w-24 border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent dark:hover:bg-transparent`,children:OJ[p]}),(0,U.jsx)(vJ,{align:`start`,children:Object.keys(OJ).map(e=>(0,U.jsx)(bJ,{value:e,children:OJ[e]},e))})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`span`,{children:[ttt(l),n==null?``:`, ${n}ms`]}),(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{"aria-label":`Response actions`,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,U.jsx)(Od,{className:`size-4`})}),(0,U.jsxs)(XG,{align:`end`,children:[(0,U.jsxs)(QG,{onSelect:y,children:[(0,U.jsx)(_d,{className:`size-4`}),`Copy all`]}),(0,U.jsxs)(QG,{onSelect:()=>_(v),children:[(0,U.jsx)(Sd,{className:`size-4`}),`Copy headers`]}),(0,U.jsxs)(QG,{onSelect:()=>_(e.body??``),children:[(0,U.jsx)(Sd,{className:`size-4`}),`Copy body`]}),(0,U.jsxs)(QG,{onSelect:b,children:[(0,U.jsx)(Dd,{className:`size-4`}),`Save body…`]}),r?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rK,{}),(0,U.jsxs)(QG,{onSelect:r,children:[(0,U.jsx)(Kf,{className:`size-4`}),`Clear`]})]}):null,(0,U.jsx)(rK,{}),(0,U.jsxs)(QG,{onSelect:x,children:[(0,U.jsx)(kf,{className:`size-4`}),`Search`]})]})]})]})]})]})},att={[GM.PRODUCTION]:`Production`,[GM.PREVIEW]:`Preview`,[GM.WORKING_COPY]:`Working copy`},ott=e=>e.externalUsers?.[0]?.email||e.sub,AJ=e=>e.apiKeys?.find(e=>e.expiresOn===void 0||e.expiresOn===null||Date.parse(e.expiresOn)>Date.now())?.key,stt=({ape:e,onSelectKey:t,initialBucketId:n,initialConsumerSub:r})=>{let i=_T(e.account.name,e.project.name),a=(0,H.useMemo)(()=>(i.data?.defaultConfiguration??[]).flatMap(e=>e.apiKeyBucket?[{id:e.apiKeyBucket,env:e.environmentType}]:[]),[i.data]),o=(0,H.useMemo)(()=>a.find(t=>t.env===e.environment.environmentType)?.id??a[0]?.id,[a,e.environment.environmentType]),[s,c]=(0,H.useState)(n),l=s??o,[u,d]=(0,H.useState)(r),f=BM(l??``,{limit:100},{enabled:!!l}),p=f.data?.data??[],m=VM(l??``,u??``,{enabled:!!l&&!!u});return(0,H.useEffect)(()=>{if(m.data&&l&&u){let e=AJ(m.data);e&&t(e,{bucketId:l,consumerSub:u})}},[m.data]),i.isLoading?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading API key services…`}):a.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No API Key Service is configured for this project.`}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:`auth-api-key-service`,className:`text-xs font-medium text-muted-foreground`,children:`API Key Service`}),(0,U.jsxs)(mJ,{value:l,onValueChange:e=>{c(e),d(void 0)},children:[(0,U.jsx)(_J,{id:`auth-api-key-service`,className:`w-full`,children:(0,U.jsx)(gJ,{placeholder:`Select a service`})}),(0,U.jsx)(vJ,{children:a.map(e=>(0,U.jsx)(bJ,{value:e.id,children:att[e.env]??e.env},e.id))})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:`auth-api-key-consumer`,className:`text-xs font-medium text-muted-foreground`,children:`API Key`}),(0,U.jsxs)(mJ,{value:u,onValueChange:d,disabled:f.isLoading||p.length===0,children:[(0,U.jsx)(_J,{id:`auth-api-key-consumer`,className:`w-full`,children:(0,U.jsx)(gJ,{placeholder:f.isLoading?`Loading consumers…`:p.length===0?`No consumers in this service`:`Select a consumer`})}),(0,U.jsx)(vJ,{children:p.map(e=>(0,U.jsx)(bJ,{value:e.sub,children:ott(e)},e.sub))})]}),u&&m.isLoading?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading key…`}):u&&m.data&&!AJ(m.data)?(0,U.jsx)(`p`,{className:`text-xs text-destructive-foreground`,children:`This consumer has no active key.`}):null]}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Sent as`,` `,(0,U.jsx)(`code`,{className:`font-mono text-foreground`,children:`Authorization: Bearer …`}),` `,`on every request.`]})]})},jJ=`Authorization`,MJ={none:`None`,basic:`Basic auth`,bearer:`Bearer token`,apiKey:`Zuplo API Key`},NJ=e=>Object.keys(e).find(e=>e.toLowerCase()===`authorization`),ctt=(e,t)=>{try{return btoa(`${e}:${t}`)}catch{return``}},PJ=e=>{let t=NJ(e),n=t?e[t]??``:``,r=n.match(/^\s*Bearer\s+(.*)$/i);if(r)return{type:`bearer`,token:r[1],username:``,password:``};let i=n.match(/^\s*Basic\s+(.*)$/i);if(i)try{let[e,...t]=atob(i[1]).split(`:`);return{type:`basic`,token:``,username:e,password:t.join(`:`)}}catch{}return{type:t?`bearer`:`none`,token:t?n:``,username:``,password:``}},ltt=({ape:e,headers:t,onChange:n,onPersist:r,authSelection:i,testId:a,allowApiKeyService:o=!0})=>{let s=Object.keys(MJ).filter(e=>o||e!==`apiKey`),c=PJ(t),[l,u]=(0,H.useState)(i?`apiKey`:c.type),[d,f]=(0,H.useState)(c.token),[p,m]=(0,H.useState)(c.username),[h,g]=(0,H.useState)(c.password),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(c.type!==`none`)return;let e=requestAnimationFrame(()=>b(!0));return()=>cancelAnimationFrame(e)},[]),(0,H.useEffect)(()=>{let e=PJ(t);u(i?`apiKey`:e.type),f(e.token),m(e.username),g(e.password)},[a]);let x=()=>{let e={...t},n=NJ(e);return n&&delete e[n],e},S=e=>{let n=x();return n[NJ(t)??jJ]=e,n},C=(e,r)=>{let i=x();e&&(i[NJ(t)??jJ]=e),n(i,r)},w=(e,t)=>C(e.trim()?`Bearer ${e}`:null,t),T=(e,t,n)=>C(e||t?`Basic ${ctt(e,t)}`:null,n),E=e=>{u(e),e===`none`?n(x(),!0):e===`bearer`?w(d,!0):e===`basic`&&T(p,h,!0)};return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,children:[(0,U.jsx)(`div`,{className:`min-h-0 grow overflow-y-auto p-4`,children:l===`none`?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This request won't send an authorization header.`}):l===`apiKey`?(0,U.jsx)(stt,{ape:e,initialBucketId:i?.bucketId,initialConsumerSub:i?.consumerSub,onSelectKey:(e,t)=>{f(e),n(S(`Bearer ${e}`),!0,t)}}):l===`basic`?(0,U.jsxs)(`div`,{className:`flex max-w-sm flex-col gap-3`,children:[(0,U.jsx)(iM,{type:`text`,placeholder:`Username`,value:p,autoComplete:`off`,"data-op-ignore":!0,onChange:e=>{m(e.target.value),T(e.target.value,h,!1)},onBlur:()=>r()}),(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(iM,{type:_?`text`:`password`,className:`pr-9`,placeholder:`Password`,value:h,autoComplete:`off`,"data-op-ignore":!0,onChange:e=>{g(e.target.value),T(p,e.target.value,!1)},onBlur:()=>r()}),(0,U.jsx)(`button`,{type:`button`,"aria-label":_?`Hide password`:`Show password`,className:`absolute right-1 top-1/2 -translate-y-1/2 rounded-sm p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground`,onClick:()=>v(e=>!e),children:_?(0,U.jsx)(Ad,{className:`size-4`}):(0,U.jsx)(jd,{className:`size-4`})})]})]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 pb-2`,children:[(0,U.jsx)(nf,{className:`size-4 shrink-0 text-muted-foreground`}),(0,U.jsx)(`input`,{type:_?`text`:`password`,className:W(`min-w-0 grow border-0 bg-transparent p-0 font-mono text-sm shadow-none outline-none focus:ring-0 placeholder:text-muted-foreground`),placeholder:`Paste a bearer token`,value:d,autoComplete:`off`,"data-op-ignore":!0,onChange:e=>{f(e.target.value),w(e.target.value,!1)},onBlur:()=>r()}),(0,U.jsx)(`button`,{type:`button`,"aria-label":_?`Hide token`:`Show token`,className:`shrink-0 rounded-sm p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,onClick:()=>v(e=>!e),children:_?(0,U.jsx)(Ad,{className:`size-4`}):(0,U.jsx)(jd,{className:`size-4`})})]})}),(0,U.jsx)(`div`,{className:`flex h-7 items-center border-t border-border px-2`,children:(0,U.jsxs)(JG,{modal:!1,open:y,onOpenChange:b,children:[(0,U.jsxs)(YG,{"aria-label":`Authorization type`,className:`flex h-6 w-40 items-center justify-between gap-1 rounded-md bg-transparent px-2 text-xs outline-none focus-visible:ring-0`,children:[MJ[l],(0,U.jsx)(td,{className:`size-3.5 opacity-50`})]}),(0,U.jsx)(XG,{align:`start`,side:`top`,className:`min-w-40`,children:(0,U.jsx)(eK,{value:l,onValueChange:e=>E(e),children:s.map(e=>(0,U.jsx)(tK,{value:e,trailingIndicator:!0,children:MJ[e]},e))})})]})})]})},FJ=({children:e,onClearValue:t,className:n,showClearButton:r,value:i})=>(0,U.jsxs)(`div`,{className:W(`relative`,n),children:[(0,U.jsx)(kf,{size:16,className:`absolute left-2.5 top-1/2 -translate-y-1/2 pb-0.5 text-muted-foreground`}),e,r&&i&&(0,U.jsx)(X,{variant:`ghost`,size:`icon-sm`,type:`button`,onClick:t,className:`absolute right-2 top-1/2 -translate-y-1/2`,children:(0,U.jsx)(ep,{size:16,className:`text-muted-foreground`})})]}),IJ={get:`text-blue-600 dark:text-blue-400`,head:`text-pink-600 dark:text-pink-400`,post:`text-green-600 dark:text-green-400`,put:`text-yellow-600 dark:text-yellow-400`,delete:`text-red-600 dark:text-red-400`,connect:`text-orange-600 dark:text-orange-400`,options:`text-teal-600 dark:text-teal-400`,trace:`text-fuchsia-600 dark:text-fuchsia-400`,patch:`text-orange-600 dark:text-orange-400`,multiple:`text-zuplo-600 dark:text-zuplo-400`},utt={get:`bg-blue-200 dark:bg-blue-900/40`,head:`bg-pink-200 dark:bg-pink-900/40`,post:`bg-green-200 dark:bg-green-900/40`,put:`bg-yellow-200 dark:bg-yellow-900/40`,delete:`bg-red-200 dark:bg-red-900/40`,connect:`bg-orange-200 dark:bg-orange-900/40`,options:`bg-teal-200 dark:bg-teal-900/40`,trace:`bg-fuchsia-200 dark:bg-fuchsia-900/40`,patch:`bg-orange-200 dark:bg-orange-900/40`,multiple:`bg-zuplo-200/75 dark:bg-zuplo-900/40`},LJ={get:`bg-blue-500`,head:`bg-pink-500`,post:`bg-green-500`,put:`bg-yellow-500`,delete:`bg-red-500`,connect:`bg-orange-500`,options:`bg-teal-500`,trace:`bg-fuchsia-500`,patch:`bg-orange-500`,multiple:`bg-zuplo-500`},RJ=({method:e,className:t})=>{let n=e.includes(`,`)?`multiple`:e;return(0,U.jsx)(`div`,{className:W(`rounded-lg text-center items-center flex justify-center h-5 px-2`,`text-xs font-semibold`,IJ[n],utt[n],t),"data-test":`route-method`,children:e.includes(`,`)?`MULTI`:e.toUpperCase()})},dtt=e=>e.split(`/`).pop()||e,ftt=({endpoints:e,selectedEndpointId:t,onSelect:n,isLoading:r})=>{let[i,a]=(0,H.useState)(``),o=(0,H.useMemo)(()=>{let t=i.trim().toLowerCase();return t?e.filter(e=>e.path.toLowerCase().includes(t)||e.method.toLowerCase().includes(t)||(e.summary?.toLowerCase().includes(t)??!1)):e},[e,i]),s=(0,H.useMemo)(()=>{let e=new Map;for(let t of o){let n=e.get(t.file);n?n.push(t):e.set(t.file,[t])}return[...e.entries()]},[o]),c=s.length>1;return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,U.jsx)(`div`,{className:`shrink-0 border-b border-border p-2`,children:(0,U.jsx)(FJ,{value:i,onClearValue:()=>a(``),showClearButton:i.length>0,children:(0,U.jsx)(iM,{value:i,size:`sm`,placeholder:`Filter endpoints…`,"aria-label":`Filter endpoints`,onChange:e=>a(e.target.value),className:`pl-8`})})}),(0,U.jsx)(`div`,{className:`min-h-0 grow overflow-y-auto p-1.5`,children:o.length===0?(0,U.jsx)(`div`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:r?`Loading endpoints…`:i?`No endpoints match your filter.`:`No routes to test.`}):(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map(([e,r])=>(0,U.jsxs)(`div`,{children:[c&&(0,U.jsx)(`div`,{title:e,className:`truncate px-2 py-1 font-medium text-[11px] text-muted-foreground uppercase tracking-wide`,children:dtt(e)}),(0,U.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r.map(e=>{let r=e.id===t;return(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-current":r,title:e.summary??e.path,className:W(`flex w-full flex-col gap-1 rounded-md px-2 py-1.5 text-left outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring`,r?`bg-accent text-foreground`:`hover:bg-accent/60`),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(RJ,{method:e.method,className:`shrink-0`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-foreground`,children:e.path})]}),e.summary?(0,U.jsx)(`span`,{className:`truncate pl-0.5 text-xs text-muted-foreground`,children:e.summary}):null]})},e.id)})})]},e))})})]})},zJ=e=>{try{return Array.from(new URLSearchParams(e??``).entries())}catch{return[]}},ptt=e=>{let t=new URLSearchParams;for(let[n,r]of e)n!==``&&t.append(n,r);return t.toString()},BJ=e=>{let t=e[e.length-1];return!t||t[0]!==``||t[1]!==``?[...e,[``,``]]:e},mtt=({value:e,onChange:t,onPersist:n,testId:r})=>{let[i,a]=(0,H.useState)(()=>BJ(zJ(e)));(0,H.useEffect)(()=>{a(BJ(zJ(e)))},[r]);let o=(e,r)=>{let i=BJ(e);a(i),t(ptt(i)),r&&n()},s=(e,t,n)=>{o(i.map((r,i)=>i===e?[t,n]:r),!1)},c=e=>{o(i.filter((t,n)=>n!==e),!0)};return(0,U.jsx)(`div`,{className:`flex flex-col gap-y-2 p-4`,children:i.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex flex-row gap-x-2`,children:[(0,U.jsx)(iM,{type:`text`,className:`grow`,placeholder:`Key`,value:e[0],onChange:n=>s(t,n.target.value,e[1]),onBlur:()=>n()}),(0,U.jsx)(iM,{type:`text`,className:`grow`,placeholder:`Value`,value:e[1],onChange:n=>s(t,e[0],n.target.value),onBlur:()=>n()}),(0,U.jsx)(`button`,{type:`button`,className:`rounded-sm p-2 enabled:hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>c(t),disabled:t===i.length-1,"aria-label":`Delete field`,children:(0,U.jsx)(Ed,{className:`h-4 w-4`})})]},t))})},htt=e=>{try{let t=JSON.parse(e);if(t&&typeof t==`object`&&`query`in t)return{query:typeof t.query==`string`?t.query:``,variables:t.variables===void 0?``:JSON.stringify(t.variables,null,2)}}catch{}return{query:e??``,variables:``}},gtt=({value:e,onChange:t,isReadOnly:n})=>{let r=(0,H.useRef)(htt(e)).current,[i,a]=(0,H.useState)(r.query),[o,s]=(0,H.useState)(r.variables),c=(e,n)=>{let r=n.trim(),i={query:e};if(r)try{i={query:e,variables:JSON.parse(r)}}catch{}t(JSON.stringify(i,null,2))};return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex min-h-0 grow flex-col`,children:[(0,U.jsx)(`div`,{className:`px-3 py-1 text-xs font-medium text-muted-foreground`,children:`Query`}),(0,U.jsx)(`div`,{className:`min-h-0 grow`,children:(0,U.jsx)(yM,{defaultValue:r.query,language:`graphql`,options:{readOnly:n,lineNumbers:`on`,minimap:{enabled:!1}},onChange:e=>{a(e??``),c(e??``,o)}})})]}),(0,U.jsxs)(`div`,{className:`flex h-2/5 min-h-0 flex-col border-t border-border`,children:[(0,U.jsx)(`div`,{className:`px-3 py-1 text-xs font-medium text-muted-foreground`,children:`Variables`}),(0,U.jsx)(`div`,{className:`min-h-0 grow`,children:(0,U.jsx)(yM,{defaultValue:r.variables,language:`json`,options:{readOnly:n,lineNumbers:`off`,minimap:{enabled:!1}},onChange:e=>{s(e??``),c(i,e??``)}})})]})]})},VJ=`Checkbox`,[_tt,vtt]=T(VJ),[ytt,btt]=_tt(VJ),HJ=H.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=H.useState(null),m=ve(t,e=>p(e)),h=H.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=Ct({prop:i,defaultProp:a??!1,onChange:l,caller:VJ}),y=H.useRef(_);return H.useEffect(()=>{let e=f?.form;if(e){let t=()=>v(y.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[f,v]),(0,U.jsxs)(ytt,{scope:n,state:_,disabled:s,children:[(0,U.jsx)(ac.button,{type:`button`,role:`checkbox`,"aria-checked":KJ(_)?`mixed`:_,"aria-required":o,"data-state":qJ(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onKeyDown:Xs(e.onKeyDown,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:Xs(e.onClick,e=>{v(e=>KJ(e)?!0:!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,U.jsx)(GJ,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`},defaultChecked:KJ(a)?!1:a})]})});HJ.displayName=VJ;var UJ=`CheckboxIndicator`,WJ=H.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,a=btt(UJ,n);return(0,U.jsx)(uc,{present:r||KJ(a.state)||a.state===!0,children:(0,U.jsx)(ac.span,{"data-state":qJ(a.state),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})});WJ.displayName=UJ;var xtt=`CheckboxBubbleInput`,GJ=H.forwardRef(({__scopeCheckbox:e,control:t,checked:n,bubbles:r=!0,defaultChecked:i,...a},o)=>{let s=H.useRef(null),c=ve(s,o),l=xq(n),u=Ce(t);H.useEffect(()=>{let e=s.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(l!==n&&i){let t=new Event(`click`,{bubbles:r});e.indeterminate=KJ(n),i.call(e,KJ(n)?!1:n),e.dispatchEvent(t)}},[l,n,r]);let d=H.useRef(KJ(n)?!1:n);return(0,U.jsx)(ac.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:i??d.current,...a,tabIndex:-1,ref:c,style:{...a.style,...u,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});GJ.displayName=xtt;function KJ(e){return e===`indeterminate`}function qJ(e){return KJ(e)?`indeterminate`:e?`checked`:`unchecked`}var JJ=HJ,Stt=WJ,YJ=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(JJ,{ref:n,className:W(`peer h-4 w-4 shrink-0 rounded-sm border shadow-xs border-input ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-zuplo-600 data-[state=checked]:border-zuplo-500 data-[state=checked]:text-primary-foreground data-[state=indeterminate]:bg-zuplo-600 data-[state=indeterminate]:border-zuplo-500 data-[state=indeterminate]:text-primary-foreground`,e),...t,children:(0,U.jsx)(Stt,{className:W(`flex items-center justify-center text-current`),children:t.checked===`indeterminate`?(0,U.jsx)(hf,{size:12,strokeWidth:3.5}):(0,U.jsx)(ed,{size:12,strokeWidth:3.5})})}));YJ.displayName=JJ.displayName;var XJ=e=>[...Object.entries(e).map(([e,t])=>({enabled:!0,key:e,value:t})),{enabled:!0,key:``,value:``}],Ctt=e=>{let t=e[e.length-1];return!t||t.key!==``||t.value!==``?[...e,{enabled:!0,key:``,value:``}]:e},ZJ=e=>{let t={};for(let n of e)n.enabled&&n.key!==``&&(t[n.key]=n.value);return t},QJ=({value:e,onChange:t,testId:n,keyPlaceholder:r=`name`,valuePlaceholder:i=`value`})=>{let[a,o]=(0,H.useState)(()=>XJ(e));(0,H.useEffect)(()=>{o(XJ(e))},[n]);let s=(e,n)=>{let r=Ctt(e);o(r),t(ZJ(r),n)},c=(e,t)=>{s(a.map((n,r)=>r===e?{...n,...t}:n),!1)},l=e=>{s(a.map((t,n)=>n===e?{...t,enabled:!t.enabled}:t),!0)},u=e=>{s(a.filter((t,n)=>n!==e),!0)};return(0,U.jsx)(`div`,{className:`flex flex-col`,children:a.map((e,n)=>{let o=n===a.length-1,s=e.key===``&&e.value===``;return(0,U.jsxs)(`div`,{className:`group flex items-center gap-2 border-b border-border/60 py-1 pr-1`,children:[(0,U.jsx)(YJ,{"aria-label":`Enabled`,className:`shrink-0`,checked:e.enabled&&!(o&&s),disabled:o&&s,onCheckedChange:()=>l(n)}),(0,U.jsx)(`input`,{type:`text`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,placeholder:r,value:e.key,onChange:e=>c(n,{key:e.target.value}),onBlur:()=>t(ZJ(a),!0),className:W(`w-2/5 shrink-0 border-0 bg-transparent p-0 font-mono text-sm text-foreground shadow-none outline-none focus:ring-0 placeholder:text-muted-foreground/60`,!e.enabled&&`line-through opacity-50`)}),(0,U.jsx)(`input`,{type:`text`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,placeholder:i,value:e.value,onChange:e=>c(n,{value:e.target.value}),onBlur:()=>t(ZJ(a),!0),className:W(`min-w-0 grow border-0 bg-transparent p-0 font-mono text-sm text-foreground shadow-none outline-none focus:ring-0 placeholder:text-muted-foreground/60`,!e.enabled&&`line-through opacity-50`)}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Delete`,onClick:()=>u(n),className:W(`shrink-0 rounded-sm p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,o&&s?`invisible`:`opacity-0 group-hover:opacity-100`),children:(0,U.jsx)(ep,{className:`size-3.5`})})]},n)})})},$J=({size:e,...t})=>(0,U.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e??`1em`,height:e??`1em`,fill:`currentColor`,fillRule:`evenodd`,viewBox:`0 0 24 24`,...t,children:[(0,U.jsx)(`title`,{children:`Model Context Protocol`}),(0,U.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 0 0-3.61 0l-9.626 9.44a.863.863 0 0 1-1.203 0 .823.823 0 0 1 0-1.18l9.626-9.44a4.313 4.313 0 0 1 6.016 0 4.116 4.116 0 0 1 1.204 3.54 4.3 4.3 0 0 1 3.609 1.18l.05.05a4.115 4.115 0 0 1 0 5.9l-8.706 8.537a.274.274 0 0 0 0 .393l1.788 1.754a.823.823 0 0 1 0 1.18.863.863 0 0 1-1.203 0l-1.788-1.753a1.92 1.92 0 0 1 0-2.754l8.706-8.538a2.47 2.47 0 0 0 0-3.54l-.05-.049a2.588 2.588 0 0 0-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 0 1-1.204 0 .823.823 0 0 1 0-1.18l7.273-7.133a2.47 2.47 0 0 0-.003-3.537z`}),(0,U.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 0 0 0-1.18.863.863 0 0 0-1.204 0l-7.119 6.982a4.115 4.115 0 0 0 0 5.9 4.314 4.314 0 0 0 6.016 0l7.12-6.982a.823.823 0 0 0 0-1.18.863.863 0 0 0-1.204 0l-7.119 6.982a2.588 2.588 0 0 1-3.61 0 2.47 2.47 0 0 1 0-3.54l7.12-6.982z`})]}),eY=`flex h-6 items-center gap-1 rounded-md border border-input bg-background px-2 text-xs outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30`,wtt=({value:e,onChange:t,isReadOnly:n,listMcpTools:r})=>{let i=(0,H.useRef)(qN(e)?e:KN).current,[a,o]=(0,H.useState)(i),[s,c]=(0,H.useState)(0),[l,u]=(0,H.useState)({status:`idle`,tools:[]});(0,H.useEffect)(()=>{qN(e)||t(i)},[]);let d=e=>{o(e),c(e=>e+1),t(e)};return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 px-3 py-2`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,U.jsx)($J,{className:`size-3.5`}),`MCP request`]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r?(0,U.jsxs)(JG,{onOpenChange:e=>{!e||!r||l.status===`loading`||(u({status:`loading`,tools:[]}),r().then(e=>{u(e.ok?{status:`loaded`,tools:e.tools}:{status:`error`,tools:[],error:e.error})}))},children:[(0,U.jsxs)(YG,{disabled:n,className:eY,children:[`Call a tool`,(0,U.jsx)(td,{className:`size-3.5 opacity-50`})]}),(0,U.jsx)(XG,{align:`end`,className:`max-w-xs`,children:l.status===`loading`?(0,U.jsxs)(QG,{disabled:!0,className:`justify-center gap-2`,children:[(0,U.jsx)(cf,{className:`size-3.5 animate-spin`}),`Loading tools…`]}):l.status===`error`?(0,U.jsx)(QG,{disabled:!0,className:`whitespace-normal`,children:l.error??`Couldn't load tools.`}):l.tools.length===0?(0,U.jsx)(QG,{disabled:!0,children:`No tools found.`}):l.tools.map(e=>(0,U.jsxs)(QG,{className:`flex-col items-start gap-0.5`,onSelect:()=>d(QVe(e)),children:[(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),e.description?(0,U.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:e.description}):null]},e.name))})]}):null,(0,U.jsxs)(JG,{children:[(0,U.jsxs)(YG,{disabled:n,className:eY,children:[`Insert request`,(0,U.jsx)(td,{className:`size-3.5 opacity-50`})]}),(0,U.jsx)(XG,{align:`end`,children:WN.map(e=>(0,U.jsxs)(QG,{onSelect:()=>d(GN(e)),children:[(0,U.jsx)(`span`,{className:`flex-1`,children:e.label}),(0,U.jsx)(`span`,{className:`ml-4 font-mono text-xs text-muted-foreground`,children:e.method})]},e.id))})]})]})]}),(0,U.jsx)(`div`,{className:`min-h-0 grow`,children:(0,U.jsx)(yM,{defaultValue:a,language:`json`,options:{readOnly:n,lineNumbers:`on`,minimap:{enabled:!1}},onChange:e=>{o(e??``),t(e??``)}},s)})]})},Ttt=({labelClassName:e,label:t,fieldName:n,span:r,children:i})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:n,className:(0,eM.default)(`col-span-1 block text-sm font-medium text-foreground text-right`,e),children:t}),(0,U.jsx)(`div`,{className:`col-span-${r} flex flex-row items-center`,children:i})]}),Ett=({isReadOnly:e,requestBody:t,language:n,onBodyChange:r,onPersist:i,bare:a=!1})=>{let[o,s]=(0,H.useState)(t),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(),[f,p]=(0,H.useState)();(0,H.useEffect)(()=>{f?.dispose();let e=u?.onDidBlurEditorText(()=>{i()});p(e),r(t),l(!1)},[u,t,o]);let m=(0,U.jsx)(yM,{defaultValue:t,onMount:e=>{d(e)},options:{readOnly:e,lineNumbers:`off`,minimap:{enabled:!1},language:n},onChange:e=>{c||l(JSON.stringify(e)!==JSON.stringify(t)),(c||JSON.stringify(e)!==JSON.stringify(t))&&(r(e),s(e))}});return a?(0,U.jsx)(`div`,{className:`h-full w-full`,children:m}):(0,U.jsx)(Ttt,{label:`Body`,fieldName:`Body`,span:5,children:(0,U.jsx)(`div`,{className:`w-full h-40 rounded-sm border-border border p-2`,children:m})})},Dtt=e=>{let t=[],n=e.match(/^[a-zA-Z][\w+.-]*:\/\//),r=e;n&&(t.push({text:n[0],className:`text-sky-600 dark:text-sky-400`}),r=e.slice(n[0].length));let i=r.indexOf(`?`),a=i===-1?r:r.slice(0,i),o=i===-1?``:r.slice(i),s=a.indexOf(`/`),c=s===-1?a:a.slice(0,s),l=s===-1?``:a.slice(s);if(c&&t.push({text:c,className:`text-foreground`}),l&&t.push({text:l,className:`text-emerald-600 dark:text-emerald-400`}),o){t.push({text:`?`,className:`text-muted-foreground`});let e=!0;for(let n of o.slice(1).split(/([&=])/))n===`&`?(t.push({text:`&`,className:`text-muted-foreground`}),e=!0):n===`=`?(t.push({text:`=`,className:`text-muted-foreground`}),e=!1):n!==``&&t.push({text:n,className:e?`text-violet-600 dark:text-violet-400`:`text-amber-600 dark:text-amber-400`})}return t},Ott=({value:e,onChange:t,onBlur:n})=>{let r=(0,H.useRef)(null),i=(0,H.useRef)(null),a=()=>{i.current&&r.current&&(i.current.scrollLeft=r.current.scrollLeft)};return(0,U.jsxs)(`div`,{className:`relative flex min-w-0 grow items-center`,children:[(0,U.jsx)(`div`,{ref:i,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 flex items-center overflow-hidden whitespace-pre px-3 font-mono text-sm`,children:Dtt(e).map((e,t)=>(0,U.jsx)(`span`,{className:e.className,children:e.text},t))}),(0,U.jsx)(`input`,{ref:r,type:`text`,name:`url`,"aria-label":`Request URL`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),onBlur:()=>n(),onScroll:a,className:`min-w-0 grow border-0 bg-transparent px-3 font-mono text-sm text-transparent caret-foreground shadow-none outline-none focus:ring-0`})]})},tY=`rounded-md px-2.5 py-1 text-sm font-medium text-muted-foreground data-[state=active]:bg-accent data-[state=active]:text-foreground data-[state=active]:shadow-none`,ktt=({phase:e,onSkip:t})=>(0,U.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 px-6 text-center`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Let's wait for the latest version to land…`}),(0,U.jsx)(`ul`,{className:`flex flex-col gap-3 text-sm`,children:(e===`waiting-for-build`?[{label:`Building the gateway`,status:`active`},{label:`Deploying your gateway`,status:`pending`},{label:`Executing test request`,status:`pending`}]:e===`verifying-deployment`?[{label:`Building the gateway`,status:`done`},{label:`Deploying your gateway`,status:`active`},{label:`Executing test request`,status:`pending`}]:[{label:`Building the gateway`,status:`done`},{label:`Deploying your gateway`,status:`done`},{label:`Executing test request`,status:`active`}]).map(n=>(0,U.jsxs)(`li`,{className:`flex items-center gap-2.5`,children:[n.status===`done`?(0,U.jsx)(ld,{className:`size-4 shrink-0 text-green-600 dark:text-green-500`}):n.status===`active`?(0,U.jsx)(cf,{className:`size-4 shrink-0 animate-spin text-foreground`}):(0,U.jsx)(hd,{className:`size-4 shrink-0 text-muted-foreground/40`}),(0,U.jsx)(`span`,{className:W(n.status===`active`?`font-medium text-foreground`:`text-muted-foreground`),children:n.label}),t&&e!==`executing`&&n.label===`Building the gateway`?(0,U.jsx)(`button`,{type:`button`,onClick:t,className:`-my-0.5 rounded px-1.5 py-0.5 text-sm font-normal text-muted-foreground/70 hover:bg-accent hover:text-foreground`,children:`Skip`}):null]},n.label))})]}),Att=({bodyType:e,methodHasBody:t,onBodyTypeChange:n})=>{let[r,i]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{if(!t||e!==`none`)return;let n=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(n)},[]),(0,U.jsxs)(JG,{modal:!1,open:r,onOpenChange:i,children:[(0,U.jsxs)(YG,{"aria-label":`Body type`,disabled:!t,className:`flex h-6 w-28 items-center justify-between gap-1 rounded-md bg-transparent px-2 text-xs outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50`,children:[QN[e],(0,U.jsx)(td,{className:`size-3.5 opacity-50`})]}),(0,U.jsx)(XG,{align:`start`,side:`top`,children:(0,U.jsx)(eK,{value:e,onValueChange:e=>n(e),children:Object.keys(QN).map(e=>(0,U.jsx)(tK,{value:e,trailingIndicator:!0,children:QN[e]},e))})})]})},jtt=({ape:e,url:t,allowedMethods:n,testRequest:r,bodySeedValue:i,urlValue:a,bodyType:o,activeTab:s,onActiveTabChange:c,requesting:l,buildReadinessPhase:u=`idle`,error:d,testResponse:f,durationMs:p,requestId:m,isReadOnly:h,shouldAllowLocalSaving:g,shouldSaveLocally:_,showRebuildWarning:v,operationId:y,path:b,headersSeed:x,authSeed:S,paramsSeed:C,allowApiKeyService:w=!0,history:T,onRestoreFromHistory:E,onClearHistory:D,listMcpTools:O,onChange:k,onUrlChange:A,onClear:j,onParamsChange:M,onHeadersChangeFromHeaders:N,onHeadersChangeFromAuth:P,onBodyTypeChange:F,onPersist:I,onLocalSaveToggle:L,onSend:R,onStop:z,onSkipBuildWait:B,onClearResponse:ee,onClose:V,buildBadge:te,endpoints:ne,selectedEndpointId:re,onSelectEndpoint:ie,isEndpointPanelOpen:ae=!1,onToggleEndpointPanel:oe,endpointsLoading:se=!1})=>{let[ce,le]=(0,H.useState)(!1),ue=!!ie&&!!oe&&(!!ne?.length||se),de=e=>{navigator.clipboard?.writeText(e)},fe=r.headers??{},pe=Object.keys(r.headers??{}).length,me=Object.keys(r.headers??{}).some(e=>e.toLowerCase()===`authorization`),he=ZN(r.method),ge=rHe[o],_e=Object.fromEntries(new URLSearchParams((r.pathname??``).split(`?`)[1]??``)),ve=Object.keys(_e).length,ye=(()=>{if(!t)return null;try{let e=new URL(t);return`${e.pathname}${e.search}`}catch{return null}})(),be=ye!=null&&(r.pathname??``)!==ye||ve>0||pe>0||(r.body??``).length>0,xe=(0,U.jsx)(`span`,{className:`size-1.5 rounded-full bg-current opacity-70`}),Se=(0,U.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,U.jsxs)(AO,{value:s,onValueChange:c,className:`flex min-h-0 grow flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 pt-2.5`,children:[(0,U.jsxs)(jO,{className:`h-auto gap-1 bg-transparent p-0`,children:[(0,U.jsxs)(MO,{value:`params`,className:`${tY} gap-1.5`,children:[`Params`,ve?(0,U.jsx)(XD,{variant:`secondary`,size:`sm`,className:`rounded-full`,children:ve}):null]}),(0,U.jsxs)(MO,{value:`headers`,className:`${tY} gap-1.5`,children:[`Headers`,pe?(0,U.jsx)(XD,{variant:`secondary`,size:`sm`,className:`rounded-full`,children:pe}):null]}),(0,U.jsxs)(MO,{value:`auth`,className:`${tY} gap-1.5`,children:[`Auth `,me?xe:null]}),(0,U.jsxs)(MO,{value:`body`,className:`${tY} gap-1.5`,children:[`Body `,he&&o!==`none`?xe:null]})]}),g&&y&&(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{"aria-label":`More options`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,U.jsx)(Od,{className:`size-4`})}),(0,U.jsx)(XG,{align:`end`,children:(0,U.jsx)($G,{checked:_,onCheckedChange:L,children:`Save request in browser storage`})})]})]}),(0,U.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:[(0,U.jsx)(NO,{value:`params`,className:`mt-0 px-3 pt-2`,children:(0,U.jsx)(QJ,{value:_e,onChange:M,testId:`${b??y}:p${C}`})}),(0,U.jsx)(NO,{value:`headers`,className:`mt-0 px-3 pt-2`,children:(0,U.jsx)(QJ,{value:r.headers,onChange:N,testId:`${b??y}:h${x}`})}),(0,U.jsx)(NO,{value:`auth`,className:`mt-0 h-full data-[state=active]:flex`,children:(0,U.jsx)(ltt,{ape:e,headers:r.headers,onChange:P,authSelection:r.authSelection,testId:`${b??y}:a${S}`,onPersist:I,allowApiKeyService:w})}),(0,U.jsxs)(NO,{value:`body`,className:`mt-0 h-full data-[state=active]:flex data-[state=active]:flex-col`,children:[(0,U.jsx)(`div`,{className:`min-h-0 grow overflow-hidden`,children:he?o===`none`?(0,U.jsx)(`div`,{className:`flex h-full w-full items-center justify-center px-4 text-center text-sm text-muted-foreground`,children:`This request does not send a body.`}):o===`form`?(0,U.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,U.jsx)(mtt,{value:r.body??``,onChange:e=>k(`body`,e),onPersist:I,testId:b??y})}):o===`graphql`?(0,U.jsx)(gtt,{value:r.body??``,onChange:e=>k(`body`,e),isReadOnly:h&&!g},`gql-${b??y}`):o===`mcp`?(0,U.jsx)(wtt,{value:r.body??``,onChange:e=>k(`body`,e),isReadOnly:h&&!g,listMcpTools:O},`mcp-${b??y}`):(0,U.jsx)(Ett,{bare:!0,requestBody:i,onBodyChange:e=>k(`body`,e),isReadOnly:h&&!g,language:ge,onPersist:I}):(0,U.jsxs)(`div`,{className:`flex h-full w-full items-center justify-center px-4 text-center text-sm text-muted-foreground`,children:[r.method,` requests don't send a body.`]})}),(0,U.jsx)(`div`,{className:`flex h-7 shrink-0 items-center border-t border-border px-2`,children:(0,U.jsx)(Att,{bodyType:o,methodHasBody:he,onBodyTypeChange:F})})]})]})]})}),Ce=d?(0,U.jsxs)(`div`,{className:`flex h-full items-center justify-center p-4 text-center text-red-600`,children:[(0,U.jsx)(od,{className:`mr-2 size-4 shrink-0`}),(0,U.jsxs)(`span`,{children:[`Error: `,d]})]}):l&&u!==`idle`?(0,U.jsx)(ktt,{phase:u,onSkip:B}):l?(0,U.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,U.jsx)(jf,{className:`mr-2 size-4 animate-pulse`}),`Sending request…`]}):f?(0,U.jsx)(itt,{result:f,requestId:m,durationMs:p,onClear:ee}):(0,U.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 px-6 text-center text-muted-foreground`,children:[(0,U.jsx)(jf,{className:`size-6 opacity-60`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Send your request to see the response here.`})]});return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,U.jsx)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-border p-2`,children:(0,U.jsxs)(`div`,{className:`flex items-stretch gap-2`,children:[(0,U.jsxs)(`div`,{className:`relative flex h-10 min-w-0 grow items-stretch overflow-hidden rounded-lg border border-input bg-background transition-shadow focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 dark:bg-input/30`,children:[T&&(0,U.jsxs)(dT,{open:ce,onOpenChange:le,children:[(0,U.jsx)(fT,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,"aria-label":`Request history`,title:`Request history`,className:`flex h-full w-10 shrink-0 items-center justify-center border-r border-input text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-0`,children:(0,U.jsx)(Qd,{className:`size-4`})})}),(0,U.jsx)(pT,{align:`start`,className:`w-96 p-0`,children:(0,U.jsx)(Get,{entries:[...T].reverse(),onRestore:e=>{E?.(e),le(!1)},onClear:D})})]}),(0,U.jsxs)(mJ,{value:r.method??`GET`,onValueChange:e=>k(`method`,e,!0),children:[(0,U.jsx)(_J,{"aria-label":`Method`,className:`h-full! w-24 shrink-0 justify-center gap-1 rounded-none border-0 border-r border-input bg-transparent px-3 font-mono font-semibold shadow-none focus-visible:ring-0 dark:bg-transparent`,children:(0,U.jsx)(`span`,{className:XN[r.method]??``,children:r.method??`GET`})}),(0,U.jsx)(vJ,{align:`start`,className:`font-mono`,children:YN.map(e=>(0,U.jsxs)(bJ,{value:e,children:[(0,U.jsx)(`span`,{className:XN[e]??``,children:e}),n.includes(e)?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:` *`}):null]},e))})]}),(0,U.jsx)(Ott,{value:a,onChange:A,onBlur:I}),be&&(0,U.jsx)(`button`,{type:`button`,"aria-label":`Clear request`,title:`Clear the request`,onClick:j,className:`flex shrink-0 items-center px-2 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(xpe,{className:`size-4`})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Copy URL`,title:`Copy URL`,onClick:()=>de(a),className:`flex shrink-0 items-center pr-0.5 pl-2 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(Sd,{className:`size-4`})}),(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{"aria-label":`Copy request as…`,title:`Copy as…`,className:`flex shrink-0 items-center pr-2 pl-0.5 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground`,children:(0,U.jsx)(td,{className:`size-3.5`})}),(0,U.jsxs)(XG,{align:`end`,children:[(0,U.jsxs)(QG,{onSelect:()=>de(oHe(r.method,a,fe,r.body)),children:[(0,U.jsx)(Wf,{className:`size-4`}),`Copy as cURL`]}),(0,U.jsxs)(QG,{onSelect:()=>de(sHe(r.method,a,fe,r.body)),children:[(0,U.jsx)(vd,{className:`size-4`}),`Copy as fetch`]}),(0,U.jsxs)(QG,{onSelect:()=>de(cHe(r.method,a,fe,r.body)),children:[(0,U.jsx)(Nd,{className:`size-4`}),`Copy as HTTP`]})]})]}),(0,U.jsxs)(`button`,{type:`button`,disabled:l&&!z,onClick:l&&z?z:R,"aria-label":l&&z?`Stop request`:void 0,className:`relative flex h-full shrink-0 items-center justify-center border-l border-input bg-brand px-4 text-sm font-medium text-brand-foreground transition-colors hover:bg-brand/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[(0,U.jsxs)(`span`,{className:W(`flex items-center gap-2`,l&&`invisible`),children:[`Send`,(0,U.jsxs)(aK,{className:`max-sm:hidden`,children:[(0,U.jsx)(iK,{className:`bg-brand-foreground/15 text-brand-foreground`,children:fP(`meta`)}),(0,U.jsx)(iK,{className:`bg-brand-foreground/15 text-brand-foreground`,children:`↵`})]})]}),l&&(0,U.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:z?(0,U.jsx)(Bf,{className:`size-3.5 fill-current`}):(0,U.jsx)(cf,{className:`size-4 animate-spin`})})]})]}),V&&(0,U.jsx)(`button`,{type:`button`,"aria-label":`Close`,onClick:V,className:`flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,U.jsx)(ep,{className:`size-4`})})]})}),(0,U.jsxs)(`div`,{className:`flex min-h-0 min-w-0 grow gap-2 bg-muted p-2`,children:[ue&&ae&&ie&&(0,U.jsx)(`div`,{className:`w-64 shrink-0 overflow-hidden rounded-lg border border-border bg-background`,children:(0,U.jsx)(ftt,{endpoints:ne??[],selectedEndpointId:re,onSelect:ie,isLoading:se})}),(0,U.jsx)(`div`,{className:`h-full min-h-0 min-w-0 grow overflow-hidden rounded-lg border border-border bg-background`,children:(0,U.jsxs)(_q,{direction:`horizontal`,children:[(0,U.jsx)(vq,{defaultSize:50,minSize:30,children:Se}),(0,U.jsx)(yq,{}),(0,U.jsx)(vq,{defaultSize:50,minSize:30,children:Ce})]})})]}),(ue||v||te)&&(0,U.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-3 border-t border-border px-3 text-xs text-muted-foreground`,children:[ue&&(0,U.jsxs)(`button`,{type:`button`,onClick:oe,"aria-pressed":ae,title:ae?`Hide endpoints`:`Show endpoints`,className:`-ml-1 flex items-center gap-1.5 rounded-md px-1.5 py-1 outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[ae?(0,U.jsx)(_f,{className:`size-3.5`}):(0,U.jsx)(vf,{className:`size-3.5`}),`Endpoints`]}),v&&(0,U.jsxs)(`span`,{className:`flex items-center text-zuplo-600`,children:[(0,U.jsx)(hd,{className:`mr-1 size-2 shrink-0 fill-zuplo-highlight text-zuplo-600`}),`Undeployed changes. Press`,(0,U.jsxs)(aK,{className:`mx-1.5 text-foreground`,children:[(0,U.jsx)(iK,{children:fP(`meta`)}),(0,U.jsx)(`span`,{children:`+`}),(0,U.jsx)(iK,{children:`S`})]}),`to deploy.`]}),te&&(0,U.jsx)(`div`,{className:`ml-auto flex items-center`,children:te})]})]})},nY=new aP,Mtt=`The latest build failed, so your changes aren't live yet. Check the build logs, fix the error, and redeploy before testing.`,Ntt=`Timed out waiting for the gateway build to go live. It may be stuck — check the build status and try again.`,rY=({ape:e,url:t,apiTest:n,allowedMethods:r=YN,shouldAllowLocalSaving:i,operationId:a,path:o,onRequestChange:s,onBeforeFire:c,onTestDirtied:l,showRebuildWarning:u,onClose:d,endpoints:f,selectedEndpointId:p,onSelectEndpoint:m,isEndpointPanelOpen:h,onToggleEndpointPanel:g,endpointsLoading:_})=>{let v=(a?nY.getTest(e.account.name,e.project.name,e.environment.name,a):void 0)?.shouldSaveTest!==!1,y=gHe(e.environment),{phase:b,awaitReady:x,skip:S}=bHe(e.environment,y),C=(y??``).replace(/\/$/,``),w=Cp(e=>e.testResponse),T=Cp(e=>e.setTestResponse),[E,D]=(0,H.useState)(n),[O,k]=(0,H.useState)(`${C}${n.pathname??``}`),[A,j]=(0,H.useState)(null),M=Cp(e=>e.appendExecutionHistory),N=Cp(e=>e.clearExecutionHistory),P=o??``,F=Cp(xp(t=>t.executionHistory.filter(t=>t.account===e.account.name&&t.project===e.project.name&&t.environment===e.environment.name&&t.path===P))),[I,L]=(0,H.useState)(!1),R=(0,H.useRef)(null),[z,B]=(0,H.useState)(),[ee,V]=(0,H.useState)(),[te,ne]=(0,H.useState)(v),[re,ie]=(0,H.useState)(ZN(n.method)?`body`:`headers`),[ae,oe]=(0,H.useState)(()=>$N(n)),[se,ce]=(0,H.useState)(0),[le,ue]=(0,H.useState)(0),[de,fe]=(0,H.useState)(0),pe=e.environment.environmentType!==GM.WORKING_COPY,{celebrate:me}=uHe(),{logEvent:he,captureException:ge}=on(),_e=oP();(0,H.useEffect)(()=>{D(n),oe($N(n)),k(`${C}${n.pathname??``}`)},[o]),(0,H.useEffect)(()=>{k(`${C}${E.pathname??``}`)},[C]);let ve=(0,H.useCallback)(async()=>{let t={...E.headers},n=Object.keys(t).find(e=>e.toLowerCase()===`content-type`)??`content-type`;t[n]=`application/json`;let r=Object.keys(t).find(e=>e.toLowerCase()===`accept`)??`accept`;t[r]=`application/json, text/event-stream`;let i={...E,method:`POST`,headers:t,body:KN};try{let t=await(await _e({environmentName:e.environment.name,testRequest:i,overrideUrl:y})).json(),n=tHe(t.body??``);return n.ok?n:typeof t.status==`number`&&t.status>=400?{ok:!1,error:`The MCP server responded ${t.status}${t.statusText?` ${t.statusText}`:``}.`}:n}catch(e){return{ok:!1,error:e instanceof Error?e.message:`Request failed`}}},[E,_e,e,y]),ye=async()=>{let t=y;if(!t){j(it);return}let n=new AbortController;R.current=n;let{signal:r}=n;L(!0),T(void 0),j(null);let i=await x(r);if(r.aborted)return;if(i===`build-failed`){L(!1),j(Mtt);return}if(i===`timeout`){L(!1),j(Ntt);return}let a=`zuplo-request-id`,o={...E.headers},s={...E,headers:o};if([`GET`,`HEAD`].includes(s.method))delete s.body;else if(ae===`graphql`&&s.body?.trim()){let e=!1;try{let t=JSON.parse(s.body);e=!!t&&typeof t==`object`&&`query`in t}catch{e=!1}e||(s.body=JSON.stringify({query:s.body}))}let l=s.headers[a]??Ne();s.headers[a]=l,B(l),c?.(l);let u=Date.now(),d=performance.now(),f=DHe(t);try{let n=await(await _e({environmentName:e.environment.name,testRequest:s,overrideUrl:t})).json();if(r.aborted)return;let i=Math.round(performance.now()-d);he(`test-console-fired`,{account:e.account.name,project:e.project.name,environment:e.environment.name,environmentType:e.environment.environmentType,httpMethod:s.method,httpStatusCode:n.status,durationMs:i,targetHost:f,cloudflareErrorCode:THe(n.body),edgeServer:EHe(n.headers,`server`)}),L(!1),V(i),T(n),me(`FIRST_200_TEST`,n),M({id:`${u}-${l}`,account:e.account.name,project:e.project.name,path:P,environment:e.environment.name,status:n.status,timestamp:u,durationMs:i,bodyType:ae,request:{...E,headers:{...E.headers}}})}catch(t){if(r.aborted)return;let n=Math.round(performance.now()-d),i=t instanceof ut,a=t instanceof Error?t.message:`Unknown error`;L(!1),j(a),he(`test-console-fired-error`,{account:e.account.name,project:e.project.name,environment:e.environment.name,environmentType:e.environment.environmentType,httpMethod:s.method,durationMs:n,targetHost:f,errorMessage:a,testProxyError:i,testProxyErrorCode:i?t.code:void 0}),ge(t)}},be=()=>{ye()},xe=()=>{R.current?.abort(),L(!1),j(null)},Se=()=>{I?xe():be()},Ce=t=>{let n={...t.request,headers:{...t.request.headers}};D(n),oe(t.bodyType??$N(n)),k(`${C}${n.pathname??``}`),fe(e=>e+1),ce(e=>e+1),ue(e=>e+1),j(null),T(void 0),je(n),he(`test-console-history-restored`,{account:e.account.name,project:e.project.name,environment:e.environment.name,httpMethod:n.method})},we=()=>{N(t=>t.account===e.account.name&&t.project===e.project.name&&t.environment===e.environment.name&&t.path===P)};pP(`meta+enter`,Se);let Te=(e,t,n)=>{let r={...E,[e]:t};D(r),n?je(r):l?.()},Ee=e=>{k(e),Te(`pathname`,tP(e,C)),fe(e=>e+1)},De=()=>{let e=t?tP(t,C):(E.pathname??``).split(`?`)[0],n={...E,headers:{},body:``,pathname:e,authSelection:void 0};D(n),k(`${C}${e}`),oe(`none`),fe(e=>e+1),ce(e=>e+1),ue(e=>e+1),je(n)},Oe=(e,t)=>{let n=(E.pathname??``).split(`?`)[0],r=new URLSearchParams(e).toString(),i=r?`${n}?${r}`:n;k(`${C}${i}`),Te(`pathname`,i,t)},ke=(e,t)=>{Te(`headers`,e,t),ue(e=>e+1)},Ae=(e,t,n)=>{let r={...E,headers:e,authSelection:n??void 0};D(r),t?je(r):l?.(),ce(e=>e+1)},je=t=>{let n=t??E;te&&a&&nY.writeTest({account:e.account.name,project:e.project.name,environment:e.environment.name,operationId:a,test:n}),s(n)};return(0,U.jsx)(jtt,{ape:e,url:t,allowedMethods:r,testRequest:E,bodySeedValue:n.body,urlValue:O,bodyType:ae,activeTab:re,onActiveTabChange:ie,requesting:I,buildReadinessPhase:b,error:A,testResponse:w,durationMs:ee,requestId:z,isReadOnly:pe,shouldAllowLocalSaving:i,shouldSaveLocally:te,showRebuildWarning:u,operationId:a,path:o,headersSeed:se,authSeed:le,paramsSeed:de,history:F,onRestoreFromHistory:Ce,onClearHistory:we,listMcpTools:ve,onChange:Te,onUrlChange:Ee,onClear:De,onParamsChange:Oe,onHeadersChangeFromHeaders:ke,onHeadersChangeFromAuth:Ae,onBodyTypeChange:e=>{oe(e);let t={...E.headers},n=Object.keys(t).find(e=>e.toLowerCase()===`content-type`),r=nHe[e];r?t[n??`content-type`]=r:n&&delete t[n];let i={...E,headers:t};if(e===`none`)i.body=``;else if(e===`mcp`){let e=Object.keys(t).find(e=>e.toLowerCase()===`accept`)??`accept`;t[e]=`application/json, text/event-stream`,qN(i.body)||(i.body=KN)}D(i),ce(e=>e+1),je(i)},onPersist:je,onLocalSaveToggle:t=>{ne(!te),he(te?`test-console-local-save-enable-clicked`:`test-console-local-save-disable-clicked`,{account:e.account.name,project:e.project.name,environment:e.environment.name}),!t&&a&&nY.optTestOutOfLocalSaving(e.account.name,e.project.name,e.environment.name,a)},onSend:be,onStop:xe,onSkipBuildWait:S,onClearResponse:()=>T(void 0),onClose:d,buildBadge:(0,U.jsx)(J5e,{deploymentUrl:y,environmentName:e.environment.name}),endpoints:f,selectedEndpointId:p,onSelectEndpoint:m,isEndpointPanelOpen:h,onToggleEndpointPanel:g,endpointsLoading:_})};function Ptt(e){if(typeof e!=`object`||!e)return null;let t=e,n=e=>typeof e==`string`?e:void 0;return{path:n(t.path),method:n(t.method),body:n(t.body),environment:n(t.environment),description:n(t.description)}}function Ftt({data:e}){let[t,n]=(0,H.useState)(!1),{logEvent:r}=on(),{account:i,project:a,environment:o}=lb([]),s=!!(i&&a),c=Cp(e=>e.setTestResponse),l=vb({enabled:t&&!!i,throwOnError:!1,refetchOnMount:!1,refetchOnWindowFocus:!1}),u=l.data?.find(e=>e.name===i),d=gT(i??``,{enabled:t&&s,throwOnError:!1,refetchOnMount:!1,refetchOnWindowFocus:!1}),f=d.data?.find(e=>e.name===a),p=zN(i??``,a??``,{enabled:t&&s,throwOnError:!1,refetchOnMount:!1,refetchOnWindowFocus:!1}),m=p.data,h=e=>e?m?.find(t=>t.urlParameter===e):void 0,g=[h(e.environment),h(o),m?.find(e=>e.environmentType===GM.PRODUCTION),...m??[]].filter(e=>!!e),_=g.find(e=>sP(e))??g[0],v=_?(sP(_)??``).replace(/\/$/,``):``,y=t&&!p.isFetching&&!!m&&!v,b=t&&(!l.isFetching&&l.isError||!d.isFetching&&d.isError||!p.isFetching&&p.isError),x=t&&!b&&!y&&!(u&&f&&_&&v),S=e.path?.trim()??``,C=e.method?.trim().toUpperCase(),w=C&&YN.includes(C)?C:`GET`,T={description:e.description??``,pathname:S,method:w,headers:{},body:e.body},E=()=>{n(!1),c(void 0)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Hje,{method:w,path:S||void 0,description:e.description,loading:x,disabled:!s,errorText:y?`No deployed environment to test against yet — deploy the project first.`:b?`Couldn’t open the test console — please try again.`:void 0,onOpen:()=>{s&&(r(`agent-z-test-console-card-clicked`,{account:i,project:a}),c(void 0),n(!0),l.isError&&l.refetch(),d.isError&&d.refetch(),(p.isError||y)&&p.refetch())}}),t&&u&&f&&_&&v?(0,U.jsx)(tb,{open:!0,onOpenChange:e=>{e||E()},children:(0,U.jsxs)(ib,{showCloseButton:!1,className:`max-w-6xl! w-full gap-0 overflow-hidden p-0`,children:[(0,U.jsx)(sb,{className:`sr-only`,children:`Test console`}),(0,U.jsx)(`div`,{className:`flex h-[650px] max-h-[70vh] flex-col`,children:(0,U.jsx)(rY,{ape:{account:u,project:f,environment:_},apiTest:T,url:`${v}${S}`,path:S||null,showRebuildWarning:!1,shouldAllowLocalSaving:!1,onRequestChange:()=>{},onClose:E})})]})}):null]})}function Itt({data:e}){let t=Xa(),{account:n,project:r}=lb([]),{logEvent:i}=on(),a=!!(n&&r);return(0,U.jsx)(Gje,{name:e.name,description:e.description,disabled:!a,onOpen:()=>{if(!n||!r)return;i(`agent-z-ai-app-card-clicked`,{account:n,project:r,hasTeam:!!e.teamId});let a=new URLSearchParams;e.name&&a.set(`name`,e.name),e.teamId&&a.set(`team`,e.teamId);let o=a.toString();t(`/${n}/${r}/ai/apps/new${o?`?${o}`:``}`)}})}var Ltt=(0,H.createContext)(null),iY={didCatch:!1,error:null},Rtt=class extends H.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=iY}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;t!==null&&(this.props.onReset?.({args:e,reason:`imperative-api`}),this.setState(iY))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&ztt(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(iY))}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:a}=this.state,o=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof t==`function`)o=t(e);else if(n)o=(0,H.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,H.createElement)(Ltt.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function ztt(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}function aY(e,t,n,r){let i;try{i=y(t,n,r)}catch{i={blastRadius:n}}oY(()=>S.captureRaw(`portal-error-shown`,i)),oY(()=>S.captureException(t,i)),oY(()=>Btt(e,i,t,n))}function Btt(e,t,n,r){((r===`app-dead`||r===`page-dead`)&&t.errorExpected!==!0?ot.error:ot.warn)(e,{...t,error:n})}function oY(e){try{e()}catch{}}var sY=({children:e,fallback:t,blastRadius:n=`page-dead`})=>(0,U.jsx)(Rtt,{onError:(e,t)=>{aY(`Portal error boundary caught an error`,e,n,{componentStack:t.componentStack})},fallbackRender:({error:e,resetErrorBoundary:n})=>t({error:e,resetError:n}),children:e}),cY=()=>{let{account:e,project:t}=lb([`account`,`project`]);return fb(mt.project(e,t),{extractData:!1}).data},Vtt=`Label`,lY=H.forwardRef((e,t)=>(0,U.jsx)(ac.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));lY.displayName=Vtt;var uY=lY,Htt=Ou(`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`),dY=H.forwardRef(({className:e,...t},n)=>(0,U.jsx)(uY,{ref:n,className:W(Htt(),e),...t}));dY.displayName=uY.displayName;var fY=mD,pY=H.createContext({}),mY=({...e})=>(0,U.jsx)(pY.Provider,{value:{name:e.name},children:(0,U.jsx)(yD,{...e})}),hY=()=>{let e=H.useContext(pY),t=H.useContext(gY),{getFieldState:n,formState:r}=pD(),i=n(e.name,r);if(!e)throw Error(`useFormField should be used within <FormField>`);let{id:a}=t;return{id:a,name:e.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...i}},gY=H.createContext({}),_Y=H.forwardRef(({className:e,...t},n)=>{let r=H.useId();return(0,U.jsx)(gY.Provider,{value:{id:r},children:(0,U.jsx)(`div`,{ref:n,className:W(`space-y-1`,e),...t})})});_Y.displayName=`FormItem`;var vY=H.forwardRef(({className:e,...t},n)=>{let{error:r,formItemId:i}=hY();return(0,U.jsx)(dY,{ref:n,className:W(r&&`text-destructive`,e),htmlFor:i,...t})});vY.displayName=`FormLabel`;var yY=H.forwardRef(({...e},t)=>{let{error:n,formItemId:r,formDescriptionId:i,formMessageId:a}=hY();return(0,U.jsx)(Qs,{ref:t,id:r,"aria-describedby":n?`${i} ${a}`:`${i}`,"aria-invalid":!!n,...e})});yY.displayName=`FormControl`;var bY=H.forwardRef(({className:e,...t},n)=>{let{formDescriptionId:r}=hY();return(0,U.jsx)(`p`,{ref:n,id:r,className:W(`text-sm text-muted-foreground`,e),...t})});bY.displayName=`FormDescription`;var xY=H.forwardRef(({className:e,children:t,...n},r)=>{let{error:i,formMessageId:a}=hY(),o=i?.message?String(i.message):t;return o?(0,U.jsx)(`p`,{ref:r,id:a,className:W(`text-sm font-medium text-destructive`,e),...n,children:o}):null});xY.displayName=`FormMessage`;var Utt=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,Wtt=e=>crypto.getRandomValues(new Uint8Array(e)),Gtt=(e,t,n)=>{let r=(2<<Math.log2(e.length-1))-1,i=-~(1.6*r*t/e.length);return(a=t)=>{let o=``;for(;;){let t=n(i),s=i|0;for(;s--;)if(o+=e[t[s]&r]||``,o.length>=a)return o}}},SY=(e,t=21)=>Gtt(e,t|0,Wtt),Ktt=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Utt[n[e]&63];return t},qtt=(e,t)=>`${e}::${t}`,Jtt={"app.created":{success:`ai-gateway-create-app-success`,failed:`ai-gateway-create-app-failed`},"app.deleted":{success:`ai-gateway-delete-app-success`,failed:`ai-gateway-delete-app-failed`},"app.settings-updated":{success:`ai-gateway-update-app-settings-success`,failed:`ai-gateway-update-app-settings-failed`},"gateway.redeploy-requested":{success:`ai-gateway-redeploy-success`,failed:`ai-gateway-redeploy-failed`},"policy.updated":{success:`ai-gateway-update-policy-success`,failed:`ai-gateway-update-policy-failed`},"provider.created":{success:`ai-gateway-create-ai-provider-success`,failed:`ai-gateway-create-ai-provider-failed`},"provider.deleted":{success:`ai-gateway-delete-ai-provider-success`,failed:`ai-gateway-delete-ai-provider-failed`},"provider.updated":{success:`ai-gateway-update-ai-provider-success`,failed:`ai-gateway-update-ai-provider-failed`},"team.created":{success:`ai-gateway-create-team-success`,failed:`ai-gateway-create-team-failed`},"team.default-created":{success:`ai-gateway-create-default-team-success`,failed:`ai-gateway-create-default-team-failed`},"team.deleted":{success:`ai-gateway-delete-team-success`,failed:`ai-gateway-delete-team-failed`},"team.limits-updated":{success:`ai-gateway-update-team-limits-success`,failed:`ai-gateway-update-team-limits-failed`},"team.member-role-updated":{success:`ai-gateway-update-team-member-role-success`,failed:`ai-gateway-update-team-member-role-failed`},"team.policy-template-updated":{success:`ai-gateway-update-team-policy-template-success`,failed:`ai-gateway-update-team-policy-template-failed`},"team.updated":{success:`ai-gateway-update-team-success`,failed:`ai-gateway-update-team-failed`}},Ytt=(e,t)=>{let n=Jtt[e];return t===`succeeded`?n.success:n.failed},CY=()=>{let{captureRaw:e}=on(),t=(0,H.useContext)(mp)?.project,n=t?KE(t):!1,r=t?qtt(t.accountName,t.name):void 0;return(0,H.useCallback)((t,i,a={})=>{n&&e(Ytt(t,i),{...a,...r?{$groups:{project:r}}:{}})},[e,n,r])};function wY(e){let{account:t,project:n}=lb([`account`,`project`]),r=fb(mt.project(t,n),{extractData:!1}).data.defaultConfiguration.find(e=>e.environmentType===GM.PRODUCTION)?.apiKeyBucket??void 0;if(!r&&!e?.optional)throw Error(`No production bucket found`);return r}var TY=()=>wY(),Xtt=()=>{let{account:e,project:t}=lb([`account`,`project`]);return fb(mt.aiProviderAssignments(e,t))};function EY({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:W(`group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none`,`h-9 min-w-0 has-[>textarea]:h-auto`,`has-[>[data-align=inline-start]]:[&>input]:pl-2`,`has-[>[data-align=inline-end]]:[&>input]:pr-2`,`has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3`,`has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3`,`has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]`,`has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40`,e),...t})}var Ztt=Ou(`text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50`,{variants:{align:{"inline-start":`order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]`,"inline-end":`order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]`,"block-start":`order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5`,"block-end":`order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5`}},defaultVariants:{align:`inline-start`}});function DY({className:e,align:t=`inline-start`,...n}){return(0,U.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:W(Ztt({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}var Qtt=Ou(`text-sm shadow-none flex gap-2 items-center`,{variants:{size:{xs:`h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2`,sm:`h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5`,"icon-xs":`size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function OY({className:e,type:t=`button`,variant:n=`ghost`,size:r=`xs`,...i}){return(0,U.jsx)(X,{type:t,"data-size":r,variant:n,className:W(Qtt({size:r}),e),...i})}function kY({className:e,...t}){return(0,U.jsx)(iM,{"data-slot":`input-group-control`,className:W(`flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent`,e),...t})}var AY=a((e=>{e.__esModule=!0,e.default=i;var t=/[\u0300-\u036f]/g,n=/ł/g,r=/ñ/g;function i(e){return e.toLowerCase().normalize(`NFD`).replace(t,``).replace(n,`l`).replace(r,`n`).trim()}})),jY=a((e=>{e.__esModule=!0,e.aggressiveFuzzyMatch=l,e.createFuzzySearchImpl=p,e.experimentalSmartFuzzyMatch=u,e.fuzzyMatchImpl=f;var t=n(AY());function n(e){return e&&e.__esModule?e:{default:e}}var r=2**53-1,i=function(e,t){return e.score-t.score},a=function(e,t){return e[0]-t[0]},o=new Set(` \xA0[]()-–—'"“”`.split(``));function s(e){return o.has(e)}function c(e,t,n,r,i,o,c){if(e===r)return[0,[[0,e.length-1]]];var d=r.length,f=t.length,p=i.length;if(t===i)return[.1,[[0,f-1]]];if(t.startsWith(i))return[.5,[[0,p-1]]];var m=e.indexOf(r);if(m>-1&&s(e[m-1]))return[.9,[[m,m+d-1]]];var h=t.indexOf(i);if(h>-1&&s(t[h-1]))return[1,[[h,h+d-1]]];var g=o.length;return g>1&&o.every(function(e){return n.has(e)})?[1.5+g*.2,o.map(function(e){var n=t.indexOf(e);return[n,n+e.length-1]}).sort(a)]:h>-1?[2,[[h,h+d-1]]]:c===`aggressive`?l(t,i):c===`smart`?u(t,i):null}function l(e,t){for(var n=e.length,r=t.length,i=0,a=t[i],o=[],s=-1,c=-2,l=0;l<n;l+=1)if(e[l]===a){if(l!==c+1&&(s>=0&&o.push([s,c]),s=l),c=l,i+=1,i===r)return o.push([s,c]),d(o,e);a=t[i]}return null}function u(e,t){for(var n=e.length,r=[],i=0,a=t[i],o=-1,c=-2;;){var l=e.indexOf(a,c+1);if(l===-1)break;if(l===0||s(e[l-1]))o=l;else{var u=t.length-i,f=e.length-l,p=Math.min(3,u,f),m=t.slice(i,i+p);if(e.slice(l,l+p)===m)o=l;else{c+=1;continue}}for(c=o;c<n&&e[c]===a;c+=1)i+=1,a=t[i];if(--c,r.push([o,c]),i===t.length)return d(r,e)}return null}function d(e,t){var n=2;return e.forEach(function(e){var r=e[0],i=e[1],a=i-r+1,o=r===0||t[r]===` `||t[r-1]===` `,s=i===t.length-1||t[i]===` `||t[i+1]===` `;o&&s?n+=.2:o?n+=.4:a>=3?n+=.8:n+=1.6}),[n,e]}function f(e,n){var r=(0,t.default)(n),i=r.split(` `),a=(0,t.default)(e),o=c(e,a,new Set(a.split(` `)),n,r,i,`smart`);return o?{item:e,score:o[0],matches:[o[1]]}:null}function p(e,n){var a=n.strategy,o=a===void 0?`aggressive`:a,s=n.getText,l=e.map(function(e){return[e,(s?s(e):[n.key?e[n.key]:e]).map(function(e){var n=e||``,r=(0,t.default)(n);return[n,r,new Set(r.split(` `))]})]});return function(e){var n=[],a=(0,t.default)(e),s=a.split(` `);return a.length?(l.forEach(function(t){for(var i=t[0],l=t[1],u=r,d=[],f=0,p=l.length;f<p;f+=1){var m=l[f],h=m[0],g=m[1],_=m[2],v=c(h,g,_,e,a,s,o);v?(u=Math.min(u,v[0]),d.push(v[1])):d.push(null)}u<r&&n.push({item:i,score:u,matches:d})}),n.sort(i),n):[]}}})),MY=r(a((e=>{e.__esModule=!0,e.default=n,e.fuzzyMatch=r,e.normalizeText=t(AY()).default;function t(e){return e&&e.__esModule?e:{default:e}}function n(e,t){return t===void 0&&(t={}),jY().createFuzzySearchImpl(e,t)}function r(e,t){return jY().fuzzyMatchImpl(e,t)}}))()),$tt=typeof MY.default==`object`&&MY.default!==null&&MY.__esModule?MY.default.default:MY.default,NY=(e,t,{getText:n,key:r})=>{let i=ub(n),a=(0,H.useMemo)(()=>$tt([...t],{key:r,getText:i.current}),[t,r,i]),o=(0,H.useMemo)(()=>e?a(e).map(({item:e})=>e):t,[e,a,t]);return e?o:t},PY=()=>{let e=wY();return fb(mt.supportedAiProviders(e),{extractData:!1})},FY=1e6,IY=1e-4,LY=e=>new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:e}),RY=e=>e*FY,ent=e=>e/FY,tnt=e=>typeof e!=`number`||!Number.isFinite(e)||e<=0?``:String(Number(RY(e).toPrecision(12))),nnt=e=>{if(typeof e!=`number`||!Number.isFinite(e)||e<0)return;if(e===0)return`Free`;let t=RY(e);return t<IY?`< ${LY(4).format(IY)}`:LY(t<1?4:2).format(t)},rnt=0,int=1,ant=2,ont=3,zY=/-(\d{4})-?(\d{2})-?(\d{2})$/,BY=99;function VY(e,t){return e+t/1e3}function snt(e){let t=e.replace(zY,``),n=t.match(/(?:^|[^\d])(\d+)\.(\d+)/);if(n){let e=Number(n[1]);return e<=BY?VY(e,Number(n[2])):null}if(/(?:^|[^\d])4o(?:$|[^\d])/.test(t))return 4;let r=t.match(/-(\d+)-(\d{1,2})(?:$|-)/);if(r&&Number(r[1])<=BY)return VY(Number(r[1]),Number(r[2]));let i=t.match(/(?:^|[^\d.])(\d+)(?=$|[^\d.bx])/i);if(i){let e=Number(i[1]);if(e<=BY)return e}return null}function cnt(e){return/\bnano\b/.test(e)?ant:/\bmini\b/.test(e)?int:/-(pro|codex|turbo|chat|sol|luna|opus|sonnet|haiku|latest)\b/.test(e)?ont:rnt}function HY(e){let t=snt(e),n=e.match(zY),r=n?Number(`${n[1]}${n[2]}${n[3]}`):0;return{generation:t??-1/0,isLatest:/-latest$/.test(e)?0:1,isSnapshot:r>0?1:0,tier:cnt(e),snapshotDate:r}}function UY(e,t){let n=HY(e),r=HY(t);return n.generation===r.generation?n.generation===-1/0&&r.generation===-1/0&&n.isLatest!==r.isLatest?n.isLatest-r.isLatest:n.tier===r.tier?n.isSnapshot===r.isSnapshot?n.snapshotDate===r.snapshotDate?e.localeCompare(t):r.snapshotDate-n.snapshotDate:n.isSnapshot-r.isSnapshot:n.tier-r.tier:r.generation-n.generation}function WY(e){return[...e].sort(UY)}var lnt=Rm({request:Pm().trim().min(1,`Tell us which provider or model you need`),details:Pm().optional()}),unt=`ai-gateway-request-provider-or-model-submitted`,GY=({children:e,defaultRequest:t,provider:n,source:r})=>{let[i,a]=(0,H.useState)(!1);return(0,U.jsxs)(tb,{open:i,onOpenChange:a,children:[(0,U.jsx)(nb,{asChild:!0,children:e}),(0,U.jsx)(ib,{className:`sm:max-w-md`,children:(0,U.jsx)(dnt,{defaultRequest:t,provider:n,source:r,onClose:()=>a(!1)})})]})},dnt=({defaultRequest:e,provider:t,source:n,onClose:r})=>{let[i,a]=(0,H.useState)(!1),{account:o,project:s}=lb([`account`,`project`]),{logEvent:c}=on(),l=qD({defaultValues:{request:e?.trim()??``,details:``},resolver:JD(lnt)});(0,H.useEffect)(()=>{let e=e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&e.stopPropagation()};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},[]);let u=l.handleSubmit(e=>{let r=e.details?.trim()||void 0;c(unt,{account:o,project:s,source:n,request:e.request.trim(),provider:t?.trim(),details:r,hasDetails:!!r}),a(!0)});return i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Request sent`}),(0,U.jsx)(cb,{children:`Thanks — we read these when deciding which providers and models to add next.`})]}),(0,U.jsx)(ob,{children:(0,U.jsx)(X,{onClick:r,children:`Done`})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Request a provider or model`}),(0,U.jsx)(cb,{children:`Don’t see the provider or model you need? Tell us which one and we’ll look into adding it.`})]}),(0,U.jsx)(fY,{...l,children:(0,U.jsxs)(`form`,{onSubmit:u,className:`space-y-4`,children:[(0,U.jsx)(mY,{control:l.control,name:`request`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Provider or model`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`e.g. Cohere, or gpt-5.1 on OpenAI`,autoFocus:!0,...e})}),(0,U.jsx)(xY,{})]})}),(0,U.jsx)(mY,{control:l.control,name:`details`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Additional details (optional)`}),(0,U.jsx)(yY,{children:(0,U.jsx)(xw,{rows:3,placeholder:`How you'd use it, links, pricing tier, etc.`,...e})}),(0,U.jsx)(xY,{})]})}),(0,U.jsxs)(ob,{children:[(0,U.jsx)(X,{type:`button`,variant:`ghost`,onClick:r,children:`Cancel`}),(0,U.jsx)(X,{type:`submit`,children:`Send request`})]})]})})]})},KY=`sticky top-0 z-10 -mx-1 space-y-2 bg-background px-1 pb-2`;function qY({form:e,mode:t,providerDisabled:n,onProviderChange:r,allowCustomModelEditing:i=!0}){let{data:a,providers:o}=PY().data,s=YE(cY()),c=e.watch(`provider`),l=Object.keys(a).filter(e=>!o[e]?.isCustom&&(s||e!==`ZuploDemo`)),u=c===`ZuploDemo`&&!o[c]?.isCustom;(0,H.useEffect)(()=>{let t=o[c]?.isCustom;e.setValue(`customProviderName`,t?c:void 0)},[c,o,e]),(0,H.useEffect)(()=>{u&&e.setValue(`apiKey`,``)},[u,e]);let d=c===`__custom`||o[c]?.isCustom===!0,f=c===eje,p=c===ije;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(mY,{control:e.control,name:`provider`,render:({field:t})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`AI Provider`}),(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsxs)(mJ,{onValueChange:e=>{t.onChange(e),r?.(e)},value:t.value,disabled:n,children:[(0,U.jsx)(yY,{children:(0,U.jsx)(_J,{className:`w-full`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(gJ,{placeholder:`Choose AI provider…`}),e.watch(`customProviderName`)&&(0,U.jsx)(XD,{variant:`invert`,children:`custom`})]})})}),(0,U.jsxs)(vJ,{className:`max-h-[325px] overflow-y-auto`,children:[l.length>0&&(0,U.jsxs)(hJ,{children:[(0,U.jsx)(yJ,{children:`Default Providers`}),l.map(e=>(0,U.jsx)(bJ,{value:e,children:o[e]?.label||e},e))]}),(0,U.jsxs)(hJ,{children:[(0,U.jsx)(yJ,{children:`Custom Providers`}),o[c]?.isCustom&&(0,U.jsx)(bJ,{value:c,children:o[c]?.label||c}),(0,U.jsx)(bJ,{value:qE,children:`Custom`})]})]})]})}),(0,U.jsx)(xY,{}),(0,U.jsx)(JY,{label:`Missing a provider?`,source:`provider-picker`})]})}),u&&(0,U.jsxs)(Vy,{variant:`warning`,children:[(0,U.jsx)(Jf,{}),(0,U.jsx)(Hy,{children:`Not for production use`}),(0,U.jsx)(Uy,{children:`Zuplo Demo is a free demo provider operated by Zuplo with daily per-account limits. Do not use it for production workloads.`})]}),(0,U.jsx)(mY,{control:e.control,name:`label`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Provider Name`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`e.g. production-openai`,maxLength:64,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,readOnly:t===`edit`,...e})}),(0,U.jsx)(xY,{})]})}),!f&&!p&&(0,U.jsx)(mY,{control:e.control,name:`baseUrl`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`API URL`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:o[c]?.baseUrl??`https://api.example.com`,...e,value:e.value??``,disabled:!d||t===`edit`})}),d&&t!==`edit`&&(0,U.jsx)(bY,{className:`text-xs`,children:`The base URL only — the gateway appends /v1/chat/completions itself. Use https://api.example.com, not https://api.example.com/v1.`}),(0,U.jsx)(xY,{})]})}),f&&(0,U.jsx)(mY,{control:e.control,name:`region`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`AWS Region`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`us-east-1`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,...e,value:e.value??``})}),(0,U.jsx)(bY,{className:`text-xs`,children:`The region Bedrock serves your account from; requests go to bedrock-mantle.<region>.api.aws.`}),(0,U.jsx)(xY,{})]})}),p&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(mY,{control:e.control,name:`region`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Location`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`us-central1`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,...e,value:e.value??``})}),(0,U.jsxs)(bY,{className:`text-xs`,children:[`The Vertex AI location to call; requests go to <location>-aiplatform.googleapis.com. Use`,` `,(0,U.jsx)(`span`,{className:`font-mono`,children:`global`}),` for the global endpoint.`]}),(0,U.jsx)(xY,{})]})}),(0,U.jsx)(mY,{control:e.control,name:`gcpProjectId`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Google Cloud Project ID`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`my-project-123`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,...e,value:e.value??``})}),(0,U.jsx)(bY,{className:`text-xs`,children:`The project with the Vertex AI API enabled. This is the project ID, not the project number.`}),(0,U.jsx)(xY,{})]})})]}),!u&&(0,U.jsx)(mY,{control:e.control,name:`apiKey`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:p?`Service Account Key (JSON)`:`API Key`}),(0,U.jsx)(yY,{children:p?(0,U.jsx)(xw,{placeholder:t===`edit`?`Leave blank to keep the existing service account key`:`{ "type": "service_account", "project_id": "…", "private_key": "…" }`,rows:5,className:`font-mono text-xs`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,...e,value:e.value??``}):(0,U.jsx)(iM,{placeholder:t===`edit`?`Leave blank to keep existing API key`:f?`Enter your long-term Bedrock API key (starts with ABSK)`:`Enter your API Key for this provider`,type:`password`,...e})}),p&&(0,U.jsx)(bY,{className:`text-xs`,children:`Paste the whole JSON key file from the Google Cloud console (IAM & Admin > Service Accounts > Keys). The service account needs the Vertex AI User role on the project.`}),(0,U.jsx)(xY,{})]})}),d&&i?(0,U.jsx)(fnt,{}):(0,U.jsx)(pnt,{modelsData:a,provider:c})]})}var JY=({label:e,defaultRequest:t,provider:n,source:r})=>(0,U.jsx)(GY,{defaultRequest:t,provider:n,source:r,children:(0,U.jsx)(X,{type:`button`,variant:`link`,size:`sm`,className:`h-auto px-0 text-muted-foreground`,children:e})}),YY=({children:e})=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,U.jsx)(`div`,{className:`text-xl font-medium`,children:`Available Models`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`prices per 1M tokens`})]}),e]}),XY=({trailing:e})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(dY,{className:`text-muted-foreground`,children:`Model`}),(0,U.jsx)(dY,{className:`justify-end text-muted-foreground`,children:`Input / 1M`}),(0,U.jsx)(dY,{className:`justify-end text-muted-foreground`,children:`Output / 1M`}),e]}),ZY=({costPerToken:e})=>{let t=nnt(e);return(0,U.jsx)(`div`,{className:W(`text-right text-sm tabular-nums`,t?`text-muted-foreground`:`text-muted-foreground/50`),children:t??`—`})},QY=({name:e,label:t})=>(0,U.jsx)(mY,{control:pD().control,name:e,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(yY,{children:(0,U.jsxs)(EY,{children:[(0,U.jsx)(DY,{align:`inline-start`,children:`$`}),(0,U.jsx)(kY,{type:`number`,step:`any`,min:0,placeholder:`0.00`,"aria-label":t,hideNumberArrows:!0,selectOnFocus:!0,name:e.name,ref:e.ref,onBlur:e.onBlur,defaultValue:tnt(e.value),onChange:t=>e.onChange(ent(Number.parseFloat(t.target.value)||0))}),(0,U.jsx)(DY,{align:`inline-end`,className:`text-muted-foreground/70`,children:`/1M`})]})}),(0,U.jsx)(xY,{})]})}),fnt=()=>{let e=pD(),{fields:t,append:n,remove:r}=WMe({control:e.control,name:`customModels`}),i=t=>!!e.getValues(`customModels.${t}.modelId`);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:KY,children:[(0,U.jsx)(YY,{children:(0,U.jsxs)(X,{type:`button`,variant:`outline`,onClick:()=>{n({name:``,status:`active`,kind:`completions`,inputCostPerToken:0,outputCostPerToken:0})},children:[(0,U.jsx)(Sf,{size:16}),`Add Model`]})}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Custom providers serve chat completions and embeddings only.`}),(0,U.jsx)(mY,{name:`customModels`,control:e.control,render:()=>(0,U.jsx)(xY,{})})]}),(0,U.jsx)(`div`,{className:W(`border rounded-md`,e.formState.errors.customModels&&`border-destructive`),children:t.length===0?(0,U.jsxs)(Gy,{children:[(0,U.jsx)(Jy,{children:`No models added yet`}),(0,U.jsx)(Yy,{children:`Add a model to get started.`})]}):(0,U.jsxs)(`div`,{className:`grid grid-cols-[minmax(8rem,1fr)_8rem_8rem_9.5rem_auto] items-start gap-2 p-4`,children:[(0,U.jsx)(XY,{trailing:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(dY,{className:`text-muted-foreground`,children:`Type`}),(0,U.jsx)(`span`,{})]})}),t.map((t,n)=>(0,U.jsxs)(`div`,{className:`grid grid-cols-subgrid col-span-full items-start gap-2`,children:[(0,U.jsx)(mY,{control:e.control,name:`customModels.${n}.name`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`Model Name`,"aria-label":`Model name`,className:`font-mono`,readOnly:i(n),...e})}),(0,U.jsx)(xY,{})]})}),(0,U.jsx)(QY,{name:`customModels.${n}.inputCostPerToken`,label:`Input cost per million tokens`}),(0,U.jsx)(QY,{name:`customModels.${n}.outputCostPerToken`,label:`Output cost per million tokens`}),(0,U.jsx)(mY,{control:e.control,name:`customModels.${n}.kind`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(yY,{children:(0,U.jsxs)(mJ,{defaultValue:`completions`,onValueChange:e.onChange,value:e.value,disabled:i(n),children:[(0,U.jsx)(_J,{className:`mb-0 w-full`,"aria-label":`Model type`,children:(0,U.jsx)(gJ,{placeholder:`Select Model Type`})}),(0,U.jsxs)(vJ,{children:[(0,U.jsx)(bJ,{value:`completions`,children:`Chat`}),(0,U.jsx)(bJ,{value:`embeddings`,children:`Embeddings`})]})]})}),(0,U.jsx)(xY,{})]})}),(0,U.jsx)(`div`,{className:`flex justify-center items-center size-full max-h-9`,children:(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Remove model`,onClick:()=>{r(n)},children:(0,U.jsx)(ep,{className:`h-4 w-4`})})})]},t.id))]})})]})},pnt=({modelsData:e,provider:t})=>{let n=pD(),[r,i]=(0,H.useState)(``),[a,o]=(0,H.useState)(`all`),s=NY(r,[...e[t]??[]].sort((e,t)=>UY(e.model,t.model)).filter(({kind:e})=>a===`all`?!0:e===a),{getText:({model:e,kind:t})=>[e,t]}),c=n.watch(`models`);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:W(KY,`pt-2`),children:[(0,U.jsx)(YY,{children:(0,U.jsx)(X,{type:`button`,variant:`link`,onClick:()=>{n.setValue(`models`,{completions:WY(e[t]?.filter(({kind:e})=>e===`completions`).map(({model:e})=>e)??[]),embeddings:WY(e[t]?.filter(({kind:e})=>e===`embeddings`).map(({model:e})=>e)??[])})},children:`Select All`})}),(0,U.jsxs)(`div`,{className:`flex justify-stretch gap-2`,children:[(0,U.jsx)(FJ,{onClearValue:()=>i(``),className:`w-8/12`,showClearButton:r.length>0,children:(0,U.jsx)(iM,{placeholder:`Search Models`,className:`px-8`,value:r,onChange:e=>i(e.target.value)})}),(0,U.jsxs)(mJ,{onValueChange:e=>{o(e)},children:[(0,U.jsx)(_J,{className:`w-4/12`,"aria-label":`Filter by model type`,children:(0,U.jsx)(gJ,{placeholder:`All Types`})}),(0,U.jsxs)(vJ,{children:[(0,U.jsx)(bJ,{value:`all`,children:`All Types`}),(0,U.jsx)(bJ,{value:`completions`,children:`Chat`}),(0,U.jsx)(bJ,{value:`embeddings`,children:`Embeddings`})]})]})]})]}),(0,U.jsx)(`div`,{className:`border rounded-md p-4`,children:s?.length===0?(0,U.jsxs)(Gy,{children:[(0,U.jsx)(Jy,{children:`No models match your search`}),(0,U.jsx)(Yy,{children:`Try a different name or model type.`}),(0,U.jsx)(Xy,{children:(0,U.jsx)(GY,{defaultRequest:r,provider:t,source:`model-search-empty`,children:(0,U.jsxs)(X,{type:`button`,variant:`outline`,size:`sm`,children:[(0,U.jsx)(pf,{size:16}),`Request a model`]})})})]}):(0,U.jsxs)(`div`,{className:`grid grid-cols-[min-content_1fr_6rem_6rem_max-content] items-center gap-x-3 gap-y-2`,children:[(0,U.jsx)(`span`,{}),(0,U.jsx)(XY,{trailing:(0,U.jsx)(`span`,{})}),s?.map(({kind:e,model:t,inputCostPerToken:r,outputCostPerToken:i})=>(0,U.jsxs)(`label`,{className:`grid grid-cols-subgrid col-span-full items-center`,children:[(0,U.jsx)(YJ,{checked:c?.[e]?.includes(t),onCheckedChange:r=>{n.setValue(`models`,{...c,[e]:r?[...c?.[e]??[],t]:(c?.[e]??[]).filter(e=>e!==t)})}}),(0,U.jsx)(`div`,{className:`truncate font-mono text-sm`,title:t,children:t}),(0,U.jsx)(ZY,{costPerToken:r}),(0,U.jsx)(ZY,{costPerToken:e===`embeddings`?void 0:i}),(0,U.jsx)(XD,{variant:`outline`,children:e===`completions`?`Chat`:`Embeddings`})]},t))]})}),s?.length!==0&&(0,U.jsx)(JY,{label:`Missing a model?`,defaultRequest:r,provider:t,source:`model-list`})]})},mnt=[[`ß`,`ss`],[`ẞ`,`Ss`],[`ä`,`ae`],[`Ä`,`Ae`],[`ö`,`oe`],[`Ö`,`Oe`],[`ü`,`ue`],[`Ü`,`Ue`],[`À`,`A`],[`Á`,`A`],[`Â`,`A`],[`Ã`,`A`],[`Ä`,`Ae`],[`Å`,`A`],[`Æ`,`AE`],[`Ç`,`C`],[`È`,`E`],[`É`,`E`],[`Ê`,`E`],[`Ë`,`E`],[`Ì`,`I`],[`Í`,`I`],[`Î`,`I`],[`Ï`,`I`],[`Ð`,`D`],[`Ñ`,`N`],[`Ò`,`O`],[`Ó`,`O`],[`Ô`,`O`],[`Õ`,`O`],[`Ö`,`Oe`],[`Ő`,`O`],[`Ø`,`O`],[`Ù`,`U`],[`Ú`,`U`],[`Û`,`U`],[`Ü`,`Ue`],[`Ű`,`U`],[`Ý`,`Y`],[`Þ`,`TH`],[`ß`,`ss`],[`à`,`a`],[`á`,`a`],[`â`,`a`],[`ã`,`a`],[`ä`,`ae`],[`å`,`a`],[`æ`,`ae`],[`ç`,`c`],[`è`,`e`],[`é`,`e`],[`ê`,`e`],[`ë`,`e`],[`ì`,`i`],[`í`,`i`],[`î`,`i`],[`ï`,`i`],[`ð`,`d`],[`ñ`,`n`],[`ò`,`o`],[`ó`,`o`],[`ô`,`o`],[`õ`,`o`],[`ö`,`oe`],[`ő`,`o`],[`ø`,`o`],[`ù`,`u`],[`ú`,`u`],[`û`,`u`],[`ü`,`ue`],[`ű`,`u`],[`ý`,`y`],[`þ`,`th`],[`ÿ`,`y`],[`ẞ`,`SS`],[`à`,`a`],[`À`,`A`],[`á`,`a`],[`Á`,`A`],[`â`,`a`],[`Â`,`A`],[`ã`,`a`],[`Ã`,`A`],[`è`,`e`],[`È`,`E`],[`é`,`e`],[`É`,`E`],[`ê`,`e`],[`Ê`,`E`],[`ì`,`i`],[`Ì`,`I`],[`í`,`i`],[`Í`,`I`],[`ò`,`o`],[`Ò`,`O`],[`ó`,`o`],[`Ó`,`O`],[`ô`,`o`],[`Ô`,`O`],[`õ`,`o`],[`Õ`,`O`],[`ù`,`u`],[`Ù`,`U`],[`ú`,`u`],[`Ú`,`U`],[`ý`,`y`],[`Ý`,`Y`],[`ă`,`a`],[`Ă`,`A`],[`Đ`,`D`],[`đ`,`d`],[`ĩ`,`i`],[`Ĩ`,`I`],[`ũ`,`u`],[`Ũ`,`U`],[`ơ`,`o`],[`Ơ`,`O`],[`ư`,`u`],[`Ư`,`U`],[`ạ`,`a`],[`Ạ`,`A`],[`ả`,`a`],[`Ả`,`A`],[`ấ`,`a`],[`Ấ`,`A`],[`ầ`,`a`],[`Ầ`,`A`],[`ẩ`,`a`],[`Ẩ`,`A`],[`ẫ`,`a`],[`Ẫ`,`A`],[`ậ`,`a`],[`Ậ`,`A`],[`ắ`,`a`],[`Ắ`,`A`],[`ằ`,`a`],[`Ằ`,`A`],[`ẳ`,`a`],[`Ẳ`,`A`],[`ẵ`,`a`],[`Ẵ`,`A`],[`ặ`,`a`],[`Ặ`,`A`],[`ẹ`,`e`],[`Ẹ`,`E`],[`ẻ`,`e`],[`Ẻ`,`E`],[`ẽ`,`e`],[`Ẽ`,`E`],[`ế`,`e`],[`Ế`,`E`],[`ề`,`e`],[`Ề`,`E`],[`ể`,`e`],[`Ể`,`E`],[`ễ`,`e`],[`Ễ`,`E`],[`ệ`,`e`],[`Ệ`,`E`],[`ỉ`,`i`],[`Ỉ`,`I`],[`ị`,`i`],[`Ị`,`I`],[`ọ`,`o`],[`Ọ`,`O`],[`ỏ`,`o`],[`Ỏ`,`O`],[`ố`,`o`],[`Ố`,`O`],[`ồ`,`o`],[`Ồ`,`O`],[`ổ`,`o`],[`Ổ`,`O`],[`ỗ`,`o`],[`Ỗ`,`O`],[`ộ`,`o`],[`Ộ`,`O`],[`ớ`,`o`],[`Ớ`,`O`],[`ờ`,`o`],[`Ờ`,`O`],[`ở`,`o`],[`Ở`,`O`],[`ỡ`,`o`],[`Ỡ`,`O`],[`ợ`,`o`],[`Ợ`,`O`],[`ụ`,`u`],[`Ụ`,`U`],[`ủ`,`u`],[`Ủ`,`U`],[`ứ`,`u`],[`Ứ`,`U`],[`ừ`,`u`],[`Ừ`,`U`],[`ử`,`u`],[`Ử`,`U`],[`ữ`,`u`],[`Ữ`,`U`],[`ự`,`u`],[`Ự`,`U`],[`ỳ`,`y`],[`Ỳ`,`Y`],[`ỵ`,`y`],[`Ỵ`,`Y`],[`ỷ`,`y`],[`Ỷ`,`Y`],[`ỹ`,`y`],[`Ỹ`,`Y`],[`ء`,`e`],[`آ`,`a`],[`أ`,`a`],[`ؤ`,`w`],[`إ`,`i`],[`ئ`,`y`],[`ا`,`a`],[`ب`,`b`],[`ة`,`t`],[`ت`,`t`],[`ث`,`th`],[`ج`,`j`],[`ح`,`h`],[`خ`,`kh`],[`د`,`d`],[`ذ`,`dh`],[`ر`,`r`],[`ز`,`z`],[`س`,`s`],[`ش`,`sh`],[`ص`,`s`],[`ض`,`d`],[`ط`,`t`],[`ظ`,`z`],[`ع`,`e`],[`غ`,`gh`],[`ـ`,`_`],[`ف`,`f`],[`ق`,`q`],[`ك`,`k`],[`ل`,`l`],[`م`,`m`],[`ن`,`n`],[`ه`,`h`],[`و`,`w`],[`ى`,`a`],[`ي`,`y`],[`َ‎`,`a`],[`ُ`,`u`],[`ِ‎`,`i`],[`٠`,`0`],[`١`,`1`],[`٢`,`2`],[`٣`,`3`],[`٤`,`4`],[`٥`,`5`],[`٦`,`6`],[`٧`,`7`],[`٨`,`8`],[`٩`,`9`],[`چ`,`ch`],[`ک`,`k`],[`گ`,`g`],[`پ`,`p`],[`ژ`,`zh`],[`ی`,`y`],[`۰`,`0`],[`۱`,`1`],[`۲`,`2`],[`۳`,`3`],[`۴`,`4`],[`۵`,`5`],[`۶`,`6`],[`۷`,`7`],[`۸`,`8`],[`۹`,`9`],[`ټ`,`p`],[`ځ`,`z`],[`څ`,`c`],[`ډ`,`d`],[`ﺫ`,`d`],[`ﺭ`,`r`],[`ړ`,`r`],[`ﺯ`,`z`],[`ږ`,`g`],[`ښ`,`x`],[`ګ`,`g`],[`ڼ`,`n`],[`ۀ`,`e`],[`ې`,`e`],[`ۍ`,`ai`],[`ٹ`,`t`],[`ڈ`,`d`],[`ڑ`,`r`],[`ں`,`n`],[`ہ`,`h`],[`ھ`,`h`],[`ے`,`e`],[`А`,`A`],[`а`,`a`],[`Б`,`B`],[`б`,`b`],[`В`,`V`],[`в`,`v`],[`Г`,`G`],[`г`,`g`],[`Д`,`D`],[`д`,`d`],[`ъе`,`ye`],[`Ъе`,`Ye`],[`ъЕ`,`yE`],[`ЪЕ`,`YE`],[`Е`,`E`],[`е`,`e`],[`Ё`,`Yo`],[`ё`,`yo`],[`Ж`,`Zh`],[`ж`,`zh`],[`З`,`Z`],[`з`,`z`],[`И`,`I`],[`и`,`i`],[`ый`,`iy`],[`Ый`,`Iy`],[`ЫЙ`,`IY`],[`ыЙ`,`iY`],[`Й`,`Y`],[`й`,`y`],[`К`,`K`],[`к`,`k`],[`Л`,`L`],[`л`,`l`],[`М`,`M`],[`м`,`m`],[`Н`,`N`],[`н`,`n`],[`О`,`O`],[`о`,`o`],[`П`,`P`],[`п`,`p`],[`Р`,`R`],[`р`,`r`],[`С`,`S`],[`с`,`s`],[`Т`,`T`],[`т`,`t`],[`У`,`U`],[`у`,`u`],[`Ф`,`F`],[`ф`,`f`],[`Х`,`Kh`],[`х`,`kh`],[`Ц`,`Ts`],[`ц`,`ts`],[`Ч`,`Ch`],[`ч`,`ch`],[`Ш`,`Sh`],[`ш`,`sh`],[`Щ`,`Sch`],[`щ`,`sch`],[`Ъ`,``],[`ъ`,``],[`Ы`,`Y`],[`ы`,`y`],[`Ь`,``],[`ь`,``],[`Э`,`E`],[`э`,`e`],[`Ю`,`Yu`],[`ю`,`yu`],[`Я`,`Ya`],[`я`,`ya`],[`ă`,`a`],[`Ă`,`A`],[`ș`,`s`],[`Ș`,`S`],[`ț`,`t`],[`Ț`,`T`],[`ţ`,`t`],[`Ţ`,`T`],[`ş`,`s`],[`Ş`,`S`],[`ç`,`c`],[`Ç`,`C`],[`ğ`,`g`],[`Ğ`,`G`],[`ı`,`i`],[`İ`,`I`],[`ա`,`a`],[`Ա`,`A`],[`բ`,`b`],[`Բ`,`B`],[`գ`,`g`],[`Գ`,`G`],[`դ`,`d`],[`Դ`,`D`],[`ե`,`ye`],[`Ե`,`Ye`],[`զ`,`z`],[`Զ`,`Z`],[`է`,`e`],[`Է`,`E`],[`ը`,`y`],[`Ը`,`Y`],[`թ`,`t`],[`Թ`,`T`],[`ժ`,`zh`],[`Ժ`,`Zh`],[`ի`,`i`],[`Ի`,`I`],[`լ`,`l`],[`Լ`,`L`],[`խ`,`kh`],[`Խ`,`Kh`],[`ծ`,`ts`],[`Ծ`,`Ts`],[`կ`,`k`],[`Կ`,`K`],[`հ`,`h`],[`Հ`,`H`],[`ձ`,`dz`],[`Ձ`,`Dz`],[`ղ`,`gh`],[`Ղ`,`Gh`],[`ճ`,`tch`],[`Ճ`,`Tch`],[`մ`,`m`],[`Մ`,`M`],[`յ`,`y`],[`Յ`,`Y`],[`ն`,`n`],[`Ն`,`N`],[`շ`,`sh`],[`Շ`,`Sh`],[`ո`,`vo`],[`Ո`,`Vo`],[`չ`,`ch`],[`Չ`,`Ch`],[`պ`,`p`],[`Պ`,`P`],[`ջ`,`j`],[`Ջ`,`J`],[`ռ`,`r`],[`Ռ`,`R`],[`ս`,`s`],[`Ս`,`S`],[`վ`,`v`],[`Վ`,`V`],[`տ`,`t`],[`Տ`,`T`],[`ր`,`r`],[`Ր`,`R`],[`ց`,`c`],[`Ց`,`C`],[`ու`,`u`],[`ՈՒ`,`U`],[`Ու`,`U`],[`փ`,`p`],[`Փ`,`P`],[`ք`,`q`],[`Ք`,`Q`],[`օ`,`o`],[`Օ`,`O`],[`ֆ`,`f`],[`Ֆ`,`F`],[`և`,`yev`],[`ა`,`a`],[`ბ`,`b`],[`გ`,`g`],[`დ`,`d`],[`ე`,`e`],[`ვ`,`v`],[`ზ`,`z`],[`თ`,`t`],[`ი`,`i`],[`კ`,`k`],[`ლ`,`l`],[`მ`,`m`],[`ნ`,`n`],[`ო`,`o`],[`პ`,`p`],[`ჟ`,`zh`],[`რ`,`r`],[`ს`,`s`],[`ტ`,`t`],[`უ`,`u`],[`ფ`,`ph`],[`ქ`,`q`],[`ღ`,`gh`],[`ყ`,`k`],[`შ`,`sh`],[`ჩ`,`ch`],[`ც`,`ts`],[`ძ`,`dz`],[`წ`,`ts`],[`ჭ`,`tch`],[`ხ`,`kh`],[`ჯ`,`j`],[`ჰ`,`h`],[`č`,`c`],[`ď`,`d`],[`ě`,`e`],[`ň`,`n`],[`ř`,`r`],[`š`,`s`],[`ť`,`t`],[`ů`,`u`],[`ž`,`z`],[`Č`,`C`],[`Ď`,`D`],[`Ě`,`E`],[`Ň`,`N`],[`Ř`,`R`],[`Š`,`S`],[`Ť`,`T`],[`Ů`,`U`],[`Ž`,`Z`],[`ހ`,`h`],[`ށ`,`sh`],[`ނ`,`n`],[`ރ`,`r`],[`ބ`,`b`],[`ޅ`,`lh`],[`ކ`,`k`],[`އ`,`a`],[`ވ`,`v`],[`މ`,`m`],[`ފ`,`f`],[`ދ`,`dh`],[`ތ`,`th`],[`ލ`,`l`],[`ގ`,`g`],[`ޏ`,`gn`],[`ސ`,`s`],[`ޑ`,`d`],[`ޒ`,`z`],[`ޓ`,`t`],[`ޔ`,`y`],[`ޕ`,`p`],[`ޖ`,`j`],[`ޗ`,`ch`],[`ޘ`,`tt`],[`ޙ`,`hh`],[`ޚ`,`kh`],[`ޛ`,`th`],[`ޜ`,`z`],[`ޝ`,`sh`],[`ޞ`,`s`],[`ޟ`,`d`],[`ޠ`,`t`],[`ޡ`,`z`],[`ޢ`,`a`],[`ޣ`,`gh`],[`ޤ`,`q`],[`ޥ`,`w`],[`ަ`,`a`],[`ާ`,`aa`],[`ި`,`i`],[`ީ`,`ee`],[`ު`,`u`],[`ޫ`,`oo`],[`ެ`,`e`],[`ޭ`,`ey`],[`ޮ`,`o`],[`ޯ`,`oa`],[`ް`,``],[`α`,`a`],[`β`,`v`],[`γ`,`g`],[`δ`,`d`],[`ε`,`e`],[`ζ`,`z`],[`η`,`i`],[`θ`,`th`],[`ι`,`i`],[`κ`,`k`],[`λ`,`l`],[`μ`,`m`],[`ν`,`n`],[`ξ`,`ks`],[`ο`,`o`],[`π`,`p`],[`ρ`,`r`],[`σ`,`s`],[`τ`,`t`],[`υ`,`y`],[`φ`,`f`],[`χ`,`x`],[`ψ`,`ps`],[`ω`,`o`],[`ά`,`a`],[`έ`,`e`],[`ί`,`i`],[`ό`,`o`],[`ύ`,`y`],[`ή`,`i`],[`ώ`,`o`],[`ς`,`s`],[`ϊ`,`i`],[`ΰ`,`y`],[`ϋ`,`y`],[`ΐ`,`i`],[`Α`,`A`],[`Β`,`B`],[`Γ`,`G`],[`Δ`,`D`],[`Ε`,`E`],[`Ζ`,`Z`],[`Η`,`I`],[`Θ`,`TH`],[`Ι`,`I`],[`Κ`,`K`],[`Λ`,`L`],[`Μ`,`M`],[`Ν`,`N`],[`Ξ`,`KS`],[`Ο`,`O`],[`Π`,`P`],[`Ρ`,`R`],[`Σ`,`S`],[`Τ`,`T`],[`Υ`,`Y`],[`Φ`,`F`],[`Χ`,`X`],[`Ψ`,`PS`],[`Ω`,`O`],[`Ά`,`A`],[`Έ`,`E`],[`Ί`,`I`],[`Ό`,`O`],[`Ύ`,`Y`],[`Ή`,`I`],[`Ώ`,`O`],[`Ϊ`,`I`],[`Ϋ`,`Y`],[`ā`,`a`],[`ē`,`e`],[`ģ`,`g`],[`ī`,`i`],[`ķ`,`k`],[`ļ`,`l`],[`ņ`,`n`],[`ū`,`u`],[`Ā`,`A`],[`Ē`,`E`],[`Ģ`,`G`],[`Ī`,`I`],[`Ķ`,`K`],[`Ļ`,`L`],[`Ņ`,`N`],[`Ū`,`U`],[`č`,`c`],[`š`,`s`],[`ž`,`z`],[`Č`,`C`],[`Š`,`S`],[`Ž`,`Z`],[`ą`,`a`],[`č`,`c`],[`ę`,`e`],[`ė`,`e`],[`į`,`i`],[`š`,`s`],[`ų`,`u`],[`ū`,`u`],[`ž`,`z`],[`Ą`,`A`],[`Č`,`C`],[`Ę`,`E`],[`Ė`,`E`],[`Į`,`I`],[`Š`,`S`],[`Ų`,`U`],[`Ū`,`U`],[`Ќ`,`Kj`],[`ќ`,`kj`],[`Љ`,`Lj`],[`љ`,`lj`],[`Њ`,`Nj`],[`њ`,`nj`],[`Тс`,`Ts`],[`тс`,`ts`],[`ą`,`a`],[`ć`,`c`],[`ę`,`e`],[`ł`,`l`],[`ń`,`n`],[`ś`,`s`],[`ź`,`z`],[`ż`,`z`],[`Ą`,`A`],[`Ć`,`C`],[`Ę`,`E`],[`Ł`,`L`],[`Ń`,`N`],[`Ś`,`S`],[`Ź`,`Z`],[`Ż`,`Z`],[`Є`,`Ye`],[`І`,`I`],[`Ї`,`Yi`],[`Ґ`,`G`],[`є`,`ye`],[`і`,`i`],[`ї`,`yi`],[`ґ`,`g`],[`IJ`,`IJ`],[`ij`,`ij`],[`¢`,`c`],[`¥`,`Y`],[`߿`,`b`],[`৳`,`t`],[`૱`,`Bo`],[`฿`,`B`],[`₠`,`CE`],[`₡`,`C`],[`₢`,`Cr`],[`₣`,`F`],[`₥`,`m`],[`₦`,`N`],[`₧`,`Pt`],[`₨`,`Rs`],[`₩`,`W`],[`₫`,`s`],[`€`,`E`],[`₭`,`K`],[`₮`,`T`],[`₯`,`Dp`],[`₰`,`S`],[`₱`,`P`],[`₲`,`G`],[`₳`,`A`],[`₴`,`S`],[`₵`,`C`],[`₶`,`tt`],[`₷`,`S`],[`₸`,`T`],[`₹`,`R`],[`₺`,`L`],[`₽`,`P`],[`₿`,`B`],[`﹩`,`$`],[`¢`,`c`],[`¥`,`Y`],[`₩`,`W`],[`𝐀`,`A`],[`𝐁`,`B`],[`𝐂`,`C`],[`𝐃`,`D`],[`𝐄`,`E`],[`𝐅`,`F`],[`𝐆`,`G`],[`𝐇`,`H`],[`𝐈`,`I`],[`𝐉`,`J`],[`𝐊`,`K`],[`𝐋`,`L`],[`𝐌`,`M`],[`𝐍`,`N`],[`𝐎`,`O`],[`𝐏`,`P`],[`𝐐`,`Q`],[`𝐑`,`R`],[`𝐒`,`S`],[`𝐓`,`T`],[`𝐔`,`U`],[`𝐕`,`V`],[`𝐖`,`W`],[`𝐗`,`X`],[`𝐘`,`Y`],[`𝐙`,`Z`],[`𝐚`,`a`],[`𝐛`,`b`],[`𝐜`,`c`],[`𝐝`,`d`],[`𝐞`,`e`],[`𝐟`,`f`],[`𝐠`,`g`],[`𝐡`,`h`],[`𝐢`,`i`],[`𝐣`,`j`],[`𝐤`,`k`],[`𝐥`,`l`],[`𝐦`,`m`],[`𝐧`,`n`],[`𝐨`,`o`],[`𝐩`,`p`],[`𝐪`,`q`],[`𝐫`,`r`],[`𝐬`,`s`],[`𝐭`,`t`],[`𝐮`,`u`],[`𝐯`,`v`],[`𝐰`,`w`],[`𝐱`,`x`],[`𝐲`,`y`],[`𝐳`,`z`],[`𝐴`,`A`],[`𝐵`,`B`],[`𝐶`,`C`],[`𝐷`,`D`],[`𝐸`,`E`],[`𝐹`,`F`],[`𝐺`,`G`],[`𝐻`,`H`],[`𝐼`,`I`],[`𝐽`,`J`],[`𝐾`,`K`],[`𝐿`,`L`],[`𝑀`,`M`],[`𝑁`,`N`],[`𝑂`,`O`],[`𝑃`,`P`],[`𝑄`,`Q`],[`𝑅`,`R`],[`𝑆`,`S`],[`𝑇`,`T`],[`𝑈`,`U`],[`𝑉`,`V`],[`𝑊`,`W`],[`𝑋`,`X`],[`𝑌`,`Y`],[`𝑍`,`Z`],[`𝑎`,`a`],[`𝑏`,`b`],[`𝑐`,`c`],[`𝑑`,`d`],[`𝑒`,`e`],[`𝑓`,`f`],[`𝑔`,`g`],[`𝑖`,`i`],[`𝑗`,`j`],[`𝑘`,`k`],[`𝑙`,`l`],[`𝑚`,`m`],[`𝑛`,`n`],[`𝑜`,`o`],[`𝑝`,`p`],[`𝑞`,`q`],[`𝑟`,`r`],[`𝑠`,`s`],[`𝑡`,`t`],[`𝑢`,`u`],[`𝑣`,`v`],[`𝑤`,`w`],[`𝑥`,`x`],[`𝑦`,`y`],[`𝑧`,`z`],[`𝑨`,`A`],[`𝑩`,`B`],[`𝑪`,`C`],[`𝑫`,`D`],[`𝑬`,`E`],[`𝑭`,`F`],[`𝑮`,`G`],[`𝑯`,`H`],[`𝑰`,`I`],[`𝑱`,`J`],[`𝑲`,`K`],[`𝑳`,`L`],[`𝑴`,`M`],[`𝑵`,`N`],[`𝑶`,`O`],[`𝑷`,`P`],[`𝑸`,`Q`],[`𝑹`,`R`],[`𝑺`,`S`],[`𝑻`,`T`],[`𝑼`,`U`],[`𝑽`,`V`],[`𝑾`,`W`],[`𝑿`,`X`],[`𝒀`,`Y`],[`𝒁`,`Z`],[`𝒂`,`a`],[`𝒃`,`b`],[`𝒄`,`c`],[`𝒅`,`d`],[`𝒆`,`e`],[`𝒇`,`f`],[`𝒈`,`g`],[`𝒉`,`h`],[`𝒊`,`i`],[`𝒋`,`j`],[`𝒌`,`k`],[`𝒍`,`l`],[`𝒎`,`m`],[`𝒏`,`n`],[`𝒐`,`o`],[`𝒑`,`p`],[`𝒒`,`q`],[`𝒓`,`r`],[`𝒔`,`s`],[`𝒕`,`t`],[`𝒖`,`u`],[`𝒗`,`v`],[`𝒘`,`w`],[`𝒙`,`x`],[`𝒚`,`y`],[`𝒛`,`z`],[`𝒜`,`A`],[`𝒞`,`C`],[`𝒟`,`D`],[`𝒢`,`g`],[`𝒥`,`J`],[`𝒦`,`K`],[`𝒩`,`N`],[`𝒪`,`O`],[`𝒫`,`P`],[`𝒬`,`Q`],[`𝒮`,`S`],[`𝒯`,`T`],[`𝒰`,`U`],[`𝒱`,`V`],[`𝒲`,`W`],[`𝒳`,`X`],[`𝒴`,`Y`],[`𝒵`,`Z`],[`𝒶`,`a`],[`𝒷`,`b`],[`𝒸`,`c`],[`𝒹`,`d`],[`𝒻`,`f`],[`𝒽`,`h`],[`𝒾`,`i`],[`𝒿`,`j`],[`𝓀`,`h`],[`𝓁`,`l`],[`𝓂`,`m`],[`𝓃`,`n`],[`𝓅`,`p`],[`𝓆`,`q`],[`𝓇`,`r`],[`𝓈`,`s`],[`𝓉`,`t`],[`𝓊`,`u`],[`𝓋`,`v`],[`𝓌`,`w`],[`𝓍`,`x`],[`𝓎`,`y`],[`𝓏`,`z`],[`𝓐`,`A`],[`𝓑`,`B`],[`𝓒`,`C`],[`𝓓`,`D`],[`𝓔`,`E`],[`𝓕`,`F`],[`𝓖`,`G`],[`𝓗`,`H`],[`𝓘`,`I`],[`𝓙`,`J`],[`𝓚`,`K`],[`𝓛`,`L`],[`𝓜`,`M`],[`𝓝`,`N`],[`𝓞`,`O`],[`𝓟`,`P`],[`𝓠`,`Q`],[`𝓡`,`R`],[`𝓢`,`S`],[`𝓣`,`T`],[`𝓤`,`U`],[`𝓥`,`V`],[`𝓦`,`W`],[`𝓧`,`X`],[`𝓨`,`Y`],[`𝓩`,`Z`],[`𝓪`,`a`],[`𝓫`,`b`],[`𝓬`,`c`],[`𝓭`,`d`],[`𝓮`,`e`],[`𝓯`,`f`],[`𝓰`,`g`],[`𝓱`,`h`],[`𝓲`,`i`],[`𝓳`,`j`],[`𝓴`,`k`],[`𝓵`,`l`],[`𝓶`,`m`],[`𝓷`,`n`],[`𝓸`,`o`],[`𝓹`,`p`],[`𝓺`,`q`],[`𝓻`,`r`],[`𝓼`,`s`],[`𝓽`,`t`],[`𝓾`,`u`],[`𝓿`,`v`],[`𝔀`,`w`],[`𝔁`,`x`],[`𝔂`,`y`],[`𝔃`,`z`],[`𝔄`,`A`],[`𝔅`,`B`],[`𝔇`,`D`],[`𝔈`,`E`],[`𝔉`,`F`],[`𝔊`,`G`],[`𝔍`,`J`],[`𝔎`,`K`],[`𝔏`,`L`],[`𝔐`,`M`],[`𝔑`,`N`],[`𝔒`,`O`],[`𝔓`,`P`],[`𝔔`,`Q`],[`𝔖`,`S`],[`𝔗`,`T`],[`𝔘`,`U`],[`𝔙`,`V`],[`𝔚`,`W`],[`𝔛`,`X`],[`𝔜`,`Y`],[`𝔞`,`a`],[`𝔟`,`b`],[`𝔠`,`c`],[`𝔡`,`d`],[`𝔢`,`e`],[`𝔣`,`f`],[`𝔤`,`g`],[`𝔥`,`h`],[`𝔦`,`i`],[`𝔧`,`j`],[`𝔨`,`k`],[`𝔩`,`l`],[`𝔪`,`m`],[`𝔫`,`n`],[`𝔬`,`o`],[`𝔭`,`p`],[`𝔮`,`q`],[`𝔯`,`r`],[`𝔰`,`s`],[`𝔱`,`t`],[`𝔲`,`u`],[`𝔳`,`v`],[`𝔴`,`w`],[`𝔵`,`x`],[`𝔶`,`y`],[`𝔷`,`z`],[`𝔸`,`A`],[`𝔹`,`B`],[`𝔻`,`D`],[`𝔼`,`E`],[`𝔽`,`F`],[`𝔾`,`G`],[`𝕀`,`I`],[`𝕁`,`J`],[`𝕂`,`K`],[`𝕃`,`L`],[`𝕄`,`M`],[`𝕆`,`N`],[`𝕊`,`S`],[`𝕋`,`T`],[`𝕌`,`U`],[`𝕍`,`V`],[`𝕎`,`W`],[`𝕏`,`X`],[`𝕐`,`Y`],[`𝕒`,`a`],[`𝕓`,`b`],[`𝕔`,`c`],[`𝕕`,`d`],[`𝕖`,`e`],[`𝕗`,`f`],[`𝕘`,`g`],[`𝕙`,`h`],[`𝕚`,`i`],[`𝕛`,`j`],[`𝕜`,`k`],[`𝕝`,`l`],[`𝕞`,`m`],[`𝕟`,`n`],[`𝕠`,`o`],[`𝕡`,`p`],[`𝕢`,`q`],[`𝕣`,`r`],[`𝕤`,`s`],[`𝕥`,`t`],[`𝕦`,`u`],[`𝕧`,`v`],[`𝕨`,`w`],[`𝕩`,`x`],[`𝕪`,`y`],[`𝕫`,`z`],[`𝕬`,`A`],[`𝕭`,`B`],[`𝕮`,`C`],[`𝕯`,`D`],[`𝕰`,`E`],[`𝕱`,`F`],[`𝕲`,`G`],[`𝕳`,`H`],[`𝕴`,`I`],[`𝕵`,`J`],[`𝕶`,`K`],[`𝕷`,`L`],[`𝕸`,`M`],[`𝕹`,`N`],[`𝕺`,`O`],[`𝕻`,`P`],[`𝕼`,`Q`],[`𝕽`,`R`],[`𝕾`,`S`],[`𝕿`,`T`],[`𝖀`,`U`],[`𝖁`,`V`],[`𝖂`,`W`],[`𝖃`,`X`],[`𝖄`,`Y`],[`𝖅`,`Z`],[`𝖆`,`a`],[`𝖇`,`b`],[`𝖈`,`c`],[`𝖉`,`d`],[`𝖊`,`e`],[`𝖋`,`f`],[`𝖌`,`g`],[`𝖍`,`h`],[`𝖎`,`i`],[`𝖏`,`j`],[`𝖐`,`k`],[`𝖑`,`l`],[`𝖒`,`m`],[`𝖓`,`n`],[`𝖔`,`o`],[`𝖕`,`p`],[`𝖖`,`q`],[`𝖗`,`r`],[`𝖘`,`s`],[`𝖙`,`t`],[`𝖚`,`u`],[`𝖛`,`v`],[`𝖜`,`w`],[`𝖝`,`x`],[`𝖞`,`y`],[`𝖟`,`z`],[`𝖠`,`A`],[`𝖡`,`B`],[`𝖢`,`C`],[`𝖣`,`D`],[`𝖤`,`E`],[`𝖥`,`F`],[`𝖦`,`G`],[`𝖧`,`H`],[`𝖨`,`I`],[`𝖩`,`J`],[`𝖪`,`K`],[`𝖫`,`L`],[`𝖬`,`M`],[`𝖭`,`N`],[`𝖮`,`O`],[`𝖯`,`P`],[`𝖰`,`Q`],[`𝖱`,`R`],[`𝖲`,`S`],[`𝖳`,`T`],[`𝖴`,`U`],[`𝖵`,`V`],[`𝖶`,`W`],[`𝖷`,`X`],[`𝖸`,`Y`],[`𝖹`,`Z`],[`𝖺`,`a`],[`𝖻`,`b`],[`𝖼`,`c`],[`𝖽`,`d`],[`𝖾`,`e`],[`𝖿`,`f`],[`𝗀`,`g`],[`𝗁`,`h`],[`𝗂`,`i`],[`𝗃`,`j`],[`𝗄`,`k`],[`𝗅`,`l`],[`𝗆`,`m`],[`𝗇`,`n`],[`𝗈`,`o`],[`𝗉`,`p`],[`𝗊`,`q`],[`𝗋`,`r`],[`𝗌`,`s`],[`𝗍`,`t`],[`𝗎`,`u`],[`𝗏`,`v`],[`𝗐`,`w`],[`𝗑`,`x`],[`𝗒`,`y`],[`𝗓`,`z`],[`𝗔`,`A`],[`𝗕`,`B`],[`𝗖`,`C`],[`𝗗`,`D`],[`𝗘`,`E`],[`𝗙`,`F`],[`𝗚`,`G`],[`𝗛`,`H`],[`𝗜`,`I`],[`𝗝`,`J`],[`𝗞`,`K`],[`𝗟`,`L`],[`𝗠`,`M`],[`𝗡`,`N`],[`𝗢`,`O`],[`𝗣`,`P`],[`𝗤`,`Q`],[`𝗥`,`R`],[`𝗦`,`S`],[`𝗧`,`T`],[`𝗨`,`U`],[`𝗩`,`V`],[`𝗪`,`W`],[`𝗫`,`X`],[`𝗬`,`Y`],[`𝗭`,`Z`],[`𝗮`,`a`],[`𝗯`,`b`],[`𝗰`,`c`],[`𝗱`,`d`],[`𝗲`,`e`],[`𝗳`,`f`],[`𝗴`,`g`],[`𝗵`,`h`],[`𝗶`,`i`],[`𝗷`,`j`],[`𝗸`,`k`],[`𝗹`,`l`],[`𝗺`,`m`],[`𝗻`,`n`],[`𝗼`,`o`],[`𝗽`,`p`],[`𝗾`,`q`],[`𝗿`,`r`],[`𝘀`,`s`],[`𝘁`,`t`],[`𝘂`,`u`],[`𝘃`,`v`],[`𝘄`,`w`],[`𝘅`,`x`],[`𝘆`,`y`],[`𝘇`,`z`],[`𝘈`,`A`],[`𝘉`,`B`],[`𝘊`,`C`],[`𝘋`,`D`],[`𝘌`,`E`],[`𝘍`,`F`],[`𝘎`,`G`],[`𝘏`,`H`],[`𝘐`,`I`],[`𝘑`,`J`],[`𝘒`,`K`],[`𝘓`,`L`],[`𝘔`,`M`],[`𝘕`,`N`],[`𝘖`,`O`],[`𝘗`,`P`],[`𝘘`,`Q`],[`𝘙`,`R`],[`𝘚`,`S`],[`𝘛`,`T`],[`𝘜`,`U`],[`𝘝`,`V`],[`𝘞`,`W`],[`𝘟`,`X`],[`𝘠`,`Y`],[`𝘡`,`Z`],[`𝘢`,`a`],[`𝘣`,`b`],[`𝘤`,`c`],[`𝘥`,`d`],[`𝘦`,`e`],[`𝘧`,`f`],[`𝘨`,`g`],[`𝘩`,`h`],[`𝘪`,`i`],[`𝘫`,`j`],[`𝘬`,`k`],[`𝘭`,`l`],[`𝘮`,`m`],[`𝘯`,`n`],[`𝘰`,`o`],[`𝘱`,`p`],[`𝘲`,`q`],[`𝘳`,`r`],[`𝘴`,`s`],[`𝘵`,`t`],[`𝘶`,`u`],[`𝘷`,`v`],[`𝘸`,`w`],[`𝘹`,`x`],[`𝘺`,`y`],[`𝘻`,`z`],[`𝘼`,`A`],[`𝘽`,`B`],[`𝘾`,`C`],[`𝘿`,`D`],[`𝙀`,`E`],[`𝙁`,`F`],[`𝙂`,`G`],[`𝙃`,`H`],[`𝙄`,`I`],[`𝙅`,`J`],[`𝙆`,`K`],[`𝙇`,`L`],[`𝙈`,`M`],[`𝙉`,`N`],[`𝙊`,`O`],[`𝙋`,`P`],[`𝙌`,`Q`],[`𝙍`,`R`],[`𝙎`,`S`],[`𝙏`,`T`],[`𝙐`,`U`],[`𝙑`,`V`],[`𝙒`,`W`],[`𝙓`,`X`],[`𝙔`,`Y`],[`𝙕`,`Z`],[`𝙖`,`a`],[`𝙗`,`b`],[`𝙘`,`c`],[`𝙙`,`d`],[`𝙚`,`e`],[`𝙛`,`f`],[`𝙜`,`g`],[`𝙝`,`h`],[`𝙞`,`i`],[`𝙟`,`j`],[`𝙠`,`k`],[`𝙡`,`l`],[`𝙢`,`m`],[`𝙣`,`n`],[`𝙤`,`o`],[`𝙥`,`p`],[`𝙦`,`q`],[`𝙧`,`r`],[`𝙨`,`s`],[`𝙩`,`t`],[`𝙪`,`u`],[`𝙫`,`v`],[`𝙬`,`w`],[`𝙭`,`x`],[`𝙮`,`y`],[`𝙯`,`z`],[`𝙰`,`A`],[`𝙱`,`B`],[`𝙲`,`C`],[`𝙳`,`D`],[`𝙴`,`E`],[`𝙵`,`F`],[`𝙶`,`G`],[`𝙷`,`H`],[`𝙸`,`I`],[`𝙹`,`J`],[`𝙺`,`K`],[`𝙻`,`L`],[`𝙼`,`M`],[`𝙽`,`N`],[`𝙾`,`O`],[`𝙿`,`P`],[`𝚀`,`Q`],[`𝚁`,`R`],[`𝚂`,`S`],[`𝚃`,`T`],[`𝚄`,`U`],[`𝚅`,`V`],[`𝚆`,`W`],[`𝚇`,`X`],[`𝚈`,`Y`],[`𝚉`,`Z`],[`𝚊`,`a`],[`𝚋`,`b`],[`𝚌`,`c`],[`𝚍`,`d`],[`𝚎`,`e`],[`𝚏`,`f`],[`𝚐`,`g`],[`𝚑`,`h`],[`𝚒`,`i`],[`𝚓`,`j`],[`𝚔`,`k`],[`𝚕`,`l`],[`𝚖`,`m`],[`𝚗`,`n`],[`𝚘`,`o`],[`𝚙`,`p`],[`𝚚`,`q`],[`𝚛`,`r`],[`𝚜`,`s`],[`𝚝`,`t`],[`𝚞`,`u`],[`𝚟`,`v`],[`𝚠`,`w`],[`𝚡`,`x`],[`𝚢`,`y`],[`𝚣`,`z`],[`𝚤`,`l`],[`𝚥`,`j`],[`𝛢`,`A`],[`𝛣`,`B`],[`𝛤`,`G`],[`𝛥`,`D`],[`𝛦`,`E`],[`𝛧`,`Z`],[`𝛨`,`I`],[`𝛩`,`TH`],[`𝛪`,`I`],[`𝛫`,`K`],[`𝛬`,`L`],[`𝛭`,`M`],[`𝛮`,`N`],[`𝛯`,`KS`],[`𝛰`,`O`],[`𝛱`,`P`],[`𝛲`,`R`],[`𝛳`,`TH`],[`𝛴`,`S`],[`𝛵`,`T`],[`𝛶`,`Y`],[`𝛷`,`F`],[`𝛸`,`x`],[`𝛹`,`PS`],[`𝛺`,`O`],[`𝛻`,`D`],[`𝛼`,`a`],[`𝛽`,`b`],[`𝛾`,`g`],[`𝛿`,`d`],[`𝜀`,`e`],[`𝜁`,`z`],[`𝜂`,`i`],[`𝜃`,`th`],[`𝜄`,`i`],[`𝜅`,`k`],[`𝜆`,`l`],[`𝜇`,`m`],[`𝜈`,`n`],[`𝜉`,`ks`],[`𝜊`,`o`],[`𝜋`,`p`],[`𝜌`,`r`],[`𝜍`,`s`],[`𝜎`,`s`],[`𝜏`,`t`],[`𝜐`,`y`],[`𝜑`,`f`],[`𝜒`,`x`],[`𝜓`,`ps`],[`𝜔`,`o`],[`𝜕`,`d`],[`𝜖`,`E`],[`𝜗`,`TH`],[`𝜘`,`K`],[`𝜙`,`f`],[`𝜚`,`r`],[`𝜛`,`p`],[`𝜜`,`A`],[`𝜝`,`V`],[`𝜞`,`G`],[`𝜟`,`D`],[`𝜠`,`E`],[`𝜡`,`Z`],[`𝜢`,`I`],[`𝜣`,`TH`],[`𝜤`,`I`],[`𝜥`,`K`],[`𝜦`,`L`],[`𝜧`,`M`],[`𝜨`,`N`],[`𝜩`,`KS`],[`𝜪`,`O`],[`𝜫`,`P`],[`𝜬`,`S`],[`𝜭`,`TH`],[`𝜮`,`S`],[`𝜯`,`T`],[`𝜰`,`Y`],[`𝜱`,`F`],[`𝜲`,`X`],[`𝜳`,`PS`],[`𝜴`,`O`],[`𝜵`,`D`],[`𝜶`,`a`],[`𝜷`,`v`],[`𝜸`,`g`],[`𝜹`,`d`],[`𝜺`,`e`],[`𝜻`,`z`],[`𝜼`,`i`],[`𝜽`,`th`],[`𝜾`,`i`],[`𝜿`,`k`],[`𝝀`,`l`],[`𝝁`,`m`],[`𝝂`,`n`],[`𝝃`,`ks`],[`𝝄`,`o`],[`𝝅`,`p`],[`𝝆`,`r`],[`𝝇`,`s`],[`𝝈`,`s`],[`𝝉`,`t`],[`𝝊`,`y`],[`𝝋`,`f`],[`𝝌`,`x`],[`𝝍`,`ps`],[`𝝎`,`o`],[`𝝏`,`a`],[`𝝐`,`e`],[`𝝑`,`i`],[`𝝒`,`k`],[`𝝓`,`f`],[`𝝔`,`r`],[`𝝕`,`p`],[`𝝖`,`A`],[`𝝗`,`B`],[`𝝘`,`G`],[`𝝙`,`D`],[`𝝚`,`E`],[`𝝛`,`Z`],[`𝝜`,`I`],[`𝝝`,`TH`],[`𝝞`,`I`],[`𝝟`,`K`],[`𝝠`,`L`],[`𝝡`,`M`],[`𝝢`,`N`],[`𝝣`,`KS`],[`𝝤`,`O`],[`𝝥`,`P`],[`𝝦`,`R`],[`𝝧`,`TH`],[`𝝨`,`S`],[`𝝩`,`T`],[`𝝪`,`Y`],[`𝝫`,`F`],[`𝝬`,`X`],[`𝝭`,`PS`],[`𝝮`,`O`],[`𝝯`,`D`],[`𝝰`,`a`],[`𝝱`,`v`],[`𝝲`,`g`],[`𝝳`,`d`],[`𝝴`,`e`],[`𝝵`,`z`],[`𝝶`,`i`],[`𝝷`,`th`],[`𝝸`,`i`],[`𝝹`,`k`],[`𝝺`,`l`],[`𝝻`,`m`],[`𝝼`,`n`],[`𝝽`,`ks`],[`𝝾`,`o`],[`𝝿`,`p`],[`𝞀`,`r`],[`𝞁`,`s`],[`𝞂`,`s`],[`𝞃`,`t`],[`𝞄`,`y`],[`𝞅`,`f`],[`𝞆`,`x`],[`𝞇`,`ps`],[`𝞈`,`o`],[`𝞉`,`a`],[`𝞊`,`e`],[`𝞋`,`i`],[`𝞌`,`k`],[`𝞍`,`f`],[`𝞎`,`r`],[`𝞏`,`p`],[`𝞐`,`A`],[`𝞑`,`V`],[`𝞒`,`G`],[`𝞓`,`D`],[`𝞔`,`E`],[`𝞕`,`Z`],[`𝞖`,`I`],[`𝞗`,`TH`],[`𝞘`,`I`],[`𝞙`,`K`],[`𝞚`,`L`],[`𝞛`,`M`],[`𝞜`,`N`],[`𝞝`,`KS`],[`𝞞`,`O`],[`𝞟`,`P`],[`𝞠`,`S`],[`𝞡`,`TH`],[`𝞢`,`S`],[`𝞣`,`T`],[`𝞤`,`Y`],[`𝞥`,`F`],[`𝞦`,`X`],[`𝞧`,`PS`],[`𝞨`,`O`],[`𝞩`,`D`],[`𝞪`,`av`],[`𝞫`,`g`],[`𝞬`,`d`],[`𝞭`,`e`],[`𝞮`,`z`],[`𝞯`,`i`],[`𝞰`,`i`],[`𝞱`,`th`],[`𝞲`,`i`],[`𝞳`,`k`],[`𝞴`,`l`],[`𝞵`,`m`],[`𝞶`,`n`],[`𝞷`,`ks`],[`𝞸`,`o`],[`𝞹`,`p`],[`𝞺`,`r`],[`𝞻`,`s`],[`𝞼`,`s`],[`𝞽`,`t`],[`𝞾`,`y`],[`𝞿`,`f`],[`𝟀`,`x`],[`𝟁`,`ps`],[`𝟂`,`o`],[`𝟃`,`a`],[`𝟄`,`e`],[`𝟅`,`i`],[`𝟆`,`k`],[`𝟇`,`f`],[`𝟈`,`r`],[`𝟉`,`p`],[`𝟊`,`F`],[`𝟋`,`f`],[`⒜`,`(a)`],[`⒝`,`(b)`],[`⒞`,`(c)`],[`⒟`,`(d)`],[`⒠`,`(e)`],[`⒡`,`(f)`],[`⒢`,`(g)`],[`⒣`,`(h)`],[`⒤`,`(i)`],[`⒥`,`(j)`],[`⒦`,`(k)`],[`⒧`,`(l)`],[`⒨`,`(m)`],[`⒩`,`(n)`],[`⒪`,`(o)`],[`⒫`,`(p)`],[`⒬`,`(q)`],[`⒭`,`(r)`],[`⒮`,`(s)`],[`⒯`,`(t)`],[`⒰`,`(u)`],[`⒱`,`(v)`],[`⒲`,`(w)`],[`⒳`,`(x)`],[`⒴`,`(y)`],[`⒵`,`(z)`],[`Ⓐ`,`(A)`],[`Ⓑ`,`(B)`],[`Ⓒ`,`(C)`],[`Ⓓ`,`(D)`],[`Ⓔ`,`(E)`],[`Ⓕ`,`(F)`],[`Ⓖ`,`(G)`],[`Ⓗ`,`(H)`],[`Ⓘ`,`(I)`],[`Ⓙ`,`(J)`],[`Ⓚ`,`(K)`],[`Ⓛ`,`(L)`],[`Ⓝ`,`(N)`],[`Ⓞ`,`(O)`],[`Ⓟ`,`(P)`],[`Ⓠ`,`(Q)`],[`Ⓡ`,`(R)`],[`Ⓢ`,`(S)`],[`Ⓣ`,`(T)`],[`Ⓤ`,`(U)`],[`Ⓥ`,`(V)`],[`Ⓦ`,`(W)`],[`Ⓧ`,`(X)`],[`Ⓨ`,`(Y)`],[`Ⓩ`,`(Z)`],[`ⓐ`,`(a)`],[`ⓑ`,`(b)`],[`ⓒ`,`(b)`],[`ⓓ`,`(c)`],[`ⓔ`,`(e)`],[`ⓕ`,`(f)`],[`ⓖ`,`(g)`],[`ⓗ`,`(h)`],[`ⓘ`,`(i)`],[`ⓙ`,`(j)`],[`ⓚ`,`(k)`],[`ⓛ`,`(l)`],[`ⓜ`,`(m)`],[`ⓝ`,`(n)`],[`ⓞ`,`(o)`],[`ⓟ`,`(p)`],[`ⓠ`,`(q)`],[`ⓡ`,`(r)`],[`ⓢ`,`(s)`],[`ⓣ`,`(t)`],[`ⓤ`,`(u)`],[`ⓥ`,`(v)`],[`ⓦ`,`(w)`],[`ⓧ`,`(x)`],[`ⓨ`,`(y)`],[`ⓩ`,`(z)`],[`Ċ`,`C`],[`ċ`,`c`],[`Ġ`,`G`],[`ġ`,`g`],[`Ħ`,`H`],[`ħ`,`h`],[`Ż`,`Z`],[`ż`,`z`],[`𝟎`,`0`],[`𝟏`,`1`],[`𝟐`,`2`],[`𝟑`,`3`],[`𝟒`,`4`],[`𝟓`,`5`],[`𝟔`,`6`],[`𝟕`,`7`],[`𝟖`,`8`],[`𝟗`,`9`],[`𝟘`,`0`],[`𝟙`,`1`],[`𝟚`,`2`],[`𝟛`,`3`],[`𝟜`,`4`],[`𝟝`,`5`],[`𝟞`,`6`],[`𝟟`,`7`],[`𝟠`,`8`],[`𝟡`,`9`],[`𝟢`,`0`],[`𝟣`,`1`],[`𝟤`,`2`],[`𝟥`,`3`],[`𝟦`,`4`],[`𝟧`,`5`],[`𝟨`,`6`],[`𝟩`,`7`],[`𝟪`,`8`],[`𝟫`,`9`],[`𝟬`,`0`],[`𝟭`,`1`],[`𝟮`,`2`],[`𝟯`,`3`],[`𝟰`,`4`],[`𝟱`,`5`],[`𝟲`,`6`],[`𝟳`,`7`],[`𝟴`,`8`],[`𝟵`,`9`],[`𝟶`,`0`],[`𝟷`,`1`],[`𝟸`,`2`],[`𝟹`,`3`],[`𝟺`,`4`],[`𝟻`,`5`],[`𝟼`,`6`],[`𝟽`,`7`],[`𝟾`,`8`],[`𝟿`,`9`],[`①`,`1`],[`②`,`2`],[`③`,`3`],[`④`,`4`],[`⑤`,`5`],[`⑥`,`6`],[`⑦`,`7`],[`⑧`,`8`],[`⑨`,`9`],[`⑩`,`10`],[`⑪`,`11`],[`⑫`,`12`],[`⑬`,`13`],[`⑭`,`14`],[`⑮`,`15`],[`⑯`,`16`],[`⑰`,`17`],[`⑱`,`18`],[`⑲`,`19`],[`⑳`,`20`],[`⑴`,`1`],[`⑵`,`2`],[`⑶`,`3`],[`⑷`,`4`],[`⑸`,`5`],[`⑹`,`6`],[`⑺`,`7`],[`⑻`,`8`],[`⑼`,`9`],[`⑽`,`10`],[`⑾`,`11`],[`⑿`,`12`],[`⒀`,`13`],[`⒁`,`14`],[`⒂`,`15`],[`⒃`,`16`],[`⒄`,`17`],[`⒅`,`18`],[`⒆`,`19`],[`⒇`,`20`],[`⒈`,`1.`],[`⒉`,`2.`],[`⒊`,`3.`],[`⒋`,`4.`],[`⒌`,`5.`],[`⒍`,`6.`],[`⒎`,`7.`],[`⒏`,`8.`],[`⒐`,`9.`],[`⒑`,`10.`],[`⒒`,`11.`],[`⒓`,`12.`],[`⒔`,`13.`],[`⒕`,`14.`],[`⒖`,`15.`],[`⒗`,`16.`],[`⒘`,`17.`],[`⒙`,`18.`],[`⒚`,`19.`],[`⒛`,`20.`],[`⓪`,`0`],[`⓫`,`11`],[`⓬`,`12`],[`⓭`,`13`],[`⓮`,`14`],[`⓯`,`15`],[`⓰`,`16`],[`⓱`,`17`],[`⓲`,`18`],[`⓳`,`19`],[`⓴`,`20`],[`⓵`,`1`],[`⓶`,`2`],[`⓷`,`3`],[`⓸`,`4`],[`⓹`,`5`],[`⓺`,`6`],[`⓻`,`7`],[`⓼`,`8`],[`⓽`,`9`],[`⓾`,`10`],[`⓿`,`0`],[`🙰`,`&`],[`🙱`,`&`],[`🙲`,`&`],[`🙳`,`&`],[`🙴`,`&`],[`🙵`,`&`],[`🙶`,`"`],[`🙷`,`"`],[`🙸`,`"`],[`‽`,`?!`],[`🙹`,`?!`],[`🙺`,`?!`],[`🙻`,`?!`],[`🙼`,`/`],[`🙽`,`\\`],[`🜇`,`AR`],[`🜈`,`V`],[`🜉`,`V`],[`🜆`,`VR`],[`🜅`,`VF`],[`🜩`,`2`],[`🜪`,`5`],[`🝡`,`f`],[`🝢`,`W`],[`🝣`,`U`],[`🝧`,`V`],[`🝨`,`T`],[`🝪`,`V`],[`🝫`,`MB`],[`🝬`,`VB`],[`🝲`,`3B`],[`🝳`,`3B`],[`💯`,`100`],[`🔙`,`BACK`],[`🔚`,`END`],[`🔛`,`ON!`],[`🔜`,`SOON`],[`🔝`,`TOP`],[`🔞`,`18`],[`🔤`,`abc`],[`🔠`,`ABCD`],[`🔡`,`abcd`],[`🔢`,`1234`],[`🔣`,`T&@%`],[`#️⃣`,`#`],[`*️⃣`,`*`],[`0️⃣`,`0`],[`1️⃣`,`1`],[`2️⃣`,`2`],[`3️⃣`,`3`],[`4️⃣`,`4`],[`5️⃣`,`5`],[`6️⃣`,`6`],[`7️⃣`,`7`],[`8️⃣`,`8`],[`9️⃣`,`9`],[`🔟`,`10`],[`🅰️`,`A`],[`🅱️`,`B`],[`🆎`,`AB`],[`🆑`,`CL`],[`🅾️`,`O`],[`🅿`,`P`],[`🆘`,`SOS`],[`🅲`,`C`],[`🅳`,`D`],[`🅴`,`E`],[`🅵`,`F`],[`🅶`,`G`],[`🅷`,`H`],[`🅸`,`I`],[`🅹`,`J`],[`🅺`,`K`],[`🅻`,`L`],[`🅼`,`M`],[`🅽`,`N`],[`🆀`,`Q`],[`🆁`,`R`],[`🆂`,`S`],[`🆃`,`T`],[`🆄`,`U`],[`🆅`,`V`],[`🆆`,`W`],[`🆇`,`X`],[`🆈`,`Y`],[`🆉`,`Z`]],hnt=(e,t)=>{for(let[n,r]of t)e=e.replace(new RegExp(iw(n),`g`),r);return e};function gnt(e,t){if(typeof e!=`string`)throw TypeError(`Expected a string, got \`${typeof e}\``);t={customReplacements:[],...t};let n=new Map([...mnt,...t.customReplacements]);return e=e.normalize(),e=hnt(e,n),e=e.normalize(`NFD`).replace(/\p{Diacritic}/gu,``).normalize(),e}var _nt=[[`&`,` and `],[`🦄`,` unicorn `],[`♥`,` love `]],vnt=e=>e.replace(/([A-Z]{2,})(\d+)/g,`$1 $2`).replace(/([a-z\d]+)([A-Z]{2,})/g,`$1 $2`).replace(/([a-z\d])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-rt-z\d]+)/g,`$1 $2`),ynt=(e,t)=>{let n=iw(t);return e.replace(RegExp(`${n}{2,}`,`g`),t).replace(RegExp(`^${n}|${n}$`,`g`),``)},bnt=e=>{let t=`a-z\\d`;if(t+=e.lowercase?``:`A-Z`,e.preserveCharacters.length>0)for(let n of e.preserveCharacters){if(n===e.separator)throw Error(`The separator character \`${e.separator}\` cannot be included in preserved characters: ${e.preserveCharacters}`);t+=iw(n)}return RegExp(`[^${t}]+`,`g`)};function $Y(e,t){if(typeof e!=`string`)throw TypeError(`Expected a string, got \`${typeof e}\``);t={separator:`-`,lowercase:!0,decamelize:!0,customReplacements:[],preserveLeadingUnderscore:!1,preserveTrailingDash:!1,preserveCharacters:[],...t};let n=t.preserveLeadingUnderscore&&e.startsWith(`_`),r=t.preserveTrailingDash&&e.endsWith(`-`),i=new Map([..._nt,...t.customReplacements]);e=gnt(e,{customReplacements:i}),t.decamelize&&(e=vnt(e));let a=bnt(t);return t.lowercase&&(e=e.toLowerCase()),e=e.replace(/([a-zA-Z\d]+)'([ts])(\s|$)/g,`$1$2$3`),e=e.replace(a,t.separator),e=e.replace(/\\/g,``),t.separator&&(e=ynt(e,t.separator)),n&&(e=`_${e}`),r&&(e=`${e}-`),e}var eX=e=>$Y(e.toUpperCase(),{lowercase:!1,separator:`_`}),xnt=(e,t,n)=>`API_KEY_${eX(e)||eX(t)||`PROVIDER`}_${n}`,Snt=(e,t)=>{let n=e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[._-]+|[._-]+$/g,``),r=(e===`__custom`?`custom`:n||`provider`).slice(0,64).replace(/[._-]+$/g,``),i=new Set(Array.from(t,e=>e.toLowerCase()));if(!i.has(r))return r;let a=2,o=r;do{let e=`-${a}`;o=`${r.slice(0,64-e.length).replace(/[._-]+$/g,``)}${e}`,a+=1}while(i.has(o));return o},Cnt=(e,t)=>e.length===0||e===t,wnt=Pm().min(1,`Provider Name is required`).max(64,`Provider Name must be 64 characters or fewer`).regex(/^[a-z0-9][a-z0-9._-]*$/,`Use lowercase letters, numbers, periods, underscores, or hyphens, starting with a letter or number`),tX=Rm({provider:Pm().min(1,`Provider is required`),customProviderName:Pm().optional(),label:wnt,apiKey:Pm().optional(),envVarName:Pm().optional(),baseUrl:Pm().url(`Must be a valid URL`).optional(),region:Pm().optional(),gcpProjectId:Pm().optional(),customModels:Lm(Rm({modelId:Pm().optional(),name:Pm().min(1,`Model name is required`),kind:Bm([`completions`,`embeddings`]),inputCostPerToken:Fm().min(0,`Cost must be non-negative`),outputCostPerToken:Fm().min(0,`Cost must be non-negative`),status:Bm([`active`,`deprecated`])})).optional(),models:Rm({completions:Lm(Pm()).optional(),embeddings:Lm(Pm()).optional()}).optional()}),nX=e=>e.refine(e=>e.provider!==`__custom`||(e.baseUrl?.length??0)>0,{message:`API URL is required for custom providers`,path:[`baseUrl`]}).superRefine((e,t)=>{if(e.provider!==`__custom`||!e.baseUrl)return;let n;try{n=new URL(e.baseUrl)}catch{return}let r=e=>t.addIssue({code:Pp.custom,path:[`baseUrl`],message:e});if(n.protocol!==`https:`&&n.protocol!==`http:`){r(`API URL must use http or https — replace '${n.protocol}//' with 'https://'`);return}(n.username||n.password)&&r(`API URL must not embed credentials — the API key belongs in the API Key field. Remove the 'user:password@' part`),n.search&&r(`API URL must not contain a query string. Remove everything from '${n.search}' on`),n.hash&&r(`API URL must not contain a fragment. Remove everything from '${n.hash}' on`);let i=n.pathname.replace(/\/+$/,``),a=/\/v1(?:\/(?:chat\/completions|embeddings))?$/.exec(i);if(a){let e=`${n.origin}${i.slice(0,-a[0].length)}`;r(`The gateway appends /v1/chat/completions itself, so the API URL must not end in '${a[0]}'. Use '${e}'`)}}).refine(e=>e.provider!==`__custom`||(e.customModels?.length??0)>0,{message:`Models are required for custom providers`,path:[`customModels`]}).refine(e=>e.provider!==`BedrockMantle`||(e.region?.trim().length??0)>0,{message:`AWS Region is required for Bedrock Mantle`,path:[`region`]}).refine(e=>e.provider!==`BedrockMantle`||!e.region?.trim()||tje.test(e.region.trim()),{message:`Enter a lowercase AWS region code, like us-east-1`,path:[`region`]}).refine(e=>e.provider!==`BedrockMantle`||!e.apiKey?.trim().startsWith(`bedrock-api-key-`),{message:`This is a short-term Bedrock API key, which expires within 12 hours. Create a long-term key (it starts with ABSK) in the AWS console`,path:[`apiKey`]}).refine(e=>e.provider!==`BedrockMantle`||!e.apiKey?.trim()||e.apiKey.trim().startsWith(`ABSK`),{message:`Bedrock Mantle uses long-term Bedrock API keys, which start with ABSK`,path:[`apiKey`]}).refine(e=>e.provider!==`VertexAI`||(e.region?.trim().length??0)>0,{message:`Location is required for Vertex AI`,path:[`region`]}).refine(e=>e.provider!==`VertexAI`||!e.region?.trim()||oje.test(e.region.trim()),{message:`Enter a lowercase Google Cloud location, like us-central1, or global`,path:[`region`]}).refine(e=>e.provider!==`VertexAI`||(e.gcpProjectId?.trim().length??0)>0,{message:`Google Cloud project ID is required for Vertex AI`,path:[`gcpProjectId`]}).refine(e=>e.provider!==`VertexAI`||!e.gcpProjectId?.trim()||!/^\d+$/.test(e.gcpProjectId.trim()),{message:`This looks like a project number. Use the project ID — the readable identifier next to the project name in the Google Cloud console`,path:[`gcpProjectId`]}).refine(e=>e.provider!==`VertexAI`||!e.gcpProjectId?.trim()||sje.test(e.gcpProjectId.trim()),{message:`Project IDs are 6 to 30 characters: lowercase letters, digits and hyphens, starting with a letter`,path:[`gcpProjectId`]}).refine(e=>e.provider!==`VertexAI`||!e.apiKey?.trim()||uje(e.apiKey.trim()),{message:`Vertex AI authenticates with a service account, not an API key. Paste the whole JSON key file from the Google Cloud console (IAM & Admin > Service Accounts > Keys)`,path:[`apiKey`]}),Tnt=nX(tX),Ent=nX(tX.extend({label:Pm().min(1,`Provider Name is required`)})),Dnt=(e,t=[])=>{let n=new Set(Array.from(e,e=>e.toLowerCase())),r=new Set(Array.from(t,e=>e.toLowerCase()));return Tnt.refine(e=>!n.has(e.label.toLowerCase()),{message:`This Provider Name is already in use`,path:[`label`]}).refine(e=>e.provider!==`__custom`||!r.has(e.label.toLowerCase()),{message:`This custom provider name is already in use`,path:[`label`]})};function rX(){let[e,t]=(0,H.useTransition)();return{startOpening:t,renderTrigger:t=>(0,H.isValidElement)(t)?(0,H.cloneElement)(t,{disabled:t.props.disabled||e,children:(0,U.jsx)(rM,{loading:e,className:`flex items-center justify-center gap-2`,children:t.props.children})}):t}}var Ont=SY(`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`,6),knt=`OpenAI`;function Ant(e){return e===`ZuploDemo`?`Zuplo Demo needs no API key. Select the models you want available.`:e===`VertexAI`?`Vertex AI authenticates with a Google Cloud service account, not an API key. Set the location and project, paste the JSON key file, and select available models.`:`Configure a new AI provider with your API key and select available models.`}var iX=({children:e,onOpenChange:t,defaultOpen:n=!1,initialValues:r})=>{let[i,a]=(0,H.useState)(n),{startOpening:o,renderTrigger:s}=rX(),c=wY(),l=Dt(),{account:u,project:d}=lb([`account`,`project`]),f=cY(),{logEvent:p}=on(),m=CY(),h=Xtt().data,g=(0,H.useCallback)(e=>Snt(e,h.flatMap(t=>[t.label,...e===`__custom`&&t.customProviderName?[t.customProviderName]:[]])),[h]),_=JE(r?.provider)&&!YE(f)?void 0:r,v=_?.provider?.trim()||knt,y=v===qE,b=(0,H.useCallback)(()=>({provider:v,customProviderName:void 0,label:_?.label?.trim()||g(v),apiKey:``,region:``,gcpProjectId:``,models:{completions:_?.models?.completions??[],embeddings:_?.models?.embeddings??[]},...y?{baseUrl:_?.baseUrl?.trim()||void 0,customModels:_?.customModels?.map(e=>({name:e.name,kind:e.kind,status:`active`,inputCostPerToken:e.inputCostPerToken??0,outputCostPerToken:e.outputCostPerToken??0}))}:{}}),[g,_,y,v]),x=(0,H.useMemo)(()=>Dnt(h.map(e=>e.label),h.flatMap(e=>e.customProviderName?[e.customProviderName]:[])),[h]),S=je({mutationFn:async e=>{let t=e.provider===qE,n=t?`Custom`:e.provider;if(t){let t=await l.fetch(tn.ai.createBucketAiProvider(c,{name:e.label,baseURL:e.baseUrl??``}));for(let n of e.customModels??[])await l.fetch(tn.ai.createAiProviderModel(c,t.id,{model:n.name,kind:n.kind,inputCostPerToken:n.inputCostPerToken,outputCostPerToken:n.outputCostPerToken,status:`active`}))}return await l.fetch(tn.ai.createAiProviderAssignment(u,d,{provider:n,customProviderName:t?e.label:void 0,label:e.label,envVarName:xnt(e.label,n,Ont()),...e.apiKey?.trim()?{value:e.apiKey.trim()}:{},endpointUrl:dje(e),...e.provider===`VertexAI`&&e.gcpProjectId?.trim()?{gcpProjectId:e.gcpProjectId.trim()}:{},metadata:{models:e.customModels?{completions:e.customModels.filter(e=>e.kind===`completions`).map(e=>e.name),embeddings:e.customModels.filter(e=>e.kind===`embeddings`).map(e=>e.name)}:{completions:e.models?.completions??[],embeddings:e.models?.embeddings??[]}}}))},onSuccess:()=>{C.reset(),t?.(!1),a(!1)},onSettled:(e,t,n)=>m(`provider.created`,t?`failed`:`succeeded`,{provider:n.provider,completions_models:n.models?.completions?.length??0,embedding_models:n.models?.embeddings?.length??0,custom_models:n.customModels?.length??0})}),C=qD({defaultValues:b(),resolver:JD(x)}),{isDirty:w}=_D(C),T=C.watch(`provider`),E=(0,H.useCallback)(()=>{S.reset(),C.reset(),t?.(!1),a(!1)},[S,C,t]),D=LM(w,E);return(0,U.jsxs)(tb,{open:i,onOpenChange:e=>{e?(C.reset(b()),t?.(!0),o(()=>a(!0))):D.guardedClose()},children:[n?null:(0,U.jsx)(nb,{asChild:!0,children:s(e??(0,U.jsx)(X,{children:`Add Provider`}))}),(0,U.jsxs)(ib,{className:`sm:max-w-3xl max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Add AI Provider`}),(0,U.jsx)(cb,{children:Ant(T)}),(0,U.jsx)(YD,{error:S.error,className:`break-all`})]}),(0,U.jsx)(fY,{...C,children:(0,U.jsxs)(`form`,{onSubmit:C.handleSubmit(e=>{p(`ai-gateway-create-ai-provider-submitted`,{provider:e.provider}),S.mutate(e)}),className:`flex flex-col flex-1 overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto space-y-4 px-1`,children:(0,U.jsx)(qY,{form:C,mode:`create`,onProviderChange:e=>{Cnt(C.getValues(`label`),g(T))&&C.setValue(`label`,g(e),{shouldDirty:!0,shouldValidate:!0})}})}),(0,U.jsxs)(ob,{className:`mt-4`,children:[(0,U.jsx)(X,{type:`button`,variant:`ghost`,onClick:E,disabled:S.isPending,children:`Cancel`}),(0,U.jsx)(X,{type:`submit`,children:(0,U.jsxs)(rM,{loading:S.isPending,children:[`Create`,(0,U.jsx)(hP,{className:`bg-white/20`,children:(0,U.jsx)(mP,{onPress:C.handleSubmit(e=>S.mutate(e)),hotkey:`meta+Enter`})})]})})]})]})})]}),(0,U.jsx)(IM,{open:D.showConfirm,onOpenChange:D.setShowConfirm,onDiscard:D.handleDiscard})]})};function jnt({onFail:e}){return(0,H.useEffect)(()=>{e()},[e]),null}function Mnt({data:e}){let{account:t,project:n}=lb([]);return t&&n&&JE(e.provider)?(0,U.jsx)(sY,{fallback:()=>(0,U.jsx)(aX,{data:e}),children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(ZE,{provider:e.provider,description:e.description,loading:!0,onOpen:()=>{}}),children:(0,U.jsx)(Nnt,{data:e})})}):(0,U.jsx)(aX,{data:e})}function Nnt({data:e}){return YE(cY())?(0,U.jsx)(aX,{data:e}):(0,U.jsx)(ZE,{provider:e.provider,description:e.description,unavailableText:mje,onOpen:()=>{}})}function aX({data:e}){let[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1),a=(0,H.useCallback)(()=>i(!0),[]),{logEvent:o}=on(),{account:s,project:c}=lb([]),l=!!(s&&c);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ZE,{provider:e.provider,description:e.description,loading:t&&!r,disabled:!l,errorText:r?`Couldn’t open the Add AI Provider dialog — please try again.`:void 0,onOpen:()=>{l&&(o(`agent-z-ai-provider-card-clicked`,{account:s,project:c,provider:e.provider}),i(!1),n(!0))}}),t&&!r?(0,U.jsx)(sY,{blastRadius:`feature-dead`,fallback:()=>(0,U.jsx)(jnt,{onFail:a}),children:(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(iX,{defaultOpen:!0,initialValues:{provider:Pnt(e.provider),label:e.label,models:e.models,baseUrl:e.baseUrl,customModels:e.customModels},onOpenChange:e=>{e||n(!1)}})})}):null]})}function Pnt(e){if(e)return e.toLowerCase()===`custom`?qE:e}var Fnt=(e,t=0)=>e.flatMap(e=>[[e,t],...Fnt(e.children,t+1)]),Int=e=>{if(e.length===0)return[];let t=new Map,n=[];for(let n of e)t.set(n.id,{...n,children:[]});for(let r of e){let e=t.get(r.id);if(!e)continue;let i=r.parentId;i&&t.has(i)?t.get(i)?.children.push(e):n.push(e)}return n};function Lnt(e,t){return H.useReducer((e,n)=>t[e][n]??e,e)}var oX=`ScrollArea`,[Rnt,znt]=T(oX),[Bnt,sX]=Rnt(oX),Vnt=H.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=H.useState(null),[l,u]=H.useState(null),[d,f]=H.useState(null),[p,m]=H.useState(null),[h,g]=H.useState(null),[_,v]=H.useState(0),[y,b]=H.useState(0),[x,S]=H.useState(!1),[C,w]=H.useState(!1),T=ve(t,e=>c(e)),E=At(i);return(0,U.jsx)(Bnt,{scope:n,type:r,dir:E,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:x,onScrollbarXEnabledChange:S,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:C,onScrollbarYEnabledChange:w,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,U.jsx)(ce.div,{dir:E,...o,ref:T,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})});Vnt.displayName=oX;var Hnt=`ScrollAreaViewport`,Unt=H.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=sX(Hnt,n),s=ve(t,H.useRef(null),o.onViewportChange);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,U.jsx)(ce.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,U.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});Unt.displayName=Hnt;var cX=`ScrollAreaScrollbar`,Wnt=H.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=sX(cX,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return H.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,U.jsx)(Gnt,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,U.jsx)(Knt,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,U.jsx)(qnt,{...r,ref:t,forceMount:n}):i.type===`always`?(0,U.jsx)(lX,{...r,ref:t}):null});Wnt.displayName=cX;var Gnt=H.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=sX(cX,e.__scopeScrollArea),[a,o]=H.useState(!1);return H.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,U.jsx)(xt,{present:n||a,children:(0,U.jsx)(qnt,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Knt=H.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=sX(cX,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=mX(()=>c(`SCROLL_END`),100),[s,c]=Lnt(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return H.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),H.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,U.jsx)(xt,{present:n||s!==`hidden`,children:(0,U.jsx)(lX,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:hn(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:hn(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),qnt=H.forwardRef((e,t)=>{let n=sX(cX,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=H.useState(!1),s=e.orientation===`horizontal`,c=mX(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return hX(n.viewport,c),hX(n.content,c),(0,U.jsx)(xt,{present:r||a,children:(0,U.jsx)(lX,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),lX=H.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=sX(cX,e.__scopeScrollArea),a=H.useRef(null),o=H.useRef(0),[s,c]=H.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=rrt(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return irt(e,o.current,s,t)}return n===`horizontal`?(0,U.jsx)(Jnt,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=art(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,U.jsx)(Ynt,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=art(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),Jnt=H.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=sX(cX,e.__scopeScrollArea),[o,s]=H.useState(),c=H.useRef(null),l=ve(t,c,a.onScrollbarXChange);return H.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,U.jsx)(Qnt,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":pX(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),srt(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:fX(o.paddingLeft),paddingEnd:fX(o.paddingRight)}})}})}),Ynt=H.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=sX(cX,e.__scopeScrollArea),[o,s]=H.useState(),c=H.useRef(null),l=ve(t,c,a.onScrollbarYChange);return H.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,U.jsx)(Qnt,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":pX(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),srt(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:fX(o.paddingTop),paddingEnd:fX(o.paddingBottom)}})}})}),[Xnt,Znt]=Rnt(cX),Qnt=H.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:d,onResize:f,...p}=e,m=sX(cX,n),[h,g]=H.useState(null),_=ve(t,e=>g(e)),v=H.useRef(null),y=H.useRef(``),b=m.viewport,x=r.content-r.viewport,S=u(d),C=u(c),w=mX(f,10);function T(e){v.current&&l({x:e.clientX-v.current.left,y:e.clientY-v.current.top})}return H.useEffect(()=>{let e=e=>{let t=e.target;h?.contains(t)&&S(e,x)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[b,h,x,S]),H.useEffect(C,[r,C]),hX(h,w),hX(m.content,w),(0,U.jsx)(Xnt,{scope:n,scrollbar:h,hasThumb:i,onThumbChange:u(a),onThumbPointerUp:u(o),onThumbPositionChange:C,onThumbPointerDown:u(s),children:(0,U.jsx)(ce.div,{...p,ref:_,style:{position:`absolute`,...p.style},onPointerDown:hn(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),v.current=h.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,m.viewport&&(m.viewport.style.scrollBehavior=`auto`),T(e))}),onPointerMove:hn(e.onPointerMove,T),onPointerUp:hn(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=y.current,m.viewport&&(m.viewport.style.scrollBehavior=``),v.current=null})})})}),uX=`ScrollAreaThumb`,$nt=H.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Znt(uX,e.__scopeScrollArea);return(0,U.jsx)(xt,{present:n||i.hasThumb,children:(0,U.jsx)(ert,{ref:t,...r})})}),ert=H.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=sX(uX,n),o=Znt(uX,n),{onThumbPositionChange:s}=o,c=ve(t,e=>o.onThumbChange(e)),l=H.useRef(void 0),u=mX(()=>{l.current&&=(l.current(),void 0)},100);return H.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=crt(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,U.jsx)(ce.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:hn(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:hn(e.onPointerUp,o.onThumbPointerUp)})});$nt.displayName=uX;var dX=`ScrollAreaCorner`,trt=H.forwardRef((e,t)=>{let n=sX(dX,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,U.jsx)(nrt,{...e,ref:t}):null});trt.displayName=dX;var nrt=H.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=sX(dX,n),[a,o]=H.useState(0),[s,c]=H.useState(0),l=!!(a&&s);return hX(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),hX(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,U.jsx)(ce.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function fX(e){return e?parseInt(e,10):0}function rrt(e,t){let n=e/t;return isNaN(n)?0:n}function pX(e){let t=rrt(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function irt(e,t,n,r=`ltr`){let i=pX(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return ort([c,l],d)(e)}function art(e,t,n=`ltr`){let r=pX(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=bq(e,n===`ltr`?[0,o]:[o*-1,0]);return ort([0,o],[0,s])(c)}function ort(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function srt(e,t){return e>0&&e<t}var crt=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function mX(e,t){let n=u(e),r=H.useRef(0);return H.useEffect(()=>()=>window.clearTimeout(r.current),[]),H.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function hX(e,t){let n=u(t);bt(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var lrt=Vnt,urt=Unt,drt=trt;function frt({className:e,children:t,...n}){return(0,U.jsxs)(lrt,{"data-slot":`scroll-area`,className:W(`relative`,e),...n,children:[(0,U.jsx)(urt,{"data-slot":`scroll-area-viewport`,className:`focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-hidden focus-visible:ring-[3px] focus-visible:outline-1`,children:t}),(0,U.jsx)(prt,{}),(0,U.jsx)(drt,{})]})}function prt({className:e,orientation:t=`vertical`,...n}){return(0,U.jsx)(Wnt,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:W(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,U.jsx)($nt,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var mrt=`device-mobile.robot.broom.browsers.building.briefcase.bug.brain.brackets-curly.brackets-angle.book-open-text.at.android-logo.app-store-logo.angular-logo.bank.asterisk.app-window.wrench.traffic-signal.windows-logo.warning.siren.shield-check.shield-star.seal-check.scan-smiley.pulse.plugs.phone.notepad.network.megaphone.lock-laminated.lock-key.key.house-line.heart.folder-open.flag-checkered.floppy-disk-back.fingerprint.files.file-sql.file-py.file-vue.file-csharp.eyes.download.detective.database.desktop.currency-dollar-simple.cookie.confetti.coins.command.code-simple.code-block.clover.cloud.clock-clockwise.clock.circles-three-plus.circles-three.circles-four.chart-polar.chart-scatter.chart-line-up.chart-line-down.chart-line.chart-bar-horizontal.chart-donut.chat-circle-dots.chat-centered-text`.split(`.`),gX=({icon:e,className:t,size:n})=>{switch(e){case`device-mobile`:return(0,U.jsx)(ome,{weight:`regular`,className:t,size:n});case`robot`:return(0,U.jsx)(Fme,{weight:`regular`,className:t,size:n});case`broom`:return(0,U.jsx)(Ape,{weight:`regular`,className:t,size:n});case`browsers`:return(0,U.jsx)(jpe,{weight:`regular`,className:t,size:n});case`building`:return(0,U.jsx)(Npe,{weight:`regular`,className:t,size:n});case`briefcase`:return(0,U.jsx)(kpe,{weight:`regular`,className:t,size:n});case`bug`:return(0,U.jsx)(Mpe,{weight:`regular`,className:t,size:n});case`brain`:return(0,U.jsx)(Ope,{weight:`regular`,className:t,size:n});case`brackets-curly`:return(0,U.jsx)(Dpe,{weight:`regular`,className:t,size:n});case`brackets-angle`:return(0,U.jsx)(Epe,{weight:`regular`,className:t,size:n});case`book-open-text`:return(0,U.jsx)(ly,{weight:`regular`,className:t,size:n});case`at`:return(0,U.jsx)(Cpe,{weight:`regular`,className:t,size:n});case`android-logo`:return(0,U.jsx)(gpe,{weight:`regular`,className:t,size:n});case`app-store-logo`:return(0,U.jsx)(vpe,{weight:`regular`,className:t,size:n});case`angular-logo`:return(0,U.jsx)(_pe,{weight:`regular`,className:t,size:n});case`bank`:return(0,U.jsx)(wpe,{weight:`regular`,className:t,size:n});case`asterisk`:return(0,U.jsx)(Spe,{weight:`regular`,className:t,size:n});case`app-window`:return(0,U.jsx)(ype,{weight:`regular`,className:t,size:n});case`wrench`:return(0,U.jsx)(Dy,{weight:`regular`,className:t,size:n});case`traffic-signal`:return(0,U.jsx)(Bme,{weight:`regular`,className:t,size:n});case`windows-logo`:return(0,U.jsx)(Hme,{weight:`regular`,className:t,size:n});case`warning`:return(0,U.jsx)(wy,{weight:`regular`,className:t,size:n});case`siren`:return(0,U.jsx)(Rme,{weight:`regular`,className:t,size:n});case`shield-check`:return(0,U.jsx)(by,{weight:`regular`,className:t,size:n});case`shield-star`:return(0,U.jsx)(xy,{weight:`regular`,className:t,size:n});case`seal-check`:return(0,U.jsx)(Lme,{weight:`regular`,className:t,size:n});case`scan-smiley`:return(0,U.jsx)(Ime,{weight:`regular`,className:t,size:n});case`pulse`:return(0,U.jsx)(Pme,{weight:`regular`,className:t,size:n});case`plugs`:return(0,U.jsx)(Mme,{weight:`regular`,className:t,size:n});case`phone`:return(0,U.jsx)(jme,{weight:`regular`,className:t,size:n});case`notepad`:return(0,U.jsx)(kme,{weight:`regular`,className:t,size:n});case`network`:return(0,U.jsx)(Ome,{weight:`regular`,className:t,size:n});case`megaphone`:return(0,U.jsx)(Dme,{weight:`regular`,className:t,size:n});case`lock-laminated`:return(0,U.jsx)(Tme,{weight:`regular`,className:t,size:n});case`lock-key`:return(0,U.jsx)(vy,{weight:`regular`,className:t,size:n});case`key`:return(0,U.jsx)(gy,{weight:`regular`,className:t,size:n});case`house-line`:return(0,U.jsx)(Sme,{weight:`regular`,className:t,size:n});case`heart`:return(0,U.jsx)(xme,{weight:`regular`,className:t,size:n});case`folder-open`:return(0,U.jsx)(vme,{weight:`regular`,className:t,size:n});case`flag-checkered`:return(0,U.jsx)(gme,{weight:`regular`,className:t,size:n});case`floppy-disk-back`:return(0,U.jsx)(_me,{weight:`regular`,className:t,size:n});case`fingerprint`:return(0,U.jsx)(py,{weight:`regular`,className:t,size:n});case`files`:return(0,U.jsx)(hme,{weight:`regular`,className:t,size:n});case`file-sql`:return(0,U.jsx)(fme,{weight:`regular`,className:t,size:n});case`file-py`:return(0,U.jsx)(dme,{weight:`regular`,className:t,size:n});case`file-vue`:return(0,U.jsx)(mme,{weight:`regular`,className:t,size:n});case`file-csharp`:return(0,U.jsx)(ume,{weight:`regular`,className:t,size:n});case`eyes`:return(0,U.jsx)(cme,{weight:`regular`,className:t,size:n});case`download`:return(0,U.jsx)(sme,{weight:`regular`,className:t,size:n});case`detective`:return(0,U.jsx)(ame,{weight:`regular`,className:t,size:n});case`database`:return(0,U.jsx)(rme,{weight:`regular`,className:t,size:n});case`desktop`:return(0,U.jsx)(ime,{weight:`regular`,className:t,size:n});case`currency-dollar-simple`:return(0,U.jsx)(nme,{weight:`regular`,className:t,size:n});case`cookie`:return(0,U.jsx)(tme,{weight:`regular`,className:t,size:n});case`confetti`:return(0,U.jsx)(eme,{weight:`regular`,className:t,size:n});case`coins`:return(0,U.jsx)(Qpe,{weight:`regular`,className:t,size:n});case`command`:return(0,U.jsx)($pe,{weight:`regular`,className:t,size:n});case`code-simple`:return(0,U.jsx)(Zpe,{weight:`regular`,className:t,size:n});case`code-block`:return(0,U.jsx)(fy,{weight:`regular`,className:t,size:n});case`clover`:return(0,U.jsx)(Xpe,{weight:`regular`,className:t,size:n});case`cloud`:return(0,U.jsx)(Ype,{weight:`regular`,className:t,size:n});case`clock-clockwise`:return(0,U.jsx)(Jpe,{weight:`regular`,className:t,size:n});case`clock`:return(0,U.jsx)(qpe,{weight:`regular`,className:t,size:n});case`circles-three-plus`:return(0,U.jsx)(Kpe,{weight:`regular`,className:t,size:n});case`circles-three`:return(0,U.jsx)(Gpe,{weight:`regular`,className:t,size:n});case`circles-four`:return(0,U.jsx)(Wpe,{weight:`regular`,className:t,size:n});case`chart-polar`:return(0,U.jsx)(zpe,{weight:`regular`,className:t,size:n});case`chart-scatter`:return(0,U.jsx)(dy,{weight:`regular`,className:t,size:n});case`chart-line-up`:return(0,U.jsx)(Rpe,{weight:`regular`,className:t,size:n});case`chart-line-down`:return(0,U.jsx)(Lpe,{weight:`regular`,className:t,size:n});case`chart-line`:return(0,U.jsx)(Ipe,{weight:`regular`,className:t,size:n});case`chart-bar-horizontal`:return(0,U.jsx)(Ppe,{weight:`regular`,className:t,size:n});case`chart-donut`:return(0,U.jsx)(Fpe,{weight:`regular`,className:t,size:n});case`chat-circle-dots`:return(0,U.jsx)(Vpe,{weight:`regular`,className:t,size:n});case`chat-centered-text`:return(0,U.jsx)(Bpe,{weight:`regular`,className:t,size:n});default:return null}},hrt=({className:e,iconClassName:t,value:n,onChange:r,open:i,name:a,onOpenChange:o})=>{let[s,c]=(0,H.useState)(``),l=NY(s,mrt,{getText:e=>[e]}),[u,d]=(0,H.useState)(i??!1),f=o??d;return(0,U.jsxs)(dT,{open:u,onOpenChange:f,children:[(0,U.jsx)(fT,{asChild:!0,children:(0,U.jsxs)(X,{variant:`ghost`,className:W(`size-10 shrink-0`,e),children:[(0,U.jsx)(gX,{icon:n??`scan-smiley`,className:t}),(0,U.jsx)(`input`,{type:`hidden`,name:a,value:n})]})}),(0,U.jsxs)(pT,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(EY,{className:`h-8`,children:[(0,U.jsx)(kY,{placeholder:`Search`,autoFocus:!0,value:s,onChange:e=>c(e.target.value)}),(0,U.jsx)(DY,{align:`inline-start`,children:(0,U.jsx)(kf,{})}),s&&(0,U.jsx)(DY,{align:`inline-end`,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon-xs`,onClick:()=>c(``),children:(0,U.jsx)(ep,{})})})]}),(0,U.jsx)(frt,{className:`h-[250px]`,children:(0,U.jsx)(`div`,{className:`grid grid-cols-6 place-items-center-safe`,children:l.map(e=>(0,U.jsx)(X,{variant:`ghost`,size:`icon-lg`,onClick:()=>{r(e),f(!1)},children:(0,U.jsx)(gX,{icon:e,className:`size-5`})},e))})})]})]})},_X=`ai-gateway-auth-v2-inbound`,grt=new Set([_X,`ai-gateway-configuration-loader-v2-inbound`,`ai-gateway-configuration-executor-v2-inbound`]),_rt=e=>grt.has(e),vrt={canEdit:!1,canRemove:!1},yrt=[_X],brt=()=>yrt.map(e=>({name:e,permissions:{...vrt}})),xrt=e=>e.at(0)?.metadata?.deploymentName||void 0,Srt=()=>{let e=TY();return xrt(fb(mt.bucketConfigurations(e)).data??[])},Crt=()=>{let e=TY(),t=fb(mt.bucketConfigurationTeams(e)),n=(0,H.useMemo)(()=>Int(t.data),[t.data]);return{teams:t.data,tree:n}},wrt=`__top-level__`,Trt=.75,Ert=({team:e})=>{let t=e.metadata?.icon;return t?(0,U.jsx)(gX,{icon:t,size:16,className:`shrink-0`}):(0,U.jsx)(Xf,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})},Drt=e=>{let t=[];return e.map(([e,n])=>{t.length=n;let r=[...t];return t[n]=e.label,{team:e,depth:n,path:r}})},Ort=(e,t)=>[...e,t].join(` / `),krt=({options:e,value:t,onChange:n})=>{let[r,i]=(0,H.useState)(!1),a=(0,H.useMemo)(()=>Drt(e),[e]),o=a.find(({team:e})=>e.id===t),s=e=>{n(e),i(!1)};return(0,U.jsxs)(dT,{open:r,onOpenChange:i,modal:!1,children:[(0,U.jsx)(fT,{asChild:!0,children:(0,U.jsxs)(X,{type:`button`,variant:`outline`,role:`combobox`,"aria-label":`Parent team`,"aria-expanded":r,className:`w-full justify-between border-input font-normal`,children:[(0,U.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:o?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ert,{team:o.team}),(0,U.jsx)(`span`,{className:`truncate`,children:o.team.label}),o.path.length>0?(0,U.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[`in `,o.path.join(` / `)]}):null]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hf,{className:`size-4 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`No parent team`})]})}),(0,U.jsx)(td,{className:`ml-2 size-4 shrink-0 opacity-50`})]})}),(0,U.jsx)(pT,{className:`w-(--radix-popover-trigger-width) p-0`,side:`bottom`,align:`start`,children:(0,U.jsxs)(Rw,{children:[(0,U.jsx)(zw,{placeholder:`Search teams...`,className:`h-9`}),(0,U.jsxs)(Bw,{className:`max-h-[280px]`,children:[(0,U.jsx)(Vw,{className:`py-6 text-center text-sm text-muted-foreground`,children:`No teams match.`}),(0,U.jsxs)(Uw,{value:`No parent team top-level`,onSelect:()=>s(wrt),className:`flex cursor-pointer items-center gap-2`,children:[(0,U.jsx)(hf,{className:`size-4 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`flex-1 truncate text-muted-foreground`,children:`No parent team`}),(0,U.jsx)(ed,{className:W(`size-4 shrink-0 text-muted-foreground`,o?`opacity-0`:`opacity-100`)})]}),a.map(({team:e,depth:n,path:r})=>(0,U.jsxs)(Uw,{value:`${Ort(r,e.label)} ${e.id}`,"aria-label":Ort(r,e.label),onSelect:()=>s(e.id),className:`flex cursor-pointer items-center gap-2`,style:{paddingLeft:`${.5+n*Trt}rem`},children:[(0,U.jsx)(Ert,{team:e}),(0,U.jsx)(`span`,{className:`truncate`,children:e.label}),r.length>0?(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:[`in `,r.join(` / `)]}):(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsx)(ed,{className:W(`size-4 shrink-0 text-muted-foreground`,e.id===t?`opacity-100`:`opacity-0`)})]},e.id))]})]})})]})};Rm({teamName:Pm().min(1,`Team name is required`),icon:Pm(),parentTeamId:Pm().optional()});var Art=({children:e,parentId:t,...n})=>{let{project:r}=hp([`project`]);return!(fb(mt.permissionsAiTeam(t??``)).data?.includes(`can_edit`)??!1)&&!n.defaultOpen?(0,U.jsx)(vX,{children:e}):(0,U.jsx)(Prt,{...n,parentId:t,applyPolicyTemplate:KE(r),children:e})},jrt=({children:e,...t})=>{let{account:n,project:r}=lb([`account`,`project`]);return!(fb(mt.permissionsProject(n,r)).data?.includes(`ai_team_editor`)??!1)&&!t.defaultOpen?(0,U.jsx)(vX,{children:e}):(0,U.jsx)(Mrt,{...t,children:e})},Mrt=({children:e,...t})=>{let n=TY(),{project:r}=hp([`project`]),i=fb(mt.bucketConfigurations(n)).data?.at(0)?.id,{tree:a}=Crt(),o=(0,H.useMemo)(()=>Fnt(a),[a]);return i?(0,U.jsx)(Prt,{...t,parentId:i,rootId:i,parentOptions:o,applyPolicyTemplate:KE(r),children:e}):(0,U.jsx)(vX,{reason:`Deploy this gateway to production before adding teams`,children:e})},vX=({children:e,reason:t=`You don't have permission to add teams`})=>{let n=e??(0,U.jsx)(X,{variant:`default`,children:`Create Team`});return(0,U.jsxs)(SN,{children:[(0,U.jsx)(CN,{asChild:!0,children:(0,U.jsx)(`span`,{className:`inline-flex`,children:(0,H.isValidElement)(n)?(0,H.cloneElement)(n,{disabled:!0}):n})}),(0,U.jsx)(wN,{children:t})]})},Nrt=({applyPolicyTemplate:e,parentId:t,rootId:n})=>!e||!t?{}:t===n?{inboundPolicyChain:brt()}:{inheritPolicyTemplate:!0},Prt=({children:e,parentId:t,rootId:n,parentOptions:r,applyPolicyTemplate:i=!1,disabled:a,teamsBasePath:o,defaultOpen:s=!1,initialName:c,onOpenChange:l})=>{let{account:u,project:d}=lb([`account`,`project`]),{logEvent:f}=on(),p=CY(),m=qD({defaultValues:{teamName:c??``,parentTeamId:wrt}}),h=Dt(),g=TY(),_=Srt(),v=Xa(),[y,b]=(0,H.useState)(s),x=je({mutationFn:async e=>{let r=(e.parentTeamId&&e.parentTeamId!==`__top-level__`?e.parentTeamId:void 0)??t;return await h.fetch(tn.ai.createBucketConfiguration(g,{label:e.teamName,parentId:r,metadata:{version:`1`,deploymentName:_,icon:e.icon,...Nrt({applyPolicyTemplate:i,parentId:r,rootId:n})}}))},onSuccess:e=>{m.reset(),l?.(!1),b(!1),v(`${o??`/${u}/${d}/ai/teams`}/${e.id}`)},onSettled:(e,t)=>p(`team.created`,t?`failed`:`succeeded`)});return(0,U.jsxs)(tb,{open:y,onOpenChange:e=>{b(e),l?.(e),e||m.reset()},children:[s?null:(0,U.jsx)(nb,{asChild:!0,disabled:a,children:e??(0,U.jsx)(X,{variant:`default`,children:`Create Team`})}),(0,U.jsxs)(ib,{children:[(0,U.jsx)(fY,{...m,children:(0,U.jsxs)(`form`,{id:`new-team`,onSubmit:m.handleSubmit(e=>{f(`ai-gateway-create-team-submitted`,{teamName:e.teamName,icon:e.icon}),x.mutate(e)}),className:`flex flex-col gap-4`,children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Create Team`}),(0,U.jsx)(cb,{children:`Organize apps and control access across your organization. Teams let you enforce usage limits and manage costs. Create as many as you need.`})]}),(0,U.jsx)(YD,{error:x.error}),(0,U.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,U.jsx)(RDe,{}),(0,U.jsx)(mY,{control:m.control,name:`icon`,render:({field:e})=>(0,U.jsx)(hrt,{onChange:e.onChange,name:`icon`,value:e.value,iconClassName:`size-6`,className:W(`h-auto`,e.value?`border-transparent`:`border-dashed border-border text-neutral-300`)})}),(0,U.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2`,children:[r&&r.length>0?(0,U.jsx)(mY,{control:m.control,name:`parentTeamId`,render:({field:e})=>(0,U.jsx)(krt,{options:r,value:e.value??`__top-level__`,onChange:e.onChange})}):null,(0,U.jsx)(mY,{control:m.control,name:`teamName`,render:({field:e})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(iM,{placeholder:`John's Team`,autoFocus:!0,...e}),(0,U.jsx)(xY,{})]})})]})]})]})}),(0,U.jsxs)(ob,{children:[(0,U.jsx)(rb,{asChild:!0,children:(0,U.jsx)(X,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,U.jsx)(X,{type:`submit`,form:`new-team`,children:(0,U.jsx)(rM,{loading:x.isPending,children:`Create Team`})})]})]})]})};function Frt({data:e}){let[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1),a=(0,H.useCallback)(()=>i(!0),[]),{logEvent:o}=on(),{account:s,project:c}=lb([]),l=!!(s&&c),u=(0,H.useCallback)(e=>{e||n(!1)},[]);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Kje,{name:e.name,isSubTeam:!!e.parentTeamId,description:e.description,loading:t&&!r,disabled:!l,errorText:r?`Couldn’t open the Create Team dialog — please try again, or create it from AI Gateway → Teams.`:void 0,onOpen:()=>{l&&(o(`agent-z-ai-team-card-clicked`,{account:s,project:c,isSubTeam:!!e.parentTeamId}),i(!1),n(!0))}}),t&&!r?(0,U.jsx)(sY,{blastRadius:`feature-dead`,fallback:()=>(0,U.jsx)(jnt,{onFail:a}),children:(0,U.jsx)(H.Suspense,{fallback:null,children:e.parentTeamId?(0,U.jsx)(Art,{parentId:e.parentTeamId,defaultOpen:!0,initialName:e.name,onOpenChange:u}):(0,U.jsx)(jrt,{defaultOpen:!0,initialName:e.name,onOpenChange:u})})}):null]})}var Irt=SY(`0123456789abcdefghijklmnopqrstuvwxyz`,4),yX=(e,{method:t,path:n,existingOperationIds:r})=>{if(!t||!n)return Ktt(6);let i=n.split(`/`).filter(e=>e.length>0).join(`-`),a=(e.summary?$Y(e.summary,{lowercase:!0}):``)||$Y(`${t}-${i}`);return r?.has(a)?`${a}-${Irt()}`:a},Lrt=[`get`,`put`,`post`,`delete`,`options`,`head`,`patch`,`trace`];function Rrt(e,t=new Set){let n=new Set(t);for(let t of Object.values(e.paths??{}))if(t)for(let e of Lrt){let r=t[e];r?.operationId&&n.add(r.operationId)}let r={};for(let[t,i]of Object.entries(e.paths??{})){if(!i){r[t]=i;continue}let e={...i};for(let r of Lrt){let i=e[r];if(i&&!i.operationId){let a=yX(i,{method:r,path:t,existingOperationIds:n});n.add(a),e[r]={...i,operationId:a}}}r[t]=e}return{...e,paths:r}}var zrt=`x-zuplo`,bX=`x-internal`,Brt=`x-mcp-server`,xX=`x-graphql`,SX=`${zrt}-path`,CX=`${zrt}-route`,Vrt=e=>e?.export===`mcpServerHandler`&&(()=>{let t=e.options;if(!t||typeof t!=`object`)return!1;let n=t;return Array.isArray(n.openApiFilePaths)&&n.openApiFilePaths.length>0})(),Hrt=e=>e?.export===`mcpServerHandler`&&(()=>{let t=e.options;if(!t||typeof t!=`object`)return!1;let n=t;return Array.isArray(n.files)&&n.files.length>0})(),wX=e=>e?.export===`mcpServerHandler`,TX=e=>e?.export===`McpProxyHandler`||e?.export===`McpVirtualServerHandler`||e?.export===`mcpVirtualServerHandler`,EX=e=>{let t=e[CX]?.handler;return wX(t)||TX(t)};function Urt(e){return e==null}function Wrt(e){return typeof e==`object`&&!!e}function Grt(e){return Array.isArray(e)?e:Urt(e)?[]:[e]}function Krt(e,t){var n,r,i,a;if(t)for(a=Object.keys(t),n=0,r=a.length;n<r;n+=1)i=a[n],e[i]=t[i];return e}function qrt(e,t){var n=``,r;for(r=0;r<t;r+=1)n+=e;return n}function Jrt(e){return e===0&&1/e==-1/0}var DX={isNothing:Urt,isObject:Wrt,toArray:Grt,repeat:qrt,isNegativeZero:Jrt,extend:Krt};function Yrt(e,t){var n=``,r=e.reason||`(unknown reason)`;return e.mark?(e.mark.name&&(n+=`in "`+e.mark.name+`" `),n+=`(`+(e.mark.line+1)+`:`+(e.mark.column+1)+`)`,!t&&e.mark.snippet&&(n+=`
318
318
 
319
319
  `+e.mark.snippet),r+` `+n):r}function OX(e,t){Error.call(this),this.name=`YAMLException`,this.reason=e,this.mark=t,this.message=Yrt(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=Error().stack||``}OX.prototype=Object.create(Error.prototype),OX.prototype.constructor=OX,OX.prototype.toString=function(e){return this.name+`: `+Yrt(this,e)};var kX=OX;function AX(e,t,n,r,i){var a=``,o=``,s=Math.floor(i/2)-1;return r-t>s&&(a=` ... `,t=r-s+a.length),n-r>s&&(o=` ...`,n=r+s-o.length),{str:a+e.slice(t,n).replace(/\t/g,`→`)+o,pos:r-t+a.length}}function jX(e,t){return DX.repeat(` `,t-e.length)+e}function Xrt(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||=79,typeof t.indent!=`number`&&(t.indent=1),typeof t.linesBefore!=`number`&&(t.linesBefore=3),typeof t.linesAfter!=`number`&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],i=[],a,o=-1;a=n.exec(e.buffer);)i.push(a.index),r.push(a.index+a[0].length),e.position<=a.index&&o<0&&(o=r.length-2);o<0&&(o=r.length-1);var s=``,c,l,u=Math.min(e.line+t.linesAfter,i.length).toString().length,d=t.maxLength-(t.indent+u+3);for(c=1;c<=t.linesBefore&&!(o-c<0);c++)l=AX(e.buffer,r[o-c],i[o-c],e.position-(r[o]-r[o-c]),d),s=DX.repeat(` `,t.indent)+jX((e.line-c+1).toString(),u)+` | `+l.str+`
320
320
  `+s;for(l=AX(e.buffer,r[o],i[o],e.position,d),s+=DX.repeat(` `,t.indent)+jX((e.line+1).toString(),u)+` | `+l.str+`
@@ -479,7 +479,7 @@ export function runtimeInit(runtime: RuntimeExtensions) {
479
479
  `,`
480
480
  +`).split(`
481
481
  `));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,H.useEffect)(()=>{let n=t?.target??Uwt,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)&&qSt(e))return!1;let n=Gwt(e.code,s);if(a.current.add(e[n]),Wwt(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=Gwt(e.code,s);Wwt(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 Wwt(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function Gwt(e,t){return t.includes(e)?`code`:`key`}var Kwt=()=>{let e=X2();return(0,H.useMemo)(()=>({zoomIn:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=b2(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 _2(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=v2(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function qwt(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)Jwt(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 Jwt(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 Ywt(e,t){return qwt(e,t)}function Xwt(e,t){return qwt(e,t)}function t4(e,t){return{id:e,type:`select`,selected:t}}function n4(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(t4(a.id,e)))}return r}function Zwt({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 Qwt(e){return{id:e.id,type:`remove`}}var $wt=e=>TSt(e),eTt=e=>wSt(e);function tTt(e){return(0,H.forwardRef)(e)}function nTt(e){let[t,n]=(0,H.useState)(BigInt(0)),[r]=(0,H.useState)(()=>rTt(()=>n(e=>e+BigInt(1))));return $2(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function rTt(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var iTt=(0,H.createContext)(null);function aTt({children:e}){let t=X2(),n=nTt((0,H.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=Zwt({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=nTt((0,H.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(Zwt({items:s,lookup:o}))},[])),i=(0,H.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,U.jsx)(iTt.Provider,{value:i,children:e})}function oTt(){let e=(0,H.useContext)(iTt);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var sTt=e=>!!e.panZoom;function r4(){let e=Kwt(),t=X2(),n=oTt(),r=Y2(sTt),i=(0,H.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=$wt(e)?e:n.get(e.id),a=i.parentId?VSt(i.position,i.measured,i.parentId,n,r):i.position;return f2({...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&&$wt(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&&eTt(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 jSt({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(Qwt);o?.(f),c(e)}if(m){let e=d.map(Qwt);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=ISt(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=f2(s?r:a),l=m2(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=ISt(e)?e:a(e);if(!r)return!1;let i=m2(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 ESt(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??USt();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,H.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var cTt=e=>e.selected,lTt=typeof window<`u`?window:void 0;function uTt({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=X2(),{deleteElements:r}=r4(),i=e4(e,{actInsideInputWithModifier:!1}),a=e4(t,{target:lTt});(0,H.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(cTt),edges:e.filter(cTt)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,H.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function dTt(e){let t=X2();(0,H.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=T2(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,Y0.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 i4={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},fTt=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function pTt({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=Q0.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=X2(),S=(0,H.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=Y2(fTt,q2),E=e4(f),D=(0,H.useRef)();dTt(S);let O=(0,H.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,H.useEffect)(()=>{if(S.current){D.current=QCt({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,H.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,U.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:i4,children:m})}var mTt=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function hTt(){let{userSelectionActive:e,userSelectionRect:t}=Y2(mTt,q2);return e&&t?(0,U.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var a4=(e,t)=>n=>{n.target===t.current&&e?.(n)},gTt=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function _Tt({isSelecting:e,selectionKeyPressed:t,selectionMode:n=$0.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=X2(),{userSelectionActive:g,elementsSelectable:_,dragging:v,connectionInProgress:y}=Y2(gTt,q2),b=_&&(e||g),x=(0,H.useRef)(null),S=(0,H.useRef)(),C=(0,H.useRef)(new Set),w=(0,H.useRef)(new Set),T=(0,H.useRef)(!1),E=e=>{if(T.current||y){T.current=!1;return}c?.(e),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},D=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}l?.(e)},O=u?e=>u(e):void 0;return(0,U.jsxs)(`div`,{className:U1([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:v,selection:e}]),onClick:b?void 0:a4(E,x),onContextMenu:a4(D,x),onWheel:a4(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}=E2(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(o2(s,y,a,n===$0.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)}}HSt(b,C.current)||u(n4(s,C.current,!0)),HSt(x,w.current)||d(n4(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}=E2(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:i4,children:[m,(0,U.jsx)(hTt,{})]})}function o4({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`,Y0.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function vTt({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=X2(),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)();return(0,H.useEffect)(()=>{u.current=MCt({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{o4({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,H.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var yTt=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function bTt(){let e=X2();return(0,H.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=yTt(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=g2(t,i));let{position:a,positionAbsolute:s}=ASt({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 s4=(0,H.createContext)(null),xTt=s4.Provider;s4.Consumer;var STt=()=>(0,H.useContext)(s4),CTt=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),wTt=(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===Z0.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function TTt({type:e=`source`,position:t=n2.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=X2(),_=STt(),{connectOnClick:v,noPanClassName:y,rfId:b}=Y2(CTt,q2),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=Y2(wTt(_,m,e),q2);_||g.getState().onError?.(`010`,Y0.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(iCt(i,e))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=JSt(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();R2.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=GSt(t.target),h=n||c,{connection:v,isValid:y}=R2.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})};return(0,U.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:U1([`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 c4=(0,H.memo)(tTt(TTt));function ETt({data:e,isConnectable:t,sourcePosition:n=n2.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[e?.label,(0,U.jsx)(c4,{type:`source`,position:n,isConnectable:t})]})}function DTt({data:e,isConnectable:t,targetPosition:n=n2.Top,sourcePosition:r=n2.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(c4,{type:`target`,position:n,isConnectable:t}),e?.label,(0,U.jsx)(c4,{type:`source`,position:r,isConnectable:t})]})}function OTt(){return null}function kTt({data:e,isConnectable:t,targetPosition:n=n2.Top}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(c4,{type:`target`,position:n,isConnectable:t}),e?.label]})}var l4={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ATt={input:ETt,default:DTt,output:kTt,group:OTt};function jTt(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 MTt=e=>{let{width:t,height:n,x:r,y:i}=a2(e.nodeLookup,{filter:e=>!!e.selected});return{width:h2(t)?t:null,height:h2(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 NTt({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=X2(),{width:i,height:a,transformString:o,userSelectionActive:s}=Y2(MTt,q2),c=bTt(),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(vTt({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,U.jsx)(`div`,{className:U1([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,U.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(l4,e.key)&&(e.preventDefault(),c({direction:l4[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var PTt=typeof window<`u`?window:void 0,FTt=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function ITt({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}=Y2(FTt,q2),R=e4(l,{target:PTt}),z=e4(h,{target:PTt}),B=z||w,ee=z||b,V=u&&B!==!0,te=R||L||V;return uTt({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,U.jsx)(pTt,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:ee,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!R&&B,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,zoomActivationKeyCode:g,preventScrolling:k,noWheelClassName:j,noPanClassName:M,onViewportChange:P,isControlledViewport:F,paneClickDistance:s,selectionOnDrag:V,children:(0,U.jsxs)(_Tt,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:B,isSelecting:!!te,selectionMode:d,selectionKeyPressed:R,paneClickDistance:s,selectionOnDrag:V,children:[e,I&&(0,U.jsx)(NTt,{onSelectionContextMenu:A,noPanClassName:M,disableKeyboardA11y:N})]})})}ITt.displayName=`FlowRenderer`;var LTt=(0,H.memo)(ITt),RTt=e=>t=>e?o2(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 zTt(e){return Y2((0,H.useCallback)(RTt(e),[e]),q2)}var BTt=e=>e.updateNodeInternals;function VTt(){let e=Y2(BTt),[t]=(0,H.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,H.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function HTt({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=X2(),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(e.sourcePosition),c=(0,H.useRef)(e.targetPosition),l=(0,H.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,H.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,H.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,H.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function UTt({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}=Y2(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},q2),S=y.type||`default`,C=g?.[S]||ATt[S];C===void 0&&(v?.(`003`,Y0.error003(S)),S=`default`,C=g?.default||ATt.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=X2(),k=BSt(y),A=HTt({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=vTt({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=bTt();if(y.hidden)return null;let N=C2(y),P=jTt(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,ee=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&o4({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},V=t=>{if(!(qSt(t.nativeEvent)||m)){if(ySt.includes(t.key)&&T)o4({id:e,store:O,unselect:t.key===`Escape`,nodeRef:A});else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(l4,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:l4[t.key],factor:t.shiftKey?4:1})}}},te=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(o2(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,U.jsx)(`div`,{className:U1([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:ee,onDoubleClick:B,onKeyDown:D?V:void 0,tabIndex:D?0:void 0,onFocus:D?te:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${Swt}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,U.jsx)(xTt,{value:e,children:(0,U.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var WTt=(0,H.memo)(UTt),GTt=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function KTt(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=Y2(GTt,q2),o=zTt(e.onlyRenderVisibleElements),s=VTt();return(0,U.jsx)(`div`,{className:`react-flow__nodes`,style:i4,children:o.map(o=>(0,U.jsx)(WTt,{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))})}KTt.displayName=`NodeRenderer`;var qTt=(0,H.memo)(KTt);function JTt(e){return Y2((0,H.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&tCt({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),q2)}var YTt=({color:e=`none`,strokeWidth:t=1})=>(0,U.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),XTt=({color:e=`none`,strokeWidth:t=1})=>(0,U.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),ZTt={[t2.Arrow]:YTt,[t2.ArrowClosed]:XTt};function QTt(e){let t=X2();return(0,H.useMemo)(()=>Object.prototype.hasOwnProperty.call(ZTt,e)?ZTt[e]:(t.getState().onError?.(`009`,Y0.error009(e)),null),[e])}var $Tt=({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=QTt(t);return c?(0,U.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,U.jsx)(c,{color:n,strokeWidth:o})}):null},eEt=({defaultColor:e,rfId:t})=>{let n=Y2(e=>e.edges),r=Y2(e=>e.defaultEdgeOptions),i=(0,H.useMemo)(()=>hCt(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,U.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,U.jsx)(`defs`,{children:i.map(e=>(0,U.jsx)($Tt,{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};eEt.displayName=`MarkerDefinitions`;var tEt=(0,H.memo)(eEt);function nEt({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,H.useState)({x:1,y:0,width:0,height:0}),p=U1([`react-flow__edge-textwrapper`,l]),m=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,U.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,U.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,U.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}nEt.displayName=`EdgeText`;var rEt=(0,H.memo)(nEt);function u4({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{...u,d:e,fill:`none`,className:U1([`react-flow__edge-path`,u.className])}),l?(0,U.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&h2(t)&&h2(n)?(0,U.jsx)(rEt,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function iEt({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===n2.Left||e===n2.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function aEt({sourceX:e,sourceY:t,sourcePosition:n=n2.Bottom,targetX:r,targetY:i,targetPosition:a=n2.Top}){let[o,s]=iEt({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=iEt({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=XSt({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 oEt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=aEt({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,U.jsx)(u4,{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 sEt=oEt({isInternal:!1}),cEt=oEt({isInternal:!0});sEt.displayName=`SimpleBezierEdge`,cEt.displayName=`SimpleBezierEdgeInternal`;function lEt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=n2.Bottom,targetPosition:m=n2.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=O2({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,U.jsx)(u4,{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 uEt=lEt({isInternal:!1}),dEt=lEt({isInternal:!0});uEt.displayName=`SmoothStepEdge`,dEt.displayName=`SmoothStepEdgeInternal`;function fEt(e){return(0,H.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,U.jsx)(uEt,{...n,id:r,pathOptions:(0,H.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var pEt=fEt({isInternal:!1}),mEt=fEt({isInternal:!0});pEt.displayName=`StepEdge`,mEt.displayName=`StepEdgeInternal`;function hEt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=aCt({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,U.jsx)(u4,{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 gEt=hEt({isInternal:!1}),_Et=hEt({isInternal:!0});gEt.displayName=`StraightEdge`,_Et.displayName=`StraightEdgeInternal`;function vEt(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=n2.Bottom,targetPosition:s=n2.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]=QSt({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,U.jsx)(u4,{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 yEt=vEt({isInternal:!1}),bEt=vEt({isInternal:!0});yEt.displayName=`BezierEdge`,bEt.displayName=`BezierEdgeInternal`;var xEt={default:bEt,straight:_Et,step:mEt,smoothstep:dEt,simplebezier:cEt},SEt={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},CEt=(e,t,n)=>n===n2.Left?e-t:n===n2.Right?e+t:e,wEt=(e,t,n)=>n===n2.Top?e-t:n===n2.Bottom?e+t:e,TEt=`react-flow__edgeupdater`;function EEt({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,U.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:U1([TEt,`${TEt}-${s}`]),cx:CEt(t,r,e),cy:wEt(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function DEt({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=X2(),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`;R2.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,U.jsxs)(U.Fragment,{children:[(e===!0||e===`source`)&&(0,U.jsx)(EEt,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,U.jsx)(EEt,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function OEt({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=Y2(t=>t.edgeLookup.get(e)),b=Y2(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||xEt[x];S===void 0&&(_?.(`011`,Y0.error011(x)),x=`default`,S=h?.default||xEt.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,H.useRef)(null),[D,O]=(0,H.useState)(!1),[k,A]=(0,H.useState)(!1),j=X2(),{zIndex:M,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=Y2((0,H.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return{zIndex:y.zIndex,...SEt};let i=fCt({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_});return{zIndex:eCt({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...i||SEt}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),q2),z=(0,H.useMemo)(()=>y.markerStart?`url('#${A2(y.markerStart,m)}')`:void 0,[y.markerStart,m]),B=(0,H.useMemo)(()=>y.markerEnd?`url('#${A2(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let ee=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},V=a?e=>{a(e,{...y})}:void 0,te=o?e=>{o(e,{...y})}:void 0,ne=s?e=>{s(e,{...y})}:void 0,re=c?e=>{c(e,{...y})}:void 0,ie=l?e=>{l(e,{...y})}:void 0;return(0,U.jsx)(`svg`,{style:{zIndex:M},children:(0,U.jsxs)(`g`,{className:U1([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:ee,onDoubleClick:V,onContextMenu:te,onMouseEnter:ne,onMouseMove:re,onMouseLeave:ie,onKeyDown:C?t=>{if(!v&&ySt.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?`${Cwt}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,U.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:z,markerEnd:B,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,U.jsx)(DEt,{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 kEt=(0,H.memo)(OEt),AEt=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function jEt({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}=Y2(AEt,q2),b=JTt(t);return(0,U.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,U.jsx)(tEt,{defaultColor:e,rfId:n}),b.map(e=>(0,U.jsx)(kEt,{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))]})}jEt.displayName=`EdgeRenderer`;var MEt=(0,H.memo)(jEt),NEt=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function PEt({children:e}){return(0,U.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:Y2(NEt)},children:e})}function FEt(e){let t=r4(),n=(0,H.useRef)(!1);(0,H.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var IEt=e=>e.panZoom?.syncViewport;function LEt(e){let t=Y2(IEt),n=X2();return(0,H.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function REt(e){return e.connection.inProgress?{...e.connection,to:_2(e.connection.to,e.transform)}:{...e.connection}}function zEt(e){return e?t=>e(REt(t)):REt}function BEt(e){return Y2(zEt(e),q2)}var VEt=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function HEt({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=Y2(VEt,q2);return a&&i&&c?(0,U.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,U.jsx)(`g`,{className:U1([`react-flow__connection`,CSt(s)]),children:(0,U.jsx)(UEt,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var UEt=({style:e,type:t=e2.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}=BEt();if(!i)return;if(n)return(0,U.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:CSt(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 e2.Bezier:[m]=QSt(h);break;case e2.SimpleBezier:[m]=aEt(h);break;case e2.Step:[m]=O2({...h,borderRadius:0});break;case e2.SmoothStep:[m]=O2(h);break;default:[m]=aCt(h)}return(0,U.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};UEt.displayName=`ConnectionLine`;var WEt={};function GEt(e=WEt){(0,H.useRef)(e),X2(),(0,H.useEffect)(()=>{},[e])}function KEt(){X2(),(0,H.useRef)(!1),(0,H.useEffect)(()=>{},[])}function qEt({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,onPaneClick:B,onPaneMouseEnter:ee,onPaneMouseMove:V,onPaneMouseLeave:te,onPaneScroll:ne,onPaneContextMenu:re,paneClickDistance:ie,nodeClickDistance:ae,onEdgeContextMenu:oe,onEdgeMouseEnter:se,onEdgeMouseMove:ce,onEdgeMouseLeave:le,reconnectRadius:ue,onReconnect:de,onReconnectStart:fe,onReconnectEnd:pe,noDragClassName:me,noWheelClassName:he,noPanClassName:ge,disableKeyboardA11y:_e,nodeExtent:ve,rfId:ye,viewport:be,onViewportChange:xe}){return GEt(e),GEt(t),KEt(),FEt(n),LEt(be),(0,U.jsx)(LTt,{onPaneClick:B,onPaneMouseEnter:ee,onPaneMouseMove:V,onPaneMouseLeave:te,onPaneContextMenu:re,onPaneScroll:ne,paneClickDistance:ie,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:me,noWheelClassName:he,noPanClassName:ge,disableKeyboardA11y:_e,onViewportChange:xe,isControlledViewport:!!be,children:(0,U.jsxs)(PEt,{children:[(0,U.jsx)(MEt,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:de,onReconnectStart:fe,onReconnectEnd:pe,onlyRenderVisibleElements:T,onEdgeContextMenu:oe,onEdgeMouseEnter:se,onEdgeMouseMove:ce,onEdgeMouseLeave:le,reconnectRadius:ue,defaultMarkerColor:M,noPanClassName:ge,disableKeyboardA11y:_e,rfId:ye}),(0,U.jsx)(HEt,{style:h,type:m,component:g,containerStyle:_}),(0,U.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,U.jsx)(qTt,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:ae,onlyRenderVisibleElements:T,noPanClassName:ge,noDragClassName:me,disableKeyboardA11y:_e,nodeExtent:ve,rfId:ye}),(0,U.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}qEt.displayName=`GraphView`;var JEt=(0,H.memo)(qEt),YEt=({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??X0;DCt(h,g,_);let{nodesInitialized:x}=P2(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=b2(a2(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:X0,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Z0.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:{...xSt},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:LSt,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:bSt,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},XEt=({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})=>_wt((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 kSt({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...YEt({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}=P2(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();DCt(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}=wCt(e,n,r,i,a,o,l);d&&(yCt(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=k2(e,o.fromHandle,n2.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=I2(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(Ywt(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(Xwt(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=>t4(e,!0)));return}i(n4(r,new Set([...e]),!0)),a(n4(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>t4(e,!0)));return}a(n4(n,new Set([...e]))),i(n4(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(t4(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(t4(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,t4(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,t4(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]||(P2(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 TCt({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:{...xSt}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...YEt()})}},Object.is);function ZEt({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,H.useState)(()=>XEt({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,U.jsx)(vwt,{value:m,children:(0,U.jsx)(aTt,{children:p})})}function QEt({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,H.useContext)(J2)?(0,U.jsx)(U.Fragment,{children:e}):(0,U.jsx)(ZEt,{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 $Et={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function eDt({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=e2.Bezier,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:ee,deleteKeyCode:V=`Backspace`,selectionKeyCode:te=`Shift`,selectionOnDrag:ne=!1,selectionMode:re=$0.Full,panActivationKeyCode:ie=`Space`,multiSelectionKeyCode:ae=x2()?`Meta`:`Control`,zoomActivationKeyCode:oe=x2()?`Meta`:`Control`,snapToGrid:se,snapGrid:ce,onlyRenderVisibleElements:le=!1,selectNodesOnDrag:ue,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,nodeOrigin:he=Fwt,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve=!0,defaultViewport:ye=Iwt,minZoom:be=.5,maxZoom:xe=2,translateExtent:Se=X0,preventScrolling:Ce=!0,nodeExtent:we,defaultMarkerColor:Te=`#b1b1b7`,zoomOnScroll:Ee=!0,zoomOnPinch:De=!0,panOnScroll:Oe=!1,panOnScrollSpeed:ke=.5,panOnScrollMode:Ae=Q0.Free,zoomOnDoubleClick:je=!0,panOnDrag:Me=!0,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze=1,nodeClickDistance:Be=0,children:Ve,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe=10,onNodesChange:Ze,onEdgesChange:Qe,noDragClassName:$e=`nodrag`,noWheelClassName:et=`nowheel`,noPanClassName:tt=`nopan`,fitView:nt,fitViewOptions:rt,connectOnClick:it,attributionPosition:at,proOptions:ot,defaultEdgeOptions:st,elevateNodesOnSelect:ct=!0,elevateEdgesOnSelect:lt=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:pt,connectionRadius:mt,isValidConnection:ht,onError:gt,style:_t,id:vt,nodeDragThreshold:yt,connectionDragThreshold:bt,viewport:xt,onViewportChange:St,width:Ct,height:wt,colorMode:Tt=`light`,debug:Et,onScroll:Dt,ariaLabelConfig:Ot,zIndexMode:kt=`basic`,...At},jt){let Mt=vt||`1`,Nt=Hwt(Tt),Pt=(0,H.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Dt?.(e)},[Dt]);return(0,U.jsx)(`div`,{"data-testid":`rf__wrapper`,...At,onScroll:Pt,style:{..._t,...$Et},ref:jt,className:U1([`react-flow`,i,Nt]),id:vt,role:`application`,children:(0,U.jsxs)(QEt,{nodes:e,edges:t,width:Ct,height:wt,fitView:nt,fitViewOptions:rt,minZoom:be,maxZoom:xe,nodeOrigin:he,nodeExtent:we,zIndexMode:kt,children:[(0,U.jsx)(Bwt,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve,elevateNodesOnSelect:ct,elevateEdgesOnSelect:lt,minZoom:be,maxZoom:xe,nodeExtent:we,onNodesChange:Ze,onEdgesChange:Qe,snapToGrid:se,snapGrid:ce,connectionMode:L,translateExtent:Se,connectOnClick:it,defaultEdgeOptions:st,fitView:nt,fitViewOptions:rt,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:tt,nodeOrigin:he,rfId:Mt,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:pt,onError:gt,connectionRadius:mt,isValidConnection:ht,selectNodesOnDrag:ue,nodeDragThreshold:yt,connectionDragThreshold:bt,onBeforeDelete:I,debug:Et,ariaLabelConfig:Ot,zIndexMode:kt}),(0,U.jsx)(JEt,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:ee,selectionKeyCode:te,selectionOnDrag:ne,selectionMode:re,deleteKeyCode:V,multiSelectionKeyCode:ae,panActivationKeyCode:ie,zoomActivationKeyCode:oe,onlyRenderVisibleElements:le,defaultViewport:ye,translateExtent:Se,minZoom:be,maxZoom:xe,preventScrolling:Ce,zoomOnScroll:Ee,zoomOnPinch:De,zoomOnDoubleClick:je,panOnScroll:Oe,panOnScrollSpeed:ke,panOnScrollMode:Ae,panOnDrag:Me,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze,nodeClickDistance:Be,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe,defaultMarkerColor:Te,noDragClassName:$e,noWheelClassName:et,noPanClassName:tt,rfId:Mt,disableKeyboardA11y:ut,nodeExtent:we,viewport:xt,onViewportChange:St}),(0,U.jsx)(Pwt,{onSelectionChange:k}),Ve,(0,U.jsx)(kwt,{proOptions:ot,position:at}),(0,U.jsx)(Owt,{rfId:Mt,disableKeyboardA11y:ut})]})})}var tDt=tTt(eDt);Y0.error014();function nDt({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,U.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:U1([`react-flow__background-pattern`,n,r])})}function rDt({radius:e,className:t}){return(0,U.jsx)(`circle`,{cx:e,cy:e,r:e,className:U1([`react-flow__background-pattern`,`dots`,t])})}var d4;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(d4||={});var iDt={[d4.Dots]:1,[d4.Lines]:1,[d4.Cross]:6},aDt=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function oDt({id:e,variant:t=d4.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,H.useRef)(null),{transform:f,patternId:p}=Y2(aDt,q2),m=r||iDt[t],h=t===d4.Dots,g=t===d4.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,U.jsxs)(`svg`,{className:U1([`react-flow__background`,l]),style:{...c,...i4,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,U.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,U.jsx)(rDt,{radius:y/2,className:u}):(0,U.jsx)(nDt,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,U.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}oDt.displayName=`Background`;var sDt=(0,H.memo)(oDt);function cDt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,U.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function lDt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,U.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function uDt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,U.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function dDt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,U.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function fDt(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,U.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function f4({children:e,className:t,...n}){return(0,U.jsx)(`button`,{type:`button`,className:U1([`react-flow__controls-button`,t]),...n,children:e})}var pDt=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function mDt({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=X2(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=Y2(pDt,q2),{zoomIn:y,zoomOut:b,fitView:x}=r4(),S=()=>{y(),a?.()},C=()=>{b(),o?.()},w=()=>{x(i),s?.()},T=()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)};return(0,U.jsxs)(Z2,{className:U1([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(f4,{onClick:S,className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,U.jsx)(cDt,{})}),(0,U.jsx)(f4,{onClick:C,className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,U.jsx)(lDt,{})})]}),n&&(0,U.jsx)(f4,{className:`react-flow__controls-fitview`,onClick:w,title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,U.jsx)(uDt,{})}),r&&(0,U.jsx)(f4,{className:`react-flow__controls-interactive`,onClick:T,title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,U.jsx)(fDt,{}):(0,U.jsx)(dDt,{})}),u]})}mDt.displayName=`Controls`,(0,H.memo)(mDt);function hDt({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,U.jsx)(`rect`,{className:U1([`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 gDt=(0,H.memo)(hDt),_Dt=e=>e.nodes.map(e=>e.id),p4=e=>e instanceof Function?e:()=>e;function vDt({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=gDt,onClick:o}){let s=Y2(_Dt,q2),c=p4(t),l=p4(e),u=p4(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,U.jsx)(U.Fragment,{children:s.map(e=>(0,U.jsx)(bDt,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function yDt({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}=Y2(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}=C2(r);return{node:r,x:i,y:a,width:o,height:s}},q2);return!l||l.hidden||!BSt(l)?null:(0,U.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var bDt=(0,H.memo)(yDt),xDt=(0,H.memo)(vDt),SDt=200,CDt=150,wDt=e=>!e.hidden,TDt=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?FSt(a2(e.nodeLookup,{filter:wDt}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},EDt=`react-flow__minimap-desc`;function DDt({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=X2(),S=(0,H.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=Y2(TDt,q2),j=e?.width??SDt,M=e?.height??CDt,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,z=C.x-(I-C.width)/2-R,B=C.y-(L-C.height)/2-R,ee=I+R*2,V=L+R*2,te=`${EDt}-${T}`,ne=(0,H.useRef)(0),re=(0,H.useRef)();ne.current=F,(0,H.useEffect)(()=>{if(S.current&&E)return re.current=HCt({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>ne.current}),()=>{re.current?.destroy()}},[E]),(0,H.useEffect)(()=>{re.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let ie=p?e=>{let[t,n]=re.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ae=m?(0,H.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,oe=_??A[`minimap.ariaLabel`];return(0,U.jsx)(Z2,{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:U1([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,U.jsxs)(`svg`,{width:j,height:M,viewBox:`${z} ${B} ${ee} ${V}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":te,ref:S,onClick:ie,children:[oe&&(0,U.jsx)(`title`,{id:te,children:oe}),(0,U.jsx)(xDt,{onClick:ae,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,U.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${z-R},${B-R}h${ee+R*2}v${V+R*2}h${-ee-R*2}z
482
- M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}DDt.displayName=`MiniMap`,(0,H.memo)(DDt);var ODt=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,kDt={[U2.Line]:`right`,[U2.Handle]:`bottom-right`};function ADt({nodeId:e,position:t,variant:n=U2.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=STt(),y=typeof e==`string`?e:v,b=X2(),x=(0,H.useRef)(null),S=n===U2.Handle,C=Y2((0,H.useCallback)(ODt(S&&p),[S,p]),q2),w=(0,H.useRef)(null),T=t??kDt[n];return(0,H.useEffect)(()=>{if(!(!x.current||!y))return w.current||=swt({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=I2([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...VSt({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,U.jsx)(`div`,{className:U1([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,H.memo)(ADt);function m4({value:e,onValueChange:t,options:n,columns:r=2,layout:i=`cards`,idPrefix:a=`wizard-choice`,ariaLabel:o,className:s}){return(0,U.jsx)(rvt,{value:e,onValueChange:e=>t(e),"aria-label":o,className:W(i===`list`?`flex flex-col gap-2`:[`grid gap-3`,r===1&&`grid-cols-1`,r===2&&`grid-cols-2`,r===3&&`grid-cols-3`],s),children:n.map(t=>{let n=`${a}-${t.value}`,r=e===t.value,o=W(`rounded-md border transition-colors`,t.disabled?`cursor-not-allowed opacity-60`:`cursor-pointer`,r?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`bg-card hover:bg-neutral-50 dark:hover:bg-neutral-800/60`);return i===`list`?(0,U.jsxs)(dY,{htmlFor:n,className:W(`flex items-center gap-3 px-3 py-2.5`,o),children:[(0,U.jsx)(H1,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium sm:w-56 sm:shrink-0`,children:t.title}),t.description&&(0,U.jsx)(`div`,{className:`min-w-0 flex-1 text-xs leading-snug text-muted-foreground`,children:t.description})]})]},t.value):(0,U.jsxs)(dY,{htmlFor:n,className:W(`flex flex-col gap-1.5 p-3`,o),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(H1,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:t.title})]}),t.description&&(0,U.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t.description})]},t.value)})})}var h4=({tiles:e,selectedId:t,onSelect:n,fallbackIcon:r,columns:i=4,emptyState:a,className:o})=>{let[s,c]=(0,H.useState)(()=>new Set);return(0,U.jsxs)(`div`,{className:W(`grid auto-rows-min gap-2 p-0.5`,i===4?`grid-cols-4`:`grid-cols-3`,o),children:[e.map(e=>{let i=t===e.id,a=s.has(e.id)||!e.iconUrl;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-pressed":i,className:W(`flex flex-col items-center justify-center gap-1.5 rounded-md border bg-card p-2 text-center transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-800/60`,i?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`border-border`),children:[a?r:(0,U.jsx)(`img`,{src:e.iconUrl,alt:``,className:`size-7 object-contain brightness-0 dark:invert`,onError:()=>c(t=>new Set(t).add(e.id))}),(0,U.jsx)(`span`,{className:`w-full truncate text-xs leading-tight`,children:e.name})]},e.id)}),e.length===0&&a&&(0,U.jsx)(`div`,{className:`col-span-full py-6 text-center text-sm text-muted-foreground`,children:a})]})},jDt=`#ff00bd`,MDt=`#98036a`,NDt=`#fff0fc`,PDt=`#9ca3af`,FDt=`#6b7280`,IDt=`#f7f9fb`,g4=152,_4=60,LDt={client:qu,gateway:Qf,origin:Mf},RDt=`!h-0 !min-h-0 !w-0 !min-w-0 !border-0 !bg-transparent`,zDt={box:({data:e})=>{let{label:t,kind:n,emphasis:r}=e,i=LDt[n];return(0,U.jsxs)(`div`,{className:W(`flex flex-col items-center justify-center gap-1.5 rounded-lg border bg-card px-2 text-center shadow-xs`,r?`border-zuplo-600`:`border-neutral-300 dark:border-neutral-600`),style:{width:g4,height:_4},children:[(0,U.jsx)(c4,{type:`target`,position:n2.Left,isConnectable:!1,className:RDt}),(0,U.jsx)(i,{"aria-hidden":`true`,strokeWidth:1.75,className:W(`size-[18px] shrink-0`,r?`text-zuplo-600`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:`text-xs font-medium leading-tight text-muted-foreground`,children:t}),(0,U.jsx)(c4,{type:`source`,position:n2.Right,isConnectable:!1,className:RDt})]})}},v4=[{id:`client`,type:`box`,position:{x:0,y:0},width:g4,height:_4,initialWidth:g4,initialHeight:_4,data:{label:`MCP Client`,kind:`client`,emphasis:!1},draggable:!1,selectable:!1},{id:`gateway`,type:`box`,position:{x:270,y:0},width:g4,height:_4,initialWidth:g4,initialHeight:_4,data:{label:`Zuplo MCP Gateway`,kind:`gateway`,emphasis:!0},draggable:!1,selectable:!1},{id:`origin`,type:`box`,position:{x:540,y:0},width:g4,height:_4,initialWidth:g4,initialHeight:_4,data:{label:`Origin MCP Server`,kind:`origin`,emphasis:!1},draggable:!1,selectable:!1}],BDt=e=>{let t=(e,t,n,r,i)=>({id:e,source:t,target:n,type:`smoothstep`,label:r,animated:!1,style:{stroke:i?jDt:PDt,strokeWidth:i?2:1.5},labelStyle:{fill:i?MDt:FDt,fontWeight:i?600:500,fontSize:11},labelBgStyle:{fill:i?NDt:IDt,fillOpacity:.95},labelBgPadding:[6,3],labelBgBorderRadius:4,markerEnd:{type:t2.ArrowClosed,width:14,height:14,color:i?jDt:PDt}});return[t(`inbound`,`client`,`gateway`,`Inbound auth`,e===`inbound`),t(`outbound`,`gateway`,`origin`,`Outbound auth`,e===`outbound`)]},y4={minX:Math.min(...v4.map(e=>e.position.x)),minY:Math.min(...v4.map(e=>e.position.y)),maxX:Math.max(...v4.map(e=>e.position.x+(e.width??g4))),maxY:Math.max(...v4.map(e=>e.position.y+(e.height??_4)))},VDt=y4.maxX-y4.minX,HDt=y4.maxY-y4.minY,UDt=.5,WDt=1.2,GDt=.12;function KDt(e,t){let n=Math.min(e/VDt,t/HDt),r=Math.min(WDt,Math.max(UDt,n*(1-GDt*2)));return{x:(e-VDt*r)/2-y4.minX*r,y:(t-HDt*r)/2-y4.minY*r,zoom:r}}var qDt=({active:e})=>{let t=(0,H.useMemo)(()=>BDt(e),[e]),n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useCallback)(()=>{let e=n.current,t=e?.clientWidth??0,i=e?.clientHeight??0;t>0&&i>0&&r.current?.setViewport(KDt(t,i))},[]),a=(0,H.useCallback)(e=>{r.current=e,i()},[i]);return(0,H.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=requestAnimationFrame(i)});return r.observe(e),()=>{cancelAnimationFrame(t),r.disconnect()}},[i]),(0,U.jsx)(`div`,{ref:n,role:`img`,"aria-label":`MCP request flow, configuring ${e} authentication`,className:`h-36 w-full overflow-hidden rounded-md border border-border`,children:(0,U.jsx)(tDt,{nodes:v4,edges:t,nodeTypes:zDt,onInit:a,minZoom:UDt,maxZoom:WDt,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:IDt},children:(0,U.jsx)(sDt,{variant:d4.Dots,gap:16,size:1,color:`#dbe1e8`})})})};function b4(e){return e&&e.length>0?e:void 0}function x4(e){return e&&Object.keys(e).length>0?e:void 0}function JDt(e){let t=new Set;for(let n of e??[]){let e=n.trim();e&&t.add(e)}return[...t]}function S4(e,t){if(t!==`rolesAndGroups`)return{};if(e.public===!0)return{public:!0};let n=JDt(e.roles),r=JDt(e.groups);return{...n.length>0?{roles:n}:{},...r.length>0?{groups:r}:{}}}function YDt(e){let t=e&&typeof e==`object`?e:{};return{accessControlMode:t.accessControl?.mode===`rolesAndGroups`?`rolesAndGroups`:`allPublic`,catalog:{tools:C4(t.tools,`name`,e=>({name:e})),prompts:C4(t.prompts,`name`,e=>({name:e})),resources:C4(t.resources,`uri`,e=>({uri:e,name:e})),resourceTemplates:C4(t.resourceTemplates,`uriTemplate`,e=>({uriTemplate:e,name:e}))}}}function C4(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 w4(e){return XDt(e.catalog,e.accessControlMode)}function XDt(e,t=`allPublic`){return{...t===`rolesAndGroups`?{accessControl:{mode:t}}:{},tools:e.tools.flatMap(e=>{let n=b4(e.name);if(!n)return[];let r=b4(e.description),i=x4(e.annotations),a=x4(e._meta);return[{name:n,...r?{description:r}:{},...i?{annotations:i}:{},...a?{_meta:a}:{},...S4(e,t)}]}),prompts:e.prompts.flatMap(e=>{let n=b4(e.name);if(!n)return[];let r=b4(e.description),i=x4(e._meta);return[{name:n,...r?{description:r}:{},...i?{_meta:i}:{},...S4(e,t)}]}),resources:e.resources.flatMap(e=>{let n=b4(e.uri);if(!n)return[];let r=b4(e.name),i=b4(e.description),a=b4(e.mimeType),o=x4(e._meta);return[{uri:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...S4(e,t)}]}),resourceTemplates:e.resourceTemplates.flatMap(e=>{let n=b4(e.uriTemplate);if(!n)return[];let r=b4(e.name),i=b4(e.description),a=b4(e.mimeType),o=x4(e._meta);return[{uriTemplate:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...S4(e,t)}]})}}var T4=e=>`/mcp-idp-icons/${e}.svg`,E4=[{id:`auth0`,label:`Auth0`,description:`Auth0 by Okta`,iconUrl:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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 D4(e){return E4.find(t=>t.id===e)}function ZDt(e){return Object.fromEntries(e.fields.map(e=>[e.key,e.defaultValue]))}var QDt=`Most Used`,$Dt=`Other`,eOt=[`rate-limit`,`api-key`],tOt=[{name:`Rate Limiting & Quotas`,baseIds:[`rate-limit`,`complex-rate-limit`,`quota`]},{name:`Authentication`,baseIds:[`api-key`,`basic-auth`,`mtls-auth`,`ldap-auth`,`open-id-jwt-auth`,`okta-jwt-auth`,`auth0-jwt-auth`,`clerk-jwt-auth`,`cognito-jwt-auth`,`firebase-jwt`,`supabase-jwt-auth`,`propel-auth-jwt`,`curity-phantom-token`,`stripe-webhook-verification`,`web-bot-auth`]},{name:`Authorization`,baseIds:[`jwt-scopes`,`openfga-authz`,`okta-fga-authz`,`axiomatics-authz`,`authzen`,`geo-filter`,`require-origin`]},{name:`MCP Authentication`,baseIds:[`mcp-oauth`,`mcp-auth0-oauth`,`mcp-clerk-oauth`,`mcp-cognito-oauth`,`mcp-entra-oauth`,`mcp-google-oauth`,`mcp-keycloak-oauth`,`mcp-logto-oauth`,`mcp-okta-oauth`,`mcp-onelogin-oauth`,`mcp-ping-oauth`,`mcp-workos-oauth`,`mcp-token-exchange`,`mcp-capability-filter`]},{name:`AI Gateway`,baseIds:[`ai-gateway-model-filtering-v2`,`ai-gateway-fallback-model-v2`,`ai-gateway-metering-v2`,`ai-gateway-semantic-cache-v2`,`ai-gateway-dlp`,`ai-gateway-smart-router`,`akamai-ai-firewall-v2`,`comet-opik-tracing-v2`,`galileo-tracing-v2`]},{name:`AI & Security`,baseIds:[`prompt-injection`,`bot-detection`,`akamai-firewall-for-ai`,`secret-masking`]},{name:`Caching`,baseIds:[`caching`,`semantic-cache`]},{name:`Transformations`,baseIds:[`xml-to-json`,`formdata-to-json`,`set-body`,`set-headers`,`set-query-params`,`set-status`,`remove-headers`,`remove-query-params`,`clear-headers`,`query-param-to-header`,`replace-string`,`change-method`]},{name:`Validation`,baseIds:[`validate-json-schema`,`request-validation`,`request-size-limit`]},{name:`Traffic Management`,baseIds:[`traffic-splitting`,`brownout`,`sleep`,`mock-api`,`http-deprecation`]},{name:`GraphQL`,baseIds:[`graphql-complexity-limit`,`graphql-disable-introspection`,`graphql-introspection-filter`]},{name:`Monetization & Metering`,baseIds:[`monetization`,`openmeter`,`amberflo-metering`,`moesif`,`readme-metrics`]},{name:`Logging & Tracing`,baseIds:[`audit-log`]},{name:`Upstream Auth`,baseIds:[`set-upstream-api-key`,`upstream-azure-ad-service-auth`,`upstream-firebase-admin-auth`,`upstream-firebase-user-auth`,`upstream-gcp-federated-auth`,`upstream-gcp-jwt`,`upstream-gcp-service-auth`,`upstream-zuplo-jwt-auth`]},{name:`Custom & Composite`,baseIds:[`custom-code`,`composite`]}],nOt=/-(inbound|outbound|internal)$/,O4=e=>e.replace(nOt,``),k4=new Map;for(let e of tOt)for(let t of e.baseIds)k4.has(t)||k4.set(t,e.name);var rOt=e=>k4.get(O4(e.id))??`Other`,iOt=e=>k4.get(O4(e))===`Authentication`,aOt=e=>eOt.includes(O4(e.id)),oOt=e=>{let t=new Map,n=[];for(let r of e){aOt(r)&&n.push(r);let e=rOt(r),i=t.get(e);i?i.push(r):t.set(e,[r])}let r=[];n.length>0&&r.push({name:QDt,policies:n});for(let{name:e}of tOt){let n=t.get(e);n&&n.length>0&&r.push({name:e,policies:n})}let i=t.get($Dt);return i&&i.length>0&&r.push({name:$Dt,policies:i}),r},sOt=[...E4.map(e=>e.policyType)];function cOt(e){return sOt.includes(e)||iOt(e)}var A4=`mcp-token-exchange-inbound`,j4=`mcp-capability-filter-inbound`,lOt=`set-upstream-api-key-inbound`,uOt=`remove-headers-inbound`;function M4(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 dOt=e=>e.toLowerCase().replaceAll(` `,`-`),N4=({name:e,onChangeName:t,disabled:n,policies:r})=>{let[i,a]=(0,H.useState)(null);return(0,U.jsxs)(`div`,{className:`grid grid-cols-12 text-sm gap-2 items-center pt-1`,children:[(0,U.jsx)(`label`,{className:`col-span-1`,children:`Name`}),(0,U.jsx)(`div`,{className:`col-span-11`,children:(0,U.jsx)(iM,{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=dOt(n.toLowerCase());a(Pgt(i,r)),t(i)},"aria-describedby":`email-description`})}),i&&(0,U.jsx)(`div`,{className:`col-span-11 col-start-2 mt-1 text-red-600`,children:i})]})},fOt=`Toggle`,pOt=H.forwardRef((e,t)=>{let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=Ct({prop:n,onChange:i,defaultProp:r??!1,caller:fOt});return(0,U.jsx)(ac.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:Xs(e.onClick,()=>{e.disabled||s(!o)})})});pOt.displayName=fOt;var P4=`ToggleGroup`,[mOt,hOt]=T(P4,[OW]),gOt=OW(),F4=H.forwardRef((e,t)=>{let{type:n,...r}=e;if(n===`single`)return(0,U.jsx)(yOt,{...r,ref:t});if(n===`multiple`)return(0,U.jsx)(bOt,{...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${P4}\``)});F4.displayName=P4;var[_Ot,vOt]=mOt(P4),yOt=H.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=Ct({prop:n,defaultProp:r??``,onChange:i,caller:P4});return(0,U.jsx)(_Ot,{scope:e.__scopeToggleGroup,type:`single`,value:H.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:H.useCallback(()=>s(``),[s]),children:(0,U.jsx)(COt,{...a,ref:t})})}),bOt=H.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=Ct({prop:n,defaultProp:r??[],onChange:i,caller:P4}),c=H.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=H.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,U.jsx)(_Ot,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,U.jsx)(COt,{...a,ref:t})})});F4.displayName=P4;var[xOt,SOt]=mOt(P4),COt=H.forwardRef((e,t)=>{let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=gOt(n),u=At(o),d={role:`group`,dir:u,...c};return(0,U.jsx)(xOt,{scope:n,rovingFocus:i,disabled:r,children:i?(0,U.jsx)(NW,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,U.jsx)(ac.div,{...d,ref:t})}):(0,U.jsx)(ac.div,{...d,ref:t})})}),I4=`ToggleGroupItem`,wOt=H.forwardRef((e,t)=>{let n=vOt(I4,e.__scopeToggleGroup),r=SOt(I4,e.__scopeToggleGroup),i=gOt(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=H.useRef(null);return r.rovingFocus?(0,U.jsx)(PW,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,U.jsx)(TOt,{...s,ref:t})}):(0,U.jsx)(TOt,{...s,ref:t})});wOt.displayName=I4;var TOt=H.forwardRef((e,t)=>{let{__scopeToggleGroup:n,value:r,...i}=e,a=vOt(I4,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0};return(0,U.jsx)(pOt,{...a.type===`single`?o:void 0,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})}),EOt=F4,DOt=wOt,OOt=Ou(`inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground`},size:{default:`h-9 px-2 min-w-9`,xs:`h-6 px-1.5 min-w-6 text-xs [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 px-1.5 min-w-8`,lg:`h-10 px-2.5 min-w-10`}},defaultVariants:{variant:`default`,size:`default`}}),kOt=H.createContext({size:`default`,variant:`default`,spacing:0});function L4({className:e,variant:t,size:n,spacing:r=0,children:i,...a}){return(0,U.jsx)(EOt,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,style:{"--gap":r},className:W(`group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs`,e),...a,children:(0,U.jsx)(kOt.Provider,{value:{variant:t,size:n,spacing:r},children:i})})}function R4({className:e,children:t,variant:n,size:r,...i}){let a=H.useContext(kOt);return(0,U.jsx)(DOt,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:W(OOt({variant:a.variant||n,size:a.size||r}),`w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10`,`data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l`,e),...i,children:t})}var AOt=({documentationSrc:e,className:t})=>(0,U.jsx)(`div`,{className:W(`prose prose-neutral prose-sm dark:prose-invert z-10 prose-headings:mt-2 prose-headings:text-sm max-w-full [&_li>div]:inline [&_li>div>p]:inline [&_code::before]:content-none [&_code::after]:content-none`,t),dangerouslySetInnerHTML:{__html:e}}),jOt=({documentationSrc:e})=>(0,U.jsxs)(`div`,{className:`px-4 py-2 border-t h-full overflow-y-auto h-[stretch]`,children:[(0,U.jsx)(`h3`,{className:`text-lg font-medium text-foreground`,children:`Documentation`}),(0,U.jsx)(AOt,{documentationSrc:e})]}),MOt={[j4]:(0,H.lazy)(()=>gn(()=>import(`./McpCapabilityFilterDesigner-DB3wLpXJ.js`),__vite__mapDeps([7,1,8,2])))};function NOt(e){return e?MOt[e]:void 0}var POt=(e=!1)=>async({queryKey:t})=>{let[n]=t;if(typeof n!=`string`)throw new he({type:`https://zup.fail/invalid-query-key`,title:`Invalid query key`});let r=new Request(n),i;try{i=await fetch(r)}catch(e){throw e instanceof TypeError?new he({type:`https://zup.fail/api-request-failed`,title:`API request failed`,status:500,instance:n}):e}if(!i.ok){let e=new He(`Error while making request. Please try again or contact support if the problem persists.`);throw await e.tryReadResponse(i),e}try{return await(e?i.clone().json():i.clone().text())}catch(e){let t=await i.clone().text();throw Zt.captureException(e,{message:`Failed to parse response of ${n} to JSON`,responseText:t,status:i.status,requestUrl:n}),e}};function z4(e,{json:t,...n}={}){return Oe({queryKey:[e.url],queryFn:POt(t),...n})}var B4=(e={})=>z4(mt.cdnContent(`/portal/policies.v6.json`),{...e,json:!0}),FOt=(e,t={})=>z4({url:e??``},{...t,enabled:!!e&&t.enabled!==!1,json:!0});function IOt(e){let t=e?.properties?.handler?.properties?.options;if(!(!t||t.type!==`object`||!t.properties||Object.keys(t.properties).length===0))return t}function LOt(e){if(e.oneOf||e.anyOf||e.allOf||e.const)return`json`;if(e.enum)return e.enum.every(e=>typeof e==`string`)?`select`:`json`;if(typeof e.type!=`string`)return`json`;switch(e.type){case`boolean`:return`boolean`;case`number`:case`integer`:return`number`;case`string`:return`text`;case`array`:{let t=e.items;if(t&&!Array.isArray(t)){if(t.type===`string`&&!t.oneOf&&!t.anyOf&&!t.allOf)return`string-array`;if(t.type===`object`&&t.properties&&Object.keys(t.properties).length>0)return`object-array`}return`json`}case`object`:{if(e.properties&&Object.keys(e.properties).length>0)return`object`;let t=e.additionalProperties;return t&&typeof t==`object`&&(t.type===`string`||t.type===`number`||t.type===`integer`)?`record`:`json`}default:return`json`}}function V4(e,t){return e.required?.includes(t)??!1}function ROt(e){return e[`x-advanced`]===!0||e[`x-show-example`]===!1}var zOt=()=>{let e=(0,H.useContext)(mp);return!!(e?.account&&e?.project)},BOt=({children:e,onInject:t,isEnabled:n=!0})=>{let r=zOt();return!n||!r?(0,U.jsx)(`div`,{className:`relative w-full`,children:e}):(0,U.jsx)(VOt,{onInject:t,children:e})},VOt=({children:e,onInject:t})=>{let n=hp([`account`,`project`]),r=NN(n.account.name,n.project.name);return(0,U.jsxs)(tb,{children:[(0,U.jsxs)(`div`,{className:`relative w-full`,children:[e,(0,U.jsx)(nb,{asChild:!0,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`flex-none ml-1 absolute top-1 right-1 bg-card`,title:`Select environment variable`,children:(0,U.jsx)(sf,{className:`w-4`})})})]}),(0,U.jsxs)(ib,{children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Environment Variables`}),(0,U.jsx)(cb,{asChild:!0,children:(0,U.jsxs)(ZD,{className:`mt-4 divide-y divide-double bg-gray-50 dark:bg-neutral-900 max-h-96 overflow-y-auto`,children:[r.isPending?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rO,{className:`h-6 w-2/3 m-1`}),(0,U.jsx)(rO,{className:`h-6 w-2/3 m-1`}),(0,U.jsx)(rO,{className:`h-6 w-2/3 m-1`})]}):r.data?.length===0&&(0,U.jsx)(`div`,{className:`p-2`,children:`No environment variables`}),r.data?.map(e=>(0,U.jsxs)(`div`,{className:`p-2 py-3 flex justify-between items-center`,children:[(0,U.jsx)(`div`,{children:e.name}),(0,U.jsx)(rb,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,size:`xs`,className:`flex-none`,onClick:()=>t(e,`$env(${e.name})`),children:`Use`})})]},e.id))]})})]}),(0,U.jsx)(ob,{children:(0,U.jsx)(rb,{children:(0,U.jsx)(X,{type:`submit`,variant:`outline`,children:`Close`})})})]})]})},H4=(0,H.createContext)(!0),U4=({schema:e,value:t,onChange:n,disabled:r,allowEnvVariables:i})=>{let a=(0,H.useContext)(H4),o=i??a,s=(e,r)=>{if(r===void 0){let{[e]:r,...i}=t;n(i)}else n({...t,[e]:r})},c=(n,i)=>(0,U.jsx)(UOt,{name:n,schema:i,required:V4(e,n),value:t[n],onChange:e=>s(n,e),disabled:r},n),l=Object.entries(e.properties??{}),u=(t,n)=>ROt(n)&&!V4(e,t),d=l.filter(([e,t])=>u(e,t)),f=l.filter(([e,t])=>!u(e,t)),p=[...f.filter(([t])=>V4(e,t)),...f.filter(([t])=>!V4(e,t))];return(0,U.jsx)(H4.Provider,{value:o,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[p.map(([e,t])=>c(e,t)),d.length>0&&(0,U.jsx)(HOt,{defaultOpen:d.some(([e])=>t[e]!==void 0),children:d.map(([e,t])=>c(e,t))})]})})},HOt=({defaultOpen:e,children:t})=>{let[n,r]=(0,H.useState)(e);return(0,U.jsxs)(ET,{open:n,onOpenChange:r,children:[(0,U.jsxs)(DT,{className:`flex items-center gap-1 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground`,children:[(0,U.jsx)(nd,{className:W(`size-4 transition-transform`,n&&`rotate-90`)}),n?`Hide advanced options`:`Show advanced options`]}),(0,U.jsx)(OT,{className:`flex flex-col gap-5 pt-5`,children:t})]})},UOt=({name:e,schema:t,required:n,value:r,onChange:i,disabled:a})=>{let o=(0,H.useId)(),s=LOt(t);return s===`boolean`?(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsx)(WOt,{htmlFor:o,name:e,schema:t,required:n}),(0,U.jsx)(y1,{id:o,checked:r===!0,onCheckedChange:e=>i(e),disabled:a})]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(WOt,{htmlFor:o,name:e,schema:t,required:n}),(0,U.jsx)(GOt,{id:o,kind:s,schema:t,required:n,value:r,onChange:i,disabled:a})]})},WOt=({htmlFor:e,name:t,schema:n,required:r})=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,U.jsxs)(dY,{htmlFor:e,className:`capitalize`,children:[t,r?(0,U.jsx)(`span`,{className:`text-destructive`,children:` *`}):(0,U.jsx)(`span`,{className:`ml-1 font-normal normal-case text-muted-foreground`,children:`(optional)`})]}),n.description&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.description})]}),GOt=({id:e,kind:t,schema:n,required:r,value:i,onChange:a,disabled:o})=>{switch(t){case`text`:return(0,U.jsx)(W4,{id:e,value:typeof i==`string`?i:``,placeholder:typeof n.default==`string`?n.default:void 0,onValueChange:e=>a(e===``?void 0:e),disabled:o});case`number`:return(0,U.jsx)(iM,{id:e,type:`number`,step:n.type===`integer`?1:void 0,value:typeof i==`number`?i:``,placeholder:typeof n.default==`number`?String(n.default):void 0,onChange:e=>{let t=e.target.value===``?NaN:Number(e.target.value);a(Number.isNaN(t)?void 0:t)},disabled:o});case`select`:return(0,U.jsxs)(mJ,{value:typeof i==`string`?i:Vet,onValueChange:e=>a(e===`__UNSET`?void 0:e),disabled:o,children:[(0,U.jsx)(_J,{id:e,className:`w-full`,children:(0,U.jsx)(gJ,{placeholder:`Select an option`})}),(0,U.jsxs)(vJ,{children:[!r&&(0,U.jsx)(bJ,{value:`__UNSET`,children:(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`Not set`})}),(n.enum??[]).filter(e=>typeof e==`string`).map(e=>(0,U.jsx)(bJ,{value:e,children:e},e))]})]});case`string-array`:return(0,U.jsx)(KOt,{value:i,onChange:a,disabled:o});case`object-array`:return(0,U.jsx)(qOt,{schema:n,value:i,onChange:a,disabled:o});case`record`:return(0,U.jsx)(JOt,{schema:n,value:i,onChange:a,disabled:o});case`object`:return(0,U.jsx)(`div`,{className:`border rounded-md p-3 ml-1`,children:(0,U.jsx)(U4,{schema:n,value:G4(i)?i:{},onChange:e=>a(Object.keys(e).length===0?void 0:e),disabled:o})});case`json`:return(0,U.jsx)(YOt,{id:e,value:i,onChange:a,disabled:o})}},W4=({id:e,value:t,placeholder:n,onValueChange:r,disabled:i})=>{let a=(0,H.useContext)(H4),o=zOt(),s=a&&o&&!i;return(0,U.jsx)(BOt,{isEnabled:s,onInject:(e,t)=>r(t),children:(0,U.jsx)(iM,{id:e,value:t,placeholder:n,onChange:e=>r(e.target.value),disabled:i,className:W(s&&`pr-10`)})})},KOt=({value:e,onChange:t,disabled:n})=>{let r=Array.isArray(e)?e.map(e=>typeof e==`string`?e:String(e)):[],i=e=>{t(e.length===0?void 0:e)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(W4,{value:e,onValueChange:e=>{let n=[...r];n[t]=e,i(n)},disabled:n}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove item`,onClick:()=>i(r.filter((e,n)=>n!==t)),disabled:n,children:(0,U.jsx)(ep,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>i([...r,``]),disabled:n,children:[(0,U.jsx)(Sf,{className:`size-4`}),`Add item`]})]})},qOt=({schema:e,value:t,onChange:n,disabled:r})=>{let i=Array.isArray(e.items)?void 0:e.items,a=Array.isArray(t)?t:[],o=e=>{n(e.length===0?void 0:e)};return i?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a.map((e,t)=>(0,U.jsxs)(`div`,{className:`relative border rounded-md p-3 pr-10`,children:[(0,U.jsx)(U4,{schema:i,value:G4(e)?e:{},onChange:e=>{let n=[...a];n[t]=e,o(n)},disabled:r}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove item`,className:`absolute top-2 right-2`,onClick:()=>o(a.filter((e,n)=>n!==t)),disabled:r,children:(0,U.jsx)(ep,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>o([...a,{}]),disabled:r,children:[(0,U.jsx)(Sf,{className:`size-4`}),`Add item`]})]}):null},JOt=({schema:e,value:t,onChange:n,disabled:r})=>{let i=typeof e.additionalProperties==`object`?e.additionalProperties.type:`string`,a=i===`number`||i===`integer`,[o,s]=(0,H.useState)(()=>G4(t)?Object.entries(t).map(([e,t])=>({key:e,value:String(t)})):[]),c=e=>{s(e);let t={};for(let n of e)if(n.key!==``)if(a){if(n.value.trim()===``)continue;let e=Number(n.value);if(Number.isNaN(e))continue;t[n.key]=e}else t[n.key]=n.value;n(Object.keys(t).length===0?void 0:t)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(iM,{value:e.key,placeholder:`Key`,onChange:n=>{let r=[...o];r[t]={...e,key:n.target.value},c(r)},disabled:r}),a?(0,U.jsx)(iM,{value:e.value,placeholder:`Value`,type:`number`,onChange:n=>{let r=[...o];r[t]={...e,value:n.target.value},c(r)},disabled:r}):(0,U.jsx)(W4,{value:e.value,placeholder:`Value`,onValueChange:n=>{let r=[...o];r[t]={...e,value:n},c(r)},disabled:r}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove entry`,onClick:()=>c(o.filter((e,n)=>n!==t)),disabled:r,children:(0,U.jsx)(ep,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>c([...o,{key:``,value:``}]),disabled:r,children:[(0,U.jsx)(Sf,{className:`size-4`}),`Add entry`]})]})},YOt=({id:e,value:t,onChange:n,disabled:r})=>{let[i,a]=(0,H.useState)(()=>t===void 0?``:JSON.stringify(t,void 0,2)),[o,s]=(0,H.useState)(!1);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(xw,{id:e,className:W(`font-mono text-xs`,o&&`border-destructive`),value:i,placeholder:`JSON value`,onChange:e=>{let t=e.target.value;if(a(t),t.trim()===``){s(!1),n(void 0);return}try{n(JSON.parse(t)),s(!1)}catch{s(!0)}},disabled:r}),o&&(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`Invalid JSON — the last valid value will be saved.`})]})};function G4(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var XOt=({designConfig:e,policyType:t,defaultHandler:n,isReadOnly:r,hasError:i,codeTabLabel:a,documentationSrc:o,designerContext:s,alwaysShowForm:c=!1,ref:l})=>{let{logEvent:u}=on(),{variant:d,isResolved:f}=xde(`policy-form-editor`),p=c||d===`test`,m=FOt(p?e?.optionsSchemaUrl:void 0),h=p?IOt(m.data):void 0,g=!!h,_=!!o,v=NOt(t),y=!!v,[b,x]=(0,H.useState)(n),[S,C]=(0,H.useState)(),[w,T]=(0,H.useState)(null),E=(0,H.useRef)(void 0),D=S??(y?`designer`:g?`form`:`code`),O=()=>{let e=E.current?.getValue();if(!e)throw Error(`The policy configuration is empty`);return JSON.parse(e)};(0,H.useImperativeHandle)(l,()=>({getHandler:()=>D===`code`?O():b}));let k=t=>{if(t!==D){if(D===`code`)try{x(O())}catch(e){T(`Fix the JSON before switching: ${e instanceof Error?e.message:`Unknown error`}`);return}t===`code`&&E.current?.setValue(JSON.stringify(b,void 0,2)),T(null),C(t),u(`policy-form-editor-mode-switched`,{policy:e?.id,mode:t})}};if(!f&&!c||m.isLoading)return(0,U.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,U.jsx)(oM,{className:`w-5 h-5 border-2`})});let A=y||g;return(0,U.jsxs)(`div`,{className:`flex flex-col min-h-0 min-w-0 h-full`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 border-b p-2`,children:(0,U.jsx)(L4,{variant:`outline`,type:`single`,value:D,onValueChange:e=>{e&&k(e)},children:[...y?[{value:`designer`,label:`Designer`}]:[],...g?[{value:`form`,label:`Form`}]:[],{value:`code`,label:A?`Code`:a},..._?[{value:`docs`,label:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Gu,{}),`Docs`]})}]:[]].map(({value:e,label:t})=>(0,U.jsx)(R4,{value:e,variant:`outline`,size:`xs`,className:`gap-1 px-2`,children:t},e))})}),w&&(0,U.jsx)(`p`,{className:`text-sm text-red-500 mx-3 mt-2`,children:w}),v&&(0,U.jsx)(`div`,{className:W(`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,D!==`designer`&&`hidden`),children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,U.jsx)(oM,{className:`w-5 h-5 border-2`})}),children:(0,U.jsx)(v,{options:b.options,onChange:e=>x({...b,options:e}),isReadOnly:r,operation:s?.operation,policyManager:s?.policyManager})})}),g&&D===`form`&&h&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,U.jsx)(U4,{schema:h,value:ZOt(b.options)?b.options:{},onChange:e=>x({...b,options:e}),disabled:r})}),(0,U.jsx)(`div`,{className:W(`flex-1 min-h-0 min-w-0`,D!==`code`&&`hidden`),children:(0,U.jsx)(yM,{options:{...KZ,readOnly:r,automaticLayout:!0},className:W({"border border-red-500":i}),width:`100%`,height:`100%`,language:`json`,onMount:e=>{E.current=e},defaultValue:JSON.stringify(b,void 0,2)})}),_&&D===`docs`&&o&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,U.jsx)(AOt,{documentationSrc:o})})]})};function ZOt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var K4=({designConfig:e,policyType:t,defaultHandler:n,initialName:r,policies:i,isReadOnly:a=!1,nameDisabled:o=!1,codeTabLabel:s=`Configuration`,alwaysShowForm:c=!1,designerContext:l,ref:u})=>{let[d,f]=(0,H.useState)(r),[p,m]=(0,H.useState)(null),h=(0,H.useRef)(null);return(0,H.useImperativeHandle)(u,()=>({getPolicyConfig:()=>{let e=Pgt(d,i);if(e)throw m(e),Error(e);if(!h.current)throw Error(`The policy editor is not ready`);try{let e=h.current.getHandler();return m(null),{name:d,handler:e}}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw m(t),Error(t)}}})),(0,U.jsxs)(`div`,{className:`flex flex-col w-full h-full min-h-0`,children:[(0,U.jsx)(N4,{name:d,onChangeName:f,disabled:o,policies:i}),(0,U.jsx)(`div`,{className:`border rounded overflow-hidden mt-4 flex-1 min-h-0 min-w-0`,children:(0,U.jsx)(XOt,{ref:h,designConfig:e,policyType:t,defaultHandler:n,isReadOnly:a,hasError:!!p,codeTabLabel:s,documentationSrc:e?.exampleHtml,alwaysShowForm:c,designerContext:l})}),p&&(0,U.jsx)(`p`,{className:`text-red-500 ml-2 mt-1`,children:p})]})},QOt=`Invalid Rewrite URL provided`,$Ot=`Tip: Use the API Test Console to test the behavior of request properties and environment variables.`,ekt=e=>`${e} is not a valid pattern`,tkt=e=>`Failed to parse component(s), rewrite result: ${e}`,nkt=e=>`${e} is not a valid URL`,q4=new Proxy({},{get(e,t){return typeof t==`symbol`?()=>`superProxy.toString()`:q4}}),rkt=e=>{if(e===``)return{errorType:`Error`,message:QOt};let t={url:new URL(`https://www.zuplo.com`),host:``,hostname:``,origin:``,port:``,protocol:``,headers:new Headers({}),params:{},pathname:``,method:``,query:{},search:``,env:q4,request:q4,e:encodeURIComponent,context:q4},n=(e,t={})=>Function(`vars`,[`const tagged = ( ${Object.keys(t).join(`, `)} ) =>`,`\`${e}\``,`return tagged(...Object.values(vars))`].join(`
482
+ M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}DDt.displayName=`MiniMap`,(0,H.memo)(DDt);var ODt=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,kDt={[U2.Line]:`right`,[U2.Handle]:`bottom-right`};function ADt({nodeId:e,position:t,variant:n=U2.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=STt(),y=typeof e==`string`?e:v,b=X2(),x=(0,H.useRef)(null),S=n===U2.Handle,C=Y2((0,H.useCallback)(ODt(S&&p),[S,p]),q2),w=(0,H.useRef)(null),T=t??kDt[n];return(0,H.useEffect)(()=>{if(!(!x.current||!y))return w.current||=swt({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=I2([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...VSt({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,U.jsx)(`div`,{className:U1([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,H.memo)(ADt);function m4({value:e,onValueChange:t,options:n,columns:r=2,layout:i=`cards`,idPrefix:a=`wizard-choice`,ariaLabel:o,className:s}){return(0,U.jsx)(rvt,{value:e,onValueChange:e=>t(e),"aria-label":o,className:W(i===`list`?`flex flex-col gap-2`:[`grid gap-3`,r===1&&`grid-cols-1`,r===2&&`grid-cols-2`,r===3&&`grid-cols-3`],s),children:n.map(t=>{let n=`${a}-${t.value}`,r=e===t.value,o=W(`rounded-md border transition-colors`,t.disabled?`cursor-not-allowed opacity-60`:`cursor-pointer`,r?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`bg-card hover:bg-neutral-50 dark:hover:bg-neutral-800/60`);return i===`list`?(0,U.jsxs)(dY,{htmlFor:n,className:W(`flex items-center gap-3 px-3 py-2.5`,o),children:[(0,U.jsx)(H1,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium sm:w-56 sm:shrink-0`,children:t.title}),t.description&&(0,U.jsx)(`div`,{className:`min-w-0 flex-1 text-xs leading-snug text-muted-foreground`,children:t.description})]})]},t.value):(0,U.jsxs)(dY,{htmlFor:n,className:W(`flex flex-col gap-1.5 p-3`,o),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(H1,{value:t.value,id:n,disabled:t.disabled}),t.icon,(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:t.title})]}),t.description&&(0,U.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t.description})]},t.value)})})}var h4=({tiles:e,selectedId:t,onSelect:n,fallbackIcon:r,columns:i=4,emptyState:a,className:o})=>{let[s,c]=(0,H.useState)(()=>new Set);return(0,U.jsxs)(`div`,{className:W(`grid auto-rows-min gap-2 p-0.5`,i===4?`grid-cols-4`:`grid-cols-3`,o),children:[e.map(e=>{let i=t===e.id,a=s.has(e.id)||!e.iconUrl;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-pressed":i,className:W(`flex flex-col items-center justify-center gap-1.5 rounded-md border bg-card p-2 text-center transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-800/60`,i?`border-zuplo-600 bg-zuplo-50 dark:bg-zuplo-950/40`:`border-border`),children:[a?r:(0,U.jsx)(`img`,{src:e.iconUrl,alt:``,className:`size-7 object-contain brightness-0 dark:invert`,onError:()=>c(t=>new Set(t).add(e.id))}),(0,U.jsx)(`span`,{className:`w-full truncate text-xs leading-tight`,children:e.name})]},e.id)}),e.length===0&&a&&(0,U.jsx)(`div`,{className:`col-span-full py-6 text-center text-sm text-muted-foreground`,children:a})]})},jDt=`#ff00bd`,MDt=`#98036a`,NDt=`#fff0fc`,PDt=`#9ca3af`,FDt=`#6b7280`,IDt=`#f7f9fb`,g4=152,_4=60,LDt={client:qu,gateway:Qf,origin:Mf},RDt=`!h-0 !min-h-0 !w-0 !min-w-0 !border-0 !bg-transparent`,zDt={box:({data:e})=>{let{label:t,kind:n,emphasis:r}=e,i=LDt[n];return(0,U.jsxs)(`div`,{className:W(`flex flex-col items-center justify-center gap-1.5 rounded-lg border bg-card px-2 text-center shadow-xs`,r?`border-zuplo-600`:`border-neutral-300 dark:border-neutral-600`),style:{width:g4,height:_4},children:[(0,U.jsx)(c4,{type:`target`,position:n2.Left,isConnectable:!1,className:RDt}),(0,U.jsx)(i,{"aria-hidden":`true`,strokeWidth:1.75,className:W(`size-[18px] shrink-0`,r?`text-zuplo-600`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:`text-xs font-medium leading-tight text-muted-foreground`,children:t}),(0,U.jsx)(c4,{type:`source`,position:n2.Right,isConnectable:!1,className:RDt})]})}},v4=[{id:`client`,type:`box`,position:{x:0,y:0},width:g4,height:_4,initialWidth:g4,initialHeight:_4,data:{label:`MCP Client`,kind:`client`,emphasis:!1},draggable:!1,selectable:!1},{id:`gateway`,type:`box`,position:{x:270,y:0},width:g4,height:_4,initialWidth:g4,initialHeight:_4,data:{label:`Zuplo MCP Gateway`,kind:`gateway`,emphasis:!0},draggable:!1,selectable:!1},{id:`origin`,type:`box`,position:{x:540,y:0},width:g4,height:_4,initialWidth:g4,initialHeight:_4,data:{label:`Origin MCP Server`,kind:`origin`,emphasis:!1},draggable:!1,selectable:!1}],BDt=e=>{let t=(e,t,n,r,i)=>({id:e,source:t,target:n,type:`smoothstep`,label:r,animated:!1,style:{stroke:i?jDt:PDt,strokeWidth:i?2:1.5},labelStyle:{fill:i?MDt:FDt,fontWeight:i?600:500,fontSize:11},labelBgStyle:{fill:i?NDt:IDt,fillOpacity:.95},labelBgPadding:[6,3],labelBgBorderRadius:4,markerEnd:{type:t2.ArrowClosed,width:14,height:14,color:i?jDt:PDt}});return[t(`inbound`,`client`,`gateway`,`Inbound auth`,e===`inbound`),t(`outbound`,`gateway`,`origin`,`Outbound auth`,e===`outbound`)]},y4={minX:Math.min(...v4.map(e=>e.position.x)),minY:Math.min(...v4.map(e=>e.position.y)),maxX:Math.max(...v4.map(e=>e.position.x+(e.width??g4))),maxY:Math.max(...v4.map(e=>e.position.y+(e.height??_4)))},VDt=y4.maxX-y4.minX,HDt=y4.maxY-y4.minY,UDt=.5,WDt=1.2,GDt=.12;function KDt(e,t){let n=Math.min(e/VDt,t/HDt),r=Math.min(WDt,Math.max(UDt,n*(1-GDt*2)));return{x:(e-VDt*r)/2-y4.minX*r,y:(t-HDt*r)/2-y4.minY*r,zoom:r}}var qDt=({active:e})=>{let t=(0,H.useMemo)(()=>BDt(e),[e]),n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useCallback)(()=>{let e=n.current,t=e?.clientWidth??0,i=e?.clientHeight??0;t>0&&i>0&&r.current?.setViewport(KDt(t,i))},[]),a=(0,H.useCallback)(e=>{r.current=e,i()},[i]);return(0,H.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=requestAnimationFrame(i)});return r.observe(e),()=>{cancelAnimationFrame(t),r.disconnect()}},[i]),(0,U.jsx)(`div`,{ref:n,role:`img`,"aria-label":`MCP request flow, configuring ${e} authentication`,className:`h-36 w-full overflow-hidden rounded-md border border-border`,children:(0,U.jsx)(tDt,{nodes:v4,edges:t,nodeTypes:zDt,onInit:a,minZoom:UDt,maxZoom:WDt,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:IDt},children:(0,U.jsx)(sDt,{variant:d4.Dots,gap:16,size:1,color:`#dbe1e8`})})})};function b4(e){return e&&e.length>0?e:void 0}function x4(e){return e&&Object.keys(e).length>0?e:void 0}function JDt(e){let t=new Set;for(let n of e??[]){let e=n.trim();e&&t.add(e)}return[...t]}function S4(e,t){if(t!==`rolesAndGroups`)return{};if(e.public===!0)return{public:!0};let n=JDt(e.roles),r=JDt(e.groups);return{...n.length>0?{roles:n}:{},...r.length>0?{groups:r}:{}}}function YDt(e){let t=e&&typeof e==`object`?e:{};return{accessControlMode:t.accessControl?.mode===`rolesAndGroups`?`rolesAndGroups`:`allPublic`,catalog:{tools:C4(t.tools,`name`,e=>({name:e})),prompts:C4(t.prompts,`name`,e=>({name:e})),resources:C4(t.resources,`uri`,e=>({uri:e,name:e})),resourceTemplates:C4(t.resourceTemplates,`uriTemplate`,e=>({uriTemplate:e,name:e}))}}}function C4(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 w4(e){return XDt(e.catalog,e.accessControlMode)}function XDt(e,t=`allPublic`){return{...t===`rolesAndGroups`?{accessControl:{mode:t}}:{},tools:e.tools.flatMap(e=>{let n=b4(e.name);if(!n)return[];let r=b4(e.description),i=x4(e.annotations),a=x4(e._meta);return[{name:n,...r?{description:r}:{},...i?{annotations:i}:{},...a?{_meta:a}:{},...S4(e,t)}]}),prompts:e.prompts.flatMap(e=>{let n=b4(e.name);if(!n)return[];let r=b4(e.description),i=x4(e._meta);return[{name:n,...r?{description:r}:{},...i?{_meta:i}:{},...S4(e,t)}]}),resources:e.resources.flatMap(e=>{let n=b4(e.uri);if(!n)return[];let r=b4(e.name),i=b4(e.description),a=b4(e.mimeType),o=x4(e._meta);return[{uri:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...S4(e,t)}]}),resourceTemplates:e.resourceTemplates.flatMap(e=>{let n=b4(e.uriTemplate);if(!n)return[];let r=b4(e.name),i=b4(e.description),a=b4(e.mimeType),o=x4(e._meta);return[{uriTemplate:n,...r?{name:r}:{},...i?{description:i}:{},...a?{mimeType:a}:{},...o?{_meta:o}:{},...S4(e,t)}]})}}var T4=e=>`/mcp-idp-icons/${e}.svg`,E4=[{id:`auth0`,label:`Auth0`,description:`Auth0 by Okta`,iconUrl:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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:T4(`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 D4(e){return E4.find(t=>t.id===e)}function ZDt(e){return Object.fromEntries(e.fields.map(e=>[e.key,e.defaultValue]))}var QDt=`Most Used`,$Dt=`Other`,eOt=[`rate-limit`,`api-key`],tOt=[{name:`Rate Limiting & Quotas`,baseIds:[`rate-limit`,`complex-rate-limit`,`quota`]},{name:`Authentication`,baseIds:[`api-key`,`basic-auth`,`mtls-auth`,`ldap-auth`,`open-id-jwt-auth`,`okta-jwt-auth`,`auth0-jwt-auth`,`clerk-jwt-auth`,`cognito-jwt-auth`,`firebase-jwt`,`supabase-jwt-auth`,`propel-auth-jwt`,`curity-phantom-token`,`stripe-webhook-verification`,`web-bot-auth`]},{name:`Authorization`,baseIds:[`jwt-scopes`,`openfga-authz`,`okta-fga-authz`,`axiomatics-authz`,`authzen`,`geo-filter`,`require-origin`]},{name:`MCP Authentication`,baseIds:[`mcp-oauth`,`mcp-auth0-oauth`,`mcp-clerk-oauth`,`mcp-cognito-oauth`,`mcp-entra-oauth`,`mcp-google-oauth`,`mcp-keycloak-oauth`,`mcp-logto-oauth`,`mcp-okta-oauth`,`mcp-onelogin-oauth`,`mcp-ping-oauth`,`mcp-workos-oauth`,`mcp-token-exchange`,`mcp-capability-filter`]},{name:`AI Gateway`,baseIds:[`ai-gateway-model-filtering-v2`,`ai-gateway-fallback-model-v2`,`ai-gateway-metering-v2`,`ai-gateway-semantic-cache-v2`,`ai-gateway-dlp`,`ai-gateway-smart-router`,`akamai-ai-firewall-v2`,`comet-opik-tracing-v2`,`galileo-tracing-v2`]},{name:`AI & Security`,baseIds:[`prompt-injection`,`bot-detection`,`akamai-firewall-for-ai`,`secret-masking`]},{name:`Caching`,baseIds:[`caching`,`semantic-cache`]},{name:`Transformations`,baseIds:[`xml-to-json`,`formdata-to-json`,`set-body`,`set-headers`,`set-query-params`,`set-status`,`remove-headers`,`remove-query-params`,`clear-headers`,`query-param-to-header`,`replace-string`,`change-method`]},{name:`Validation`,baseIds:[`validate-json-schema`,`request-validation`,`request-size-limit`]},{name:`Traffic Management`,baseIds:[`traffic-splitting`,`brownout`,`sleep`,`mock-api`,`http-deprecation`]},{name:`GraphQL`,baseIds:[`graphql-complexity-limit`,`graphql-disable-introspection`,`graphql-introspection-filter`]},{name:`Monetization & Metering`,baseIds:[`monetization`,`openmeter`,`amberflo-metering`,`moesif`,`readme-metrics`]},{name:`Logging & Tracing`,baseIds:[`audit-log`]},{name:`Upstream Auth`,baseIds:[`set-upstream-api-key`,`upstream-azure-ad-service-auth`,`upstream-firebase-admin-auth`,`upstream-firebase-user-auth`,`upstream-gcp-federated-auth`,`upstream-gcp-jwt`,`upstream-gcp-service-auth`,`upstream-zuplo-jwt-auth`]},{name:`Custom & Composite`,baseIds:[`custom-code`,`composite`]}],nOt=/-(inbound|outbound|internal)$/,O4=e=>e.replace(nOt,``),k4=new Map;for(let e of tOt)for(let t of e.baseIds)k4.has(t)||k4.set(t,e.name);var rOt=e=>k4.get(O4(e.id))??`Other`,iOt=e=>k4.get(O4(e))===`Authentication`,aOt=e=>eOt.includes(O4(e.id)),oOt=e=>{let t=new Map,n=[];for(let r of e){aOt(r)&&n.push(r);let e=rOt(r),i=t.get(e);i?i.push(r):t.set(e,[r])}let r=[];n.length>0&&r.push({name:QDt,policies:n});for(let{name:e}of tOt){let n=t.get(e);n&&n.length>0&&r.push({name:e,policies:n})}let i=t.get($Dt);return i&&i.length>0&&r.push({name:$Dt,policies:i}),r},sOt=[...E4.map(e=>e.policyType)];function cOt(e){return sOt.includes(e)||iOt(e)}var A4=`mcp-token-exchange-inbound`,j4=`mcp-capability-filter-inbound`,lOt=`set-upstream-api-key-inbound`,uOt=`remove-headers-inbound`;function M4(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 dOt=e=>e.toLowerCase().replaceAll(` `,`-`),N4=({name:e,onChangeName:t,disabled:n,policies:r})=>{let[i,a]=(0,H.useState)(null);return(0,U.jsxs)(`div`,{className:`grid grid-cols-12 text-sm gap-2 items-center pt-1`,children:[(0,U.jsx)(`label`,{className:`col-span-1`,children:`Name`}),(0,U.jsx)(`div`,{className:`col-span-11`,children:(0,U.jsx)(iM,{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=dOt(n.toLowerCase());a(Pgt(i,r)),t(i)},"aria-describedby":`email-description`})}),i&&(0,U.jsx)(`div`,{className:`col-span-11 col-start-2 mt-1 text-red-600`,children:i})]})},fOt=`Toggle`,pOt=H.forwardRef((e,t)=>{let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=Ct({prop:n,onChange:i,defaultProp:r??!1,caller:fOt});return(0,U.jsx)(ac.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:Xs(e.onClick,()=>{e.disabled||s(!o)})})});pOt.displayName=fOt;var P4=`ToggleGroup`,[mOt,hOt]=T(P4,[OW]),gOt=OW(),F4=H.forwardRef((e,t)=>{let{type:n,...r}=e;if(n===`single`)return(0,U.jsx)(yOt,{...r,ref:t});if(n===`multiple`)return(0,U.jsx)(bOt,{...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${P4}\``)});F4.displayName=P4;var[_Ot,vOt]=mOt(P4),yOt=H.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=Ct({prop:n,defaultProp:r??``,onChange:i,caller:P4});return(0,U.jsx)(_Ot,{scope:e.__scopeToggleGroup,type:`single`,value:H.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:H.useCallback(()=>s(``),[s]),children:(0,U.jsx)(COt,{...a,ref:t})})}),bOt=H.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=Ct({prop:n,defaultProp:r??[],onChange:i,caller:P4}),c=H.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=H.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,U.jsx)(_Ot,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,U.jsx)(COt,{...a,ref:t})})});F4.displayName=P4;var[xOt,SOt]=mOt(P4),COt=H.forwardRef((e,t)=>{let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=gOt(n),u=At(o),d={role:`group`,dir:u,...c};return(0,U.jsx)(xOt,{scope:n,rovingFocus:i,disabled:r,children:i?(0,U.jsx)(NW,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,U.jsx)(ac.div,{...d,ref:t})}):(0,U.jsx)(ac.div,{...d,ref:t})})}),I4=`ToggleGroupItem`,wOt=H.forwardRef((e,t)=>{let n=vOt(I4,e.__scopeToggleGroup),r=SOt(I4,e.__scopeToggleGroup),i=gOt(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=H.useRef(null);return r.rovingFocus?(0,U.jsx)(PW,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,U.jsx)(TOt,{...s,ref:t})}):(0,U.jsx)(TOt,{...s,ref:t})});wOt.displayName=I4;var TOt=H.forwardRef((e,t)=>{let{__scopeToggleGroup:n,value:r,...i}=e,a=vOt(I4,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0};return(0,U.jsx)(pOt,{...a.type===`single`?o:void 0,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})}),EOt=F4,DOt=wOt,OOt=Ou(`inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground`},size:{default:`h-9 px-2 min-w-9`,xs:`h-6 px-1.5 min-w-6 text-xs [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 px-1.5 min-w-8`,lg:`h-10 px-2.5 min-w-10`}},defaultVariants:{variant:`default`,size:`default`}}),kOt=H.createContext({size:`default`,variant:`default`,spacing:0});function L4({className:e,variant:t,size:n,spacing:r=0,children:i,...a}){return(0,U.jsx)(EOt,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,style:{"--gap":r},className:W(`group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs`,e),...a,children:(0,U.jsx)(kOt.Provider,{value:{variant:t,size:n,spacing:r},children:i})})}function R4({className:e,children:t,variant:n,size:r,...i}){let a=H.useContext(kOt);return(0,U.jsx)(DOt,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:W(OOt({variant:a.variant||n,size:a.size||r}),`w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10`,`data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l`,e),...i,children:t})}var AOt=({documentationSrc:e,className:t})=>(0,U.jsx)(`div`,{className:W(`prose prose-neutral prose-sm dark:prose-invert z-10 prose-headings:mt-2 prose-headings:text-sm max-w-full [&_li>div]:inline [&_li>div>p]:inline [&_code::before]:content-none [&_code::after]:content-none`,t),dangerouslySetInnerHTML:{__html:e}}),jOt=({documentationSrc:e})=>(0,U.jsxs)(`div`,{className:`px-4 py-2 border-t h-full overflow-y-auto h-[stretch]`,children:[(0,U.jsx)(`h3`,{className:`text-lg font-medium text-foreground`,children:`Documentation`}),(0,U.jsx)(AOt,{documentationSrc:e})]}),MOt={[j4]:(0,H.lazy)(()=>gn(()=>import(`./McpCapabilityFilterDesigner-6l45_xy_.js`),__vite__mapDeps([7,1,8,2])))};function NOt(e){return e?MOt[e]:void 0}var POt=(e=!1)=>async({queryKey:t})=>{let[n]=t;if(typeof n!=`string`)throw new he({type:`https://zup.fail/invalid-query-key`,title:`Invalid query key`});let r=new Request(n),i;try{i=await fetch(r)}catch(e){throw e instanceof TypeError?new he({type:`https://zup.fail/api-request-failed`,title:`API request failed`,status:500,instance:n}):e}if(!i.ok){let e=new He(`Error while making request. Please try again or contact support if the problem persists.`);throw await e.tryReadResponse(i),e}try{return await(e?i.clone().json():i.clone().text())}catch(e){let t=await i.clone().text();throw Zt.captureException(e,{message:`Failed to parse response of ${n} to JSON`,responseText:t,status:i.status,requestUrl:n}),e}};function z4(e,{json:t,...n}={}){return Oe({queryKey:[e.url],queryFn:POt(t),...n})}var B4=(e={})=>z4(mt.cdnContent(`/portal/policies.v6.json`),{...e,json:!0}),FOt=(e,t={})=>z4({url:e??``},{...t,enabled:!!e&&t.enabled!==!1,json:!0});function IOt(e){let t=e?.properties?.handler?.properties?.options;if(!(!t||t.type!==`object`||!t.properties||Object.keys(t.properties).length===0))return t}function LOt(e){if(e.oneOf||e.anyOf||e.allOf||e.const)return`json`;if(e.enum)return e.enum.every(e=>typeof e==`string`)?`select`:`json`;if(typeof e.type!=`string`)return`json`;switch(e.type){case`boolean`:return`boolean`;case`number`:case`integer`:return`number`;case`string`:return`text`;case`array`:{let t=e.items;if(t&&!Array.isArray(t)){if(t.type===`string`&&!t.oneOf&&!t.anyOf&&!t.allOf)return`string-array`;if(t.type===`object`&&t.properties&&Object.keys(t.properties).length>0)return`object-array`}return`json`}case`object`:{if(e.properties&&Object.keys(e.properties).length>0)return`object`;let t=e.additionalProperties;return t&&typeof t==`object`&&(t.type===`string`||t.type===`number`||t.type===`integer`)?`record`:`json`}default:return`json`}}function V4(e,t){return e.required?.includes(t)??!1}function ROt(e){return e[`x-advanced`]===!0||e[`x-show-example`]===!1}var zOt=()=>{let e=(0,H.useContext)(mp);return!!(e?.account&&e?.project)},BOt=({children:e,onInject:t,isEnabled:n=!0})=>{let r=zOt();return!n||!r?(0,U.jsx)(`div`,{className:`relative w-full`,children:e}):(0,U.jsx)(VOt,{onInject:t,children:e})},VOt=({children:e,onInject:t})=>{let n=hp([`account`,`project`]),r=NN(n.account.name,n.project.name);return(0,U.jsxs)(tb,{children:[(0,U.jsxs)(`div`,{className:`relative w-full`,children:[e,(0,U.jsx)(nb,{asChild:!0,children:(0,U.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`flex-none ml-1 absolute top-1 right-1 bg-card`,title:`Select environment variable`,children:(0,U.jsx)(sf,{className:`w-4`})})})]}),(0,U.jsxs)(ib,{children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Environment Variables`}),(0,U.jsx)(cb,{asChild:!0,children:(0,U.jsxs)(ZD,{className:`mt-4 divide-y divide-double bg-gray-50 dark:bg-neutral-900 max-h-96 overflow-y-auto`,children:[r.isPending?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rO,{className:`h-6 w-2/3 m-1`}),(0,U.jsx)(rO,{className:`h-6 w-2/3 m-1`}),(0,U.jsx)(rO,{className:`h-6 w-2/3 m-1`})]}):r.data?.length===0&&(0,U.jsx)(`div`,{className:`p-2`,children:`No environment variables`}),r.data?.map(e=>(0,U.jsxs)(`div`,{className:`p-2 py-3 flex justify-between items-center`,children:[(0,U.jsx)(`div`,{children:e.name}),(0,U.jsx)(rb,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,size:`xs`,className:`flex-none`,onClick:()=>t(e,`$env(${e.name})`),children:`Use`})})]},e.id))]})})]}),(0,U.jsx)(ob,{children:(0,U.jsx)(rb,{children:(0,U.jsx)(X,{type:`submit`,variant:`outline`,children:`Close`})})})]})]})},H4=(0,H.createContext)(!0),U4=({schema:e,value:t,onChange:n,disabled:r,allowEnvVariables:i})=>{let a=(0,H.useContext)(H4),o=i??a,s=(e,r)=>{if(r===void 0){let{[e]:r,...i}=t;n(i)}else n({...t,[e]:r})},c=(n,i)=>(0,U.jsx)(UOt,{name:n,schema:i,required:V4(e,n),value:t[n],onChange:e=>s(n,e),disabled:r},n),l=Object.entries(e.properties??{}),u=(t,n)=>ROt(n)&&!V4(e,t),d=l.filter(([e,t])=>u(e,t)),f=l.filter(([e,t])=>!u(e,t)),p=[...f.filter(([t])=>V4(e,t)),...f.filter(([t])=>!V4(e,t))];return(0,U.jsx)(H4.Provider,{value:o,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[p.map(([e,t])=>c(e,t)),d.length>0&&(0,U.jsx)(HOt,{defaultOpen:d.some(([e])=>t[e]!==void 0),children:d.map(([e,t])=>c(e,t))})]})})},HOt=({defaultOpen:e,children:t})=>{let[n,r]=(0,H.useState)(e);return(0,U.jsxs)(ET,{open:n,onOpenChange:r,children:[(0,U.jsxs)(DT,{className:`flex items-center gap-1 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground`,children:[(0,U.jsx)(nd,{className:W(`size-4 transition-transform`,n&&`rotate-90`)}),n?`Hide advanced options`:`Show advanced options`]}),(0,U.jsx)(OT,{className:`flex flex-col gap-5 pt-5`,children:t})]})},UOt=({name:e,schema:t,required:n,value:r,onChange:i,disabled:a})=>{let o=(0,H.useId)(),s=LOt(t);return s===`boolean`?(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsx)(WOt,{htmlFor:o,name:e,schema:t,required:n}),(0,U.jsx)(y1,{id:o,checked:r===!0,onCheckedChange:e=>i(e),disabled:a})]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(WOt,{htmlFor:o,name:e,schema:t,required:n}),(0,U.jsx)(GOt,{id:o,kind:s,schema:t,required:n,value:r,onChange:i,disabled:a})]})},WOt=({htmlFor:e,name:t,schema:n,required:r})=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,U.jsxs)(dY,{htmlFor:e,className:`capitalize`,children:[t,r?(0,U.jsx)(`span`,{className:`text-destructive`,children:` *`}):(0,U.jsx)(`span`,{className:`ml-1 font-normal normal-case text-muted-foreground`,children:`(optional)`})]}),n.description&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.description})]}),GOt=({id:e,kind:t,schema:n,required:r,value:i,onChange:a,disabled:o})=>{switch(t){case`text`:return(0,U.jsx)(W4,{id:e,value:typeof i==`string`?i:``,placeholder:typeof n.default==`string`?n.default:void 0,onValueChange:e=>a(e===``?void 0:e),disabled:o});case`number`:return(0,U.jsx)(iM,{id:e,type:`number`,step:n.type===`integer`?1:void 0,value:typeof i==`number`?i:``,placeholder:typeof n.default==`number`?String(n.default):void 0,onChange:e=>{let t=e.target.value===``?NaN:Number(e.target.value);a(Number.isNaN(t)?void 0:t)},disabled:o});case`select`:return(0,U.jsxs)(mJ,{value:typeof i==`string`?i:Vet,onValueChange:e=>a(e===`__UNSET`?void 0:e),disabled:o,children:[(0,U.jsx)(_J,{id:e,className:`w-full`,children:(0,U.jsx)(gJ,{placeholder:`Select an option`})}),(0,U.jsxs)(vJ,{children:[!r&&(0,U.jsx)(bJ,{value:`__UNSET`,children:(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`Not set`})}),(n.enum??[]).filter(e=>typeof e==`string`).map(e=>(0,U.jsx)(bJ,{value:e,children:e},e))]})]});case`string-array`:return(0,U.jsx)(KOt,{value:i,onChange:a,disabled:o});case`object-array`:return(0,U.jsx)(qOt,{schema:n,value:i,onChange:a,disabled:o});case`record`:return(0,U.jsx)(JOt,{schema:n,value:i,onChange:a,disabled:o});case`object`:return(0,U.jsx)(`div`,{className:`border rounded-md p-3 ml-1`,children:(0,U.jsx)(U4,{schema:n,value:G4(i)?i:{},onChange:e=>a(Object.keys(e).length===0?void 0:e),disabled:o})});case`json`:return(0,U.jsx)(YOt,{id:e,value:i,onChange:a,disabled:o})}},W4=({id:e,value:t,placeholder:n,onValueChange:r,disabled:i})=>{let a=(0,H.useContext)(H4),o=zOt(),s=a&&o&&!i;return(0,U.jsx)(BOt,{isEnabled:s,onInject:(e,t)=>r(t),children:(0,U.jsx)(iM,{id:e,value:t,placeholder:n,onChange:e=>r(e.target.value),disabled:i,className:W(s&&`pr-10`)})})},KOt=({value:e,onChange:t,disabled:n})=>{let r=Array.isArray(e)?e.map(e=>typeof e==`string`?e:String(e)):[],i=e=>{t(e.length===0?void 0:e)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(W4,{value:e,onValueChange:e=>{let n=[...r];n[t]=e,i(n)},disabled:n}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove item`,onClick:()=>i(r.filter((e,n)=>n!==t)),disabled:n,children:(0,U.jsx)(ep,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>i([...r,``]),disabled:n,children:[(0,U.jsx)(Sf,{className:`size-4`}),`Add item`]})]})},qOt=({schema:e,value:t,onChange:n,disabled:r})=>{let i=Array.isArray(e.items)?void 0:e.items,a=Array.isArray(t)?t:[],o=e=>{n(e.length===0?void 0:e)};return i?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a.map((e,t)=>(0,U.jsxs)(`div`,{className:`relative border rounded-md p-3 pr-10`,children:[(0,U.jsx)(U4,{schema:i,value:G4(e)?e:{},onChange:e=>{let n=[...a];n[t]=e,o(n)},disabled:r}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove item`,className:`absolute top-2 right-2`,onClick:()=>o(a.filter((e,n)=>n!==t)),disabled:r,children:(0,U.jsx)(ep,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>o([...a,{}]),disabled:r,children:[(0,U.jsx)(Sf,{className:`size-4`}),`Add item`]})]}):null},JOt=({schema:e,value:t,onChange:n,disabled:r})=>{let i=typeof e.additionalProperties==`object`?e.additionalProperties.type:`string`,a=i===`number`||i===`integer`,[o,s]=(0,H.useState)(()=>G4(t)?Object.entries(t).map(([e,t])=>({key:e,value:String(t)})):[]),c=e=>{s(e);let t={};for(let n of e)if(n.key!==``)if(a){if(n.value.trim()===``)continue;let e=Number(n.value);if(Number.isNaN(e))continue;t[n.key]=e}else t[n.key]=n.value;n(Object.keys(t).length===0?void 0:t)};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(iM,{value:e.key,placeholder:`Key`,onChange:n=>{let r=[...o];r[t]={...e,key:n.target.value},c(r)},disabled:r}),a?(0,U.jsx)(iM,{value:e.value,placeholder:`Value`,type:`number`,onChange:n=>{let r=[...o];r[t]={...e,value:n.target.value},c(r)},disabled:r}):(0,U.jsx)(W4,{value:e.value,placeholder:`Value`,onValueChange:n=>{let r=[...o];r[t]={...e,value:n},c(r)},disabled:r}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Remove entry`,onClick:()=>c(o.filter((e,n)=>n!==t)),disabled:r,children:(0,U.jsx)(ep,{className:`size-4`})})]},t)),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>c([...o,{key:``,value:``}]),disabled:r,children:[(0,U.jsx)(Sf,{className:`size-4`}),`Add entry`]})]})},YOt=({id:e,value:t,onChange:n,disabled:r})=>{let[i,a]=(0,H.useState)(()=>t===void 0?``:JSON.stringify(t,void 0,2)),[o,s]=(0,H.useState)(!1);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(xw,{id:e,className:W(`font-mono text-xs`,o&&`border-destructive`),value:i,placeholder:`JSON value`,onChange:e=>{let t=e.target.value;if(a(t),t.trim()===``){s(!1),n(void 0);return}try{n(JSON.parse(t)),s(!1)}catch{s(!0)}},disabled:r}),o&&(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`Invalid JSON — the last valid value will be saved.`})]})};function G4(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var XOt=({designConfig:e,policyType:t,defaultHandler:n,isReadOnly:r,hasError:i,codeTabLabel:a,documentationSrc:o,designerContext:s,alwaysShowForm:c=!1,ref:l})=>{let{logEvent:u}=on(),{variant:d,isResolved:f}=xde(`policy-form-editor`),p=c||d===`test`,m=FOt(p?e?.optionsSchemaUrl:void 0),h=p?IOt(m.data):void 0,g=!!h,_=!!o,v=NOt(t),y=!!v,[b,x]=(0,H.useState)(n),[S,C]=(0,H.useState)(),[w,T]=(0,H.useState)(null),E=(0,H.useRef)(void 0),D=S??(y?`designer`:g?`form`:`code`),O=()=>{let e=E.current?.getValue();if(!e)throw Error(`The policy configuration is empty`);return JSON.parse(e)};(0,H.useImperativeHandle)(l,()=>({getHandler:()=>D===`code`?O():b}));let k=t=>{if(t!==D){if(D===`code`)try{x(O())}catch(e){T(`Fix the JSON before switching: ${e instanceof Error?e.message:`Unknown error`}`);return}t===`code`&&E.current?.setValue(JSON.stringify(b,void 0,2)),T(null),C(t),u(`policy-form-editor-mode-switched`,{policy:e?.id,mode:t})}};if(!f&&!c||m.isLoading)return(0,U.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,U.jsx)(oM,{className:`w-5 h-5 border-2`})});let A=y||g;return(0,U.jsxs)(`div`,{className:`flex flex-col min-h-0 min-w-0 h-full`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 border-b p-2`,children:(0,U.jsx)(L4,{variant:`outline`,type:`single`,value:D,onValueChange:e=>{e&&k(e)},children:[...y?[{value:`designer`,label:`Designer`}]:[],...g?[{value:`form`,label:`Form`}]:[],{value:`code`,label:A?`Code`:a},..._?[{value:`docs`,label:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Gu,{}),`Docs`]})}]:[]].map(({value:e,label:t})=>(0,U.jsx)(R4,{value:e,variant:`outline`,size:`xs`,className:`gap-1 px-2`,children:t},e))})}),w&&(0,U.jsx)(`p`,{className:`text-sm text-red-500 mx-3 mt-2`,children:w}),v&&(0,U.jsx)(`div`,{className:W(`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,D!==`designer`&&`hidden`),children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex items-center justify-center min-h-40`,children:(0,U.jsx)(oM,{className:`w-5 h-5 border-2`})}),children:(0,U.jsx)(v,{options:b.options,onChange:e=>x({...b,options:e}),isReadOnly:r,operation:s?.operation,policyManager:s?.policyManager})})}),g&&D===`form`&&h&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,U.jsx)(U4,{schema:h,value:ZOt(b.options)?b.options:{},onChange:e=>x({...b,options:e}),disabled:r})}),(0,U.jsx)(`div`,{className:W(`flex-1 min-h-0 min-w-0`,D!==`code`&&`hidden`),children:(0,U.jsx)(yM,{options:{...KZ,readOnly:r,automaticLayout:!0},className:W({"border border-red-500":i}),width:`100%`,height:`100%`,language:`json`,onMount:e=>{E.current=e},defaultValue:JSON.stringify(b,void 0,2)})}),_&&D===`docs`&&o&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,U.jsx)(AOt,{documentationSrc:o})})]})};function ZOt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var K4=({designConfig:e,policyType:t,defaultHandler:n,initialName:r,policies:i,isReadOnly:a=!1,nameDisabled:o=!1,codeTabLabel:s=`Configuration`,alwaysShowForm:c=!1,designerContext:l,ref:u})=>{let[d,f]=(0,H.useState)(r),[p,m]=(0,H.useState)(null),h=(0,H.useRef)(null);return(0,H.useImperativeHandle)(u,()=>({getPolicyConfig:()=>{let e=Pgt(d,i);if(e)throw m(e),Error(e);if(!h.current)throw Error(`The policy editor is not ready`);try{let e=h.current.getHandler();return m(null),{name:d,handler:e}}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw m(t),Error(t)}}})),(0,U.jsxs)(`div`,{className:`flex flex-col w-full h-full min-h-0`,children:[(0,U.jsx)(N4,{name:d,onChangeName:f,disabled:o,policies:i}),(0,U.jsx)(`div`,{className:`border rounded overflow-hidden mt-4 flex-1 min-h-0 min-w-0`,children:(0,U.jsx)(XOt,{ref:h,designConfig:e,policyType:t,defaultHandler:n,isReadOnly:a,hasError:!!p,codeTabLabel:s,documentationSrc:e?.exampleHtml,alwaysShowForm:c,designerContext:l})}),p&&(0,U.jsx)(`p`,{className:`text-red-500 ml-2 mt-1`,children:p})]})},QOt=`Invalid Rewrite URL provided`,$Ot=`Tip: Use the API Test Console to test the behavior of request properties and environment variables.`,ekt=e=>`${e} is not a valid pattern`,tkt=e=>`Failed to parse component(s), rewrite result: ${e}`,nkt=e=>`${e} is not a valid URL`,q4=new Proxy({},{get(e,t){return typeof t==`symbol`?()=>`superProxy.toString()`:q4}}),rkt=e=>{if(e===``)return{errorType:`Error`,message:QOt};let t={url:new URL(`https://www.zuplo.com`),host:``,hostname:``,origin:``,port:``,protocol:``,headers:new Headers({}),params:{},pathname:``,method:``,query:{},search:``,env:q4,request:q4,e:encodeURIComponent,context:q4},n=(e,t={})=>Function(`vars`,[`const tagged = ( ${Object.keys(t).join(`, `)} ) =>`,`\`${e}\``,`return tagged(...Object.values(vars))`].join(`
483
483
  `))(t),r=null;try{r=n(e,t)}catch(t){return t instanceof ReferenceError||t instanceof TypeError?{errorType:`Error`,message:t.message}:{errorType:`Error`,message:ekt(e)}}return r?e.includes(`env.`)||e.includes(`$env(`)||e.includes(`params.`)||e.includes(`{pathname`)||e.includes(`{method`)||e.includes(`query.`)||e.includes(`{headers`)||e.includes(`request`)||e.includes(`{context`)?{errorType:`Warning`,message:$Ot}:ikt(r)?{errorType:`Error`,message:tkt(r)}:akt(r)?{errorType:null,message:null}:{errorType:`Error`,message:nkt(r)}:{errorType:`Error`,message:`Its null`}},ikt=e=>e.includes(`undefined`)||e.includes(`[object`),akt=e=>{try{return new URL(e),!0}catch{return!1}},okt=[{token:"${pathname}",example:`/v1/products/:productId`},{token:"${search}",example:`?category=cars`},{token:"${params.productId}",example:`:productId`},{token:"${query.category}",example:`cars`},{token:'${headers.get("content-type")}',example:`application/json`},{token:"${method}",example:`GET`},{token:"${host}",example:`example.com:8080`},{token:"${hostname}",example:`example.com`},{token:"${origin}",example:`https://example.com`},{token:"${port}",example:`8080`},{token:"${protocol}",example:`https:`},{token:"${url}",example:`https://example.com:8080/v1/products/…`},{token:"${request.user.sub}",example:`user284787985473`},{token:"${context.route.custom}",example:`my-value`}],J4=/\$env\(([A-Za-z_][A-Za-z0-9_]*)\)/g;function skt(e,t,n){let r=Math.min(n.start,e.length),i=Math.min(Math.max(n.end,r),e.length);return{url:e.slice(0,r)+t+e.slice(i),caret:r+t.length}}function ckt(e){return e.replace(J4,"${env.$1}")}function lkt(e){let t=J4.test(e);return J4.lastIndex=0,t}var ukt=({url:e,onUrlChange:t,isReadOnly:n})=>{let r=J4.exec(e)?.[1];return J4.lastIndex=0,r?(0,U.jsxs)(`div`,{"data-test":`rewrite-url-env-syntax-warning`,className:`flex flex-wrap items-center justify-between gap-2 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`code`,{className:`font-mono`,children:`$env(${r})`}),` is policy-options syntax and won't be substituted in a rewrite URL. Use`,` `,(0,U.jsx)(`code`,{className:`font-mono`,children:`\${env.${r}}`}),` here.`]}),!n&&(0,U.jsxs)(X,{type:`button`,variant:`outline`,size:`xs`,className:`shrink-0`,"data-test":`rewrite-url-fix-env-syntax`,onClick:()=>t(ckt(e)),children:[`Replace with `,`\${env.${r}}`]})]}):null},dkt=({url:e,onUrlChange:t,isReadOnly:n,label:r,environmentVariableNames:i=[],...a})=>{let o=(0,H.useId)(),s=(0,H.useRef)(null),c=(0,H.useRef)(!1),l=(0,H.useRef)(null),{errorType:u,message:d}=rkt(e),f=u===`Error`,p=n=>{let r=s.current,i=skt(e,n,c.current&&r&&r.selectionStart!=null?{start:r.selectionStart,end:r.selectionEnd??r.selectionStart}:{start:e.length,end:e.length});l.current=i.caret,t(i.url)},m=()=>{let e=l.current;l.current=null;let t=s.current;if(t&&e!=null){t.focus();let n=Math.min(e,t.value.length);t.setSelectionRange(n,n)}};return(0,U.jsxs)(U.Fragment,{children:[r&&(0,U.jsx)(dY,{htmlFor:o,className:`self-center text-sm font-normal`,children:r}),(0,U.jsxs)(`div`,{className:W(`flex flex-col gap-1.5`,!r&&`col-span-full`),children:[(0,U.jsxs)(`div`,{className:`relative w-full`,children:[(0,U.jsx)(iM,{ref:s,disabled:n,id:o,name:`rewrite-url`,"data-test":`rewrite-url-input`,"aria-invalid":f,...a,onFocus:e=>{c.current=!0,a.onFocus?.(e)},className:W(a.className,`pr-10`),onChange:e=>{t(e.target.value)},value:e}),(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{asChild:!0,children:(0,U.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:n,className:`absolute top-1 right-1 bg-card`,title:`Insert a variable`,"data-test":`rewrite-url-insert-variable`,children:(0,U.jsx)(Yu,{className:`w-4`})})}),(0,U.jsxs)(XG,{align:`end`,className:`max-h-80 w-96 overflow-y-auto`,onCloseAutoFocus:e=>{e.preventDefault(),window.setTimeout(m,0)},children:[(0,U.jsxs)(ZG,{children:[(0,U.jsx)(nK,{children:`Environment variables`}),i.map(e=>(0,U.jsx)(QG,{onSelect:()=>p(`\${env.${e}}`),children:(0,U.jsx)(`span`,{className:`font-mono text-xs text-zuplo-600 dark:text-zuplo-400`,children:`\${env.${e}}`})},e)),(0,U.jsx)(QG,{onSelect:()=>p("${env.EXAMPLE_VARIABLE}"),children:(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs text-zuplo-600 dark:text-zuplo-400`,children:"${env.EXAMPLE_VARIABLE}"}),(0,U.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-muted-foreground`,children:`example`})]})})]}),(0,U.jsx)(rK,{}),(0,U.jsxs)(ZG,{children:[(0,U.jsx)(nK,{children:`Request variables`}),okt.map(({token:e,example:t})=>(0,U.jsx)(QG,{onSelect:()=>p(e),children:(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs text-zuplo-600 dark:text-zuplo-400`,children:e}),(0,U.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-muted-foreground`,children:t})]})},e))]})]})]})]}),(0,U.jsx)(ukt,{url:e,onUrlChange:t,isReadOnly:n}),f&&(0,U.jsx)(`div`,{"data-test":`rewrite-url-input-error`,className:`text-sm text-red-500`,children:d})]})]})},Y4=e=>{let t=(0,H.useContext)(mp),n=t?.account?.name,r=t?.project?.name,i=NN(n??``,r??``,{enabled:!!(n&&r),useErrorBoundary:!1});return(0,U.jsx)(dkt,{...e,environmentVariableNames:i.data?.map(e=>e.name)??[]})},X4=`Authorization`,fkt=/^[A-Za-z_][A-Za-z0-9_]*$/;function pkt(e){return e?.apiKeyAuth?{authMode:`none`,noAuthBehavior:`strip`}:e?.clientRegistration?.mode===`manual`?{authMode:`user-oauth`,clientRegistration:{mode:`manual`,clientId:``,...e.clientRegistration.tokenEndpointAuthMethod?{tokenEndpointAuthMethod:e.clientRegistration.tokenEndpointAuthMethod}:{}}}:{authMode:`user-oauth`,clientRegistration:{mode:`auto`}}}var mkt=/^\/[a-zA-Z0-9\-_/{}.]+$/,hkt=Pm().url(),gkt=Rm({name:Pm().min(1,`Name is required`).regex(/^[a-zA-Z][a-zA-Z0-9 _-]*$/,`Use letters, numbers, spaces, hyphens or underscores`),mcpUrl:Pm().min(1,`URL is required`).refine(e=>!lkt(e),"$env(NAME) is not substituted in URLs — use ${env.NAME} instead.").refine(e=>F1(e)||hkt.safeParse(e).success,"Must be a valid URL (e.g. https://mcp.example.com/mcp) or use ${env.NAME}"),path:Pm().min(2,`Path is required`).regex(mkt,`Path must start with / and use a-z, 0-9, -, _, or /`).refine(e=>e.startsWith(`/`),`Path must start with /`)});function Z4(e){let t=vkt(e);return t?`/mcp/${t}-v1`:``}function _kt(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function vkt(e){return e.toLowerCase().trim().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).replace(/-{2,}/g,`-`)}function ykt(e){let t=vkt(e).replace(/-/g,`_`).toUpperCase();return t?`${t}_MCP_UPSTREAM_KEY`:`MCP_UPSTREAM_KEY`}var bkt={prompts:[],resources:[],resourceTemplates:[],tools:[]},Q4=[{key:`upstream`,label:`Upstream`},{key:`auth`,label:`Inbound Auth`},{key:`tools`,label:`Tools`},{key:`upstream-auth`,label:`Outbound Auth`}],$4=`flex-1 min-h-0 flex flex-col gap-4`,xkt=`sm:max-w-4xl flex flex-col h-[872px] max-h-[calc(100vh-2rem)]`,Skt={authMode:`user-oauth`,clientRegistration:{mode:`auto`}},Ckt={catalogMode:`curated`,catalog:bkt,accessControlMode:`allPublic`},wkt=e=>e?{name:e.step1.name,mcpUrl:e.step1.mcpUrl,path:e.step1.path}:void 0,Tkt=e=>{if(!e)return Skt;let t=e.step1;switch(t.authMode){case`user-oauth`:return{authMode:`user-oauth`,clientRegistration:t.clientRegistration};case`api-key`:return{authMode:`api-key`,apiKeyHeader:t.apiKeyHeader,apiKeyEnvVar:t.apiKeyEnvVar};case`upstream-policy`:return{authMode:`upstream-policy`,policyType:t.policyType,policyName:t.policyName,handler:t.handler};default:return{authMode:`none`,noAuthBehavior:t.noAuthBehavior}}};function Ekt({operationPath:e,operation:t,policyList:n}){let r=t[CX];if(!r)return;let i=r.handler;if(!TX(i))return;let a=i.options?.rewritePattern;if(!a)return;let o=r.policies?.inbound??[],s=new Map(n.map(e=>[e.name,e])),c=o.map(e=>s.get(e)).filter(e=>e!==void 0),l=c.find(e=>e.policyType===`mcp-token-exchange-inbound`)?.handler?.options??{},u=c.find(e=>cOt(e.policyType)),d=c.find(e=>e.policyType===j4),f=c.find(e=>e.policyType===`remove-headers-inbound`&&M4(e.handler?.options)),p=c.find(e=>e.policyType===lOt),m=p?.handler?.options??{},h=c.find(e=>e.policyType.startsWith(`upstream-`)),g={name:l.displayName??t.summary??`MCP Server`,mcpUrl:a,path:e},_;_=l.authMode===`user-oauth`&&l.clientRegistration?{...g,authMode:`user-oauth`,clientRegistration:l.clientRegistration}:p?{...g,authMode:`api-key`,apiKeyHeader:m.header??X4,apiKeyEnvVar:/^\$env\((?<name>[^)]+)\)$/u.exec(m.value??``)?.groups?.name??m.value??``}:h?{...g,authMode:`upstream-policy`,policyType:h.policyType,policyName:h.name,handler:h.handler}:{...g,authMode:`none`,noAuthBehavior:f?`strip`:`passthrough`};let{catalog:v,accessControlMode:y}=YDt(d?.handler?.options),b=d?{catalogMode:`curated`,accessControlMode:y,catalog:v}:{catalogMode:`passthrough`},x=u?{authPolicyChoice:`existing`,existingPolicyName:u.name}:{authPolicyChoice:`none`};return{step1:_,step2:b,step3:x}}var Dkt=({isOpen:e,existingPaths:t,onClose:n,onFinish:r,mode:i=`create`,initialResult:a})=>{let[o,s]=(0,H.useState)(`upstream`),[c,l]=(0,H.useState)(()=>wkt(a)),[u,d]=(0,H.useState)(()=>Tkt(a)),[f,p]=(0,H.useState)(()=>a?.step2??Ckt),[m,h]=(0,H.useState)(()=>a?.step3),[g,_]=(0,H.useState)(!1),v=LM(g,n);(0,H.useEffect)(()=>{if(!e||!g)return;let t=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e,g]);let{captureRaw:y}=on(),b=(0,H.useRef)(!1),x=(0,H.useRef)(!1),S=(0,H.useRef)(o);(0,H.useEffect)(()=>{S.current=o},[o]);let C=yo(()=>e&&g&&!b.current);(0,H.useEffect)(()=>{let t=x.current;!t&&e?(b.current=!1,y(`mcp-gateway-create-virtual-mcp-started`)):t&&!e&&!b.current&&y(`mcp-gateway-create-virtual-mcp-cancelled`,{lastStep:S.current}),x.current=e},[e,y]);let w=Q4.findIndex(e=>e.key===o),T=e=>{y(`mcp-gateway-create-virtual-mcp-step-upstream-completed`,{upstreamHost:(()=>{try{return new URL(e.mcpUrl).hostname}catch{return}})()}),c?.mcpUrl!==e.mcpUrl&&(p(Ckt),d(pkt(z1(e.mcpUrl)))),_(!0),l(e),s(`auth`)},E=()=>{c&&(y(`mcp-gateway-create-virtual-mcp-skipped`,{fromStep:S.current,upstreamHost:(()=>{try{return new URL(c.mcpUrl).hostname}catch{return}})()}),b.current=!0,r({step1:{...c,authMode:`none`,noAuthBehavior:`passthrough`},step2:{catalogMode:`passthrough`},step3:{authPolicyChoice:`none`}}),n())},D=e=>{_(!0),h(e),s(`tools`)},O=e=>{y(`mcp-gateway-create-virtual-mcp-step-tools-completed`,{loadToolsFromUpstream:e.catalogMode===`passthrough`,...e.catalogMode===`curated`?{curatedToolCount:e.catalog.tools.length,curatedPromptCount:e.catalog.prompts.length,curatedResourceCount:e.catalog.resources.length,curatedResourceTemplateCount:e.catalog.resourceTemplates.length}:{}}),_(!0),p(e),s(`upstream-auth`)},k=e=>{y(`mcp-gateway-create-virtual-mcp-step-upstream-auth-completed`,{upstreamAuthMode:e.authMode,clientRegistrationMode:e.authMode===`user-oauth`?e.clientRegistration.mode:void 0}),d(e),!(!c||!m)&&(b.current=!0,r({step1:{...c,...e},step2:f,step3:m}),n())},A=()=>{o===`auth`?s(`upstream`):o===`tools`?s(`auth`):o===`upstream-auth`&&s(`tools`)};return(0,U.jsxs)(tb,{open:e,onOpenChange:e=>{e||v.guardedClose()},children:[(0,U.jsxs)(ib,{className:xkt,onInteractOutside:e=>e.preventDefault(),children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:i===`edit`?`Edit MCP Gateway Virtual Server`:`New MCP Gateway Virtual Server`}),(0,U.jsx)(cb,{children:`Configure the upstream MCP server, tools, and authentication.`})]}),(0,U.jsx)(`ol`,{"aria-label":`Wizard steps`,className:`flex items-center gap-2 text-xs text-muted-foreground`,children:Q4.map((e,t)=>{let n=e.key===o,r=t<w;return(0,U.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:W(`size-5 rounded-full border flex items-center justify-center text-[10px] font-semibold`,n&&`bg-zuplo-700 border-zuplo-700 text-white`,r&&`bg-zuplo-100 border-zuplo-700 text-zuplo-700`,!n&&!r&&`border-neutral-300 dark:border-neutral-600`),children:r?(0,U.jsx)(ed,{size:10}):t+1}),(0,U.jsx)(`span`,{className:W(n&&`text-foreground font-medium`),children:e.label}),t<Q4.length-1&&(0,U.jsx)(`span`,{className:`text-neutral-300 dark:text-neutral-600`,children:`›`})]},e.key)})}),o===`upstream`&&(0,U.jsx)(kkt,{defaultValues:c,existingPaths:t,lockPath:i===`edit`,onCancel:v.guardedClose,onNext:T}),o===`auth`&&c&&(0,U.jsx)(Mkt,{defaultValues:m,onBack:A,onNext:D,onSkip:i===`create`?E:void 0}),o===`tools`&&c&&(0,U.jsx)(jkt,{defaultValues:f,mcpUrl:c.mcpUrl,upstreamAuth:u,onBack:A,onNext:O,onSkip:i===`create`?E:void 0}),o===`upstream-auth`&&(0,U.jsx)(Akt,{defaultValues:u,serverName:c?.name??``,inboundAuthChoice:m,onJumpToInboundAuth:()=>s(`auth`),onBack:A,onFinish:k,onSkip:i===`create`?E:void 0})]}),(0,U.jsx)(IM,{open:v.showConfirm,onOpenChange:v.setShowConfirm,onDiscard:v.handleDiscard}),(0,U.jsx)(IM,{open:C.state===`blocked`,onOpenChange:()=>C.reset?.(),onDiscard:()=>C.proceed?.()})]})},Okt=(e,t)=>R1.find(n=>n.name===e&&n.url===t),e3=({onSkip:e,className:t,children:n})=>(0,U.jsxs)(ob,{className:W(`shrink-0 sm:justify-between`,t),children:[e?(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:e,title:`Create the virtual server now with no policies. You can add inbound auth, tools, and outbound auth later.`,children:`Skip`}):(0,U.jsx)(`span`,{"aria-hidden":!0,className:`hidden sm:block`}),(0,U.jsx)(`div`,{className:`flex gap-2`,children:n})]}),kkt=({defaultValues:e,existingPaths:t,lockPath:n,onCancel:r,onNext:i})=>{let{logEvent:a}=on(),o=qD({defaultValues:e??{name:``,mcpUrl:``,path:``},resolver:JD(gkt)}),s=e?Okt(e.name,e.mcpUrl):void 0,[c,l]=(0,H.useState)(e?`configure`:`browse`),[u,d]=(0,H.useState)(s||!e?`library`:`custom`),[f,p]=(0,H.useState)(s?.id),[m,h]=(0,H.useState)(``),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(()=>!!e?.path&&e.path!==Z4(e.name)),b=(0,H.useMemo)(()=>{let e=m.trim().toLowerCase();return(e?R1.filter(t=>t.name.toLowerCase().includes(e)):R1).map(e=>({id:e.id,name:e.name,iconUrl:e.iconUrl}))},[m]),x=f?R1.find(e=>e.id===f):void 0,S=e=>{R1.some(t=>t.id===e)&&(p(e),_(!1))},C=()=>{let e=f?R1.find(e=>e.id===f):void 0;if(e){if(d(`library`),o.setValue(`name`,e.name,{shouldDirty:!0,shouldValidate:!0}),o.setValue(`mcpUrl`,e.url,{shouldDirty:!0,shouldValidate:!0}),!v&&!n){let n=_kt(Z4(e.name),t);o.setValue(`path`,n,{shouldDirty:!0,shouldValidate:!0})}a(`mcp-gateway-create-virtual-mcp-library-server-selected`,{id:e.id,name:e.name,url:e.url,configureMode:`library`}),l(`configure`)}},w=()=>{a(`mcp-gateway-create-virtual-mcp-custom-server-selected`),p(void 0),d(`custom`),o.setValue(`name`,``,{shouldDirty:!0}),o.setValue(`mcpUrl`,``,{shouldDirty:!0}),l(`configure`)},T=o.watch(`name`),E=o.watch(`path`);(0,H.useEffect)(()=>{if(v)return;let e=_kt(Z4(T),t);e!==E&&o.setValue(`path`,e,{shouldValidate:!1})},[v,T,t,E,o]);let D=e=>{if(t.has(e.path)){a(`mcp-gateway-create-virtual-mcp-upstream-path-conflict-failed`,{path:e.path,name:e.name}),o.setError(`path`,{type:`manual`,message:`Path "${e.path}" is already used by another route`});return}i(e)};return c===`browse`?(0,U.jsxs)(`div`,{className:$4,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed shrink-0`,children:`Choose an MCP server from the library, or set up a custom one.`}),(0,U.jsx)(iM,{placeholder:`Search servers…`,size:`sm`,value:m,onChange:e=>h(e.target.value),className:`shrink-0`}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:(0,U.jsx)(h4,{tiles:b,selectedId:f,onSelect:S,fallbackIcon:(0,U.jsx)($J,{className:`size-7 text-muted-foreground`}),emptyState:`No servers match "${m}".`})}),(0,U.jsxs)(`button`,{type:`button`,onClick:w,className:`shrink-0 flex items-center justify-center gap-2 rounded-md border border-dashed border-neutral-300 dark:border-neutral-600 bg-card px-4 py-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-800/60`,children:[(0,U.jsx)(Sf,{"aria-hidden":`true`,className:`size-4`}),`Set up a custom MCP server`]}),(0,U.jsxs)(ob,{className:`shrink-0`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:r,children:`Cancel`}),(0,U.jsx)(X,{type:`button`,onClick:C,disabled:!f,title:f?void 0:`Select a server`,children:`Next`})]})]}):(0,U.jsx)(fY,{...o,children:(0,U.jsxs)(`form`,{onSubmit:o.handleSubmit(D),className:$4,children:[u===`library`&&x?(0,U.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border bg-surface-sunken px-4 py-3 shrink-0`,children:[g||!x.iconUrl?(0,U.jsx)($J,{className:`size-9 shrink-0 text-muted-foreground`}):(0,U.jsx)(`img`,{src:x.iconUrl,alt:``,className:`size-9 shrink-0 object-contain brightness-0 dark:invert`,onError:()=>_(!0)}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,U.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:x.name}),x.description&&(0,U.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:x.description})]})]}):(0,U.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border bg-surface-sunken px-4 py-3 shrink-0`,children:[(0,U.jsx)($J,{className:`size-9 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,U.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Custom MCP server`}),(0,U.jsx)(`div`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Point the gateway at any MCP-compatible server — your own first-party MCP service or one not yet covered by our Library.`})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(mY,{control:o.control,name:`name`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Name`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`e.g. Linear, GitHub, Atlassian`,size:`sm`,...e})}),(0,U.jsx)(xY,{})]})}),(0,U.jsx)(mY,{control:o.control,name:`mcpUrl`,render:({field:e})=>{let t=u===`library`;return(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`MCP URL`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`https://mcp.example.com/mcp`,size:`sm`,readOnly:t,"aria-readonly":t||void 0,tabIndex:t?-1:void 0,...e})}),!t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ukt,{url:e.value,onUrlChange:e.onChange,isReadOnly:!1}),(0,U.jsxs)(bY,{children:[`Environment variable references are supported — e.g.`,` `,(0,U.jsx)(`code`,{children:"${env.LINEAR_MCP_URL}"}),`.`]})]}),(0,U.jsx)(xY,{})]})}}),(0,U.jsx)(mY,{control:o.control,name:`path`,render:({field:e})=>(0,U.jsxs)(_Y,{children:[(0,U.jsx)(vY,{children:`Path`}),(0,U.jsx)(yY,{children:(0,U.jsx)(iM,{placeholder:`/mcp/your-server`,size:`sm`,readOnly:n,"aria-readonly":n||void 0,...e,onChange:t=>{n||(y(!0),e.onChange(t))}})}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[n?`The mount path is fixed once a virtual server is created. To move it, delete and re-create the route.`:null,n?null:(0,U.jsxs)(U.Fragment,{children:[`Where this virtual server will be mounted. Defaults to`,` `,(0,U.jsx)(`code`,{children:`/mcp/<name>-v1`}),`; suffixed if that's already taken.`]})]}),(0,U.jsx)(xY,{})]})})]}),(0,U.jsxs)(ob,{className:`mt-auto shrink-0`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:()=>l(`browse`),children:`Back`}),(0,U.jsx)(X,{type:`submit`,children:`Next`})]})]})})},Akt=({defaultValues:e,serverName:t,inboundAuthChoice:n,onJumpToInboundAuth:r,onBack:i,onFinish:a,onSkip:o})=>{let{logEvent:s,captureRaw:c}=on(),l=u1(),u=B4(),[d,f]=(0,H.useState)(`method`),[p,m]=(0,H.useState)(e.authMode),[h,g]=(0,H.useState)(e.authMode===`none`?e.noAuthBehavior:`passthrough`),[_,v]=(0,H.useState)(e.authMode===`user-oauth`?e.clientRegistration.mode:`auto`),[y,b]=(0,H.useState)(e.authMode===`user-oauth`&&e.clientRegistration.mode===`manual`?e.clientRegistration.clientId:``),[x,S]=(0,H.useState)(e.authMode===`user-oauth`&&e.clientRegistration.mode===`manual`?e.clientRegistration.clientSecret??``:``),[C,w]=(0,H.useState)(e.authMode===`user-oauth`&&e.clientRegistration.mode===`manual`?e.clientRegistration.tokenEndpointAuthMethod??`client_secret_basic`:`client_secret_basic`),T=ykt(t),[E,D]=(0,H.useState)(e.authMode===`api-key`?e.apiKeyHeader:X4),[O,k]=(0,H.useState)(e.authMode===`api-key`?e.apiKeyEnvVar:T),[A,j]=(0,H.useState)(e.authMode===`upstream-policy`?e.policyType:void 0),M=(0,H.useRef)(null),N=(0,H.useMemo)(()=>(u.data?.policies??[]).filter(e=>e.id.startsWith(`upstream-`)&&e.id.endsWith(`-inbound`)&&!e.isInternal&&!e.isDeprecated&&!e.isCustom).sort((e,t)=>e.name.localeCompare(t.name)),[u.data]),P=A?b1(u.data,A):void 0,F=e.authMode===`upstream-policy`&&e.policyType===A?e.policyName:void 0,[I,L]=(0,H.useState)(()=>e.authMode===`upstream-policy`?{[e.policyType]:{name:e.policyName,handler:e.handler}}:{}),R=A?I[A]:void 0,z=R?.handler??P?.defaultHandler,B=(0,H.useMemo)(()=>N.map(e=>({id:e.id,name:e.name,iconUrl:e.icon})),[N]),[ee,V]=(0,H.useState)(),te=y.trim(),ne=x.trim(),re=p===`user-oauth`&&(!n||n.authPolicyChoice===`none`),ie=O.trim(),ae=E.trim(),oe=re||p===`upstream-policy`&&!A,se=p===`user-oauth`&&_===`manual`&&!te||p===`api-key`&&!ie||p===`upstream-policy`&&!A,ce=p===`api-key`&&!ie?`Environment variable is required`:p===`upstream-policy`&&!A?`Pick a policy`:se?`Client ID is required`:void 0,le=()=>{if(p===`none`){a({authMode:`none`,noAuthBehavior:h});return}if(p===`upstream-policy`){if(!A)return;try{let e=M.current?.getPolicyConfig()??t3();a({authMode:`upstream-policy`,policyType:A,policyName:e.name,handler:e.handler})}catch{c(`mcp-gateway-create-virtual-mcp-outbound-service-policy-invalid-failed`,{policyType:A})}return}if(p===`api-key`){if(!fkt.test(ie)){V(`Environment variable must be a valid name (letters, numbers, underscore).`);return}a({authMode:`api-key`,apiKeyHeader:ae||X4,apiKeyEnvVar:ie});return}if(_===`auto`){a({authMode:`user-oauth`,clientRegistration:{mode:`auto`}});return}if(ne&&!/^\$env\([A-Z][A-Z0-9_]*\)$/u.test(ne)){s(`mcp-gateway-create-virtual-mcp-outbound-client-secret-invalid-failed`,{clientRegistrationMode:_,tokenEndpointAuthMethod:C}),V(`Store client secrets in an environment variable.`);return}a({authMode:`user-oauth`,clientRegistration:{mode:`manual`,clientId:te,...ne?{clientSecret:ne}:{},tokenEndpointAuthMethod:C}})};return(0,U.jsxs)(`div`,{className:$4,children:[d===`method`&&(0,U.jsx)(qDt,{active:`outbound`}),d===`method`&&re&&(0,U.jsxs)(`div`,{className:`rounded-md border border-amber-300 dark:border-amber-900/60 bg-amber-50 dark:bg-amber-950/40 px-3 py-2.5 text-xs text-amber-900 dark:text-amber-200 leading-relaxed flex items-start gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex-1`,children:[(0,U.jsx)(`div`,{className:`font-semibold`,children:`Inbound auth policy required`}),(0,U.jsx)(`div`,{className:`mt-0.5`,children:`Upstream User OAuth needs an inbound MCP OAuth policy so the gateway can bind upstream grants to the caller. Configure one in the Inbound Auth step before finishing.`})]}),(0,U.jsxs)(`button`,{type:`button`,onClick:r,className:`shrink-0 self-center inline-flex items-center gap-1 rounded-md border border-amber-400 dark:border-amber-900/60 bg-card px-2.5 py-1 text-xs font-medium text-amber-900 dark:text-amber-200 hover:bg-amber-100 dark:hover:bg-amber-900/40`,children:[(0,U.jsx)(id,{"aria-hidden":`true`,className:`size-3.5`}),`Configure inbound auth`]})]}),d===`method`&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:`Choose whether the gateway needs upstream credentials before forwarding MCP requests.`}),d===`method`&&(0,U.jsx)(m4,{ariaLabel:`Outbound authentication`,idPrefix:`upstream-auth`,layout:`list`,value:p,onValueChange:e=>{s(`mcp-gateway-create-virtual-mcp-outbound-auth-mode-selected`,{value:e}),V(void 0),m(e)},options:[{value:`user-oauth`,title:`User OAuth`,description:`Exchange each user's gateway grant for an upstream MCP grant.`},{value:`api-key`,title:`API key`,description:`Attach a fixed API key from an environment variable to every request.`},{value:`upstream-policy`,title:`Service auth`,description:`Authenticate with a service credential policy — GCP, AWS IAM, Azure AD, and more.`},{value:`none`,title:`None`,description:`Forward directly — the upstream doesn't need credentials from the gateway.`}]}),d===`configure`&&(0,U.jsxs)(`div`,{className:`shrink-0`,children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:`Configure outbound policy`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:p===`user-oauth`?`Configure how the gateway registers its OAuth client with the upstream.`:p===`api-key`?`Configure the API key attached to every upstream request.`:`Name the policy and fill in its configuration.`})]}),d===`method`&&p===`none`&&(0,U.jsxs)(`div`,{className:`rounded-md border bg-card p-3 flex items-center justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:`Remove inbound Authorization header`}),(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed`,children:h===`strip`?(0,U.jsxs)(U.Fragment,{children:[`Strips the inbound MCP client's `,(0,U.jsx)(`code`,{children:`Authorization`}),` `,`header (via a remove-headers policy) before forwarding to the upstream.`]}):(0,U.jsxs)(U.Fragment,{children:[`Forwards the inbound MCP client's `,(0,U.jsx)(`code`,{children:`Authorization`}),` `,`header to the upstream as-is.`]})})]}),(0,U.jsx)(y1,{checked:h===`strip`,onCheckedChange:e=>{let t=e?`strip`:`passthrough`;s(`mcp-gateway-create-virtual-mcp-outbound-no-auth-behavior-selected`,{value:t}),g(t)},"aria-label":`Remove inbound Authorization header`})]}),d===`method`&&p===`upstream-policy`&&(0,U.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{children:`Policy`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Pick the service-credential policy that authenticates the gateway to your upstream, then fill in its details.`}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-0.5`,children:(0,U.jsx)(h4,{tiles:B,selectedId:A,onSelect:e=>{c(`mcp-gateway-create-virtual-mcp-outbound-service-policy-selected`,{value:e}),V(void 0),j(e)},fallbackIcon:(0,U.jsx)(nf,{className:`size-7 text-muted-foreground`}),emptyState:`No upstream auth policies found in the policy library.`})})]}),d===`configure`&&p===`api-key`&&(0,U.jsxs)(`div`,{className:`rounded-md border bg-card p-3 flex flex-col gap-3`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:`Upstream API key`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`upstream-api-key-header`,children:`Header`}),(0,U.jsx)(iM,{id:`upstream-api-key-header`,size:`sm`,value:E,onChange:e=>D(e.target.value),placeholder:X4})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`upstream-api-key-env`,children:`Environment variable`}),(0,U.jsx)(iM,{id:`upstream-api-key-env`,size:`sm`,value:O,onChange:e=>{V(void 0),k(e.target.value)},placeholder:T})]})]}),(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground leading-relaxed`,children:[`Sets`,` `,(0,U.jsxs)(`code`,{children:[ae||X4,`: $env(`,ie||T,`)`]}),` `,`on every request to the upstream. Define the environment variable with your key in the project's Environment Variables — the wizard references it but doesn't create it.`]})]}),d===`configure`&&p===`upstream-policy`&&A&&(0,U.jsxs)(U.Fragment,{children:[P&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-surface-sunken px-3 py-2 shrink-0`,children:[(0,U.jsx)(m1,{url:P.icon,className:`size-6`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:P.name}),P.description&&(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:P.description})]})]}),z&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 px-1`,children:(0,U.jsx)(K4,{ref:M,designConfig:P,policyType:A,defaultHandler:z,initialName:R?.name??S1(l.getPolicyListEnforced(),A),policies:l.getPolicyListEnforced().filter(e=>e.name!==F),alwaysShowForm:!0},A)})]}),d===`configure`&&p===`user-oauth`&&(0,U.jsxs)(`div`,{className:`rounded-md border bg-card p-3 flex flex-col gap-3`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium`,children:`OAuth client registration`}),(0,U.jsx)(m4,{ariaLabel:`OAuth client registration`,idPrefix:`upstream-client-registration`,value:_,onValueChange:e=>{s(`mcp-gateway-create-virtual-mcp-outbound-client-registration-selected`,{value:e}),v(e)},options:[{value:`auto`,title:`Dynamic`,description:`The gateway registers itself with the upstream automatically via Dynamic Client Registration (DCR). Nothing to configure.`},{value:`manual`,title:`Manual`,description:`Use a client ID and secret you already registered with the upstream. Pick this when it doesn't support dynamic registration.`}]}),_===`manual`&&(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`upstream-client-id`,children:`Client ID`}),(0,U.jsx)(iM,{id:`upstream-client-id`,size:`sm`,value:y,onChange:e=>b(e.target.value),placeholder:`$env(UPSTREAM_OAUTH_CLIENT_ID)`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`upstream-client-secret`,children:`Client secret`}),(0,U.jsx)(iM,{id:`upstream-client-secret`,type:`password`,size:`sm`,value:x,onChange:e=>{V(void 0),S(e.target.value)},placeholder:`$env(UPSTREAM_OAUTH_CLIENT_SECRET)`}),(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground leading-relaxed`,children:[`Use `,(0,U.jsx)(`code`,{children:`$env(NAME)`}),`; literal secrets are not written to config.`]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 col-span-2`,children:[(0,U.jsx)(dY,{htmlFor:`upstream-token-auth-method`,children:`Token endpoint auth`}),(0,U.jsxs)(mJ,{value:C,onValueChange:e=>w(e),children:[(0,U.jsx)(_J,{id:`upstream-token-auth-method`,children:(0,U.jsx)(gJ,{})}),(0,U.jsxs)(vJ,{children:[(0,U.jsx)(bJ,{value:`client_secret_basic`,children:`Client secret basic`}),(0,U.jsx)(bJ,{value:`client_secret_post`,children:`Client secret post`}),(0,U.jsx)(bJ,{value:`none`,children:`None`})]})]})]})]})]}),ee&&(0,U.jsx)(`div`,{className:`rounded-md border border-red-200 dark:border-red-900/60 bg-red-50 dark:bg-red-950/40 px-3 py-2 text-xs text-red-700 dark:text-red-200`,children:ee}),d===`method`?(0,U.jsxs)(e3,{onSkip:o,className:`mt-auto`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:i,children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:()=>{p===`none`?le():(V(void 0),f(`configure`))},disabled:oe,title:re?`Configure an inbound auth policy first`:p===`upstream-policy`&&!A?`Select a policy`:void 0,children:p===`none`?`Finish`:`Next`})]}):(0,U.jsxs)(e3,{onSkip:o,className:`mt-auto`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:()=>{if(V(void 0),p===`upstream-policy`&&A)try{let e=M.current?.getPolicyConfig();e&&L(t=>({...t,[A]:e}))}catch{}f(`method`)},children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:le,disabled:se,title:ce,children:`Finish`})]})]})},jkt=({defaultValues:e,mcpUrl:t,upstreamAuth:n,onBack:r,onNext:i,onSkip:a})=>{let{logEvent:o}=on(),[s,c]=(0,H.useState)(e.catalogMode),[l,u]=(0,H.useState)(()=>e.catalogMode===`curated`?e.catalog:bkt),[d,f]=(0,H.useState)(e.catalogMode===`curated`?e.accessControlMode:`allPublic`),p=d===`rolesAndGroups`,m=()=>{i(s===`passthrough`?{catalogMode:`passthrough`}:{catalogMode:`curated`,catalog:l,accessControlMode:d})},h=l.tools.length+l.prompts.length+l.resources.length+l.resourceTemplates.length,g=s===`curated`&&h===0;return(0,U.jsxs)(`div`,{className:$4,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:`Decide which tools, prompts, and resources this virtual server exposes to its clients.`}),(0,U.jsx)(m4,{ariaLabel:`Catalog mode`,idPrefix:`catalog-mode`,columns:2,value:s,onValueChange:e=>{o(`mcp-gateway-create-virtual-mcp-catalog-strategy-selected`,{value:e,mcpUrl:t}),c(e)},options:[{value:`curated`,title:`Filter & curate`,description:`Pick exactly which tools, prompts, and resources this server exposes — and control who can use each.`},{value:`passthrough`,title:`Passthrough`,description:`Federate the upstream's catalog live: everything the server advertises is exposed. Zero config.`}]}),s===`curated`&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-md border bg-card px-3 py-2 shrink-0`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Roles & groups access control`}),(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Mark each capability public, or restrict it to specific roles or groups. Anything left unclassified won't be exposed — nothing is public by default.`})]}),(0,U.jsx)(y1,{checked:p,onCheckedChange:e=>f(e?`rolesAndGroups`:`allPublic`),"aria-label":`Enable roles and groups access control`})]}),s===`curated`&&(0,U.jsx)(j_t,{catalog:l,onChange:u,accessControlEnabled:p,upstream:{mcpUrl:t,upstreamAuth:n}}),(0,U.jsxs)(e3,{onSkip:a,className:`mt-auto`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:r,children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:m,disabled:g,title:g?`Select at least one tool, prompt, or resource to continue`:void 0,children:`Next`})]})]})},Mkt=({defaultValues:e,onBack:t,onNext:n,onSkip:r})=>{let{logEvent:i,captureRaw:a}=on(),o=u1(),s=(0,H.useMemo)(()=>o.getPolicyListEnforced().filter(e=>cOt(e.policyType)),[o]),[c,l]=(0,H.useState)(e?.authPolicyChoice??(s.length>0?`existing`:`new`)),[u,d]=(0,H.useState)(e?.authPolicyChoice===`new`||e?.authPolicyChoice===`new-other`?`configure`:`method`),[f,p]=(0,H.useState)(e?.authPolicyChoice===`existing`?e.existingPolicyName:s[0]?.name??``),[m,h]=(0,H.useState)(e?.authPolicyChoice===`new`?e.providerId:void 0),[g,_]=(0,H.useState)(e?.authPolicyChoice===`new`?e.newPolicyName:``),[v,y]=(0,H.useState)(()=>e?.authPolicyChoice===`new`?{[e.providerId]:e.handler}:{}),[b,x]=(0,H.useState)(e?.authPolicyChoice===`new-other`?e.policyType:void 0),[S,C]=(0,H.useState)(()=>e?.authPolicyChoice===`new-other`?{[e.policyType]:{name:e.newPolicyName,handler:e.handler}}:{}),[w,T]=(0,H.useState)(),[E,D]=(0,H.useState)(!1),O=(0,H.useRef)(null),k=B4(),A=(0,H.useMemo)(()=>E4.map(e=>({id:e.id,name:e.label,iconUrl:e.iconUrl})),[]),j=(0,H.useMemo)(()=>(k.data?.policies??[]).filter(e=>e.id.endsWith(`-inbound`)&&iOt(e.id)&&!e.isInternal&&!e.isDeprecated&&!e.isCustom).sort((e,t)=>e.name.localeCompare(t.name)),[k.data]),M=(0,H.useMemo)(()=>j.map(e=>({id:e.id,name:e.name,iconUrl:e.icon})),[j]),N=b?b1(k.data,b):void 0,P=b?S[b]:void 0,F=P?.handler??N?.defaultHandler,I=m?D4(m):void 0,L=I?v[I.id]??{module:I.policyModule,export:I.policyExport,options:I.defaultOptions??ZDt(I)}:void 0,R=e=>{let t=D4(e);if(!t)return;i(`mcp-gateway-create-virtual-mcp-inbound-auth-provider-selected`,{id:t.id,label:t.label}),T(void 0),D(!1);let n=m?D4(m):void 0,r=g.trim();(!r||r===n?.suggestedPolicyName)&&_(t.suggestedPolicyName),h(t.id)},z=()=>{if(c===`none`){a(`mcp-gateway-create-virtual-mcp-step-inbound-auth-completed`,{choice:c,candidatesLength:s.length}),n({authPolicyChoice:`none`});return}if(c===`existing`){if(!f){T(`Pick a policy.`);return}a(`mcp-gateway-create-virtual-mcp-step-inbound-auth-completed`,{choice:c,candidatesLength:s.length}),n({authPolicyChoice:`existing`,existingPolicyName:f});return}if(T(void 0),c===`new-other`){b&&d(`configure`);return}m&&d(`configure`)},B=()=>{if(!I){d(`method`);return}let e;try{e=O.current?.getPolicyConfig()??t3()}catch{i(`mcp-gateway-create-virtual-mcp-inbound-auth-policy-invalid-failed`,{providerId:I.id,newPolicyName:g});return}_(e.name),y(t=>({...t,[I.id]:e.handler})),a(`mcp-gateway-create-virtual-mcp-step-inbound-auth-completed`,{choice:c,selectedProviderId:I.id,candidatesLength:s.length}),n({authPolicyChoice:`new`,providerId:I.id,policyType:I.policyType,newPolicyName:e.name,handler:e.handler})},ee=()=>{if(!b){d(`method`);return}let e;try{e=O.current?.getPolicyConfig()??t3()}catch{i(`mcp-gateway-create-virtual-mcp-inbound-auth-policy-invalid-failed`,{policyType:b});return}C(t=>({...t,[b]:e})),a(`mcp-gateway-create-virtual-mcp-step-inbound-auth-completed`,{choice:c,otherPolicyType:b,candidatesLength:s.length}),n({authPolicyChoice:`new-other`,policyType:b,newPolicyName:e.name,handler:e.handler})},V=[{value:`new`,title:`New user identity provider`,description:`Scaffold an inbound OAuth policy for the IdP your users sign in with — Auth0, Okta, Entra, and more.`},{value:`new-other`,title:`New other identity provider`,description:`For agents and non-standard clients — API key, JWT, basic auth, and more.`},...s.length>0?[{value:`existing`,title:`Existing policy`,description:`Reuse an inbound auth policy already in this project.`}]:[],{value:`none`,title:`None`,description:`Allow unauthenticated requests, or add your own policy manually.`}];return(0,U.jsxs)(`div`,{className:$4,children:[u===`method`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(qDt,{active:`inbound`}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground leading-relaxed shrink-0`,children:[`Choose how MCP clients authenticate `,(0,U.jsx)(`em`,{children:`to`}),` this gateway.`]}),(0,U.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-1 flex flex-col gap-3`,children:[(0,U.jsx)(m4,{ariaLabel:`Inbound authentication method`,idPrefix:`inbound-method`,layout:`list`,value:c,onValueChange:e=>{i(`mcp-gateway-create-virtual-mcp-inbound-auth-method-selected`,{value:e,candidatesLength:s.length}),T(void 0),l(e)},options:V}),c===`existing`&&s.length>0&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{children:`Choose a policy`}),(0,U.jsx)(m4,{ariaLabel:`Existing inbound auth policy`,idPrefix:`inbound-existing`,columns:1,value:f,onValueChange:e=>{T(void 0),p(e)},options:s.map(e=>({value:e.name,title:(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.name})}))})]}),c===`none`&&(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The virtual server will accept unauthenticated requests. You can add an authorization policy later if required.`}),c===`new`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{children:`Identity provider`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Pick the identity provider that issues tokens for this server, then fill in its details.`}),(0,U.jsx)(h4,{tiles:A,selectedId:m,onSelect:R,fallbackIcon:(0,U.jsx)(nf,{className:`size-7 text-muted-foreground`})})]}),c===`new-other`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{children:`Authentication policy`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Pick how clients authenticate to this server, then fill in the policy's details.`}),(0,U.jsx)(h4,{tiles:M,selectedId:b,onSelect:e=>{i(`mcp-gateway-create-virtual-mcp-inbound-other-policy-selected`,{value:e}),T(void 0),x(e)},fallbackIcon:(0,U.jsx)(nf,{className:`size-7 text-muted-foreground`}),emptyState:`No authentication policies found in the policy library.`})]}),w&&(0,U.jsx)(`div`,{className:`text-sm text-destructive`,children:w})]}),(0,U.jsxs)(e3,{onSkip:r,className:`border-t pt-3`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:t,children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:z,disabled:c===`new`&&!m||c===`new-other`&&!b,title:c===`new`&&!m?`Select an identity provider`:c===`new-other`&&!b?`Select an authentication policy`:void 0,children:`Next`})]})]}),u===`configure`&&c===`new`&&I&&L&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`shrink-0`,children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:`Configure inbound policy`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:`Name the policy and fill in your identity provider's details.`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-surface-sunken px-3 py-2 shrink-0`,children:[E||!I.iconUrl?(0,U.jsx)(nf,{className:`h-6 w-6 shrink-0 text-muted-foreground`}):(0,U.jsx)(`img`,{src:I.iconUrl,alt:``,className:`h-6 w-6 object-contain brightness-0 dark:invert`,onError:()=>D(!0)}),(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:I.label}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:I.description})]})]}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0 px-1`,children:(0,U.jsx)(K4,{ref:O,designConfig:b1(k.data,I.policyType),policyType:I.policyType,defaultHandler:L,initialName:g.trim()||I.suggestedPolicyName,policies:o.getPolicyListEnforced(),alwaysShowForm:!0},I.id)}),(0,U.jsxs)(e3,{onSkip:r,className:`border-t pt-3`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:()=>{T(void 0);try{let e=O.current?.getPolicyConfig();e&&(_(e.name),y(t=>({...t,[I.id]:e.handler})))}catch{}d(`method`)},children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:B,children:`Next`})]})]}),u===`configure`&&c===`new-other`&&b&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`shrink-0`,children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:`Configure inbound policy`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:`Name the policy and fill in its configuration.`})]}),N&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-surface-sunken px-3 py-2 shrink-0`,children:[(0,U.jsx)(m1,{url:N.icon,className:`size-6`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:N.name}),N.description&&(0,U.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:N.description})]})]}),F&&(0,U.jsx)(`div`,{className:`flex-1 min-h-0 px-1`,children:(0,U.jsx)(K4,{ref:O,designConfig:N,policyType:b,defaultHandler:F,initialName:P?.name??S1(o.getPolicyListEnforced(),`mcp-${b}`),policies:o.getPolicyListEnforced(),alwaysShowForm:!0},b)}),(0,U.jsxs)(e3,{onSkip:r,className:`border-t pt-3`,children:[(0,U.jsx)(X,{variant:`outline`,type:`button`,onClick:()=>{T(void 0);try{let e=O.current?.getPolicyConfig();e&&C(t=>({...t,[b]:e}))}catch{}d(`method`)},children:`Back`}),(0,U.jsx)(X,{type:`button`,onClick:ee,children:`Next`})]})]})]})};function t3(){throw Error(`The policy editor is not ready`)}function Nkt(e){return e.toLowerCase().trim().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).replace(/-{2,}/g,`-`)}function n3(e,t){if(!t.has(e))return e;let n=1;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function Pkt(e,t){if(!t.has(e))return e;let n=1;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}var Fkt=`remove-authorization-header`;function Ikt(e){return{name:e,policyType:uOt,handler:{module:`$import(@zuplo/runtime)`,export:`RemoveHeadersInboundPolicy`,options:{headers:[`authorization`]}}}}function Lkt(e){return e.find(e=>e.policyType===`remove-headers-inbound`&&M4(e.handler?.options))}function Rkt(e){try{let t=new URL(e),n=new URL(`/.well-known/oauth-protected-resource`,t.origin),r=t.pathname.replace(/\/$/,``);return r&&r!==`/`&&(n.pathname+=r),n.toString()}catch{return}}function zkt({result:e,policyList:t,existingOperationIds:n}){let{step1:r,step2:i,step3:a}=e,o=Nkt(r.name),s=z1(r.mcpUrl),c=s?.protectedResourceMetadataUrl??Rkt(r.mcpUrl),l=[],u=new Set(t.map(e=>e.name)),d=e=>{let t=n3(e,u);return u.add(t),t},f;r.authMode===`user-oauth`&&(f=d(`mcp-upstream-${o}`),l.push({name:f,policyType:A4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpTokenExchangeInboundPolicy`,options:{id:o,displayName:r.name,summary:`${r.name} remote MCP server, federated via the gateway.`,...c?{protectedResourceMetadataUrl:c}:{},authMode:`user-oauth`,scopes:s?.scopes??[],clientRegistration:r.clientRegistration}}}));let p;r.authMode===`api-key`&&(p=d(`set-${o}-api-key`),l.push({name:p,policyType:lOt,handler:{module:`$import(@zuplo/runtime)`,export:`SetUpstreamApiKeyInboundPolicy`,options:{header:r.apiKeyHeader,value:`$env(${r.apiKeyEnvVar})`}}}));let m;i.catalogMode===`curated`&&(m=d(`mcp-filter-${o}`),l.push({name:m,policyType:j4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpCapabilityFilterInboundPolicy`,options:w4(i)}}));let h;a.authPolicyChoice===`existing`?h=a.existingPolicyName:(a.authPolicyChoice===`new`||a.authPolicyChoice===`new-other`)&&(h=a.newPolicyName,u.add(h),l.push({name:h,policyType:a.policyType,handler:a.handler}));let g;r.authMode===`upstream-policy`&&(g=r.policyName,u.add(g),l.push({name:g,policyType:r.policyType,handler:r.handler}));let _;if(r.authMode===`none`&&r.noAuthBehavior===`strip`){let e=Lkt(t);e?_=e.name:(_=d(Fkt),l.push(Ikt(_)))}let v=[h,m,f,p,g,_].filter(e=>!!e),y=Pkt(`${o}-mcp-server`,n);return{policiesToCreate:l,operationPath:r.path,method:`post`,operation:{summary:r.name,description:`MCP Virtual Server fronted by the gateway (${r.mcpUrl})`,tags:[`MCP`],[Brt]:!0,[CX]:{corsPolicy:`none`,handler:{export:`McpProxyHandler`,module:`$import(@zuplo/runtime/mcp-gateway)`,options:{rewritePattern:r.mcpUrl}},policies:{inbound:v}},operationId:y}}}function Bkt(e){let{step1:t,step2:n,step3:r}=e,i;try{i=new URL(t.mcpUrl).hostname}catch{i=void 0}return{upstreamHost:i,upstreamAuthMode:t.authMode,inboundAuthChoice:r.authPolicyChoice,...r.authPolicyChoice===`new`?{inboundAuthProvider:r.providerId}:{},...r.authPolicyChoice===`new-other`?{inboundAuthPolicyType:r.policyType}:{},loadToolsFromUpstream:n.catalogMode===`passthrough`,...n.catalogMode===`curated`?{curatedToolCount:n.catalog.tools.length,curatedPromptCount:n.catalog.prompts.length,curatedResourceCount:n.catalog.resources.length,curatedResourceTemplateCount:n.catalog.resourceTemplates.length}:{}}}function Vkt({autoCreate:e,onAutoCreateConsumed:t}){let n=Y$(),{isReadOnly:r}=wZ(),i=n.openApiData?.tags??[],[a,o]=(0,H.useState)(e?{mode:`create`}:null),s=(0,H.useRef)(!1);(0,H.useEffect)(()=>{e&&!s.current&&(s.current=!0,t?.())},[e,t]);let c=e=>n.operationArray?.filter(t=>t.tags?.includes(e)).length??0,l=new Set(i.map(e=>e.name)),u=a?.mode===`edit`?i.find(e=>e.name===a.name):void 0;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Tags group your API's operations. Assign them to routes from each route's editor; here you can create and edit the tags themselves.`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-[52vh] overflow-y-auto px-0.5 py-1`,children:i.length===0?(0,U.jsxs)(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-sm text-muted-foreground`,children:[`No tags yet.`,!r&&` Use “Add tag” below to create one.`]}):i.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>o({mode:`edit`,name:e.name}),className:`group flex w-full items-center gap-2 rounded-md border border-border bg-card px-3 py-2 text-left transition-colors hover:bg-accent`,children:[(0,U.jsx)(Uf,{size:14,className:`shrink-0 text-muted-foreground`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,U.jsx)(`div`,{className:e.description?`truncate text-xs text-muted-foreground`:`truncate text-xs italic text-muted-foreground`,children:e.description||`No description`})]}),(0,U.jsx)(bf,{size:13,className:`shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100`})]},e.name))}),!r&&(0,U.jsx)(`div`,{children:(0,U.jsxs)(X,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o({mode:`create`}),children:[(0,U.jsx)(Sf,{size:14}),`Add tag`]})}),(0,U.jsx)(Hkt,{open:a!==null,mode:a?.mode??`create`,initialName:u?.name??``,initialDescription:u?.description??``,currentName:a?.mode===`edit`?a.name:void 0,existingNames:l,usageCount:a?.mode===`edit`?c(a.name):0,isReadOnly:r,onOpenChange:e=>{e||o(null)},onSubmit:(e,t)=>{let r=e.trim(),i=t.trim();try{a?.mode===`create`?n.addTag(r,i||void 0):a?.mode===`edit`&&n.updateTag(a.name,r,i),o(null)}catch{}},onDelete:a?.mode===`edit`?()=>{a?.mode===`edit`&&n.deleteTag(a.name),o(null)}:void 0},a?.mode===`edit`?`edit:${a.name}`:`create`)]})}function Hkt({open:e,onOpenChange:t,mode:n,initialName:r,initialDescription:i,currentName:a,existingNames:o,usageCount:s,isReadOnly:c,onSubmit:l,onDelete:u}){return(0,U.jsx)(tb,{open:e,onOpenChange:t,children:(0,U.jsx)(ib,{className:`sm:max-w-md`,children:(0,U.jsx)(Ukt,{mode:n,initialName:r,initialDescription:i,currentName:a,existingNames:o,usageCount:s,isReadOnly:c,onCancel:()=>t(!1),onSubmit:l,onDelete:u})})})}function Ukt({mode:e,initialName:t,initialDescription:n,currentName:r,existingNames:i,usageCount:a,isReadOnly:o,onCancel:s,onSubmit:c,onDelete:l}){let[u,d]=(0,H.useState)(t),[f,p]=(0,H.useState)(n),[m,h]=(0,H.useState)(!1),g=u.trim(),_=g.length>0&&g!==r&&i.has(g),v=g.length>0&&!_&&!o;return(0,U.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),v&&c(u,f)},className:`flex flex-col gap-4`,children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:e===`create`?`Add tag`:`Edit tag`}),(0,U.jsx)(cb,{children:e===`create`?`Create a tag you can assign to routes.`:`Rename this tag or update its description.`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(dY,{htmlFor:`tag-edit-name`,children:[`Name `,(0,U.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,U.jsx)(iM,{id:`tag-edit-name`,value:u,onChange:e=>d(e.target.value),placeholder:`my-tag`,"aria-invalid":_||g.length===0,disabled:o,autoFocus:!0}),_&&(0,U.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`A tag named “`,g,`” already exists.`]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`tag-edit-description`,children:`Description`}),(0,U.jsx)(xw,{id:`tag-edit-description`,value:f,onChange:e=>p(e.target.value),placeholder:`A short description. Markdown is supported.`,rows:3,disabled:o})]})]}),(0,U.jsx)(ob,{className:`sm:justify-between`,children:m?(0,U.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,children:[(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Delete “`,r,`”?`,a>0&&` It will be removed from ${a} ${a===1?`route`:`routes`}.`]}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,onClick:()=>h(!1),children:`Keep`}),(0,U.jsxs)(X,{type:`button`,variant:`destructive`,onClick:l,children:[(0,U.jsx)(Kf,{size:14}),`Delete tag`]})]})]}):(0,U.jsxs)(U.Fragment,{children:[l&&!o?(0,U.jsxs)(X,{type:`button`,variant:`destructive-outline`,onClick:()=>h(!0),children:[(0,U.jsx)(Kf,{size:14}),`Delete`]}):(0,U.jsx)(`span`,{}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,onClick:s,children:`Cancel`}),(0,U.jsx)(X,{type:`submit`,disabled:!v,children:e===`create`?`Add`:`Save`})]})]})})]})}function Wkt({open:e,onOpenChange:t,info:n,onSave:r,defaultTab:i=`details`,tagsAutoCreate:a,onTagsAutoCreateConsumed:o}){return(0,U.jsx)(tb,{open:e,onOpenChange:t,children:(0,U.jsxs)(ib,{className:`top-16 translate-y-0 sm:max-w-xl`,children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`API Settings`}),(0,U.jsx)(cb,{children:`Edit your OpenAPI document's details and tags.`})]}),(0,U.jsxs)(AO,{defaultValue:i,children:[(0,U.jsxs)(jO,{variant:`underline`,children:[(0,U.jsx)(MO,{variant:`underline`,value:`details`,children:`Details`}),(0,U.jsx)(MO,{variant:`underline`,value:`tags`,children:`Tags`})]}),(0,U.jsx)(NO,{value:`details`,children:(0,U.jsx)(Gkt,{info:n,onCancel:()=>t(!1),onSave:e=>{r(e),t(!1)}})}),(0,U.jsx)(NO,{value:`tags`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsx)(Vkt,{autoCreate:a,onAutoCreateConsumed:o}),(0,U.jsx)(ob,{children:(0,U.jsx)(X,{type:`button`,onClick:()=>t(!1),children:`Done`})})]})})]})]})})}function Gkt({info:e,onSave:t,onCancel:n}){let[r,i]=(0,H.useState)(e.title??``),[a,o]=(0,H.useState)(e.version??``),[s,c]=(0,H.useState)(e.summary??``),[l,u]=(0,H.useState)(e.description??``),[d,f]=(0,H.useState)(e.termsOfService??``),[p,m]=(0,H.useState)(e.contact?.name??``),[h,g]=(0,H.useState)(e.contact?.url??``),[_,v]=(0,H.useState)(e.contact?.email??``),[y,b]=(0,H.useState)(e.license?.name??``),[x,S]=(0,H.useState)(e.license?.url??``),C=r.trim().length>0&&a.trim().length>0;return(0,U.jsxs)(`form`,{onSubmit:n=>{if(n.preventDefault(),!C)return;let i={...e,title:r.trim(),version:a.trim()},o=e=>{let t={summary:s,description:l,termsOfService:d}[e].trim();t?i[e]=t:delete i[e]};o(`summary`),o(`description`),o(`termsOfService`);let c={...e.contact??{}};for(let[e,t]of[[`name`,p],[`url`,h],[`email`,_]])t.trim()?c[e]=t.trim():delete c[e];if(Object.keys(c).length>0?i.contact=c:delete i.contact,y.trim()){let t={...e.license??{},name:y.trim()};x.trim()?t.url=x.trim():delete t.url,i.license=t}else delete i.license;t(i)},className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 max-h-[60vh] overflow-y-auto px-0.5 py-1`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-[1fr_auto] gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(dY,{htmlFor:`openapi-info-title`,children:[`Title `,(0,U.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,U.jsx)(iM,{id:`openapi-info-title`,value:r,onChange:e=>i(e.target.value),placeholder:`My API`,"aria-invalid":r.trim().length===0,autoFocus:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:w-32`,children:[(0,U.jsxs)(dY,{htmlFor:`openapi-info-version`,children:[`Version `,(0,U.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,U.jsx)(iM,{id:`openapi-info-version`,value:a,onChange:e=>o(e.target.value),placeholder:`1.0.0`,"aria-invalid":a.trim().length===0})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`openapi-info-summary`,children:`Summary`}),(0,U.jsx)(iM,{id:`openapi-info-summary`,value:s,onChange:e=>c(e.target.value),placeholder:`A short summary of the API`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`openapi-info-description`,children:`Description`}),(0,U.jsx)(xw,{id:`openapi-info-description`,value:l,onChange:e=>u(e.target.value),placeholder:`A longer description. Markdown is supported.`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`openapi-info-tos`,children:`Terms of service`}),(0,U.jsx)(iM,{id:`openapi-info-tos`,type:`url`,value:d,onChange:e=>f(e.target.value),placeholder:`https://example.com/terms`})]}),(0,U.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-md border border-border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-xs font-medium text-muted-foreground`,children:`Contact`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`openapi-info-contact-name`,children:`Name`}),(0,U.jsx)(iM,{id:`openapi-info-contact-name`,value:p,onChange:e=>m(e.target.value),placeholder:`API Support`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`openapi-info-contact-url`,children:`URL`}),(0,U.jsx)(iM,{id:`openapi-info-contact-url`,type:`url`,value:h,onChange:e=>g(e.target.value),placeholder:`https://example.com/support`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`openapi-info-contact-email`,children:`Email`}),(0,U.jsx)(iM,{id:`openapi-info-contact-email`,type:`email`,value:_,onChange:e=>v(e.target.value),placeholder:`support@example.com`})]})]})]}),(0,U.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-md border border-border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-xs font-medium text-muted-foreground`,children:`License`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`openapi-info-license-name`,children:`Name`}),(0,U.jsx)(iM,{id:`openapi-info-license-name`,value:y,onChange:e=>b(e.target.value),placeholder:`MIT`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(dY,{htmlFor:`openapi-info-license-url`,children:`URL`}),(0,U.jsx)(iM,{id:`openapi-info-license-url`,type:`url`,value:x,onChange:e=>S(e.target.value),placeholder:`https://opensource.org/licenses/MIT`})]})]})]})]}),(0,U.jsxs)(ob,{children:[(0,U.jsx)(X,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,U.jsx)(X,{type:`submit`,disabled:!C,children:`Save`})]})]})}var r3=(0,H.createContext)({setPath:()=>{},setSummary:()=>{}}),Kkt=({isReadOnly:e,initialSummary:t,onSummaryChange:n,onFieldModified:r})=>{let i=(0,H.useRef)(null),[a,o]=(0,H.useState)(!1),{setSummary:s}=(0,H.useContext)(r3);(0,H.useEffect)(()=>{i.current&&(i.current.value=t??``,s(t))},[t]);let c=e=>{a||(o(!0),r()),s(e.target.value)},l=e=>{a&&(n(e.target.value),o(!1))};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(dY,{htmlFor:`operation-summary`,className:`flex items-center gap-2`,children:`Summary`}),(0,U.jsxs)(EY,{className:`bg-background`,children:[(0,U.jsx)(kY,{ref:i,disabled:e,"data-test":`operation-summary-input`,id:`operation-summary`,name:`summary`,onChange:c,onBlur:l}),(0,U.jsx)(DY,{align:`inline-end`,children:(0,U.jsxs)(SN,{children:[(0,U.jsx)(CN,{asChild:!0,children:(0,U.jsx)(OY,{variant:`ghost`,"aria-label":`Info`,size:`icon-sm`,children:(0,U.jsx)(hy,{})})}),(0,U.jsx)(wN,{className:`max-w-52`,children:`Summary is used to describe the operation in the API. It should be brief and to the point.`})]})})]})]})};function qkt(){var e=[...arguments];return(0,H.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var i3=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function a3(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function o3(e){return`nodeType`in e}function s3(e){return e?a3(e)?e:o3(e)?e.ownerDocument?.defaultView??window:window:window}function c3(e){let{Document:t}=s3(e);return e instanceof t}function l3(e){return a3(e)?!1:e instanceof s3(e).HTMLElement}function Jkt(e){return e instanceof s3(e).SVGElement}function u3(e){return e?a3(e)?e.document:o3(e)?c3(e)?e:l3(e)||Jkt(e)?e.ownerDocument:document:document:document}var d3=i3?H.useLayoutEffect:H.useEffect;function f3(e){let t=(0,H.useRef)(e);return d3(()=>{t.current=e}),(0,H.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Ykt(){let e=(0,H.useRef)(null);return[(0,H.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,H.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function p3(e,t){t===void 0&&(t=[e]);let n=(0,H.useRef)(e);return d3(()=>{n.current!==e&&(n.current=e)},t),n}function m3(e,t){let n=(0,H.useRef)();return(0,H.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function h3(e){let t=f3(e),n=(0,H.useRef)(null);return[n,(0,H.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function g3(e){let t=(0,H.useRef)();return(0,H.useEffect)(()=>{t.current=e},[e]),t.current}var _3={};function v3(e,t){return(0,H.useMemo)(()=>{if(t)return t;let n=_3[e]==null?0:_3[e]+1;return _3[e]=n,e+`-`+n},[e,t])}function Xkt(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var y3=Xkt(1),b3=Xkt(-1);function Zkt(e){return`clientX`in e&&`clientY`in e}function x3(e){if(!e)return!1;let{KeyboardEvent:t}=s3(e.target);return t&&e instanceof t}function Qkt(e){if(!e)return!1;let{TouchEvent:t}=s3(e.target);return t&&e instanceof t}function S3(e){if(Qkt(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Zkt(e)?{x:e.clientX,y:e.clientY}:null}var C3=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[C3.Translate.toString(e),C3.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),$kt=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function eAt(e){return e.matches($kt)?e:e.querySelector($kt)}var tAt={display:`none`};function nAt(e){let{id:t,value:n}=e;return H.createElement(`div`,{id:t,style:tAt},n)}function rAt(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return H.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function iAt(){let[e,t]=(0,H.useState)(``);return{announce:(0,H.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var aAt=(0,H.createContext)(null);function oAt(e){let t=(0,H.useContext)(aAt);(0,H.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function sAt(){let[e]=(0,H.useState)(()=>new Set),t=(0,H.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,H.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var cAt={draggable:`
484
484
  To pick up a draggable item, press the space bar.
485
485
  While dragging, use the arrow keys to move the item.
@@ -1559,7 +1559,7 @@ In some cases, you need to provide options to alter GraphQL's execution behavior
1559
1559
  `+t+`)`}function c8(e){let t=$6(e.defaultValue,e.type),n=e.name+`: `+String(e.type);return t&&(n+=` = ${Sn(t)}`),n+l8(e.deprecationReason)}function WIt(e){return u8(e)+`directive @`+e.name+UIt(e.args)+(e.isRepeatable?` repeatable`:``)+` on `+e.locations.join(` | `)}function l8(e){return e==null?``:e===`No longer supported`?` @deprecated`:` @deprecated(reason: ${Sn({kind:tr.STRING,value:e})})`}function GIt(e){return e.specifiedByURL==null?``:` @specifiedBy(url: ${Sn({kind:tr.STRING,value:e.specifiedByURL})})`}function u8(e,t=``,n=!0){let{description:r}=e;if(r==null)return``;let i=Sn({kind:tr.STRING,value:r,block:Nn(r)});return(t&&!n?`
1560
1560
  `+t:t)+i.replace(/\n/g,`
1561
1561
  `+t)+`
1562
- `}var d8=`/docs/schema.graphql`,KIt=()=>JSON.stringify({query:DIt()}),qIt=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`${kIt(OIt(t.data))}\n`}catch(e){throw Error(`Could not build a schema from the introspection result: ${e instanceof Error?e.message:String(e)}`)}},JIt=({endpointUrl:e,rewriteUrl:t,ape:n,onClose:r})=>{let{logEvent:i}=on(),a=pp(),o=LZ(),s=oP(),[c,l]=(0,H.useState)(t??e),[u,d]=(0,H.useState)([{key:``,value:``}]),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(),g=(e,t,n)=>{d(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},_=()=>d(e=>[...e,{key:``,value:``}]),v=e=>d(t=>t.filter((t,n)=>n!==e)),y=async()=>{h(void 0),p(!0);let l=c===t?`handler`:c===e?`gateway`:`custom`,d={account:n.account.name,project:n.project.name,environment:n.environment.name,endpointMode:l};i(`graphql-schema-introspection-run`,d);let f=`request`,m;try{let e;try{f=`invalid_url`,e=new URL(c)}catch{throw Error(`Enter a valid endpoint URL, including the protocol (e.g. https://).`)}let t={"content-type":`application/json`};for(let{key:e,value:n}of u){let r=e.trim();r.length>0&&(t[r]=n)}f=`request`;let l=await(await s({environmentName:n.environment.name,testRequest:{description:`GraphQL introspection`,pathname:`${e.pathname}${e.search}`,method:`POST`,headers:t,body:KIt()},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=qIt(l.body);f=`save`,await o.mutateAsync({file:{path:d8,content:p},accountName:n.account.name,projectName:n.project.name,environmentName:n.environment.name}),i(`graphql-schema-introspection-success`,{...d,upstreamStatus:m}),a.success(`Schema saved to ${d8}`),r()}catch(e){let t=e instanceof Error?e.message:String(e);i(`graphql-schema-introspection-failed`,{...d,stage:f,upstreamStatus:m,reason:t}),h(t)}finally{p(!1)}};return(0,U.jsx)(tb,{open:!0,onOpenChange:e=>!e&&!f&&r(),children:(0,U.jsxs)(ib,{className:`sm:max-w-2xl`,children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Download GraphQL schema`}),(0,U.jsxs)(cb,{children:[`Run an introspection query against this endpoint. On success the schema is stored in `,(0,U.jsx)(`code`,{children:d8}),`.`]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(dY,{htmlFor:`graphql-introspection-endpoint`,children:`Endpoint`}),e&&e!==c&&(0,U.jsx)(X,{variant:`link`,size:`xs`,type:`button`,className:`h-auto p-0`,disabled:f,onClick:()=>l(e),children:`Use gateway URL`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(iM,{id:`graphql-introspection-endpoint`,value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com/graphql`,disabled:f,"data-op-ignore":!0}),(0,U.jsx)(sM,{textToCopy:c})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(dY,{children:`Headers (optional)`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(iM,{placeholder:`Header name`,value:e.key,onChange:e=>g(t,`key`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(iM,{placeholder:`Value`,value:e.value,onChange:e=>g(t,`value`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,type:`button`,"aria-label":`Remove header`,onClick:()=>v(t),children:(0,U.jsx)(Kf,{className:`size-4`})})]},t))}),(0,U.jsx)(`div`,{children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,type:`button`,onClick:_,children:[(0,U.jsx)(Sf,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Add header`})]})})]}),m&&(0,U.jsxs)(Vy,{variant:`destructive`,children:[(0,U.jsx)(od,{}),(0,U.jsx)(Hy,{children:`Introspection failed`}),(0,U.jsx)(Uy,{className:`break-words`,children:m})]})]}),(0,U.jsxs)(ob,{children:[(0,U.jsx)(rb,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,type:`button`,disabled:f,children:`Cancel`})}),(0,U.jsx)(X,{variant:`brand`,type:`button`,onClick:y,disabled:f||c.trim().length===0,children:f?`Running…`:`Run introspection`})]})]})})},YIt=({path:e,rewriteUrl:t})=>{let n=hp(),r=Xa(),{logEvent:i}=on(),[a,o]=(0,H.useState)(!1),s=sP(n.environment),c=s?new URL(e,s).toString():void 0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,children:[(0,U.jsx)(o1,{className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{children:`Schema`}),(0,U.jsx)(td,{className:`size-4 shrink-0`})]})}),(0,U.jsxs)(XG,{align:`end`,children:[(0,U.jsxs)(QG,{onSelect:()=>{i(`graphql-schema-open`,{account:n.account.name,project:n.project.name,environment:n.environment.name}),r({pathname:Zr(mb.Code,{account:n.account.name,project:n.project.name,environment:encodeURIComponent(n.environment.urlParameter)}),search:`?path=${d8}`})},children:[(0,U.jsx)(Rd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Open Schema`})]}),(0,U.jsxs)(QG,{disabled:!c,onSelect:()=>o(!0),children:[(0,U.jsx)(Dd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Download Schema`})]})]})]}),a&&c&&(0,U.jsx)(JIt,{endpointUrl:c,rewriteUrl:t,ape:n,onClose:()=>o(!1)})]})},XIt=({operationTags:e,onTagsChanged:t})=>{let{isReadOnly:n}=wZ(),r=Y$(),[i,a]=(0,H.useState)(``),o=r.openApiData?.tags?.map(e=>e.name)??[],s=n=>{e.includes(n)?t(e.filter(e=>e!==n)):t([...e,n])},c=()=>{let n=i.trim();if(n){if(!o.includes(n))try{r.addTag(n)}catch{}e.includes(n)||t([...e,n]),a(``)}};return(0,U.jsxs)(dT,{children:[(0,U.jsx)(fT,{asChild:!0,children:(0,U.jsxs)(l6,{children:[(0,U.jsx)(Uf,{size:16}),e.length===1?(0,U.jsx)(`span`,{className:`truncate max-w-[12ch]`,title:e[0],children:e[0]}):`${e.length} Tags`]})}),(0,U.jsxs)(pT,{className:`w-64 p-0 z-100`,align:`end`,children:[(0,U.jsx)(`div`,{className:`px-3 pt-3 pb-2`,children:(0,U.jsx)(`h4`,{className:`text-sm font-medium`,children:`Operation Tags`})}),o.length>0&&(0,U.jsx)(`div`,{className:`border-t max-h-48 overflow-y-auto`,children:o.map(t=>(0,U.jsxs)(`button`,{type:`button`,disabled:n,className:`w-full flex items-center justify-between px-3 py-1.5 text-sm hover:bg-accent disabled:opacity-50 disabled:cursor-default cursor-pointer`,onClick:()=>s(t),children:[(0,U.jsx)(`span`,{className:`truncate`,children:t}),(0,U.jsx)(ed,{size:14,className:W(`shrink-0`,!e.includes(t)&&`invisible`)})]},t))}),!n&&(0,U.jsx)(`div`,{className:`border-t p-2`,children:(0,U.jsxs)(`form`,{className:`flex gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,U.jsx)(iM,{value:i,onChange:e=>a(e.target.value),placeholder:`New tag...`,className:`h-7 text-xs`}),(0,U.jsx)(X,{type:`submit`,variant:`outline`,size:`icon-sm`,disabled:!i.trim(),children:(0,U.jsx)(Sf,{size:14})})]})})]})]})},ZIt=r(a((e=>{var t=/~/,n=/~[01]/g;function r(e){switch(e){case`~1`:return`/`;case`~0`:return`~`}throw Error(`Invalid tilde escape: `+e)}function i(e){return t.test(e)?e.replace(n,r):e}function a(e){if(typeof e==`string`){if(e=e.split(`/`),e[0]===``)return e;throw Error(`Invalid JSON pointer.`)}else if(Array.isArray(e)){for(let t of e)if(typeof t!=`string`&&typeof t!=`number`)throw Error(`Invalid JSON pointer. Must be of type string or number.`);return e}throw Error(`Invalid JSON pointer.`)}function o(e,t){if(typeof e!=`object`)throw Error(`Invalid input object.`);t=a(t);var n=t.length;if(n===1)return e;for(var r=1;r<n;){if(e=e[i(t[r++])],n===r)return e;if(typeof e!=`object`||!e)return}}e.get=o}))());function f8(e,t){try{return e.startsWith(`#`)?ZIt.get(t,e.replace(`#`,``)):ZIt.get(t,e)}catch(e){console.error(`Error resolving schema reference. Reference may be invalid or referencing an external document.`,e);return}}var QIt=(e,t)=>{let n=e;return!n||`$ref`in n&&(n=f8(n.$ref,t),!n)?``:n.example?n.example:n.examples&&n.examples.length>0?n.examples[0]:n.default?n.default:``},$It=(e,t)=>{if(e.examples&&Object.keys(e.examples).length>0){let n=Object.values(e.examples)[0];if(`$ref`in n){let e=f8(n.$ref,t);if(!e)return``;n=e}return n.value}if(e.example)return e.example;let n=e.schema;return QIt(n,t)},eLt=(e,t)=>{let n=e.requestBody;if(!n)return``;if(`$ref`in n){let e=f8(n.$ref,t);if(!e)return``;n=e}let{content:r}=n;if(!(`application/json`in r))return``;let i=r[`application/json`];if(i.examples&&Object.keys(i.examples).length>0){let e=Object.values(i.examples)[0];if(`$ref`in e){let n=f8(e.$ref,t);if(!n)return``;e=n}return e.value}let a=i.schema;return QIt(a,t)},tLt=JSON.stringify({query:`{ __schema { queryType { name } } }`},null,2),nLt=new aP,rLt=e=>e.additionalOperationContext.method.split(`,`).map(e=>e.toUpperCase()),p8=e=>{let{oasFilePath:t,method:n,path:r}=e.additionalOperationContext;return`${t}::${e.operationId??`${n} ${r}`}`},iLt=({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=rLt(t)[0],i=t[xX]===!0,a=EX(t),o=eLt(t,n),s=nLt.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]:$It(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?KN:i?tLt:l);return s?.test&&s.test.method===r?s.test:{description:t.summary??t.description??``,pathname:t.additionalOperationContext.path,method:r,headers:u,body:d}},[u,d]=(0,H.useState)(n),[f,p]=(0,H.useState)(()=>l(n,r)),[m,h]=(0,H.useState)(o),g=Cp(e=>e.setTestResponse),_=Dp(),v=s??_,y=(0,H.useMemo)(()=>({...v,[n.additionalOperationContext.oasFilePath]:r}),[v,n.additionalOperationContext.oasFilePath,r]),b=(0,H.useMemo)(()=>Object.entries(y).flatMap(([e,t])=>J$(e,t)),[y]),x=(0,H.useMemo)(()=>b.map(e=>({id:p8(e),method:e.additionalOperationContext.method,path:e.additionalOperationContext.path,summary:e.summary,file:e.additionalOperationContext.oasFilePath})),[b]);return(0,H.useEffect)(()=>{g(void 0)},[]),(0,U.jsx)(`div`,{className:`flex h-[650px] max-h-[70vh] flex-col`,children:(0,U.jsx)(rY,{ape:e,apiTest:f,showRebuildWarning:i,allowedMethods:rLt(u),url:`${t}${u.additionalOperationContext.path}`,shouldAllowLocalSaving:!!u.operationId,operationId:u.operationId,path:u.additionalOperationContext.path,onRequestChange:e=>{p(e)},onClose:a,endpoints:x,selectedEndpointId:p8(u),onSelectEndpoint:e=>{if(e===p8(u))return;let t=b.find(t=>p8(t)===e);if(!t)return;let n=y[t.additionalOperationContext.oasFilePath]??r;d(t),p(l(t,n)),g(void 0)},isEndpointPanelOpen:m,onToggleEndpointPanel:()=>h(e=>!e),endpointsLoading:c},p8(u))})},aLt=({envUrl:e,ape:t,operation:n,openApiDocument:r,showRebuildWarning:i,entries:a,onClose:o,defaultEndpointsPanelOpen:s})=>(0,U.jsx)(SJ.Provider,{value:{entries:a},children:(0,U.jsx)(`div`,{className:`w-full text-muted-foreground`,children:(0,U.jsx)(iLt,{openApiDocument:r,ape:t,envUrl:e,showRebuildWarning:i,operation:n,onClose:o,defaultEndpointsPanelOpen:s})})}),oLt=({open:e,onOpenChange:t,onProceed:n})=>{let{saveAndDeploy:r,isPending:i}=ylt();return(0,U.jsx)(tb,{open:e,onOpenChange:t,children:(0,U.jsxs)(ib,{className:`sm:max-w-md`,children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Unsaved changes`}),(0,U.jsx)(cb,{children:`Your unsaved changes will not be reflected when you test this route until you save and deploy them. Save them now, or continue testing the currently deployed version.`})]}),(0,U.jsxs)(ob,{children:[(0,U.jsx)(X,{variant:`ghost`,onClick:n,disabled:i,children:`Continue without saving`}),(0,U.jsx)(X,{variant:`default`,onClick:async()=>{try{await r()}catch{return}n()},disabled:i,children:(0,U.jsx)(rM,{loading:i,children:`Save changes`})})]})]})})},sLt=(0,H.lazy)(()=>gn(()=>import(`./GraphiQLConsole-BKzVJZ-7.js`),__vite__mapDeps([9,1,2,8,10,11,12]))),cLt=({path:e,method:t,summary:n,operationData:r,hasFileChanged:i,isGraphql:a})=>{let{logEvent:o}=on(),s=hp(),c=Y$().getOpenApiDataEnforced(),{entries:l}=(0,H.useContext)(SJ),u=sP(s.environment),[d,f]=(0,H.useState)(null),p=u?new URL(e,u).toString():void 0,m=Iee({mutationKey:ilt})>0,[h,g]=h$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:t.includes(`,`)?t.split(`,`)[0]:t,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:a?`playground`:`default`}),(0,U.jsx)(tb,{open:!0,onOpenChange:e=>!e&&g(),children:(0,U.jsxs)(ib,{showCloseButton:!1,className:`max-w-6xl! w-full gap-0 overflow-hidden p-0`,children:[(0,U.jsx)(sb,{className:`sr-only`,children:`Test route`}),(0,U.jsx)(aLt,{envUrl:u??``,showRebuildWarning:i,ape:s,entries:l,operation:r,openApiDocument:c,onClose:g})]})})),[e,t,n,r,l,a]),[_,v]=h$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:`POST`,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:`graphiql`}),(0,U.jsx)(tb,{open:!0,onOpenChange:e=>!e&&v(),children:(0,U.jsxs)(ib,{className:`max-w-6xl! w-full p-0 overflow-hidden`,children:[(0,U.jsx)(sb,{className:`sr-only`,children:`GraphiQL`}),(0,U.jsx)(`div`,{className:`h-[80vh] w-full`,children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:`Loading GraphiQL…`}),children:(0,U.jsx)(sLt,{url:p??``,ape:s})})})]})})),[p,s]),y=e=>{e===`graphiql`?_():h()},b=e=>{if(i){f(e);return}y(e)},x=(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{children:`Saving`}),(0,U.jsx)(nM,{color:`current`})]}),S=m?`Saving`:`Test Route`;return(0,U.jsxs)(U.Fragment,{children:[a?(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{asChild:!0,children:(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":S,children:(0,U.jsxs)(rM,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(tp,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`}),(0,U.jsx)(td,{className:`size-4 shrink-0`})]})})}),(0,U.jsxs)(XG,{align:`end`,children:[(0,U.jsxs)(QG,{onSelect:()=>b(`playground`),children:[(0,U.jsx)(tp,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Playground`})]}),(0,U.jsxs)(QG,{disabled:!p,onSelect:()=>b(`graphiql`),children:[(0,U.jsx)(o1,{className:`size-4`}),(0,U.jsx)(`span`,{children:`GraphiQL`})]})]})]}):(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":S,onClick:()=>b(`playground`),children:(0,U.jsxs)(rM,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(tp,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`})]})}),(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(oLt,{open:d!==null,onOpenChange:e=>{e||f(null)},onProceed:()=>{let e=d;f(null),e&&y(e)}})})]})},lLt=({onRequestHandlerChange:e,isReadOnly:t,routeHandler:n})=>{let r=c1(n),i=(t,i)=>{e({...n,options:{...r.options,[t]:i}})};return(0,U.jsxs)(ZD,{className:`p-4 bg-surface-sunken`,children:[(0,U.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-base font-medium`,children:`MCP Server Options`}),(0,U.jsx)(kT,{showIcon:!0,href:`https://docs.zuplo.com/handlers/mcp-server`,className:`text-sm text-zuplo-pink`,children:`MCP Server Docs`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-12 gap-4 col-span-full items-center`,children:[(0,U.jsx)(`div`,{className:`col-span-8`,children:(0,U.jsx)(s6,{isReadOnly:t,label:`Server Name`,onChange:e=>i(`name`,e.target.value),className:`col-span-8`,value:typeof r.options.name==`string`?r.options.name:`My MCP Server`})}),(0,U.jsx)(`div`,{className:`col-span-4`,children:(0,U.jsx)(s6,{isReadOnly:t,label:`Server Version`,className:`col-span-4`,onChange:e=>i(`version`,e.target.value),value:typeof r.options.version==`string`?r.options.version:`v0.0.1`})}),(0,U.jsxs)(`div`,{className:`col-span-12 mt-2`,children:[(0,U.jsx)(dY,{className:`text-sm mb-2 block`,children:`Advanced Options`}),(0,U.jsx)(`div`,{className:W(`flex gap-4`,t&&`opacity-50`),children:(0,U.jsxs)(`label`,{className:`text-sm flex items-center gap-2`,children:[(0,U.jsx)(YJ,{"data-test":`mcp-debug-mode`,checked:!!r.options.debugMode,onCheckedChange:e=>{i(`debugMode`,e)},disabled:t}),`Debug Mode`]})})]})]})]})},uLt=({routeHandler:e,operation:t,isReadOnly:n,onRequestHandlerChange:r})=>{let{captureRaw:i}=on(),a=Bht(),o=c1(e),s=typeof o.options.rewritePattern==`string`?o.options.rewritePattern:``,c=ENt(()=>{i(`mcp-gateway-upstream-url-edited`)});return(0,U.jsx)(ZD,{className:`p-4`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground font-medium`,children:`Upstream MCP server`}),!!(a&&t)&&(0,U.jsxs)(X,{type:`button`,variant:`default`,size:`sm`,disabled:n,onClick:()=>{!t||!a||(i(`mcp-gateway-edit-virtual-mcp-opened`),a(t))},className:`shrink-0`,children:[(0,U.jsx)(Nf,{className:`w-3.5 h-3.5`}),`Edit MCP Server Policy`]})]}),(0,U.jsx)(Y4,{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 dLt(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 fLt({operationData:e,addRouteMenuProps:t}){return e?(0,U.jsx)(`div`,{className:`w-full h-full min-h-0 overflow-y-auto px-4 pt-2 pb-4`,children:(0,U.jsx)(mLt,{operationData:e})}):(0,U.jsx)(Gmt,{...t})}var pLt=()=>{let e=Ep(),t=Dp(),n=(0,H.useMemo)(()=>e.flatMap(e=>{let n=t[e.path];return n?J$(e.path,n).filter(e=>EX(e)).map(t=>[e,t]):[]}),[e,t]);return{getLinkedMcpServers:(e,t)=>n.filter(([,n])=>{let r=n[CX]?.handler;return wX(r)?r.options?.operations?.some(n=>a1(n.file)===e&&n.id===t):!1})}},mLt=({operationData:e})=>{let[t]=wJ(`path`);if(!t)throw Error(`Open API file path not found in URL`);let n=vlt(t),r=hp(),{logEvent:i}=on(),{additionalOperationContext:a,...o}=e,{path:s,method:c}=a,l=Y$(),u=pp(),d=u1(),{isReadOnly:f}=wZ(),[p,m]=(0,H.useState)(),[h,g]=(0,H.useState)();pLt();let _=l.openApiData?.servers?.at(0)?.url,v=o[CX]??Z$(_??`https://echo.zuplo.io`),y=o[bX]===!0,b=o.deprecated===!0,x=o[xX]===!0,S=l.openApiFileModel.saveState!==Hs.unmodified,C=v.handler,w=wX(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,[CX]:{...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,[bX]: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[xX]=!0,kmt(d),n[CX]=Omt(v,!0)):(delete n[xX],o[CX]&&(n[CX]=Omt(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,[CX]: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,[SX]:a}),i(`route-path-mode-changed`,{pathMode:n,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},L=()=>{n(Hs.modified)};return(0,U.jsxs)(`div`,{className:`mb-4 flex flex-col gap-6`,children:[(0,U.jsxs)(ZD,{className:`bg-neutral-50 dark:bg-transparent`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,U.jsxs)(QD,{children:[(0,U.jsx)($D,{children:`Request Handling`}),(0,U.jsx)(eO,{})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-6`,children:[x&&(0,U.jsx)(YIt,{path:s,rewriteUrl:typeof C.options?.rewritePattern==`string`?C.options?.rewritePattern:void 0}),(0,U.jsx)(wFt,{operationData:e}),(0,U.jsx)(cLt,{path:s,method:c,summary:o.summary??``,operationData:e,hasFileChanged:S,isGraphql:x})]})]}),(0,U.jsxs)(tO,{className:`grid grid-cols-1 xl:grid-cols-[max-content_1fr] gap-y-3 xl:gap-y-2 items-center gap-x-6`,children:[(0,U.jsx)(NFt,{isReadOnly:f,initialPath:s,method:c,onChangeMethod:N,pathMode:e.additionalOperationContext.pathZuploConfig?.pathMode,hasError:p!=null,onPathChange:M,onPathModeChange:I,onFieldModified:L,isMcpToolHandler:wX(C)||TX(C)}),p&&(0,U.jsx)(Vy,{"data-test":`path-error`,className:`col-span-full p-2`,variant:`destructive`,children:(0,U.jsx)(Uy,{children:p})}),w&&(0,U.jsx)(Vy,{className:`col-span-full p-2 py-1`,variant:`destructive`,children:(0,U.jsxs)(Uy,{"data-test":`request-handler-error`,className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{children:w}),(0,U.jsx)(X,{onClick:()=>N(`post`),size:`xs`,variant:`outline`,className:`border-none`,children:`Switch to POST method`})]})}),(0,U.jsx)(Kkt,{isReadOnly:f,initialSummary:o.summary,onSummaryChange:E,onFieldModified:L}),(0,U.jsx)(TFt,{isReadOnly:f,defaultOperationId:e.operationId,openApiManager:l,path:s,method:c,operationData:e})]}),(0,U.jsxs)(nO,{className:`flex flex-wrap gap-2 px-3 py-1.5 bg-card justify-end`,children:[(0,U.jsx)(XIt,{operationTags:o.tags??[],onTagsChanged:F}),(0,U.jsx)(iPt,{isReadOnly:f,selectedCorsPolicy:v.corsPolicy,corsPolicies:d.corsPolicyList??[],onSelectionChanged:P}),!wX(v.handler)&&!TX(v.handler)&&(0,U.jsx)(AFt,{operation:e,defaultValues:dLt(v.mcp),onSubmit:e=>{let t={...v,mcp:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[CX]:t}})}}),(0,U.jsx)($Pt,{isExcludedFromDocs:y,onVisibilityChanged:O}),(0,U.jsx)(PFt,{isGraphql:x,onGraphqlChanged:A,isDeprecated:b,onDeprecatedChanged:k})]})]}),(0,U.jsx)(yNt,{inboundPolicies:v.policies?.inbound??[],outboundPolicies:v.policies?.outbound??[],operation:e,children:(0,U.jsx)(hLt,{isReadOnly:f,operationData:e,handler:v.handler,firstServerUrl:_,onRequestHandlerChange:T})}),(0,U.jsx)(QPt,{initialDescription:o.description??``,onChange:D,path:s,method:c,oasFilePath:t})]})},hLt=({operationData:e,handler:t,firstServerUrl:n,isReadOnly:r,onRequestHandlerChange:i})=>{let a=(e[CX]??Z$(n??`https://echo.zuplo.io`)).handler;switch(t.export){case`mcpServerHandler`:return(0,U.jsx)(lLt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i});case`McpProxyHandler`:case`McpVirtualServerHandler`:case`mcpVirtualServerHandler`:return(0,U.jsx)(uLt,{routeHandler:a,operation:e,isReadOnly:r,onRequestHandlerChange:i});default:return(0,U.jsx)(ePt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i})}},gLt=Ae()(e=>({updateLinkedMcpServers:void 0,setUpdateLinkedMcpServers:t=>e({updateLinkedMcpServers:t})})),_Lt=()=>{let e=p(gLt,e=>e.updateLinkedMcpServers),t=HZ(),n=()=>{gLt.setState({updateLinkedMcpServers:void 0})};return(0,U.jsx)(tb,{open:!!e,onOpenChange:e=>{e||n()},children:(0,U.jsxs)(ib,{children:[(0,U.jsx)(sb,{children:`MCP Server Links`}),(0,U.jsx)(cb,{children:`This operation is linked to MCP servers, if you update the operation id, you need to update the MCP server links as well.`}),(0,U.jsx)(`div`,{className:`flex gap-2 items-center justify-center`,children:e?.linkedMcpServers.map(([,e])=>(0,U.jsx)(XD,{children:e},e))}),(0,U.jsxs)(ob,{children:[(0,U.jsx)(X,{variant:`outline`,onClick:n,children:`Cancel`}),(0,U.jsx)(X,{onClick:()=>{e?.linkedMcpServers.forEach(([n,r])=>{let i=new hmt(n,t),a=i.getOperationById(r);if(!a)return;let o=a[CX];if(!o)return;let s=o.handler;if(wX(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:T$(t,`operationId`,e.newOperationId)})}i.updateOperation({path:a?.additionalOperationContext.path,method:a.additionalOperationContext.method,newOperationObject:T$(a,`${CX}.handler.options.operations`,s.options?.operations?.map(t=>a1(t.file)===n.path?{...t,id:t.id===e.oldOperationId?e.newOperationId:t.id}:t))})}})},children:`Update`})]})]})})},vLt=`$import(@zuplo/runtime)`,yLt=`${vLt}::urlForwardHandler`,bLt=`${vLt}::urlRewriteHandler`,xLt=(e,t)=>{let n=e.options?.[t],r=typeof n==`string`?n.trim():``;return r.length>0?r:void 0},SLt=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)},CLt=e=>{if(e){let t=`${e.module}::${e.export}`,n=t===yLt?xLt(e,`baseUrl`):t===bLt?xLt(e,`rewritePattern`):void 0;if(n){let e=SLt(n);return{key:`target:${e}`,label:e,mono:!0,icon:Yd,collapsible:!0}}}return{...Oht(e),collapsible:!1}};function wLt(){let e=Y$(),{captureRaw:t}=on(),n=hp(),r=zZ();return i=>{e.updateInfo(i),t(`openapi-info-updated`);let{projectTreeNodes:a,filesByPath:o}=Cp.getState(),s=a.map(e=>e.path?o[e.path]:void 0).filter(e=>!!e&&e.saveState===Hs.modified);s.length!==0&&r.mutateAsync({environmentName:n.environment.name,accountName:n.account.name,projectName:n.project.name,files:s}).catch(()=>{})}}var m8=`Document Order`,TLt=[`Document Order`,`Path`,`Summary`],h8=`Untagged`,ELt=[{value:`none`,label:`None`},{value:`path`,label:`Path`},{value:`handler`,label:`Handler type`},{value:`target`,label:`Target`}],DLt=new Set([`handler`,`target`]);function OLt(e){return`${e}-${Ne().split(`-`).at(0)}`}function g8(e){return new Set(e.getPolicyListEnforced().map(e=>e.name))}function kLt(e){if(!e)return;let t=Lkt(e.getPolicyListEnforced());if(t)return t.name;let n=n3(Fkt,g8(e));return e.createPolicy(Ikt(n)),n}var ALt=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}},jLt=e=>t=>{if(e.length===0)return!0;let n=t.tags;return!n||n.length===0?e.includes(h8):n.some(t=>e.includes(t))},MLt=({onNavigateToOpenApiFileTab:e})=>{let{logEvent:t,captureRaw:n}=on(),[r,i]=Jet(`tags`,[]),[a,o]=hT(`open-api-designer-group-by`,`none`);(0,H.useEffect)(()=>{let e=window.localStorage.getItem(`open-api-designer-show-headers`);e!==null&&(e===`true`&&a===`none`&&o(`path`),window.localStorage.removeItem(`open-api-designer-show-headers`))},[a,o]);let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(`details`),[d,f]=(0,H.useState)(!1),p=wLt(),m=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)||(e.preventDefault(),m.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let[h,g]=(0,H.useState)(),[_,v]=(0,H.useState)(),[y,b]=(0,H.useState)(()=>new Set),x=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[S,C]=(0,H.useState)(()=>new Set),w=e=>C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),{isReadOnly:T}=wZ(),[E,D]=wJ(`operation`),[O,k]=hT(`default-sort-routes`,m8),[A,j]=wJ(`sort`,O);(0,H.useEffect)(()=>{A&&k(A)},[k,A]),(0,H.useEffectEvent)(()=>{if(E)try{document.querySelector(`#op-${E}`)?.scrollIntoView()}catch{}});let[M,N]=(0,H.useState)(void 0),P=Y$(),F=u1(),I=uM(),L=UZ(kht),R=WZ(),z=()=>{if(L)return jht(L.content??``)?`ok`:`manual`;let e=Aht,t={path:kht,content:e,type:Vs.File,saveState:Hs.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:Hs.modified}),`ok`},{results:B,setSearchTerm:ee,searchTerm:V}=lht(P.operationArray?.filter(jLt(r)).sort(ALt(A))??[],{keys:[e=>e.additionalOperationContext.path,e=>e.summary??``,e=>e.operationId,e=>e.additionalOperationContext.method]});(0,H.useEffect)(()=>{let e=V?.trim()??``;if(e.length===0)return;let n=setTimeout(()=>{t(`route-search-used`,{view:`routes`,query:e,queryLength:e.length})},600);return()=>clearTimeout(n)},[V,t]);let te=(()=>{let e=new Map;for(let t of B){let n,r,i,o,s;if(a===`handler`||a===`target`){let e=t[CX]?.handler,c=a===`target`?CLt(e):{...Oht(e),collapsible:!1};({key:n,label:r,mono:i,collapsible:o,icon:s}=c)}else n=t.additionalOperationContext.path,r=n,i=!0,o=!1,s=void 0;let c=e.get(n);c?c.operations.push(t):e.set(n,{key:n,label:r,mono:i,icon:s,collapsible:o,operations:[t]})}return[...e.values()]})(),[ne,re]=(0,H.useState)(),[ie,ae]=(0,H.useState)(),[oe,se]=(0,H.useState)(!1),ce=(0,H.useMemo)(()=>{if(!_)return[];let e=(P.operationArray?.find(e=>e.additionalOperationContext.path===_.path&&e.additionalOperationContext.method===_.method))?.[CX]?.policies?.inbound??[];if(e.length===0)return[];let t=new Set;for(let e of F.policyList??[]){if(e.policyType!==`composite-inbound`&&e.policyType!==`composite-outbound`)continue;let n=e.handler.options?.policies;if(n)for(let e of n)t.add(e)}let n=F.policiesUsageInfo??[];return e.map(e=>n.find(t=>t.name===e)).filter(e=>{if(!e||e.operations.length!==1)return!1;let n=e.operations[0];return!(n.additionalOperationContext.path!==_.path||n.additionalOperationContext.method!==_.method||t.has(e.name))})},[_,P.operationArray,F.policyList,F.policiesUsageInfo]),[le,ue]=(0,H.useState)(()=>new Set);(0,H.useEffect)(()=>{ue(_?new Set(ce.map(e=>e.name)):new Set)},[_]);let de=(e,t)=>{ue(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},fe=()=>{if(_==null){se(!1);return}try{for(let e of le)try{F.deletePolicy(e),t(`policy-deleted`,{policy:e})}catch{}P.deleteOperation(_.path,_.method),t(`route-deleted`,_)}catch(e){e instanceof Error&&(t(`route-deletion-failed`,_),N(e.message),pe())}v(void 0),se(!1)},[pe,me]=h$(()=>{let t=()=>{N(void 0),me()};return(0,U.jsx)(tQ,{alertType:`ERROR`,bodyText:M??``,onPrimaryButtonClick:e,onSecondaryButtonClick:t,primaryButtonText:`Edit file directly`,secondaryButtonText:`Cancel`,hideModal:t,title:`Error`})},[M]),[he,ge]=h$(()=>(0,U.jsx)(tQ,{alertType:`CAUTION`,bodyText:`Cannot reorder in this view — view by Document Order to reorganize the order of operations.`,onPrimaryButtonClick:()=>{j(m8),ge()},onSecondaryButtonClick:ge,primaryButtonText:`Switch to Document Order`,secondaryButtonText:`Cancel`,hideModal:ge,title:`Cannot reorder`})),[_e,ve]=h$(()=>(0,U.jsx)(Nht,{open:!0,onOpenChange:e=>{e||ve()}})),ye=(e,t)=>{if(A!==m8){he();return}P.movePathInDocument(e,t)};if(!P.openApiData)throw Error(`Invalid State - no OpenApiData`);let be=P.openApiData.info,xe=P.openApiData.tags?.map(e=>({value:e.name,label:e.name}));xe?.push({value:h8,label:h8});let Se=()=>{let e=n1.OpenAPIV3.HttpMethods.GET,n=P.openApiData?.servers?.at(0)?.url,r=Emt(n??`https://echo.zuplo.io`),i=`/path-${((P.operationArray?.filter(t=>t.additionalOperationContext.path.startsWith(`/path-`)&&t.additionalOperationContext.method===e)?.map(e=>parseInt(e.additionalOperationContext.path.replace(`/path-`,``),10))?.filter(e=>!Number.isNaN(e))?.sort((e,t)=>t-e))?.at(0)??0)+1}`;try{let t=P.addOperation(i,e,r);t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:i,httpMethod:e}),N(n.message),pe())}t(`route-added`)},Ce=(e,n,r)=>{let i=P.openApiData?.servers?.at(0)?.url,a=Emt(i??`https://echo.zuplo.io`),o=r?.[CX],s=a[CX];o&&s&&(o.handler&&(s.handler=JSON.parse(JSON.stringify(o.handler))),o.policies&&(s.policies=JSON.parse(JSON.stringify(o.policies))));try{let t=P.addOperation(e,n,a);t&&D(t)}catch(r){r instanceof Error&&(t(`route-add-failed`,{httpPath:e,httpMethod:n}),N(r.message),pe())}t(`route-added`)},we=()=>{let e=n1.OpenAPIV3.HttpMethods.POST,n=OLt(`mcp`),r=P.addOperation(`/mcp`,e,{summary:`MCP Server`,description:`Default MCP Server`,[CX]:{corsPolicy:`none`,handler:{export:`mcpServerHandler`,module:`$import(@zuplo/runtime)`,options:{operations:[]}},policies:{inbound:[]}},operationId:n},{avoidConflict:!0});r&&D(r),t(`route-added`)},Te=()=>{let e=n1.OpenAPIV3.HttpMethods.POST,n=Amt(`https://rickandmortyapi.com/graphql`);try{kmt(F);let t=P.addOperation(`/graphql`,e,n,{avoidConflict:!0});t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/graphql`,httpMethod:e}),N(n.message),pe())}t(`route-added`)},Ee=()=>{let e=n1.OpenAPIV3.HttpMethods.GET,n=jmt();try{let t=P.addOperation(`/websocket`,e,n,{avoidConflict:!0});t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/websocket`,httpMethod:e}),N(n.message),pe())}t(`route-added`)},[De,Oe]=(0,H.useState)(!1),[ke,Ae]=(0,H.useState)(),[je,Me]=(0,H.useState)(0),Pe=(0,H.useMemo)(()=>{let e=new Set(Object.keys(P.openApiData?.paths??{}));return ke&&e.delete(ke.path),e},[P.openApiData?.paths,ke]),Fe=async e=>{let n;try{n=z()}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}let r;try{r=zkt({result:e,policyList:F.getPolicyListEnforced(),existingOperationIds:new Set(P.operationArray?.map(e=>e.operationId)??[])});for(let e of r.policiesToCreate)F.createPolicy(e)}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}try{let e=P.addOperation(r.operationPath,r.method,r.operation,{avoidConflict:!0});e&&D(e)}catch(e){e instanceof Error&&(N(e.message),pe())}t(`route-added`),t(`mcp-gateway-create-virtual-mcp-submitted`,Bkt(e)),n===`manual`&&_e()},Ie=()=>{Me(e=>e+1),Oe(!0)},Le=e=>{let t=Ekt({operationPath:e.additionalOperationContext.path,operation:e,policyList:F?.getPolicyListEnforced()??[]});t&&(Me(e=>e+1),Ae({initialResult:t,path:e.additionalOperationContext.path,method:e.additionalOperationContext.method,operationId:e.operationId}))},Re=async e=>{let t=ke;if(!t)return;let{initialResult:r,path:i,method:a}=t,o=P.operationArray?.find(e=>e.additionalOperationContext.path===i&&e.additionalOperationContext.method===a);if(!o){Ae(void 0);return}let s;try{s=z()}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}let c=Nkt(e.step1.name),l=z1(e.step1.mcpUrl),u=l?.protectedResourceMetadataUrl??Rkt(e.step1.mcpUrl),d=o[CX]?.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===A4),g=m.find(e=>e.policyType===j4),_=m.find(e=>e.policyType===`remove-headers-inbound`&&M4(e.handler?.options)),v=m.find(e=>e.policyType.startsWith(`upstream-`)),y;if(e.step1.authMode===`user-oauth`){let t={id:c,displayName:e.step1.name,summary:`${e.step1.name} remote MCP server, federated via the gateway.`,...u?{protectedResourceMetadataUrl:u}:{},authMode:`user-oauth`,scopes:l?.scopes??[],clientRegistration:e.step1.clientRegistration};if(h&&F)try{F.updatePolicy(h.name,{...h,handler:{...h.handler,options:t}}),y=h.name}catch(e){if(e instanceof Error){N(e.message),pe();return}}else if(F){y=n3(`mcp-upstream-${c}`,g8(F));try{F.createPolicy({name:y,policyType:A4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpTokenExchangeInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}}}let b;if(e.step1.authMode===`upstream-policy`&&F){let{policyType:t,policyName:n,handler:r}=e.step1;try{v&&v.policyType===t?F.updatePolicy(v.name,{...v,name:n,handler:r}):F.createPolicy({name:n,policyType:t,handler:r}),b=n}catch(e){if(e instanceof Error){N(e.message),pe();return}}}let x;if(e.step2.catalogMode===`curated`){let t=w4(e.step2);if(g&&F)try{F.updatePolicy(g.name,{...g,handler:{...g.handler,options:t}}),x=g.name}catch(e){if(e instanceof Error){N(e.message),pe();return}}else if(F){x=n3(`mcp-filter-${c}`,g8(F));try{F.createPolicy({name:x,policyType:j4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpCapabilityFilterInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}}}let S;if(e.step3.authPolicyChoice===`existing`)S=e.step3.existingPolicyName;else if((e.step3.authPolicyChoice===`new`||e.step3.authPolicyChoice===`new-other`)&&(S=e.step3.newPolicyName,F))try{F.createPolicy({name:S,policyType:e.step3.policyType,handler:e.step3.handler})}catch(e){if(e instanceof Error){N(e.message),pe();return}}let C;if(e.step1.authMode===`none`&&e.step1.noAuthBehavior===`strip`)try{C=_?.name??kLt(F)}catch(e){if(e instanceof Error){N(e.message),pe();return}}let w=[S,x,y,b,C].filter(e=>!!e),T=o[CX],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})`,[CX]:{...T??{},handler:{...E??{export:`McpProxyHandler`,module:`$import(@zuplo/runtime/mcp-gateway)`},options:{...E?.options??{},rewritePattern:e.step1.mcpUrl}},policies:{...T?.policies??{},inbound:w}}}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}let D;try{D=new URL(e.step1.mcpUrl).hostname}catch{D=void 0}n(`mcp-gateway-edit-virtual-mcp-submitted`,{upstreamHost:D,upstreamAuthMode:e.step1.authMode,previousUpstreamAuthMode:r.step1.authMode,inboundAuthChoice:e.step3.authPolicyChoice,previousInboundAuthChoice:r.step3.authPolicyChoice}),Ae(void 0),s===`manual`&&_e()},ze=(0,H.useMemo)(()=>E?B.find(e=>e.operationId===E)||B.find(e=>h?.path===e.additionalOperationContext.path&&h?.method===e.additionalOperationContext.method):void 0,[B,E,h]);(0,H.useEffect)(()=>{ze&&!h&&g({path:ze.additionalOperationContext.path,method:ze.additionalOperationContext.method})},[ze,h]);let Be=(e,n,r)=>{let i=(e,t)=>{let n=e.replace(/-duplicate(-\d+)?$/,``),r=`${n}-duplicate`,i=2;for(;t(r);)r=`${n}-duplicate-${i}`,i++;return r},a=P.operationArray??[],o=i(e,e=>a.some(t=>t.additionalOperationContext.path===e&&t.additionalOperationContext.method===n)),s=i(r.operationId??`op-${Ne().slice(0,4)}`,e=>a.some(t=>t.operationId===e)),c=JSON.parse(JSON.stringify(r));c.operationId=s;try{let e=P.addOperation(o,n,c);e&&D(e)}catch(e){e instanceof Error&&(t(`route-add-failed`,{httpPath:o,httpMethod:n}),N(e.message),pe())}t(`route-added`,{httpPath:o,httpMethod:n,duplicate:!0})},Ve=()=>{f(!0),u(`tags`),c(!0)},He=ke!==void 0,Ue=(0,U.jsx)(Dkt,{isOpen:De||He,existingPaths:Pe,mode:He?`edit`:`create`,initialResult:ke?.initialResult,onClose:()=>{Oe(!1),Ae(void 0)},onFinish:He?Re:Fe},`mcp-wizard-${je}`),We={onAddRest:Se,onAddGraphql:Te,onAddWebSocket:Ee,onAddMcpVirtual:Ie,onAddMcpServer:we,onAddTag:Ve};return P.operationArray?.length===0&&(!V||V.trim().length===0)?(0,U.jsxs)(U.Fragment,{children:[Ue,(0,U.jsx)(Gmt,{...We})]}):(0,U.jsxs)(`div`,{className:`ms-2 grid grid-cols-3 h-full grow`,children:[(0,U.jsx)(f$,{open:oe,onOpenChange:e=>{se(e),e||v(void 0)},onClickDelete:fe,title:`Delete`,deleteButtonText:`Confirm`,children:ce.length===0?`Are you sure you want to delete this operation?`:(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{children:[`The following`,` `,ce.length===1?`policy is`:`policies are`,` `,`used only by this route. Would you like to delete`,` `,ce.length===1?`it`:`them`,` `,`too?`]}),(0,U.jsx)(`ul`,{className:`flex flex-col divide-y divide-border max-h-[40vh] overflow-y-auto rounded-md border bg-surface-sunken`,children:ce.map(e=>{let t=`delete-policy-${e.name}`;return(0,U.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2`,children:[(0,U.jsx)(YJ,{id:t,checked:le.has(e.name),onCheckedChange:t=>de(e.name,t===!0),className:`mt-0.5`}),(0,U.jsxs)(`label`,{htmlFor:t,className:`flex flex-col gap-0.5 text-left cursor-pointer min-w-0`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.name}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e.policyType})]})]},e.name)})})]})}),(0,U.jsx)(_Lt,{}),Ue,be&&(0,U.jsx)(Wkt,{open:s,onOpenChange:c,info:be,onSave:p,defaultTab:l,tagsAutoCreate:d,onTagsAutoCreateConsumed:()=>f(!1)}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 justify-start h-full pt-2 min-h-0`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between gap-x-2`,children:[(0,U.jsx)(`div`,{className:`flex gap-1`,children:(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{className:`flex group select-none`,asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,title:`Filter and sort routes`,children:[(0,U.jsx)(Gd,{size:16}),`Filter`]})}),(0,U.jsxs)(XG,{className:`min-w-[220px]`,align:`start`,children:[(0,U.jsx)(nK,{children:`Sort by`}),(0,U.jsx)(ZG,{children:TLt.map(e=>(0,U.jsxs)(QG,{onClick:()=>j(e),className:`justify-between`,children:[e,(0,U.jsx)(ed,{className:W(`mr-2`,e!==A&&`invisible`),size:16})]},e))}),(0,U.jsx)(rK,{}),(0,U.jsx)(nK,{children:`Filter by tag`}),(0,U.jsx)(ZG,{className:`max-h-60 overflow-y-auto`,children:xe?.map(e=>(0,U.jsxs)(QG,{onClick:t=>{t.stopPropagation(),t.preventDefault(),r.includes(e.value)?i(r.filter(t=>t!==e.value)):i([...r,e.value])},className:`justify-between`,children:[e.label,(0,U.jsx)(ed,{className:W(`mr-2`,!r.includes(e.value)&&`invisible`),size:18})]},e.label))}),(0,U.jsx)(rK,{}),(0,U.jsx)(nK,{children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Cee,{size:16}),`Group by`]})}),(0,U.jsx)(ZG,{children:ELt.map(e=>(0,U.jsxs)(QG,{onClick:t=>{t.stopPropagation(),t.preventDefault(),o(e.value)},className:`justify-between`,children:[e.label,(0,U.jsx)(ed,{className:W(`mr-2`,a!==e.value&&`invisible`),size:16})]},e.value))})]})]})}),T?null:(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>{f(!1),u(`details`),c(!0)},"aria-label":`API Settings`,title:`API Settings`,children:(0,U.jsx)(bf,{size:16})}),(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,"data-test":`add-route-btn`,className:`relative gap-0.5!`,children:[(0,U.jsx)(`div`,{className:`absolute w-1.5 h-1.5 rounded-full -top-0.5 -right-[3px] bg-zuplo-700`}),(0,U.jsx)(Sf,{"aria-hidden":`true`,className:`size-3.5`}),`Add`]})}),(0,U.jsx)(XG,{children:(0,U.jsx)(Wmt,{...We})})]})]})]}),(0,U.jsx)(FJ,{onClearValue:()=>ee(``),value:V,showClearButton:!!V&&V.length>0,children:(0,U.jsx)(iM,{ref:m,value:V,onChange:e=>ee(e.target.value),placeholder:`Search Routes`,className:`px-8`})}),r.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,U.jsxs)(`div`,{className:`group flex items-center gap-1 max-w-full pl-1.5 pr-0.5 py-0.5 rounded-full border border-border bg-card text-xs text-foreground`,children:[(0,U.jsx)(Uf,{size:11,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e} filter`,onClick:t=>{t.stopPropagation(),i(r.filter(t=>t!==e))},className:`shrink-0 size-4 rounded-full flex items-center justify-center text-muted-foreground hover:bg-neutral-200 dark:hover:bg-neutral-700 hover:text-neutral-900 dark:hover:text-foreground`,children:(0,U.jsx)(ep,{size:11})})]},e))}),(0,U.jsx)(`div`,{className:`overflow-y-auto space-y-1`,children:te.map((e,t,n)=>{let r=!e.collapsible||S.has(e.key),i=e.operations.length,o=e.icon,s=(0,U.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-background px-1.5 py-0.5 text-xs font-normal tabular-nums text-muted-foreground`,children:i});return(0,U.jsxs)(`div`,{children:[e.collapsible?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>w(e.key),"aria-expanded":r,className:`mt-3 mb-1 flex w-full items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-left text-sm font-semibold text-foreground transition-colors first:mt-1 hover:bg-muted`,title:r?`Collapse ${e.label}`:`Expand ${e.label} (${i} ${i===1?`route`:`routes`})`,children:[r?(0,U.jsx)(td,{size:15,className:`shrink-0 text-muted-foreground`}):(0,U.jsx)(nd,{size:15,className:`shrink-0 text-muted-foreground`}),o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate font-mono`,title:e.label,children:e.label}),s]}):a!==`none`&&(0,U.jsxs)(`div`,{className:`mt-3 mb-1 flex items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-sm font-semibold text-foreground first:mt-1`,children:[o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:W(`truncate`,e.mono&&`font-mono`),title:e.label,children:e.label}),s]}),r&&e.operations.map(({additionalOperationContext:e,...r})=>{let i=ze?.operationId===r.operationId,o=r[CX]?.handler,s=wX(o),c=TX(o),l=s?o.options?.operations?.length??0:0,u=l>0,d=y.has(r.operationId);return(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(ght,{path:i&&ne?ne:e.path,type:c?`mcp-virtual`:s?`mcp`:`route`,method:e.method,summary:i&&ie?ie:r.summary,operationId:r.operationId,operation:r,isSelected:i,onOperationSelected:t=>{re(``),ae(``),g({path:e.path,method:e.method}),D(t)},onDelete:(e,t,n)=>{v({path:e,method:t,operationId:n}),se(!0)},onAddRoute:Ce,onDuplicate:()=>Be(e.path,e.method,r),onMoveUp:DLt.has(a)?void 0:()=>ye(e.path,`up`),onMoveDown:DLt.has(a)?void 0:()=>ye(e.path,`down`),isFirstPath:A===m8&&t===0,isLastPath:A===m8&&t===n.length-1,isToolsExpanded:u?d:void 0,onToggleTools:u?()=>x(r.operationId):void 0,toolsCount:u?l:void 0}),o&&u&&d&&(0,U.jsx)(Rht,{handler:o,operation:{...r,additionalOperationContext:e}})]},r.operationId)})]},e.key)})})]}),(0,U.jsx)(`div`,{className:`col-span-2 flex flex-col h-full overflow-y-auto`,children:(0,U.jsx)(r3.Provider,{value:{setPath:re,setSummary:ae},children:(0,U.jsx)(zht.Provider,{value:Le,children:(0,U.jsx)(fLt,{operationData:ze,addRouteMenuProps:We})})})})]})},NLt={create:{shell:`bg-emerald-500/8 shadow-emerald-950/5`,icon:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`,count:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`},update:{shell:`bg-brand/8 shadow-brand/5`,icon:`bg-brand/12 text-brand`,count:`bg-brand/12 text-brand`},keep:{shell:`bg-background shadow-black/5 dark:shadow-white/5`,icon:`bg-muted text-muted-foreground`,count:`bg-muted text-muted-foreground`}},_8=({icon:e,operations:t,title:n,tone:r})=>{let i=NLt[r];return(0,U.jsxs)(`section`,{className:`rounded-2xl p-4 shadow-sm ${i.shell}`,"aria-label":`${n} operations`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 font-semibold text-foreground`,children:[(0,U.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-xl ${i.icon}`,children:e}),n,` operations`]}),(0,U.jsx)(`div`,{className:`rounded-full px-2.5 py-1 text-xs font-medium tabular-nums ${i.count}`,children:t.size})]}),(0,U.jsx)(`div`,{className:`space-y-1.5`,children:Array.from(t).map(e=>{let t=e.split(`>`),n=t[0],r=t.slice(1,t.length).join(`>`);return(0,U.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 rounded-xl bg-background/80 px-3 py-2 text-sm shadow-xs`,children:[(0,U.jsx)(RJ,{className:`w-14`,method:n}),(0,U.jsx)(`span`,{className:`break-all text-foreground/90`,children:r})]},e)})})]})},PLt=({openApiFileModel:e,onOpenApiFileSynced:t,setIsOpen:n})=>{let[r,i]=(0,H.useState)(),a=pp(),o=e=>{i(e)},s=async()=>{if(!r)throw Error(`No file selected`);let i=e.content?JSON.parse(e.content):null;t(i?Got(i,r.content):r.content),n(!1),a.success(`OpenAPI file merged successfully`,{icon:(0,U.jsx)(Hpe,{className:`h-4 w-4`})})};if(r){let t=Xot(JSON.parse(e.content??`{}`),r.content);return(0,U.jsx)($$,{isOpen:!0,setIsOpen:n,title:`Review OpenAPI import`,className:`sm:max-w-4xl max-h-[88vh] overflow-y-auto`,icon:(0,U.jsx)(my,{className:`shrink-0 h-6 w-6 text-brand`}),iconStyle:`bg-zuplo-pink/10`,buttons:[{onButtonClick:()=>{n(!1)},variant:`outline`,buttonContent:`Cancel`,id:`Close merge open-api modal`,testID:`merge-cancel-btn`},{onButtonClick:s,variant:`brand`,buttonContent:`Import changes`,id:`Complete open-api merge`,testID:`complete-merge-btn`}],bodyComponent:(0,U.jsxs)(`div`,{className:`mt-6 text-left text-sm`,children:[(0,U.jsx)(`div`,{className:`overflow-hidden rounded-3xl bg-gradient-to-br from-brand/12 via-background to-background p-px shadow-lg shadow-brand/5`,children:(0,U.jsxs)(`div`,{className:`rounded-[calc(1.5rem-1px)] bg-background p-5`,children:[(0,U.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[1fr_auto_1fr] md:items-center`,children:[(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-brand/10 text-brand`,children:(0,U.jsx)(pme,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Import file`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:r.name})]})]})}),(0,U.jsx)(`div`,{className:`hidden h-10 w-10 items-center justify-center rounded-full bg-brand text-brand-foreground shadow-sm shadow-brand/24 md:flex`,children:(0,U.jsx)(my,{className:`h-5 w-5`})}),(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,children:(0,U.jsx)(by,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Current API`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:e.path})]})]})})]}),(0,U.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2 text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:`Operations are matched by`}),(0,U.jsx)(XD,{variant:`outline`,children:`Path + method`}),(0,U.jsx)(`span`,{children:`so existing Zuplo extensions and policies stay in place.`})]})]})}),(0,U.jsxs)(`div`,{className:`mt-6 flex items-end justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:`Import summary`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Review what will change before applying this file.`})]}),(0,U.jsxs)(`div`,{className:`rounded-full bg-surface-sunken px-3 py-1 text-xs font-medium text-muted-foreground tabular-nums`,children:[t.created.size+t.merged.size+t.retained.size,` `,`operations`]})]}),(0,U.jsxs)(`div`,{className:`mt-3 grid max-h-96 gap-3 overflow-y-auto rounded-3xl bg-surface-sunken p-3 shadow-[inset_0_1px_rgba(255,255,255,0.04)]`,children:[t.created.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(Nme,{className:`h-4 w-4`}),title:`Create`,tone:`create`,operations:t.created}):null,t.merged.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(Ame,{className:`h-4 w-4`}),title:`Update`,tone:`update`,operations:t.merged}):null,t.retained.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(Upe,{className:`h-4 w-4`}),title:`Keep`,tone:`keep`,operations:t.retained}):null]})]})})}return(0,U.jsx)(Rmt,{title:`Import OpenAPI`,onValidFileSelected:o,setIsOpen:n})},FLt=()=>{let e=Dt(),t=je({mutationFn:t=>e.fetch(tn.users.updatePreferences(t))}),{data:n}=fb(mt.user.preferences());return{preferences:n,updatePreferences:t.mutate,updatePreferencesMutation:t}},ILt=!1;function v8(){let e=at(),{preferences:t,updatePreferencesMutation:n}=FLt();return{isFileTreeOpen:t.fileTreeOpen??ILt,setIsFileTreeOpen:r=>{let i=[mt.user.preferences().url,!0],a=e.getQueryData(i),o={...a??t,fileTreeOpen:r};e.setQueryData(i,o),n.mutate(o,{onError:()=>{a&&e.setQueryData(i,a),e.invalidateQueries({queryKey:i})}})}}}function LLt(){let e=VZ(),{logEvent:t}=on(),[n,r]=wJ(`v`,`designer`),{isFileTreeOpen:i}=v8(),a=e?.path.split(`/`).pop()??`JSON`,o=HZ(),s=Bmt(),[c,l]=h$(()=>{if(!e)throw Error(`File model not found`);return t(`merge-open-api`),(0,U.jsx)(PLt,{openApiFileModel:e,onOpenApiFileSynced:n=>{let r={...e,content:JSON.stringify(n,null,2)};o(r,!0),t(`merge-open-api-complete`),s(r.path)},setIsOpen:l})},[e,s]);return(0,U.jsx)(bht,{children:(0,U.jsx)(_mt,{children:(0,U.jsxs)(AO,{defaultValue:`designer`,value:n,onValueChange:e=>r(e),className:`flex flex-col h-full w-full max-h-screen min-w-[850px]`,children:[i&&(0,U.jsxs)(jO,{className:`rounded-none border-b w-full justify-start`,children:[(0,U.jsx)(MO,{value:`designer`,children:`Route Designer`}),(0,U.jsx)(MO,{value:`raw`,children:a??`Raw`}),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,onClick:c,className:`ml-4`,children:[(0,U.jsx)(Vme,{className:`w-4 h-4`}),` Import`]})]}),(0,U.jsx)(NO,{value:`designer`,className:`grow h-full overflow-y-auto`,children:(0,U.jsx)(Tmt,{onNavigateToOpenApiFileTab:()=>r(`raw`),children:(0,U.jsx)(MLt,{onNavigateToOpenApiFileTab:()=>r(`raw`)})})}),(0,U.jsx)(NO,{value:`raw`,className:`grow h-full overflow-y-auto`,forceMount:!0,children:(0,U.jsx)(eQ,{})})]})})})}function RLt({title:e,description:t,folder:n,icon:r,emptyText:i,newLabel:a,onCreate:o}){let s=Cp(e=>e.projectTreeNodes),[c,l]=As(),{isReadOnly:u}=wZ(),d=n.endsWith(`/`)?n:`${n}/`,f=(0,H.useMemo)(()=>s.filter(e=>e.type===Vs.File&&e.path.startsWith(d)).sort((e,t)=>e.path.localeCompare(t.path)),[s,d]),p=e=>{let t=new URLSearchParams(c);t.set(`path`,e),t.delete(`v`),t.delete(`line`),l(t)};return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:e}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:t})]}),!u&&(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,onClick:o,className:`shrink-0`,children:[(0,U.jsx)(Sf,{className:`size-4`}),a]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:f.length===0?(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:i}):f.map(e=>{let t=e.path.slice(d.length);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:W(`group flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors`,`bg-surface hover:border-brand/40 hover:bg-brand/5`,`ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`),children:[(0,U.jsx)(r,{className:`size-4 shrink-0 text-neutral-500 group-hover:text-brand`}),(0,U.jsx)(`span`,{className:`truncate text-sm font-medium text-neutral-800 dark:text-neutral-200`,children:t})]},e.path)})})]})})}function zLt(){let e=Cp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=v8();return(0,U.jsx)(RLt,{title:`Custom Modules`,description:`TypeScript modules in your project's modules/ folder — request handlers, policies, and other custom code.`,folder:`/modules`,icon:gf,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 BLt(){let e=Cp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=v8();return(0,U.jsx)(RLt,{title:`Schemas`,description:`JSON schemas in your project's schemas/ folder, used to validate requests and responses.`,folder:`/schemas`,icon:Fd,emptyText:`No schemas yet. Create one to validate request or response bodies.`,newLabel:`New Schema`,onCreate:()=>{t(!0),e({strategyFolder:`/schemas`,template:`Schema`})}})}var VLt=()=>{let[e,t]=(0,H.useState)(),{isReadOnly:n}=wZ(),r=u1(),i=r.policiesUsageInfo,{logEvent:a}=on(),o=hp([`account`,`project`,`environment`]),[s,c]=h$(()=>e?(0,U.jsx)(gNt,{isOpen:!0,setIsOpen:c,stackType:e,shouldHideExistingPolicies:!0,policyManager:r}):null,[e]),l=e=>{t(e),a(`create-policy-clicked`,{account:o.account.name,project:o.project.name,environment:o.environment.name,type:e}),s()},u=(r.policyList??[]).flatMap(e=>i?.find(t=>t.name===e.name)??[]);return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:`Policies`}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:`Reusable policies from your project's config/policies.json — apply them to routes to inspect and control requests and responses.`})]}),!n&&(0,U.jsxs)(JG,{modal:!1,children:[(0,U.jsx)(YG,{asChild:!0,children:(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,className:`shrink-0`,children:[(0,U.jsx)(Sf,{className:`size-4`}),`New Policy`]})}),(0,U.jsxs)(XG,{align:`end`,children:[(0,U.jsxs)(QG,{onClick:()=>l(`inbound`),children:[(0,U.jsx)(Lu,{className:`mr-2 size-4`}),`Inbound Policy`]}),(0,U.jsxs)(QG,{onClick:()=>l(`outbound`),children:[(0,U.jsx)(Vu,{className:`mr-2 size-4`}),`Outbound Policy`]})]})]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:u.length===0?(0,U.jsxs)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:[`No policies yet. Create an inbound or outbound policy to inspect and control requests and responses, or`,` `,(0,U.jsx)(kT,{href:`https://zuplo.com/docs/overview/policies`,children:`read the docs`}),`.`]}):u.map(e=>(0,U.jsx)(lNt,{policy:e},e.name))})]})})},HLt=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={}))})),ULt=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={}))})),WLt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),GLt=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`})),KLt=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})),qLt=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})),JLt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isValidProjectName=e.MAX_PRETTY_BRANCH_LENGTH=e.MAX_HASH_LENGTH=void 0;var t=qLt();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})),YLt=i({$defs:()=>w8,$id:()=>b8,$schema:()=>y8,additionalProperties:()=>!1,default:()=>XLt,description:()=>``,properties:()=>T8,required:()=>C8,title:()=>x8,type:()=>S8}),y8,b8,x8,S8,C8,w8,T8,XLt,ZLt=n((()=>{y8=`https://json-schema.org/draft/2020-12/schema`,b8=`http://schemas.zuplo.com/route.json`,x8=`Route Config File`,S8=`object`,C8=[`routes`,`versions`],w8={corsPolicy:{type:`string`,pattern:`^[0-9a-z-]+$`},httpMethod:{type:`string`,enum:[`GET`,`HEAD`,`POST`,`PUT`,`DELETE`,`CONNECT`,`OPTIONS`,`TRACE`,`PATCH`]},handlerDefinition:{type:`object`,properties:{module:{type:`string`,pattern:`^\\$import\\([^ )]*?\\)$`},export:{type:`string`},options:{type:`object`,additionalProperties:!0}},additionalProperties:!1,required:[`module`,`export`]},schema:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:[`object`,`boolean`]},parameterBaseObject:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:`object`,properties:{description:{type:`string`},required:{default:!1,type:`boolean`},deprecated:{default:!1,type:`boolean`},schema:{$ref:`#/$defs/schema`}},required:[`schema`]},parameterDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#parameter-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,properties:{name:{type:`string`},in:{type:`string`,enum:[`query`,`header`,`path`,`cookie`]}},required:[`name`,`in`,`schema`],if:{type:`object`,properties:{in:{const:`query`}},required:[`in`]},then:{type:`object`,properties:{allowEmptyValue:{default:!1,type:`boolean`}}}},"media-type":{$comment:`https://spec.openapis.org/oas/v3.1.0#media-type-object`,type:`object`,properties:{schema:{$ref:`#/$defs/schema`}},unevaluatedProperties:!1},content:{$comment:`https://spec.openapis.org/oas/v3.1.0#fixed-fields-10`,type:`object`,additionalProperties:{$ref:`#/$defs/media-type`},propertyNames:{enum:[`application/json`,`application/problem+json`]}},header:{$comment:`https://spec.openapis.org/oas/v3.1.0#header-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,required:[`schema`]},response:{$comment:`https://spec.openapis.org/oas/v3.1.0#response-object`,type:`object`,properties:{description:{type:`string`},headers:{type:`object`,additionalProperties:{$ref:`#/$defs/header`}},content:{$ref:`#/$defs/content`}},required:[`description`],unevaluatedProperties:!1},responsesDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#responses-object`,type:`object`,properties:{default:{$ref:`#/$defs/response`}},patternProperties:{"^[1-5](?:[0-9]{2}|XX)$":{$ref:`#/$defs/response`}},minProperties:1,unevaluatedProperties:!1},tag:{$comment:`https://spec.openapis.org/oas/v3.1.0#tag-object`,type:`object`,properties:{name:{type:`string`},description:{type:`string`}},required:[`name`],unevaluatedProperties:!1},info:{type:`object`,required:[`title`,`version`],properties:{title:{type:`string`},summary:{type:`string`},description:{type:`string`},termsOfService:{type:`string`,format:`uri`},version:{type:`string`}}},versionData:{type:`object`,required:[`name`,`pathPrefix`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},pathPrefix:{type:`string`,pattern:`(^$|^/[^\\s]*$)`},info:{$ref:`#/$defs/info`},openApiFile:{description:`The project relative path to the OpenAPI spec.`,type:`string`},tags:{type:`array`,items:{$ref:`#/$defs/tag`}},excludeFromOpenApi:{type:`boolean`,description:`If false, OpenAPI documentation will not be generated for this version. If openApiFile is set this setting is ignored.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`}}},routeConfiguration:{type:`object`,required:[`path`,`methods`,`handler`,`version`],additionalProperties:!1,properties:{operationId:{type:`string`},path:{type:`string`,pattern:`^/[^\\s]*$`},methods:{type:`array`,items:{$ref:`#/$defs/httpMethod`}},label:{type:`string`,description:`An internal user-friendly identifier of the route.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`},key:{type:`string`,deprecated:!0},handler:{$ref:`#/$defs/handlerDefinition`},corsPolicy:{$ref:`#/$defs/corsPolicy`},custom:{},version:{type:`string`,pattern:`^[0-9a-z-]+$`},policies:{type:`object`,additionalProperties:!1,properties:{inbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}},outbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}}}},summary:{type:`string`},description:{type:`string`},parameters:{type:`array`,items:{$ref:`#/$defs/parameterDefinition`}},excludeFromOpenApi:{type:`boolean`},responses:{$ref:`#/$defs/responsesDefinition`},tags:{type:`array`,items:{type:`string`}}}},policyConfiguration:{type:`object`,required:[`name`,`policyType`,`handler`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},policyType:{type:`string`},handler:{$ref:`#/$defs/handlerDefinition`},options:{type:`object`,additionalProperties:!0}}},corsPolicyConfiguration:{type:`object`,required:[`name`,`allowedOrigins`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},allowCredentials:{type:`boolean`},maxAge:{type:`number`},allowedOrigins:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},allowedMethods:{oneOf:[{type:`array`,items:{$ref:`#/$defs/httpMethod`}},{type:`string`}]},allowedHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},exposeHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]}}}},T8={$schema:{type:`string`},info:{$ref:`#/$defs/info`,deprecated:!0},versions:{type:`array`,minItems:1,items:{$ref:`#/$defs/versionData`}},routes:{type:`array`,minItems:0,items:{$ref:`#/$defs/routeConfiguration`}},policies:{type:`array`,items:{$ref:`#/$defs/policyConfiguration`}},corsPolicies:{type:`array`,items:{$ref:`#/$defs/corsPolicyConfiguration`}},requestErrorHandler:{$ref:`#/$defs/handlerDefinition`}},XLt={$schema:y8,$id:b8,title:x8,description:``,type:S8,additionalProperties:!1,required:C8,$defs:w8,properties:T8}})),QLt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c,l),"date-time":t(d,f),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:h,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:w,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:_,int32:{type:`number`,validate:b},int64:{type:`number`,validate:x},float:{type:`number`,validate:S},double:{type:`number`,validate:S},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,f),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function c(e,t){let n=s.exec(e);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[5];return(r<=23&&i<=59&&a<=59||r===23&&i===59&&a===60)&&(!t||o!==``)}function l(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3]+(n[4]||``),t=r[1]+r[2]+r[3]+(r[4]||``),e>t?1:e<t?-1:0}var u=/t|\s/i;function d(e){let t=e.split(u);return t.length===2&&a(t[0])&&c(t[1],!0)}function f(e,t){if(!(e&&t))return;let[n,r]=e.split(u),[i,a]=t.split(u),s=o(n,i);if(s!==void 0)return s||l(r,a)}var p=/\/|:/,m=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function h(e){return p.test(e)&&m.test(e)}var g=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function _(e){return g.lastIndex=0,g.test(e)}var v=-(2**31),y=2**31-1;function b(e){return Number.isInteger(e)&&e<=y&&e>=v}function x(e){return Number.isInteger(e)}function S(){return!0}var C=/[^\\]\\Z/;function w(e){if(C.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),E8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),$Lt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=E8(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r=e.UsedValueState||={}),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),D8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=E8(),n=$Lt(),r=E8();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=$Lt();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?`
1562
+ `}var d8=`/docs/schema.graphql`,KIt=()=>JSON.stringify({query:DIt()}),qIt=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`${kIt(OIt(t.data))}\n`}catch(e){throw Error(`Could not build a schema from the introspection result: ${e instanceof Error?e.message:String(e)}`)}},JIt=({endpointUrl:e,rewriteUrl:t,ape:n,onClose:r})=>{let{logEvent:i}=on(),a=pp(),o=LZ(),s=oP(),[c,l]=(0,H.useState)(t??e),[u,d]=(0,H.useState)([{key:``,value:``}]),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(),g=(e,t,n)=>{d(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},_=()=>d(e=>[...e,{key:``,value:``}]),v=e=>d(t=>t.filter((t,n)=>n!==e)),y=async()=>{h(void 0),p(!0);let l=c===t?`handler`:c===e?`gateway`:`custom`,d={account:n.account.name,project:n.project.name,environment:n.environment.name,endpointMode:l};i(`graphql-schema-introspection-run`,d);let f=`request`,m;try{let e;try{f=`invalid_url`,e=new URL(c)}catch{throw Error(`Enter a valid endpoint URL, including the protocol (e.g. https://).`)}let t={"content-type":`application/json`};for(let{key:e,value:n}of u){let r=e.trim();r.length>0&&(t[r]=n)}f=`request`;let l=await(await s({environmentName:n.environment.name,testRequest:{description:`GraphQL introspection`,pathname:`${e.pathname}${e.search}`,method:`POST`,headers:t,body:KIt()},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=qIt(l.body);f=`save`,await o.mutateAsync({file:{path:d8,content:p},accountName:n.account.name,projectName:n.project.name,environmentName:n.environment.name}),i(`graphql-schema-introspection-success`,{...d,upstreamStatus:m}),a.success(`Schema saved to ${d8}`),r()}catch(e){let t=e instanceof Error?e.message:String(e);i(`graphql-schema-introspection-failed`,{...d,stage:f,upstreamStatus:m,reason:t}),h(t)}finally{p(!1)}};return(0,U.jsx)(tb,{open:!0,onOpenChange:e=>!e&&!f&&r(),children:(0,U.jsxs)(ib,{className:`sm:max-w-2xl`,children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Download GraphQL schema`}),(0,U.jsxs)(cb,{children:[`Run an introspection query against this endpoint. On success the schema is stored in `,(0,U.jsx)(`code`,{children:d8}),`.`]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(dY,{htmlFor:`graphql-introspection-endpoint`,children:`Endpoint`}),e&&e!==c&&(0,U.jsx)(X,{variant:`link`,size:`xs`,type:`button`,className:`h-auto p-0`,disabled:f,onClick:()=>l(e),children:`Use gateway URL`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(iM,{id:`graphql-introspection-endpoint`,value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com/graphql`,disabled:f,"data-op-ignore":!0}),(0,U.jsx)(sM,{textToCopy:c})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(dY,{children:`Headers (optional)`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(iM,{placeholder:`Header name`,value:e.key,onChange:e=>g(t,`key`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(iM,{placeholder:`Value`,value:e.value,onChange:e=>g(t,`value`,e.target.value),"data-op-ignore":!0}),(0,U.jsx)(X,{variant:`ghost`,size:`icon`,type:`button`,"aria-label":`Remove header`,onClick:()=>v(t),children:(0,U.jsx)(Kf,{className:`size-4`})})]},t))}),(0,U.jsx)(`div`,{children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,type:`button`,onClick:_,children:[(0,U.jsx)(Sf,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Add header`})]})})]}),m&&(0,U.jsxs)(Vy,{variant:`destructive`,children:[(0,U.jsx)(od,{}),(0,U.jsx)(Hy,{children:`Introspection failed`}),(0,U.jsx)(Uy,{className:`break-words`,children:m})]})]}),(0,U.jsxs)(ob,{children:[(0,U.jsx)(rb,{asChild:!0,children:(0,U.jsx)(X,{variant:`outline`,type:`button`,disabled:f,children:`Cancel`})}),(0,U.jsx)(X,{variant:`brand`,type:`button`,onClick:y,disabled:f||c.trim().length===0,children:f?`Running…`:`Run introspection`})]})]})})},YIt=({path:e,rewriteUrl:t})=>{let n=hp(),r=Xa(),{logEvent:i}=on(),[a,o]=(0,H.useState)(!1),s=sP(n.environment),c=s?new URL(e,s).toString():void 0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,children:[(0,U.jsx)(o1,{className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{children:`Schema`}),(0,U.jsx)(td,{className:`size-4 shrink-0`})]})}),(0,U.jsxs)(XG,{align:`end`,children:[(0,U.jsxs)(QG,{onSelect:()=>{i(`graphql-schema-open`,{account:n.account.name,project:n.project.name,environment:n.environment.name}),r({pathname:Zr(mb.Code,{account:n.account.name,project:n.project.name,environment:encodeURIComponent(n.environment.urlParameter)}),search:`?path=${d8}`})},children:[(0,U.jsx)(Rd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Open Schema`})]}),(0,U.jsxs)(QG,{disabled:!c,onSelect:()=>o(!0),children:[(0,U.jsx)(Dd,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Download Schema`})]})]})]}),a&&c&&(0,U.jsx)(JIt,{endpointUrl:c,rewriteUrl:t,ape:n,onClose:()=>o(!1)})]})},XIt=({operationTags:e,onTagsChanged:t})=>{let{isReadOnly:n}=wZ(),r=Y$(),[i,a]=(0,H.useState)(``),o=r.openApiData?.tags?.map(e=>e.name)??[],s=n=>{e.includes(n)?t(e.filter(e=>e!==n)):t([...e,n])},c=()=>{let n=i.trim();if(n){if(!o.includes(n))try{r.addTag(n)}catch{}e.includes(n)||t([...e,n]),a(``)}};return(0,U.jsxs)(dT,{children:[(0,U.jsx)(fT,{asChild:!0,children:(0,U.jsxs)(l6,{children:[(0,U.jsx)(Uf,{size:16}),e.length===1?(0,U.jsx)(`span`,{className:`truncate max-w-[12ch]`,title:e[0],children:e[0]}):`${e.length} Tags`]})}),(0,U.jsxs)(pT,{className:`w-64 p-0 z-100`,align:`end`,children:[(0,U.jsx)(`div`,{className:`px-3 pt-3 pb-2`,children:(0,U.jsx)(`h4`,{className:`text-sm font-medium`,children:`Operation Tags`})}),o.length>0&&(0,U.jsx)(`div`,{className:`border-t max-h-48 overflow-y-auto`,children:o.map(t=>(0,U.jsxs)(`button`,{type:`button`,disabled:n,className:`w-full flex items-center justify-between px-3 py-1.5 text-sm hover:bg-accent disabled:opacity-50 disabled:cursor-default cursor-pointer`,onClick:()=>s(t),children:[(0,U.jsx)(`span`,{className:`truncate`,children:t}),(0,U.jsx)(ed,{size:14,className:W(`shrink-0`,!e.includes(t)&&`invisible`)})]},t))}),!n&&(0,U.jsx)(`div`,{className:`border-t p-2`,children:(0,U.jsxs)(`form`,{className:`flex gap-1`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,U.jsx)(iM,{value:i,onChange:e=>a(e.target.value),placeholder:`New tag...`,className:`h-7 text-xs`}),(0,U.jsx)(X,{type:`submit`,variant:`outline`,size:`icon-sm`,disabled:!i.trim(),children:(0,U.jsx)(Sf,{size:14})})]})})]})]})},ZIt=r(a((e=>{var t=/~/,n=/~[01]/g;function r(e){switch(e){case`~1`:return`/`;case`~0`:return`~`}throw Error(`Invalid tilde escape: `+e)}function i(e){return t.test(e)?e.replace(n,r):e}function a(e){if(typeof e==`string`){if(e=e.split(`/`),e[0]===``)return e;throw Error(`Invalid JSON pointer.`)}else if(Array.isArray(e)){for(let t of e)if(typeof t!=`string`&&typeof t!=`number`)throw Error(`Invalid JSON pointer. Must be of type string or number.`);return e}throw Error(`Invalid JSON pointer.`)}function o(e,t){if(typeof e!=`object`)throw Error(`Invalid input object.`);t=a(t);var n=t.length;if(n===1)return e;for(var r=1;r<n;){if(e=e[i(t[r++])],n===r)return e;if(typeof e!=`object`||!e)return}}e.get=o}))());function f8(e,t){try{return e.startsWith(`#`)?ZIt.get(t,e.replace(`#`,``)):ZIt.get(t,e)}catch(e){console.error(`Error resolving schema reference. Reference may be invalid or referencing an external document.`,e);return}}var QIt=(e,t)=>{let n=e;return!n||`$ref`in n&&(n=f8(n.$ref,t),!n)?``:n.example?n.example:n.examples&&n.examples.length>0?n.examples[0]:n.default?n.default:``},$It=(e,t)=>{if(e.examples&&Object.keys(e.examples).length>0){let n=Object.values(e.examples)[0];if(`$ref`in n){let e=f8(n.$ref,t);if(!e)return``;n=e}return n.value}if(e.example)return e.example;let n=e.schema;return QIt(n,t)},eLt=(e,t)=>{let n=e.requestBody;if(!n)return``;if(`$ref`in n){let e=f8(n.$ref,t);if(!e)return``;n=e}let{content:r}=n;if(!(`application/json`in r))return``;let i=r[`application/json`];if(i.examples&&Object.keys(i.examples).length>0){let e=Object.values(i.examples)[0];if(`$ref`in e){let n=f8(e.$ref,t);if(!n)return``;e=n}return e.value}let a=i.schema;return QIt(a,t)},tLt=JSON.stringify({query:`{ __schema { queryType { name } } }`},null,2),nLt=new aP,rLt=e=>e.additionalOperationContext.method.split(`,`).map(e=>e.toUpperCase()),p8=e=>{let{oasFilePath:t,method:n,path:r}=e.additionalOperationContext;return`${t}::${e.operationId??`${n} ${r}`}`},iLt=({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=rLt(t)[0],i=t[xX]===!0,a=EX(t),o=eLt(t,n),s=nLt.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]:$It(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?KN:i?tLt:l);return s?.test&&s.test.method===r?s.test:{description:t.summary??t.description??``,pathname:t.additionalOperationContext.path,method:r,headers:u,body:d}},[u,d]=(0,H.useState)(n),[f,p]=(0,H.useState)(()=>l(n,r)),[m,h]=(0,H.useState)(o),g=Cp(e=>e.setTestResponse),_=Dp(),v=s??_,y=(0,H.useMemo)(()=>({...v,[n.additionalOperationContext.oasFilePath]:r}),[v,n.additionalOperationContext.oasFilePath,r]),b=(0,H.useMemo)(()=>Object.entries(y).flatMap(([e,t])=>J$(e,t)),[y]),x=(0,H.useMemo)(()=>b.map(e=>({id:p8(e),method:e.additionalOperationContext.method,path:e.additionalOperationContext.path,summary:e.summary,file:e.additionalOperationContext.oasFilePath})),[b]);return(0,H.useEffect)(()=>{g(void 0)},[]),(0,U.jsx)(`div`,{className:`flex h-[650px] max-h-[70vh] flex-col`,children:(0,U.jsx)(rY,{ape:e,apiTest:f,showRebuildWarning:i,allowedMethods:rLt(u),url:`${t}${u.additionalOperationContext.path}`,shouldAllowLocalSaving:!!u.operationId,operationId:u.operationId,path:u.additionalOperationContext.path,onRequestChange:e=>{p(e)},onClose:a,endpoints:x,selectedEndpointId:p8(u),onSelectEndpoint:e=>{if(e===p8(u))return;let t=b.find(t=>p8(t)===e);if(!t)return;let n=y[t.additionalOperationContext.oasFilePath]??r;d(t),p(l(t,n)),g(void 0)},isEndpointPanelOpen:m,onToggleEndpointPanel:()=>h(e=>!e),endpointsLoading:c},p8(u))})},aLt=({envUrl:e,ape:t,operation:n,openApiDocument:r,showRebuildWarning:i,entries:a,onClose:o,defaultEndpointsPanelOpen:s})=>(0,U.jsx)(SJ.Provider,{value:{entries:a},children:(0,U.jsx)(`div`,{className:`w-full text-muted-foreground`,children:(0,U.jsx)(iLt,{openApiDocument:r,ape:t,envUrl:e,showRebuildWarning:i,operation:n,onClose:o,defaultEndpointsPanelOpen:s})})}),oLt=({open:e,onOpenChange:t,onProceed:n})=>{let{saveAndDeploy:r,isPending:i}=ylt();return(0,U.jsx)(tb,{open:e,onOpenChange:t,children:(0,U.jsxs)(ib,{className:`sm:max-w-md`,children:[(0,U.jsxs)(ab,{children:[(0,U.jsx)(sb,{children:`Unsaved changes`}),(0,U.jsx)(cb,{children:`Your unsaved changes will not be reflected when you test this route until you save and deploy them. Save them now, or continue testing the currently deployed version.`})]}),(0,U.jsxs)(ob,{children:[(0,U.jsx)(X,{variant:`ghost`,onClick:n,disabled:i,children:`Continue without saving`}),(0,U.jsx)(X,{variant:`default`,onClick:async()=>{try{await r()}catch{return}n()},disabled:i,children:(0,U.jsx)(rM,{loading:i,children:`Save changes`})})]})]})})},sLt=(0,H.lazy)(()=>gn(()=>import(`./GraphiQLConsole-Ck-5k6YD.js`),__vite__mapDeps([9,1,2,8,10,11,12]))),cLt=({path:e,method:t,summary:n,operationData:r,hasFileChanged:i,isGraphql:a})=>{let{logEvent:o}=on(),s=hp(),c=Y$().getOpenApiDataEnforced(),{entries:l}=(0,H.useContext)(SJ),u=sP(s.environment),[d,f]=(0,H.useState)(null),p=u?new URL(e,u).toString():void 0,m=Iee({mutationKey:ilt})>0,[h,g]=h$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:t.includes(`,`)?t.split(`,`)[0]:t,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:a?`playground`:`default`}),(0,U.jsx)(tb,{open:!0,onOpenChange:e=>!e&&g(),children:(0,U.jsxs)(ib,{showCloseButton:!1,className:`max-w-6xl! w-full gap-0 overflow-hidden p-0`,children:[(0,U.jsx)(sb,{className:`sr-only`,children:`Test route`}),(0,U.jsx)(aLt,{envUrl:u??``,showRebuildWarning:i,ape:s,entries:l,operation:r,openApiDocument:c,onClose:g})]})})),[e,t,n,r,l,a]),[_,v]=h$(()=>(o(`test-route-clicked`,{httpPath:e,httpMethod:`POST`,account:s.account.name,project:s.project.name,environment:s.environment.name,mode:`graphiql`}),(0,U.jsx)(tb,{open:!0,onOpenChange:e=>!e&&v(),children:(0,U.jsxs)(ib,{className:`max-w-6xl! w-full p-0 overflow-hidden`,children:[(0,U.jsx)(sb,{className:`sr-only`,children:`GraphiQL`}),(0,U.jsx)(`div`,{className:`h-[80vh] w-full`,children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:`Loading GraphiQL…`}),children:(0,U.jsx)(sLt,{url:p??``,ape:s})})})]})})),[p,s]),y=e=>{e===`graphiql`?_():h()},b=e=>{if(i){f(e);return}y(e)},x=(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{children:`Saving`}),(0,U.jsx)(nM,{color:`current`})]}),S=m?`Saving`:`Test Route`;return(0,U.jsxs)(U.Fragment,{children:[a?(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{asChild:!0,children:(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":S,children:(0,U.jsxs)(rM,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(tp,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`}),(0,U.jsx)(td,{className:`size-4 shrink-0`})]})})}),(0,U.jsxs)(XG,{align:`end`,children:[(0,U.jsxs)(QG,{onSelect:()=>b(`playground`),children:[(0,U.jsx)(tp,{className:`size-4`}),(0,U.jsx)(`span`,{children:`Playground`})]}),(0,U.jsxs)(QG,{disabled:!p,onSelect:()=>b(`graphiql`),children:[(0,U.jsx)(o1,{className:`size-4`}),(0,U.jsx)(`span`,{children:`GraphiQL`})]})]})]}):(0,U.jsx)(X,{variant:`brand`,disabled:m,"aria-label":S,onClick:()=>b(`playground`),children:(0,U.jsxs)(rM,{loading:m,className:`flex items-center gap-2`,alternative:x,children:[(0,U.jsx)(tp,{className:`shrink-0 fill-current`}),(0,U.jsx)(`span`,{children:`Test Route`})]})}),(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(oLt,{open:d!==null,onOpenChange:e=>{e||f(null)},onProceed:()=>{let e=d;f(null),e&&y(e)}})})]})},lLt=({onRequestHandlerChange:e,isReadOnly:t,routeHandler:n})=>{let r=c1(n),i=(t,i)=>{e({...n,options:{...r.options,[t]:i}})};return(0,U.jsxs)(ZD,{className:`p-4 bg-surface-sunken`,children:[(0,U.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-base font-medium`,children:`MCP Server Options`}),(0,U.jsx)(kT,{showIcon:!0,href:`https://docs.zuplo.com/handlers/mcp-server`,className:`text-sm text-zuplo-pink`,children:`MCP Server Docs`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-12 gap-4 col-span-full items-center`,children:[(0,U.jsx)(`div`,{className:`col-span-8`,children:(0,U.jsx)(s6,{isReadOnly:t,label:`Server Name`,onChange:e=>i(`name`,e.target.value),className:`col-span-8`,value:typeof r.options.name==`string`?r.options.name:`My MCP Server`})}),(0,U.jsx)(`div`,{className:`col-span-4`,children:(0,U.jsx)(s6,{isReadOnly:t,label:`Server Version`,className:`col-span-4`,onChange:e=>i(`version`,e.target.value),value:typeof r.options.version==`string`?r.options.version:`v0.0.1`})}),(0,U.jsxs)(`div`,{className:`col-span-12 mt-2`,children:[(0,U.jsx)(dY,{className:`text-sm mb-2 block`,children:`Advanced Options`}),(0,U.jsx)(`div`,{className:W(`flex gap-4`,t&&`opacity-50`),children:(0,U.jsxs)(`label`,{className:`text-sm flex items-center gap-2`,children:[(0,U.jsx)(YJ,{"data-test":`mcp-debug-mode`,checked:!!r.options.debugMode,onCheckedChange:e=>{i(`debugMode`,e)},disabled:t}),`Debug Mode`]})})]})]})]})},uLt=({routeHandler:e,operation:t,isReadOnly:n,onRequestHandlerChange:r})=>{let{captureRaw:i}=on(),a=Bht(),o=c1(e),s=typeof o.options.rewritePattern==`string`?o.options.rewritePattern:``,c=ENt(()=>{i(`mcp-gateway-upstream-url-edited`)});return(0,U.jsx)(ZD,{className:`p-4`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground font-medium`,children:`Upstream MCP server`}),!!(a&&t)&&(0,U.jsxs)(X,{type:`button`,variant:`default`,size:`sm`,disabled:n,onClick:()=>{!t||!a||(i(`mcp-gateway-edit-virtual-mcp-opened`),a(t))},className:`shrink-0`,children:[(0,U.jsx)(Nf,{className:`w-3.5 h-3.5`}),`Edit MCP Server Policy`]})]}),(0,U.jsx)(Y4,{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 dLt(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 fLt({operationData:e,addRouteMenuProps:t}){return e?(0,U.jsx)(`div`,{className:`w-full h-full min-h-0 overflow-y-auto px-4 pt-2 pb-4`,children:(0,U.jsx)(mLt,{operationData:e})}):(0,U.jsx)(Gmt,{...t})}var pLt=()=>{let e=Ep(),t=Dp(),n=(0,H.useMemo)(()=>e.flatMap(e=>{let n=t[e.path];return n?J$(e.path,n).filter(e=>EX(e)).map(t=>[e,t]):[]}),[e,t]);return{getLinkedMcpServers:(e,t)=>n.filter(([,n])=>{let r=n[CX]?.handler;return wX(r)?r.options?.operations?.some(n=>a1(n.file)===e&&n.id===t):!1})}},mLt=({operationData:e})=>{let[t]=wJ(`path`);if(!t)throw Error(`Open API file path not found in URL`);let n=vlt(t),r=hp(),{logEvent:i}=on(),{additionalOperationContext:a,...o}=e,{path:s,method:c}=a,l=Y$(),u=pp(),d=u1(),{isReadOnly:f}=wZ(),[p,m]=(0,H.useState)(),[h,g]=(0,H.useState)();pLt();let _=l.openApiData?.servers?.at(0)?.url,v=o[CX]??Z$(_??`https://echo.zuplo.io`),y=o[bX]===!0,b=o.deprecated===!0,x=o[xX]===!0,S=l.openApiFileModel.saveState!==Hs.unmodified,C=v.handler,w=wX(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,[CX]:{...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,[bX]: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[xX]=!0,kmt(d),n[CX]=Omt(v,!0)):(delete n[xX],o[CX]&&(n[CX]=Omt(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,[CX]: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,[SX]:a}),i(`route-path-mode-changed`,{pathMode:n,fileName:t,account:r.account.name,project:r.project.name,environment:r.environment.name})},L=()=>{n(Hs.modified)};return(0,U.jsxs)(`div`,{className:`mb-4 flex flex-col gap-6`,children:[(0,U.jsxs)(ZD,{className:`bg-neutral-50 dark:bg-transparent`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,U.jsxs)(QD,{children:[(0,U.jsx)($D,{children:`Request Handling`}),(0,U.jsx)(eO,{})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-6`,children:[x&&(0,U.jsx)(YIt,{path:s,rewriteUrl:typeof C.options?.rewritePattern==`string`?C.options?.rewritePattern:void 0}),(0,U.jsx)(wFt,{operationData:e}),(0,U.jsx)(cLt,{path:s,method:c,summary:o.summary??``,operationData:e,hasFileChanged:S,isGraphql:x})]})]}),(0,U.jsxs)(tO,{className:`grid grid-cols-1 xl:grid-cols-[max-content_1fr] gap-y-3 xl:gap-y-2 items-center gap-x-6`,children:[(0,U.jsx)(NFt,{isReadOnly:f,initialPath:s,method:c,onChangeMethod:N,pathMode:e.additionalOperationContext.pathZuploConfig?.pathMode,hasError:p!=null,onPathChange:M,onPathModeChange:I,onFieldModified:L,isMcpToolHandler:wX(C)||TX(C)}),p&&(0,U.jsx)(Vy,{"data-test":`path-error`,className:`col-span-full p-2`,variant:`destructive`,children:(0,U.jsx)(Uy,{children:p})}),w&&(0,U.jsx)(Vy,{className:`col-span-full p-2 py-1`,variant:`destructive`,children:(0,U.jsxs)(Uy,{"data-test":`request-handler-error`,className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{children:w}),(0,U.jsx)(X,{onClick:()=>N(`post`),size:`xs`,variant:`outline`,className:`border-none`,children:`Switch to POST method`})]})}),(0,U.jsx)(Kkt,{isReadOnly:f,initialSummary:o.summary,onSummaryChange:E,onFieldModified:L}),(0,U.jsx)(TFt,{isReadOnly:f,defaultOperationId:e.operationId,openApiManager:l,path:s,method:c,operationData:e})]}),(0,U.jsxs)(nO,{className:`flex flex-wrap gap-2 px-3 py-1.5 bg-card justify-end`,children:[(0,U.jsx)(XIt,{operationTags:o.tags??[],onTagsChanged:F}),(0,U.jsx)(iPt,{isReadOnly:f,selectedCorsPolicy:v.corsPolicy,corsPolicies:d.corsPolicyList??[],onSelectionChanged:P}),!wX(v.handler)&&!TX(v.handler)&&(0,U.jsx)(AFt,{operation:e,defaultValues:dLt(v.mcp),onSubmit:e=>{let t={...v,mcp:e};l.updateOperation({path:s,method:c,newOperationObject:{...o,[CX]:t}})}}),(0,U.jsx)($Pt,{isExcludedFromDocs:y,onVisibilityChanged:O}),(0,U.jsx)(PFt,{isGraphql:x,onGraphqlChanged:A,isDeprecated:b,onDeprecatedChanged:k})]})]}),(0,U.jsx)(yNt,{inboundPolicies:v.policies?.inbound??[],outboundPolicies:v.policies?.outbound??[],operation:e,children:(0,U.jsx)(hLt,{isReadOnly:f,operationData:e,handler:v.handler,firstServerUrl:_,onRequestHandlerChange:T})}),(0,U.jsx)(QPt,{initialDescription:o.description??``,onChange:D,path:s,method:c,oasFilePath:t})]})},hLt=({operationData:e,handler:t,firstServerUrl:n,isReadOnly:r,onRequestHandlerChange:i})=>{let a=(e[CX]??Z$(n??`https://echo.zuplo.io`)).handler;switch(t.export){case`mcpServerHandler`:return(0,U.jsx)(lLt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i});case`McpProxyHandler`:case`McpVirtualServerHandler`:case`mcpVirtualServerHandler`:return(0,U.jsx)(uLt,{routeHandler:a,operation:e,isReadOnly:r,onRequestHandlerChange:i});default:return(0,U.jsx)(ePt,{isReadOnly:r,routeHandler:a,onRequestHandlerChange:i})}},gLt=Ae()(e=>({updateLinkedMcpServers:void 0,setUpdateLinkedMcpServers:t=>e({updateLinkedMcpServers:t})})),_Lt=()=>{let e=p(gLt,e=>e.updateLinkedMcpServers),t=HZ(),n=()=>{gLt.setState({updateLinkedMcpServers:void 0})};return(0,U.jsx)(tb,{open:!!e,onOpenChange:e=>{e||n()},children:(0,U.jsxs)(ib,{children:[(0,U.jsx)(sb,{children:`MCP Server Links`}),(0,U.jsx)(cb,{children:`This operation is linked to MCP servers, if you update the operation id, you need to update the MCP server links as well.`}),(0,U.jsx)(`div`,{className:`flex gap-2 items-center justify-center`,children:e?.linkedMcpServers.map(([,e])=>(0,U.jsx)(XD,{children:e},e))}),(0,U.jsxs)(ob,{children:[(0,U.jsx)(X,{variant:`outline`,onClick:n,children:`Cancel`}),(0,U.jsx)(X,{onClick:()=>{e?.linkedMcpServers.forEach(([n,r])=>{let i=new hmt(n,t),a=i.getOperationById(r);if(!a)return;let o=a[CX];if(!o)return;let s=o.handler;if(wX(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:T$(t,`operationId`,e.newOperationId)})}i.updateOperation({path:a?.additionalOperationContext.path,method:a.additionalOperationContext.method,newOperationObject:T$(a,`${CX}.handler.options.operations`,s.options?.operations?.map(t=>a1(t.file)===n.path?{...t,id:t.id===e.oldOperationId?e.newOperationId:t.id}:t))})}})},children:`Update`})]})]})})},vLt=`$import(@zuplo/runtime)`,yLt=`${vLt}::urlForwardHandler`,bLt=`${vLt}::urlRewriteHandler`,xLt=(e,t)=>{let n=e.options?.[t],r=typeof n==`string`?n.trim():``;return r.length>0?r:void 0},SLt=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)},CLt=e=>{if(e){let t=`${e.module}::${e.export}`,n=t===yLt?xLt(e,`baseUrl`):t===bLt?xLt(e,`rewritePattern`):void 0;if(n){let e=SLt(n);return{key:`target:${e}`,label:e,mono:!0,icon:Yd,collapsible:!0}}}return{...Oht(e),collapsible:!1}};function wLt(){let e=Y$(),{captureRaw:t}=on(),n=hp(),r=zZ();return i=>{e.updateInfo(i),t(`openapi-info-updated`);let{projectTreeNodes:a,filesByPath:o}=Cp.getState(),s=a.map(e=>e.path?o[e.path]:void 0).filter(e=>!!e&&e.saveState===Hs.modified);s.length!==0&&r.mutateAsync({environmentName:n.environment.name,accountName:n.account.name,projectName:n.project.name,files:s}).catch(()=>{})}}var m8=`Document Order`,TLt=[`Document Order`,`Path`,`Summary`],h8=`Untagged`,ELt=[{value:`none`,label:`None`},{value:`path`,label:`Path`},{value:`handler`,label:`Handler type`},{value:`target`,label:`Target`}],DLt=new Set([`handler`,`target`]);function OLt(e){return`${e}-${Ne().split(`-`).at(0)}`}function g8(e){return new Set(e.getPolicyListEnforced().map(e=>e.name))}function kLt(e){if(!e)return;let t=Lkt(e.getPolicyListEnforced());if(t)return t.name;let n=n3(Fkt,g8(e));return e.createPolicy(Ikt(n)),n}var ALt=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}},jLt=e=>t=>{if(e.length===0)return!0;let n=t.tags;return!n||n.length===0?e.includes(h8):n.some(t=>e.includes(t))},MLt=({onNavigateToOpenApiFileTab:e})=>{let{logEvent:t,captureRaw:n}=on(),[r,i]=Jet(`tags`,[]),[a,o]=hT(`open-api-designer-group-by`,`none`);(0,H.useEffect)(()=>{let e=window.localStorage.getItem(`open-api-designer-show-headers`);e!==null&&(e===`true`&&a===`none`&&o(`path`),window.localStorage.removeItem(`open-api-designer-show-headers`))},[a,o]);let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(`details`),[d,f]=(0,H.useState)(!1),p=wLt(),m=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)||(e.preventDefault(),m.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let[h,g]=(0,H.useState)(),[_,v]=(0,H.useState)(),[y,b]=(0,H.useState)(()=>new Set),x=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[S,C]=(0,H.useState)(()=>new Set),w=e=>C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),{isReadOnly:T}=wZ(),[E,D]=wJ(`operation`),[O,k]=hT(`default-sort-routes`,m8),[A,j]=wJ(`sort`,O);(0,H.useEffect)(()=>{A&&k(A)},[k,A]),(0,H.useEffectEvent)(()=>{if(E)try{document.querySelector(`#op-${E}`)?.scrollIntoView()}catch{}});let[M,N]=(0,H.useState)(void 0),P=Y$(),F=u1(),I=uM(),L=UZ(kht),R=WZ(),z=()=>{if(L)return jht(L.content??``)?`ok`:`manual`;let e=Aht,t={path:kht,content:e,type:Vs.File,saveState:Hs.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:Hs.modified}),`ok`},{results:B,setSearchTerm:ee,searchTerm:V}=lht(P.operationArray?.filter(jLt(r)).sort(ALt(A))??[],{keys:[e=>e.additionalOperationContext.path,e=>e.summary??``,e=>e.operationId,e=>e.additionalOperationContext.method]});(0,H.useEffect)(()=>{let e=V?.trim()??``;if(e.length===0)return;let n=setTimeout(()=>{t(`route-search-used`,{view:`routes`,query:e,queryLength:e.length})},600);return()=>clearTimeout(n)},[V,t]);let te=(()=>{let e=new Map;for(let t of B){let n,r,i,o,s;if(a===`handler`||a===`target`){let e=t[CX]?.handler,c=a===`target`?CLt(e):{...Oht(e),collapsible:!1};({key:n,label:r,mono:i,collapsible:o,icon:s}=c)}else n=t.additionalOperationContext.path,r=n,i=!0,o=!1,s=void 0;let c=e.get(n);c?c.operations.push(t):e.set(n,{key:n,label:r,mono:i,icon:s,collapsible:o,operations:[t]})}return[...e.values()]})(),[ne,re]=(0,H.useState)(),[ie,ae]=(0,H.useState)(),[oe,se]=(0,H.useState)(!1),ce=(0,H.useMemo)(()=>{if(!_)return[];let e=(P.operationArray?.find(e=>e.additionalOperationContext.path===_.path&&e.additionalOperationContext.method===_.method))?.[CX]?.policies?.inbound??[];if(e.length===0)return[];let t=new Set;for(let e of F.policyList??[]){if(e.policyType!==`composite-inbound`&&e.policyType!==`composite-outbound`)continue;let n=e.handler.options?.policies;if(n)for(let e of n)t.add(e)}let n=F.policiesUsageInfo??[];return e.map(e=>n.find(t=>t.name===e)).filter(e=>{if(!e||e.operations.length!==1)return!1;let n=e.operations[0];return!(n.additionalOperationContext.path!==_.path||n.additionalOperationContext.method!==_.method||t.has(e.name))})},[_,P.operationArray,F.policyList,F.policiesUsageInfo]),[le,ue]=(0,H.useState)(()=>new Set);(0,H.useEffect)(()=>{ue(_?new Set(ce.map(e=>e.name)):new Set)},[_]);let de=(e,t)=>{ue(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},fe=()=>{if(_==null){se(!1);return}try{for(let e of le)try{F.deletePolicy(e),t(`policy-deleted`,{policy:e})}catch{}P.deleteOperation(_.path,_.method),t(`route-deleted`,_)}catch(e){e instanceof Error&&(t(`route-deletion-failed`,_),N(e.message),pe())}v(void 0),se(!1)},[pe,me]=h$(()=>{let t=()=>{N(void 0),me()};return(0,U.jsx)(tQ,{alertType:`ERROR`,bodyText:M??``,onPrimaryButtonClick:e,onSecondaryButtonClick:t,primaryButtonText:`Edit file directly`,secondaryButtonText:`Cancel`,hideModal:t,title:`Error`})},[M]),[he,ge]=h$(()=>(0,U.jsx)(tQ,{alertType:`CAUTION`,bodyText:`Cannot reorder in this view — view by Document Order to reorganize the order of operations.`,onPrimaryButtonClick:()=>{j(m8),ge()},onSecondaryButtonClick:ge,primaryButtonText:`Switch to Document Order`,secondaryButtonText:`Cancel`,hideModal:ge,title:`Cannot reorder`})),[_e,ve]=h$(()=>(0,U.jsx)(Nht,{open:!0,onOpenChange:e=>{e||ve()}})),ye=(e,t)=>{if(A!==m8){he();return}P.movePathInDocument(e,t)};if(!P.openApiData)throw Error(`Invalid State - no OpenApiData`);let be=P.openApiData.info,xe=P.openApiData.tags?.map(e=>({value:e.name,label:e.name}));xe?.push({value:h8,label:h8});let Se=()=>{let e=n1.OpenAPIV3.HttpMethods.GET,n=P.openApiData?.servers?.at(0)?.url,r=Emt(n??`https://echo.zuplo.io`),i=`/path-${((P.operationArray?.filter(t=>t.additionalOperationContext.path.startsWith(`/path-`)&&t.additionalOperationContext.method===e)?.map(e=>parseInt(e.additionalOperationContext.path.replace(`/path-`,``),10))?.filter(e=>!Number.isNaN(e))?.sort((e,t)=>t-e))?.at(0)??0)+1}`;try{let t=P.addOperation(i,e,r);t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:i,httpMethod:e}),N(n.message),pe())}t(`route-added`)},Ce=(e,n,r)=>{let i=P.openApiData?.servers?.at(0)?.url,a=Emt(i??`https://echo.zuplo.io`),o=r?.[CX],s=a[CX];o&&s&&(o.handler&&(s.handler=JSON.parse(JSON.stringify(o.handler))),o.policies&&(s.policies=JSON.parse(JSON.stringify(o.policies))));try{let t=P.addOperation(e,n,a);t&&D(t)}catch(r){r instanceof Error&&(t(`route-add-failed`,{httpPath:e,httpMethod:n}),N(r.message),pe())}t(`route-added`)},we=()=>{let e=n1.OpenAPIV3.HttpMethods.POST,n=OLt(`mcp`),r=P.addOperation(`/mcp`,e,{summary:`MCP Server`,description:`Default MCP Server`,[CX]:{corsPolicy:`none`,handler:{export:`mcpServerHandler`,module:`$import(@zuplo/runtime)`,options:{operations:[]}},policies:{inbound:[]}},operationId:n},{avoidConflict:!0});r&&D(r),t(`route-added`)},Te=()=>{let e=n1.OpenAPIV3.HttpMethods.POST,n=Amt(`https://rickandmortyapi.com/graphql`);try{kmt(F);let t=P.addOperation(`/graphql`,e,n,{avoidConflict:!0});t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/graphql`,httpMethod:e}),N(n.message),pe())}t(`route-added`)},Ee=()=>{let e=n1.OpenAPIV3.HttpMethods.GET,n=jmt();try{let t=P.addOperation(`/websocket`,e,n,{avoidConflict:!0});t&&D(t)}catch(n){n instanceof Error&&(t(`route-add-failed`,{httpPath:`/websocket`,httpMethod:e}),N(n.message),pe())}t(`route-added`)},[De,Oe]=(0,H.useState)(!1),[ke,Ae]=(0,H.useState)(),[je,Me]=(0,H.useState)(0),Pe=(0,H.useMemo)(()=>{let e=new Set(Object.keys(P.openApiData?.paths??{}));return ke&&e.delete(ke.path),e},[P.openApiData?.paths,ke]),Fe=async e=>{let n;try{n=z()}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}let r;try{r=zkt({result:e,policyList:F.getPolicyListEnforced(),existingOperationIds:new Set(P.operationArray?.map(e=>e.operationId)??[])});for(let e of r.policiesToCreate)F.createPolicy(e)}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}try{let e=P.addOperation(r.operationPath,r.method,r.operation,{avoidConflict:!0});e&&D(e)}catch(e){e instanceof Error&&(N(e.message),pe())}t(`route-added`),t(`mcp-gateway-create-virtual-mcp-submitted`,Bkt(e)),n===`manual`&&_e()},Ie=()=>{Me(e=>e+1),Oe(!0)},Le=e=>{let t=Ekt({operationPath:e.additionalOperationContext.path,operation:e,policyList:F?.getPolicyListEnforced()??[]});t&&(Me(e=>e+1),Ae({initialResult:t,path:e.additionalOperationContext.path,method:e.additionalOperationContext.method,operationId:e.operationId}))},Re=async e=>{let t=ke;if(!t)return;let{initialResult:r,path:i,method:a}=t,o=P.operationArray?.find(e=>e.additionalOperationContext.path===i&&e.additionalOperationContext.method===a);if(!o){Ae(void 0);return}let s;try{s=z()}catch(e){if(e instanceof Error){N(e.message),pe();return}throw e}let c=Nkt(e.step1.name),l=z1(e.step1.mcpUrl),u=l?.protectedResourceMetadataUrl??Rkt(e.step1.mcpUrl),d=o[CX]?.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===A4),g=m.find(e=>e.policyType===j4),_=m.find(e=>e.policyType===`remove-headers-inbound`&&M4(e.handler?.options)),v=m.find(e=>e.policyType.startsWith(`upstream-`)),y;if(e.step1.authMode===`user-oauth`){let t={id:c,displayName:e.step1.name,summary:`${e.step1.name} remote MCP server, federated via the gateway.`,...u?{protectedResourceMetadataUrl:u}:{},authMode:`user-oauth`,scopes:l?.scopes??[],clientRegistration:e.step1.clientRegistration};if(h&&F)try{F.updatePolicy(h.name,{...h,handler:{...h.handler,options:t}}),y=h.name}catch(e){if(e instanceof Error){N(e.message),pe();return}}else if(F){y=n3(`mcp-upstream-${c}`,g8(F));try{F.createPolicy({name:y,policyType:A4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpTokenExchangeInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}}}let b;if(e.step1.authMode===`upstream-policy`&&F){let{policyType:t,policyName:n,handler:r}=e.step1;try{v&&v.policyType===t?F.updatePolicy(v.name,{...v,name:n,handler:r}):F.createPolicy({name:n,policyType:t,handler:r}),b=n}catch(e){if(e instanceof Error){N(e.message),pe();return}}}let x;if(e.step2.catalogMode===`curated`){let t=w4(e.step2);if(g&&F)try{F.updatePolicy(g.name,{...g,handler:{...g.handler,options:t}}),x=g.name}catch(e){if(e instanceof Error){N(e.message),pe();return}}else if(F){x=n3(`mcp-filter-${c}`,g8(F));try{F.createPolicy({name:x,policyType:j4,handler:{module:`$import(@zuplo/runtime/mcp-gateway)`,export:`McpCapabilityFilterInboundPolicy`,options:t}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}}}let S;if(e.step3.authPolicyChoice===`existing`)S=e.step3.existingPolicyName;else if((e.step3.authPolicyChoice===`new`||e.step3.authPolicyChoice===`new-other`)&&(S=e.step3.newPolicyName,F))try{F.createPolicy({name:S,policyType:e.step3.policyType,handler:e.step3.handler})}catch(e){if(e instanceof Error){N(e.message),pe();return}}let C;if(e.step1.authMode===`none`&&e.step1.noAuthBehavior===`strip`)try{C=_?.name??kLt(F)}catch(e){if(e instanceof Error){N(e.message),pe();return}}let w=[S,x,y,b,C].filter(e=>!!e),T=o[CX],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})`,[CX]:{...T??{},handler:{...E??{export:`McpProxyHandler`,module:`$import(@zuplo/runtime/mcp-gateway)`},options:{...E?.options??{},rewritePattern:e.step1.mcpUrl}},policies:{...T?.policies??{},inbound:w}}}})}catch(e){if(e instanceof Error){N(e.message),pe();return}}let D;try{D=new URL(e.step1.mcpUrl).hostname}catch{D=void 0}n(`mcp-gateway-edit-virtual-mcp-submitted`,{upstreamHost:D,upstreamAuthMode:e.step1.authMode,previousUpstreamAuthMode:r.step1.authMode,inboundAuthChoice:e.step3.authPolicyChoice,previousInboundAuthChoice:r.step3.authPolicyChoice}),Ae(void 0),s===`manual`&&_e()},ze=(0,H.useMemo)(()=>E?B.find(e=>e.operationId===E)||B.find(e=>h?.path===e.additionalOperationContext.path&&h?.method===e.additionalOperationContext.method):void 0,[B,E,h]);(0,H.useEffect)(()=>{ze&&!h&&g({path:ze.additionalOperationContext.path,method:ze.additionalOperationContext.method})},[ze,h]);let Be=(e,n,r)=>{let i=(e,t)=>{let n=e.replace(/-duplicate(-\d+)?$/,``),r=`${n}-duplicate`,i=2;for(;t(r);)r=`${n}-duplicate-${i}`,i++;return r},a=P.operationArray??[],o=i(e,e=>a.some(t=>t.additionalOperationContext.path===e&&t.additionalOperationContext.method===n)),s=i(r.operationId??`op-${Ne().slice(0,4)}`,e=>a.some(t=>t.operationId===e)),c=JSON.parse(JSON.stringify(r));c.operationId=s;try{let e=P.addOperation(o,n,c);e&&D(e)}catch(e){e instanceof Error&&(t(`route-add-failed`,{httpPath:o,httpMethod:n}),N(e.message),pe())}t(`route-added`,{httpPath:o,httpMethod:n,duplicate:!0})},Ve=()=>{f(!0),u(`tags`),c(!0)},He=ke!==void 0,Ue=(0,U.jsx)(Dkt,{isOpen:De||He,existingPaths:Pe,mode:He?`edit`:`create`,initialResult:ke?.initialResult,onClose:()=>{Oe(!1),Ae(void 0)},onFinish:He?Re:Fe},`mcp-wizard-${je}`),We={onAddRest:Se,onAddGraphql:Te,onAddWebSocket:Ee,onAddMcpVirtual:Ie,onAddMcpServer:we,onAddTag:Ve};return P.operationArray?.length===0&&(!V||V.trim().length===0)?(0,U.jsxs)(U.Fragment,{children:[Ue,(0,U.jsx)(Gmt,{...We})]}):(0,U.jsxs)(`div`,{className:`ms-2 grid grid-cols-3 h-full grow`,children:[(0,U.jsx)(f$,{open:oe,onOpenChange:e=>{se(e),e||v(void 0)},onClickDelete:fe,title:`Delete`,deleteButtonText:`Confirm`,children:ce.length===0?`Are you sure you want to delete this operation?`:(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{children:[`The following`,` `,ce.length===1?`policy is`:`policies are`,` `,`used only by this route. Would you like to delete`,` `,ce.length===1?`it`:`them`,` `,`too?`]}),(0,U.jsx)(`ul`,{className:`flex flex-col divide-y divide-border max-h-[40vh] overflow-y-auto rounded-md border bg-surface-sunken`,children:ce.map(e=>{let t=`delete-policy-${e.name}`;return(0,U.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2`,children:[(0,U.jsx)(YJ,{id:t,checked:le.has(e.name),onCheckedChange:t=>de(e.name,t===!0),className:`mt-0.5`}),(0,U.jsxs)(`label`,{htmlFor:t,className:`flex flex-col gap-0.5 text-left cursor-pointer min-w-0`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground truncate`,children:e.name}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e.policyType})]})]},e.name)})})]})}),(0,U.jsx)(_Lt,{}),Ue,be&&(0,U.jsx)(Wkt,{open:s,onOpenChange:c,info:be,onSave:p,defaultTab:l,tagsAutoCreate:d,onTagsAutoCreateConsumed:()=>f(!1)}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 justify-start h-full pt-2 min-h-0`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between gap-x-2`,children:[(0,U.jsx)(`div`,{className:`flex gap-1`,children:(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{className:`flex group select-none`,asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,title:`Filter and sort routes`,children:[(0,U.jsx)(Gd,{size:16}),`Filter`]})}),(0,U.jsxs)(XG,{className:`min-w-[220px]`,align:`start`,children:[(0,U.jsx)(nK,{children:`Sort by`}),(0,U.jsx)(ZG,{children:TLt.map(e=>(0,U.jsxs)(QG,{onClick:()=>j(e),className:`justify-between`,children:[e,(0,U.jsx)(ed,{className:W(`mr-2`,e!==A&&`invisible`),size:16})]},e))}),(0,U.jsx)(rK,{}),(0,U.jsx)(nK,{children:`Filter by tag`}),(0,U.jsx)(ZG,{className:`max-h-60 overflow-y-auto`,children:xe?.map(e=>(0,U.jsxs)(QG,{onClick:t=>{t.stopPropagation(),t.preventDefault(),r.includes(e.value)?i(r.filter(t=>t!==e.value)):i([...r,e.value])},className:`justify-between`,children:[e.label,(0,U.jsx)(ed,{className:W(`mr-2`,!r.includes(e.value)&&`invisible`),size:18})]},e.label))}),(0,U.jsx)(rK,{}),(0,U.jsx)(nK,{children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Cee,{size:16}),`Group by`]})}),(0,U.jsx)(ZG,{children:ELt.map(e=>(0,U.jsxs)(QG,{onClick:t=>{t.stopPropagation(),t.preventDefault(),o(e.value)},className:`justify-between`,children:[e.label,(0,U.jsx)(ed,{className:W(`mr-2`,a!==e.value&&`invisible`),size:16})]},e.value))})]})]})}),T?null:(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>{f(!1),u(`details`),c(!0)},"aria-label":`API Settings`,title:`API Settings`,children:(0,U.jsx)(bf,{size:16})}),(0,U.jsxs)(JG,{children:[(0,U.jsx)(YG,{asChild:!0,children:(0,U.jsxs)(X,{variant:`outline`,size:`sm`,"data-test":`add-route-btn`,className:`relative gap-0.5!`,children:[(0,U.jsx)(`div`,{className:`absolute w-1.5 h-1.5 rounded-full -top-0.5 -right-[3px] bg-zuplo-700`}),(0,U.jsx)(Sf,{"aria-hidden":`true`,className:`size-3.5`}),`Add`]})}),(0,U.jsx)(XG,{children:(0,U.jsx)(Wmt,{...We})})]})]})]}),(0,U.jsx)(FJ,{onClearValue:()=>ee(``),value:V,showClearButton:!!V&&V.length>0,children:(0,U.jsx)(iM,{ref:m,value:V,onChange:e=>ee(e.target.value),placeholder:`Search Routes`,className:`px-8`})}),r.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,U.jsxs)(`div`,{className:`group flex items-center gap-1 max-w-full pl-1.5 pr-0.5 py-0.5 rounded-full border border-border bg-card text-xs text-foreground`,children:[(0,U.jsx)(Uf,{size:11,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e} filter`,onClick:t=>{t.stopPropagation(),i(r.filter(t=>t!==e))},className:`shrink-0 size-4 rounded-full flex items-center justify-center text-muted-foreground hover:bg-neutral-200 dark:hover:bg-neutral-700 hover:text-neutral-900 dark:hover:text-foreground`,children:(0,U.jsx)(ep,{size:11})})]},e))}),(0,U.jsx)(`div`,{className:`overflow-y-auto space-y-1`,children:te.map((e,t,n)=>{let r=!e.collapsible||S.has(e.key),i=e.operations.length,o=e.icon,s=(0,U.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-background px-1.5 py-0.5 text-xs font-normal tabular-nums text-muted-foreground`,children:i});return(0,U.jsxs)(`div`,{children:[e.collapsible?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>w(e.key),"aria-expanded":r,className:`mt-3 mb-1 flex w-full items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-left text-sm font-semibold text-foreground transition-colors first:mt-1 hover:bg-muted`,title:r?`Collapse ${e.label}`:`Expand ${e.label} (${i} ${i===1?`route`:`routes`})`,children:[r?(0,U.jsx)(td,{size:15,className:`shrink-0 text-muted-foreground`}):(0,U.jsx)(nd,{size:15,className:`shrink-0 text-muted-foreground`}),o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`truncate font-mono`,title:e.label,children:e.label}),s]}):a!==`none`&&(0,U.jsxs)(`div`,{className:`mt-3 mb-1 flex items-center gap-1.5 rounded-md bg-muted/60 px-2 py-2 text-sm font-semibold text-foreground first:mt-1`,children:[o&&(0,U.jsx)(o,{size:16,className:`shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:W(`truncate`,e.mono&&`font-mono`),title:e.label,children:e.label}),s]}),r&&e.operations.map(({additionalOperationContext:e,...r})=>{let i=ze?.operationId===r.operationId,o=r[CX]?.handler,s=wX(o),c=TX(o),l=s?o.options?.operations?.length??0:0,u=l>0,d=y.has(r.operationId);return(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(ght,{path:i&&ne?ne:e.path,type:c?`mcp-virtual`:s?`mcp`:`route`,method:e.method,summary:i&&ie?ie:r.summary,operationId:r.operationId,operation:r,isSelected:i,onOperationSelected:t=>{re(``),ae(``),g({path:e.path,method:e.method}),D(t)},onDelete:(e,t,n)=>{v({path:e,method:t,operationId:n}),se(!0)},onAddRoute:Ce,onDuplicate:()=>Be(e.path,e.method,r),onMoveUp:DLt.has(a)?void 0:()=>ye(e.path,`up`),onMoveDown:DLt.has(a)?void 0:()=>ye(e.path,`down`),isFirstPath:A===m8&&t===0,isLastPath:A===m8&&t===n.length-1,isToolsExpanded:u?d:void 0,onToggleTools:u?()=>x(r.operationId):void 0,toolsCount:u?l:void 0}),o&&u&&d&&(0,U.jsx)(Rht,{handler:o,operation:{...r,additionalOperationContext:e}})]},r.operationId)})]},e.key)})})]}),(0,U.jsx)(`div`,{className:`col-span-2 flex flex-col h-full overflow-y-auto`,children:(0,U.jsx)(r3.Provider,{value:{setPath:re,setSummary:ae},children:(0,U.jsx)(zht.Provider,{value:Le,children:(0,U.jsx)(fLt,{operationData:ze,addRouteMenuProps:We})})})})]})},NLt={create:{shell:`bg-emerald-500/8 shadow-emerald-950/5`,icon:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`,count:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`},update:{shell:`bg-brand/8 shadow-brand/5`,icon:`bg-brand/12 text-brand`,count:`bg-brand/12 text-brand`},keep:{shell:`bg-background shadow-black/5 dark:shadow-white/5`,icon:`bg-muted text-muted-foreground`,count:`bg-muted text-muted-foreground`}},_8=({icon:e,operations:t,title:n,tone:r})=>{let i=NLt[r];return(0,U.jsxs)(`section`,{className:`rounded-2xl p-4 shadow-sm ${i.shell}`,"aria-label":`${n} operations`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 font-semibold text-foreground`,children:[(0,U.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-xl ${i.icon}`,children:e}),n,` operations`]}),(0,U.jsx)(`div`,{className:`rounded-full px-2.5 py-1 text-xs font-medium tabular-nums ${i.count}`,children:t.size})]}),(0,U.jsx)(`div`,{className:`space-y-1.5`,children:Array.from(t).map(e=>{let t=e.split(`>`),n=t[0],r=t.slice(1,t.length).join(`>`);return(0,U.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 rounded-xl bg-background/80 px-3 py-2 text-sm shadow-xs`,children:[(0,U.jsx)(RJ,{className:`w-14`,method:n}),(0,U.jsx)(`span`,{className:`break-all text-foreground/90`,children:r})]},e)})})]})},PLt=({openApiFileModel:e,onOpenApiFileSynced:t,setIsOpen:n})=>{let[r,i]=(0,H.useState)(),a=pp(),o=e=>{i(e)},s=async()=>{if(!r)throw Error(`No file selected`);let i=e.content?JSON.parse(e.content):null;t(i?Got(i,r.content):r.content),n(!1),a.success(`OpenAPI file merged successfully`,{icon:(0,U.jsx)(Hpe,{className:`h-4 w-4`})})};if(r){let t=Xot(JSON.parse(e.content??`{}`),r.content);return(0,U.jsx)($$,{isOpen:!0,setIsOpen:n,title:`Review OpenAPI import`,className:`sm:max-w-4xl max-h-[88vh] overflow-y-auto`,icon:(0,U.jsx)(my,{className:`shrink-0 h-6 w-6 text-brand`}),iconStyle:`bg-zuplo-pink/10`,buttons:[{onButtonClick:()=>{n(!1)},variant:`outline`,buttonContent:`Cancel`,id:`Close merge open-api modal`,testID:`merge-cancel-btn`},{onButtonClick:s,variant:`brand`,buttonContent:`Import changes`,id:`Complete open-api merge`,testID:`complete-merge-btn`}],bodyComponent:(0,U.jsxs)(`div`,{className:`mt-6 text-left text-sm`,children:[(0,U.jsx)(`div`,{className:`overflow-hidden rounded-3xl bg-gradient-to-br from-brand/12 via-background to-background p-px shadow-lg shadow-brand/5`,children:(0,U.jsxs)(`div`,{className:`rounded-[calc(1.5rem-1px)] bg-background p-5`,children:[(0,U.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[1fr_auto_1fr] md:items-center`,children:[(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-brand/10 text-brand`,children:(0,U.jsx)(pme,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Import file`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:r.name})]})]})}),(0,U.jsx)(`div`,{className:`hidden h-10 w-10 items-center justify-center rounded-full bg-brand text-brand-foreground shadow-sm shadow-brand/24 md:flex`,children:(0,U.jsx)(my,{className:`h-5 w-5`})}),(0,U.jsx)(`div`,{className:`rounded-2xl bg-surface-sunken p-4 shadow-[inset_0_1px_rgba(255,255,255,0.05)]`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,children:(0,U.jsx)(by,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Current API`}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate font-medium text-foreground`,children:e.path})]})]})})]}),(0,U.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2 text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:`Operations are matched by`}),(0,U.jsx)(XD,{variant:`outline`,children:`Path + method`}),(0,U.jsx)(`span`,{children:`so existing Zuplo extensions and policies stay in place.`})]})]})}),(0,U.jsxs)(`div`,{className:`mt-6 flex items-end justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:`Import summary`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Review what will change before applying this file.`})]}),(0,U.jsxs)(`div`,{className:`rounded-full bg-surface-sunken px-3 py-1 text-xs font-medium text-muted-foreground tabular-nums`,children:[t.created.size+t.merged.size+t.retained.size,` `,`operations`]})]}),(0,U.jsxs)(`div`,{className:`mt-3 grid max-h-96 gap-3 overflow-y-auto rounded-3xl bg-surface-sunken p-3 shadow-[inset_0_1px_rgba(255,255,255,0.04)]`,children:[t.created.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(Nme,{className:`h-4 w-4`}),title:`Create`,tone:`create`,operations:t.created}):null,t.merged.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(Ame,{className:`h-4 w-4`}),title:`Update`,tone:`update`,operations:t.merged}):null,t.retained.size>0?(0,U.jsx)(_8,{icon:(0,U.jsx)(Upe,{className:`h-4 w-4`}),title:`Keep`,tone:`keep`,operations:t.retained}):null]})]})})}return(0,U.jsx)(Rmt,{title:`Import OpenAPI`,onValidFileSelected:o,setIsOpen:n})},FLt=()=>{let e=Dt(),t=je({mutationFn:t=>e.fetch(tn.users.updatePreferences(t))}),{data:n}=fb(mt.user.preferences());return{preferences:n,updatePreferences:t.mutate,updatePreferencesMutation:t}},ILt=!1;function v8(){let e=at(),{preferences:t,updatePreferencesMutation:n}=FLt();return{isFileTreeOpen:t.fileTreeOpen??ILt,setIsFileTreeOpen:r=>{let i=[mt.user.preferences().url,!0],a=e.getQueryData(i),o={...a??t,fileTreeOpen:r};e.setQueryData(i,o),n.mutate(o,{onError:()=>{a&&e.setQueryData(i,a),e.invalidateQueries({queryKey:i})}})}}}function LLt(){let e=VZ(),{logEvent:t}=on(),[n,r]=wJ(`v`,`designer`),{isFileTreeOpen:i}=v8(),a=e?.path.split(`/`).pop()??`JSON`,o=HZ(),s=Bmt(),[c,l]=h$(()=>{if(!e)throw Error(`File model not found`);return t(`merge-open-api`),(0,U.jsx)(PLt,{openApiFileModel:e,onOpenApiFileSynced:n=>{let r={...e,content:JSON.stringify(n,null,2)};o(r,!0),t(`merge-open-api-complete`),s(r.path)},setIsOpen:l})},[e,s]);return(0,U.jsx)(bht,{children:(0,U.jsx)(_mt,{children:(0,U.jsxs)(AO,{defaultValue:`designer`,value:n,onValueChange:e=>r(e),className:`flex flex-col h-full w-full max-h-screen min-w-[850px]`,children:[i&&(0,U.jsxs)(jO,{className:`rounded-none border-b w-full justify-start`,children:[(0,U.jsx)(MO,{value:`designer`,children:`Route Designer`}),(0,U.jsx)(MO,{value:`raw`,children:a??`Raw`}),(0,U.jsxs)(X,{variant:`outline`,size:`sm`,onClick:c,className:`ml-4`,children:[(0,U.jsx)(Vme,{className:`w-4 h-4`}),` Import`]})]}),(0,U.jsx)(NO,{value:`designer`,className:`grow h-full overflow-y-auto`,children:(0,U.jsx)(Tmt,{onNavigateToOpenApiFileTab:()=>r(`raw`),children:(0,U.jsx)(MLt,{onNavigateToOpenApiFileTab:()=>r(`raw`)})})}),(0,U.jsx)(NO,{value:`raw`,className:`grow h-full overflow-y-auto`,forceMount:!0,children:(0,U.jsx)(eQ,{})})]})})})}function RLt({title:e,description:t,folder:n,icon:r,emptyText:i,newLabel:a,onCreate:o}){let s=Cp(e=>e.projectTreeNodes),[c,l]=As(),{isReadOnly:u}=wZ(),d=n.endsWith(`/`)?n:`${n}/`,f=(0,H.useMemo)(()=>s.filter(e=>e.type===Vs.File&&e.path.startsWith(d)).sort((e,t)=>e.path.localeCompare(t.path)),[s,d]),p=e=>{let t=new URLSearchParams(c);t.set(`path`,e),t.delete(`v`),t.delete(`line`),l(t)};return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:e}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:t})]}),!u&&(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,onClick:o,className:`shrink-0`,children:[(0,U.jsx)(Sf,{className:`size-4`}),a]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:f.length===0?(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:i}):f.map(e=>{let t=e.path.slice(d.length);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:W(`group flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors`,`bg-surface hover:border-brand/40 hover:bg-brand/5`,`ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`),children:[(0,U.jsx)(r,{className:`size-4 shrink-0 text-neutral-500 group-hover:text-brand`}),(0,U.jsx)(`span`,{className:`truncate text-sm font-medium text-neutral-800 dark:text-neutral-200`,children:t})]},e.path)})})]})})}function zLt(){let e=Cp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=v8();return(0,U.jsx)(RLt,{title:`Custom Modules`,description:`TypeScript modules in your project's modules/ folder — request handlers, policies, and other custom code.`,folder:`/modules`,icon:gf,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 BLt(){let e=Cp(e=>e.setPendingNewFile),{setIsFileTreeOpen:t}=v8();return(0,U.jsx)(RLt,{title:`Schemas`,description:`JSON schemas in your project's schemas/ folder, used to validate requests and responses.`,folder:`/schemas`,icon:Fd,emptyText:`No schemas yet. Create one to validate request or response bodies.`,newLabel:`New Schema`,onCreate:()=>{t(!0),e({strategyFolder:`/schemas`,template:`Schema`})}})}var VLt=()=>{let[e,t]=(0,H.useState)(),{isReadOnly:n}=wZ(),r=u1(),i=r.policiesUsageInfo,{logEvent:a}=on(),o=hp([`account`,`project`,`environment`]),[s,c]=h$(()=>e?(0,U.jsx)(gNt,{isOpen:!0,setIsOpen:c,stackType:e,shouldHideExistingPolicies:!0,policyManager:r}):null,[e]),l=e=>{t(e),a(`create-policy-clicked`,{account:o.account.name,project:o.project.name,environment:o.environment.name,type:e}),s()},u=(r.policyList??[]).flatMap(e=>i?.find(t=>t.name===e.name)??[]);return(0,U.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-bold text-neutral-900 dark:text-neutral-100`,children:`Policies`}),(0,U.jsx)(`p`,{className:`text-sm text-neutral-600 dark:text-neutral-400`,children:`Reusable policies from your project's config/policies.json — apply them to routes to inspect and control requests and responses.`})]}),!n&&(0,U.jsxs)(JG,{modal:!1,children:[(0,U.jsx)(YG,{asChild:!0,children:(0,U.jsxs)(X,{variant:`secondary`,size:`sm`,className:`shrink-0`,children:[(0,U.jsx)(Sf,{className:`size-4`}),`New Policy`]})}),(0,U.jsxs)(XG,{align:`end`,children:[(0,U.jsxs)(QG,{onClick:()=>l(`inbound`),children:[(0,U.jsx)(Lu,{className:`mr-2 size-4`}),`Inbound Policy`]}),(0,U.jsxs)(QG,{onClick:()=>l(`outbound`),children:[(0,U.jsx)(Vu,{className:`mr-2 size-4`}),`Outbound Policy`]})]})]})]}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-1.5`,children:u.length===0?(0,U.jsxs)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-neutral-500 dark:text-neutral-400`,children:[`No policies yet. Create an inbound or outbound policy to inspect and control requests and responses, or`,` `,(0,U.jsx)(kT,{href:`https://zuplo.com/docs/overview/policies`,children:`read the docs`}),`.`]}):u.map(e=>(0,U.jsx)(lNt,{policy:e},e.name))})]})})},HLt=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={}))})),ULt=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={}))})),WLt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),GLt=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`})),KLt=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})),qLt=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})),JLt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isValidProjectName=e.MAX_PRETTY_BRANCH_LENGTH=e.MAX_HASH_LENGTH=void 0;var t=qLt();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})),YLt=i({$defs:()=>w8,$id:()=>b8,$schema:()=>y8,additionalProperties:()=>!1,default:()=>XLt,description:()=>``,properties:()=>T8,required:()=>C8,title:()=>x8,type:()=>S8}),y8,b8,x8,S8,C8,w8,T8,XLt,ZLt=n((()=>{y8=`https://json-schema.org/draft/2020-12/schema`,b8=`http://schemas.zuplo.com/route.json`,x8=`Route Config File`,S8=`object`,C8=[`routes`,`versions`],w8={corsPolicy:{type:`string`,pattern:`^[0-9a-z-]+$`},httpMethod:{type:`string`,enum:[`GET`,`HEAD`,`POST`,`PUT`,`DELETE`,`CONNECT`,`OPTIONS`,`TRACE`,`PATCH`]},handlerDefinition:{type:`object`,properties:{module:{type:`string`,pattern:`^\\$import\\([^ )]*?\\)$`},export:{type:`string`},options:{type:`object`,additionalProperties:!0}},additionalProperties:!1,required:[`module`,`export`]},schema:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:[`object`,`boolean`]},parameterBaseObject:{$comment:`https://spec.openapis.org/oas/v3.1.0#schema-object`,type:`object`,properties:{description:{type:`string`},required:{default:!1,type:`boolean`},deprecated:{default:!1,type:`boolean`},schema:{$ref:`#/$defs/schema`}},required:[`schema`]},parameterDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#parameter-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,properties:{name:{type:`string`},in:{type:`string`,enum:[`query`,`header`,`path`,`cookie`]}},required:[`name`,`in`,`schema`],if:{type:`object`,properties:{in:{const:`query`}},required:[`in`]},then:{type:`object`,properties:{allowEmptyValue:{default:!1,type:`boolean`}}}},"media-type":{$comment:`https://spec.openapis.org/oas/v3.1.0#media-type-object`,type:`object`,properties:{schema:{$ref:`#/$defs/schema`}},unevaluatedProperties:!1},content:{$comment:`https://spec.openapis.org/oas/v3.1.0#fixed-fields-10`,type:`object`,additionalProperties:{$ref:`#/$defs/media-type`},propertyNames:{enum:[`application/json`,`application/problem+json`]}},header:{$comment:`https://spec.openapis.org/oas/v3.1.0#header-object`,allOf:[{$ref:`#/$defs/parameterBaseObject`}],type:`object`,required:[`schema`]},response:{$comment:`https://spec.openapis.org/oas/v3.1.0#response-object`,type:`object`,properties:{description:{type:`string`},headers:{type:`object`,additionalProperties:{$ref:`#/$defs/header`}},content:{$ref:`#/$defs/content`}},required:[`description`],unevaluatedProperties:!1},responsesDefinition:{$comment:`https://spec.openapis.org/oas/v3.1.0#responses-object`,type:`object`,properties:{default:{$ref:`#/$defs/response`}},patternProperties:{"^[1-5](?:[0-9]{2}|XX)$":{$ref:`#/$defs/response`}},minProperties:1,unevaluatedProperties:!1},tag:{$comment:`https://spec.openapis.org/oas/v3.1.0#tag-object`,type:`object`,properties:{name:{type:`string`},description:{type:`string`}},required:[`name`],unevaluatedProperties:!1},info:{type:`object`,required:[`title`,`version`],properties:{title:{type:`string`},summary:{type:`string`},description:{type:`string`},termsOfService:{type:`string`,format:`uri`},version:{type:`string`}}},versionData:{type:`object`,required:[`name`,`pathPrefix`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},pathPrefix:{type:`string`,pattern:`(^$|^/[^\\s]*$)`},info:{$ref:`#/$defs/info`},openApiFile:{description:`The project relative path to the OpenAPI spec.`,type:`string`},tags:{type:`array`,items:{$ref:`#/$defs/tag`}},excludeFromOpenApi:{type:`boolean`,description:`If false, OpenAPI documentation will not be generated for this version. If openApiFile is set this setting is ignored.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`}}},routeConfiguration:{type:`object`,required:[`path`,`methods`,`handler`,`version`],additionalProperties:!1,properties:{operationId:{type:`string`},path:{type:`string`,pattern:`^/[^\\s]*$`},methods:{type:`array`,items:{$ref:`#/$defs/httpMethod`}},label:{type:`string`,description:`An internal user-friendly identifier of the route.`},enforceOpenApi:{type:`boolean`,description:`If true, schema validation found in the OpenAPI spec will be enforced on requests/responses.`},key:{type:`string`,deprecated:!0},handler:{$ref:`#/$defs/handlerDefinition`},corsPolicy:{$ref:`#/$defs/corsPolicy`},custom:{},version:{type:`string`,pattern:`^[0-9a-z-]+$`},policies:{type:`object`,additionalProperties:!1,properties:{inbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}},outbound:{type:`array`,items:{type:`string`,pattern:`^[0-9a-z-]+$`}}}},summary:{type:`string`},description:{type:`string`},parameters:{type:`array`,items:{$ref:`#/$defs/parameterDefinition`}},excludeFromOpenApi:{type:`boolean`},responses:{$ref:`#/$defs/responsesDefinition`},tags:{type:`array`,items:{type:`string`}}}},policyConfiguration:{type:`object`,required:[`name`,`policyType`,`handler`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},policyType:{type:`string`},handler:{$ref:`#/$defs/handlerDefinition`},options:{type:`object`,additionalProperties:!0}}},corsPolicyConfiguration:{type:`object`,required:[`name`,`allowedOrigins`],additionalProperties:!1,properties:{name:{type:`string`,pattern:`^[0-9a-z-]+$`},allowCredentials:{type:`boolean`},maxAge:{type:`number`},allowedOrigins:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},allowedMethods:{oneOf:[{type:`array`,items:{$ref:`#/$defs/httpMethod`}},{type:`string`}]},allowedHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]},exposeHeaders:{oneOf:[{type:`array`,items:{type:`string`}},{type:`string`}]}}}},T8={$schema:{type:`string`},info:{$ref:`#/$defs/info`,deprecated:!0},versions:{type:`array`,minItems:1,items:{$ref:`#/$defs/versionData`}},routes:{type:`array`,minItems:0,items:{$ref:`#/$defs/routeConfiguration`}},policies:{type:`array`,items:{$ref:`#/$defs/policyConfiguration`}},corsPolicies:{type:`array`,items:{$ref:`#/$defs/corsPolicyConfiguration`}},requestErrorHandler:{$ref:`#/$defs/handlerDefinition`}},XLt={$schema:y8,$id:b8,title:x8,description:``,type:S8,additionalProperties:!1,required:C8,$defs:w8,properties:T8}})),QLt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c,l),"date-time":t(d,f),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:h,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:w,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:_,int32:{type:`number`,validate:b},int64:{type:`number`,validate:x},float:{type:`number`,validate:S},double:{type:`number`,validate:S},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,f),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function c(e,t){let n=s.exec(e);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[5];return(r<=23&&i<=59&&a<=59||r===23&&i===59&&a===60)&&(!t||o!==``)}function l(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3]+(n[4]||``),t=r[1]+r[2]+r[3]+(r[4]||``),e>t?1:e<t?-1:0}var u=/t|\s/i;function d(e){let t=e.split(u);return t.length===2&&a(t[0])&&c(t[1],!0)}function f(e,t){if(!(e&&t))return;let[n,r]=e.split(u),[i,a]=t.split(u),s=o(n,i);if(s!==void 0)return s||l(r,a)}var p=/\/|:/,m=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function h(e){return p.test(e)&&m.test(e)}var g=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function _(e){return g.lastIndex=0,g.test(e)}var v=-(2**31),y=2**31-1;function b(e){return Number.isInteger(e)&&e<=y&&e>=v}function x(e){return Number.isInteger(e)}function S(){return!0}var C=/[^\\]\\Z/;function w(e){if(C.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),E8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),$Lt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=E8(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r=e.UsedValueState||={}),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),D8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=E8(),n=$Lt(),r=E8();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=$Lt();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?`
1563
1563
  `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${L(e)}`}e.not=j;var M=I(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=I(e.operators.OR);function F(...e){return e.reduce(P)}e.or=F;function I(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${L(n)} ${e} ${L(r)}`}function L(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),O8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=D8(),n=E8();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y=e.Type||={});function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),k8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=D8();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),A8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=D8(),n=O8(),r=k8();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),eRt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=A8(),n=D8(),r=k8(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),tRt=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})),nRt=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),j8=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=tRt(),n=nRt(),r=A8(),i=D8(),a=O8(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o=e.DataType||={});function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
1564
1564
  || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
1565
1565
  || (${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"