import{F as f,ai as x,r,l as b,aJ as y,j as l,aK as S,ax as v,o as h,m as T,Z as R,aL as B,aM as E,aN as J}from"./index.CS3tpmQq.js";import{l as k}from"./index.8HslT92O.js";import{R as w}from"./main.Bmkh5wwK.js";const L=f("div",{target:"e1ltsdae0"})(({theme:o})=>({overflowY:"auto",position:"relative",".react-json-view .copy-icon svg":{fontSize:"1em !important",marginRight:`${o.spacing.threeXS} !important`,verticalAlign:"middle !important"}})),P=f("div",{target:"e1ltsdae1"})(({theme:o})=>({display:"flex",alignItems:"center",gap:o.spacing.sm,padding:o.spacing.sm,paddingLeft:o.spacing.md,fontFamily:o.genericFonts.codeFont,fontSize:o.fontSizes.twoSm,color:o.colors.bodyText,maxWidth:"90vw",wordBreak:"break-all"})),$=f("button",{target:"e1ltsdae2"})(({theme:o})=>({display:"flex",alignItems:"center",justifyContent:"center",padding:o.spacing.threeXS,backgroundColor:"transparent",border:"none",borderRadius:o.radii.md,cursor:"pointer",color:o.colors.fadedText60,transition:"color 0.15s ease, background-color 0.15s ease","&:hover":{backgroundColor:o.colors.darkenedBgMix15,color:o.colors.bodyText},"&:active":{backgroundColor:o.colors.darkenedBgMix25},"&:focus":{outline:"none"},"&:focus-visible":{boxShadow:x(o)}})),I=f("div",{target:"e1ltsdae3"})(({top:o,left:e})=>({position:"fixed",top:o,left:e}));function j({top:o,left:e,path:t,clearTooltip:d}){const[p,s]=r.useState(!0),n=b(),{colors:i,radii:a}=n,{isCopied:c,copyToClipboard:u,label:m}=y(),g=r.useCallback(()=>{s(!1),d()},[d]),C=r.useCallback(()=>{u(t)},[u,t]);return l(B,{content:h(P,{"data-testid":"stJsonPathTooltip",children:[l("code",{children:t}),l($,{onClick:C,title:m,"aria-label":m,autoFocus:!0,children:l(R,{size:"sm",iconValue:c?":material/check:":":material/content_copy:"})})]}),placement:v.top,accessibilityType:S.tooltip,showArrow:!1,popoverMargin:15,onClickOutside:g,onEsc:g,overrides:{Body:{style:{borderTopLeftRadius:a.default,borderTopRightRadius:a.default,borderBottomLeftRadius:a.default,borderBottomRightRadius:a.default,paddingTop:"0 !important",paddingBottom:"0 !important",paddingLeft:"0 !important",paddingRight:"0 !important",backgroundColor:"transparent"}},Inner:{style:{backgroundColor:T(n)?i.bgColor:i.secondaryBg,color:i.bodyText,borderTopLeftRadius:a.default,borderTopRightRadius:a.default,borderBottomLeftRadius:a.default,borderBottomRightRadius:a.default,paddingTop:"0 !important",paddingBottom:"0 !important",paddingLeft:"0 !important",paddingRight:"0 !important"}}},isOpen:p,children:l(I,{"data-testid":"stJsonPathTooltipTarget",top:o,left:e})})}const F=r.memo(j);function z(o){return o.length===0?"$":o.reduce((e,t,d)=>{if(t===null)return e;if(/^\d+$/.test(t))return`${e}[${t}]`;if(t===""||/[^a-zA-Z0-9_$]/.test(t)||/^\d/.test(t)){const n=t.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`${e}["${n}"]`}return d===0||e===""?t:`${e}.${t}`},"")}function A(){const[o,e]=r.useState(null),t=r.useRef({x:0,y:0});r.useEffect(()=>{const s=n=>{t.current={x:n.clientX,y:n.clientY}};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const d=r.useCallback(s=>{const{x:n,y:i}=t.current,a=[...s.namespace,s.name],c=z(a);e({path:c,x:n,y:i})},[]),p=r.useCallback(()=>{e(null)},[]);return{tooltip:o,handleSelect:d,clearTooltip:p}}function M({element:o}){const e=b(),{tooltip:t,handleSelect:d,clearTooltip:p}=A(),{copyToClipboard:s}=y(),n=r.useCallback(c=>{s(JSON.stringify(c.src))},[s]);let i;try{i=JSON.parse(o.body)}catch(c){const u=E(c);try{i=k.parse(o.body)}catch{const g=parseInt(u.message.replace(/[^0-9]/g,""),10);return u.message+=`
${o.body.substring(0,g+1)} ← here`,l(J,{name:"Json Parse Error",message:u.message})}}const a=T(e)?"rjv-default":"monokai";return h(L,{className:"stJson","data-testid":"stJson",children:[l(w,{src:i,collapsed:o.maxExpandDepth??!o.expanded,displayDataTypes:!1,displayObjectSize:!1,name:!1,theme:a,enableClipboard:n,onSelect:d,style:{fontFamily:e.genericFonts.codeFont,fontSize:e.fontSizes.codeFontSize,fontWeight:e.fontWeights.code,backgroundColor:e.colors.bgColor,whiteSpace:"pre-wrap"}}),t&&l(F,{top:t.y,left:t.x,path:t.path,clearTooltip:p})]})}const W=r.memo(M);export{W as default};
