var F=Object.defineProperty;var K=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var L=(o,s,e)=>s in o?F(o,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[s]=e,V=(o,s)=>{for(var e in s||(s={}))G.call(s,e)&&L(o,e,s[e]);if(K)for(var e of K(s))H.call(s,e)&&L(o,e,s[e]);return o};import{S as M,i as Q,s as T,e as j,j as J,k as P,c as w,a as E,m as N,d as g,n as W,b as C,J as O,f as X,K as v,o as R,W as U,x as b,u as S,v as q,l as Y,w as Z,O as D,P as I,X as x,Y as ee,r as se}from"../../../../chunks/vendor-cb8fe21e.js";import{p as te}from"../../../../chunks/stores-3696a338.js";import{g as re}from"../../../../chunks/navigation-51f4a605.js";import{E as A}from"../../../../chunks/editor-045a54b8.js";import{E as oe}from"../../../../chunks/error-ce582bf2.js";import"../../../../chunks/singletons-12a22614.js";import"../../../../chunks/preload-helper-ec9aa979.js";function B(o){let s,e,t,r,l,_,f,u,h,m,i,p;function $(a){o[9](a)}let k={language:"json",schema:V({type:"object"},o[0].schema.model)};return o[1]!==void 0&&(k.value=o[1]),r=new A({props:k}),x.push(()=>ee(r,"value",$)),r.$on("save",o[10]),u=new oe({props:{error:o[2]}}),i=new A({props:{language:"json",isReadonly:!0,value:JSON.stringify([],null,2)}}),{c(){s=j("div"),e=j("div"),t=j("div"),J(r.$$.fragment),_=P(),f=j("div"),J(u.$$.fragment),h=P(),m=j("div"),J(i.$$.fragment),this.h()},l(a){s=w(a,"DIV",{class:!0,style:!0});var c=E(s);e=w(c,"DIV",{class:!0,style:!0});var n=E(e);t=w(n,"DIV",{class:!0});var d=E(t);N(r.$$.fragment,d),d.forEach(g),_=W(n),f=w(n,"DIV",{class:!0,style:!0});var y=E(f);N(u.$$.fragment,y),y.forEach(g),n.forEach(g),h=W(c),m=w(c,"DIV",{class:!0});var z=E(m);N(i.$$.fragment,z),z.forEach(g),c.forEach(g),this.h()},h(){C(t,"class","w-full h-4/6"),C(f,"class","w-full h-2/6 border-t-2"),O(f,"border-color","#171812"),C(e,"class","w-8/12 border-r-2"),O(e,"border-color","#171812"),C(m,"class","w-4/12"),C(s,"class","flex flex-column h-screen"),O(s,"background-color","#272822")},m(a,c){X(a,s,c),v(s,e),v(e,t),R(r,t,null),v(e,_),v(e,f),R(u,f,null),v(s,h),v(s,m),R(i,m,null),p=!0},p(a,c){const n={};c&1&&(n.schema=V({type:"object"},a[0].schema.model)),!l&&c&2&&(l=!0,n.value=a[1],U(()=>l=!1)),r.$set(n);const d={};c&4&&(d.error=a[2]),u.$set(d)},i(a){p||(b(r.$$.fragment,a),b(u.$$.fragment,a),b(i.$$.fragment,a),p=!0)},o(a){S(r.$$.fragment,a),S(u.$$.fragment,a),S(i.$$.fragment,a),p=!1},d(a){a&&g(s),q(r),q(u),q(i)}}}function ae(o){let s,e,t=!!o[0]&&B(o);return{c(){t&&t.c(),s=Y()},l(r){t&&t.l(r),s=Y()},m(r,l){t&&t.m(r,l),X(r,s,l),e=!0},p(r,[l]){r[0]?t?(t.p(r,l),l&1&&b(t,1)):(t=B(r),t.c(),b(t,1),t.m(s.parentNode,s)):t&&(se(),S(t,1,1,()=>{t=null}),Z())},i(r){e||(b(t),e=!0)},o(r){S(t),e=!1},d(r){t&&t.d(r),r&&g(s)}}}function ne(o,s,e){let t,r,l,_;D(o,te,n=>e(7,l=n));const f=I("stores").models;D(o,f,n=>e(8,_=n));const u=I("stores").activeConfig;D(o,u,n=>e(11,t=n));const h=I("stores").activeClient;D(o,h,n=>e(12,r=n));const m=I("services");let i,p=JSON.stringify({},null,2),$;async function k(n){console.log("Saving...",n);try{e(2,$=null);const d=m.parse(n),{data:y}=await r.create(i.name,m.sanitize(d));console.log("Entity created",{entity:y}),re(`/${t.name}/${i.name}/${y[i.correlation_field]}`.toLowerCase(),{replaceState:!0})}catch(d){console.error(d),e(2,$=d)}}function a(n){p=n,e(1,p)}const c=()=>k(p);return o.$$.update=()=>{o.$$.dirty&384&&e(0,i=_[l.params.model])},[i,p,$,f,u,h,k,l,_,a,c]}class _e extends M{constructor(s){super();Q(this,s,ne,ae,T,{})}}export{_e as default};
