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

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