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