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