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