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