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