"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Example=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),jotai_1=require("jotai"),Samples_1=require("../Samples"),hooks_1=require("../../hooks"),operation_1=require("../../jotai/operation");function ExampleComponent({mediaType:e,mediaContent:t,renderSample:a}){const o=(0,hooks_1.useOtelTelemetry)(),r=e.operation.pointer,[s,n]=(0,jotai_1.useAtom)((0,operation_1.operationStore)(r)),i=e.examples||{},p=Object.keys(i),m=(0,hooks_1.useActivateExample)(t),{exampleKey:l}=(0,Samples_1.useExampleKey)(e.operation,i);if(!p.length||1===p.length)return a();return(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(Samples_1.ExampleSwitch,{examples:i,exampleKey:l,onChange:e=>{o.send({type:"openapi_docs.examples_switcher.clicked",payload:{example:e,number_of_examples:p.length}}),n(Object.assign(Object.assign({},s),{activeExampleName:e,activeOneOf:{[r]:p.indexOf(e)},requestValues:{body:null}})),m(e)}}),a(l)]})}exports.Example=(0,react_1.memo)(ExampleComponent);
//# sourceMappingURL=Example.js.map