import{r as n,j as s}from"./vendor-react-wBh_31cN.js";import{j as D,y as R,s as w,p as E,a as L,b as M,R as N}from"./vendor-codemirror-DA5NNfyg.js";import{d as y}from"./index-dNe6i2rS.js";import{L as _}from"./label-gPWmc6ow.js";import"./vendor-markdown-DYw41Xyj.js";import"./vendor-redux-CJZrIb6x.js";import"./vendor-router-D1GqFWiT.js";import"./vendor-utils-OeoE2qq_.js";import"./vendor-icons-BUUmD6ht.js";import"./vendor-radix-BRyWS4bQ.js";import"./vendor-grid-CeFlDWv4.js";const f=()=>typeof document<"u"&&document.documentElement.classList.contains("dark"),G=()=>{const[t,c]=n.useState(f);return n.useEffect(()=>{const e=new MutationObserver(()=>c(f()));return e.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>e.disconnect()},[]),t},l={json:L,python:E,sql:w,yaml:R,javascript:D},S=n.forwardRef(({mode:t,value:c,onChange:e,readOnly:r=!1,showLineNumbers:d=!0,height:h="200px",minHeight:x,maxHeight:g,className:j,label:a,labelAction:m,extensions:u,autoCompleteOverrides:o,codeMirrorProps:b},v)=>{const k=G(),I=n.useMemo(()=>{const i=[];return t&&l[t]&&i.push(l[t]()),o&&o.length>0&&i.push(M({override:o})),u&&i.push(...u),i},[t,u,o]),p=s.jsx("div",{ref:v,"data-slot":"code-input",className:y("overflow-hidden rounded-md border border-input shadow-xs transition-colors","[&_.cm-focused]:border-ring [&_.cm-focused]:ring-3 [&_.cm-focused]:ring-ring/50",j),children:s.jsx(N,{value:c,onChange:e,readOnly:r,editable:!r,extensions:I,height:h,minHeight:x,maxHeight:g,theme:k?"dark":"light",basicSetup:{lineNumbers:d,foldGutter:d,highlightActiveLineGutter:!r,highlightActiveLine:!r},...b})});return!a&&!m?p:s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[a&&s.jsx(_,{children:a}),m]}),p]})});S.displayName="CodeInputImpl";export{S as default};
