@emeryld/rrroutes-openapi 2.6.5 → 2.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/assets/docs.js +239 -86
- package/dist/web/v2/components/flows/FlowCanvas.d.ts +2 -2
- package/dist/web/v2/components/flows/FlowRunProgress.d.ts +2 -2
- package/dist/web/v2/components/flows/FlowToolbar.d.ts +22 -0
- package/dist/web/v2/components/flows/FlowVariablePanel.d.ts +2 -2
- package/dist/web/v2/components/flows/RecordingReviewDialog.d.ts +9 -0
- package/dist/web/v2/components/flows/nodes/ConditionNode.d.ts +2 -2
- package/dist/web/v2/components/flows/nodes/DelayNode.d.ts +2 -2
- package/dist/web/v2/components/flows/nodes/ExtractNode.d.ts +2 -2
- package/dist/web/v2/components/flows/nodes/RequestNode.d.ts +4 -7
- package/dist/web/v2/hooks/useFlowKeyboardShortcuts.d.ts +17 -0
- package/dist/web/v2/hooks/useFlowRecording.d.ts +13 -0
- package/dist/web/v2/stores/flowStore.d.ts +4 -0
- package/dist/web/v2/utils/flowHelpers.d.ts +33 -0
- package/dist/web/v2/utils/flowPresets.d.ts +11 -0
- package/dist/web/v2/utils/flowRecorder.d.ts +5 -0
- package/package.json +1 -1
- package/dist/public/assets/Add.js +0 -1
- package/dist/public/assets/Autocomplete.js +0 -1
- package/dist/public/assets/BaseFilterBar.js +0 -1
- package/dist/public/assets/BentoGrid.js +0 -1
- package/dist/public/assets/CacheLogsPage.js +0 -1
- package/dist/public/assets/DeleteOutline.js +0 -1
- package/dist/public/assets/DiffPage.js +0 -7
- package/dist/public/assets/Download.js +0 -1
- package/dist/public/assets/EndpointDetailPage.js +0 -1
- package/dist/public/assets/EndpointDetailPanel.js +0 -1
- package/dist/public/assets/EndpointPlaygroundPage.js +0 -1
- package/dist/public/assets/ExpandLess.js +0 -1
- package/dist/public/assets/ExportButton.js +0 -2
- package/dist/public/assets/FlowBuilderPage.js +0 -20
- package/dist/public/assets/HistoryPage.js +0 -1
- package/dist/public/assets/LogsPage.js +0 -1
- package/dist/public/assets/PageContainer.js +0 -3
- package/dist/public/assets/PlayArrow.js +0 -1
- package/dist/public/assets/PresetsPage.js +0 -4
- package/dist/public/assets/RoutesPage.js +0 -1
- package/dist/public/assets/SchedulingPage.js +0 -1
- package/dist/public/assets/SchemaTreeView.js +0 -1
- package/dist/public/assets/SettingsPage.js +0 -1
- package/dist/public/assets/SocketsPage.js +0 -1
- package/dist/public/assets/filterTypes.js +0 -1
- package/dist/public/assets/getValidReactChildren.js +0 -1
- package/dist/public/assets/kvRowAdapters.js +0 -1
- package/dist/public/assets/schemaDefaults.js +0 -1
- package/dist/public/assets/useEndpointOptions.js +0 -1
- package/dist/public/assets/useQueryState.js +0 -1
- package/dist/public/assets/vendor-recharts.js +0 -99
- package/dist/public/assets/vendor-xyflow.js +0 -15
|
@@ -9,5 +9,5 @@ type FlowCanvasProps = {
|
|
|
9
9
|
onNodeClick?: (event: React.MouseEvent, node: Node) => void;
|
|
10
10
|
onMouseMove?: (event: React.MouseEvent) => void;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
export
|
|
12
|
+
declare const _default: import("react").NamedExoticComponent<FlowCanvasProps>;
|
|
13
|
+
export default _default;
|
|
@@ -3,5 +3,5 @@ type FlowRunProgressProps = {
|
|
|
3
3
|
runState: FlowRunState;
|
|
4
4
|
nodes: FlowStepNode[];
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
declare const _default: import("react").NamedExoticComponent<FlowRunProgressProps>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FlowDefinition, FlowNodeType } from '../../stores/flowStore.js';
|
|
2
|
+
import { type PresetTemplate } from '../../utils/flowPresets.js';
|
|
3
|
+
type FlowToolbarProps = {
|
|
4
|
+
flowName: string;
|
|
5
|
+
onFlowNameChange: (name: string) => void;
|
|
6
|
+
flows: FlowDefinition[];
|
|
7
|
+
activeFlowId: string | null;
|
|
8
|
+
onSelectFlow: (id: string | null) => void;
|
|
9
|
+
onNewFlow: () => void;
|
|
10
|
+
onLoadPreset: (template: PresetTemplate) => void;
|
|
11
|
+
onSave: () => void;
|
|
12
|
+
onAddNode: (type: FlowNodeType) => void;
|
|
13
|
+
onRun: () => void;
|
|
14
|
+
isRunning: boolean;
|
|
15
|
+
isRecording: boolean;
|
|
16
|
+
recordedRequestCount: number;
|
|
17
|
+
onStartRecording: () => void;
|
|
18
|
+
onStopRecording: () => void;
|
|
19
|
+
connectSource: string | null;
|
|
20
|
+
};
|
|
21
|
+
declare const _default: import("react").NamedExoticComponent<FlowToolbarProps>;
|
|
22
|
+
export default _default;
|
|
@@ -3,5 +3,5 @@ type FlowVariablePanelProps = {
|
|
|
3
3
|
variables: FlowVariable[];
|
|
4
4
|
nodes: FlowStepNode[];
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
declare const _default: import("react").NamedExoticComponent<FlowVariablePanelProps>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RequestLogType } from '../../types/types.requestLog.js';
|
|
2
|
+
type RecordingReviewDialogProps = {
|
|
3
|
+
open: boolean;
|
|
4
|
+
requests: RequestLogType[];
|
|
5
|
+
onGenerate: (selectedRequests: RequestLogType[], flowName: string) => void;
|
|
6
|
+
onCancel: () => void;
|
|
7
|
+
};
|
|
8
|
+
export default function RecordingReviewDialog({ open, requests, onGenerate, onCancel, }: RecordingReviewDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -3,5 +3,5 @@ type ConditionNodeData = {
|
|
|
3
3
|
expression: string;
|
|
4
4
|
onSelect?: () => void;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
declare const _default: import("react").NamedExoticComponent<NodeProps<Node<ConditionNodeData>>>;
|
|
7
|
+
export default _default;
|
|
@@ -3,5 +3,5 @@ type DelayNodeData = {
|
|
|
3
3
|
durationMs: number;
|
|
4
4
|
onSelect?: () => void;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
declare const _default: import("react").NamedExoticComponent<NodeProps<Node<DelayNodeData>>>;
|
|
7
|
+
export default _default;
|
|
@@ -4,5 +4,5 @@ type ExtractNodeData = {
|
|
|
4
4
|
jsonPath: string;
|
|
5
5
|
onSelect?: () => void;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
export
|
|
7
|
+
declare const _default: import("react").NamedExoticComponent<NodeProps<Node<ExtractNodeData>>>;
|
|
8
|
+
export default _default;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { type Node, type NodeProps } from '@xyflow/react';
|
|
2
|
-
type RequestNodeData
|
|
3
|
-
|
|
4
|
-
path: string;
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
body?: string;
|
|
2
|
+
import type { RequestNodeData } from '../../../stores/flowStore.js';
|
|
3
|
+
type RequestNodeDataWithSelect = RequestNodeData & {
|
|
7
4
|
onSelect?: () => void;
|
|
8
5
|
};
|
|
9
|
-
|
|
10
|
-
export
|
|
6
|
+
declare const _default: import("react").NamedExoticComponent<NodeProps<Node<RequestNodeDataWithSelect>>>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Edge, type Node } from '@xyflow/react';
|
|
2
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
3
|
+
import type { FlowStepNode } from '../stores/flowStore.js';
|
|
4
|
+
type UseFlowKeyboardShortcutsArgs = {
|
|
5
|
+
selectedNode: FlowStepNode | null;
|
|
6
|
+
setSelectedNode: Dispatch<SetStateAction<FlowStepNode | null>>;
|
|
7
|
+
connectSource: string | null;
|
|
8
|
+
setConnectSource: Dispatch<SetStateAction<string | null>>;
|
|
9
|
+
setNodes: Dispatch<SetStateAction<Node[]>>;
|
|
10
|
+
setEdges: Dispatch<SetStateAction<Edge[]>>;
|
|
11
|
+
mousePosRef: React.RefObject<{
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
export declare function useFlowKeyboardShortcuts({ selectedNode, setSelectedNode, connectSource, setConnectSource, setNodes, setEdges, mousePosRef, }: UseFlowKeyboardShortcutsArgs): void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FlowDefinition } from '../stores/flowStore.js';
|
|
2
|
+
import type { RequestLogType } from '../types/types.requestLog.js';
|
|
3
|
+
type UseFlowRecordingReturn = {
|
|
4
|
+
isRecording: boolean;
|
|
5
|
+
recordedRequests: RequestLogType[];
|
|
6
|
+
showReviewDialog: boolean;
|
|
7
|
+
handleStartRecording: () => void;
|
|
8
|
+
handleStopRecording: () => void;
|
|
9
|
+
handleGenerateFlow: (selectedRequests: RequestLogType[], flowName: string) => FlowDefinition;
|
|
10
|
+
handleCancelRecording: () => void;
|
|
11
|
+
};
|
|
12
|
+
export declare function useFlowRecording(): UseFlowRecordingReturn;
|
|
13
|
+
export {};
|
|
@@ -6,6 +6,10 @@ export type RequestNodeData = {
|
|
|
6
6
|
headers?: Record<string, string>;
|
|
7
7
|
body?: string;
|
|
8
8
|
queryParams?: Record<string, string>;
|
|
9
|
+
/** Captured response output from a recorded request */
|
|
10
|
+
recordedOutput?: string;
|
|
11
|
+
/** Captured HTTP status from a recorded request */
|
|
12
|
+
recordedStatus?: number;
|
|
9
13
|
};
|
|
10
14
|
export type ConditionNodeData = {
|
|
11
15
|
expression: string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Edge, Node } from '@xyflow/react';
|
|
2
|
+
import type { FlowEdge, FlowNodeType, FlowStepNode, RequestNodeData } from '../stores/flowStore.js';
|
|
3
|
+
import type { RequestLogType } from '../types/types.requestLog.js';
|
|
4
|
+
export declare function toFlowStepNodes(nodes: Node[]): FlowStepNode[];
|
|
5
|
+
export declare function toFlowEdges(edges: Edge[]): FlowEdge[];
|
|
6
|
+
export declare const DEFAULT_NODE_DATA: Record<FlowNodeType, () => unknown>;
|
|
7
|
+
/** POST/PUT/PATCH get prefilled Content-Type header and body template */
|
|
8
|
+
export declare function makeRequestData(method: string): RequestNodeData;
|
|
9
|
+
export declare const SHORTCUT_MAP: Record<string, FlowNodeType>;
|
|
10
|
+
export declare const SHORTCUT_LABELS: Record<FlowNodeType, string>;
|
|
11
|
+
export type DuplicateGroup = {
|
|
12
|
+
/** The canonical request (first occurrence) */
|
|
13
|
+
canonical: RequestLogType;
|
|
14
|
+
/** All duplicates of the canonical (same method+path+body+query signature) */
|
|
15
|
+
duplicates: RequestLogType[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Detect duplicate/near-duplicate HTTP requests in an array of request logs.
|
|
19
|
+
*
|
|
20
|
+
* Two requests are considered duplicates if they share the same method, path,
|
|
21
|
+
* stringified body, and stringified query. Headers are intentionally excluded
|
|
22
|
+
* because they often differ due to timestamps, auth tokens, etc.
|
|
23
|
+
*
|
|
24
|
+
* @returns An array of {@link DuplicateGroup} objects, one per group that has
|
|
25
|
+
* 2 or more members. The first occurrence is the `canonical` and the rest
|
|
26
|
+
* are in `duplicates`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function detectDuplicates(requests: RequestLogType[]): DuplicateGroup[];
|
|
29
|
+
/**
|
|
30
|
+
* Convert a recorded HTTP request log entry into a cURL command string.
|
|
31
|
+
* Useful for exporting requests from the history panel or flow recorder.
|
|
32
|
+
*/
|
|
33
|
+
export declare function requestToCurl(req: RequestLogType): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FlowEdge, FlowStepNode } from '../stores/flowStore.js';
|
|
2
|
+
export type PresetTemplate = {
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
build: () => {
|
|
6
|
+
name: string;
|
|
7
|
+
nodes: FlowStepNode[];
|
|
8
|
+
edges: FlowEdge[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const PRESET_TEMPLATES: PresetTemplate[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FlowDefinition } from '../stores/flowStore.js';
|
|
2
|
+
import type { RequestLogType } from '../types/types.requestLog.js';
|
|
3
|
+
export declare function generateFlowFromRequests(requests: RequestLogType[], flowName: string, options?: {
|
|
4
|
+
addAssertions?: boolean;
|
|
5
|
+
}): FlowDefinition;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./vendor-xyflow.js";import{R as t}from"./docs.js";const h=t(o.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}));export{h as A};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as b,m as Ge}from"./vendor-recharts.js";import{A as Ft,f as xe,i as ue,o as Ct,a as ut}from"./PageContainer.js";import{ba as Vt,K as ct,bb as Ue,bc as Ht,I as wt,J as Rt,U as Dt,M as Ke,N as Tt,O as E,W as ce,bd as zt,L as dt,b1 as Mt,be as Nt,j as jt,a1 as Et}from"./docs.js";import{j as x}from"./vendor-xyflow.js";function Wt(o){const r=b.useRef({});return b.useEffect(()=>{r.current=o}),r.current}function $t({array1:o,array2:r,parser:p=f=>f}){return o&&r&&o.length===r.length&&o.every((f,C)=>p(f)===p(r[C]))}function St(o){return o.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function Bt(o={}){const{ignoreAccents:r=!0,ignoreCase:p=!0,limit:f,matchFrom:C="any",stringify:w,trim:L=!1}=o;return(R,{inputValue:W,getOptionLabel:F})=>{let S=L?W.trim():W;p&&(S=S.toLowerCase()),r&&(S=St(S));const B=S?R.filter(de=>{let D=(w||F)(de);return p&&(D=D.toLowerCase()),r&&(D=St(D)),C==="start"?D.startsWith(S):D.includes(S)}):R;return typeof f=="number"?B.slice(0,f):B}}const Ut=Bt(),At=5,Gt=o=>{var r;return o.current!==null&&((r=o.current.parentElement)==null?void 0:r.contains(document.activeElement))},Kt=[];function Lt(o,r,p,f){if(r||o==null||f)return"";const C=p(o);return typeof C=="string"?C:""}function qt(o){const{unstable_isActiveElementInListbox:r=Gt,unstable_classNamePrefix:p="Mui",autoComplete:f=!1,autoHighlight:C=!1,autoSelect:w=!1,blurOnSelect:L=!1,clearOnBlur:R=!o.freeSolo,clearOnEscape:W=!1,componentName:F="useAutocomplete",defaultValue:S=o.multiple?Kt:null,disableClearable:B=!1,disableCloseOnSelect:de=!1,disabled:D,disabledItemsFocusable:ke=!1,disableListWrap:ve=!1,filterOptions:gt=Ut,filterSelectedOptions:qe=!1,freeSolo:Y=!1,getOptionDisabled:U,getOptionKey:we,getOptionLabel:_e=t=>t.label??t,groupBy:re,handleHomeEndKeys:Je=!o.freeSolo,id:ht,includeInputInList:Ie=!1,inputValue:Re,isOptionEqualToValue:se=(t,e)=>t===e,multiple:u=!1,onChange:Qe,onClose:Xe,onHighlightChange:De,onInputChange:M,onOpen:Te,open:bt,openOnFocus:mt=!1,options:xt,readOnly:K=!1,renderValue:k,selectOnFocus:Ye=!o.freeSolo,value:Me}=o,T=Vt(ht);let I=_e;I=t=>{const e=_e(t);return typeof e!="string"?String(e):e};const ye=b.useRef(!1),Pe=b.useRef(!0),y=b.useRef(null),N=b.useRef(null),[Oe,It]=b.useState(null),[v,ae]=b.useState(-1),Ze=C?0:-1,$=b.useRef(Ze),yt=b.useRef(Lt(S??Me,u,I)).current,[s,et]=ct({controlled:Me,default:S,name:F}),[d,q]=ct({controlled:Re,default:yt,name:F,state:"inputValue"}),[fe,Ne]=b.useState(!1),ge=b.useCallback((t,e,n)=>{if(!(u?s.length<e.length:e!==null)&&!R)return;const i=Lt(e,u,I,k);d!==i&&(q(i),M&&M(t,i,n))},[I,d,u,M,q,R,s,k]),[_,ie]=ct({controlled:bt,default:!1,name:F,state:"open"}),[Pt,he]=b.useState(!0),Ee=!u&&s!=null&&d===I(s),A=_&&!K,g=A?gt(xt.filter(t=>!(qe&&(u?s:[s]).some(e=>e!==null&&se(t,e)))),{inputValue:Ee&&Pt?"":d,getOptionLabel:I}):[],V=Wt({filteredOptions:g,value:s,inputValue:d});b.useEffect(()=>{const t=s!==V.value;fe&&!t||Y&&!t||ge(null,s,"reset")},[s,ge,fe,V.value,Y]);const Fe=_&&g.length>0&&!K,G=Ue(t=>{if(t===-1)y.current.focus();else{const e=k?"data-item-index":"data-tag-index";Oe.querySelector(`[${e}="${t}"]`).focus()}});b.useEffect(()=>{u&&v>s.length-1&&(ae(-1),G(-1))},[s,u,v,G]);function tt(t,e){if(!N.current||t<0||t>=g.length)return-1;let n=t;for(;;){const a=N.current.querySelector(`[data-option-index="${n}"]`),i=ke?!1:!a||a.disabled||a.getAttribute("aria-disabled")==="true";if(a&&a.hasAttribute("tabindex")&&!i)return n;if(e==="next"?n=(n+1)%g.length:n=(n-1+g.length)%g.length,n===t)return-1}}const J=Ue(({event:t,index:e,reason:n})=>{if($.current=e,e===-1?y.current.removeAttribute("aria-activedescendant"):y.current.setAttribute("aria-activedescendant",`${T}-option-${e}`),De&&["mouse","keyboard","touch"].includes(n)&&De(t,e===-1?null:g[e],n),!N.current)return;const a=N.current.querySelector(`[role="option"].${p}-focused`);a&&(a.classList.remove(`${p}-focused`),a.classList.remove(`${p}-focusVisible`));let i=N.current;if(N.current.getAttribute("role")!=="listbox"&&(i=N.current.parentElement.querySelector('[role="listbox"]')),!i)return;if(e===-1){i.scrollTop=0;return}const O=N.current.querySelector(`[data-option-index="${e}"]`);if(O&&(O.classList.add(`${p}-focused`),n==="keyboard"&&O.classList.add(`${p}-focusVisible`),i.scrollHeight>i.clientHeight&&n!=="mouse"&&n!=="touch")){const h=O,j=i.clientHeight+i.scrollTop,je=h.offsetTop+h.offsetHeight;je>j?i.scrollTop=je-i.clientHeight:h.offsetTop-h.offsetHeight*(re?1.3:0)<i.scrollTop&&(i.scrollTop=h.offsetTop-h.offsetHeight*(re?1.3:0))}}),H=Ue(({event:t,diff:e,direction:n="next",reason:a})=>{if(!A)return;const O=tt((()=>{const h=g.length-1;if(e==="reset")return Ze;if(e==="start")return 0;if(e==="end")return h;const j=$.current+e;return j<0?j===-1&&Ie?-1:ve&&$.current!==-1||Math.abs(e)>1?0:h:j>h?j===h+1&&Ie?-1:ve||Math.abs(e)>1?h:0:j})(),n);if(J({index:O,reason:a,event:t}),f&&e!=="reset")if(O===-1)y.current.value=d;else{const h=I(g[O]);y.current.value=h,h.toLowerCase().indexOf(d.toLowerCase())===0&&d.length>0&&y.current.setSelectionRange(d.length,h.length)}}),Ve=!$t({array1:V.filteredOptions,array2:g,parser:I}),ot=()=>{const t=(e,n)=>{const a=e?I(e):"",i=n?I(n):"";return a===i};if($.current!==-1&&!$t({array1:V.filteredOptions,array2:g,parser:I})&&V.inputValue===d&&(u?s.length===V.value.length&&V.value.every((e,n)=>I(s[n])===I(e)):t(V.value,s))){const e=V.filteredOptions[$.current];if(e)return g.findIndex(n=>I(n)===I(e))}return-1},Ce=b.useCallback(()=>{if(!A)return;const t=ot();if(t!==-1){$.current=t;return}const e=u?s[0]:s;if(g.length===0||e==null){H({diff:"reset"});return}if(N.current){if(e!=null){const n=g[$.current];if(u&&n&&s.findIndex(i=>se(n,i))!==-1)return;const a=g.findIndex(i=>se(i,e));a===-1?H({diff:"reset"}):J({index:a});return}if($.current>=g.length-1){J({index:g.length-1});return}J({index:$.current})}},[g.length,u?!1:s,H,J,A,d,u]),Z=Ue(t=>{Ht(N,t),t&&Ce()});b.useEffect(()=>{(Ve||A)&&Ce()},[Ce,Ve,A]);const Q=t=>{_||(ie(!0),he(!0),Te&&Te(t))},le=(t,e)=>{_&&(ie(!1),Xe&&Xe(t,e))},z=(t,e,n,a)=>{if(u){if(s.length===e.length&&s.every((i,O)=>i===e[O]))return}else if(s===e)return;Qe&&Qe(t,e,n,a),et(e)},X=b.useRef(!1),ee=(t,e,n="selectOption",a="options")=>{let i=n,O=e;if(u){O=Array.isArray(s)?s.slice():[];const h=O.findIndex(j=>se(e,j));h===-1?O.push(e):a!=="freeSolo"&&(O.splice(h,1),i="removeOption")}ge(t,O,i),z(t,O,i,{option:e}),!de&&(!t||!t.ctrlKey&&!t.metaKey)&&le(t,i),(L===!0||L==="touch"&&X.current||L==="mouse"&&!X.current)&&y.current.blur()};function nt(t,e){if(t===-1)return-1;let n=t;for(;;){if(e==="next"&&n===s.length||e==="previous"&&n===-1)return-1;const a=k?"data-item-index":"data-tag-index",i=Oe.querySelector(`[${a}="${n}"]`);if(!i||!i.hasAttribute("tabindex")||i.disabled||i.getAttribute("aria-disabled")==="true")n+=e==="next"?1:-1;else return n}}const pe=(t,e)=>{if(!u)return;d===""&&le(t,"toggleInput");let n=v;v===-1&&e==="previous"?(n=s.length-1,Y&&d!==""&&(q(""),M&&M(t,"","reset"))):(n+=e==="next"?1:-1,n<0&&(n=0),n===s.length&&(n=-1)),n=nt(n,e),ae(n),G(n)},He=t=>{ye.current=!0,q(""),M&&M(t,"","clear"),z(t,u?[]:null,"clear")},rt=t=>e=>{if(t.onKeyDown&&t.onKeyDown(e),!e.defaultMuiPrevented&&(v!==-1&&!["ArrowLeft","ArrowRight"].includes(e.key)&&(ae(-1),G(-1)),e.which!==229))switch(e.key){case"Home":A&&Je&&(e.preventDefault(),H({diff:"start",direction:"next",reason:"keyboard",event:e}));break;case"End":A&&Je&&(e.preventDefault(),H({diff:"end",direction:"previous",reason:"keyboard",event:e}));break;case"PageUp":e.preventDefault(),H({diff:-At,direction:"previous",reason:"keyboard",event:e}),Q(e);break;case"PageDown":e.preventDefault(),H({diff:At,direction:"next",reason:"keyboard",event:e}),Q(e);break;case"ArrowDown":e.preventDefault(),H({diff:1,direction:"next",reason:"keyboard",event:e}),Q(e);break;case"ArrowUp":e.preventDefault(),H({diff:-1,direction:"previous",reason:"keyboard",event:e}),Q(e);break;case"ArrowLeft":{const n=y.current;if(!(n&&n.selectionStart===0&&n.selectionEnd===0))return;!u&&k&&s!=null?(Y&&d!==""&&(q(""),M&&M(e,"","reset")),ae(0),G(0)):pe(e,"previous");break}case"ArrowRight":!u&&k?(ae(-1),G(-1)):pe(e,"next");break;case"Enter":if($.current!==-1&&A){const n=g[$.current],a=U?U(n):!1;if(e.preventDefault(),a)return;ee(e,n,"selectOption"),f&&y.current.setSelectionRange(y.current.value.length,y.current.value.length)}else Y&&d!==""&&Ee===!1&&(u&&e.preventDefault(),ee(e,d,"createOption","freeSolo"));break;case"Escape":A?(e.preventDefault(),e.stopPropagation(),le(e,"escape")):W&&(d!==""||u&&s.length>0||k)&&(e.preventDefault(),e.stopPropagation(),He(e));break;case"Backspace":if(u&&!K&&d===""&&s.length>0){const n=v===-1?s.length-1:v,a=s.slice();a.splice(n,1),z(e,a,"removeOption",{option:s[n]})}!u&&k&&!K&&d===""&&z(e,null,"removeOption",{option:s});break;case"Delete":if(u&&!K&&d===""&&s.length>0&&v!==-1){const n=v,a=s.slice();a.splice(n,1),z(e,a,"removeOption",{option:s[n]})}!u&&k&&!K&&d===""&&z(e,null,"removeOption",{option:s});break}},be=t=>{Ne(!0),v!==-1&&(ae(-1),G(-1)),mt&&!ye.current&&Q(t)},me=t=>{if(r(N)){y.current.focus();return}Ne(!1),Pe.current=!0,ye.current=!1,w&&$.current!==-1&&A?ee(t,g[$.current],"blur"):w&&Y&&d!==""?ee(t,d,"blur","freeSolo"):R&&ge(t,s,"blur"),le(t,"blur")},$e=t=>{const e=t.target.value;d!==e&&(q(e),he(!1),M&&M(t,e,"input")),e===""?!B&&!u&&!k&&z(t,null,"clear"):Q(t)},st=t=>{const e=Number(t.currentTarget.getAttribute("data-option-index"));$.current!==e&&J({event:t,index:e,reason:"mouse"})},at=t=>{J({event:t,index:Number(t.currentTarget.getAttribute("data-option-index")),reason:"touch"}),X.current=!0},it=t=>{const e=Number(t.currentTarget.getAttribute("data-option-index"));ee(t,g[e],"selectOption"),X.current=!1},lt=t=>e=>{const n=s.slice();n.splice(t,1),z(e,n,"removeOption",{option:s[t]})},Se=t=>{z(t,null,"removeOption",{option:s})},m=t=>{_?le(t,"toggleInput"):Q(t)},P=t=>{t.currentTarget.contains(t.target)&&t.target.getAttribute("id")!==T&&t.preventDefault()},te=t=>{t.currentTarget.contains(t.target)&&(y.current.focus(),Ye&&Pe.current&&y.current.selectionEnd-y.current.selectionStart===0&&y.current.select(),Pe.current=!1)},pt=t=>{!D&&(d===""||!_)&&m(t)};let Ae=Y&&d.length>0;Ae=Ae||(u?s.length>0:s!==null);let ze=g;return re&&(ze=g.reduce((t,e,n)=>{const a=re(e);return t.length>0&&t[t.length-1].group===a?t[t.length-1].options.push(e):t.push({key:n,index:n,group:a,options:[e]}),t},[])),D&&fe&&me(),{getRootProps:(t={})=>({...t,onKeyDown:rt(t),onMouseDown:P,onClick:te}),getInputLabelProps:()=>({id:`${T}-label`,htmlFor:T}),getInputProps:()=>({id:T,value:d,onBlur:me,onFocus:be,onChange:$e,onMouseDown:pt,"aria-activedescendant":A?"":null,"aria-autocomplete":f?"both":"list","aria-controls":Fe?`${T}-listbox`:void 0,"aria-expanded":Fe,autoComplete:"off",ref:y,autoCapitalize:"none",spellCheck:"false",role:"combobox",disabled:D}),getClearProps:()=>({tabIndex:-1,type:"button",onClick:He}),getItemProps:({index:t=0}={})=>({...u&&{key:t},...k?{"data-item-index":t}:{"data-tag-index":t},tabIndex:-1,...!K&&{onDelete:u?lt(t):Se}}),getPopupIndicatorProps:()=>({tabIndex:-1,type:"button",onClick:m}),getTagProps:({index:t})=>({key:t,"data-tag-index":t,tabIndex:-1,...!K&&{onDelete:lt(t)}}),getListboxProps:()=>({role:"listbox",id:`${T}-listbox`,"aria-labelledby":`${T}-label`,ref:Z,onMouseDown:t=>{t.preventDefault()}}),getOptionProps:({index:t,option:e})=>{const n=(u?s:[s]).some(i=>i!=null&&se(e,i)),a=U?U(e):!1;return{key:(we==null?void 0:we(e))??I(e),tabIndex:-1,role:"option",id:`${T}-option-${t}`,onMouseMove:st,onClick:it,onTouchStart:at,"data-option-index":t,"aria-disabled":a,"aria-selected":n}},id:T,inputValue:d,value:s,dirty:Ae,expanded:A&&Oe,popupOpen:A,focused:fe||v!==-1,anchorEl:Oe,setAnchorEl:It,focusedItem:v,focusedTag:v,groupedOptions:ze}}function _t(o){return wt("MuiListSubheader",o)}Rt("MuiListSubheader",["root","colorPrimary","colorInherit","gutters","inset","sticky"]);const Jt=o=>{const{classes:r,color:p,disableGutters:f,inset:C,disableSticky:w}=o,L={root:["root",p!=="default"&&`color${Ke(p)}`,!f&&"gutters",C&&"inset",!w&&"sticky"]};return Tt(L,_t,r)},Qt=E("li",{name:"MuiListSubheader",slot:"Root",overridesResolver:(o,r)=>{const{ownerState:p}=o;return[r.root,p.color!=="default"&&r[`color${Ke(p.color)}`],!p.disableGutters&&r.gutters,p.inset&&r.inset,!p.disableSticky&&r.sticky]}})(ce(({theme:o})=>({boxSizing:"border-box",lineHeight:"48px",listStyle:"none",color:(o.vars||o).palette.text.secondary,fontFamily:o.typography.fontFamily,fontWeight:o.typography.fontWeightMedium,fontSize:o.typography.pxToRem(14),variants:[{props:{color:"primary"},style:{color:(o.vars||o).palette.primary.main}},{props:{color:"inherit"},style:{color:"inherit"}},{props:({ownerState:r})=>!r.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:r})=>r.inset,style:{paddingLeft:72}},{props:({ownerState:r})=>!r.disableSticky,style:{position:"sticky",top:0,zIndex:1,backgroundColor:(o.vars||o).palette.background.paper}}]}))),ft=b.forwardRef(function(r,p){const f=Dt({props:r,name:"MuiListSubheader"}),{className:C,color:w="default",component:L="li",disableGutters:R=!1,disableSticky:W=!1,inset:F=!1,...S}=f,B={...f,color:w,component:L,disableGutters:R,disableSticky:W,inset:F},de=Jt(B);return x.jsx(Qt,{as:L,className:Ge(de.root,C),ref:p,ownerState:B,...S})});ft&&(ft.muiSkipListHighlight=!0);function Xt(o){return wt("MuiAutocomplete",o)}const l=Rt("MuiAutocomplete",["root","expanded","fullWidth","focused","focusVisible","tag","tagSizeSmall","tagSizeMedium","hasPopupIcon","hasClearIcon","inputRoot","input","inputFocused","endAdornment","clearIndicator","popupIndicator","popupIndicatorOpen","popper","popperDisablePortal","paper","listbox","loading","noOptions","option","groupLabel","groupUl"]);var kt,vt;const Yt=o=>{const{classes:r,disablePortal:p,expanded:f,focused:C,fullWidth:w,hasClearIcon:L,hasPopupIcon:R,inputFocused:W,popupOpen:F,size:S}=o,B={root:["root",f&&"expanded",C&&"focused",w&&"fullWidth",L&&"hasClearIcon",R&&"hasPopupIcon"],inputRoot:["inputRoot"],input:["input",W&&"inputFocused"],tag:["tag",`tagSize${Ke(S)}`],endAdornment:["endAdornment"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",F&&"popupIndicatorOpen"],popper:["popper",p&&"popperDisablePortal"],paper:["paper"],listbox:["listbox"],loading:["loading"],noOptions:["noOptions"],option:["option"],groupLabel:["groupLabel"],groupUl:["groupUl"]};return Tt(B,Xt,r)},Zt=E("div",{name:"MuiAutocomplete",slot:"Root",overridesResolver:(o,r)=>{const{ownerState:p}=o,{fullWidth:f,hasClearIcon:C,hasPopupIcon:w,inputFocused:L,size:R}=p;return[{[`& .${l.tag}`]:r.tag},{[`& .${l.tag}`]:r[`tagSize${Ke(R)}`]},{[`& .${l.inputRoot}`]:r.inputRoot},{[`& .${l.input}`]:r.input},{[`& .${l.input}`]:L&&r.inputFocused},r.root,f&&r.fullWidth,w&&r.hasPopupIcon,C&&r.hasClearIcon]}})({[`&.${l.focused} .${l.clearIndicator}`]:{visibility:"visible"},"@media (pointer: fine)":{[`&:hover .${l.clearIndicator}`]:{visibility:"visible"}},[`& .${l.tag}`]:{margin:3,maxWidth:"calc(100% - 6px)"},[`& .${l.inputRoot}`]:{[`.${l.hasPopupIcon}&, .${l.hasClearIcon}&`]:{paddingRight:30},[`.${l.hasPopupIcon}.${l.hasClearIcon}&`]:{paddingRight:56},[`& .${l.input}`]:{width:0,minWidth:30}},[`& .${ut.root}`]:{paddingBottom:1,"& .MuiInput-input":{padding:"4px 4px 4px 0px"}},[`& .${ut.root}.${ue.sizeSmall}`]:{[`& .${ut.input}`]:{padding:"2px 4px 3px 0"}},[`& .${Ct.root}`]:{padding:9,[`.${l.hasPopupIcon}&, .${l.hasClearIcon}&`]:{paddingRight:39},[`.${l.hasPopupIcon}.${l.hasClearIcon}&`]:{paddingRight:65},[`& .${l.input}`]:{padding:"7.5px 4px 7.5px 5px"},[`& .${l.endAdornment}`]:{right:9}},[`& .${Ct.root}.${ue.sizeSmall}`]:{paddingTop:6,paddingBottom:6,paddingLeft:6,[`& .${l.input}`]:{padding:"2.5px 4px 2.5px 8px"}},[`& .${xe.root}`]:{paddingTop:19,paddingLeft:8,[`.${l.hasPopupIcon}&, .${l.hasClearIcon}&`]:{paddingRight:39},[`.${l.hasPopupIcon}.${l.hasClearIcon}&`]:{paddingRight:65},[`& .${xe.input}`]:{padding:"7px 4px"},[`& .${l.endAdornment}`]:{right:9}},[`& .${xe.root}.${ue.sizeSmall}`]:{paddingBottom:1,[`& .${xe.input}`]:{padding:"2.5px 4px"}},[`& .${ue.hiddenLabel}`]:{paddingTop:8},[`& .${xe.root}.${ue.hiddenLabel}`]:{paddingTop:0,paddingBottom:0,[`& .${l.input}`]:{paddingTop:16,paddingBottom:17}},[`& .${xe.root}.${ue.hiddenLabel}.${ue.sizeSmall}`]:{[`& .${l.input}`]:{paddingTop:8,paddingBottom:9}},[`& .${l.input}`]:{flexGrow:1,textOverflow:"ellipsis",opacity:0},variants:[{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{[`& .${l.tag}`]:{margin:2,maxWidth:"calc(100% - 4px)"}}},{props:{inputFocused:!0},style:{[`& .${l.input}`]:{opacity:1}}},{props:{multiple:!0},style:{[`& .${l.inputRoot}`]:{flexWrap:"wrap"}}}]}),eo=E("div",{name:"MuiAutocomplete",slot:"EndAdornment"})({position:"absolute",right:0,top:"50%",transform:"translate(0, -50%)"}),to=E(Et,{name:"MuiAutocomplete",slot:"ClearIndicator"})({marginRight:-2,padding:4,visibility:"hidden"}),oo=E(Et,{name:"MuiAutocomplete",slot:"PopupIndicator",overridesResolver:(o,r)=>{const{ownerState:p}=o;return[r.popupIndicator,p.popupOpen&&r.popupIndicatorOpen]}})({padding:2,marginRight:-2,variants:[{props:{popupOpen:!0},style:{transform:"rotate(180deg)"}}]}),no=E(Nt,{name:"MuiAutocomplete",slot:"Popper",overridesResolver:(o,r)=>{const{ownerState:p}=o;return[{[`& .${l.option}`]:r.option},r.popper,p.disablePortal&&r.popperDisablePortal]}})(ce(({theme:o})=>({zIndex:(o.vars||o).zIndex.modal,variants:[{props:{disablePortal:!0},style:{position:"absolute"}}]}))),ro=E(Mt,{name:"MuiAutocomplete",slot:"Paper"})(ce(({theme:o})=>({...o.typography.body1,overflow:"auto"}))),so=E("div",{name:"MuiAutocomplete",slot:"Loading"})(ce(({theme:o})=>({color:(o.vars||o).palette.text.secondary,padding:"14px 16px"}))),ao=E("div",{name:"MuiAutocomplete",slot:"NoOptions"})(ce(({theme:o})=>({color:(o.vars||o).palette.text.secondary,padding:"14px 16px"}))),io=E("ul",{name:"MuiAutocomplete",slot:"Listbox"})(ce(({theme:o})=>({listStyle:"none",margin:0,padding:"8px 0",maxHeight:"40vh",overflow:"auto",position:"relative",[`& .${l.option}`]:{minHeight:48,display:"flex",overflow:"hidden",justifyContent:"flex-start",alignItems:"center",cursor:"pointer",paddingTop:6,boxSizing:"border-box",outline:"0",WebkitTapHighlightColor:"transparent",paddingBottom:6,paddingLeft:16,paddingRight:16,[o.breakpoints.up("sm")]:{minHeight:"auto"},[`&.${l.focused}`]:{backgroundColor:(o.vars||o).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},'&[aria-disabled="true"]':{opacity:(o.vars||o).palette.action.disabledOpacity,pointerEvents:"none"},[`&.${l.focusVisible}`]:{backgroundColor:(o.vars||o).palette.action.focus},'&[aria-selected="true"]':{backgroundColor:o.alpha((o.vars||o).palette.primary.main,(o.vars||o).palette.action.selectedOpacity),[`&.${l.focused}`]:{backgroundColor:o.alpha((o.vars||o).palette.primary.main,`${(o.vars||o).palette.action.selectedOpacity} + ${(o.vars||o).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:(o.vars||o).palette.action.selected}},[`&.${l.focusVisible}`]:{backgroundColor:o.alpha((o.vars||o).palette.primary.main,`${(o.vars||o).palette.action.selectedOpacity} + ${(o.vars||o).palette.action.focusOpacity}`)}}}}))),lo=E(ft,{name:"MuiAutocomplete",slot:"GroupLabel"})(ce(({theme:o})=>({backgroundColor:(o.vars||o).palette.background.paper,top:-8}))),po=E("ul",{name:"MuiAutocomplete",slot:"GroupUl"})({padding:0,[`& .${l.option}`]:{paddingLeft:24}}),ho=b.forwardRef(function(r,p){const f=Dt({props:r,name:"MuiAutocomplete"}),{autoComplete:C=!1,autoHighlight:w=!1,autoSelect:L=!1,blurOnSelect:R=!1,ChipProps:W,className:F,clearIcon:S=kt||(kt=x.jsx(zt,{fontSize:"small"})),clearOnBlur:B=!f.freeSolo,clearOnEscape:de=!1,clearText:D="Clear",closeText:ke="Close",componentsProps:ve,defaultValue:gt=f.multiple?[]:null,disableClearable:qe=!1,disableCloseOnSelect:Y=!1,disabled:U=!1,disabledItemsFocusable:we=!1,disableListWrap:_e=!1,disablePortal:re=!1,filterOptions:Je,filterSelectedOptions:ht=!1,forcePopupIcon:Ie="auto",freeSolo:Re=!1,fullWidth:se=!1,getLimitTagsText:u=c=>`+${c}`,getOptionDisabled:Qe,getOptionKey:Xe,getOptionLabel:De,isOptionEqualToValue:M,groupBy:Te,handleHomeEndKeys:bt=!f.freeSolo,id:mt,includeInputInList:xt=!1,inputValue:K,limitTags:k=-1,ListboxComponent:Ye,ListboxProps:Me,loading:T=!1,loadingText:I="Loading…",multiple:ye=!1,noOptionsText:Pe="No options",onChange:y,onClose:N,onHighlightChange:Oe,onInputChange:It,onOpen:v,open:ae,openOnFocus:Ze=!1,openText:$="Open",options:yt,PaperComponent:s,PopperComponent:et,popupIcon:d=vt||(vt=x.jsx(Ft,{})),readOnly:q=!1,renderGroup:fe,renderInput:Ne,renderOption:ge,renderTags:_,renderValue:ie,selectOnFocus:Pt=!f.freeSolo,size:he="medium",slots:Ee={},slotProps:A={},value:g,...V}=f,{getRootProps:Fe,getInputProps:G,getInputLabelProps:tt,getPopupIndicatorProps:J,getClearProps:H,getItemProps:Ve,getListboxProps:ot,getOptionProps:Ce,value:Z,dirty:Q,expanded:le,id:z,popupOpen:X,focused:ee,focusedItem:nt,anchorEl:pe,setAnchorEl:He,inputValue:rt,groupedOptions:be}=qt({...f,componentName:"Autocomplete"}),me=!qe&&!U&&Q&&!q,$e=(!Re||Ie===!0)&&Ie!==!1,{onMouseDown:st}=G(),{ref:at,...it}=ot(),Se=De||(c=>c.label??c),m={...f,disablePortal:re,expanded:le,focused:ee,fullWidth:se,getOptionLabel:Se,hasClearIcon:me,hasPopupIcon:$e,inputFocused:nt===-1,popupOpen:X,size:he},P=Yt(m),te={slots:{paper:s,popper:et,...Ee},slotProps:{chip:W,listbox:Me,...ve,...A}},[pt,Ae]=dt("listbox",{elementType:io,externalForwardedProps:te,ownerState:m,className:P.listbox,additionalProps:it,ref:at}),[ze,t]=dt("paper",{elementType:Mt,externalForwardedProps:te,ownerState:m,className:P.paper}),[e,n]=dt("popper",{elementType:Nt,externalForwardedProps:te,ownerState:m,className:P.popper,additionalProps:{disablePortal:re,style:{width:pe?pe.clientWidth:null},role:"presentation",anchorEl:pe,open:X}});let a;const i=c=>({className:P.tag,disabled:U,...Ve(c)});if(ye?Z.length>0&&(_?a=_(Z,i,m):ie?a=ie(Z,i,m):a=Z.map((c,oe)=>{const{key:ne,...Le}=i({index:oe});return x.jsx(jt,{label:Se(c),size:he,...Le,...te.slotProps.chip},ne)})):ie&&Z!=null&&(a=ie(Z,i,m)),k>-1&&Array.isArray(a)){const c=a.length-k;!ee&&c>0&&(a=a.splice(0,k),a.push(x.jsx("span",{className:P.tag,children:u(c)},a.length)))}const h=fe||(c=>x.jsxs("li",{children:[x.jsx(lo,{className:P.groupLabel,ownerState:m,component:"div",children:c.group}),x.jsx(po,{className:P.groupUl,ownerState:m,children:c.children})]},c.key)),je=ge||((c,oe)=>{const{key:ne,...Le}=c;return x.jsx("li",{...Le,children:Se(oe)},ne)}),Ot=(c,oe)=>{const ne=Ce({option:c,index:oe});return je({...ne,className:P.option},c,{selected:ne["aria-selected"],index:oe,inputValue:rt},m)},We=te.slotProps.clearIndicator,Be=te.slotProps.popupIndicator;return x.jsxs(b.Fragment,{children:[x.jsx(Zt,{ref:p,className:Ge(P.root,F),ownerState:m,...Fe(V),children:Ne({id:z,disabled:U,fullWidth:!0,size:he==="small"?"small":void 0,InputLabelProps:tt(),InputProps:{ref:He,className:P.inputRoot,startAdornment:a,onMouseDown:c=>{c.target===c.currentTarget&&st(c)},...(me||$e)&&{endAdornment:x.jsxs(eo,{className:P.endAdornment,ownerState:m,children:[me?x.jsx(to,{...H(),"aria-label":D,title:D,ownerState:m,...We,className:Ge(P.clearIndicator,We==null?void 0:We.className),children:S}):null,$e?x.jsx(oo,{...J(),disabled:U,"aria-label":X?ke:$,title:X?ke:$,ownerState:m,...Be,className:Ge(P.popupIndicator,Be==null?void 0:Be.className),children:d}):null]})}},inputProps:{className:P.input,disabled:U,readOnly:q,...G()}})}),pe?x.jsx(no,{as:e,...n,children:x.jsxs(ro,{as:ze,...t,children:[T&&be.length===0?x.jsx(so,{className:P.loading,ownerState:m,children:I}):null,be.length===0&&!Re&&!T?x.jsx(ao,{className:P.noOptions,ownerState:m,role:"presentation",onMouseDown:c=>{c.preventDefault()},children:Pe}):null,be.length>0?x.jsx(pt,{as:Ye,...Ae,children:be.map((c,oe)=>Te?h({key:c.key,group:c.group,children:c.options.map((ne,Le)=>Ot(ne,c.index+Le))}):Ot(c,oe))}):null]})}):null]})});export{ho as A};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./vendor-xyflow.js";import{I as B,J as U,U as $,T as G,M as S,N as K,O as V,W as H,R as I,a1 as F,j as _,h as Q,C as J,S as v,G as A,E as X,a3 as T,Z,k as q}from"./docs.js";import{R as Y}from"./useQueryState.js";import{h,m as ee}from"./vendor-recharts.js";import{u as te,F as ne,T as b}from"./PageContainer.js";import{A as se}from"./Autocomplete.js";function oe(e){return B("MuiInputAdornment",e)}const P=U("MuiInputAdornment",["root","filled","standard","outlined","positionStart","positionEnd","disablePointerEvents","hiddenLabel","sizeSmall"]);var w;const re=(e,n)=>{const{ownerState:s}=e;return[n.root,n[`position${S(s.position)}`],s.disablePointerEvents===!0&&n.disablePointerEvents,n[s.variant]]},ae=e=>{const{classes:n,disablePointerEvents:s,hiddenLabel:r,position:a,size:i,variant:l}=e,u={root:["root",s&&"disablePointerEvents",a&&`position${S(a)}`,l,r&&"hiddenLabel",i&&`size${S(i)}`]};return K(u,oe,n)},ie=V("div",{name:"MuiInputAdornment",slot:"Root",overridesResolver:re})(H(({theme:e})=>({display:"flex",maxHeight:"2em",alignItems:"center",whiteSpace:"nowrap",color:(e.vars||e).palette.action.active,variants:[{props:{variant:"filled"},style:{[`&.${P.positionStart}&:not(.${P.hiddenLabel})`]:{marginTop:16}}},{props:{position:"start"},style:{marginRight:8}},{props:{position:"end"},style:{marginLeft:8}},{props:{disablePointerEvents:!0},style:{pointerEvents:"none"}}]}))),N=h.forwardRef(function(n,s){const r=$({props:n,name:"MuiInputAdornment"}),{children:a,className:i,component:l="div",disablePointerEvents:u=!1,disableTypography:p=!1,position:f,variant:C,...d}=r,m=te()||{};let x=C;C&&m.variant,m&&!x&&(x=m.variant);const y={...r,hiddenLabel:m.hiddenLabel,size:m.size,disablePointerEvents:u,position:f,variant:x},g=ae(y);return t.jsx(ne.Provider,{value:null,children:t.jsx(ie,{as:l,ownerState:y,className:ee(g.root,i),ref:s,...d,children:typeof a=="string"&&!p?t.jsx(G,{color:"textSecondary",children:a}):t.jsxs(h.Fragment,{children:[f==="start"?w||(w=t.jsx("span",{className:"notranslate","aria-hidden":!0,children:""})):null,a]})})})}),le=I(t.jsx("path",{d:"M4.25 5.61C6.27 8.2 10 13 10 13v6c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-6s3.72-4.8 5.74-7.39c.51-.66.04-1.61-.79-1.61H5.04c-.83 0-1.3.95-.79 1.61"})),de=I(t.jsx("path",{d:"M19.79 5.61C20.3 4.95 19.83 4 19 4H6.83l7.97 7.97zM2.81 2.81 1.39 4.22 10 13v6c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2.17l5.78 5.78 1.41-1.41z"})),ce=new Set(["INPUT","TEXTAREA","SELECT"]);function ue({searchInputRef:e}){h.useEffect(()=>{const n=s=>{var a;if(s.defaultPrevented||s.key!=="/"||s.metaKey||s.ctrlKey||s.altKey)return;const r=s.target;r&&ce.has(r.tagName)||(s.preventDefault(),(a=e==null?void 0:e.current)==null||a.focus())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e])}const pe=I(t.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),me=I(t.jsx("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"}));function xe({value:e,onChange:n,placeholder:s="Search...",onSubmit:r,textFieldProps:a,inputRef:i}){const l=p=>{n(p.target.value)},u=p=>{p.key==="Enter"&&(r==null||r())};return t.jsx(b,{value:e,onChange:l,placeholder:s,onKeyDown:u,fullWidth:!0,inputRef:i,InputProps:{startAdornment:t.jsx(N,{position:"start",children:t.jsx(me,{fontSize:"small"})}),endAdornment:e?t.jsx(N,{position:"end",children:t.jsx(F,{size:"small",onClick:()=>n(""),"aria-label":"Clear search input",children:t.jsx(pe,{fontSize:"small"})})}):void 0},...a})}function k({options:e,selection:n,onChange:s,placeholder:r,label:a}){return t.jsx(se,{multiple:!0,freeSolo:!0,options:e,value:n,onChange:(i,l)=>s(l),renderValue:(i,l)=>i.map((u,p)=>t.jsx(_,{size:"small",label:u,...l({index:p})})),sx:{flex:1},renderInput:i=>t.jsx(b,{...i,label:a,placeholder:r,size:"small"})})}function ve({value:e,onChange:n,children:s,tagOptions:r,groupOptions:a,onRefresh:i,refreshing:l=!1,searchOnly:u=!1}){const p=Q(),[f,C]=h.useState(!1),[d,m]=h.useState("include"),x=h.useRef(null);ue({searchInputRef:x});const y=o=>{n({...e,pageSize:o})},g=(o,j)=>{n({...e,[o]:he(j)})},M=e.searchQuery??"",c=d==="exclude",O=d==="include"?e.tagsInclude:e.tagsExclude,R=d==="include"?e.groupsInclude:e.groupsExclude,z=o=>{n({...e,tagsInclude:d==="include"?o:e.tagsInclude,tagsExclude:d==="exclude"?o:e.tagsExclude})},W=()=>m(o=>o==="include"?"exclude":"include"),E=c?{opacity:.5}:void 0;return t.jsx(J,{title:"Filters",bgcolor:c?q(p.palette.error.main,.08):void 0,children:t.jsxs(v,{spacing:2,children:[t.jsxs(v,{direction:{xs:"column",md:"row"},spacing:2,children:[t.jsx(A,{sx:{flex:1,minWidth:0,...E},children:t.jsx(xe,{value:M,onChange:o=>g("searchQuery",o),placeholder:"Search",inputRef:x,textFieldProps:{disabled:c}})}),!u&&t.jsxs(t.Fragment,{children:[t.jsx(F,{onClick:()=>C(o=>!o),sx:{transform:f?"rotate(180deg)":"rotate(0deg)",transition:"transform 150ms ease"},"aria-label":"Toggle advanced filters",children:t.jsx(X,{})}),t.jsx(T,{variant:c?"contained":"outlined",color:c?"error":"primary",onClick:W,startIcon:c?t.jsx(de,{}):t.jsx(le,{}),sx:{minWidth:140},children:c?"Exclude mode":"Include mode"})]}),i?t.jsx(T,{variant:"outlined",color:"primary",onClick:i,startIcon:t.jsx(Y,{sx:l?{animation:"spin 0.9s linear infinite","@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}}:void 0}),disabled:l,sx:{minWidth:140},children:"Refresh"}):null]}),t.jsxs(Z,{in:f,timeout:"auto",unmountOnExit:!0,children:[t.jsxs(v,{direction:{xs:"column",md:"row"},spacing:2,alignItems:{xs:"stretch",md:"flex-start"},sx:E,children:[t.jsx(b,{label:"After",type:"datetime-local",value:D(e.afterDate),onChange:o=>g("afterDate",L(o.target.value)),size:"small",fullWidth:!0,slotProps:{inputLabel:{shrink:!0}},sx:{flex:2},disabled:c}),t.jsx(b,{label:"Before",type:"datetime-local",value:D(e.beforeDate),onChange:o=>g("beforeDate",L(o.target.value)),size:"small",fullWidth:!0,slotProps:{inputLabel:{shrink:!0}},sx:{flex:2},disabled:c}),t.jsx(b,{label:"Page size",type:"number",value:e.pageSize??"",onChange:o=>{const j=Number(o.target.value);y(Number.isNaN(j)||j<=0?void 0:j)},size:"small",fullWidth:!0,slotProps:{inputLabel:{shrink:!0}},sx:{flex:1},disabled:c})]}),t.jsxs(v,{spacing:2,sx:{mt:2,flex:1},children:[t.jsx(k,{options:r??[],selection:O??[],label:`Tags (${d})`,placeholder:"Add tags",onChange:z}),t.jsx(k,{options:a??[],selection:R??[],label:`Groups (${d})`,placeholder:"Add groups",onChange:z})]})]}),s?t.jsx(A,{sx:{borderTop:"1px solid",borderColor:"divider",pt:2},children:s(d,E)}):null]})})}function D(e){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return e;const s=n.getTimezoneOffset();return new Date(n.getTime()-s*60*1e3).toISOString().slice(0,16)}function L(e){if(!e)return;const n=new Date(e);return Number.isNaN(n.getTime())?e:n.toISOString()}function he(e){if(!(typeof e=="string"&&e.trim()==="")&&!(Array.isArray(e)&&e.length===0))return e}export{ve as B};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./vendor-xyflow.js";import{E as W}from"./ExpandLess.js";import{S as E,G as k,ak as P,E as B,T as D,aW as A,a9 as $,a1 as G}from"./docs.js";import{h as n}from"./vendor-recharts.js";const M=n.createContext({collapsed:[],toggleCollapse:()=>{},cardCount:1,dragging:!1}),T=n.createContext(0);function N({onResize:o,onDragStart:l,onDragEnd:i}){const s=n.useRef(!1),d=n.useRef(0),w=n.useCallback(r=>{r.preventDefault(),s.current=!0,d.current=r.clientX,document.body.style.cursor="col-resize",document.body.style.userSelect="none",l();const u=p=>{if(!s.current)return;const h=p.clientX-d.current;d.current=p.clientX,o(h)},f=()=>{s.current=!1,document.body.style.cursor="",document.body.style.userSelect="",i(),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",f)};window.addEventListener("pointermove",u),window.addEventListener("pointerup",f)},[o,l,i]);return t.jsx(k,{onPointerDown:w,sx:{width:"6px",flexShrink:0,cursor:"col-resize",position:"relative",zIndex:1,"&::after":{content:'""',position:"absolute",top:"20%",bottom:"20%",left:"50%",transform:"translateX(-50%)",width:"2px",borderRadius:"1px",bgcolor:"divider"},"&:hover::after, &:active::after":{bgcolor:"primary.main"}}})}function q({children:o}){return t.jsx(E,{spacing:2,children:o})}const L=5;function F({sizes:o,children:l}){const i=Array.isArray(l)?l.filter(e=>e!=null):[l],s=i.length,[d,w]=n.useState(()=>{const e=o??i.map(()=>1),c=e.reduce((a,m)=>a+m,0)||1;return e.map(a=>a/c*100)}),[r,u]=n.useState(()=>i.map(()=>!1)),[f,p]=n.useState(!1),h=n.useRef(null),x=n.useCallback(e=>{u(c=>{const a=[...c];return a[e]=!c[e],a})},[]),j=n.useCallback(()=>p(!0),[]),v=n.useCallback(()=>p(!1),[]),X=n.useCallback((e,c)=>{const a=h.current;if(!a)return;const m=a.offsetWidth;if(m<=0)return;const z=c/m*100;w(y=>{const g=[...y];let C=e,b=e+1;for(;C>=0&&r[C];)C--;for(;b<s&&r[b];)b++;if(C<0||b>=s)return y;const I=g[C]+z,R=g[b]-z;return I<L||R<L?y:(g[C]=I,g[b]=R,g)})},[s,r]),H={collapsed:r,toggleCollapse:x,cardCount:s,dragging:f},S=[];for(let e=0;e<i.length;e++){if(e>0){const a=r[e-1],m=r[e];if(!(a||m)){const y=e-1;S.push(t.jsx(N,{onResize:g=>X(y,g),onDragStart:j,onDragEnd:v},`handle-${e}`))}}const c=r[e];S.push(t.jsx(T.Provider,{value:e,children:t.jsx(k,{sx:{flex:c?s>1?"0 0 36px":void 0:`${d[e]} 0 0%`,minWidth:c&&s>1?"36px":"60px",overflow:"hidden"},children:i[e]})},`card-${e}`))}return t.jsx(M.Provider,{value:H,children:t.jsx(k,{ref:h,sx:{display:"flex",gap:0,width:"100%"},children:S})})}function J({title:o,actions:l,children:i}){const{collapsed:s,toggleCollapse:d,cardCount:w,dragging:r}=n.useContext(M),u=n.useContext(T),f=s[u]??!1,p=w>1,h=f&&p,x=f&&!p,j=n.useCallback(()=>{d(u)},[u,d]);return h?t.jsxs(P,{onClick:j,sx:{height:"100%",cursor:"pointer",bgcolor:"background.paper",border:"none",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:2,overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[t.jsx(B,{fontSize:"small",sx:{mb:1,color:"text.secondary",transform:"rotate(-90deg)"}}),o&&t.jsx(D,{variant:"caption",sx:{writingMode:"vertical-rl",textOrientation:"mixed",whiteSpace:"nowrap",color:"text.secondary"},children:o})]}):t.jsx(P,{sx:{height:"100%",bgcolor:"background.paper",border:"none",display:"flex",flexDirection:"column"},children:t.jsxs(A,{sx:{flex:1,display:"flex",flexDirection:"column",...x?{pb:"16px !important"}:{}},children:[(o||l)&&t.jsxs(E,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1,sx:{mb:x?0:1},children:[t.jsxs(E,{direction:"row",alignItems:"center",spacing:.5,sx:{cursor:"pointer",userSelect:"none"},onClick:j,children:[t.jsx($,{title:x?"Expand":"Collapse",children:t.jsx(G,{size:"small",onClick:v=>{v.stopPropagation(),j()},sx:{p:.25},children:x?t.jsx(B,{fontSize:"small"}):t.jsx(W,{fontSize:"small"})})}),o&&t.jsx(D,{variant:"subtitle1",component:"h2",children:o})]}),l&&!x&&t.jsx(k,{onClick:v=>v.stopPropagation(),children:l})]}),!x&&t.jsx(k,{sx:{flex:1,pointerEvents:r?"none":"auto"},children:i})]})})}export{q as B,F as a,J as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./vendor-xyflow.js";import{P as me}from"./PageContainer.js";import{B as fe,a as ae,b as N}from"./BentoGrid.js";import{h as d,B as A,C as L,X as v,Y as z,T,q as D,P as xe,v as ge,w as ye,z as be,L as U,t as se,D as je,S as ke}from"./vendor-recharts.js";import{S as F,aI as Se,aJ as Te,x as Q,b as B,e as V,aK as re,h as oe,k as ne,C as W,B as X,D as K,aL as C,z as Y,aB as le,d as ce,aM as Ce,aN as Le,v as ue,aO as ve,a3 as ze,aP as Fe,aQ as J,aR as De,aS as ie,aA as Ee,aT as Pe,aU as Ae,aV as q}from"./docs.js";import{u as G}from"./useQueryState.js";import{D as Z}from"./filterTypes.js";import{B as ee}from"./BaseFilterBar.js";import"./ExpandLess.js";import"./Autocomplete.js";function Ke({groups:o,onGroupSelect:a}){return e.jsx(F,{spacing:2,children:e.jsx(Se,{columns:Te,items:o,onRowClick:s=>a(s.groupId),sortBy:"lastSeen",sortDirection:"desc"})})}const Me={...Z,searchQuery:"",orderBy:"timestamp",orderDirection:"desc",pageSize:200};function $e(){const[o,a]=G("cacheGroupFilters",Me),{openCacheGroup:s}=Q(),i=B("GET /__rrroutes/cache",{cursorParam:"cursor",splitPageSize:500,splitPageSizeParam:"pageSize",getNextPageParam(x){return x.meta.nextCursor}}),{data:r,isLoading:n,error:h,refetch:m,isFetching:p}=i.useEndpoint({query:o}),b=V(r,{reverse:!1}),f=d.useMemo(()=>re(b),[b]),l=d.useCallback(x=>{x&&s(x)},[s]),c=oe(),j=ne(c.palette.divider,.4),g=d.useMemo(()=>we(f),[f]),E=e.jsx(W,{title:"Cache groups",children:e.jsx(Ke,{groups:f.groupSummaries,onGroupSelect:l})}),S=e.jsxs(F,{spacing:3,children:[e.jsx(X,{stats:g.cards}),e.jsx(K,{charts:[{title:"Top groups by key count",chart:e.jsxs(A,{data:f.topGroupsByKeyCount,children:[e.jsx(L,{stroke:j,strokeDasharray:"3 3"}),e.jsx(v,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fill:c.palette.text.secondary,fontSize:12}}),e.jsx(z,{allowDecimals:!1,axisLine:!1,tickLine:!1,tick:{fill:c.palette.text.secondary,fontSize:12}}),e.jsx(T,{formatter:x=>[`${x}`,"keys"]}),e.jsx(D,{dataKey:"count",fill:c.palette.primary.main})]})},{title:"Top groups by payload",chart:e.jsxs(A,{data:f.topGroupsBySize,layout:"vertical",children:[e.jsx(L,{stroke:j,strokeDasharray:"3 3"}),e.jsx(v,{type:"number",axisLine:!1,tickLine:!1,tick:{fill:c.palette.text.secondary,fontSize:12},tickFormatter:x=>C(Number(x))}),e.jsx(z,{type:"category",dataKey:"label",width:140,axisLine:!1,tickLine:!1,tick:{fill:c.palette.text.secondary,fontSize:12}}),e.jsx(T,{formatter:x=>[C(Number(x)),"payload"]}),e.jsx(D,{dataKey:"size",fill:c.palette.secondary.main})]})}]})]});return e.jsxs(F,{spacing:3,children:[e.jsx(ee,{value:o,onChange:a,onRefresh:m,refreshing:p}),e.jsx(Y,{initialTab:"Table view",tabs:{"Table view":E,Insights:S}})]})}function we(o){const{groupSummaries:a,totalKeys:s,totalSize:i,expiredKeys:r}=o,n=a.filter(l=>typeof l.avgTtl=="number"),h=n.length?n.reduce((l,c)=>l+(c.avgTtl??0),0)/n.length:void 0,m=a.length?s/a.length:void 0,p=a.length?i/a.length:void 0,b=a.filter(l=>(l.expiredCount??0)>0).length,f=a.reduce((l,c)=>l?c.count>l.count?c:l:c,null);return{cards:[{label:"Groups",value:a.length,detail:`${s} keys`},{label:"Keys per group",value:m?m.toFixed(1):"—",detail:f?`${f.groupId??"Ungrouped"} has ${f.count} keys`:"Awaiting data"},{label:"Avg TTL (group)",value:h?le(h):"—",detail:`${n.length} groups with TTL`},{label:"Avg payload (group)",value:p?C(p):"—",detail:`Total ${C(i)}`},{label:"Groups with expired keys",value:b,detail:`${r} expired keys`}]}}const _e={...Z,searchQuery:"",orderBy:"timestamp",orderDirection:"desc",pageSize:200};function Re(){const[o,a]=G("cacheKeyFilters",_e),{openCacheKeyDetail:s}=Q(),i=B("GET /__rrroutes/cache",{cursorParam:"cursor",splitPageSize:500,splitPageSizeParam:"pageSize",getNextPageParam(k){return k.meta.nextCursor}}),r=B("POST /__rrroutes/cache/clear"),{data:n,isLoading:h,error:m,refetch:p,isFetching:b,fetchNextPage:f,hasNextPage:l,isFetchingNextPage:c}=i.useEndpoint({query:o}),j=V(n,{reverse:!1}),g=ce(m,{messageFallback:"Failed to load cache keys.",refetch:p}),E=d.useMemo(()=>re(j),[j]),S=d.useMemo(()=>Ce(j),[j]),x=d.useMemo(()=>Le(j),[j]),P=d.useMemo(()=>Ge(E,S,x),[E,S,x]),[O,M]=d.useState(!1),$=d.useCallback(async k=>{M(!0);try{await r.fetch({query:{...Be(o),...k}},void 0),await p()}catch(H){console.error("Failed to clear cache",H)}finally{M(!1)}},[o,r,p]),w=e.jsx(ze,{variant:"outlined",color:"error",size:"small",onClick:()=>$(),disabled:O||h,children:"Clear cache"});return e.jsxs(F,{spacing:3,children:[e.jsx(ee,{value:o,onChange:a,onRefresh:p,refreshing:b}),e.jsx(Y,{initialTab:"Table view",tabs:{"Table view":e.jsx(W,{title:"Cache keys",actions:w,children:e.jsx(ue,{items:j,endpoint:{data:n,fetchNextPage:f,hasNextPage:l,isFetchingNextPage:c},columns:ve,query:o,setQuery:a,onRowClick:k=>s(k.name??k.id),stateHandler:{isLoading:h,loading:{variant:"table"},emptyFallback:{title:"No cache keys",description:"Adjust filters to surface recent cache activity."},error:g}})}),Insights:e.jsxs(F,{spacing:3,children:[e.jsx(X,{stats:P.stats}),e.jsx(K,{charts:[{title:"TTL distribution",subText:"Key-level TTL buckets",chart:e.jsxs(A,{data:P.ttlHistogram,children:[e.jsx(L,{strokeDasharray:"3 3"}),e.jsx(v,{dataKey:"label",axisLine:!1,tickLine:!1}),e.jsx(z,{allowDecimals:!1,axisLine:!1,tickLine:!1}),e.jsx(T,{formatter:k=>[`${k}`,"keys"]}),e.jsx(D,{dataKey:"count",fill:"#1e88e5"})]})},{title:"Payload distribution",subText:"Bucketed by size range",chart:e.jsxs(A,{data:P.sizeHistogram,children:[e.jsx(L,{strokeDasharray:"3 3"}),e.jsx(v,{dataKey:"label",axisLine:!1,tickLine:!1}),e.jsx(z,{allowDecimals:!1,axisLine:!1,tickLine:!1}),e.jsx(T,{formatter:k=>[`${k}`,"keys"]}),e.jsx(D,{dataKey:"count",fill:"#42a5f5"})]})}]})]})}})]})}function Be(o){const{cursor:a,pageSize:s,...i}=o;return i}function Ge(o,a,s){const{totalKeys:i,totalSize:r,ttlCount:n,ttlSum:h,expiredKeys:m,groupSummaries:p}=o,b=i?n/i*100:0,f=i?m/i*100:0,l=i?r/i:void 0,c=n?h/n:void 0;return{stats:[{label:"Total keys",value:i,detail:`${p.length} groups`},{label:"Keys with TTL",value:n,detail:`${b.toFixed(1)}% of keys`},{label:"Average TTL",value:c!=null?le(c):"—",detail:`${n} TTL samples`},{label:"Expired keys",value:m,detail:`${f.toFixed(1)}% of keys`},{label:"Average payload",value:l!=null?C(l):"—",detail:`Total ${C(r)} across keys`}],ttlHistogram:a,sizeHistogram:s}}const Ie={...Z,searchQuery:"",orderBy:"timestamp",orderDirection:"desc",pageSize:200},Oe={operations:Ae};function He(){const[o,a]=G("cacheTraceFilters",Ie),[s,i]=G("cacheTraceExtras",Oe),{openCacheTraceDetail:r}=Q(),n=d.useMemo(()=>({cursorParam:"cursor",splitPageSize:500,splitPageSizeParam:"pageSize",getNextPageParam(t){return t.meta.nextCursor}}),[]),h=B("GET /__rrroutes/cache/trace",n),m=d.useMemo(()=>{const t=[],u=[];for(const[R,te]of Object.entries(s.operations))te==="include"&&t.push(R),te==="exclude"&&u.push(R);return{...o,...t.length?{operationsInclude:t}:{},...u.length?{operationsExclude:u}:{}}},[o,s]),p=h.useEndpoint({query:m}),{data:b,isLoading:f,error:l,refetch:c,isFetching:j}=p,g=V(b,{reverse:!1}),E=ce(l,{messageFallback:"Failed to load cache traces.",refetch:c}),S=d.useMemo(()=>Ne(g),[g]),x=d.useMemo(()=>Ue(S.operationCounts),[S.operationCounts]),P=d.useMemo(()=>qe(g),[g]),O=d.useMemo(()=>Qe(g),[g]),M=d.useMemo(()=>Ve(g),[g]),$=d.useMemo(()=>We(g),[g]),w=$.reduce((t,u)=>u.total>t.total?u:t,{hour:0,hourLabel:"00",total:0}),k=d.useCallback(t=>{i(u=>({...u,operations:{...u.operations,[t]:Fe(u.operations[t])}}))},[]),H=d.useCallback(t=>{r(t)},[r]),y=oe(),_=ne(y.palette.divider,.4),de=S.operationCounts.hit,he=S.operationCounts.miss,pe=de+he;return e.jsxs(F,{spacing:3,children:[e.jsx(ee,{value:o,onChange:a,onRefresh:c,refreshing:j,children:()=>e.jsx(F,{direction:"row",spacing:1,flexWrap:"wrap",children:J.map(t=>e.jsx(De,{operation:t,state:s.operations[t],onClick:()=>k(t)},t))})}),e.jsx(Y,{initialTab:"Table view",tabs:{"Table view":e.jsx(W,{title:"Trace entries",children:e.jsx(ue,{items:g,endpoint:p,columns:Pe,query:o,setQuery:a,onRowClick:H,stateHandler:{isLoading:f,loading:{variant:"table"},emptyFallback:{title:"No cache traces",description:"Adjust filters to view additional trace events."},error:E}})}),Insights:e.jsxs(F,{spacing:3,children:[e.jsx(X,{stats:S.cards}),e.jsx(K,{charts:[{title:"Operation mix",chart:e.jsxs(xe,{children:[e.jsx(ge,{data:x,dataKey:"value",nameKey:"name",innerRadius:48,outerRadius:74,paddingAngle:2,label:({name:t,percent:u})=>`${t} · ${u?(u*100).toFixed(0):"-"}%`,children:x.map(t=>e.jsx(ye,{fill:ie[t.name]},`cell-${t.name}`))}),e.jsx(T,{formatter:t=>[`${t}`,"ops"]})]})},{title:"Hit / miss trend",subText:P.length?`${pe} total operations`:"No hit/miss data available",chart:e.jsxs(be,{data:P,children:[e.jsx(L,{stroke:_,strokeDasharray:"3 3"}),e.jsx(v,{dataKey:"timestamp",type:"number",domain:["dataMin","dataMax"],tickFormatter:t=>new Date(t).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}),tick:{fill:y.palette.text.secondary,fontSize:12},axisLine:!1,tickLine:!1}),e.jsx(z,{allowDecimals:!1,tick:{fill:y.palette.text.secondary,fontSize:12},axisLine:!1,tickLine:!1}),e.jsx(T,{labelFormatter:t=>Ee(t),formatter:(t,u)=>[`${t}`,String(u)]}),e.jsx(U,{}),e.jsx(se,{type:"monotone",dataKey:"hits",stroke:y.palette.primary.main,strokeWidth:2,dot:!1}),e.jsx(se,{type:"monotone",dataKey:"misses",stroke:y.palette.error.main,strokeWidth:2,dot:!1})]})}]}),e.jsx(K,{charts:[{title:"Duration by operation",chart:e.jsxs(A,{data:O,children:[e.jsx(L,{stroke:_,strokeDasharray:"3 3"}),e.jsx(v,{dataKey:"operation",tick:{fill:y.palette.text.secondary,fontSize:12},axisLine:!1,tickLine:!1}),e.jsx(z,{allowDecimals:!1,tick:{fill:y.palette.text.secondary,fontSize:12},axisLine:!1,tickLine:!1,tickFormatter:t=>`${Math.round(t)} ms`}),e.jsx(T,{formatter:t=>[`${t} ms`,"Duration"]}),e.jsx(U,{}),e.jsx(D,{dataKey:"avg",stackId:"a",fill:y.palette.primary.main}),e.jsx(D,{dataKey:"p95",stackId:"a",fill:y.palette.secondary.main})]})},{title:"Size vs. duration",chart:e.jsxs(je,{children:[e.jsx(L,{stroke:_,strokeDasharray:"3 3"}),e.jsx(v,{dataKey:"size",name:"Size",tickFormatter:t=>C(Number(t)),tick:{fill:y.palette.text.secondary,fontSize:12},axisLine:!1,tickLine:!1}),e.jsx(z,{dataKey:"duration",name:"Duration",tick:{fill:y.palette.text.secondary,fontSize:12},tickFormatter:t=>`${Math.round(t)} ms`,axisLine:!1,tickLine:!1}),e.jsx(T,{cursor:{strokeDasharray:"3 3"},formatter:(t,u)=>u==="duration"?[`${t?Math.round(Number(t)):"-"} ms`,"Duration"]:[C(Number(t)),"Size"]}),Object.entries(ie).map(([t,u])=>e.jsx(ke,{name:t,data:M.filter(R=>R.operation===t),fill:u},t))]})}]}),e.jsx(K,{charts:[{title:"Activity by hour",subText:`Peak hour: ${String(w.hour).padStart(2,"0")}:00 with ${w.total} events.`,chart:e.jsxs(A,{data:$,children:[e.jsx(L,{stroke:_,strokeDasharray:"3 3"}),e.jsx(v,{dataKey:"hourLabel",tick:{fill:y.palette.text.secondary,fontSize:12},axisLine:!1,tickLine:!1}),e.jsx(z,{allowDecimals:!1,tick:{fill:y.palette.text.secondary,fontSize:12},axisLine:!1,tickLine:!1}),e.jsx(T,{formatter:t=>[`${t}`,"events"]}),e.jsx(U,{}),e.jsx(D,{dataKey:"total",fill:y.palette.primary.main})]})}]})]})}})]})}function Ne(o){const a={hit:0,miss:0,set:0,delete:0},s=[];let i=0;o.forEach(l=>{a[l.operation]+=1,typeof l.durationMs=="number"&&s.push(l.durationMs),typeof l.size=="number"&&(i+=l.size)});const r=a.hit,n=a.miss,h=r+n?r/(r+n)*100:null,m=s.length?s.reduce((l,c)=>l+c,0)/s.length:null,p=I(s,95),b=I(s,99);return{cards:[{label:"Hit rate",value:h!=null?`${h.toFixed(1)}%`:"n/a",detail:`${r} hits · ${n} misses`},{label:"Average duration",value:m!=null?`${q(m)} ms`:"—",detail:`P95 ${p?`${q(p)} ms`:"—"}`},{label:"P99 duration",value:b?`${q(b)} ms`:"—",detail:`${s.length} recorded ops`},{label:"Data volume",value:C(i),detail:`${o.length} trace events`}],operationCounts:a}}function Ue(o){return J.map(a=>({name:a,value:o[a]??0}))}function qe(o){const s=new Map;return o.forEach(i=>{const r=Math.floor((i.timestamp??0)/3e5)*3e5,n=s.get(r)??{hits:0,misses:0};i.operation==="hit"&&(n.hits+=1),i.operation==="miss"&&(n.misses+=1),s.set(r,n)}),Array.from(s.entries()).sort((i,r)=>i[0]-r[0]).map(([i,{hits:r,misses:n}])=>({timestamp:i,hits:r,misses:n}))}function Qe(o){const a={hit:[],miss:[],set:[],delete:[]};return o.forEach(s=>{typeof s.durationMs=="number"&&a[s.operation].push(s.durationMs)}),J.map(s=>{const i=a[s],r=i.length===0?0:i.reduce((n,h)=>n+h,0)/i.length;return{operation:s,avg:r,p95:I(i,95)??r,p99:I(i,99)??r}})}function Ve(o){return o.filter(a=>typeof a.size=="number"&&typeof a.durationMs=="number"&&a.size>0).map(a=>({size:a.size??0,duration:a.durationMs??0,operation:a.operation})).slice(-150)}function We(o){const a=Array.from({length:24},(s,i)=>({hour:i,hourLabel:String(i).padStart(2,"0"),total:0}));return o.forEach(s=>{const i=new Date(s.timestamp),r=a[i.getHours()];r&&(r.total+=1)}),a}function I(o,a){if(!o.length)return null;const s=[...o].sort((h,m)=>h-m),i=a/100*(s.length-1),r=Math.floor(i),n=i-r;return r+1>=s.length?s[r]:s[r]+n*(s[r+1]-s[r])}function ot(){return e.jsx(me,{title:"Cache Logs",subtitle:"Inspect cache keys and trace data generated by running requests.",children:e.jsxs(fe,{children:[e.jsxs(ae,{sizes:[6,6],children:[e.jsx(N,{title:"Keys",children:e.jsx(Re,{})}),e.jsx(N,{title:"Groups",children:e.jsx($e,{})})]}),e.jsx(ae,{children:e.jsx(N,{title:"Trace",children:e.jsx(He,{})})})]})})}export{ot as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./vendor-xyflow.js";import{R as o}from"./docs.js";const s=o(t.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM8 9h8v10H8zm7.5-5-1-1h-5l-1 1H5v2h14V4z"}));export{s as D};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{j as d}from"./vendor-xyflow.js";import{h as C}from"./vendor-recharts.js";import{h as J,S,T as I,b1 as W,G as T,k as q,H as $,Y as N,b as E,e as H,z as _}from"./docs.js";import{A as F}from"./Autocomplete.js";import{T as V,P as G}from"./PageContainer.js";class D{diff(e,n,t={}){let l;typeof t=="function"?(l=t,t={}):"callback"in t&&(l=t.callback);const s=this.castInput(e,t),r=this.castInput(n,t),a=this.removeEmpty(this.tokenize(s,t)),i=this.removeEmpty(this.tokenize(r,t));return this.diffWithOptionsObj(a,i,t,l)}diffWithOptionsObj(e,n,t,l){var s;const r=p=>{if(p=this.postProcess(p,t),l){setTimeout(function(){l(p)},0);return}else return p},a=n.length,i=e.length;let h=1,c=a+i;t.maxEditLength!=null&&(c=Math.min(c,t.maxEditLength));const y=(s=t.timeout)!==null&&s!==void 0?s:1/0,x=Date.now()+y,u=[{oldPos:-1,lastComponent:void 0}];let f=this.extractCommon(u[0],n,e,0,t);if(u[0].oldPos+1>=i&&f+1>=a)return r(this.buildValues(u[0].lastComponent,n,e));let m=-1/0,g=1/0;const w=()=>{for(let p=Math.max(m,-h);p<=Math.min(g,h);p+=2){let P;const L=u[p-1],v=u[p+1];L&&(u[p-1]=void 0);let z=!1;if(v){const R=v.oldPos-p;z=v&&0<=R&&R<a}const b=L&&L.oldPos+1<i;if(!z&&!b){u[p]=void 0;continue}if(!b||z&&L.oldPos<v.oldPos?P=this.addToPath(v,!0,!1,0,t):P=this.addToPath(L,!1,!0,1,t),f=this.extractCommon(P,n,e,p,t),P.oldPos+1>=i&&f+1>=a)return r(this.buildValues(P.lastComponent,n,e))||!0;u[p]=P,P.oldPos+1>=i&&(g=Math.min(g,p-1)),f+1>=a&&(m=Math.max(m,p+1))}h++};if(l)(function p(){setTimeout(function(){if(h>c||Date.now()>x)return l(void 0);w()||p()},0)})();else for(;h<=c&&Date.now()<=x;){const p=w();if(p)return p}}addToPath(e,n,t,l,s){const r=e.lastComponent;return r&&!s.oneChangePerToken&&r.added===n&&r.removed===t?{oldPos:e.oldPos+l,lastComponent:{count:r.count+1,added:n,removed:t,previousComponent:r.previousComponent}}:{oldPos:e.oldPos+l,lastComponent:{count:1,added:n,removed:t,previousComponent:r}}}extractCommon(e,n,t,l,s){const r=n.length,a=t.length;let i=e.oldPos,h=i-l,c=0;for(;h+1<r&&i+1<a&&this.equals(t[i+1],n[h+1],s);)h++,i++,c++,s.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return c&&!s.oneChangePerToken&&(e.lastComponent={count:c,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=i,h}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){const l=[];let s;for(;e;)l.push(e),s=e.previousComponent,delete e.previousComponent,e=s;l.reverse();const r=l.length;let a=0,i=0,h=0;for(;a<r;a++){const c=l[a];if(c.removed)c.value=this.join(t.slice(h,h+c.count)),h+=c.count;else{if(!c.added&&this.useLongestToken){let y=n.slice(i,i+c.count);y=y.map(function(x,u){const f=t[h+u];return f.length>x.length?f:x}),c.value=this.join(y)}else c.value=this.join(n.slice(i,i+c.count));i+=c.count,c.added||(h+=c.count)}}return l}}class K extends D{constructor(){super(...arguments),this.tokenize=B}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
|
|
2
|
-
`))&&(e=e.trim()),(!t.newlineIsToken||!n.includes(`
|
|
3
|
-
`))&&(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith(`
|
|
4
|
-
`)&&(e=e.slice(0,-1)),n.endsWith(`
|
|
5
|
-
`)&&(n=n.slice(0,-1))),super.equals(e,n,t)}}new K;function B(o,e){e.stripTrailingCr&&(o=o.replace(/\r\n/g,`
|
|
6
|
-
`));const n=[],t=o.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(let l=0;l<t.length;l++){const s=t[l];l%2&&!e.newlineIsToken?n[n.length-1]+=s:n.push(s)}return n}class U extends D{constructor(){super(...arguments),this.tokenize=B}get useLongestToken(){return!0}castInput(e,n){const{undefinedReplacement:t,stringifyReplacer:l=(s,r)=>typeof r>"u"?t:r}=n;return typeof e=="string"?e:JSON.stringify(O(e,null,null,l),null," ")}equals(e,n,t){return super.equals(e.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"),t)}}const Y=new U;function Q(o,e,n){return Y.diff(o,e,n)}function O(o,e,n,t,l){e=e||[],n=n||[],t&&(o=t(l===void 0?"":l,o));let s;for(s=0;s<e.length;s+=1)if(e[s]===o)return n[s];let r;if(Object.prototype.toString.call(o)==="[object Array]"){for(e.push(o),r=new Array(o.length),n.push(r),s=0;s<o.length;s+=1)r[s]=O(o[s],e,n,t,String(s));return e.pop(),n.pop(),r}if(o&&o.toJSON&&(o=o.toJSON()),typeof o=="object"&&o!==null){e.push(o),r={},n.push(r);const a=[];let i;for(i in o)Object.prototype.hasOwnProperty.call(o,i)&&a.push(i);for(a.sort(),s=0;s<a.length;s+=1)i=a[s],r[i]=O(o[i],e,n,t,i);e.pop(),n.pop()}else r=o;return r}function X(o,e){const n=typeof o=="string"?o:JSON.stringify(o,null,2)??"",t=typeof e=="string"?e:JSON.stringify(e,null,2)??"";return Q(n,t)}function j({left:o,right:e,title:n}){const t=J(),l=X(o,e),s=C.useRef(null),r=C.useRef(null),a=C.useRef(!1),i=C.useCallback(u=>()=>{if(a.current)return;a.current=!0;const f=u==="left"?s.current:r.current,m=u==="left"?r.current:s.current;f&&m&&(m.scrollTop=f.scrollTop,m.scrollLeft=f.scrollLeft),a.current=!1},[]),h=[],c=[];for(const u of l){const f=u.value.replace(/\n$/,"").split(`
|
|
7
|
-
`);if(u.added)for(const m of f)h.push({text:"",type:"unchanged"}),c.push({text:m,type:"added"});else if(u.removed)for(const m of f)h.push({text:m,type:"removed"}),c.push({text:"",type:"unchanged"});else for(const m of f)h.push({text:m,type:"unchanged"}),c.push({text:m,type:"unchanged"})}const y=u=>{switch(u){case"added":return q(t.palette.success.main,.15);case"removed":return q(t.palette.error.main,.15);default:return"transparent"}},x=(u,f,m,g)=>d.jsxs(W,{sx:{flex:1,minWidth:0,overflow:"hidden",backgroundColor:q(t.palette.background.paper,.5),backdropFilter:"blur(14px)",border:`1px solid ${q("#ffffff",.07)}`},children:[d.jsx(T,{sx:{px:2,py:1,borderBottom:`1px solid ${q("#ffffff",.07)}`},children:d.jsx(I,{variant:"subtitle2",color:"text.secondary",children:g})}),d.jsx(T,{ref:f,onScroll:m,sx:{overflow:"auto",maxHeight:500,p:1},children:u.map((w,p)=>d.jsx(T,{sx:{backgroundColor:y(w.type),px:1.5,py:.25,fontFamily:'"Fira Code", "JetBrains Mono", monospace',fontSize:"0.8rem",lineHeight:1.7,whiteSpace:"pre",minHeight:"1.7em",borderRadius:.5},children:w.text},p))})]});return d.jsxs(S,{spacing:1.5,children:[n&&d.jsx(I,{variant:"h6",color:"text.primary",children:n}),d.jsxs(S,{direction:"row",spacing:2,sx:{width:"100%"},children:[x(h,s,i("left"),"Left"),x(c,r,i("right"),"Right")]})]})}function M(o){return new Date(o).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function A({requests:o,value:e,onChange:n,label:t="Select request"}){const l=C.useMemo(()=>o.find(s=>s.id===e)??null,[o,e]);return d.jsx(F,{options:o,value:l,onChange:(s,r)=>n((r==null?void 0:r.id)??null),getOptionLabel:s=>`${s.method.toUpperCase()} ${s.path} ${s.status} ${M(s.createdAt)}`,filterOptions:(s,r)=>{const a=r.inputValue.toLowerCase();return a?s.filter(i=>i.method.toLowerCase().includes(a)||i.path.toLowerCase().includes(a)||String(i.status).includes(a)):s},isOptionEqualToValue:(s,r)=>s.id===r.id,renderOption:(s,r)=>{const{key:a,...i}=s;return d.jsx("li",{...i,children:d.jsxs(S,{direction:"row",spacing:1,alignItems:"center",sx:{width:"100%",py:.5},children:[d.jsx($,{method:r.method}),d.jsx(I,{variant:"body2",sx:{flex:1,fontFamily:'"Fira Code", "JetBrains Mono", monospace',fontSize:"0.8rem"},noWrap:!0,children:r.path}),d.jsx(N,{status:r.status}),d.jsx(I,{variant:"caption",color:"text.secondary",noWrap:!0,sx:{minWidth:100,textAlign:"right"},children:M(r.createdAt)})]})},a)},renderInput:s=>d.jsx(V,{...s,label:t,size:"small"}),sx:{minWidth:300}})}function se(){const[o,e]=C.useState(null),[n,t]=C.useState(null),l=C.useMemo(()=>({cursorParam:"cursor",getNextPageParam(g){return g.meta.nextCursor}}),[]),s=E("GET /__rrroutes/requests",l),{data:r}=s.useEndpoint({query:{}}),a=H(r,{reverse:!0}),i=C.useMemo(()=>a.map(g=>({id:g.id,method:g.method,path:g.path,status:g.status,createdAt:g.createdAt})),[a]),h=E("GET /__rrroutes/requests/:requestId",{enabled:!!o}),c=E("GET /__rrroutes/requests/:requestId",{enabled:!!n}),{data:y}=h.useEndpoint({params:{requestId:o??void 0}}),{data:x}=c.useEndpoint({params:{requestId:n??void 0}}),u=y==null?void 0:y.out,f=x==null?void 0:x.out,m=!!(u&&f);return d.jsx(G,{title:"Diff",subtitle:"Compare two requests side by side.",children:d.jsxs(S,{spacing:3,children:[d.jsxs(S,{direction:{xs:"column",sm:"row"},spacing:2,children:[d.jsx(T,{sx:{flex:1},children:d.jsx(A,{requests:i,value:o,onChange:e,label:"Left request"})}),d.jsx(T,{sx:{flex:1},children:d.jsx(A,{requests:i,value:n,onChange:t,label:"Right request"})})]}),m?d.jsx(_,{initialTab:"Headers",tabs:{Headers:d.jsx(j,{left:u.headers,right:f.headers,title:"Headers"}),Params:d.jsx(j,{left:u.params,right:f.params,title:"Params"}),Body:d.jsx(j,{left:u.body,right:f.body,title:"Body"}),Response:d.jsx(j,{left:u.output,right:f.output,title:"Response"}),Timing:d.jsx(j,{left:{durationMs:u.durationMs,status:u.status,requestSize:u.requestSize,responseSize:u.responseSize},right:{durationMs:f.durationMs,status:f.status,requestSize:f.requestSize,responseSize:f.responseSize},title:"Timing"})}}):d.jsx(I,{variant:"body2",color:"text.secondary",children:"Select two requests above to compare them."})]})})}export{se as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./vendor-xyflow.js";import{R as t}from"./docs.js";const a=t(o.jsx("path",{d:"M5 20h14v-2H5zM19 9h-4V3H9v6H5l7 7z"}));export{a as D};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./vendor-xyflow.js";import{h as n}from"./vendor-recharts.js";import{E as O}from"./EndpointDetailPanel.js";import{u as _,n as D,a as R,o as U,p as x,q as w,r as L,s as P,S as b,C as $}from"./docs.js";import{P as A,T as N}from"./PageContainer.js";import{u as Y,a as M}from"./useEndpointOptions.js";import{A as Q}from"./Autocomplete.js";import"./SchemaTreeView.js";import"./ExpandLess.js";import"./getValidReactChildren.js";import"./filterTypes.js";function V(){const p=_(),{endpointId:h}=D(),s=h?decodeURIComponent(h):"",[i]=R(),d=i.get(U),[k,y]=n.useState(()=>x(d));n.useEffect(()=>{const e=x(d);y(t=>t===e?t:e)},[d]);const[v,f]=n.useState(s);n.useEffect(()=>{f(s)},[s]);const[I,g]=n.useState(""),{options:E,isLoading:T}=Y(I),r=n.useMemo(()=>w(s),[s]),c=(r==null?void 0:r.display)??s??"",{data:u}=M(c),l=n.useMemo(()=>{const e=[...E],t=a=>{a&&(e.some(m=>m.value===a.value)||e.push(a))};return t(r),t(u?L(u):void 0),e},[E,r,u]),S=i.get(P);n.useEffect(()=>{if(S==="playgroundMax"){const e=new URLSearchParams(i);e.delete(P);const t=c?`/playground/${encodeURIComponent(c)}`:"/playground",a=e.toString();p(a?`${t}?${a}`:t,{replace:!0})}},[S,p,i,c]);const C=n.useCallback(e=>{const t=i.toString(),a=`/routes/${encodeURIComponent(e)}`;p(t?`${a}?${t}`:a)},[p,i]),j=(e,t)=>{if(!t)return;const a=l.find(m=>m.value===t);a&&C(a.value)};return o.jsx(A,{title:"Endpoint details",subtitle:"Inspect endpoint contracts, history, and metrics.",children:o.jsxs(b,{spacing:3,children:[o.jsx($,{title:"Endpoint",children:o.jsx(b,{spacing:2,children:o.jsx(Q,{freeSolo:!0,options:l.map(e=>e.value),value:c,inputValue:v,loading:T,onChange:j,onInputChange:(e,t,a)=>{f(t),a==="input"&&g(t),(a==="clear"||a==="reset"&&t==="")&&g("")},getOptionLabel:e=>{const t=l.find(a=>a.value===e);return t?t.display:e},renderInput:e=>o.jsx(N,{...e,label:"Switch endpoint",placeholder:"GET /v1/example",helperText:"Search by method and path"})})})}),o.jsx(O,{endpointId:s})]})})}export{V as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./vendor-xyflow.js";import{h as v,A as L,C as R,X as w,Y as D,T as M,x as C}from"./vendor-recharts.js";import{b as S,t as T,d as E,e as A,C as F,S as o,T as c,v as B,w as P,H as z,j as H,x as N,y as _,z as G,h as I,B as Y,D as O,G as K}from"./docs.js";import{S as h}from"./SchemaTreeView.js";import{D as $}from"./filterTypes.js";function Q({method:t,path:r,onSelectRequest:i,onRequestsChange:s}){const[u,l]=v.useState(()=>({...$,pageSize:10})),a=S("GET /__rrroutes/requests",{cursorParam:"cursor",getNextPageParam(g){var x;return(x=g.meta)==null?void 0:x.nextCursor},enabled:!!(t&&r)}).useEndpoint({query:{...u,endpointKeysInclude:r&&t?[T(t,r,!0)]:[]}}),{data:f,isLoading:j,error:y,refetch:n,isFetchingNextPage:m}=a,q=E(y,{messageFallback:"Failed to load requests.",refetch:n}),b=A(f,{reverse:!1});v.useEffect(()=>{s==null||s(b)},[b,s]);const k=(g,x)=>{i(g,x)};return e.jsx(F,{title:"Requests feed",children:e.jsx(o,{spacing:2,children:r&&t?e.jsx(B,{items:b,columns:P,query:u,stateHandler:{emptyFallback:{title:"No requests",description:"This endpoint has not received any requests yet."},error:q,isLoading:j,loading:{variant:"table"}},endpoint:a,setQuery:l,onRowClick:k}):e.jsx(c,{variant:"body2",color:"text.secondary",children:"Endpoint identifier missing."})})})}function U({endpoint:t}){return e.jsxs(o,{spacing:1,children:[e.jsxs(o,{direction:"row",spacing:1.5,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[e.jsx(z,{method:t.method}),e.jsx(c,{variant:"h6",sx:{fontFamily:"monospace",color:"text.primary"},children:t.path}),e.jsx(H,{label:t.stability,size:"small",color:"secondary",sx:{textTransform:"capitalize"}})]}),t.summary&&e.jsx(c,{variant:"body2",color:"text.secondary",children:t.summary})]})}function re({endpointId:t,showHeader:r=!0}){const{openRequestDetail:i}=N(),s=S("GET /__rrroutes/endpoints/:endpointId",{enabled:!!t}),u=v.useMemo(()=>{if(t==null)return;if(t.indexOf(" ")===-1)return t;const[n,m]=t.split(" ");return T(n,m,!0)},[t]),{data:l,isLoading:d,error:a,refetch:f}=s.useEndpoint({params:{endpointId:u}}),j=E(a,{messageFallback:"Unable to load endpoint.",refetch:f}),y=l==null?void 0:l.out;return e.jsx(e.Fragment,{children:e.jsx(_,{loading:{variant:"full"},emptyFallback:t?{title:"Endpoint not found",description:"This endpoint may have been removed."}:{title:"Select an endpoint",description:"Choose an endpoint from the list to inspect its contract and metrics."},data:y,error:j,isLoading:d,children:n=>e.jsxs(o,{spacing:1,children:[r&&e.jsx(U,{endpoint:n}),e.jsx(G,{initialTab:"Request",tabs:{Request:e.jsx(V,{endpoint:n}),Response:e.jsx(W,{endpoint:n}),Meta:e.jsx(X,{endpoint:n}),Metrics:e.jsx(J,{endpoint:n,onSelectRequest:m=>i({requestId:m.id,allowReplay:!0}),onRequestsChange:()=>{}})}})]})})})}function V({endpoint:t}){return e.jsxs(o,{spacing:2.5,children:[e.jsx(h,{title:"Body",schema:t.contract.body}),e.jsx(h,{title:"Params",schema:t.contract.params}),e.jsx(h,{title:"Query",schema:t.contract.query})]})}function W({endpoint:t}){return e.jsx(h,{title:"Response",schema:t.contract.output})}function X({endpoint:t}){const r=Object.entries(t.meta||{});return e.jsxs(o,{spacing:2,children:[e.jsx(p,{label:"Feed",value:t.feed?"Yes":"No"}),e.jsx(p,{label:"Implemented",value:t.implemented?"Yes":"No"}),e.jsx(p,{label:"Hidden",value:t.hidden?"Yes":"No"}),r.length>0&&e.jsxs(K,{children:[e.jsx(c,{variant:"subtitle2",gutterBottom:!0,children:"Metadata"}),e.jsx(o,{spacing:1,children:r.map(([i,s])=>e.jsx(p,{label:i,value:s},i))})]})]})}function J({endpoint:t,onSelectRequest:r,onRequestsChange:i}){var d;const s=I(),u=typeof t.successRate=="number"?`${Math.round(t.successRate*100)}%`:"—",l=t.averageDurationMs?`${Math.round(t.averageDurationMs)} ms`:"—";return e.jsxs(o,{spacing:3,children:[e.jsx(Y,{stats:[{label:"Avg duration",value:l},{label:"Success rate",value:u}]}),e.jsx(O,{charts:[{title:"Request volume",chart:e.jsxs(L,{data:t.volumeTS.map(a=>({...a,date:new Date(a.timestamp)})),children:[e.jsx(R,{stroke:"rgba(255,255,255,0.1)",strokeDasharray:"3 3"}),e.jsx(w,{dataKey:"date",tickFormatter:a=>new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),tick:{fill:s.palette.text.secondary,fontSize:12},axisLine:!1,tickLine:!1}),e.jsx(D,{tick:{fill:s.palette.text.secondary,fontSize:12},axisLine:!1,tickLine:!1,allowDecimals:!1}),e.jsx(M,{labelFormatter:a=>new Date(a).toLocaleString(),formatter:a=>[`${a} requests`,"Volume"],contentStyle:{backgroundColor:s.palette.background.paper,borderColor:s.palette.divider}}),e.jsx(C,{type:"monotone",dataKey:"count",stroke:s.palette.primary.main,fill:s.palette.primary.main,fillOpacity:.22,strokeWidth:2})]})}]}),(d=t.latestErrors)!=null&&d.length?e.jsx(F,{title:"Latest error request IDs",children:e.jsx(o,{spacing:.5,children:t.latestErrors.map(a=>e.jsx(c,{variant:"body2",sx:{fontFamily:"monospace"},children:a.id},a.id))})}):null,e.jsx(Q,{method:t.method,path:t.path,onSelectRequest:r,onRequestsChange:i})]})}function p({label:t,value:r}){return e.jsxs(o,{direction:"row",spacing:1,justifyContent:"space-between",children:[e.jsx(c,{variant:"body2",color:"text.secondary",children:t}),e.jsx(c,{variant:"body2",sx:{fontFamily:"monospace",color:"text.primary"},children:r})]})}export{re as E};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./vendor-xyflow.js";import{h as o,m as yt}from"./vendor-recharts.js";import{A as qe}from"./Add.js";import{I as Ze,J as et,K as jt,L as Be,M as me,N as tt,O as Ae,P as vt,Q as st,R as re,U as Ct,V as wt,W as bt,X as Ke,S as k,A as ve,i as Ce,T as B,Y as kt,G as O,E as we,m as be,Z as It,_ as rt,$ as Pt,a0 as nt,a1 as se,a2 as Mt,a3 as _,a4 as He,a5 as Et,a6 as ot,q as Fe,a7 as _e,a8 as at,a9 as Oe,c as it,aa as lt,ab as zt,g as Pe,ac as St,ad as Bt,ae as Ot,af as Tt,ag as qt,ah as Ue,n as At}from"./docs.js";import{P as Ht}from"./PlayArrow.js";import{u as Ft,a as Rt}from"./useEndpointOptions.js";import{r as pe,D as Dt,a as Nt}from"./kvRowAdapters.js";import{D as $t}from"./DeleteOutline.js";import{u as Vt,T as ye,I as Lt,P as Jt}from"./PageContainer.js";import{s as Wt,f as ge,a as Qe,d as Gt,b as Kt}from"./schemaDefaults.js";import{A as _t}from"./Autocomplete.js";import{S as Te}from"./SchemaTreeView.js";import"./ExpandLess.js";import"./getValidReactChildren.js";function Ut(e){return Ze("PrivateSwitchBase",e)}et("PrivateSwitchBase",["root","checked","disabled","input","edgeStart","edgeEnd"]);const Qt=e=>{const{classes:s,checked:r,disabled:f,edge:g}=e,x={root:["root",r&&"checked",f&&"disabled",g&&`edge${me(g)}`],input:["input"]};return tt(x,Ut,s)},Yt=Ae(vt,{name:"MuiSwitchBase"})({padding:9,borderRadius:"50%",variants:[{props:{edge:"start",size:"small"},style:{marginLeft:-3}},{props:({edge:e,ownerState:s})=>e==="start"&&s.size!=="small",style:{marginLeft:-12}},{props:{edge:"end",size:"small"},style:{marginRight:-3}},{props:({edge:e,ownerState:s})=>e==="end"&&s.size!=="small",style:{marginRight:-12}}]}),Xt=Ae("input",{name:"MuiSwitchBase",shouldForwardProp:st})({cursor:"inherit",position:"absolute",opacity:0,width:"100%",height:"100%",top:0,left:0,margin:0,padding:0,zIndex:1}),Zt=o.forwardRef(function(s,r){const{autoFocus:f,checked:g,checkedIcon:x,defaultChecked:d,disabled:v,disableFocusRipple:l=!1,edge:y=!1,icon:j,id:u,inputProps:h,inputRef:M,name:w,onBlur:z,onChange:b,onFocus:T,readOnly:q,required:X=!1,tabIndex:Z,type:K,value:U,slots:L={},slotProps:Q={},...c}=s,[$,le]=jt({controlled:g,default:!!d,name:"SwitchBase",state:"checked"}),R=Vt(),ne=S=>{T&&T(S),R&&R.onFocus&&R.onFocus(S)},D=S=>{z&&z(S),R&&R.onBlur&&R.onBlur(S)},ce=S=>{if(S.nativeEvent.defaultPrevented||q)return;const H=S.target.checked;le(H),b&&b(S,H)};let J=v;R&&typeof J>"u"&&(J=R.disabled);const oe=K==="checkbox"||K==="radio",ee={...s,checked:$,disabled:J,disableFocusRipple:l,edge:y},ae=Qt(ee),ie={slots:L,slotProps:{input:h,...Q}},[F,W]=Be("root",{ref:r,elementType:Yt,className:ae.root,shouldForwardComponentProp:!0,externalForwardedProps:{...ie,component:"span",...c},getSlotProps:S=>({...S,onFocus:H=>{var V;(V=S.onFocus)==null||V.call(S,H),ne(H)},onBlur:H=>{var V;(V=S.onBlur)==null||V.call(S,H),D(H)}}),ownerState:ee,additionalProps:{centerRipple:!0,focusRipple:!l,disabled:J,role:void 0,tabIndex:null}}),[Y,de]=Be("input",{ref:M,elementType:Xt,className:ae.input,externalForwardedProps:ie,getSlotProps:S=>({...S,onChange:H=>{var V;(V=S.onChange)==null||V.call(S,H),ce(H)}}),ownerState:ee,additionalProps:{autoFocus:f,checked:g,defaultChecked:d,disabled:J,id:oe?u:void 0,name:w,readOnly:q,required:X,tabIndex:Z,type:K,...K==="checkbox"&&U===void 0?{}:{value:U}}});return t.jsxs(F,{...W,children:[t.jsx(Y,{...de}),$?x:j]})}),es=re(t.jsx("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"})),ts=re(t.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"})),ss=re(t.jsx("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"}));function rs(e){return Ze("MuiCheckbox",e)}const Me=et("MuiCheckbox",["root","checked","disabled","indeterminate","colorPrimary","colorSecondary","sizeSmall","sizeMedium"]),ns=e=>{const{classes:s,indeterminate:r,color:f,size:g}=e,x={root:["root",r&&"indeterminate",`color${me(f)}`,`size${me(g)}`]},d=tt(x,rs,s);return{...s,...d}},os=Ae(Zt,{shouldForwardProp:e=>st(e)||e==="classes",name:"MuiCheckbox",slot:"Root",overridesResolver:(e,s)=>{const{ownerState:r}=e;return[s.root,r.indeterminate&&s.indeterminate,s[`size${me(r.size)}`],r.color!=="default"&&s[`color${me(r.color)}`]]}})(bt(({theme:e})=>({color:(e.vars||e).palette.text.secondary,variants:[{props:{color:"default",disableRipple:!1},style:{"&:hover":{backgroundColor:e.alpha((e.vars||e).palette.action.active,(e.vars||e).palette.action.hoverOpacity)}}},...Object.entries(e.palette).filter(Ke()).map(([s])=>({props:{color:s,disableRipple:!1},style:{"&:hover":{backgroundColor:e.alpha((e.vars||e).palette[s].main,(e.vars||e).palette.action.hoverOpacity)}}})),...Object.entries(e.palette).filter(Ke()).map(([s])=>({props:{color:s},style:{[`&.${Me.checked}, &.${Me.indeterminate}`]:{color:(e.vars||e).palette[s].main},[`&.${Me.disabled}`]:{color:(e.vars||e).palette.action.disabled}}})),{props:{disableRipple:!1},style:{"&:hover":{"@media (hover: none)":{backgroundColor:"transparent"}}}}]}))),as=t.jsx(ts,{}),is=t.jsx(es,{}),ls=t.jsx(ss,{}),cs=o.forwardRef(function(s,r){const f=Ct({props:s,name:"MuiCheckbox"}),{checkedIcon:g=as,color:x="primary",icon:d=is,indeterminate:v=!1,indeterminateIcon:l=ls,inputProps:y,size:j="medium",disableRipple:u=!1,className:h,slots:M={},slotProps:w={},...z}=f,b=v?l:d,T=v?l:g,q={...f,disableRipple:u,color:x,indeterminate:v,size:j},X=ns(q),Z=w.input??y,[K,U]=Be("root",{ref:r,elementType:os,className:yt(X.root,h),shouldForwardComponentProp:!0,externalForwardedProps:{slots:M,slotProps:w,...z},ownerState:q,additionalProps:{type:"checkbox",icon:o.cloneElement(b,{fontSize:b.props.fontSize??j}),checkedIcon:o.cloneElement(T,{fontSize:T.props.fontSize??j}),disableRipple:u,slots:M,slotProps:{input:wt(typeof Z=="function"?Z(q):Z,{"data-indeterminate":v})}}});return t.jsx(K,{...U,classes:X})}),ds=re(t.jsx("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"})),us=re(t.jsx("path",{d:"M17 7h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1 0 1.43-.98 2.63-2.31 2.98l1.46 1.46C20.88 15.61 22 13.95 22 12c0-2.76-2.24-5-5-5m-1 4h-2.19l2 2H16zM2 4.27l3.11 3.11C3.29 8.12 2 9.91 2 12c0 2.76 2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1 0-1.59 1.21-2.9 2.76-3.07L8.73 11H8v2h2.73L13 15.27V17h1.73l4.01 4L20 19.74 3.27 3z"})),hs=re(t.jsx("path",{d:"M11.07 12.85c.77-1.39 2.25-2.21 3.11-3.44.91-1.29.4-3.7-2.18-3.7-1.69 0-2.52 1.28-2.87 2.34L6.54 6.96C7.25 4.83 9.18 3 11.99 3c2.35 0 3.96 1.07 4.78 2.41.7 1.15 1.11 3.3.03 4.9-1.2 1.77-2.35 2.31-2.97 3.45-.25.46-.35.76-.35 2.24h-2.89c-.01-.78-.13-2.05.48-3.15M14 20c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2"}));function ps(e){try{const s=JSON.parse(e);if(s!==null&&typeof s=="object"&&"message"in s){const r=s;return{name:typeof r.name=="string"?r.name:void 0,message:String(r.message),stack:typeof r.stack=="string"?r.stack:void 0}}}catch{}return{message:e}}function ms(e){const s=e.toLowerCase(),r=[];return s.includes("cors")&&r.push({key:"cors",text:"This looks like a CORS error. Check that your server includes the correct Access-Control-Allow-Origin headers and that the request origin is allowed."}),(s.includes("json")||s.includes("parse")||s.includes("syntax"))&&r.push({key:"json",text:"This may be a JSON parsing issue. Verify that the request and response bodies are valid JSON and that Content-Type headers are set correctly."}),(s.includes("timeout")||s.includes("etimedout"))&&r.push({key:"timeout",text:"The request appears to have timed out. Consider increasing the timeout value or checking whether the server is under heavy load."}),(s.includes("econnrefused")||s.includes("enotfound"))&&r.push({key:"connection",text:"The server could not be reached. Verify that the server URL is correct and that the server is running."}),r}function xs({title:e="Last run",lastRun:s,runButton:r,extendable:f=!1,maxDetailsHeight:g}){const[x,d]=o.useState(!1),[v,l]=o.useState(!1);o.useEffect(()=>{s&&d(!0)},[s]);const y=o.useMemo(()=>s!=null&&s.errorMessage?ps(s.errorMessage):void 0,[s==null?void 0:s.errorMessage]),j=o.useMemo(()=>y?ms(y.message):[],[y]);return t.jsx(k,{spacing:2,display:"flex",sx:{flexGrow:1},children:t.jsxs(ve,{expanded:x,onChange:(u,h)=>d(h),sx:{bgcolor:"background.default"},children:[t.jsx(Ce,{expandIcon:t.jsx(we,{}),children:t.jsxs(k,{direction:{xs:"column",sm:"row"},spacing:1,alignItems:{xs:"flex-start",sm:"center"},sx:{width:"100%",paddingRight:2},children:[t.jsx(B,{variant:"subtitle1",children:e}),s?t.jsxs(k,{direction:"row",spacing:2,alignItems:"center",children:[t.jsx(kt,{status:s.status}),t.jsxs(B,{variant:"body2",color:"text.secondary",children:[s.duration??"—"," ms"]}),t.jsx(B,{variant:"body2",color:"text.secondary",children:s.time})]}):t.jsx(B,{variant:"body2",color:"text.secondary",children:"No runs yet"}),t.jsx(O,{sx:{flexGrow:1}}),r]})}),t.jsx(be,{children:s?t.jsxs(k,{spacing:2,children:[y?t.jsxs(k,{spacing:1.5,children:[t.jsx(B,{color:"error",sx:{fontWeight:600},children:y.name?`${y.name}: ${y.message}`:`Error: ${y.message}`}),y.stack?t.jsxs(O,{children:[t.jsxs(B,{variant:"body2",onClick:()=>l(u=>!u),sx:{cursor:"pointer",color:"text.secondary",userSelect:"none","&:hover":{textDecoration:"underline"}},children:[v?"Hide":"Show"," stack trace"]}),t.jsx(It,{in:v,children:t.jsx(B,{component:"pre",variant:"body2",sx:{fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-all",bgcolor:"action.hover",borderRadius:1,p:1.5,mt:.5,maxHeight:300,overflow:"auto"},children:y.stack})})]}):null,s.requestSnapshot?t.jsxs(O,{sx:{bgcolor:"action.hover",borderRadius:1,p:1.5},children:[t.jsx(B,{variant:"caption",color:"text.secondary",sx:{mb:.5,display:"block"},children:"Request that caused this error"}),t.jsxs(k,{spacing:.5,children:[s.requestSnapshot.method||s.requestSnapshot.path?t.jsxs(B,{variant:"body2",sx:{fontFamily:"monospace"},children:[s.requestSnapshot.method," ",s.requestSnapshot.path]}):null,s.requestSnapshot.body?t.jsx(B,{component:"pre",variant:"body2",sx:{fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-all",m:0},children:s.requestSnapshot.body}):null]})]}):null,j.map(u=>t.jsx(rt,{severity:"info",variant:"outlined",children:u.text},u.key))]}):null,t.jsx(Pt,{value:s.response,title:"Response body"})]}):t.jsx(B,{color:"text.secondary",children:"Run the endpoint to see output."})})]})})}function fs({items:e,activeId:s,isLoading:r=!1,label:f="Requests",onSelect:g,onAdd:x,onClose:d,canClose:v,renderLabel:l,disabled:y}){const j=y?!1:(v==null?void 0:v(e.length))??e.length>1;return t.jsxs(O,{sx:{position:"sticky",top:0,zIndex:5,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",boxShadow:u=>`0 4px 12px ${u.palette.common.black}11`},children:[t.jsxs(k,{direction:"row",alignItems:"center",spacing:1,sx:{px:2,py:1},children:[t.jsx(B,{variant:"subtitle2",color:"text.secondary",children:f}),r?t.jsx(nt,{size:12}):null]}),t.jsxs(O,{sx:{display:"flex",gap:1,alignItems:"center",overflow:"hidden",px:2,pb:.5},children:[e.map(u=>{const h=u.id===s,M=(l==null?void 0:l(u))??String(u.id);return t.jsxs(O,{onClick:()=>g(u.id),sx:{flex:h?"0 0 240px":"1 1 160px",minWidth:0,maxWidth:h?240:200,border:"1px solid",borderColor:h?"primary.main":"divider",bgcolor:h?"primary.main":"background.default",color:h?"primary.contrastText":"text.primary",cursor:"pointer",display:"flex",alignItems:"center",gap:.75,px:1,py:.5},children:[t.jsx(B,{variant:"subtitle2",noWrap:!0,sx:{flex:1,fontWeight:h?600:void 0},children:M}),t.jsx(k,{direction:"row",spacing:.5,alignItems:"center",children:t.jsx(se,{size:"small",onClick:w=>{w.stopPropagation(),j&&d(u.id)},disabled:!j,sx:{color:h?"primary.contrastText":"text.secondary"},children:t.jsx(Mt,{fontSize:"inherit"})})})]},u.id)}),t.jsx(se,{color:"primary",onClick:x,sx:{flexShrink:0,height:32,width:32,border:"1px solid",borderColor:"divider",alignSelf:"center"},disabled:y,children:t.jsx(qe,{fontSize:"small"})})]})]})}function je({title:e,rows:s,onChange:r,actions:f,defaultExpanded:g=!0,disableAccordion:x=!1,summaryToggleButton:d,showFieldMeta:v=!0,disabled:l}){const y=(w,z)=>{if(l)return;const b=s.map((T,q)=>q===w?{...T,...z}:T);r(b)},j=w=>{if(l)return;const z=s.filter((b,T)=>T!==w);r(z)},u=()=>{l||r([...s,He()])},h=t.jsxs(k,{spacing:1.5,children:[s.length===0&&t.jsx(B,{variant:"body2",color:"text.secondary",children:'No fields defined. Use "Add" to create one.'}),s.map((w,z)=>t.jsxs(k,{spacing:.5,children:[t.jsxs(k,{direction:{xs:"column",sm:"row"},spacing:1,alignItems:"center",children:[t.jsx(cs,{checked:w.enabled,onChange:b=>y(z,{enabled:b.target.checked}),disabled:l}),t.jsx(ye,{label:"Key",value:w.key,onChange:b=>y(z,{key:b.target.value}),disabled:l,sx:{flexGrow:1}}),t.jsx(ye,{label:"Value",value:w.value,onChange:b=>y(z,{value:b.target.value}),disabled:l,sx:{flexGrow:2}}),t.jsx(se,{onClick:()=>j(z),disabled:l,children:t.jsx($t,{})})]}),w.typeHint||w.description?t.jsxs(B,{variant:"caption",color:"text.secondary",sx:{pl:{sm:"48px"}},children:[w.typeHint?`Type: ${w.typeHint}`:null,w.typeHint&&w.description?" — ":"",w.description??null]}):null]},w.id)),t.jsx(_,{size:"small",variant:"outlined",startIcon:t.jsx(qe,{}),onClick:u,sx:{alignSelf:"flex-start"},disabled:l,children:"Add field"})]});if(x){const w=!!(e!=null&&e.trim())||!!f;return t.jsxs(k,{spacing:1.5,children:[w?t.jsxs(k,{direction:"row",alignItems:"center",spacing:1,flexWrap:"wrap",children:[e!=null&&e.trim()?t.jsx(B,{variant:"subtitle1",sx:{flexGrow:1},children:e}):t.jsx(O,{sx:{flexGrow:1}}),f]}):null,h]})}const M=f||d?t.jsxs(k,{direction:"row",spacing:1,alignItems:"center",children:[f,d?t.jsx(O,{sx:{display:"flex",alignItems:"center"},children:d}):null]}):null;return t.jsxs(ve,{defaultExpanded:g,children:[t.jsxs(Ce,{expandIcon:t.jsx(we,{}),sx:{alignItems:"center",gap:1},children:[t.jsx(B,{variant:"subtitle1",sx:{flexGrow:1},children:e}),M]}),t.jsx(be,{children:h})]})}const gs=re(t.jsx("path",{d:"M15 21h2v-2h-2zm4-12h2V7h-2zM3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2zm8-6h2v-2h-2zM15 5h2V3h-2zm4 8h2v-2h-2zm0 8c1.1 0 2-.9 2-2h-2z"})),ys=re(t.jsx("path",{d:"M15 15H3v2h12zm0-8H3v2h12zM3 13h18v-2H3zm0 8h18v-2H3zM3 3v2h18V3z"})),js=re(t.jsx("path",{fillRule:"evenodd",d:"M4 11h16v2H4z"}));function vs({value:e,onChange:s,placeholder:r,minRows:f=6,error:g,helperText:x,onBlur:d,disabled:v}){const[l,y]=o.useState(null),j=!!(g||l),u=l??x??"",h=o.useCallback(async()=>{try{await navigator.clipboard.writeText(e),y(null)}catch{y("Unable to copy to clipboard")}},[e]),M=o.useCallback(b=>{if(!e.trim()){s(""),y(null);return}try{const T=JSON.parse(e),q=b===void 0?JSON.stringify(T):JSON.stringify(T,null,b);s(q),y(null)}catch(T){console.error("Invalid JSON string",T),y("Invalid JSON body")}},[s,e]),w=()=>M(2),z=()=>M(void 0);return t.jsxs(O,{children:[t.jsxs(k,{direction:"row",spacing:.5,justifyContent:"flex-end",sx:{mb:1},children:[t.jsx(se,{size:"small",onClick:h,"aria-label":"Copy body",disabled:v,children:t.jsx(Et,{fontSize:"small"})}),t.jsx(se,{size:"small",onClick:w,"aria-label":"Format body",disabled:v,children:t.jsx(ys,{fontSize:"small"})}),t.jsx(se,{size:"small",onClick:z,"aria-label":"Inline body",disabled:v,children:t.jsx(js,{fontSize:"small"})})]}),t.jsx(ye,{placeholder:r,multiline:!0,fullWidth:!0,minRows:f,value:e,onChange:b=>{y(null),s(b.target.value)},onBlur:d,error:j,helperText:u,disabled:v}),j&&!u?t.jsx(B,{variant:"caption",color:"error",children:"Invalid JSON body"}):null]})}const Ee=({title:e,defaultExpanded:s=!0,summaryActions:r,schemaView:f,children:g})=>t.jsxs(ve,{defaultExpanded:s,children:[t.jsxs(Ce,{expandIcon:t.jsx(we,{}),sx:{alignItems:"center",gap:1},children:[t.jsx(B,{variant:"subtitle1",sx:{flexGrow:1},children:e}),r?t.jsx(k,{direction:"row",spacing:.5,alignItems:"center",children:r}):null]}),t.jsx(be,{children:t.jsx(k,{spacing:1,children:t.jsxs(k,{direction:{xs:"column",lg:"row"},spacing:2,alignItems:"stretch",children:[t.jsx(O,{flex:1,children:g}),f?t.jsx(O,{flexBasis:{lg:"40%"},minWidth:0,sx:{maxHeight:{lg:400},overflowY:"auto"},children:f}):null]})})})]});function Cs({method:e,path:s,queryRows:r,headerRows:f,bodyText:g,onMethodChange:x,onPathChange:d,onQueryChange:v,onHeadersChange:l,onBodyChange:y,querySection:j,headersSection:u,bodySection:h,disabled:M}){return t.jsxs(k,{spacing:2,children:[t.jsx(Ee,{title:"Query parameters",defaultExpanded:(j==null?void 0:j.defaultExpanded)??!0,summaryActions:j==null?void 0:j.summaryActions,schemaView:j==null?void 0:j.schemaView,children:t.jsx(je,{title:"",disableAccordion:!0,rows:r,onChange:v,showFieldMeta:(j==null?void 0:j.showFieldMeta)??!0,disabled:M})}),t.jsx(Ee,{title:"Headers",defaultExpanded:(u==null?void 0:u.defaultExpanded)??!1,summaryActions:u==null?void 0:u.summaryActions,schemaView:u==null?void 0:u.schemaView,children:t.jsx(je,{title:"",disableAccordion:!0,rows:f,onChange:l,actions:u==null?void 0:u.actions,disabled:M})}),t.jsx(Ee,{title:"Body",defaultExpanded:(h==null?void 0:h.defaultExpanded)??!1,summaryActions:h==null?void 0:h.summaryActions,schemaView:h==null?void 0:h.schemaView,children:t.jsx(vs,{value:g,onChange:y,error:h==null?void 0:h.error,helperText:h==null?void 0:h.helperText,minRows:8,onBlur:h==null?void 0:h.onBlur,disabled:M})})]})}function ws({requestInput:e,endpointOptions:s,isLoading:r,onEndpointSelect:f,onRequestInputChange:g,onCommit:x,onBlur:d,label:v="Method & URL",helperText:l,disabled:y}){return t.jsx(_t,{freeSolo:!0,fullWidth:!0,inputValue:e,options:s,loading:r,onChange:f,onInputChange:g,getOptionLabel:j=>typeof j=="string"?j:j.display,isOptionEqualToValue:(j,u)=>typeof j=="string"||typeof u=="string"?!1:j.value===u.value,renderInput:j=>t.jsx(ye,{...j,label:v,helperText:l,onBlur:d,onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),x==null||x())},InputProps:{...j.InputProps,endAdornment:t.jsxs(t.Fragment,{children:[r?t.jsx(nt,{size:16}):null,j.InputProps.endAdornment]}),disabled:y}})})}function bs({tab:e,onUpdateTab:s,endpointOptions:r,isOptionsLoading:f,onSearchChange:g,onEndpointSelect:x,runner:d}){var le,R,ne,D,ce,J,oe,ee,ae,ie,F,W,Y,de,S,H,V,ue;const{defaultHeaders:v,setDefaultHeaders:l}=ot(),y=(d==null?void 0:d.bodyError)??null,j=(d==null?void 0:d.setBodyError)??(()=>{}),u=o.useMemo(()=>e.route?e.route.method===e.method&&e.route.path===e.url:!1,[e]),h=o.useMemo(()=>{var m,a;return u?(a=(m=e.route)==null?void 0:m.contract)==null?void 0:a.body:void 0},[u,e.route]),M=o.useMemo(()=>`${e.method.toUpperCase()} ${e.url}`.trim(),[e.method,e.url]),[w,z]=o.useState(M),[b,T]=o.useState({params:!1,query:!1,body:!1});o.useEffect(()=>{z(M)},[M,e.id]),o.useEffect(()=>{if(!h||e.body&&e.body.trim().length>0)return;const m=Wt(h);if(m!==void 0)try{const a=JSON.stringify(m,null,2);s(P=>({...P,body:a}))}catch{}},[h,s,e.body]),o.useEffect(()=>{var P,A;if(!u)return;const m=(A=(P=e.route)==null?void 0:P.contract)==null?void 0:A.query;if(!m||e.query.length>0)return;const a=xe(m);a.length!==0&&s(te=>({...te,query:a}))},[u,s,e.query.length,e.route]);const q=o.useCallback(m=>{const a=m.trim();if(!a)return;const P=Fe(a);if(P){x(P.display);return}const[A,...te]=a.split(" ");if(te.length>0){const N=A.toLowerCase(),he=te.join(" ").trim()||"/";if(_e.includes(N)){s(ke=>({...ke,method:N,url:he}));return}}else{const N=A.toLowerCase();if(_e.includes(N)){s(he=>({...he,method:N}));return}}s(N=>({...N,url:a}))},[x,s]),X=o.useCallback(()=>{w.trim()!==M.trim()&&q(w)},[q,w,M]),Z=o.useMemo(()=>{var m;return!u||!((m=e.route)!=null&&m.contract)?!1:!!(e.route.contract.params||e.route.contract.query||e.route.contract.body)},[u,e.route]),K=o.useCallback(()=>{s(m=>{var A;let a={...m};const P=(A=m.route)==null?void 0:A.contract;if(P!=null&&P.params&&(a={...a,params:ge(a.params,P.params)}),P!=null&&P.query&&(a={...a,query:ge(a.query,P.query)}),P!=null&&P.body){let te;if(a.body&&a.body.trim().length>0)try{te=JSON.parse(a.body)}catch{return a}const N=Qe(te,P.body);try{a={...a,body:JSON.stringify(N,null,2)}}catch{}}return a})},[s]),U=o.useCallback(()=>{var a,P;const m=(P=(a=e.route)==null?void 0:a.contract)==null?void 0:P.params;m&&s(A=>({...A,params:ge(A.params,m)}))},[s,e.route]),L=o.useCallback(()=>{var a,P;const m=(P=(a=e.route)==null?void 0:a.contract)==null?void 0:P.query;m&&s(A=>({...A,query:ge(A.query,m)}))},[s,e.route]),Q=o.useCallback(()=>{if(!h)return;let m;if(e.body&&e.body.trim().length>0)try{m=JSON.parse(e.body),j(null)}catch{j("Invalid JSON body");return}const a=Qe(m,h);try{const P=JSON.stringify(a,null,2);s(A=>({...A,body:P}))}catch{}},[h,s,j,e.body]),c=o.useCallback((m,a)=>{if(a){if(typeof a=="string"){z(a),q(a);return}z(a.display),x(a),g("")}},[q,x,g]),$=o.useCallback((m,a,P)=>{z(a),P==="input"&&g(a),(P==="clear"||P==="reset"&&a==="")&&g("")},[g]);return t.jsx(k,{spacing:2,sx:{minHeight:0,flexGrow:1},children:t.jsxs(k,{spacing:2,sx:{minHeight:0},children:[t.jsxs(k,{direction:{xs:"column",md:"row"},spacing:1.5,alignItems:{xs:"stretch",md:"center"},children:[t.jsx(ws,{requestInput:w,endpointOptions:r,isLoading:f,onEndpointSelect:c,onRequestInputChange:$,onBlur:X,onCommit:X,helperText:"Type a method and path or select an endpoint"}),u&&Z?t.jsx(_,{size:"small",variant:"outlined",onClick:K,sx:{whiteSpace:"nowrap",minWidth:"auto"},children:"Fill All"}):null]}),u?null:t.jsx(rt,{severity:"info",children:"Path parameters are disabled because this tab targets a raw URL."}),u?t.jsx(Is,{title:"Path parameters",defaultExpanded:e.params.length>0,schema:(R=(le=e.route)==null?void 0:le.contract)==null?void 0:R.params,schemaTitle:"Path parameters schema",showSchema:b.params,summaryActions:t.jsxs(t.Fragment,{children:[(D=(ne=e.route)==null?void 0:ne.contract)!=null&&D.params?t.jsx(_,{size:"small",variant:"text",onClick:m=>{m.stopPropagation(),U()},children:"Fill defaults"}):null,(J=(ce=e.route)==null?void 0:ce.contract)!=null&&J.params?t.jsx(Se,{showSchema:b.params,label:"path schema",onToggle:m=>T(a=>({...a,params:m}))}):null]}),children:t.jsx(je,{title:"",disableAccordion:!0,rows:e.params,onChange:m=>s(a=>({...a,params:m})),showFieldMeta:(ee=(oe=e.route)==null?void 0:oe.contract)!=null&&ee.params?b.params:!0})}):null,t.jsx(Cs,{method:e.method,path:e.url,queryRows:e.query,headerRows:e.headers,bodyText:e.body,onMethodChange:m=>s(a=>({...a,method:m})),onPathChange:m=>s(a=>({...a,url:m})),onQueryChange:m=>s(a=>({...a,query:m})),onHeadersChange:m=>s(a=>({...a,headers:m})),onBodyChange:m=>s(a=>({...a,body:m})),querySection:{defaultExpanded:e.query.length>0,summaryActions:t.jsxs(t.Fragment,{children:[(ie=(ae=e.route)==null?void 0:ae.contract)!=null&&ie.query?t.jsx(_,{size:"small",variant:"text",onClick:m=>{m.stopPropagation(),L()},children:"Fill defaults"}):null,(W=(F=e.route)==null?void 0:F.contract)!=null&&W.query?t.jsx(Se,{showSchema:b.query,label:"query schema",onToggle:m=>T(a=>({...a,query:m}))}):null]}),schemaView:b.query&&((de=(Y=e.route)==null?void 0:Y.contract)!=null&&de.query)?t.jsx(Te,{title:"Query schema",schema:(H=(S=e.route)==null?void 0:S.contract)==null?void 0:H.query}):void 0,showFieldMeta:(ue=(V=e.route)==null?void 0:V.contract)!=null&&ue.query?b.query:!0},headersSection:{defaultExpanded:!1,actions:t.jsxs(k,{direction:"row",spacing:1,children:[t.jsx(_,{size:"small",variant:"text",onClick:m=>{m.stopPropagation(),s(a=>({...a,headers:at(v)}))},disabled:v.length===0,children:"Use defaults"}),t.jsx(_,{size:"small",variant:"text",onClick:m=>{m.stopPropagation(),l(e.headers)},disabled:e.headers.length===0,children:"Save as defaults"})]})},bodySection:{defaultExpanded:!!h||e.body.trim().length>0,summaryActions:t.jsxs(t.Fragment,{children:[h?t.jsx(_,{size:"small",variant:"text",onClick:m=>{m.stopPropagation(),Q()},children:"Use defaults"}):null,h?t.jsx(Se,{showSchema:b.body,label:"body schema",onToggle:m=>T(a=>({...a,body:m}))}):null]}),schemaView:h&&b.body?t.jsx(Te,{title:"Body schema",schema:h}):void 0,helperText:y||(u?"Leave empty for no body":"JSON payload to send with this custom request"),error:!!y}})]})})}function ze(e,s){if(!s)return e;const r=e.map(x=>{const d=s[x.key];return d==null?x:{...x,value:String(d),enabled:!0}}),f=new Set(e.map(x=>x.key)),g=Object.entries(s).filter(([x])=>!f.has(x)).map(([x,d])=>He({key:x,value:d==null?"":String(d),enabled:!0}));return[...r,...g]}function xe(e){return e?e.kind==="object"&&e.properties?Object.entries(e.properties).map(([s,r])=>He({key:s,value:Kt(r),enabled:!(r!=null&&r.optional),typeHint:Gt(r),description:r==null?void 0:r.description})):[]:[]}function ks(e,s){if(e==null)return s?JSON.stringify({},null,2):"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return s?JSON.stringify({},null,2):""}}function Is({title:e,defaultExpanded:s,schema:r,schemaTitle:f,showSchema:g,summaryActions:x,children:d}){return t.jsxs(ve,{defaultExpanded:s,children:[t.jsxs(Ce,{expandIcon:t.jsx(k,{direction:"row",spacing:.5,alignItems:"center",children:t.jsx(we,{})}),children:[t.jsx(B,{variant:"subtitle1",sx:{flexGrow:1},children:e}),x?t.jsx(k,{direction:"row",spacing:.5,alignItems:"center",children:x}):null]}),t.jsx(be,{children:t.jsx(Ps,{schema:r,schemaTitle:f,showSchema:g,children:d})})]})}function Ps({children:e,schema:s,schemaTitle:r,showSchema:f}){return t.jsx(k,{spacing:1,children:t.jsxs(k,{direction:{xs:"column",lg:"row"},spacing:2,alignItems:"stretch",sx:{width:"100%"},children:[t.jsx(O,{flex:1,children:e}),f&&s?t.jsx(O,{flexBasis:{lg:"40%"},minWidth:0,sx:{maxHeight:{lg:400},overflowY:"auto"},children:t.jsx(Te,{title:r,schema:s})}):null]})})}function Se({showSchema:e,label:s,onToggle:r}){return r?t.jsx(Oe,{title:e?`Hide ${s}`:`Show ${s}`,placement:"top",children:t.jsx(se,{size:"small",color:e?"primary":"default",onClick:f=>{f.stopPropagation(),r(!e)},"aria-pressed":e,children:t.jsx(gs,{fontSize:"small",sx:{transition:"transform 0.2s ease",transform:e?"rotateY(180deg)":"none"}})})}):null}function Ms(e,s){const{fetch:r}=it(),{addRun:f}=lt(),[g,x]=o.useState(!1),[d,v]=o.useState(null);o.useEffect(()=>{v(null),x(!1)},[e==null?void 0:e.id]);const l=o.useCallback(async()=>{var u;if(!e)return;let y;if(e.body)try{y=JSON.parse(e.body),v(null)}catch{v("Invalid JSON body");return}const j=`run-${Date.now()}`;x(!0);try{const h={params:e.params,query:e.query,headers:e.headers,body:e.body},M=await r(e.method,e.url,h,j),w=pe(e.params),z=pe(e.query),b=pe(e.headers),T={id:M.id,method:M.log.method,path:M.log.path,createdAt:M.log.createdAt,durationMs:M.log.durationMs,status:M.log.status,response:M.log.output,errorMessage:(u=M.error)==null?void 0:u.message,headers:M.log.headers,request:{params:w,query:z,body:y,headers:b}};f(T),s(q=>({...q,latestResponse:T}))}catch(h){console.error("Playground run failed",h)}finally{x(!1)}},[f,r,s,e]);return{isRunning:g,bodyError:d,setBodyError:v,run:l}}const Es={method:"get",path:"/",stability:"unknown"},Ye=120,zs=800;function Ss(e){return{method:e.method,path:e.path,summary:e.summary,contract:e.contract,stability:e.stability}}function Bs(e,s,r){var d,v,l;const f=xe((d=s==null?void 0:s.contract)==null?void 0:d.params),g=xe((v=s==null?void 0:s.contract)==null?void 0:v.query),x=(l=s==null?void 0:s.contract)!=null&&l.body?JSON.stringify({},null,2):"";return{...e,name:r,method:(s==null?void 0:s.method)??e.method,url:(s==null?void 0:s.path)??e.url,params:f,query:g,headers:e.headers,body:x,latestResponse:null,route:s}}function Os({initialRoute:e,initialLabel:s,renderLayout:r}){var Re,De,Ne,$e;const{openPanel:f}=zt(),{client:g}=it(),{consumePrefill:x,prefillVersion:d,tabsState:v,updateTabsState:l}=lt(),{defaultHeaders:y,setDefaultHeaders:j,resetDefaultHeaders:u}=ot(),[h,M]=o.useState(Ye),w=o.useRef(null),z=o.useCallback(n=>{if(!w.current)return;const p=w.current.startY-n.clientY,i=w.current.startHeight+p;M(Math.min(Math.max(i,Ye),zs))},[]),b=o.useCallback(()=>{w.current=null,document.removeEventListener("pointermove",z),document.removeEventListener("pointerup",b)},[z]),T=o.useCallback(n=>{n.preventDefault(),w.current={startY:n.clientY,startHeight:h},document.addEventListener("pointermove",z),document.addEventListener("pointerup",b)},[h,z,b]);o.useEffect(()=>()=>{document.removeEventListener("pointermove",z),document.removeEventListener("pointerup",b)},[z,b]);const[q,X]=o.useState(""),[Z,K]=o.useState(!1),U=o.useRef(null),L=v.tabs,Q=v.activeTabId,c=L.find(n=>n.id===Q)??null,$=e??Es,{options:le,isLoading:R}=Ft(q),ne=o.useMemo(()=>{const n=new Map;return le.forEach(p=>n.set(p.value,p)),L.forEach(p=>{if(!p.route)return;const{displayId:i}=Pe(p.route.method,p.route.path);!i||n.has(i)||n.set(i,{value:i,display:i,method:p.route.method,path:p.route.path})}),Array.from(n.values())},[le,L]),D=o.useMemo(()=>!c||!c.route?!1:c.route.method===c.method&&c.route.path===c.url,[c]),ce=c?D?"matched":"raw":"matched",J=o.useMemo(()=>!c||!D||!c.route?null:Pe(c.route.method,c.route.path).displayId??null,[c,D]),oe=!!J&&D,ee=ce==="matched"?((Re=c==null?void 0:c.route)==null?void 0:Re.summary)??(e==null?void 0:e.summary)??"":"Raw URL request",ae=e?`${e.method}:${e.path}`:null,ie=o.useMemo(()=>{if(!e)return null;const{displayId:n}=Pe(e.method,e.path);return n??null},[e]),F=o.useCallback((n,p=$,i)=>{var Ve,Le,Je,We,Ge;const C=xe((Ve=p.contract)==null?void 0:Ve.params),I=xe((Le=p.contract)==null?void 0:Le.query),E=at(y),G=(Je=p.contract)!=null&&Je.body?JSON.stringify({},null,2):"",fe=(i==null?void 0:i.method)??p.method,ft=(i==null?void 0:i.path)??p.path,Ie=(We=i==null?void 0:i.tabName)==null?void 0:We.trim(),gt=Ie&&Ie.length>0?Ie:n;return{id:`tab-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,name:gt,url:ft,method:fe,params:i!=null&&i.params?ze(C,i.params):C,query:i!=null&&i.query?ze(I,i.query):I,headers:i!=null&&i.headers?ze(E,i.headers):E,body:i?ks(i.body,!!((Ge=p.contract)!=null&&Ge.body)):G,latestResponse:null,route:p}},[y,$]);o.useEffect(()=>{if(L.length>0){Q||l(I=>{var E;return{...I,activeTabId:((E=I.tabs[0])==null?void 0:E.id)??null}});return}const n=e?{method:e.method,path:e.path}:void 0,p=x(n),i=(s==null?void 0:s.trim())||(e?`${e.method.toUpperCase()} ${e.path}`:"Tab 1"),C=F(i,e??$,p);l({tabs:[C],activeTabId:C.id})},[Q,x,F,$,s,e,L.length,l]),o.useEffect(()=>{!e||!ae||l(n=>{const p=n.tabs.find(E=>E.route?E.route.method===e.method&&E.route.path===e.path:E.method===e.method&&E.url===e.path);if(p)return n.activeTabId===p.id?n:{...n,activeTabId:p.id};const i=x({method:e.method,path:e.path,leafKey:ie??void 0}),C=(s==null?void 0:s.trim())||`${e.method.toUpperCase()} ${e.path}`,I=F(C,e,i);return{tabs:[...n.tabs,I],activeTabId:I.id}})},[x,F,ie,s,e,ae,l]),o.useEffect(()=>{e&&l(n=>{let p=!1;const i=n.tabs.map(C=>!C.route||C.route.method!==e.method||C.route.path!==e.path||C.route.contract&&C.route.summary?C:(p=!0,C.params.length===0&&C.query.length===0&&C.body.trim().length===0?Bs(C,e,C.name):{...C,route:e}));return p?{...n,tabs:i}:n})},[e,l]);const W=o.useCallback((n,p)=>{n&&l(i=>{let C=!1;const I=i.tabs.map(E=>{if(E.id!==n)return E;const G=p(E);return G===E?E:(C=!0,G)});return C?{...i,tabs:I}:i})},[l]),Y=o.useCallback(n=>{W(Q,n)},[Q,W]),de=o.useCallback(()=>{l(n=>{const p=F(`Tab ${n.tabs.length+1}`);return{tabs:[...n.tabs,p],activeTabId:p.id}})},[F,l]),S=o.useCallback(n=>{l(p=>({...p,activeTabId:n}))},[l]),H=o.useCallback(n=>{l(p=>{var I,E;if(p.tabs.length<=1){const G=F("Tab 1");return{tabs:[G],activeTabId:G.id}}const i=p.tabs.filter(G=>G.id!==n),C=p.activeTabId===n?((I=i[i.length-1])==null?void 0:I.id)??((E=i[0])==null?void 0:E.id)??null:p.activeTabId;return{tabs:i,activeTabId:C}})},[F,l]),V=o.useCallback(n=>{X(n)},[]),ue=o.useCallback(async n=>{var i;const p=St(n);if(!p)return null;try{const I=(i=(await g.fetch({method:"GET",path:"/__rrroutes/endpoints/:endpointId",params:{endpointId:p}})).data)==null?void 0:i.out;return I?Ss(I):null}catch(C){return console.error("Failed to load endpoint detail for playground",C),null}},[g]);o.useEffect(()=>{if(!d)return;const n=x();if(!n)return;let p=null;l(i=>{var E;const C=(E=n.tabName)!=null&&E.trim()&&n.tabName.trim().length>0?n.tabName.trim():n.method&&n.path?`${n.method.toUpperCase()} ${n.path}`:`Tab ${i.tabs.length+1}`,I=F(C,$,n);return p=I,{tabs:[...i.tabs,I],activeTabId:I.id}}),n.leafKey&&p&&ue(n.leafKey).then(i=>{!i||!p||W(p.id,C=>({...C,route:i}))})},[x,F,$,d,ue,W,l]);const m=o.useCallback(n=>{if(!n)return;const p=typeof n=="string"?Fe(n):n;if(!p)return;const i=p.method.toLowerCase(),C=p.path,I=L.find(E=>E.method.toLowerCase()===i&&E.url===C);if(I){S(I.id);return}Y(E=>({...E,method:i,url:C}))},[S,Y,L]),a=((c==null?void 0:c.method)??$.method).toUpperCase(),P=(c==null?void 0:c.url)??$.path,A=D?oe?"Route matched. Click to view endpoint.":"Route matched.":"Raw request. No matching endpoint.",te=o.useCallback(()=>{J&&f("endpoints")},[J,f]);o.useEffect(()=>{if(!c)return;const n=c.id,p=setTimeout(async()=>{const i=`${c.method.toUpperCase()} ${c.url}`.trim();if(!i)return;const C=ne.find(I=>I.value===i);if(C&&(!c.route||c.route.path!==C.path||c.route.method!==C.method)){U.current=i;const I=await ue(C.value);if(U.current!==i||!I)return;U.current=null,W(n,E=>{var G,fe;return((G=E.route)==null?void 0:G.path)===I.path&&((fe=E.route)==null?void 0:fe.method)===I.method?E:{...E,route:I}})}else!C&&c.route&&W(n,I=>I.route?{...I,route:void 0}:I)},500);return()=>{clearTimeout(p)}},[c,ne,ue,W]);const N=Ms(c??null,Y),he=o.useMemo(()=>c!=null&&c.latestResponse?{status:c.latestResponse.status,duration:c.latestResponse.durationMs,time:new Date(c.latestResponse.createdAt).toLocaleTimeString(),errorMessage:c.latestResponse.errorMessage,response:c.latestResponse.response}:null,[c==null?void 0:c.latestResponse]),ke=t.jsx(Oe,{title:"Default headers",children:t.jsx(se,{color:"inherit",onClick:()=>K(!0),"aria-label":"Default headers",size:"small",children:t.jsx(Ot,{fontSize:"small"})})}),ct=t.jsx(fs,{items:L,activeId:Q,isLoading:R,onSelect:S,onAdd:de,onClose:H,renderLabel:n=>{var p;return((p=n.name)==null?void 0:p.trim())||"Untitled Request"}}),dt=c?t.jsx(Bt,{method:c.method,url:c.url,headers:pe(c.headers),body:c.body||void 0,queryParams:pe(c.query)}):null,ut=t.jsxs(k,{direction:"row",spacing:1,alignItems:"center",children:[t.jsx(_,{variant:"contained",onClick:n=>{n.stopPropagation(),N.run()},disabled:N.isRunning,startIcon:t.jsx(Ht,{}),children:N.isRunning?"Running...":"Run"}),dt]}),ht=Math.max(h-140,180),pt=c?t.jsxs(O,{sx:{bgcolor:"background.paper",borderTop:"1px solid",borderColor:"divider",boxShadow:n=>`0 -8px 16px ${n.palette.common.black}11`,height:h,display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(O,{onPointerDown:T,sx:{cursor:"row-resize",py:.5,display:"flex",justifyContent:"center",borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper"},role:"presentation","aria-label":"Resize last run panel",children:t.jsx(O,{sx:{width:64,height:4,borderRadius:999,bgcolor:"divider"}})}),t.jsx(O,{sx:{flexGrow:1,overflow:"hidden",p:2},children:t.jsx(xs,{extendable:!0,lastRun:he,runButton:ut,maxDetailsHeight:ht})})]}):null,mt=t.jsx(k,{spacing:0,sx:{width:"100%",overflowX:"hidden",minHeight:0},children:t.jsx(O,{sx:{flexGrow:1,minHeight:0,p:{xs:2,md:3},display:"flex",overflowX:"hidden"},children:t.jsx(k,{spacing:3,flexGrow:1,sx:{minHeight:0,width:"100%"},children:c?t.jsxs(k,{spacing:3,flexGrow:1,sx:{minHeight:0},children:[t.jsxs(k,{spacing:.5,children:[t.jsxs(k,{direction:{xs:"column",sm:"row"},spacing:1.5,alignItems:{xs:"flex-start",sm:"center"},children:[t.jsx(Lt,{value:c.name,onChange:n=>Y(p=>({...p,name:n.target.value})),placeholder:"Untitled Request",sx:{fontSize:{xs:24,sm:28},fontWeight:600,px:1,py:.5,borderRadius:1,border:"1px solid",borderColor:"transparent",bgcolor:"background.paper",width:"100%",maxWidth:480,"&:hover":{borderColor:"divider"},"&:focus-within":{borderColor:"primary.main",boxShadow:n=>`0 0 0 3px ${n.palette.primary.main}22`}}}),t.jsx(Oe,{title:A,children:t.jsx("span",{children:t.jsx(se,{size:"small",onClick:oe?te:void 0,disabled:!oe,"aria-label":D?"Route matched":"Route not matched",sx:{color:D?((De=c.route)==null?void 0:De.stability)=="unknown"?"warning.main":"success.main":"error.main","&.Mui-disabled":{color:D?((Ne=c.route)==null?void 0:Ne.stability)=="unknown"?"warning.main":"success.main":"error.main",opacity:.5}},children:D?(($e=c.route)==null?void 0:$e.stability)=="unknown"?t.jsx(hs,{fontSize:"small"}):t.jsx(ds,{fontSize:"small"}):t.jsx(us,{fontSize:"small"})})})})]}),t.jsxs(B,{variant:"subtitle2",color:"text.secondary",children:[a," ",P]}),ee?t.jsx(B,{variant:"body2",color:"text.secondary",children:ee}):null]}),t.jsx(B,{variant:"body1",color:"text.secondary",children:ce==="matched"?"Execute this endpoint directly and inspect the response. Use the contract as a guide when filling params, query, and body.":"Execute a request against a custom URL. Query and body editors remain available, while route parameters are disabled."}),t.jsx(bs,{tab:c,onUpdateTab:Y,endpointOptions:ne,isOptionsLoading:R,onSearchChange:V,onEndpointSelect:m,runner:N},c.id)]}):t.jsxs(k,{spacing:2,alignItems:"center",justifyContent:"center",sx:{flexGrow:1},children:[t.jsx(B,{color:"text.secondary",children:"Get started by creating your first request."}),t.jsx(_,{variant:"contained",startIcon:t.jsx(qe,{}),onClick:de,children:"Create new Request"})]})})})}),xt=r({topOverlay:ct,bottomOverlay:pt,content:mt,settingsButton:ke});return t.jsxs(t.Fragment,{children:[xt,t.jsx(Ts,{open:Z,onClose:()=>K(!1),headers:y,onChange:j,onReset:u})]})}function Ts({open:e,onClose:s,headers:r,onChange:f,onReset:g}){return t.jsxs(Tt,{open:e,onClose:s,fullWidth:!0,maxWidth:"sm",children:[t.jsx(Dt,{children:"Default headers"}),t.jsx(qt,{dividers:!0,children:t.jsx(je,{title:"Default headers",rows:r,onChange:f,disableAccordion:!0,actions:t.jsx(_,{size:"small",variant:"text",onClick:g,disabled:r.length===0,children:"Reset"})})}),t.jsx(Nt,{children:t.jsx(_,{onClick:s,children:"Close"})})]})}function Xe(){const e=o.useRef(null),s=o.useRef(null),[r,f]=o.useState(0),g=()=>{var d;(d=e.current)==null||d.disconnect(),e.current=null},x=o.useCallback(d=>{if(s.current===d)return;if(g(),s.current=d,!d){f(0);return}const v=()=>{f(d.getBoundingClientRect().height)};e.current=new ResizeObserver(l=>{if(!Array.isArray(l)||l.length===0)return;const y=l[0];y&&f(y.contentRect.height)}),e.current.observe(d),v()},[]);return o.useEffect(()=>()=>{g()},[]),{ref:x,height:r}}function qs({top:e,bottom:s,children:r}){const f=Xe(),g=Xe(),d={position:"fixed",left:{xs:0,sm:240},right:0,zIndex:v=>v.zIndex.drawer+2};return t.jsxs(O,{sx:{position:"relative",width:"100%"},children:[t.jsx(O,{sx:{pt:10,pb:20,minHeight:"100%"},children:r}),e?t.jsx(Ue,{children:t.jsx(O,{sx:{...d,top:v=>{var l;return((l=v.mixins.toolbar)==null?void 0:l.minHeight)??64}},children:t.jsx(O,{ref:f.ref,sx:{pointerEvents:"auto",width:"100%"},children:e})})}):null,s?t.jsx(Ue,{children:t.jsx(O,{sx:{...d,bottom:0,pb:"env(safe-area-inset-bottom)"},children:t.jsx(O,{ref:g.ref,sx:{pointerEvents:"auto",width:"100%"},children:s})})}):null]})}function Us(){const{endpointId:e}=At(),s=e?decodeURIComponent(e):"",r=o.useMemo(()=>Fe(s),[s]),f=(r==null?void 0:r.display)??s??"",{data:g}=Rt(f),x=o.useMemo(()=>{if(g)return{method:g.method,path:g.path,summary:g.summary,contract:g.contract};if(r)return{method:r.method,path:r.path}},[g,r]);return t.jsx(Jt,{children:t.jsx(Os,{initialRoute:x,initialLabel:f,renderLayout:({topOverlay:d,bottomOverlay:v,content:l,settingsButton:y})=>t.jsx(qs,{top:d,bottom:v,children:t.jsxs(k,{spacing:4,children:[t.jsxs(k,{direction:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",spacing:2,children:[t.jsxs(O,{children:[t.jsx(B,{variant:"h4",component:"h1",gutterBottom:!0,children:"Playground"}),t.jsx(B,{variant:"body1",color:"text.secondary",children:"Experiment with any endpoint using the playground."})]}),t.jsx(O,{sx:{alignSelf:{xs:"flex-end",sm:"center"}},children:y})]}),l]})})})})}export{Us as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./vendor-xyflow.js";import{R as s}from"./docs.js";const a=s(o.jsx("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}));export{a as E};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as h}from"./vendor-xyflow.js";import{D as E}from"./Download.js";import{h as y}from"./vendor-recharts.js";import{a3 as C}from"./docs.js";const j="text/csv;charset=utf-8;",S=t=>t.toLowerCase().endsWith(".csv")?t:`${t}.csv`,m=t=>{if(t==null)return"";let e;if(t instanceof Date)e=t.toISOString();else if(typeof t=="object")try{e=JSON.stringify(t)}catch{e=String(t)}else e=String(t);const o=e.replace(/"/g,'""');return/[",\n\r]/.test(e)?`"${o}"`:o},v=t=>{const e=[],o=new Set;return t.forEach(r=>{Object.keys(r).forEach(s=>{o.has(s)||(o.add(s),e.push(s))})}),e};function g(t,e){if(typeof document>"u")throw new Error("exportToCsv can only be used in a browser environment.");const o=v(e),r=[];o.length&&r.push(o.map(c=>m(c)).join(",")),e.forEach(c=>{const p=o.map(i=>m(c[i]));r.push(p.join(","))});const s=r.join(`\r
|
|
2
|
-
`),d=new Blob([s],{type:j}),l=URL.createObjectURL(d),n=document.createElement("a");n.href=l,n.setAttribute("download",S(t)),n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(l)}function D({filename:t,rows:e,getRows:o,children:r="Export CSV",disabled:s,startIcon:d,variant:l="outlined",size:n="small",color:c="secondary",...p}){const[i,f]=y.useState(!1),b=y.useCallback(async()=>{if(!i){f(!0);try{let a=[];if(typeof o=="function"){const u=await o();a=Array.isArray(u)?u:[]}else Array.isArray(e)&&(a=e);g(t,a)}catch(a){console.error("Failed to export CSV",a)}finally{f(!1)}}},[i,t,o,e]),x=s||i||!e&&!o;return h.jsx(C,{variant:l,size:n,color:c,disabled:x,onClick:b,startIcon:d??h.jsx(E,{fontSize:"small"}),...p,children:r})}export{D as E};
|