import{jsx as e}from"react/jsx-runtime";import{Suspense as S,lazy as h,memo as x,useEffect as O,useState as R}from"react";import{useAtomValue as o}from"jotai";import{globalOptionsAtom as T}from"../../jotai/store.js";import{operationStore as A}from"../../jotai/operation.js";import{appStore as C,allowedEnvironmentsAtom as L,environmentsAtom as V}from"../../jotai/app.js";import{useTranslate as j}from"../../hooks/index.js";import{convertOperationToReplayValue as k}from"./utils.js";import{getDefaultCollectorUrl as w}from"../../utils/telemetry.js";import{styled as i}from"../../styled-components.js";import{HTTPSnippet as P}from"../../services/code-samples/httpsnippet/index.js";const U=h(async()=>import("@redocly/replay").then(t=>({default:t.EmbeddedReplay})));function W({activeOperationId:t,corsProxyUrl:l,fullOpenApi:d,pointer:r,hideOtherSecuritySchemes:m}){const n=j(),{mockServer:s}=o(T),c=o(A(r)),f=o(C),u=o(V),a=o(L),[v,y]=R(!1);return O(()=>{y(!0)},[]),e(z,{children:v?e(S,{fallback:e(p,{children:n("openapi.loading","Loading...")}),children:e(U,{activeOperationId:t,activeOperationPointer:r,api:d,settings:{predefinedEnvValues:u,corsProxyUrl:l,mockServer:s,disableCollectionsTab:!0,hideOtherSecuritySchemes:m,...a&&{allowedEnvironments:a},telemetry:{tracerName:"replay-openapi",collectorUrl:w()},HTTPSnippet:P,convertOperationToReplayValue:(g,b,E)=>k(g,b,E,void 0,c,f)}})}):e(p,{children:n("openapi.loading","Loading...")})})}const M=x(W),p=i.div`
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100px;
`,z=i.div`
  border: 1px solid var(--border-color-primary);
  border-radius: var(--border-radius-lg);
  padding: 0;
`;export{M as EmbeddedReplay};
