import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect}from"react";import{MimeLabel,Container,Select}from"../common";import{SelectOrLabel}from"../SelectOrLabel";import{normalizeText}from"../../utils";import{useOtelTelemetry}from"../../hooks";export const ExampleSwitch=({exampleKey:e,examples:t,onChange:a,className:l})=>{var m;const o=useOtelTelemetry(),r=Object.keys(t),s=e?r.indexOf(e):0,[i,n]=useState(s>-1?s:0);useEffect((()=>n(s>-1?s:0)),[e,s]);const c=r.map(((e,a)=>({value:normalizeText(t[e].summary)||e,idx:a})));return c.length<2?null:_jsx(Container,{"data-testid":"example-switch",className:l,children:_jsx(SelectOrLabel,{Select:Select,Label:MimeLabel,variant:"dark",fullWidth:!0,options:c,value:null===(m=c[i])||void 0===m?void 0:m.value,onChange:({idx:e})=>{o.send({type:"openapi_docs.examples_switcher.clicked",payload:{example:r[e],number_of_examples:r.length}}),n(e),a(r[e])}})})};
//# sourceMappingURL=ExampleSwitch.js.map