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