import{d as C,a0 as N,ao as O,bl as b,as as R,w as $,a2 as D,o as l,m as c,k as m,G as u,f as t,t as g,p as d,aa as M,bq as j,br as z,F as k,I as E,i as J,h,ay as P,bB as A,l as F,aC as q,_ as G}from"./CAAfHP_R.js";import{_ as I}from"./Cx373ZJy.js";import{e as T}from"./DROQPQ1U.js";const U=["open"],H={flex:"~ gap2","select-none":"","items-center":"",px4:""},K={key:0,class:"bg-red:10 px5 py3 text-red"},Y=C({__name:"StateEditor",props:{name:{},open:{type:Boolean},revision:{},state:{},readonly:{type:Boolean}},emits:["update:open"],setup(V,{emit:B}){const o=V,s=N(o,"open",B,{passive:!0}),_=O(),n=b(),p=b();function f(){p.value=void 0;try{o.state?n.value=JSON.parse(JSON.stringify(o.state||{})):(typeof o.state=="number"||typeof o.state!="string")&&(n.value=o.state)}catch(e){console.error(e),p.value=e}}R(()=>{f(),$(()=>[o.revision,o.state],e=>{typeof e!="number"&&typeof e!="string"?y(e,o.state):n.value=o.state},{deep:!0})});function y(e,r){const i=e[1];for(const a in i)Array.isArray(i[a])?r[a]=i[a].slice():typeof i[a]=="object"?y(i[a],r[a]):r[a]=i[a]}async function w(){f(),await q()}return(e,r)=>{const i=G,a=I,S=D("tooltip");return l(),c("div",{class:"state-editor-details",open:e.name?t(s):!0},[m("div",H,[e.name?(l(),c("button",{key:0,flex:"~","cursor-pointer":"","items-center":"",class:u(t(s)?"":"op50"),onClick:r[0]||(r[0]=v=>s.value=!t(s))},[m("div",{"i-carbon-chevron-right":"",transition:"",class:u(t(s)?"rotate-90 op0":"")},null,2),m("code",{px3:"",py1:"","font-mono":"",class:u(t(s)?"bg-[#8881] rounded-t":"rounded hover:bg-active")},g(e.name),3)],2)):d("",!0),M(e.$slots,"actions",j(z({isOpen:t(s),name:e.name,state:e.state}))),t(s)?(l(),c(k,{key:1},[E(J(i,{title:"Refresh View",icon:"carbon-renew",border:!1,onClick:w},null,512),[[S,"Refresh View",void 0,{bottom:!0}]]),t(n)&&!t(p)?(l(),h(a,{key:0,getter:()=>({name:e.name,input:JSON.stringify(t(n))})},null,8,["getter"])):d("",!0)],64)):d("",!0)]),t(s)||!e.name?(l(),c(k,{key:0},[t(p)?(l(),c("div",K," Error: "+g(t(p)),1)):(l(),h(t(T),P({key:1,modelValue:t(n),"onUpdate:modelValue":r[1]||(r[1]=v=>F(n)?n.value=v:null)},e.$attrs,{class:["json-editor-vue",[t(_)==="dark"?"jse-theme-dark":"",(e.name,"")]],"main-menu-bar":!1,"navigation-bar":!1,"status-bar":!1,"read-only":"readonly"in e?e.readonly:t(A),indentation:2,"tab-size":2}),null,16,["modelValue","class","read-only"]))],64)):d("",!0)],8,U)}}});export{Y as _};
