import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{memo}from"react";import{useAtom}from"jotai";import{ExampleSwitch,useExampleKey}from"../Samples";import{useActivateExample,useOtelTelemetry}from"../../hooks";import{operationStore}from"../../jotai/operation";function ExampleComponent({mediaType:e,mediaContent:t,renderSample:m}){const a=useOtelTelemetry(),o=e.operation.pointer,[p,r]=useAtom(operationStore(o)),s=e.examples||{},n=Object.keys(s),i=useActivateExample(t),{exampleKey:l}=useExampleKey(e.operation,s);if(!n.length||1===n.length)return m();return _jsxs(_Fragment,{children:[_jsx(ExampleSwitch,{examples:s,exampleKey:l,onChange:e=>{a.send({type:"openapi_docs.examples_switcher.clicked",payload:{example:e,number_of_examples:n.length}}),r(Object.assign(Object.assign({},p),{activeExampleName:e,activeOneOf:{[o]:n.indexOf(e)},requestValues:{body:null}})),i(e)}}),m(l)]})}export const Example=memo(ExampleComponent);
//# sourceMappingURL=Example.js.map