import{At as e,Dt as t,J as n,L as r,Lt as i,M as a,O as o,U as s,a as c,jt as l,kt as u,lt as d,nt as f,u as p,v as m,w as h}from"./chunk.p3hCiSrt.js";import{t as g}from"./chunk.D93ZmnLR.js";import{t as _}from"./chunk.De1vj4hM.js";import{t as v}from"./chunk.DOwjsMaD.js";import"./chunk.TIounDiA.js";var y=i(l(),1);function b(e={timeout:2e3}){let[t,n]=(0,y.useState)(null),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(null),s=t=>{window.clearTimeout(a),o(window.setTimeout(()=>i(!1),e.timeout)),i(t)};return{copy:e=>{`clipboard`in navigator?navigator.clipboard.writeText(e).then(()=>s(!0)).catch(e=>n(e)):n(Error(`useClipboard: navigator.clipboard is not supported`))},reset:()=>{i(!1),n(null),window.clearTimeout(a)},error:t,copied:r}}var x=e(),S={timeout:1e3};function C(e){let{children:t,timeout:n,value:r,...i}=d(`CopyButton`,S,e),a=b({timeout:n});return(0,x.jsx)(x.Fragment,{children:t({copy:()=>a.copy(r),copied:a.copied,...i})})}C.displayName=`@mantine/core/CopyButton`;var w=[`secret`,`password`,`key`,`token`,`api_key`],T=e=>{let t=e.toLowerCase();return w.some(e=>t.includes(e))},E=e=>{let t=new Map;for(let n of e){let e=n.schema;if(e?.properties)for(let[r,i]of Object.entries(e.properties)){if(t.has(r))continue;let e=i,a=n.values[r],o=e.type??`unknown`,s=e.format;if(e.anyOf){let t=e.anyOf.find(e=>e.type!==`null`);t&&(o=t.type??`unknown`,s=t.format)}t.set(r,{name:r,value:a,type:o,description:e.description,format:s})}}return Array.from(t.values()).sort((e,t)=>e.name.localeCompare(t.name))},D=({variable:e})=>{let t=e.value!==void 0&&e.value!==``,i=t?String(e.value):``,a=T(e.name);return(0,x.jsxs)(c,{direction:`column`,children:[e.description?.split(`
`).map((e,t)=>(0,x.jsxs)(n,{fz:11,ff:`monospace`,c:`dimmed`,fs:`italic`,lh:1.6,children:[`# `,e]},t)),(0,x.jsxs)(c,{align:`center`,gap:0,style:{lineHeight:1.6},children:[(0,x.jsx)(n,{fz:12,ff:`monospace`,fw:600,c:`teal.5`,component:`span`,children:e.name}),(0,x.jsx)(n,{fz:12,ff:`monospace`,c:`dimmed`,component:`span`,children:`=`}),t?(0,x.jsx)(n,{fz:12,ff:`monospace`,component:`span`,style:{filter:a?`blur(4px)`:void 0,transition:`filter 150ms`,cursor:a?`pointer`:void 0},onMouseEnter:e=>{a&&(e.currentTarget.style.filter=`none`)},onMouseLeave:e=>{a&&(e.currentTarget.style.filter=`blur(4px)`)},children:i}):(0,x.jsx)(n,{fz:12,ff:`monospace`,c:`dimmed`,fs:`italic`,component:`span`,children:`(not set)`}),(0,x.jsx)(s,{size:`xs`,variant:`dot`,color:`gray`,ml:`sm`,style:{flexShrink:0},children:e.format||e.type}),t&&(0,x.jsx)(C,{value:String(e.value),children:({copied:e,copy:t})=>(0,x.jsx)(r,{label:e?`Copied!`:`Copy`,withArrow:!0,children:(0,x.jsx)(c,{ml:6,onClick:t,style:{cursor:`pointer`,flexShrink:0},c:e?`teal`:`dimmed`,children:e?(0,x.jsx)(o,{size:12}):(0,x.jsx)(h,{size:12})})})})]})]})},O=()=>{let e=u(t),[r,i]=(0,y.useState)([]),[o,l]=(0,y.useState)(``);(0,y.useEffect)(()=>{e.fetch(`/__devtools/api/metadata`,{schema:{response:v}}).then(e=>i(e.data.envs)).catch(()=>{})},[e]);let d=(0,y.useMemo)(()=>E(r),[r]),h=(0,y.useMemo)(()=>{if(!o)return d;let e=o.toLowerCase();return d.filter(t=>t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[d,o]);return d.length===0?(0,x.jsx)(c,{align:`center`,justify:`center`,style:{flex:1},c:`dimmed`,children:(0,x.jsxs)(c,{direction:`column`,align:`center`,gap:`xs`,children:[(0,x.jsx)(_,{size:40,opacity:.3}),(0,x.jsx)(n,{fz:`sm`,children:`No environment variables found`}),(0,x.jsx)(n,{fz:`xs`,c:`dimmed`,children:`Use $env primitive to define expected environment variables`})]})}):(0,x.jsxs)(c,{direction:`column`,style:{flex:1},children:[(0,x.jsx)(c,{p:`sm`,style:{borderBottom:`1px solid ${p.colors.border}`,flexShrink:0},children:(0,x.jsxs)(c,{gap:`sm`,align:`center`,children:[(0,x.jsx)(a,{placeholder:`Search variables...`,leftSection:(0,x.jsx)(m,{size:14}),size:`xs`,value:o,onChange:e=>l(e.currentTarget.value),style:{flex:1,maxWidth:340}}),(0,x.jsxs)(s,{variant:`light`,color:`gray`,size:`sm`,children:[h.length,` / `,d.length]})]})}),(0,x.jsx)(f,{style:{flex:1},p:`md`,children:(0,x.jsx)(g,{block:!0,style:{background:p.colors.surface,border:`1px solid ${p.colors.border}`,borderRadius:8,padding:16},children:(0,x.jsx)(c,{direction:`column`,gap:8,children:h.map(e=>(0,x.jsx)(D,{variable:e},e.name))})})})]})},k=()=>(0,x.jsx)(O,{});export{k as default};