"use strict";var __rest=this&&this.__rest||function(e,r){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&r.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(o=Object.getOwnPropertySymbols(e);l<o.length;l++)r.indexOf(o[l])<0&&Object.prototype.propertyIsEnumerable.call(e,o[l])&&(t[o[l]]=e[o[l]])}return t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CodeSample=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),theme_1=require("@redocly/theme"),styled_components_1=__importDefault(require("styled-components")),SelectOrLabel_1=require("../SelectOrLabel"),MediaTypeSwitch_1=require("../MediaTypeSwitch"),PayloadSamples_1=require("../PayloadSamples"),Example_1=require("./Example"),common_1=require("../common");function CodeSampleComponent(e){var r,{onCopyClick:t}=e,o=__rest(e,["onCopyClick"]);const l=null===(r=o.operation.requestBody)||void 0===r?void 0:r.content,a=(0,react_1.useCallback)((e=>{var r,t;return(null!==(t=null===(r=null==l?void 0:l.mediaTypes)||void 0===r?void 0:r.length)&&void 0!==t?t:0)>1?(0,jsx_runtime_1.jsx)(PayloadSamples_1.SelectWrapper,{children:(0,jsx_runtime_1.jsx)(SelectOrLabel_1.SelectOrLabel,Object.assign({Label:common_1.MimeLabel,Select:common_1.Select,variant:"dark",fullWidth:!0},e))}):null}),[l]),n=e=>o.source?(0,jsx_runtime_1.jsx)(StyledCodeBlock,{lang:o.lang,source:o.source,header:{className:"code-block-header",controls:{copy:{onClick:t}}}}):(0,jsx_runtime_1.jsx)(StyledCodeBlock,{lang:o.lang,externalSource:{sample:o.externalSample,exampleName:e,operation:o.operation,pathParams:o.pathParams,properties:o.properties},header:{className:"code-block-header",controls:{copy:{onClick:t}}}});return void 0===l||null!=o.source?n():(0,jsx_runtime_1.jsx)(MediaTypeSwitch_1.MediaTypesSwitch,{content:l,renderSelect:a,children:e=>(0,jsx_runtime_1.jsx)(Example_1.Example,{mediaType:e,mediaContent:l,renderSample:n})})}exports.CodeSample=(0,react_1.memo)(CodeSampleComponent);const StyledCodeBlock=(0,styled_components_1.default)(theme_1.CodeBlock)`
  border: none;
  margin: 0;

  .code-block-header {
    border-bottom: 0;
    padding-right: var(--spacing-sm);
  }
`;
//# sourceMappingURL=CodeSample.js.map