import{jsx as i}from"react/jsx-runtime";import{useAtomValue as m}from"jotai";import{XMLBuilder as c}from"fast-xml-parser";import{JsonViewer as a}from"@redocly/theme/components/JsonViewer/JsonViewer";import{isFormUrlEncoded as d,isJsonLike as f,isXmlLike as p,langFromMime as x,urlFormEncodePayload as g,isSequentialMediaType as y}from"../../utils/index.js";import{globalOptionsAtom as j}from"../../jotai/store.js";import{StyledCodeBlock as k}from"./styled.js";const L=new c({format:!0});function F({value:o,mimeType:r,encoding:n,onCopyClick:e,onPanelToggle:s}){const{jsonSamplesExpandLevel:l}=m(j);if(f(r)&&!y(r)){let t;try{t=typeof o=="string"?JSON.parse(o):o}catch{t=o}return i(a,{data:t,expandLevel:l,onCopyClick:e,onPanelToggle:s})}if(typeof o=="object")if(d(r))o=g(o,n);else if(p(r)){const t=Array.isArray(o)?o:{root:o};o=L.build(t)}else o=JSON.stringify(o,null,2);return i(k,{lang:x(r),source:o,header:{className:"code-block-header",controls:{copy:{onClick:e}}}})}export{F as ExampleValue};
