import o from"react";import{EmbeddedReplay as v,StoreProvider as E}from"@redocly/openapi-docs";import{Admonition as O}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{ErrorMessage as S,OpenApiComponentWrap as b}from"../styled.elements.js";import{useStore as A}from"../../hooks/use-store.js";import{getOperation as I}from"./get-operation/index.js";import{getMockServerDocsConfig as M}from"../../../../openapi-docs/template/mock-server-config.js";const B=f=>{const{descriptionFile:a,operationId:s,pointer:l,exampleKey:d,mimeType:c,requestBody:r,parameters:y,options:t,environment:n,environments:i}=f,{store:e,error:g,baseSlug:u}=A(a),p=o.useMemo(()=>({...e?.options,...t}),[t,e?.options]),m=o.useMemo(()=>{if(e)return I(e,{operationId:s,pointer:l},p,{exampleKey:d,mimeType:c,environments:i,environment:n,requestBody:r})},[d,p,c,s,l,e,i,n,r]);return e?m?o.createElement(b,null,o.createElement(E,{options:{...t,disableRouter:!0,routingBasePath:u,mockServer:M(p.mockServer,u)},definition:e.definition,withState:{environments:i,environment:n,operation:{pointer:m.pointer,state:{requestValues:{body:r,...y}}}}},o.createElement(v,{activeOperationId:m.operationId||"",fullOpenApi:e.definition,corsProxyUrl:e.options.corsProxyUrl}))):o.createElement(O,{type:"danger"},"Cannot find OpenAPI operation by operationId or pointer in ",a):o.createElement(S,null,g)};export{B as ReplayOpenApi};
