firstly 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/esm/BaseEnum.d.ts +2 -0
- package/esm/BaseEnum.js +2 -0
- package/esm/FF_Fields.js +0 -1
- package/esm/ROUTES.d.ts +2 -2
- package/esm/ROUTES.js +10 -5
- package/esm/SqlDatabase/FF_LogToConsole.d.ts +1 -0
- package/esm/SqlDatabase/FF_LogToConsole.js +22 -16
- package/esm/api/index.d.ts +19 -21
- package/esm/api/index.js +72 -62
- package/esm/auth/{client/Auth.d.ts → AuthController.d.ts} +18 -25
- package/esm/auth/{client/Auth.js → AuthController.js} +48 -44
- package/esm/auth/{client/Entities.d.ts → Entities.d.ts} +4 -3
- package/esm/auth/{client/Entities.js → Entities.js} +7 -7
- package/esm/auth/README.md +0 -10
- package/esm/auth/index.d.ts +5 -149
- package/esm/auth/index.js +5 -316
- package/esm/auth/{AuthController.server.d.ts → server/AuthController.server.d.ts} +10 -10
- package/esm/auth/{AuthController.server.js → server/AuthController.server.js} +126 -164
- package/esm/auth/server/handleAuth.d.ts +2 -0
- package/esm/auth/server/handleAuth.js +140 -0
- package/esm/auth/server/helperDb.d.ts +10 -0
- package/esm/auth/server/helperDb.js +56 -0
- package/esm/auth/server/helperFirstly.d.ts +1 -0
- package/esm/auth/server/helperFirstly.js +8 -0
- package/esm/auth/server/helperOslo.d.ts +7 -0
- package/esm/auth/server/helperOslo.js +24 -0
- package/esm/auth/server/helperRemultServer.d.ts +5 -0
- package/esm/auth/server/helperRemultServer.js +44 -0
- package/esm/auth/{RoleHelpers.d.ts → server/helperRole.d.ts} +1 -1
- package/esm/auth/{RoleHelpers.js → server/helperRole.js} +1 -1
- package/esm/auth/server/index.d.ts +5 -0
- package/esm/auth/server/index.js +5 -0
- package/esm/auth/server/module.d.ts +238 -0
- package/esm/auth/server/module.js +184 -0
- package/esm/auth/{providers → server/providers}/github.d.ts +6 -5
- package/esm/auth/{providers → server/providers}/github.js +30 -21
- package/esm/auth/{providers/index.d.ts → server/providers/helperProvider.d.ts} +0 -2
- package/esm/auth/{providers/index.js → server/providers/helperProvider.js} +5 -6
- package/esm/auth/static/assets/{Page-BEFYPjis.d.ts → Page-Bb8bFlrP.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-DtgkOCJs.js → Page-Bb8bFlrP.js} +1 -1
- package/esm/auth/static/assets/{Page-DtgkOCJs.d.ts → Page-BxomFlZ8.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-BEFYPjis.js → Page-BxomFlZ8.js} +1 -1
- package/esm/auth/static/assets/Page-CaIYu0-y.d.ts +6 -0
- package/esm/auth/static/assets/Page-CaIYu0-y.js +19 -0
- package/esm/auth/static/assets/Page-MkYglNtu.css +1 -0
- package/esm/auth/static/assets/index-Bl0Bk5u0.d.ts +64 -0
- package/esm/auth/static/assets/index-Bl0Bk5u0.js +2 -0
- package/esm/auth/static/assets/{index-CR_3yNaJ.css → index-R27C_TlP.css} +1 -1
- package/esm/auth/static/index.html +2 -2
- package/esm/auth/types.d.ts +5 -0
- package/esm/bin/cmd.js +13 -22
- package/esm/cellsBuildor.js +6 -6
- package/esm/changeLog/index.d.ts +0 -36
- package/esm/changeLog/index.js +3 -43
- package/esm/changeLog/server/index.d.ts +36 -0
- package/esm/changeLog/server/index.js +42 -0
- package/esm/cron/{index.d.ts → server/index.d.ts} +1 -1
- package/esm/cron/server/index.js +103 -0
- package/esm/feedback/FeedbackController.js +3 -3
- package/esm/feedback/index.d.ts +0 -16
- package/esm/feedback/index.js +0 -11
- package/esm/feedback/server/index.d.ts +17 -0
- package/esm/feedback/server/index.js +13 -0
- package/esm/feedback/ui/DialogIssue.svelte +4 -2
- package/esm/feedback/ui/DialogIssues.svelte +13 -4
- package/esm/feedback/ui/DialogMilestones.svelte +1 -1
- package/esm/feedback/ui/Feedback.svelte +3 -1
- package/esm/helper.d.ts +0 -1
- package/esm/helper.js +3 -17
- package/esm/index.d.ts +3 -17
- package/esm/index.js +3 -4
- package/esm/mail/index.d.ts +2 -30
- package/esm/mail/index.js +2 -79
- package/esm/mail/server/index.d.ts +31 -0
- package/esm/mail/server/index.js +88 -0
- package/esm/storeItem.d.ts +4 -1
- package/esm/storeItem.js +8 -2
- package/esm/storeList.d.ts +5 -2
- package/esm/storeList.js +1 -1
- package/esm/sveltekit/server/index.d.ts +11 -0
- package/esm/sveltekit/server/index.js +21 -0
- package/esm/ui/Button.svelte +1 -1
- package/esm/ui/Clipboardable.svelte +5 -2
- package/esm/ui/Field.svelte +4 -1
- package/esm/ui/Loading.svelte +4 -1
- package/esm/ui/Tooltip.svelte +2 -2
- package/esm/ui/dialog/DialogForm.svelte +1 -1
- package/esm/ui/dialog/DialogPrimitive.svelte +1 -2
- package/esm/ui/dialog/dialog.d.ts +6 -3
- package/esm/ui/dialog/dialog.js +1 -1
- package/esm/ui/internals/FieldContainer.svelte +0 -1
- package/esm/ui/internals/Input.svelte +3 -1
- package/esm/ui/internals/Textarea.svelte +2 -2
- package/esm/vite/index.js +24 -25
- package/package.json +50 -38
- package/esm/auth/Adapter.d.ts +0 -10
- package/esm/auth/Adapter.js +0 -50
- package/esm/auth/client/index.d.ts +0 -7
- package/esm/auth/client/index.js +0 -7
- package/esm/auth/helper.d.ts +0 -6
- package/esm/auth/helper.js +0 -14
- package/esm/auth/providers/strava.d.ts +0 -30
- package/esm/auth/providers/strava.js +0 -60
- package/esm/auth/static/assets/Page-BGTO8LC5.css +0 -1
- package/esm/auth/static/assets/Page-Cfysx_UV.d.ts +0 -6
- package/esm/auth/static/assets/Page-Cfysx_UV.js +0 -18
- package/esm/auth/static/assets/index-QypqCYwC.d.ts +0 -63
- package/esm/auth/static/assets/index-QypqCYwC.js +0 -2
- package/esm/cron/index.js +0 -102
- package/esm/handle/index.d.ts +0 -7
- package/esm/handle/index.js +0 -40
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var Ha=Object.defineProperty;var Wi=i=>{throw TypeError(i)};var Ga=(i,e,t)=>e in i?Ha(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var h=(i,e,t)=>Ga(i,typeof e!="symbol"?e+"":e,t),Hi=(i,e,t)=>e.has(i)||Wi("Cannot "+t);var Me=(i,e,t)=>(Hi(i,e,"read from private field"),t?t.call(i):e.get(i)),Ne=(i,e,t)=>e.has(i)?Wi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),$e=(i,e,t,n)=>(Hi(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t);import{n as oe,s as Qa,r as Tt,a as Pt,i as za,g as Ka,S as yt,b as mt,c as Ir,d as T,e as ki,v as It,f as Ot,h as gt,j as Gi,k as Jn,o as Qi,l as Un,m as Xa,p as Or,q as Ii,t as j,u as D,w as Ar,x as R,y as Sr,z as J,A as Cr,B as Er,C as Fr,D as ei,E as zi,F as Za,G as L,H as Ki,I as q,J as Pn,K as De,L as Ya,M as te,N as G,O as V,P as He,Q as S,R as Ee,T as Dn,U as ke,V as ne,W as ie,X as re,Y as Dt,Z as Rt,_ as Bt,$ as xa}from"./index-Bl0Bk5u0.js";function eo(i,e){const t={},n={},r={$$scope:1};let s=i.length;for(;s--;){const a=i[s],o=e[s];if(o){for(const l in a)l in o||(n[l]=1);for(const l in o)r[l]||(t[l]=o[l],r[l]=1);i[s]=o}else for(const l in a)r[l]=1}for(const a in n)a in t||(t[a]=void 0);return t}const _t=[];function Oi(i,e){return{subscribe:Ht(i,e).subscribe}}function Ht(i,e=oe){let t;const n=new Set;function r(o){if(Pt(i,o)&&(i=o,t)){const l=!_t.length;for(const f of n)f[1](),_t.push(f,i);if(l){for(let f=0;f<_t.length;f+=2)_t[f][0](_t[f+1]);_t.length=0}}}function s(o){r(o(i))}function a(o,l=oe){const f=[o,l];return n.add(f),n.size===1&&(t=e(r,s)||oe),o(i),()=>{n.delete(f),n.size===0&&t&&(t(),t=null)}}return{set:r,update:s,subscribe:a}}function Rn(i,e,t){const n=!Array.isArray(i),r=n?[i]:i;if(!r.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const s=e.length<2;return Oi(t,(a,o)=>{let l=!1;const f=[];let u=0,c=oe;const d=()=>{if(u)return;c();const y=e(n?f[0]:f,a,o);s?a(y):c=za(y)?y:oe},p=r.map((y,m)=>Qa(y,g=>{f[m]=g,u&=~(1<<m),l&&d()},()=>{u|=1<<m}));return l=!0,d(),function(){Tt(p),c(),l=!1}})}const to=i=>{const{subscribe:e,update:t}=Ht(i);return{subscribe:e,set:(n={})=>{t(r=>Object.assign(r,n))}}},tt=to({mode:"window",basePath:null}),Vn=(i=Ka(tt).mode)=>{let e="popstate";i==="window"&&(e="popstate"),i==="hash"&&(e="hashchange"),window.dispatchEvent(new Event(e))},Xi={go:(i=0)=>{history.go(i),Vn()},push:(i,e=null)=>{history.pushState(e,"",i),Vn()},replace:(i,e=null)=>{history.replaceState(e,"",i),Vn()}},no=i=>{const e=i.match(/^(\/[^?#]*)?/),t=i.match(/\?([^#]*)?/),n=i.match(/#(.*)?/);return{path:(e==null?void 0:e[1])||"/",query:t!=null&&t[1]?`?${t==null?void 0:t[1]}`:"",hash:n!=null&&n[1]?`#${n==null?void 0:n[1]}`:""}},Zi=()=>{const{pathname:i,search:e,hash:t}=document.location;return{path:i,query:e,hash:t}},Yi=()=>{let i=document.location.hash.substring(1);return i[0]!=="/"&&(i="/"+i),no(i)},io=Oi(Zi(),i=>{const e=()=>i(Zi());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),ro=Oi(Yi(),i=>{const e=()=>i(Yi());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}),Ai=Rn([tt,io,ro],([i,e,t],n)=>{i.mode==="window"&&n(e),i.mode==="hash"&&n(t)}),Wn=Rn(Ai,i=>i.path);Rn(Ai,i=>i.query);Rn(Ai,i=>i.hash);const Vt=i=>i.split(/(?=\/)/),Tr=()=>{let i=0;return()=>i++},ti=(i,e)=>e===null?i:i.startsWith(e)?i.slice(e.length):i,{Error:qt}=ki;function ni(i){let e;const t=i[11].default,n=Or(t,i,i[10],null),r={c:function(){n&&n.c()},m:function(a,o){n&&n.m(a,o),e=!0},p:function(a,o){n&&n.p&&(!e||o&1024)&&Cr(n,t,a,a[10],e?Fr(t,a[10],o,null):Er(a[10]),null)},i:function(a){e||(D(n,a),e=!0)},o:function(a){R(n,a),e=!1},d:function(a){n&&n.d(a)}};return T("SvelteRegisterBlock",{block:r,id:ni.name,type:"if",source:"(98:0) {#if isRouteActive(getPathWithoutBase($globalPath, $options.basePath), $route, $contextChildRoutes)}",ctx:i}),r}function ii(i){let e=ri(ti(i[1],i[2].basePath),i[0],i[3]),t,n,r=e&&ni(i);const s={c:function(){r&&r.c(),t=Ii()},l:function(o){throw new qt("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(o,l){r&&r.m(o,l),j(o,t,l),n=!0},p:function(o,[l]){l&15&&(e=ri(ti(o[1],o[2].basePath),o[0],o[3])),e?r?(r.p(o,l),l&15&&D(r,1)):(r=ni(o),r.c(),D(r,1),r.m(t.parentNode,t)):r&&(Ar(),R(r,1,1,()=>{r=null}),Sr())},i:function(o){n||(D(r),n=!0)},o:function(o){R(r),n=!1},d:function(o){o&&J(t),r&&r.d(o)}};return T("SvelteRegisterBlock",{block:s,id:ii.name,type:"component",source:"",ctx:i}),s}const xi=(i,e,t,n,r)=>{const s=(f,u,c)=>{const d=Vt(u).filter(p=>p!=="/").length;return(c??0)+(f?1:d)},a=(f,u)=>{const c={invalidPath:`<Route path="${f==null?void 0:f.path}" /> has invalid path. Path must start with '/'`,fallbackOutsideRoot:"<Route fallback /> cannot be outside root <Route />",pathOutsideRoot:`<Route path="${f==null?void 0:f.path}" /> cannot be outside root <Route />`,fallbackInsideFallback:"<Route fallback /> cannot be inside <Route fallback>",pathInsideFallback:`<Route path="${f==null?void 0:f.path}" /> cannot be inside <Route fallback>`};if(f.path[0]!=="/")throw new Error(c.invalidPath);if(f.root&&f.fallback)throw new Error(c.fallbackOutsideRoot);if(f.root&&f.path!=="/")throw new Error(c.pathOutsideRoot);if(u!=null&&u.fallback&&f.fallback)throw new Error(c.fallbackInsideFallback);if(u!=null&&u.fallback&&!f.fallback)throw new Error(c.pathInsideFallback)},o=s(t,n,r==null?void 0:r.depth),l={id:i,root:e,fallback:t,path:n,depth:o};return a(l,r),l},er=()=>{const{subscribe:i,update:e}=Ht([]);return{subscribe:i,update:t=>e(n=>[...n.filter(r=>t.id!==r.id),t]),remove:t=>e(n=>n.filter(r=>t.id!==r.id))}},ri=(i,e,t)=>{const n=(f,u,c,d)=>{let p=Vt(f).filter(g=>g!=="/"),y=Vt(c).filter(g=>g!=="/"),m="";if(c==="/")return u||p.length===d;for(let g=d-y.length;g<d;g++)m=m+p[g];return c===m},r=(f,u,c)=>{var y,m,g,I;let d=Vt(f).filter(v=>v!=="/"),p=!1;for(let v=0;v<(c==null?void 0:c.length)&&!p;v++)(y=c[v])!=null&&y.fallback||(p=n(f,((m=c[v])==null?void 0:m.root)??!1,((g=c[v])==null?void 0:g.path)??"",((I=c[v])==null?void 0:I.depth)??0));return d.length>=u&&!p},{root:s,fallback:a,path:o,depth:l}=e;return a?r(i,l,t):n(i,s,o,l)},tr=Tr(),un={},Hn={};function so(i,e,t){let n,r,s,a,o;It(Wn,"globalPath"),Ot(i,Wn,O=>t(1,s=O)),It(tt,"options"),Ot(i,tt,O=>t(2,a=O));let{$$slots:l={},$$scope:f}=e;gt("Route",l,["default"]);const u=tr(),c=!Gi(un);let{fallback:d=!1}=e,{path:p="/"}=e;const y=Ht();It(y,"route"),Ot(i,y,O=>t(0,n=O));const m=Jn(un);It(m,"contextRoute"),Ot(i,m,O=>t(9,r=O));const g=er(),I=Jn(Hn);It(I,"contextChildRoutes"),Ot(i,I,O=>t(3,o=O)),Qi(()=>I==null?void 0:I.remove(n)),Un(un,y),Un(Hn,g);const v=["fallback","path"];return Object.keys(e).forEach(O=>{!~v.indexOf(O)&&O.slice(0,2)!=="$$"&&O!=="slot"&&console.warn(`<Route> was created with unknown prop '${O}'`)}),i.$$set=O=>{"fallback"in O&&t(7,d=O.fallback),"path"in O&&t(8,p=O.path),"$$scope"in O&&t(10,f=O.$$scope)},i.$capture_state=()=>({writable:Ht,createIdIssuer:Tr,getPathSegments:Vt,getRoute:xi,createChildRoutes:er,isRouteActive:ri,getId:tr,routeContextKey:un,childRoutesContextKey:Hn,onDestroy:Qi,getContext:Jn,setContext:Un,hasContext:Gi,globalPath:Wn,options:tt,getPathWithoutBase:ti,id:u,root:c,fallback:d,path:p,route:y,contextRoute:m,childRoutes:g,contextChildRoutes:I,$route:n,$contextRoute:r,$globalPath:s,$options:a,$contextChildRoutes:o}),i.$inject_state=O=>{"fallback"in O&&t(7,d=O.fallback),"path"in O&&t(8,p=O.path)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),i.$$.update=()=>{i.$$.dirty&896&&Xa(y,n=xi(u,c,d,p,r),n),i.$$.dirty&1&&(I==null||I.update(n))},[n,s,a,o,y,m,I,d,p,r,f,l]}class Je extends yt{constructor(e){super(e),mt(this,e,so,ii,Ir,{fallback:7,path:8}),T("SvelteRegisterComponent",{component:this,tagName:"Route",options:e,id:ii.name})}get fallback(){throw new qt("<Route>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set fallback(e){throw new qt("<Route>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get path(){throw new qt("<Route>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set path(e){throw new qt("<Route>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const nr=i=>{var o;const e=(o=i.target)==null?void 0:o.closest("a[href]"),t=e==null?void 0:e.href;if(e===null||t===null)return!0;const n=["","true"].includes(e.getAttribute("data-handle-ignore")??"false"),r=(e.getAttribute("target")??"_self")!=="_self",s=i.metaKey||i.ctrlKey||i.altKey||i.shiftKey,a=new URL(t).origin!==document.location.origin;if(n||r||s||a)return!0;t===document.location.href?Xi.replace(t):Xi.push(t),i.preventDefault()},Pr=i=>(i.addEventListener("click",nr),{destroy:()=>{i.removeEventListener("click",nr)}}),ao="home/jycouet/udev/gh/dp/my-minion-mr/packages/firstly/node_modules/.pnpm/svelte-micro@2.5.7_svelte@4.2.18/node_modules/svelte-micro/dist/lib/components/Link.svelte";function si(i){let e,t,n,r;const s=i[5].default,a=Or(s,i,i[4],null);let o=[{href:i[0]},i[1]],l={};for(let u=0;u<o.length;u+=1)l=ei(l,o[u]);const f={c:function(){e=L("a"),a&&a.c(),Ki(e,l),q(e,ao,15,0,417)},l:function(c){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(c,d){j(c,e,d),a&&a.m(e,null),t=!0,n||(r=[Pn(Pr.call(null,e)),De(e,"click",i[6],!1,!1,!1,!1)],n=!0)},p:function(c,[d]){a&&a.p&&(!t||d&16)&&Cr(a,s,c,c[4],t?Fr(s,c[4],d,null):Er(c[4]),null),Ki(e,l=eo(o,[(!t||d&1)&&{href:c[0]},d&2&&c[1]]))},i:function(c){t||(D(a,c),t=!0)},o:function(c){R(a,c),t=!1},d:function(c){c&&J(e),a&&a.d(c),n=!1,Tt(r)}};return T("SvelteRegisterBlock",{block:f,id:si.name,type:"component",source:"",ctx:i}),f}const ir=(i,e,t)=>(i==="hash"?"#":"")+(e??"")+t;function oo(i,e,t){let n;const r=["href"];let s=zi(e,r),a;It(tt,"options"),Ot(i,tt,c=>t(3,a=c));let{$$slots:o={},$$scope:l}=e;gt("Link",o,["default"]);let{href:f}=e;i.$$.on_mount.push(function(){f===void 0&&!("href"in e||i.$$.bound[i.$$.props.href])&&console.warn("<Link> was created without expected prop 'href'")});function u(c){Ya.call(this,i,c)}return i.$$set=c=>{e=ei(ei({},e),Za(c)),t(1,s=zi(e,r)),"href"in c&&t(2,f=c.href),"$$scope"in c&&t(4,l=c.$$scope)},i.$capture_state=()=>({getFormatedHref:ir,options:tt,linkHandle:Pr,href:f,formatedHref:n,$options:a}),i.$inject_state=c=>{"href"in e&&t(2,f=c.href),"formatedHref"in e&&t(0,n=c.formatedHref)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),i.$$.update=()=>{i.$$.dirty&12&&t(0,n=ir(a.mode,a.basePath,f))},[n,s,f,a,l,o,u]}class Ue extends yt{constructor(e){super(e),mt(this,e,oo,si,Ir,{href:2}),T("SvelteRegisterComponent",{component:this,tagName:"Link",options:e,id:si.name})}get href(){throw new Error("<Link>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set href(e){throw new Error("<Link>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}class ct{constructor(...e){h(this,"fields");h(this,"options",{});h(this,"target");h(this,"readonly",!0);h(this,"allowNull",!1);h(this,"dbReadOnly",!1);h(this,"isServerExpression",!1);h(this,"key","");h(this,"caption","");h(this,"inputType","");h(this,"dbName","");h(this,"valueType");this.fields=e}apiUpdateAllowed(e){throw new Error("Method not implemented.")}displayValue(e){throw new Error("Method not implemented.")}includedInApi(e){throw new Error("Method not implemented.")}toInput(e,t){throw new Error("Method not implemented.")}fromInput(e,t){throw new Error("Method not implemented.")}getDbName(){return Promise.resolve("")}getId(e){let t=r=>e[r.key];typeof e=="function"&&(t=e);let n="";return this.fields.forEach(r=>{n.length>0&&(n+=","),n+=r.valueConverter.toJson(t(r))}),n}get valueConverter(){throw new Error("cant get value converter of compound id")}isEqualTo(e){let t={},r=e.toString().split(",");return this.fields.forEach((s,a)=>{t[s.key]=s.valueConverter.fromJson(r[a])}),t}}function ae(i,e=!0){var n;if(i===void 0)throw new Error("entity is undefined");let t=i[ft];if(!t&&e)throw new Error("item "+(((n=i.constructor)==null?void 0:n.name)||i)+" was not initialized using a context");return t}const ft=Symbol.for("entityMember"),Dr=Symbol.for("entityInfo"),Rr=Symbol.for("entityInfo_key");function Te(i,e=!0){if(i===void 0){if(e)throw new Error("Undefined is not an entity :)");return}let t=i[Dr];if(!t&&e)throw new Error(i.prototype.constructor.name+" is not a known entity, did you forget to set @Entity() or did you forget to add the '@' before the call to Entity?");return t}function lo(i){return i[Rr]}function Gn(i,e){return{[Br]:{toType:i,type:e}}}const Br=Symbol.for("relationInfo");function uo(i){return i==null?void 0:i[Br]}const ai=Symbol.for("fieldRelationInfo");function fe(i){if(i)return i[ai]}function fo(i,e,t){for(const n of i.fields.toArray()){const r=uo(n.options);if(r&&!n[ai]){const s=r.toType(),a=e.repo(s,t),o=n.options;n[ai]={type:r.type,toEntity:s,options:o,toRepo:a,getFields:()=>{let l=o.field,f={fields:o.fields,compoundIdField:void 0};function u(p){return Error(`Error for relation: "${i.metadata.key}.${n.key}", `+p)}let c=()=>l||f.fields;if(r.type==="toMany"&&!c()){for(const p of a.fields.toArray())if(!c()){const y=fe(p),m=p.options;if(y&&y.toEntity===i.metadata.entityType){if(y.type==="reference")l=p.key;else if(y.type==="toOne"){if(m.field)l=m.field;else if(m.fields){let g={};for(const I in m.fields)if(Object.prototype.hasOwnProperty.call(m.fields,I)){const v=m.fields[I];g[v]=I}f.fields=g}}}}if(!c())throw u(`No matching field found on target "${a.metadata.key}". Please specify field/fields`)}function d(p,y){const m=y.fields.find(p);if(!m)throw u(`Field "${p}" was not found in "${y.key}".`);return m}r.type==="reference"&&(l=n.key),l&&(r.type==="toOne"||r.type==="reference"?a.metadata.idMetadata.field instanceof ct?f.compoundIdField=l:f.fields={[a.metadata.idMetadata.field.key]:l}:i.metadata.idMetadata.field instanceof ct?f.compoundIdField=l:f.fields={[l]:i.metadata.idMetadata.field.key});for(const p in f.fields)Object.prototype.hasOwnProperty.call(f.fields,p)&&(d(p,a.metadata),d(f.fields[p],i.metadata));return f}}}}}class N{constructor(e){h(this,"apply");this.apply=e}static throwErrorIfFilterIsEmpty(e,t){if(N.isFilterEmpty(e))throw{message:`${t}: requires a filter to protect against accidental delete/update of all rows`,httpStatusCode:400}}static isFilterEmpty(e){if(e.$and){for(const t of e.$and)if(!N.isFilterEmpty(t))return!1}if(e.$or){for(const t of e.$or)if(N.isFilterEmpty(t))return!0;return!1}return Object.keys(e).filter(t=>!["$or","$and"].includes(t)).length==0}static async getPreciseValues(e,t){const n=new In;return await N.fromEntityFilter(e,t).__applyToConsumer(n),n.preciseValues}async getPreciseValues(){const e=new In;return await this.__applyToConsumer(e),e.preciseValues}static createCustom(e,t=""){let n={key:t,rawFilterTranslator:e};return Object.assign(r=>{if(r==null&&(r={}),!n.key)throw"Usage of custom filter before a key was assigned to it";return{[dt+n.key]:r}},{rawFilterInfo:n})}static entityFilterToJson(e,t){return N.fromEntityFilter(e,t).toJson()}static entityFilterFromJson(e,t){return yn(e,{get:n=>t[n]})}static fromEntityFilter(e,t){let n=[];for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let s=t[r];if(r=="$or")n.push(new po(...s.map(a=>N.fromEntityFilter(e,a))));else if(r=="$not")n.push(new yo(N.fromEntityFilter(e,s)));else if(r=="$and")n.push(new rr(...s.map(a=>N.fromEntityFilter(e,a))));else if(r.startsWith(dt))n.push(new N(a=>{a.custom(r.substring(dt.length),s)}));else if(r==Mr)n.push(new N(a=>a.databaseCustom(s)));else{const a=e.fields[r],o=fe(a),l=a.options;let f=(o==null?void 0:o.type)==="toOne"?l.fields?new ho(a,e.fields,l):new co(e.fields[l.field]):new bn(a),u=!1;if(s!==void 0&&s!=null){s.$id!==void 0&&(s=s.$id);for(const c in s)if(Object.prototype.hasOwnProperty.call(s,c)){const d=s[c];switch(c){case"$gte":case">=":n.push(f.isGreaterOrEqualTo(d)),u=!0;break;case"$gt":case">":n.push(f.isGreaterThan(d)),u=!0;break;case"$lte":case"<=":n.push(f.isLessOrEqualTo(d)),u=!0;break;case"$lt":case"<":n.push(f.isLessThan(d)),u=!0;break;case"$ne":case"$not":case"!=":case"$nin":u=!0,Array.isArray(d)?n.push(f.isNotIn(d)):n.push(f.isDifferentFrom(d));break;case"$in":u=!0,n.push(f.isIn(d));break;case"$contains":u=!0,n.push(f.contains(d));break;case"$startsWith":u=!0,n.push(f.startsWith(d));break;case"$endsWith":u=!0,n.push(f.endsWith(d));break;case"$notContains":u=!0,n.push(f.notContains(d));break}}Array.isArray(s)&&(u=!0,n.push(f.isIn(s)))}!u&&s!==void 0&&n.push(f.isEqualTo(s))}}return new rr(...n)}__applyToConsumer(e){this.apply(e)}static async resolve(e){return typeof e=="function"?await e():e}toJson(){let e=new vn;return this.__applyToConsumer(e),e.result}static async translateCustomWhere(e,t,n){let r=new kn(async(s,a)=>{let o=[];for(const l in t.entityType){const f=t.entityType[l];f&&f.rawFilterInfo&&f.rawFilterInfo.rawFilterTranslator&&f.rawFilterInfo.key==s&&o.push(await N.fromEntityFilter(t,await f.rawFilterInfo.rawFilterTranslator(a,n)))}return o});return e.__applyToConsumer(r),await r.resolve(),e=new N(s=>r.applyTo(s)),e}}class bn{constructor(e){h(this,"metadata");this.metadata=e}processVal(e){if(Te(this.metadata.valueType,!1)){if(e==null){if(e===null&&!this.metadata.allowNull){const n=fe(this.metadata);if((n==null?void 0:n.type)==="reference")return n.toRepo.metadata.idMetadata.field.options.valueType===Number?0:""}return null}return typeof e=="string"||typeof e=="number"?e:ae(e).getId()}return e}contains(e){return new N(t=>t.containsCaseInsensitive(this.metadata,e))}notContains(e){return new N(t=>t.notContainsCaseInsensitive(this.metadata,e))}startsWith(e){return new N(t=>t.startsWithCaseInsensitive(this.metadata,e))}endsWith(e){return new N(t=>t.endsWithCaseInsensitive(this.metadata,e))}isLessThan(e){return e=this.processVal(e),new N(t=>t.isLessThan(this.metadata,e))}isGreaterOrEqualTo(e){return e=this.processVal(e),new N(t=>t.isGreaterOrEqualTo(this.metadata,e))}isNotIn(e){return new N(t=>{for(const n of e)t.isDifferentFrom(this.metadata,this.processVal(n))})}isDifferentFrom(e){return e=this.processVal(e),e==null&&this.metadata.allowNull?new N(t=>t.isNotNull(this.metadata)):new N(t=>t.isDifferentFrom(this.metadata,e))}isLessOrEqualTo(e){return e=this.processVal(e),new N(t=>t.isLessOrEqualTo(this.metadata,e))}isGreaterThan(e){return e=this.processVal(e),new N(t=>t.isGreaterThan(this.metadata,e))}isEqualTo(e){return e=this.processVal(e),e==null&&this.metadata.allowNull?new N(t=>t.isNull(this.metadata)):new N(t=>t.isEqualTo(this.metadata,e))}isIn(e){return e=e.map(t=>this.processVal(t)),(e==null?void 0:e.length)==1&&e[0]!=null&&e[0]!==null?new N(t=>t.isEqualTo(this.metadata,e[0])):new N(t=>t.isIn(this.metadata,e))}}class co extends bn{processVal(e){return e?typeof e=="string"||typeof e=="number"?e:ae(e).getId():null}}class ho{constructor(e,t,n){h(this,"metadata");h(this,"fields");h(this,"relationOptions");this.metadata=e,this.fields=t,this.relationOptions=n}processVal(e){throw new Error("Invalid for Many To One Relation Field")}contains(e){throw new Error("Invalid for Many To One Relation Field")}notContains(e){throw new Error("Invalid for Many To One Relation Field")}endsWith(e){throw new Error("Invalid for Many To One Relation Field")}startsWith(e){throw new Error("Invalid for Many To One Relation Field")}isLessThan(e){throw new Error("Invalid for Many To One Relation Field")}isGreaterOrEqualTo(e){throw new Error("Invalid for Many To One Relation Field")}isNotIn(e){return new N(t=>{e.forEach(n=>this.isDifferentFrom(n).__applyToConsumer(t))})}isDifferentFrom(e){return new N(t=>{const n=[];for(const r in this.relationOptions.fields)if(Object.prototype.hasOwnProperty.call(this.relationOptions.fields,r)){const s=this.relationOptions.fields[r];n.push(new N(a=>new bn(this.fields.find(s)).isDifferentFrom(e[r]).__applyToConsumer(a)))}t.or(n)})}isLessOrEqualTo(e){throw new Error("Invalid for Many To One Relation Field")}isGreaterThan(e){throw new Error("Invalid for Many To One Relation Field")}isEqualTo(e){return new N(t=>{for(const n in this.relationOptions.fields)if(Object.prototype.hasOwnProperty.call(this.relationOptions.fields,n)){const r=this.relationOptions.fields[n];new bn(this.fields.find(r)).isEqualTo(e[n]).__applyToConsumer(t)}})}isIn(e){return new N(t=>{t.or(e.map(n=>this.isEqualTo(n)))})}}class rr extends N{constructor(...t){super(n=>{for(const r of this.filters)r&&r.__applyToConsumer(n)});h(this,"filters");this.filters=t}add(t){this.filters.push(t)}}class po extends N{constructor(...t){super(n=>{let r=this.filters.filter(s=>s!==void 0);r.length>1?n.or(r):r.length==1&&r[0].__applyToConsumer(n)});h(this,"filters");this.filters=t}}class yo extends N{constructor(t){super(n=>{n.not(t)});h(this,"filter");this.filter=t}}const dt="$custom$",Mr="$db$",oi="$an array";class vn{constructor(){h(this,"result",{});h(this,"hasUndefined",!1)}databaseCustom(e){throw new Error("database custom is not allowed with api calls.")}custom(e,t){Array.isArray(t)&&(t={[oi]:t}),this.add(dt+e,t)}add(e,t){t===void 0&&(this.hasUndefined=!0);let n=this.result;if(!n[e]){n[e]=t;return}let r=n[e];r instanceof Array?r.push(t):r=[r,t],n[e]=r}or(e){this.add("OR",e.map(t=>{let n=new vn;return t.__applyToConsumer(n),n.result}))}not(e){let t=new vn;e.__applyToConsumer(t),this.add("NOT",t.result)}isNull(e){this.add(e.key+".null",!0)}isNotNull(e){this.add(e.key+".null",!1)}isIn(e,t){this.add(e.key+".in",t.map(n=>e.valueConverter.toJson(n)))}isEqualTo(e,t){this.add(e.key,e.valueConverter.toJson(t))}isDifferentFrom(e,t){this.add(e.key+".ne",e.valueConverter.toJson(t))}isGreaterOrEqualTo(e,t){this.add(e.key+".gte",e.valueConverter.toJson(t))}isGreaterThan(e,t){this.add(e.key+".gt",e.valueConverter.toJson(t))}isLessOrEqualTo(e,t){this.add(e.key+".lte",e.valueConverter.toJson(t))}isLessThan(e,t){this.add(e.key+".lt",e.valueConverter.toJson(t))}containsCaseInsensitive(e,t){this.add(e.key+".contains",t)}notContainsCaseInsensitive(e,t){this.add(e.key+".notContains",t)}startsWithCaseInsensitive(e,t){this.add(e.key+".startsWith",t)}endsWithCaseInsensitive(e,t){this.add(e.key+".endsWith",t)}}function yn(i,e){let t={};function n(o){t.$and||(t.$and=[]),t.$and.push(o)}function r(o,l){t[o]===void 0?t[o]=l:n({[o]:l})}[...i.fields].forEach(o=>{function l(u,c,d=!1,p=!1){let y=e.get(o.key+u);if(y!==void 0){let m=g=>{let I=g;if(d){let O;typeof g=="string"?O=JSON.parse(g):O=g,I=O.map(P=>p?P:o.valueConverter.fromJson(P))}else I=p?I:o.valueConverter.fromJson(I);let v=c(I);v!==void 0&&r(o.key,v)};if(!d&&y instanceof Array)y.forEach(g=>{m(g)});else{d&&typeof y=="string"&&(y=JSON.parse(y));const g=a(y);for(const I of g)m(I)}}}l("",u=>u),l(".gt",u=>({$gt:u})),l(".gte",u=>({$gte:u})),l(".lt",u=>({$lt:u})),l(".lte",u=>({$lte:u})),l(".ne",u=>({$ne:u})),l(".in",u=>u,!0);var f=e.get(o.key+".null");if(f)switch(f=f.toString().trim().toLowerCase(),f){case"y":case"true":case"yes":r(o.key,null);break;default:r(o.key,{$ne:null});break}l(".contains",u=>({$contains:u}),!1,!0),l(".notContains",u=>({$notContains:u}),!1,!0),l(".startsWith",u=>({$startsWith:u}),!1,!0),l(".endsWith",u=>({$endsWith:u}),!1,!0)});let s=e.get("OR");if(s){const l=a(s).map(f=>({$or:f.map(u=>yn(i,{get:c=>u[c]}))}));l.length==1?t.$or?t.$or.push(l[0].$or):t.$or=l[0].$or:n({$and:l})}if(s=e.get("NOT"),s){let o=a(s);const l=[];for(const f of o)if(Array.isArray(f))for(const u of f)l.push({$not:yn(i,{get:c=>u[c]})});else l.push({$not:yn(i,{get:u=>f[u]})});l.length==1&&!t.$not?t=l[0]:n({$and:l})}for(const o in i.entityType){const l=i.entityType[o];if(l&&l.rawFilterInfo&&l.rawFilterInfo.rawFilterTranslator){let f=e.get(dt+o);if(f!==void 0){const u=c=>{c[oi]!=null&&(c=c[oi]),r(dt+o,c)};Array.isArray(f)?f.forEach(c=>u(c)):u(f)}}}return t;function a(o){if(!Array.isArray(o))return[o];const l=[],f=[];for(const u of o)Array.isArray(u)?f.push(u):l.push(u);return f.push(l),f}}class kn{constructor(e){h(this,"translateCustom");h(this,"commands",[]);h(this,"promises",[]);this.translateCustom=e}applyTo(e){this.commands.forEach(t=>t(e))}or(e){let t;this.promises.push(Promise.all(e.map(async n=>{let r=new kn(this.translateCustom);return n.__applyToConsumer(r),await r.resolve(),new N(s=>r.applyTo(s))})).then(n=>{t=n})),this.commands.push(n=>n.or(t))}not(e){let t;this.promises.push((async()=>{let n=new kn(this.translateCustom);e.__applyToConsumer(n),await n.resolve(),t=new N(r=>n.applyTo(r))})()),this.commands.push(n=>n.not(t))}isEqualTo(e,t){this.commands.push(n=>n.isEqualTo(e,t))}isDifferentFrom(e,t){this.commands.push(n=>n.isDifferentFrom(e,t))}isNull(e){this.commands.push(t=>t.isNull(e))}isNotNull(e){this.commands.push(t=>t.isNotNull(e))}isGreaterOrEqualTo(e,t){this.commands.push(n=>n.isGreaterOrEqualTo(e,t))}isGreaterThan(e,t){this.commands.push(n=>n.isGreaterThan(e,t))}isLessOrEqualTo(e,t){this.commands.push(n=>n.isLessOrEqualTo(e,t))}isLessThan(e,t){this.commands.push(n=>n.isLessThan(e,t))}containsCaseInsensitive(e,t){this.commands.push(n=>n.containsCaseInsensitive(e,t))}notContainsCaseInsensitive(e,t){this.commands.push(n=>n.notContainsCaseInsensitive(e,t))}startsWithCaseInsensitive(e,t){this.commands.push(n=>n.startsWithCaseInsensitive(e,t))}endsWithCaseInsensitive(e,t){this.commands.push(n=>n.endsWithCaseInsensitive(e,t))}isIn(e,t){this.commands.push(n=>n.isIn(e,t))}custom(e,t){this.promises.push((async()=>{let n=await this.translateCustom(e,t);n&&(Array.isArray(n)?n.forEach(r=>r.__applyToConsumer(this)):n.__applyToConsumer(this))})())}databaseCustom(e){this.commands.push(t=>t.databaseCustom(e))}async resolve(){for(;this.promises.length>0;){let e=this.promises;this.promises=[],await Promise.all(e)}}}class In{constructor(){h(this,"rawValues",{});h(this,"preciseValues",new Proxy(this.rawValues,{get:(e,t)=>{if(t in e){let n=e[t];if(n.bad)return;if(n.values.length>0){const r=fe(n.field);if(r){if(r.type==="reference")return n.values.map(s=>r.toRepo.metadata.idMetadata.getIdFilter(s));throw new Error("Only relations toOne without field are supported.")}return n.values}}}}))}ok(e,...t){let n=this.rawValues[e.key];n?n.values.push(...t.filter(r=>!n.values.includes(r))):this.rawValues[e.key]={field:e,bad:!1,values:[...t]}}notOk(e){let t=this.rawValues[e.key];t?t.bad=!0:this.rawValues[e.key]={field:e,bad:!0,values:[]}}not(e){}or(e){const t=e.map(n=>{let r=new In;return n.__applyToConsumer(r),r});for(const n of t)for(const r in n.rawValues)if(Object.prototype.hasOwnProperty.call(n.rawValues,r)){const s=n.rawValues[r];s&&(s.bad?this.notOk(s.field):this.ok(s.field,...s.values))}for(const n in this.rawValues)if(Object.prototype.hasOwnProperty.call(this.rawValues,n))for(const r of t)r.rawValues[n]||this.notOk(this.rawValues[n].field)}isEqualTo(e,t){this.ok(e,t)}isDifferentFrom(e,t){this.notOk(e)}isNull(e){this.ok(e,null)}isNotNull(e){this.notOk(e)}isGreaterOrEqualTo(e,t){this.notOk(e)}isGreaterThan(e,t){this.notOk(e)}isLessOrEqualTo(e,t){this.notOk(e)}isLessThan(e,t){this.notOk(e)}containsCaseInsensitive(e,t){this.notOk(e)}notContainsCaseInsensitive(e,t){this.notOk(e)}startsWithCaseInsensitive(e,t){this.notOk(e)}endsWithCaseInsensitive(e,t){this.notOk(e)}isIn(e,t){this.ok(e,...t)}custom(e,t){}databaseCustom(e){}}var mo={};const Qn=Symbol.for("remult-static1");let mn={defaultRemultFactory:void 0,remultFactory:void 0,defaultRemult:void 0,asyncContext:void 0,columnsOfType:new Map,allEntities:[],classHelpers:new Map,actionInfo:{allActions:[],runningOnServer:!1,runActionWithoutBlockingUI:i=>i(),startBusyWithProgress:()=>({progress:i=>{},close:()=>{}})},fieldOptionsEnricher:void 0,captionTransformer:void 0,defaultDataProvider:()=>{}};typeof process<"u"&&mo.IGNORE_GLOBAL_REMULT_IN_TESTS||typeof globalThis[Qn]>"u"?(globalThis[Qn]=mn,mn.remultFactory=()=>Nr()):mn=globalThis[Qn];const E=mn;function Nr(){return E.defaultRemult||(E.defaultRemult=E.defaultRemultFactory()),E.defaultRemult}function go(){E.remultFactory=()=>Nr()}function ht(i){const e=i;if(typeof e[Gt]=="function")return e[Gt]();throw Error("Error getting repository internal from "+i)}const Gt=Symbol.for("getInternal");class wo{constructor(){h(this,"iAmRemultProxy",!0);h(this,"repoCache",new Map);h(this,"repo",(...e)=>{let t=E,n=this.repoCache.get(e[0]);n||this.repoCache.set(e[0],n=new Map);let r=n.get(e[1]);return r||(r={get fields(){return E.remultFactory().repo(...e).metadata.fields},[Gt](){return t.remultFactory().repo(...e)[Gt]()},relations:s=>t.remultFactory().repo(...e).relations(s),validate:(s,...a)=>t.remultFactory().repo(...e).validate(s,...a),addEventListener:(...s)=>t.remultFactory().repo(...e).addEventListener(...s),count:(...s)=>t.remultFactory().repo(...e).count(...s),create:(...s)=>t.remultFactory().repo(...e).create(...s),delete:s=>t.remultFactory().repo(...e).delete(s),deleteMany:s=>t.remultFactory().repo(...e).deleteMany(s),updateMany:(...s)=>t.remultFactory().repo(...e).updateMany(...s),find:(...s)=>t.remultFactory().repo(...e).find(...s),groupBy:(...s)=>t.remultFactory().repo(...e).groupBy(...s),aggregate:(...s)=>t.remultFactory().repo(...e).aggregate(...s),findFirst:(...s)=>t.remultFactory().repo(...e).findFirst(...s),findOne:(...s)=>t.remultFactory().repo(...e).findOne(...s),findId:(s,a)=>t.remultFactory().repo(...e).findId(s,a),toJson:s=>t.remultFactory().repo(...e).toJson(s),fromJson:(s,a)=>t.remultFactory().repo(...e).fromJson(s,a),getEntityRef:(...s)=>t.remultFactory().repo(...e).getEntityRef(...s),insert:s=>t.remultFactory().repo(...e).insert(s),liveQuery:(...s)=>t.remultFactory().repo(...e).liveQuery(...s),get metadata(){return E.remultFactory().repo(...e).metadata},query:s=>t.remultFactory().repo(...e).query(s),save:s=>t.remultFactory().repo(...e).save(s),upsert:s=>t.remultFactory().repo(...e).upsert(s),update:(s,a)=>t.remultFactory().repo(...e).update(s,a)},n.set(e[1],r),r)})}get liveQuerySubscriber(){return E.remultFactory().liveQuerySubscriber}set liveQuerySubscriber(e){E.remultFactory().liveQuerySubscriber=e}get liveQueryStorage(){return E.remultFactory().liveQueryStorage}set liveQueryStorage(e){E.remultFactory().liveQueryStorage=e}get liveQueryPublisher(){return E.remultFactory().liveQueryPublisher}set liveQueryPublisher(e){E.remultFactory().liveQueryPublisher=e}initUser(){return E.remultFactory().initUser()}call(e,t,...n){return E.remultFactory().call(e,t,...n)}get context(){return E.remultFactory().context}get dataProvider(){return E.remultFactory().dataProvider}set dataProvider(e){E.remultFactory().dataProvider=e}get repCache(){return E.remultFactory().repCache}authenticated(){return E.remultFactory().authenticated()}isAllowed(e){return E.remultFactory().isAllowed(e)}isAllowedForInstance(e,t){return E.remultFactory().isAllowedForInstance(e,t)}clearAllCache(){return E.remultFactory().clearAllCache()}useFetch(e){return E.remultFactory().useFetch(e)}get user(){return E.remultFactory().user}set user(e){E.remultFactory().user=e}get apiClient(){return E.remultFactory().apiClient}set apiClient(e){E.remultFactory().apiClient=e}get subscriptionServer(){return E.remultFactory().subscriptionServer}set subscriptionServer(e){E.remultFactory().subscriptionServer=e}}const Ae=new wo,_o="$count",bo=Symbol.for("GroupByForApiKey"),vo=["sum","avg","min","max","distinctCount"],$r={error500RetryCount:4};function li(i){return i.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()).replace("Email","eMail")}class ko{constructor(e,t,n){h(this,"repository");h(this,"isReferenceRelation");h(this,"allowNull");h(this,"storedItem");h(this,"id");this.repository=e,this.isReferenceRelation=t,this.allowNull=n}toJson(){if(this.storedItem)return this.item===null?null:this.repository.toJson(this.item)}setId(e){this.repository.metadata.idMetadata.field.valueType==Number&&(e=+e),this.id=e}waitLoadOf(e){return e==null?null:ht(this.repository)._getCachedByIdAsync(e,!1)}get(e){if(e==null)return null;const t=ht(this.repository)._getCachedById(e,this.isReferenceRelation);return this.isReferenceRelation&&!this.storedItem?!this.allowNull&&(this.id===0||this.id==="")?null:void 0:t}set(e){if(e===null&&!this.allowNull&&this.isReferenceRelation&&(this.id==0||this.id=="")){this.storedItem={item:null};return}if(this.storedItem=void 0,e)if(typeof e=="string"||typeof e=="number")this.id=e;else{let t=ae(e,!1);t&&!this.isReferenceRelation?(ht(this.repository)._addToCache(e),this.id=t.getId()):(this.storedItem={item:e},this.id=e[this.repository.metadata.idMetadata.field.key])}else e===null?this.id=null:this.id=void 0}get item(){return this.storedItem?this.storedItem.item:this.get(this.id)}async waitLoad(){return this.waitLoadOf(this.id)}}class sr{constructor(e){h(this,"url");this.url=e}add(e,t){this.url.indexOf("?")>=0?this.url+="&":this.url+="?",this.url+=encodeURIComponent(e)+"="+encodeURIComponent(t)}addObject(e,t=""){if(e!=null)for(var n in e){let r=e[n];this.add(n+t,r)}}}function Et(i){if(!i)return new ar;let e;return e||Lr(i)&&(e=new Io(i)),e||typeof i=="function"&&(e=new ar(i)),e}function Lr(i){let e=i;return!!(e&&e.get&&e.put&&e.post&&e.delete)}class Io{constructor(e){h(this,"http");this.http=e}async post(e,t){return await On(()=>fn(this.http.post(e,t)))}delete(e){return fn(this.http.delete(e))}put(e,t){return fn(this.http.put(e,t))}async get(e){return await On(()=>fn(this.http.get(e)))}}async function On(i){var t,n,r,s;let e=0;for(;;)try{return await i()}catch(a){if(((t=a.message)!=null&&t.startsWith("Error occurred while trying to proxy")||(n=a.message)!=null&&n.startsWith("Error occured while trying to proxy")||(r=a.message)!=null&&r.includes("http proxy error")||(s=a.message)!=null&&s.startsWith("Gateway Timeout")||a.status==500)&&e++<$r.error500RetryCount){await new Promise((o,l)=>{setTimeout(()=>{o({})},500)});continue}throw a}}function fn(i){let e;return i.toPromise!==void 0?e=i.toPromise():e=i,e.then(t=>t&&(t.status==200||t.status==201)&&t.headers&&t.request&&t.data!==void 0?t.data:t).catch(async t=>{throw await Oo(t)})}async function Oo(i){var s,a,o;let e=await i;var t;e.error?t=e.error:e.isAxiosError&&(typeof((s=e.response)==null?void 0:s.data)=="string"?t=e.response.data:t=(a=e==null?void 0:e.response)==null?void 0:a.data),t||(t=e.message),e.status==0&&e.error.isTrusted&&(t="Network Error"),typeof t=="string"&&(t={message:t}),e.modelState&&(t.modelState=e.modelState);let n=e.status;n===void 0&&(n=(o=e.response)==null?void 0:o.status),n!=null&&(t.httpStatusCode=n);var r=Object.assign(t??{},{});return r}class ui{constructor(e,t){h(this,"apiProvider");h(this,"entityRequested");h(this,"isProxy",!0);this.apiProvider=e,this.entityRequested=t}getEntityDataProvider(e){var t;return(t=this.entityRequested)==null||t.call(this,e),new Ao(()=>{var n;return qr((n=this.apiProvider())==null?void 0:n.url,e.key)},()=>Et(this.apiProvider().httpClient),e)}async transaction(e){throw new Error("Method not implemented.")}}function qr(i,e){return i==null&&(i="/api"),i+"/"+e}function Si(i,e){if(i.include){let t={};for(const n in i.include)if(Object.prototype.hasOwnProperty.call(i.include,n)){let r=i.include[n];if(typeof r=="object"){const s=fe(e.fields.find(n));s&&(r=Si(r,s.toRepo.metadata))}t[n]=r}i={...i,include:t}}return i.where&&(i={...i,where:N.entityFilterToJson(e,i.where)}),i.load&&(i={...i,load:i.load(e.fields).map(t=>t.key)}),i}class Ao{constructor(e,t,n){h(this,"url");h(this,"http");h(this,"entity");this.url=e,this.http=t,this.entity=n}query(e,t){return this.buildFindRequest(e).run("query",{aggregate:this.buildAggregateOptions(t)}).then(({items:r,aggregates:s})=>({items:r.map(a=>this.translateFromJson(a)),aggregates:s}))}async groupBy(e){const{run:t}=this.buildFindRequest({where:e==null?void 0:e.where,limit:e==null?void 0:e.limit,page:e==null?void 0:e.page}),n=this.buildAggregateOptions(e),r=await t("groupBy",Object.keys(n).length>0?n:void 0);return e!=null&&e.group&&r.forEach(s=>{for(const a of e.group)s[a.key]=a.valueConverter.fromJson(s[a.key])}),r}buildAggregateOptions(e){var t,n,r,s,a,o,l;return{groupBy:(t=e==null?void 0:e.group)==null?void 0:t.map(f=>f.key),sum:(n=e==null?void 0:e.sum)==null?void 0:n.map(f=>f.key),avg:(r=e==null?void 0:e.avg)==null?void 0:r.map(f=>f.key),min:(s=e==null?void 0:e.min)==null?void 0:s.map(f=>f.key),max:(a=e==null?void 0:e.max)==null?void 0:a.map(f=>f.key),distinctCount:(o=e==null?void 0:e.distinctCount)==null?void 0:o.map(f=>f.key),orderBy:(l=e==null?void 0:e.orderBy)==null?void 0:l.map(f=>{var u;return{...f,field:(u=f.field)==null?void 0:u.key}})}}translateFromJson(e){let t={};for(const n of this.entity.fields)t[n.key]=n.valueConverter.fromJson(e[n.key]);return t}translateToJson(e){let t={};for(const n of this.entity.fields)t[n.key]=n.valueConverter.toJson(e[n.key]);return t}async count(e){const{run:t}=this.buildFindRequest({where:e});return t("count").then(n=>+n.count)}async deleteMany(e){const{run:t}=this.buildFindRequest({where:e},"delete");return t("deleteMany").then(n=>+n.deleted)}async updateMany(e,t){const{run:n}=this.buildFindRequest({where:e},"put");return n("updateMany",this.toJsonOfIncludedKeys(t)).then(r=>+r.updated)}async upsertMany(e){const{run:t}=this.buildFindRequest(void 0);return t("upsertMany",e.map(n=>({where:this.toJsonOfIncludedKeys(n.where),set:n.set!==void 0?this.toJsonOfIncludedKeys(n.set):void 0}))).then(n=>n.map(r=>this.translateFromJson(r)))}find(e){let{run:t}=this.buildFindRequest(e);return t().then(n=>n.map(r=>this.translateFromJson(r)))}buildFindRequest(e,t){t||(t="get");let n=new sr(this.url()),r;if(e){if(e.where&&(r=e.where.toJson(),Co(r,n)&&(r=void 0)),e.orderBy&&e.orderBy.Segments){let a="",o="",l=!1;e.orderBy.Segments.forEach(f=>{a.length>0&&(a+=",",o+=","),a+=f.field.key,o+=f.isDescending?"desc":"asc",f.isDescending&&(l=!0)}),a&&n.add("_sort",a),l&&n.add("_order",o)}e.limit&&n.add("_limit",e.limit),e.page&&n.add("_page",e.page)}const s=(a,o)=>{let l=new sr(n.url);if(!a&&r&&(a="get"),a&&l.add("__action",a),r){if(t==="put")return this.http().post(l.url,{set:o,where:r});o={...o,where:r}}return o&&t!="put"?this.http().post(l.url,o):this.http()[t](l.url,o)};return{createKey:()=>JSON.stringify({url:n,filterObject:r}),run:s,subscribe:async a=>({result:await s(Eo+a),unsubscribe:async()=>E.actionInfo.runActionWithoutBlockingUI(()=>this.http().post(this.url()+"?__action=endLiveQuery",{id:a}))})}}update(e,t){return this.http().put(this.url()+(e!=""?"/"+encodeURIComponent(e):"?__action=emptyId"),this.toJsonOfIncludedKeys(t)).then(n=>this.translateFromJson(n))}toJsonOfIncludedKeys(e){let t={},n=Object.keys(e);for(const r of this.entity.fields)n.includes(r.key)&&(t[r.key]=r.valueConverter.toJson(e[r.key]));return t}async delete(e){if(e=="")await this.deleteMany(N.fromEntityFilter(this.entity,this.entity.idMetadata.getIdFilter(e)));else return this.http().delete(this.url()+"/"+encodeURIComponent(e))}insert(e){return this.http().post(this.url(),this.translateToJson(e)).then(t=>this.translateFromJson(t))}insertMany(e){return this.http().post(this.url(),e.map(t=>this.translateToJson(t))).then(t=>t.map(n=>this.translateFromJson(n)))}}class ar{constructor(e){h(this,"fetch");this.fetch=e}async get(e){return await On(async()=>this.myFetch(e).then(t=>t))}put(e,t){return this.myFetch(e,{method:"put",body:JSON.stringify(t)})}delete(e){return this.myFetch(e,{method:"delete"})}async post(e,t){return await On(()=>this.myFetch(e,{method:"post",body:JSON.stringify(t)}))}myFetch(e,t){const n={};if(t!=null&&t.body&&(n["Content-type"]="application/json"),typeof window<"u"&&typeof window.document<"u"&&typeof(window.document.cookie!=="undefined"))for(const r of window.document.cookie.split(";"))r.trim().startsWith("XSRF-TOKEN=")&&(n["X-XSRF-TOKEN"]=r.split("=")[1]);return(this.fetch||fetch)(e,{credentials:"include",method:t==null?void 0:t.method,body:t==null?void 0:t.body,headers:n}).then(r=>So(r)).catch(async r=>{throw await r})}}function So(i){if(i.status!=204){if(i.status>=200&&i.status<300)return i.json();throw i.json().then(e=>({...e,message:e.message||i.statusText,url:i.url,status:i.status})).catch(()=>{throw{message:i.statusText,url:i.url,status:i.status}})}}function Co(i,e){for(const t in i)if(Object.prototype.hasOwnProperty.call(i,t)){const n=i[t];if(Array.isArray(n)&&(n.length>0&&typeof n[0]=="object"||n.length>10)||t==="NOT")return!1}for(const t in i)if(Object.prototype.hasOwnProperty.call(i,t)){const n=i[t];Array.isArray(n)?t.endsWith(".in")?e.add(t,JSON.stringify(n)):n.forEach(r=>e.add(t,r)):t.startsWith(dt)?e.add(t,JSON.stringify(n)):e.add(t,n)}return!0}const Eo="liveQuery-";var cn,Fo=new Uint8Array(16);function To(){if(!cn&&(cn=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!cn))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return cn(Fo)}const Po=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Do(i){return typeof i=="string"&&Po.test(i)}var be=[];for(var zn=0;zn<256;++zn)be.push((zn+256).toString(16).substr(1));function Ro(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(be[i[e+0]]+be[i[e+1]]+be[i[e+2]]+be[i[e+3]]+"-"+be[i[e+4]]+be[i[e+5]]+"-"+be[i[e+6]]+be[i[e+7]]+"-"+be[i[e+8]]+be[i[e+9]]+"-"+be[i[e+10]]+be[i[e+11]]+be[i[e+12]]+be[i[e+13]]+be[i[e+14]]+be[i[e+15]]).toLowerCase();if(!Do(t))throw TypeError("Stringified UUID is invalid");return t}function fi(i,e,t){i=i||{};var n=i.random||(i.rng||To)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Ro(n)}class Fe{constructor(...e){h(this,"Segments");this.Segments=e}toEntityOrderBy(){let e={};for(const t of this.Segments)t.isDescending?e[t.field.key]="desc":e[t.field.key]="asc";return e}reverse(){let e=new Fe;for(const t of this.Segments)e.Segments.push({field:t.field,isDescending:!t.isDescending});return e}compare(e,t,n){n||(n=r=>r.key);for(let r=0;r<this.Segments.length;r++){let s=this.Segments[r],a=e[n(s.field)],o=t[n(s.field)],l=s.isDescending,f=Bo(a,o,l);if(f!=0)return f}return 0}static translateOrderByToSort(e,t){let n=new Fe;if(t){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const s=t[r];let a=e.fields.find(r);const o=l=>{switch(s){case"desc":n.Segments.push({field:l,isDescending:!0});break;case"asc":n.Segments.push({field:l})}};if(a){const l=fe(a);if((l==null?void 0:l.type)==="toOne"){const f=l.options;if(typeof f.field=="string")o(e.fields.find(f.field));else if(f.fields){for(const u in f.fields)if(Object.prototype.hasOwnProperty.call(f.fields,u)){const c=f.fields[u];o(e.fields.find(c.toString()))}}}else o(a)}}}return n}static createUniqueSort(e,t){(!t||Object.keys(t).length===0)&&e.options.defaultOrderBy&&(t=Fe.translateOrderByToSort(e,e.options.defaultOrderBy)),t||(t=new Fe);for(const n of e.idMetadata.fields)t.Segments.find(r=>r.field==n)||t.Segments.push({field:n});return t}static createUniqueEntityOrderBy(e,t){(!t||Object.keys(t).length===0)&&(t=e.options.defaultOrderBy),t?t={...t}:t={};for(const n of e.idMetadata.fields)t[n.key]||(t[n.key]="asc");return t}}function Bo(i,e,t){i=or(i),e=or(e);let n=0;return i>e?n=1:i<e&&(n=-1),t&&(n*=-1),n}function or(i){return i==null||i==null?i:i.id!==void 0?i.id:i}const Kn="stream";class Mo{constructor(e,t,n){h(this,"repo");h(this,"query");h(this,"queryChannel");h(this,"subscribeCode");h(this,"unsubscribe",()=>{});h(this,"defaultQueryState",[]);h(this,"listeners",[]);h(this,"id",fi());this.repo=e,this.query=t,this.queryChannel=`users:${n}:queries:${this.id}`,this.id=this.queryChannel}sendDefaultState(e){e(this.createReducerType(()=>[...this.defaultQueryState],this.allItemsMessage(this.defaultQueryState)))}async setAllItems(e){const t=await ht(this.repo)._fromJsonArray(e,this.query.options);this.forListeners(n=>{n(()=>t)},this.allItemsMessage(t))}allItemsMessage(e){return[{type:"all",data:e}]}forListeners(e,t){e(n=>{if(this.defaultQueryState=n(this.defaultQueryState),t.find(r=>r.type==="add"||r.type==="replace")&&this.query.options.orderBy){const r=Fe.translateOrderByToSort(this.repo.metadata,this.query.options.orderBy);this.defaultQueryState.sort((s,a)=>r.compare(s,a))}});for(const n of this.listeners)e(r=>{n.next(this.createReducerType(r,t))})}createReducerType(e,t){return{applyChanges:e,changes:t,items:this.defaultQueryState}}async handle(e){{let t=e.filter(({type:r})=>r=="add"||r=="replace"),n=await ht(this.repo)._fromJsonArray(t.map(r=>r.data.item),this.query.options);for(let r=0;r<t.length;r++){const s=t[r];s.data.item=n[r]}}this.forListeners(t=>{t(n=>{n||(n=[]);for(const r of e)switch(r.type){case"all":this.setAllItems(r.data);break;case"replace":{n=n.map(s=>this.repo.metadata.idMetadata.getId(s)===r.data.oldId?r.data.item:s);break}case"add":n=n.filter(s=>this.repo.metadata.idMetadata.getId(s)!==this.repo.metadata.idMetadata.getId(r.data.item)),n.push(r.data.item);break;case"remove":n=n.filter(s=>this.repo.metadata.idMetadata.getId(s)!==r.data.id);break}return n})},e)}}const No="_liveQueryKeepAlive";class $o{constructor(e,t){h(this,"apiProvider");h(this,"getUserId");h(this,"queries",new Map);h(this,"channels",new Map);h(this,"client");h(this,"interval");this.apiProvider=e,this.getUserId=t}wrapMessageHandling(e){var t=this.apiProvider().wrapMessageHandling;t?t(e):e()}hasQueriesForTesting(){return this.queries.size>0}runPromise(e){return e}close(){this.queries.clear(),this.channels.clear(),this.closeIfNoListeners()}async subscribeChannel(e,t){let n=()=>{};const r=await this.openIfNoOpened();try{let s=this.channels.get(e);if(!s){this.channels.set(e,s=new Lo);try{s.unsubscribe=await r.subscribe(e,a=>this.wrapMessageHandling(()=>s.handle(a)),a=>{t.error(a)})}catch(a){throw t.error(a),a}}s.listeners.push(t),n=()=>{s.listeners.splice(s.listeners.indexOf(t),1),s.listeners.length==0&&(this.channels.delete(e),s.unsubscribe()),this.closeIfNoListeners()}}catch(s){throw t.error(s),s}return()=>{n(),n=()=>{}}}closeIfNoListeners(){this.client&&this.queries.size===0&&this.channels.size===0&&(this.runPromise(this.client.then(e=>e.close())),this.client=void 0,clearInterval(this.interval),this.interval=void 0)}subscribe(e,t,n){let r=!0,s=()=>{r=!1};return this.runPromise(ht(e)._buildEntityDataProviderFindOptions(t).then(a=>{if(!r)return;const{createKey:o,subscribe:l}=new ui(this.apiProvider).getEntityDataProvider(e.metadata).buildFindRequest(a),f=o();let u=this.queries.get(f);u?u.sendDefaultState(n.next):(this.queries.set(f,u=new Mo(e,{entityKey:e.metadata.key,options:t},this.getUserId())),u.subscribeCode=()=>{u.unsubscribe&&(u.unsubscribe(),u.unsubscribe=()=>{}),this.runPromise(this.subscribeChannel(u.queryChannel,{next:c=>this.runPromise(u.handle(c)),complete:()=>{},error:c=>{u.listeners.forEach(d=>d.error(c))}}).then(c=>{if(u.listeners.length==0){c();return}this.runPromise(l(u.queryChannel).then(d=>{if(u.listeners.length===0){d.unsubscribe(),c();return}this.runPromise(u.setAllItems(d.result)),u.unsubscribe=()=>{u.unsubscribe=()=>{},c(),this.runPromise(d.unsubscribe())}}).catch(d=>{u.listeners.forEach(p=>p.error(d)),c(),this.queries.delete(f)}))})).catch(c=>{u.listeners.forEach(d=>d.error(c))})},u.subscribeCode()),u.listeners.push(n),s=()=>{u.listeners.splice(u.listeners.indexOf(n),1),n.complete(),u.listeners.length==0&&(this.queries.delete(f),u.unsubscribe()),this.closeIfNoListeners()}}).catch(a=>{n.error(a)})),()=>{s()}}openIfNoOpened(){return this.client?this.client:(this.interval=setInterval(async()=>{const e=[];for(const t of this.queries.values())e.push(t.queryChannel);if(e.length>0){let t=this.apiProvider();const n=await this.runPromise(await E.actionInfo.runActionWithoutBlockingUI(()=>Et(t.httpClient).post(t.url+"/"+No,e)));for(const r of n)for(const s of this.queries.values())s.queryChannel===r&&s.subscribeCode()}},3e4),this.runPromise(this.client=this.apiProvider().subscriptionClient.openConnection(()=>{for(const e of this.queries.values())e.subscribeCode()})))}}class Lo{constructor(){h(this,"unsubscribe",()=>{});h(this,"listeners",[])}async handle(e){for(const t of this.listeners)t.next(e)}}class Ci{openConnection(e){let t;const n=new Map,r=Et(Ae.apiClient.httpClient);let s=!1,a;const o={close(){a.close()},async subscribe(u,c){let d=n.get(u);return d||(n.set(u,d=[]),await f(u)),d.push(c),()=>{d.splice(d.indexOf(c,1)),d.length==0&&(E.actionInfo.runActionWithoutBlockingUI(()=>r.post(Ae.apiClient.url+"/"+Kn+"/unsubscribe",{channel:u,clientId:t})),n.delete(u))}}},l=()=>new Promise(u=>{d();let c=0;function d(){a&&a.close(),a=Ci.createEventSource(Ae.apiClient.url+"/"+Kn),a.onmessage=p=>{let y=JSON.parse(p.data);const m=n.get(y.channel);m&&m.forEach(g=>g(y.data))},a.onerror=p=>{console.error("Live Query Event Source Error",p),a.close(),c++<$r.error500RetryCount&&setTimeout(()=>{d()},500)},a.addEventListener("connectionId",async p=>{if(t=p.data,s){for(const y of n.keys())await f(y);e()}else s=!0,u(o)})}});return l();async function f(u){await E.actionInfo.runActionWithoutBlockingUI(()=>r.post(Ae.apiClient.url+"/"+Kn+"/subscribe",{channel:u,clientId:t}))===qo&&await l()}}static createEventSource(e){return new EventSource(e,{withCredentials:!0})}}const qo="client connection not found",ci=Symbol.for("serverActionField");class jo{constructor(e){h(this,"remultObjectStorage");this.remultObjectStorage=e}static enable(){E.remultFactory=()=>{const e=E.asyncContext.getStore();if(e)return e.remult;throw new Error("remult object was requested outside of a valid request cycle.valid context, try running `withRemult` or run within initApi or a remult request cycle")}}static disable(){go()}async run(e,t){return this.remultObjectStorage?this.remultObjectStorage.run({remult:e},()=>t(e)):t(e)}isInInitRequest(){var e,t;return(t=(e=this.remultObjectStorage)==null?void 0:e.getStore())==null?void 0:t.inInitRequest}setInInitRequest(e){var n,r;const t=(n=this.remultObjectStorage)==null?void 0:n.getStore();t&&(e||(r=this.remultObjectStorage)!=null&&r.isStub)&&(t.inInitRequest=e)}getStore(){if(!this.remultObjectStorage)throw new Error("can't use static remult in this environment, `async_hooks` were not initialized");return this.remultObjectStorage.getStore()}}E.asyncContext||(E.asyncContext=new jo(void 0));function Qt(){return E.actionInfo.runningOnServer||!Ae.dataProvider.isProxy}class Le{constructor(e){h(this,"repo",(e,t)=>{t===void 0&&(t=this.dataProvider);let n=this.repCache.get(t);n||this.repCache.set(t,n=new Map);let r=n.get(e);return r||(n.set(e,r=new Ei(e,this,t,Xo(e,this))),fo(r,this,t)),r});h(this,"user");h(this,"dataProvider",new ui(()=>this.apiClient));h(this,"repCache",new Map);h(this,"liveQueryStorage");h(this,"subscriptionServer");h(this,"liveQueryPublisher",{itemChanged:async()=>{}});h(this,"liveQuerySubscriber",new $o(()=>this.apiClient,()=>{var e;return(e=this.user)==null?void 0:e.id}));h(this,"context",{});h(this,"apiClient",{url:"/api",subscriptionClient:new Ci});if(e&&e.getEntityDataProvider){this.dataProvider=e;return}if(Lr(e))this.apiClient.httpClient=e;else if(typeof e=="function")this.apiClient.httpClient=e;else if(e){const t=e;t.httpClient&&(this.apiClient.httpClient=t.httpClient),t.url&&(this.apiClient.url=t.url),t.subscriptionClient&&(this.apiClient.subscriptionClient=t.subscriptionClient),t.wrapMessageHandling&&(this.apiClient.wrapMessageHandling=t.wrapMessageHandling)}}async initUser(){const t=await Et(this.apiClient.httpClient).get(qr(this.apiClient.url,"me"));return this.user=(t==null?void 0:t.id)!=null?t:void 0,this.user}authenticated(){var e;return((e=this.user)==null?void 0:e.id)!==void 0}isAllowed(e){var t,n;if(e!=null){if(e instanceof Array){for(const r of e)if(this.isAllowed(r)===!0)return!0;return!1}return typeof e=="function"?e(this):typeof e=="boolean"?e:!!(typeof e=="string"&&(n=(t=this.user)==null?void 0:t.roles)!=null&&n.includes(e.toString()))}}isAllowedForInstance(e,t){if(Array.isArray(t)){for(const n of t)if(this.isAllowedForInstance(e,n))return!0}else return typeof t=="function"?t(e,this):this.isAllowed(t)}useFetch(e){this.dataProvider=new ui(()=>({httpClient:e}))}call(e,t,...n){const r=e[ci];if(!r.doWork)throw Error("The method received is not a valid backend method");return r.doWork(n,t,this.apiClient.url,Et(this.apiClient.httpClient))}clearAllCache(){this.repCache.clear()}}h(Le,"onFind",(e,t)=>{}),h(Le,"entityRefInit");E.defaultRemultFactory=()=>new Le;class jr{constructor(){h(this,"classes",new Map)}}function Jo(i,e){let t=i;for(;;){let n=E.classHelpers.get(t);n||E.classHelpers.set(t,n=new jr),n.classes.set(i,e);let r=Object.getPrototypeOf(t.prototype);if(r==null)break;t=r.constructor}}const Uo={defaultPageSize:200};async function Vo(i,e){const t=new Wo(i.liveQueryPublisher);let n=!0;const r=i.dataProvider;try{await i.dataProvider.transaction(async s=>{i.dataProvider=s,i.liveQueryPublisher=t,await e(s),n=!0}),n&&await t.flush()}finally{i.dataProvider=r}}class Wo{constructor(e){h(this,"orig");h(this,"transactionItems",new Map);this.orig=e}async itemChanged(e,t){let n=this.transactionItems.get(e);n||this.transactionItems.set(e,n=[]);for(const r of t)if(r.oldId!==void 0){const s=n.find(a=>a.id===r.oldId);s!==void 0?(r.deleted&&(s.deleted=!0),r.id!=s.id&&(s.id=r.id)):n.push(r)}else n.push(r)}async flush(){for(const e of this.transactionItems.keys())await this.orig.itemChanged(e,this.transactionItems.get(e))}}function jt(i,e){return e&&Object.assign(i,e),i}class Jr extends Error{constructor(t){super(t.message);h(this,"modelState");h(this,"stack");h(this,"exception");h(this,"httpStatusCode");Object.assign(this,t)}}class We{}h(We,"number","number"),h(We,"date","date"),h(We,"checkbox","checkbox"),h(We,"password","password"),h(We,"email","email"),h(We,"tel","tel"),h(We,"time","time");const Q=class Q{};h(Q,"Date",{toJson:e=>{if(e===null)return null;if(!e)return"";if(typeof e=="string"&&(e=new Date(e)),e instanceof Date)return e.toISOString();throw new Error("Expected date but got "+e)},fromJson:e=>{if(e===null)return null;if(e!=null&&e!=""&&!e.startsWith("0000-00-00"))return new Date(Date.parse(e))},toDb:e=>e,fromDb:e=>{if(typeof e=="number"&&(e=new Date(e)),typeof e=="string"&&(e=new Date(e)),e&&!(e instanceof Date))throw"expected date but got "+e;return e},fromInput:e=>Q.Date.fromJson(e),toInput:e=>Q.Date.toJson(e),displayValue:e=>e?e.toLocaleString():""}),h(Q,"DateOnly",{fromInput:e=>Q.DateOnly.fromJson(e),toInput:e=>Q.DateOnly.toJson(e),toJson:e=>{var t=e;return(typeof t=="string"||typeof t=="number")&&(t=new Date(t)),!t||t==null?null:t.getHours()==0?new Date(t.valueOf()-t.getTimezoneOffset()*6e4).toISOString().substring(0,10):t.toISOString().substring(0,10)},fromJson:e=>{if(!e||e==""||e=="0000-00-00")return null;let t=new Date(Date.parse(e));return t.setMinutes(t.getMinutes()+t.getTimezoneOffset()),t},inputType:We.date,toDb:e=>e?Q.DateOnly.fromJson(Q.DateOnly.toJson(e)):null,fromDb:e=>Q.Date.fromDb(e),fieldTypeInDb:"date",displayValue:e=>e?e.toLocaleDateString(void 0):""}),h(Q,"DateOnlyString",{...Q.DateOnly,toDb:e=>{let t=Q.DateOnly.toJson(e);if(t)return t.replace(/-/g,"")},fromDb:e=>{if(e===null)return null;if(e)return new Date(e.substring(0,4)+"-"+e.substring(4,6)+"-"+e.substring(6,8))}}),h(Q,"Boolean",{toDb:e=>e,inputType:We.checkbox,fromDb:e=>Q.Boolean.fromJson(e),fromJson:e=>typeof e=="boolean"?e:e===1?!0:e!=null?e.toString().trim().toLowerCase()=="true":e,toJson:e=>e,fromInput:e=>Q.Boolean.fromJson(e),toInput:e=>Q.Boolean.toJson(e)}),h(Q,"Number",{fromDb:e=>{if(e===null)return null;if(e!==void 0)return+e},toDb:e=>e,fromJson:e=>Q.Number.fromDb(e),toJson:e=>Q.Number.toDb(e),fromInput:(e,t)=>{let n=+e;if(e!=null)return n},toInput:(e,t)=>(e==null?void 0:e.toString())??"",inputType:We.number}),h(Q,"String",{fromDb:bt,toDb:bt,fromJson:bt,toJson:bt,fromInput:bt,toInput:bt}),h(Q,"Integer",{...Q.Number,toJson:e=>{let t=Q.Number.toDb(e);return t&&+(+t).toFixed(0)},toDb:e=>Q.Integer.toJson(e),fieldTypeInDb:"integer"}),h(Q,"Default",{fromJson:e=>e,toJson:e=>e,fromDb:e=>Q.JsonString.fromDb(e),toDb:e=>Q.JsonString.toDb(e),fromInput:e=>Q.Default.fromJson(e),toInput:e=>Q.Default.toJson(e),displayValue:e=>e+"",fieldTypeInDb:"",inputType:"text"}),h(Q,"JsonString",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e==null?null:e?JSON.parse(Q.JsonString.fromJson(e)):void 0,toDb:e=>e!==void 0?e===null?null:JSON.stringify(Q.JsonString.toJson(e)):void 0,fromInput:e=>Q.JsonString.fromJson(e),toInput:e=>Q.JsonString.toJson(e)}),h(Q,"JsonValue",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e,toDb:e=>e,fromInput:e=>Q.JsonString.fromJson(e),toInput:e=>Q.JsonString.toJson(e),fieldTypeInDb:"json"});let Oe=Q;function bt(i){return i==null?i:typeof i!="string"?i.toString():i}function Xn(i,e,t){let n=N.fromEntityFilter(i,e);const r=()=>{};n&&n.__applyToConsumer({custom:r,databaseCustom:r,containsCaseInsensitive:r,notContainsCaseInsensitive:r,startsWithCaseInsensitive:r,endsWithCaseInsensitive:r,isDifferentFrom:r,isEqualTo:(s,a)=>{t[s.key]=a},isGreaterOrEqualTo:r,isGreaterThan:r,isIn:r,isLessOrEqualTo:r,isLessThan:r,isNotNull:r,isNull:r,not:r,or:r})}class Jt{constructor(){h(this,"entityLoaders",new Map);h(this,"promises",[])}load(e,t){let n=this.entityLoaders.get(e.entityType);n||this.entityLoaders.set(e.entityType,n=new Ho(e));const r=n.find(t);return this.promises.push(r),r}async resolveAll(){for(const t of this.entityLoaders.values())for(const n of t.queries.values())n.resolve();if(this.promises.length===0)return;const e=this.promises;this.promises=[],await Promise.all(e),await this.resolveAll()}}class Ho{constructor(e){h(this,"rel");h(this,"queries",new Map);this.rel=e}find(e){const{where:t,...n}=Si(e,this.rel.metadata),r=JSON.stringify(n);let s=this.queries.get(r);return s||this.queries.set(r,s=new Go(this.rel)),s.find(e,t)}}class Go{constructor(e){h(this,"rel");h(this,"pendingInStatements",new Map);h(this,"whereVariations",new Map);this.rel=e}find(e,t){const n=JSON.stringify(t);let r=this.whereVariations.get(n);if(!r){const s=Object.keys(t);if(s.length===1&&typeof t[s[0]]!="object"&&!e.limit){let a=this.pendingInStatements.get(s[0]);a||this.pendingInStatements.set(s[0],a=new Qo(this.rel,s[0],e)),this.whereVariations.set(n,r={result:a.find(t)})}else this.whereVariations.set(n,r={result:this.rel.find(e)})}return r.result}resolve(){const e=[...this.pendingInStatements.values()];this.pendingInStatements.clear();for(const t of e)t.resolve()}}class Qo{constructor(e,t,n){h(this,"rel");h(this,"key");h(this,"options");h(this,"values",new Map);this.rel=e,this.key=t,this.options=n}async resolve(){const e=[...this.values.values()];if(e.length==1){this.rel.find(this.options).then(e[0].resolve,e[0].reject);return}var t={...this.options};t.where={[this.key]:e.map(r=>r.value)},t.limit=1e3,t.page=1;let n=[];try{for(;;){const r=await this.rel.find(t);if(n.push(...r),r.length<t.limit)break;t.page++}for(const r of this.values.values())r.resolve(n.filter(s=>{const o=ae(s).fields.find(this.key),l=fe(o.metadata),f=(l==null?void 0:l.type)==="reference"?o.getId():s[this.key];return r.value==f}))}catch(r){for(const s of this.values.values())s.reject(r)}}find(e){const t=e[this.key];let n=this.values.get(t);if(!n){let r,s,a=new Promise((o,l)=>{r=o,s=l});this.values.set(t,n={value:t,resolve:r,reject:s,result:a})}return n.result}}E.actionInfo;const we=class we{};h(we,"required",Ut(async(e,t)=>!t.valueIsNull()&&t.value!==""&&(t.value!==void 0||fe(t.metadata)!==void 0),"Should not be empty")),h(we,"unique",Ut(async(e,t)=>{if(!t.entityRef)throw"unique validation may only work on columns that are attached to an entity";return t.isBackend()&&(t.isNew||t.valueChanged())?await t.entityRef.repository.count({[t.metadata.key]:t.value})==0:!0},"already exists")),h(we,"uniqueOnBackend",Ut(async(e,t)=>t.isBackend()&&(t.isNew||t.valueChanged())?await t.entityRef.repository.count({[t.metadata.key]:t.value})==0:!0,we.unique.defaultMessage)),h(we,"regex",et((e,t)=>t.test(e))),h(we,"email",gn(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),"Invalid Email")),h(we,"url",gn(e=>!!new URL(e),"Invalid Url")),h(we,"in",et((e,t)=>t.includes(e),e=>`Value must be one of: ${e.map(t=>typeof t=="object"?(t==null?void 0:t.id)!==void 0?t==null?void 0:t.id:t==null?void 0:t.toString():t).join(", ")}`)),h(we,"notNull",gn(e=>e!=null,"Should not be null")),h(we,"enum",et((e,t)=>Object.values(t).includes(e),e=>`Value must be one of ${wn(e).join(", ")}`)),h(we,"relationExists",Ut(async(e,t)=>t.valueIsNull()||!t.isBackend()?!0:!!await t.load(),"Relation value does not exist")),h(we,"min",et((e,t)=>e>=t,e=>`Value must be bigger than or equal to ${e}`)),h(we,"max",et((e,t)=>e<=t,e=>`Value must be smaller than or equal to ${e}`)),h(we,"maxLength",et((e,t)=>e.length<=t,e=>`Value must be at most ${e} characters`)),h(we,"minLength",et((e,t)=>e.length>=t,e=>`Value must be at least ${e} characters`)),h(we,"range",et((e,[t,n])=>e>=t&&e<=n,([e,t])=>`Value must be between ${e} and ${t}`)),h(we,"defaultMessage","Invalid value");let Re=we;function Ut(i,e){const t=async(r,s,a)=>{const o=await i(r,s);typeof o=="string"&&o.length>0?s.error=o:o||(s.error=typeof a=="function"&&a(r,s,void 0)||a||typeof e=="function"&&e(r,s,void 0)||e||Re.defaultMessage)},n=(r,s,a)=>typeof r=="string"||r==="function"||r===void 0&&s===void 0?async(o,l,f)=>await t(o,l,r||f):t(r,s,a);return Object.defineProperty(n,"defaultMessage",{get:()=>e,set:r=>{e=r},enumerable:!0}),Object.assign(n,{withMessage:r=>async(s,a)=>n(s,a,r)})}function gn(i,e){return Ut((t,n)=>n.value===void 0||n.value===null?!0:i(n.value),e)}function et(i,e){const t=zo((n,r,s)=>r.value===void 0||r.value===null?!0:i(r.value,s),(n,r,s)=>typeof e=="function"&&e(s)||e,!0);return Object.assign((n,r)=>t(n,r),{get defaultMessage(){return e},set defaultMessage(n){e=n}})}function zo(i,e,t=!1){return Object.assign((r,s)=>async(a,o)=>{const l=await i(a,o,r);typeof l=="string"?o.error=l:l||(o.error=s?typeof s=="function"?t?s(r):s(a,o,r):s:e?typeof e=="function"?e(a,o,r):e:Re.defaultMessage)},{get defaultMessage(){return e},set defaultMessage(r){e=r}})}function wn(i){return Object.values(i).filter(e=>typeof i[e]!="number")}function _n(i,e,t=!1){if(!e)return i;const n=Array.isArray(e)?e:[e],r=Array.isArray(i)?i:i?[i]:[];return t?[...n,...r]:[...r,...n]}function Ct(i,e){return typeof i[e]<"u"}class Ko{constructor(e,t){h(this,"options");h(this,"repo");h(this,"_count");h(this,"_aggregates");this.options=e,this.repo=t,this.options||(this.options={}),this.options.pageSize||(this.options.pageSize=Uo.defaultPageSize)}async getPage(e){return(e??0)<1&&(e=1),this.repo.find({where:this.options.where,orderBy:this.options.orderBy,limit:this.options.pageSize,page:e,load:this.options.load,include:this.options.include})}async count(){return this._count===void 0&&(this._count=await this.repo.count(this.options.where)),this._count}async forEach(e){let t=0;for await(const n of this)await e(n),t++;return t}async paginator(e){this.options.orderBy=Fe.createUniqueEntityOrderBy(this.repo.metadata,this.options.orderBy);let t={where:{$and:[this.options.where,e]},orderBy:this.options.orderBy,limit:this.options.pageSize,load:this.options.load,include:this.options.include},n=()=>this.repo.find(t);if(this._aggregates===void 0&&Ct(this.options,"aggregate")){let o=this.options.aggregate;if(this.repo._dataProvider.isProxy){const l=new Jt;n=()=>this.repo._rawFind(t,!1,l,async f=>{const u=await this.repo._edp.query(f,await this.repo.__buildGroupByOptions(o));return this._aggregates=u.aggregates,u.items}).then(async f=>(await l.resolveAll(),f))}else{let l=n();n=async()=>(this._aggregates=await this.repo.aggregate({...o,where:this.options.where}),this._count=this._aggregates.$count,l)}}let r=await n(),s=()=>{throw new Error("no more pages")},a=r.length==this.options.pageSize;if(a){let o=await this.repo._createAfterFilter(this.options.orderBy,r[r.length-1]);s=()=>this.paginator(o)}return{count:()=>this.count(),hasNextPage:a,items:r,nextPage:s,aggregates:this._aggregates}}[Symbol.asyncIterator](){this.options.where||(this.options.where={});let e=this.options.orderBy;this.options.orderBy=Fe.createUniqueEntityOrderBy(this.repo.metadata,e);let t=-1,n,r,s=0;return r=async()=>{if(this.options.progress&&this.options.progress.progress(s++/await this.count()),n===void 0||t==n.items.length){if(n&&!n.hasNextPage)return{value:void 0,done:!0};let a=n;if(n?n=await n.nextPage():n=await this.paginator(),t=0,n.items.length==0)return{value:void 0,done:!0};if(((a==null?void 0:a.items.length)??!1)&&this.repo.getEntityRef(a.items[0]).getId()==this.repo.getEntityRef(n.items[0]).getId())throw new Error("pagination failure, returned same first row")}return t<n.items.length?{value:n.items[t++],done:!1}:{done:!0,value:void 0}},{next:async()=>r()}}}class Ei{constructor(e,t,n,r,s){h(this,"_entity");h(this,"_remult");h(this,"_dataProvider");h(this,"_info");h(this,"_defaultFindOptions");h(this,"__edp");h(this,"_idCache",new Map);h(this,"listeners");h(this,"_cache",new Map);this._entity=e,this._remult=t,this._dataProvider=n,this._info=r,this._defaultFindOptions=s}_notFoundError(e){return{message:`id ${e} not found in entity ${this.metadata.key}`,httpStatusCode:404}}[Gt](){return this}async _createAfterFilter(e,t){let n=new Map;for(const a of Fe.translateOrderByToSort(this.metadata,e).Segments){let o=t[a.field.key];n.set(a.field.key,o)}let r={$or:[]},s=[];for(const a of Fe.translateOrderByToSort(this.metadata,e).Segments){let o={};for(const l of s)o[l.key]=n.get(l.key);s.push(a.field),a.isDescending?o[a.field.key]={$lt:n.get(a.field.key)}:o[a.field.key]={$gt:n.get(a.field.key)},r.$or.push(o)}return r}relations(e){return new Proxy({},{get:(t,n)=>{const r=this.fields.find(n),s=fe(r);if(!s)throw Error(n+" is not a relation");const{toRepo:a,returnNull:o,returnUndefined:l}=this._getFocusedRelationRepo(r,e);return s.type==="toMany"?a:{findOne:f=>o?Promise.resolve(null):l?Promise.resolve(void 0):a.findFirst({},f)}}})}_getFocusedRelationRepo(e,t){const n=fe(e);let r=n.toRepo,{findOptions:s,returnNull:a,returnUndefined:o}=this._findOptionsBasedOnRelation(n,e,void 0,t,r);return{toRepo:new Ei(r._entity,r._remult,r._dataProvider,r._info,s),returnNull:a,returnUndefined:o}}get _edp(){return this.__edp?this.__edp:this.__edp=this._dataProvider.getEntityDataProvider(this.metadata)}async aggregate(e){return(await this.groupBy(e))[0]}async groupBy(e){var t=await this.__buildGroupByOptions(e);const n=await this._edp.groupBy(t);if(!(e!=null&&e[bo])&&e.group){const r={include:{}};for(const a of e.group)r.include[a]=!0;const s=new Jt;await this._populateRelationsForFields(t.group,r,n,s),await s.resolveAll()}return n}async __buildGroupByOptions(e){var a,o,l,f,u,c;let t=await this._buildEntityDataProviderFindOptions({...e});const n=d=>{const p=this.metadata.fields.find(d);if(p===void 0)throw Error(`key "${d}" not found in entity`);return p},r=d=>{var p;if((p=e==null?void 0:e.group)!=null&&p.includes(d))throw Error(`field "${d}" cannot be used both in an aggregate and in group by`);return n(d)};var s={where:t.where,limit:t.limit,page:t.page,group:(a=e==null?void 0:e.group)==null?void 0:a.map(n),sum:(o=e==null?void 0:e.sum)==null?void 0:o.map(r),avg:(l=e==null?void 0:e.avg)==null?void 0:l.map(r),min:(f=e==null?void 0:e.min)==null?void 0:f.map(r),max:(u=e==null?void 0:e.max)==null?void 0:u.map(r),distinctCount:(c=e==null?void 0:e.distinctCount)==null?void 0:c.map(r)};if(e!=null&&e.orderBy){s.orderBy=[];for(const d in e.orderBy)if(Object.prototype.hasOwnProperty.call(e==null?void 0:e.orderBy,d)){const p=e.orderBy[d];if(p){if(typeof p=="string")s.orderBy.push({field:d==="$count"?void 0:n(d),isDescending:p==="desc",operation:d==="$count"?"count":void 0});else for(const y in p)if(Object.prototype.hasOwnProperty.call(p,y)){const m=p[y];s.orderBy.push({field:this.metadata.fields.find(d),isDescending:m==="desc",operation:y})}}}}return s}_getCachedById(e,t){e=e+"",this._getCachedByIdAsync(e,t);let n=this._idCache.get(e);if(!(n instanceof Promise))return n}async _getCachedByIdAsync(e,t){e=e+"";let n=this._idCache.get(e);if(n instanceof Promise)return await n;if(this._idCache.has(e))return n;if(t)return;this._idCache.set(e,void 0);let r=this.findId(e).then(s=>(s===void 0?n=null:n=s,this._idCache.set(e,n),n));return this._idCache.set(e,r),await r}_addToCache(e){e&&this._idCache.set(this.getEntityRef(e).getId()+"",e)}get metadata(){return this._info}addEventListener(e){return this.listeners||(this.listeners=[]),this.listeners.push(e),()=>{this.listeners.splice(this.listeners.indexOf(e),1)}}query(e){return new Ko(e,this)}getEntityRef(e){let t=e[ft];return t||(this._fixTypes(e),t=new dn(this._info,e,this,this._edp,this._remult,!0),Object.defineProperty(e,ft,{get:()=>t}),t.saveOriginalData()),t}async delete(e){const t=ae(e,!1);if(t)return t.delete();if(typeof e=="string"||typeof e=="number"){if(this._dataProvider.isProxy)return this._edp.delete(e);{let r=await this.findId(e);if(!r)throw this._notFoundError(e);return await ae(r).delete()}}let n=this._getRefForExistingRow(e,void 0);return this._dataProvider.isProxy||await n.reload(),n.delete()}__cleanupPartialObject(e){const t=Object.keys(e);for(let n=0;n<t.length;n++){const r=t[n],s=this.fields[r];if(s){const a=fe(s);a&&a.type==="toOne"&&a.options.field&&t.indexOf(a.options.field)>n&&a.toRepo.getEntityRef(e[r]).getId()!==e[a.options.field]&&delete e[r]}}for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n],fe(this.fields[n]));for(const n of this.fields);}async insert(e){if(Array.isArray(e))if(this._dataProvider.isProxy){let t=[],n=[];for(const r of e){this.__cleanupPartialObject(r);let s=ae(e,!1);if(s){if(!s.isNew())throw"Item is not new"}else s=await this.getEntityRef(this.create(r));t.push(s),n.push(await s.buildDtoForInsert())}return At(await this._edp.insertMany(n),(r,s)=>t[s].processInsertResponseDto(r))}else{let t=[];for(const n of e)t.push(await this.insert(n));return t}else{let t=ae(e,!1);if(t){if(!t.isNew())throw"Item is not new";return await t.save()}else return this.__cleanupPartialObject(e),await this.getEntityRef(this.create(e)).save()}}get fields(){return this.metadata.fields}async validate(e,...t){{let n=ae(e,!1);if(n||(n=this.getEntityRef({...e})),!t||t.length===0)return await n.validate();{n.__clearErrorsAndReportChanged();let r=!1;for(const s of t)await n.fields.find(s).validate()||(r=!0);return r?n.buildErrorInfoObject():void 0}}}__createDto(e){this.__cleanupPartialObject(e);const n=this.getEntityRef({...e}).copyDataToObject(!1),r=Object.keys(e);for(const s of this.fields)(s.dbReadOnly||!r.includes(s.key))&&delete n[s.key];return n}async updateMany({where:e,set:t}){if(this.__cleanupPartialObject(t),N.throwErrorIfFilterIsEmpty(e,"updateMany"),this._dataProvider.isProxy)return this._edp.updateMany(await this._translateWhereToFilter(e),this.__createDto({...t}));{let n=0;for await(const r of this.query({where:e,aggregate:void 0}))jt(r,t),await ae(r).save(),n++;return n}}async update(e,t){{let r=ae(t,!1);if(r)return await r.save()}{let r=ae(e,!1);if(r)return jt(e,t),r.save()}this.__cleanupPartialObject(t);let n;if(typeof e=="object"?(n=this._getRefForExistingRow(e,this.metadata.idMetadata.getId(e)),Object.assign(n.instance,t)):n=this._getRefForExistingRow(t,e),this._dataProvider.isProxy)return await n.save(Object.keys(t));{const r=await n.reload();if(!r)throw this._notFoundError(n.id);for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){let a=n.fields[s];if(t[s]===void 0&&fe(a.metadata))continue;a&&(r[s]=t[s])}return await this._fixTypes(r),await n.save()}}async upsert(e){if(this._dataProvider.isProxy){let s=await this._edp.upsertMany((Array.isArray(e)?e:[e]).map(l=>{var f;return(f=this._defaultFindOptions)!=null&&f.where&&(Xn(this.metadata,this._defaultFindOptions.where,l.where),this._fixTypes(l)),{where:this.__createDto(l.where),set:l.set?this.__createDto(l.set):void 0}}));const a=new Jt,o=await this._loadManyToOneForManyRows(s,{},a);return await a.resolveAll(),Array.isArray(e)?o:o[0]}if(Array.isArray(e))return At(e,s=>this.upsert(s));let t=e;var n=await this.findFirst(t.where,{createIfNotFound:!0}),r=ae(n,!1);return r.isNew()?(t.set&&jt(n,t.set),await r.save()):t.set?(jt(n,t.set),await r.save()):n}_getRefForExistingRow(e,t){let n=ae(e,!1);if(!n){const r=new this._entity(this._remult);for(const a of this._fieldsOf(e)){const o=a.key;r[o]=e[o]}this._fixTypes(r);let s=new dn(this._info,r,this,this._edp,this._remult,!1);typeof t=="object"&&(t=this.metadata.idMetadata.getId(t)),t?(s.id=t,s.originalId=t):s.id=s.getId(),n=s,Object.defineProperty(r,ft,{get:()=>s})}return n}async save(e){if(Array.isArray(e))return At(e,t=>this.save(t));{let t=ae(e,!1);if(t)return await t.save();if(e instanceof Qr)return await this.getEntityRef(e).save();{let n=this.metadata.idMetadata.getId(e);return n===void 0?this.insert(e):this.update(n,e)}}}liveQuery(e){return e||(e={}),{subscribe:t=>{let n=t;return typeof t=="function"&&(n={next:t,complete:()=>{},error:()=>{}}),n.error??(n.error=()=>{}),n.complete??(n.complete=()=>{}),this._remult.liveQuerySubscriber.subscribe(this,e,n)}}}async _rawFind(e,t=!1,n,r){e||(e={}),this._defaultFindOptions&&(e={...this._defaultFindOptions,...e});let s=await this._buildEntityDataProviderFindOptions(e);t&&(delete s.orderBy,delete s.limit),Le.onFind(this._info,e);const a=await r(s);return await this._loadManyToOneForManyRows(a,e,n)}async find(e,t=!1){const n=new Jt,r=await this._rawFind(e,t,n,s=>this._edp.find(s));return await n.resolveAll(),r}async _buildEntityDataProviderFindOptions(e){e={...e};let t={};return t={},(!e.orderBy||Object.keys(e.orderBy).length===0)&&(this._dataProvider.isProxy||(e.orderBy=this._info.entityInfo.defaultOrderBy)),t.where=await this._translateWhereToFilter(e.where),e.orderBy!==void 0&&(t.orderBy=Fe.translateOrderByToSort(this.metadata,e.orderBy)),e.limit!==void 0&&(t.limit=e.limit),e.page!==void 0&&(t.page=e.page),t}async _fromJsonArray(e,t){const n=new Jt,r=await this._loadManyToOneForManyRows(e.map(s=>{let a={};for(const o of this.metadata.fields.toArray())a[o.key]=o.valueConverter.fromJson(s[o.key]);return a}),t,n);return await n.resolveAll(),r}async _loadManyToOneForManyRows(e,t,n){let r;t!=null&&t.load&&(r=t.load(this.metadata.fields));for(const f of this.metadata.fields)if(Te(f.valueType,!1)&&!fe(f)){let d=!f.options.lazy;if(r!==void 0&&(d=r.includes(f)),d){let p=this._remult.repo(f.valueType),y=[];for(const m of e){let g=m[f.key];g!=null&&!y.includes(g)&&!p._idCache.has(g+"")&&y.push(g)}y.length>0&&await s(p,y)}}async function s(f,u){let c=await f.find({where:f.metadata.idMetadata.getIdFilter(...u)},!0);for(const d of c)f._addToCache(d)}const a=new Set(this.fields.toArray().map(f=>{const u=this.__getRelationAndInclude(f,t);if(u.rel&&!u.incl)return f.key}).filter(f=>f!==void 0));let o=await At(e,async f=>await this._mapRawDataToResult(f,r,a));const l=this.metadata.fields.toArray();return this._populateRelationsForFields(l,t,o,n),o}_populateRelationsForFields(e,t,n,r){for(const s of e){let{rel:a,incl:o}=this.__getRelationAndInclude(s,t);if(a)if(o){const l=a.toRepo;for(const f of n){let{findOptions:u,returnNull:c}=this._findOptionsBasedOnRelation(a,s,o,f,l);const d=s.key;if(c)f[d]=null;else{const p=a.toEntity,y=l;r.load({entityType:p,find:m=>y._rawFind(m,!1,r,g=>y._edp.find(g)),metadata:y.metadata},u).then(m=>{m.length==0&&a.type=="toOne"||(f[d]=a.type!=="toMany"?m.length==0?null:m[0]:m)})}}}else for(const l of n)Reflect.deleteProperty(l,s.key)}}__getRelationAndInclude(e,t){var a;let n=fe(e),r=e.options.defaultIncluded;const s=(a=t==null?void 0:t.include)==null?void 0:a[e.key];return s!==void 0&&(r=s),{rel:n,incl:r}}_findOptionsBasedOnRelation(e,t,n,r,s){let a=!1,o=!1,l=[],f={},u=[];typeof e.options.findOptions=="function"?u.push(e.options.findOptions(r)):typeof e.options.findOptions=="object"&&u.push(e.options.findOptions),typeof n=="object"&&u.push(n);for(const p of u){p.where&&l.push(p.where);for(const y of["limit","include","orderBy"])p[y]&&(f[y]=p[y])}const c=e.getFields(),d=p=>{const y=ae(r,!1);let m=e.type==="reference"&&y?y.fields.find(t.key).getId():r[p];return(e.type==="toOne"||e.type==="reference")&&(m===null?a=!0:m===void 0?o=!0:e.type==="reference"&&typeof m=="object"&&(m=s.metadata.idMetadata.getId(m))),m};c.compoundIdField&&(e.type==="toMany"?l.push({[c.compoundIdField]:this.metadata.idMetadata.getId(r)}):l.push(s.metadata.idMetadata.getIdFilter(d(c.compoundIdField))));for(const p in c.fields)Object.prototype.hasOwnProperty.call(c.fields,p)&&l.push({[p]:d(c.fields[p])});return f.where={$and:l},(e.type==="toOne"||e.type==="reference")&&f.orderBy&&(f.limit=1),{findOptions:f,returnNull:a,returnUndefined:o}}async _mapRawDataToResult(e,t,n){let r=new this._entity(this._remult),s=new dn(this._info,r,this,this._edp,this._remult,!1,n);return Object.defineProperty(r,ft,{get:()=>s}),await s.loadDataFrom(e,t),s.saveOriginalData(),r}toJson(e){return e==null?e:Array.isArray(e)?e.map(t=>this.toJson(t)):typeof e.then=="function"?e.then(t=>this.toJson(t)):this.getEntityRef(e).toApiJson(!0)}fromJson(e,t){if(e==null)return e;if(Array.isArray(e))return e.map(r=>this.fromJson(r,t));let n=new this._entity(this._remult);for(const r of this._fieldsOf(e)){const s=r.key;if(Te(r.valueType,!1)){let o=e[r.key];typeof o=="string"||typeof o=="number"?n[s]=o:n[s]=this._remult.repo(r.valueType).fromJson(o)}else e[s]!==void 0&&(n[s]=r.valueConverter.fromJson(e[r.key]))}if(this._fixTypes(n),t)return this.create(n);{let r=new dn(this._info,n,this,this._edp,this._remult,!1);return Object.defineProperty(n,ft,{get:()=>r}),r.id=r.getId(),r.saveOriginalData(),r.originalId=r.id,n}}async count(e){return this._edp.count(await this._translateWhereToFilter(e))}async deleteMany({where:e}){if(N.throwErrorIfFilterIsEmpty(e,"deleteMany"),this._dataProvider.isProxy)return this._edp.deleteMany(await this._translateWhereToFilter(e));{let t=0;for await(const n of this.query({where:e,aggregate:void 0}))await ae(n).delete(),t++;return t}}async findOne(e,t=!1){let n,r,s=e??{};if(s.useCache){let a=Si(s,this.metadata),o=JSON.stringify(a);if(r=this._cache.get(o),r!==void 0)if(r.value&&this.getEntityRef(r.value).wasDeleted())r=void 0,this._cache.delete(o);else return r.promise;else r={value:void 0,promise:void 0},this._cache.set(o,r)}return n=this.find({...s,limit:1},t).then(async a=>{let o;return a.length>0&&(o=a[0]),!o&&s.createIfNotFound&&(o=this.create(),s.where&&await Xn(this.metadata,s.where,o)),o}),r&&(r.promise=n=n.then(a=>(r.value=a,a))),n}async findFirst(e,t,n=!1){if(t||(t={}),e)if(t.where){let r=t.where;t.where={$and:[r,e]}}else t.where=e;return this.findOne(t,n)}_fieldsOf(e){let t=Object.keys(e);return this.metadata.fields.toArray().filter(n=>t.includes(n.key))}create(e){var n;let t=new this._entity(this._remult);if(e){for(const r of this._fieldsOf(e)){const s=r.key;t[s]=e[s]}this._fixTypes(t)}return(n=this._defaultFindOptions)!=null&&n.where&&(Xn(this.metadata,this._defaultFindOptions.where,t),this._fixTypes(t)),this.getEntityRef(t),t}async _fixTypes(e){for(const t of this._fieldsOf(e)){const n=e[t.key];if(n!=null)if(t.valueType===Date&&!(n instanceof Date))e[t.key]=t.valueConverter.fromJson(t.valueConverter.toJson(n));else for(const[r,s]of[[String,"string"],[Number,"number"],[Boolean,"boolean"]])t.valueType===r&&typeof n!==s&&(e[t.key]=t.valueConverter.fromJson(t.valueConverter.toJson(n)))}return e}findId(e,t){if(e==null)return Promise.resolve(null);if(typeof e!="string"&&typeof e!="number")throw new Error("id can be either number or string, but got: "+typeof e);return this.findFirst({},{...t,where:this.metadata.idMetadata.getIdFilter(e)},!0)}async _translateWhereToFilter(e){var r,s;let t=e??{};(r=this._defaultFindOptions)!=null&&r.where&&(t={$and:[t,(s=this._defaultFindOptions)==null?void 0:s.where]}),this._dataProvider.isProxy||(this.metadata.options.backendPreprocessFilter&&(t=await this.metadata.options.backendPreprocessFilter(t,{metadata:this.metadata,getFilterPreciseValues:a=>N.getPreciseValues(this.metadata,a||t)})),this.metadata.options.backendPrefilter&&(t={$and:[t,await N.resolve(this.metadata.options.backendPrefilter)]}));let n=await N.fromEntityFilter(this.metadata,t);return n&&!this._dataProvider.isProxy&&(n=await N.translateCustomWhere(n,this.metadata,this._remult)),n}}function Xo(i,e){let t=E.columnsOfType.get(i);t||E.columnsOfType.set(i,t=[]);let n=Te(i)(e),r=lo(i),s=Object.getPrototypeOf(i);for(;s!=null;){let a=E.columnsOfType.get(s);a&&t.unshift(...a.filter(l=>!t.find(f=>f.key==l.key)));let o=Te(s,!1);if(o){let l=o(e);n={...l,...n};let f=["saving","saved","deleting","deleted","validation"];for(const u of f)if(l[u]&&l[u]!==n[u]){let c=n[u];n[u]=async(d,p)=>{await c(d,p),await l[u](d,p)}}}s=Object.getPrototypeOf(s)}return new el(Vr(t,e),n,e,i,r)}class Ur{constructor(e,t,n,r,s){h(this,"fieldsMetadata");h(this,"instance");h(this,"remult");h(this,"isNewRow");h(this,"_error");h(this,"_subscribers");h(this,"_isLoading",!1);h(this,"lookups",new Map);h(this,"errors");h(this,"originalValues",{});this.fieldsMetadata=e,this.instance=t,this.remult=n,this.isNewRow=r;{let a=n;a!=null&&a.iAmRemultProxy&&(n=E.remultFactory())}for(const a of e)if(Te(a.valueType,!1)&&n){let l=new ko(n.repo(a.valueType),!!fe(a),a.allowNull);this.lookups.set(a.key,l);let f=t[a.key],u;Object.defineProperty(t,a.key,{get:()=>(this._subscribers&&(this._subscribers.reportObserved(),u||(u=this.fields.find(a.key),u._subscribers||(u._subscribers=new hn)),u._subscribers.reportObserved()),l.item),set:c=>{var d;l.set(c),(d=this._subscribers)==null||d.reportChanged(),u||(u=this.fields.find(a.key),u._subscribers||(u._subscribers=new hn)),u._subscribers.reportChanged()},enumerable:!(s!=null&&s.has(a.key))}),l.set(f)}else{const l=fe(a);if((l==null?void 0:l.type)==="toOne"){let f=t.hasOwnProperty(a.key),u=t[a.key];r&&!u&&(f=!1),Object.defineProperty(t,a.key,{get:()=>u,set:c=>{if(u=c,c===void 0)return;const d=a.options;if(d.field&&(this.instance[d.field]=l.toRepo.metadata.idMetadata.getId(c)),d.fields){for(const p in d.fields)if(Object.prototype.hasOwnProperty.call(d.fields,p)){const y=d.fields[p];this.instance[y]=c==null?null:c[p]}}},enumerable:!(s!=null&&s.has(a.key))}),f&&(t[a.key]=u)}}}get error(){var e;return(e=this._subscribers)==null||e.reportObserved(),this._error}set error(e){var t;this._error=e,(t=this._subscribers)==null||t.reportChanged()}subscribe(e){return this.initSubscribers(),this._subscribers.subscribe(e)}initSubscribers(){if(!this._subscribers){this._subscribers=new hn;const e=this._subscribers;for(const t of this.fieldsMetadata){let n=Te(t.valueType,!1),r=this.fields.find(t.key);if(r._subscribers=new hn,!(n&&this.remult||fe(t))){let s=this.instance[t.key];Object.defineProperty(this.instance,t.key,{get:()=>(e.reportObserved(),r._subscribers.reportObserved(),s),set:a=>{s=a,e.reportChanged(),r._subscribers.reportChanged()},enumerable:!0})}}}}get isLoading(){var e;return(e=this._subscribers)==null||e.reportObserved(),this._isLoading}set isLoading(e){var t;this._isLoading=e,(t=this._subscribers)==null||t.reportChanged()}async waitLoad(){await At([...this.lookups.values()],e=>e.waitLoad())}__assertValidity(){if(!this.hasErrors())throw this.buildErrorInfoObject()}buildErrorInfoObject(){var t;let e={modelState:Object.assign({},this.errors),message:this.error};if(!e.message){for(const n of this.fieldsMetadata)if((t=this.errors)!=null&&t[n.key]){e.message=this.fields[n.key].metadata.caption+": "+this.errors[n.key],this.error=e.message;break}}return new Jr(e)}catchSaveErrors(e){let t=e;if(t instanceof Promise)return t.then(r=>this.catchSaveErrors(r));t.error&&(t=t.error),t.message?this.error=t.message:t.Message?this.error=t.Message:this.error=t;let n=t.modelState;throw n||(n=t.ModelState),n&&(this.errors=n),e}__clearErrorsAndReportChanged(){this.errors=void 0,this.error=void 0,this._reportChangedToEntityAndFields()}_reportChangedToEntityAndFields(){if(this._subscribers){this._subscribers.reportChanged();for(const e of this.fields)e._subscribers.reportChanged()}}hasErrors(){var e;return(e=this._subscribers)==null||e.reportObserved(),!this.error&&this.errors==null}copyDataToObject(e=!1){let t={};for(const n of this.fieldsMetadata){let r=this.lookups.get(n.key),s;const a=fe(n);r?s=r.id:s=this.instance[n.key],a&&e&&!n.allowNull&&s==null&&(a.toRepo.metadata.idMetadata.field.valueType===Number?s=0:s=""),(!a||a.type==="reference")&&(s!==void 0&&(s=n.valueConverter.toJson(s),s!=null&&(s=n.valueConverter.fromJson(JSON.parse(JSON.stringify(s))))),t[n.key]=s)}return t}saveOriginalData(){this.originalValues=this.copyDataToObject(),this.saveMoreOriginalData()}saveMoreOriginalData(){}async validate(){if(this.__clearErrorsAndReportChanged(),await this.__performColumnAndEntityValidations(),this.hasErrors(),!this.hasErrors())return this.buildErrorInfoObject()}async __validateEntity(){this.__clearErrorsAndReportChanged(),await this.__performColumnAndEntityValidations(),this.__assertValidity()}async __performColumnAndEntityValidations(){}toApiJson(e=!1,t=!1){let n={};for(const r of this.fieldsMetadata)if(t||!this.remult||r.includedInApi(this.instance)){let s,a=this.lookups.get(r.key),o=!1;a?e?(s=a.toJson(),o=!0,n[r.key]=s):s=a.id:fe(r)&&!e?o=!0:(s=this.instance[r.key],this.remult||s&&Te(s.constructor,!1)&&(s=ae(s).getId())),o||(n[r.key]=r.valueConverter.toJson(s))}return n}async _updateEntityBasedOnApi(e,t=!1){let n=Object.keys(e);for(const r of this.fieldsMetadata)if(n.includes(r.key)&&r.includedInApi(this.instance)&&(!this.remult||t||r.apiUpdateAllowed(this.instance))){let s=this.lookups.get(r.key);s?s.id=e[r.key]:this.instance[r.key]=r.valueConverter.fromJson(e[r.key])}await At([...this.fields].filter(r=>!fe(r.metadata)),r=>r.load())}}class dn extends Ur{constructor(t,n,r,s,a,o,l){super(t.fieldsMetadata,n,a,o,l);h(this,"info");h(this,"repo");h(this,"edp");h(this,"_isNew");h(this,"repository");h(this,"metadata");h(this,"_wasDeleted",!1);h(this,"_columns");h(this,"_saving",!1);h(this,"id");h(this,"originalId");if(this.info=t,this.repo=r,this.edp=s,this._isNew=o,this.repository=r,this.metadata=t,o)for(const f of t.fieldsMetadata){const u=f.key;f.options.defaultValue&&n[u]===void 0&&(typeof f.options.defaultValue=="function"?n[u]=f.options.defaultValue(n):n[u]||(n[u]=f.options.defaultValue))}this.info.entityInfo.entityRefInit&&this.info.entityInfo.entityRefInit(this,n),Le.entityRefInit&&Le.entityRefInit(this,n)}clone(){const t=this.toApiJson(!0,!0);return this.repo.fromJson(t,this.isNew())}get relations(){return this.repo.relations(this.instance)}get apiUpdateAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiUpdate)}get apiDeleteAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiDelete)}get apiInsertAllowed(){return this.remult.isAllowedForInstance(this.instance,this.metadata.options.allowApiInsert)}getId(){const t=n=>{let r=this.lookups.get(n.key);return r?r.id:this.instance[n.key]};return this.metadata.idMetadata.field instanceof ct?this.metadata.idMetadata.field.getId(t):t(this.metadata.idMetadata.field)}saveMoreOriginalData(){this.originalId=this.getId()}wasDeleted(){var t;return(t=this._subscribers)==null||t.reportObserved(),this._wasDeleted}undoChanges(){this.loadDataFrom(this.originalValues),this.__clearErrorsAndReportChanged()}async reload(){return await this.edp.find({where:await this.getIdFilter()}).then(async t=>{if(t.length===0)throw this.repo._notFoundError(this.id);await this.loadDataFrom(t[0]),this.saveOriginalData()}),this._reportChangedToEntityAndFields(),this.instance}get fields(){if(!this._columns){let t=[],n={find:r=>n[typeof r=="string"?r:r.key],[Symbol.iterator]:()=>t[Symbol.iterator](),toArray:()=>t};for(const r of this.info.fieldsMetadata)t.push(n[r.key]=new An(r.options,r,this.instance,this,this));this._columns=n}return this._columns}async save(t){var n,r;try{if(this._saving)throw new Error("cannot save while entity is already saving");if(this._saving=!0,this.wasDeleted())throw new Error("cannot save a deleted row");this.isLoading=!0,t===void 0&&await this.__validateEntity();let s=!1,a=this.buildLifeCycleEvent(()=>s=!0);if(!this.repo._dataProvider.isProxy){for(const c of this.fields)c.metadata.options.saving&&await c.metadata.options.saving(this.instance,c,a);this.info.entityInfo.saving&&await this.info.entityInfo.saving(this.instance,a)}this.__assertValidity();let o=this.copyDataToObject(this.isNew()),l=[];for(const c of this.metadata.fields)if(c.dbReadOnly||t!==void 0&&!t.includes(c.key)){o[c.key]=void 0,l.push(c.key);let d=this.fields.find(c);d.value=d.originalValue}let f,u=this.isNew();try{if((n=this._subscribers)==null||n.reportChanged(),this.isNew())s?f=(f=await this.edp.find({where:await this.getIdFilter()}))[0]:f=await this.edp.insert(o);else{let c={},d=!1;for(const p in o)if(Object.prototype.hasOwnProperty.call(o,p)){const y=o[p];this.fields.find(p).valueChanged()&&!l.includes(p)&&y!==void 0&&(c[p]=y,d=!0)}if(!d)return this.instance;if(s)f=(await this.edp.find({where:await this.getIdFilter()}))[0];else{if(this.id===void 0)throw new Error("Invalid operation, id is undefined");f=await this.edp.update(this.id,c)}}if(f&&await this.loadDataFrom(f),a.id=this.getId(),!this.repo._dataProvider.isProxy&&(this.info.entityInfo.saved&&await this.info.entityInfo.saved(this.instance,a),this.repo.listeners))for(const c of this.repo.listeners)await((r=c.saved)==null?void 0:r.call(c,this.instance,u));return this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key,[{id:this.getId(),oldId:this.getOriginalId(),deleted:!1}]),this.saveOriginalData(),this._isNew=!1,this.instance}catch(c){throw await this.catchSaveErrors(c)}}finally{this.isLoading=!1,this._reportChangedToEntityAndFields(),this._saving=!1}}async processInsertResponseDto(t){return await this.loadDataFrom(t),this.saveOriginalData(),this._isNew=!1,this.instance}async buildDtoForInsert(){await this.__validateEntity(),this.__assertValidity();let t=this.copyDataToObject(this.isNew());for(const n of this.metadata.fields)if(n.dbReadOnly){t[n.key]=void 0;let r=this.fields.find(n);r.value=r.originalValue}return t}buildLifeCycleEvent(t=()=>{}){const n=this;return{isNew:n.isNew(),fields:n.fields,id:n.getId(),originalId:n.getOriginalId(),metadata:n.repo.metadata,repository:n.repo,preventDefault:()=>t(),relations:n.repo.relations(n.instance)}}async getIdFilter(){return await this.repo._translateWhereToFilter(this.repo.metadata.idMetadata.getIdFilter(this.id))}async delete(){var r;this.__clearErrorsAndReportChanged();let t=!0,n=this.buildLifeCycleEvent(()=>t=!1);this.repo._dataProvider.isProxy||this.info.entityInfo.deleting&&await this.info.entityInfo.deleting(this.instance,n),this.__assertValidity();try{if(t){if(this.id===void 0)throw new Error("Invalid operation, id is undefined");await this.edp.delete(this.id)}if(this.repo._dataProvider.isProxy||this.info.entityInfo.deleted&&await this.info.entityInfo.deleted(this.instance,n),this.repo.listeners)for(const s of this.repo.listeners)await((r=s.deleted)==null?void 0:r.call(s,this.instance));this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key,[{id:this.getId(),oldId:this.getOriginalId(),deleted:!0}]),this._wasDeleted=!0}catch(s){throw await this.catchSaveErrors(s)}}async loadDataFrom(t,n){for(const r of this.info.fields){let s=this.lookups.get(r.key);s?(s.id=t[r.key],n===void 0?!r.options.lazy&&!fe(r)&&await s.waitLoad():n.includes(r)&&await s.waitLoad()):fe(r)||(t[r.key]===void 0?delete this.instance[r.key]:this.instance[r.key]=t[r.key])}await this.calcServerExpression(),this.id=this.getId()}getOriginalId(){return this.originalId}async calcServerExpression(){if(!this.repo._dataProvider.isProxy){for(const t of this.info.fieldsMetadata)if(t.options.serverExpression){const n=await t.options.serverExpression(this.instance);n!==void 0&&(this.instance[t.key]=n)}}}isNew(){var t;return(t=this._subscribers)==null||t.reportObserved(),this._isNew}wasChanged(){var t;(t=this._subscribers)==null||t.reportObserved();for(const n of this.fields){const r=fe(n.metadata);if((!r||r.type=="reference")&&n.valueChanged())return!0}return!1}async __performColumnAndEntityValidations(){var t;for(const n of this.fieldsMetadata)n.options.validate&&await new An(n.options,n,this.instance,this,this).__performValidation();if(this.info.entityInfo.validation){let n=this.buildLifeCycleEvent(()=>{});await this.info.entityInfo.validation(this.instance,n)}if(this.repo.listeners)for(const n of this.repo.listeners)await((t=n.validating)==null?void 0:t.call(n,this.instance))}}const lr=Symbol.for("controllerColumns");function Vr(i,e){return i.map(t=>Ti(t.settings(e),e))}function ur(i,e){const t=e||Ae;let n=i[lr];if(n||(n=i[ft]),!n){let r=E.columnsOfType.get(i.constructor);r||E.columnsOfType.set(i.constructor,r=[]);let s=Object.getPrototypeOf(i.constructor);for(;s!=null;){let a=E.columnsOfType.get(s);a&&r.unshift(...a.filter(o=>!r.find(l=>l.key==o.key))),s=Object.getPrototypeOf(s)}i[lr]=n=new Zo(Vr(r,t).map(a=>new Hr(a,void 0,t)),i,t)}return n}class Zo extends Ur{constructor(t,n,r){super(t,n,r,!1);h(this,"fields");let s=[],a={find:o=>a[typeof o=="string"?o:o.key],[Symbol.iterator]:()=>s[Symbol.iterator](),toArray:()=>s};for(const o of t)s.push(a[o.key]=new An(o.options,o,n,void 0,this));this.fields=a}async __performColumnAndEntityValidations(){for(const t of this.fields)t instanceof An&&await t.__performValidation()}}class An{constructor(e,t,n,r,s){h(this,"settings");h(this,"metadata");h(this,"container");h(this,"helper");h(this,"rowBase");h(this,"_subscribers");h(this,"target");h(this,"entityRef");this.settings=e,this.metadata=t,this.container=n,this.helper=r,this.rowBase=s,this.target=this.settings.target,this.entityRef=this.helper}subscribe(e){return this._subscribers||this.rowBase.initSubscribers(),this._subscribers.subscribe(e)}valueIsNull(){this.reportObserved();let e=this.rowBase.lookups.get(this.metadata.key);return e?e.id===void 0||e.id===null:this.value===null}originalValueIsNull(){return this.reportObserved(),this.rowBase.lookups.get(this.metadata.key),this.rawOriginalValue()===null}get key(){return this.metadata.key}get repo(){var e;return(e=this.helper)==null?void 0:e.repository}async load(){let e=this.rowBase.lookups.get(this.metadata.key),t=fe(this.metadata);if(t&&this.helper){if(t.type==="toMany")return this.container[this.metadata.key]=await this.repo.relations(this.container)[this.key].find();{let n=await this.repo.relations(this.container)[this.metadata.key].findOne();if(n)this.container[this.metadata.key]=n;else return null}}else if(e)return this.valueChanged()&&await e.waitLoadOf(this.rawOriginalValue()),await e.waitLoad();return this.value}reportObserved(){var e,t;(e=this._subscribers)==null||e.reportObserved(),(t=this.rowBase._subscribers)==null||t.reportObserved()}reportChanged(){var e,t;(e=this._subscribers)==null||e.reportChanged(),(t=this.rowBase._subscribers)==null||t.reportChanged()}get error(){if(this.reportObserved(),!!this.rowBase.errors)return this.rowBase.errors[this.metadata.key]}set error(e){this.rowBase.errors||(this.rowBase.errors={}),this.rowBase.errors[this.metadata.key]=e,this.reportChanged()}get displayValue(){return this.reportObserved(),this.value!=null?this.settings.displayValue?this.settings.displayValue(this.container,this.value):this.metadata.valueConverter.displayValue?this.metadata.valueConverter.displayValue(this.value):this.value.toString():""}get value(){return this.container[this.metadata.key]}set value(e){this.container[this.metadata.key]=e}get originalValue(){this.reportObserved();let e=this.rowBase.lookups.get(this.metadata.key);return e?e.get(this.rawOriginalValue()):this.rowBase.originalValues[this.metadata.key]}rawOriginalValue(){return this.rowBase.originalValues[this.metadata.key]}setId(e){this.value=e}getId(){let e=this.rowBase.lookups.get(this.metadata.key);return e?e.id!=null?e.id:null:this.value}get inputValue(){this.reportObserved();let e=this.rowBase.lookups.get(this.metadata.key);return e?e.id!=null?e.id.toString():null:this.metadata.valueConverter.toInput(this.value,this.settings.inputType)}set inputValue(e){let t=this.rowBase.lookups.get(this.metadata.key);t?t.setId(e):this.value=this.metadata.valueConverter.fromInput(e,this.settings.inputType)}valueChanged(){this.reportObserved();let e=this.value,t=this.rowBase.lookups.get(this.metadata.key);return t&&(e=t.id),JSON.stringify(this.metadata.valueConverter.toJson(this.rowBase.originalValues[this.metadata.key]))!=JSON.stringify(this.metadata.valueConverter.toJson(e))}async __performValidation(){var e;try{const t=n=>{n!==!0&&n!==void 0&&!this.error&&(typeof n=="string"&&n.length>0?this.error=n:this.error="invalid value")};if(this.settings.validate){let n=this,r={entityRef:this.entityRef,get error(){return n.error},set error(s){n.error=s},isNew:((e=this.entityRef)==null?void 0:e.isNew())??!1,load:()=>n.load(),metadata:n.metadata,originalValue:n.originalValue,value:n.value,valueChanged:()=>n.valueChanged(),originalValueIsNull:()=>n.originalValueIsNull(),valueIsNull:()=>n.valueIsNull(),isBackend:()=>{var s,a,o;return!((o=(a=(s=n.rowBase)==null?void 0:s.remult)==null?void 0:a.dataProvider)!=null&&o.isProxy)}};if(Array.isArray(this.settings.validate))for(const s of this.settings.validate)t(await s(this.container,r));else typeof this.settings.validate=="function"&&t(await this.settings.validate(this.container,r))}}catch(t){typeof t=="string"?this.error=t:this.error=t==null?void 0:t.message}}async validate(){return await this.__performValidation(),!this.error}}let Yo={transformCaption:(i,e,t,n)=>t};const Zn=E.fieldOptionsEnricher||{enrichFieldOptions:i=>i},xo=E.captionTransformer||(E.captionTransformer=Yo);function Wr(i,e,t,n){let r;return typeof i=="function"?t&&(r=i(t)):i&&(r=i),r=xo.transformCaption(t,e,r??"",n),r||(e?li(e):"")}class Hr{constructor(e,t,n){h(this,"settings");h(this,"entityDefs");h(this,"remult");h(this,"options");h(this,"target");h(this,"readonly",!1);h(this,"valueConverter");h(this,"allowNull");h(this,"caption");h(this,"dbName");h(this,"inputType");h(this,"key");h(this,"isServerExpression",!1);h(this,"valueType");this.settings=e,this.entityDefs=t,this.remult=n,this.options=this.settings,this.target=this.settings.target,this.valueConverter=new Proxy(this.settings.valueConverter??{},{get:(r,s)=>{let a=r[s];return typeof a=="function"?(...o)=>{try{return r[s](...o)}catch(l){const f=`${String(s)} failed for value ${o==null?void 0:o[0]}. Error: ${typeof l=="string"?l:l.message}`;throw new Jr({message:this.caption+": "+f,modelState:{[this.key]:f}})}}:a}}),this.allowNull=!!this.settings.allowNull,this.valueType=this.settings.valueType,this.key=this.settings.key,this.inputType=this.settings.inputType,e.serverExpression&&(this.isServerExpression=!0),typeof this.settings.allowApiUpdate=="boolean"&&(this.readonly=this.settings.allowApiUpdate),this.inputType||(this.inputType=this.valueConverter.inputType),this.dbName=e.dbName,this.dbName==null&&(this.dbName=e.key),this.caption=Wr(e.caption,e.key,n,t)}apiUpdateAllowed(e){return this.options.allowApiUpdate===void 0?!0:this.remult.isAllowedForInstance(e,this.options.allowApiUpdate)}displayValue(e){return this.entityDefs.getEntityMetadataWithoutBreakingTheEntity(e).fields.find(this.key).displayValue}includedInApi(e){return this.options.includeInApi===void 0?!0:this.remult.isAllowedForInstance(e,this.options.includeInApi)}toInput(e,t){return this.valueConverter.toInput(e,t)}fromInput(e,t){return this.valueConverter.fromInput(e,t)}async getDbName(){return Pi(this,this.entityDefs)}get dbReadOnly(){return!!this.settings.dbReadOnly}}class el{constructor(e,t,n,r,s){h(this,"entityInfo");h(this,"remult");h(this,"entityType");h(this,"key");h(this,"options");h(this,"fieldsMetadata",[]);h(this,"idMetadata",{getId:e=>{if(e==null)return e;const t=ae(e,!1);return t?t.getId():this.idMetadata.field instanceof ct?this.idMetadata.field.getId(e):e[this.idMetadata.field.key]},field:void 0,get fields(){return this.field instanceof ct?this.field.fields:[this.field]},createIdInFilter:e=>e.length>0?{$or:e.map(t=>this.idMetadata.getIdFilter(ae(t).getId()))}:{[this.fields.toArray()[0].key]:[]},isIdField:e=>e.key==this.idMetadata.field.key,getIdFilter:(...e)=>{if(this.idMetadata.field instanceof ct){let t=this.idMetadata.field;return e.length==1?t.isEqualTo(e[0]):{$or:e.map(n=>t.isEqualTo(n))}}return e.length==1?{[this.idMetadata.field.key]:e[0]}:{[this.idMetadata.field.key]:e}}});h(this,"fields");h(this,"dbName");h(this,"caption");if(this.entityInfo=t,this.remult=n,this.entityType=r,this.key=s,this.options=t,this.options.allowApiCrud!==void 0){let o;typeof this.options.allowApiCrud=="function"?o=(l,f)=>this.options.allowApiCrud(f):o=this.options.allowApiCrud,this.options.allowApiDelete===void 0&&(this.entityInfo.allowApiDelete=o),this.options.allowApiInsert===void 0&&(this.entityInfo.allowApiInsert=o),this.options.allowApiUpdate===void 0&&(this.entityInfo.allowApiUpdate=o),this.options.allowApiRead===void 0&&(this.options.allowApiRead=this.options.allowApiCrud)}this.options.allowApiRead===void 0&&(this.options.allowApiRead=!0),this.key||(this.key=r.name),t.dbName||(t.dbName=this.key),this.dbName=t.dbName;let a={find:o=>a[typeof o=="string"?o:o.key],[Symbol.iterator]:()=>this.fieldsMetadata[Symbol.iterator](),toArray:()=>this.fieldsMetadata};for(const o of e)this.fieldsMetadata.push(a[o.key]=new Hr(o,this,n));if(this.fields=a,this.caption=Wr(t.caption,this.key,n,this),t.id){let o=typeof t.id=="string"?this.fields.find(t.id):Array.isArray(t.id)?t.id.map(l=>this.fields.find(l)):typeof t.id=="function"?t.id(this.fields):Object.keys(t.id).map(l=>this.fields.find(l));Array.isArray(o)?o.length>1?this.idMetadata.field=new ct(...o):o.length==1&&(this.idMetadata.field=o[0]):this.idMetadata.field=o}if(!this.idMetadata.field){const o=this.fields.id;o?this.idMetadata.field=o:this.idMetadata.field=[...this.fields][0]}}apiUpdateAllowed(e){return this.options.allowApiUpdate===void 0?!1:e?this.getEntityMetadataWithoutBreakingTheEntity(e).apiUpdateAllowed:this.remult.isAllowedForInstance(void 0,this.options.allowApiUpdate)}get apiReadAllowed(){return this.options.allowApiRead===void 0?!0:this.remult.isAllowed(this.options.allowApiRead)}apiDeleteAllowed(e){return this.options.allowApiDelete===void 0?!1:e?this.getEntityMetadataWithoutBreakingTheEntity(e).apiDeleteAllowed:this.remult.isAllowedForInstance(void 0,this.options.allowApiDelete)}apiInsertAllowed(e){return this.options.allowApiUpdate===void 0?!1:e?this.getEntityMetadataWithoutBreakingTheEntity(e).apiInsertAllowed:this.remult.isAllowedForInstance(void 0,this.options.allowApiInsert)}getEntityMetadataWithoutBreakingTheEntity(e){let t=ae(e,!1);return t||this.remult.repo(this.entityType).getEntityRef({...e})}getDbName(){return Xr(this)}}function tl(...i){return(e,t)=>(i||(i=[]),i.splice(0,0,{valueType:e}),e[Fi]=i,e)}function nl(i){var e,t;return((t=(e=i.options)==null?void 0:e.valueConverter)==null?void 0:t.fieldTypeInDb)==="autoincrement"}function il(...i){return(e,t)=>{tl(n=>{n.valueConverter=Sn.get(e),n.displayValue=(r,s)=>s==null?void 0:s.caption,n.validate=(r,s)=>{const a=Sn.get(e).getValues();return s.value&&!a.find(o=>o===s.value)&&(s.value=a.find(o=>o.id===s.value.id)||s.value),Re.in(a)(r,s)}},...i)(e)}}class Sn{constructor(e){h(this,"valueListType");h(this,"byIdMap",new Map);h(this,"values",[]);h(this,"isNumeric",!1);h(this,"fieldTypeInDb");h(this,"inputType");this.valueListType=e;for(let n in this.valueListType){let r=this.valueListType[n];r instanceof this.valueListType&&(r.id===void 0&&(r.id=n),typeof r.id=="number"&&(this.isNumeric=!0),r.caption===void 0&&(r.caption=li(r.id!==void 0?r.id.toString():n)),this.byIdMap.set(r.id,r),this.values.push(r))}this.isNumeric&&(this.fieldTypeInDb="integer");var t=this.valueListType[Fi];if(t){for(const n of t)n!=null&&n.getValues&&(this.values.splice(0,this.values.length,...n.getValues()),this.byIdMap.clear(),this.values.forEach(r=>{r.caption===void 0&&r.id!==void 0&&(r.caption=li(r.id)),this.byIdMap.set(r.id,r)}));if(this.values.find(n=>n.id===void 0))throw new Error(`ValueType ${this.valueListType} has values without an id`)}else throw new Error("ValueType not yet initialized, did you forget to call @ValueListFieldType on "+e)}static get(e){let t=fr.get(e);return t||(t=new Sn(e),fr.set(e,t)),t}getValues(){return this.values}byId(e){return this.isNumeric&&(e=+e),this.byIdMap.get(e)}fromJson(e){return this.byId(e)}toJson(e){if(e)return e.id}fromDb(e){return this.fromJson(e)}toDb(e){return this.toJson(e)}toInput(e,t){return this.toJson(e)}fromInput(e,t){return this.fromJson(e)}displayValue(e){return e?e.caption:""}}const fr=new Map,Fi=Symbol.for("storableMember"),Yn=Symbol.for("fieldOptionalValues");function Gr(i,e){var n;let t={};for(const r of i)if(r)if(typeof r=="function")r(t,e);else{const{validate:s,...a}=r;t.validate=_n(t.validate,s),Object.assign(t,a)}return(n=Zn.enrichFieldOptions)==null||n.call(Zn,t),t}function Ti(i,e){if(i.valueType){let r=i.valueType[Fi];r&&(i=Gr([...r,i],e))}if(i.valueType==String){let r=i;i.valueConverter||(r.valueConverter=Oe.String)}if(i.valueType==Number){let r=i;i.valueConverter||(r.valueConverter=Oe.Number)}if(i.valueType==Date){let r=i;i.valueConverter||(r.valueConverter=Oe.Date)}if(i.valueType==Boolean){let r=i;r.valueConverter||(r.valueConverter=Oe.Boolean)}if(!i.valueConverter){if(Te(i.valueType,!1)){let s;i.valueConverter={toDb:a=>a,fromDb:a=>a},i.valueConverter=new Proxy(i.valueConverter,{get(a,o){if(a[o]===void 0&&s===void 0){if(o==="inputType")return"";s=e.repo(i.valueType).metadata.idMetadata.field.valueType===Number;for(const l of["fieldTypeInDb","toJson","fromJson","toDb","fromDb"])a[l]=s?Oe.Integer[l]:Oe.String[l]}return a[o]},set(a,o,l,f){return a[o]=l,!0}})}else i.valueConverter=Oe.Default;return i}i.valueConverter.toJson||(i.valueConverter.toJson=r=>r),i.valueConverter.fromJson||(i.valueConverter.fromJson=r=>r);const t=i.valueConverter.fromJson,n=i.valueConverter.toJson;return i.valueConverter.toDb||(i.valueConverter.toDb=r=>n(r)),i.valueConverter.fromDb||(i.valueConverter.fromDb=r=>t(r)),i.valueConverter.toInput||(i.valueConverter.toInput=r=>n(r)),i.valueConverter.fromInput||(i.valueConverter.fromInput=r=>t(r)),i}class Qr{get _(){return ae(this)}save(){return ae(this).save()}assign(e){return jt(this,e),this}delete(){return this._.delete()}isNew(){return this._.isNew()}get $(){return this._.fields}}class hn{constructor(){h(this,"_subscribers")}reportChanged(){this._subscribers&&this._subscribers.forEach(e=>e.reportChanged())}reportObserved(){this._subscribers&&this._subscribers.forEach(e=>e.reportObserved())}subscribe(e){let t;return typeof e=="function"?t={reportChanged:()=>e(),reportObserved:()=>{}}:t=e,this._subscribers||(this._subscribers=[]),this._subscribers.push(t),()=>this._subscribers=this._subscribers.filter(n=>n!=t)}}function rl(i){return i.metadata?i.metadata:Te(i,!1)?Ae.repo(i).metadata:i}function sl(i){return Te(i,!1)?Ae.repo(i):i}async function At(i,e){const t=[];for(let n=0;n<i.length;n++){const r=i[n];t.push(await e(r,n))}return t}const St=class St{constructor(e){h(this,"sql");h(this,"wrapIdentifier",e=>e);h(this,"provideMigrationBuilder");h(this,"createdEntities",[]);h(this,"end");this.sql=e,e.wrapIdentifier&&(this.wrapIdentifier=t=>e.wrapIdentifier(t)),Ct(e,"provideMigrationBuilder")&&(this.provideMigrationBuilder=t=>e.provideMigrationBuilder(t)),Ct(e,"end")&&(this.end=()=>e.end())}static getDb(e){const t=e||Ae.dataProvider;if(Ct(t,"createCommand"))return t;throw"the data provider is not an SqlCommandFactory"}createCommand(){return new ol(this.sql.createCommand(),St.LogToConsole)}async execute(e){return await this.createCommand().execute(e)}_getSourceSql(){return this.sql}async ensureSchema(e){this.sql.ensureSchema&&await this.sql.ensureSchema(e)}getEntityDataProvider(e){if(!this.sql.supportsJsonColumnType)for(const t of e.fields.toArray())t.valueConverter.fieldTypeInDb==="json"&&(t.valueConverter={...t.valueConverter,toDb:Oe.JsonString.toDb,fromDb:Oe.JsonString.fromDb});return new zr(e,this,async t=>{this.createdEntities.indexOf(t.$entityName)<0&&(this.createdEntities.push(t.$entityName),await this.sql.entityIsUsedForTheFirstTime(e))},this.sql)}transaction(e){return this.sql.transaction(async t=>{let n=!1;try{await e(new St({createCommand:()=>{let r=t.createCommand();return{addParameterAndReturnSqlToken:s=>r.param(s),param:s=>r.param(s),execute:async s=>{if(n)throw"can't run a command after the transaction was completed";return r.execute(s)}}},getLimitSqlSyntax:this.sql.getLimitSqlSyntax,entityIsUsedForTheFirstTime:r=>t.entityIsUsedForTheFirstTime(r),transaction:r=>t.transaction(r),supportsJsonColumnType:this.sql.supportsJsonColumnType,wrapIdentifier:this.wrapIdentifier,end:this.end,doesNotSupportReturningSyntax:this.sql.doesNotSupportReturningSyntax,doesNotSupportReturningSyntaxOnlyForUpdate:this.sql.doesNotSupportReturningSyntaxOnlyForUpdate,orderByNullsFirst:this.sql.orderByNullsFirst}))}finally{n=!0}})}static rawFilter(e){return{[Mr]:{buildSql:e}}}static async filterToRaw(e,t,n,r,s){n||(n=new ll);const a=sl(e);var o=new Xe(n,r||await Kr(a.metadata,s));return o._addWhere=!1,await(await ht(a)._translateWhereToFilter(t)).__applyToConsumer(o),await o.resolveWhere()}};h(St,"LogToConsole",!1),h(St,"durationThreshold",0);let Ft=St;const al=new Map([["INSERT","⚪"],["SELECT","🔵"],["UPDATE","🟣"],["DELETE","🟤"],["CREATE","🟩"],["ALTER","🟨"],["DROP","🟥"],["TRUNCATE","⬛"],["GRANT","🟪"],["REVOKE","🟫"]]);class ol{constructor(e,t){h(this,"origin");h(this,"logToConsole");h(this,"args",{});this.origin=e,this.logToConsole=t}addParameterAndReturnSqlToken(e){return this.param(e)}param(e,t){let n=this.origin.param(e);return this.args[n]=e,n}async execute(e){try{let n=new Date,r=await this.origin.execute(e);if(this.logToConsole!==!1){var t=new Date().valueOf()-n.valueOf();if(t>=Ft.durationThreshold){const s=t/1e3;if(this.logToConsole==="oneLiner"){const a=e.replace(/(\r\n|\n|\r|\t)/gm," ").replace(/ +/g," ").trim(),o=a.split(" ")[0].toUpperCase();console.info(`${al.get(o)||"💢"} (${s.toFixed(3)}) ${a} ${JSON.stringify(this.args)}`)}else typeof this.logToConsole=="function"?this.logToConsole(s,e,this.args):console.info(e+`
|
|
2
|
+
`,{arguments:this.args,duration:s})}}return r}catch(n){throw console.error((n.message||"Sql Error")+`:
|
|
3
|
+
`,e,{arguments:this.args,error:n}),n}}}class zr{constructor(e,t,n,r){h(this,"entity");h(this,"sql");h(this,"iAmUsed");h(this,"strategy");this.entity=e,this.sql=t,this.iAmUsed=n,this.strategy=r}async init(){let e=await Kr(this.entity,t=>this.sql.wrapIdentifier(t));return await this.iAmUsed(e),e}async count(e){let t=await this.init(),n="select count(*) count from "+t.$entityName,r=this.sql.createCommand();if(e){let s=new Xe(r,t);e.__applyToConsumer(s),n+=await s.resolveWhere()}return r.execute(n).then(s=>Number(s.rows[0].count))}async groupBy(e){return await ul(e,await this.init(),this.sql.createCommand(),this.sql._getSourceSql().orderByNullsFirst,this.sql._getSourceSql().getLimitSqlSyntax)}async find(e){let t=await this.init(),{colKeys:n,select:r}=this.buildSelect(t);r="select "+r,r+=`
|
|
4
|
+
from `+t.$entityName;let s=this.sql.createCommand();if(e){if(e.where){let a=new Xe(s,t);e.where.__applyToConsumer(a),r+=await a.resolveWhere()}if(e.limit&&(e.orderBy=Fe.createUniqueSort(this.entity,e.orderBy)),e.orderBy||(e.orderBy=Fe.createUniqueSort(this.entity,new Fe)),e.orderBy){let a=!0,o=[];for(const l of e.orderBy.Segments)o.push(l);for(const l of o)a?(r+=" Order By ",a=!1):r+=", ",r+=t.$dbNameOf(l.field),l.isDescending&&(r+=" desc"),this.sql._getSourceSql().orderByNullsFirst&&(l.isDescending?r+=" nulls last":r+=" nulls first")}if(e.limit){let a=1;e.page&&(a=e.page),a<1&&(a=1),r+=" "+this.strategy.getLimitSqlSyntax(e.limit,(a-1)*e.limit)}}return s.execute(r).then(a=>a.rows.map(o=>this.buildResultRow(n,o,a)))}buildResultRow(e,t,n){let r={};for(let s=0;s<e.length;s++){const a=e[s];try{r[a.key]=a.valueConverter.fromDb(t[n.getColumnKeyInResultForIndexInSelect(s)])}catch(o){throw new Error("Failed to load from db:"+a.key+`\r
|
|
5
|
+
`+o)}}return r}buildSelect(e){let t="",n=[];for(const r of this.entity.fields)r.isServerExpression||(n.length>0&&(t+=", "),t+=e.$dbNameOf(r),r.options.sqlExpression&&(t+=" as "+r.key),n.push(r));return{colKeys:n,select:t}}async update(e,t){let n=await this.init(),r=this.sql.createCommand(),s="update "+n.$entityName+" set ",a=!1;for(const d of this.entity.fields)if(!dr(d,n)){if(t[d.key]!==void 0){let p=d.valueConverter.toDb(t[d.key]);p!==void 0&&(a?s+=", ":a=!0,s+=n.$dbNameOf(d)+" = "+r.param(p))}}const o=this.entity.idMetadata.getIdFilter(e);let l=new Xe(r,n);N.fromEntityFilter(this.entity,o).__applyToConsumer(l),s+=await l.resolveWhere();let{colKeys:f,select:u}=this.buildSelect(n),c=!0;return this.sql._getSourceSql().doesNotSupportReturningSyntax&&(c=!1),c&&this.sql._getSourceSql().doesNotSupportReturningSyntaxOnlyForUpdate&&(c=!1),c&&(s+=" returning "+u),r.execute(s).then(d=>{var p,y;if((y=(p=this.sql._getSourceSql()).afterMutation)==null||y.call(p),!c)return cr(this.entity,this,t,e,"update");if(d.rows.length!=1)throw new Error("Failed to update row with id "+e+", rows updated: "+d.rows.length);return this.buildResultRow(f,d.rows[0],d)})}async delete(e){let t=await this.init(),n=this.sql.createCommand(),r=new Xe(n,t);N.fromEntityFilter(this.entity,this.entity.idMetadata.getIdFilter(e)).__applyToConsumer(r);let s="delete from "+t.$entityName;return s+=await r.resolveWhere(),n.execute(s).then(()=>{var a,o;(o=(a=this.sql._getSourceSql()).afterMutation)==null||o.call(a)})}async insert(e){let t=await this.init(),n=this.sql.createCommand(),r="",s="",a=!1;for(const u of this.entity.fields)if(!dr(u,t)){let c=u.valueConverter.toDb(e[u.key]);c!=null&&(a?(r+=", ",s+=", "):a=!0,r+=t.$dbNameOf(u),s+=n.param(c))}let o=`insert into ${t.$entityName} (${r}) values (${s})`,{colKeys:l,select:f}=this.buildSelect(t);return this.sql._getSourceSql().doesNotSupportReturningSyntax||(o+=" returning "+f),await n.execute(o).then(u=>{var c,d;if((d=(c=this.sql._getSourceSql()).afterMutation)==null||d.call(c),this.sql._getSourceSql().doesNotSupportReturningSyntax)if(nl(this.entity.idMetadata.field)){const p=u.rows[0];if(typeof p!="number")throw new Error("Auto increment, for a database that is does not support returning syntax, should return an array with the single last added id. Instead it returned: "+JSON.stringify(p));return this.find({where:new N(y=>y.isEqualTo(this.entity.idMetadata.field,p))}).then(y=>y[0])}else return cr(this.entity,this,e,void 0,"insert");return this.buildResultRow(l,u.rows[0],u)})}}h(zr,"LogToConsole",!1);class ll{execute(e){throw new Error("Method not implemented.")}addParameterAndReturnSqlToken(e){return this.param(e)}param(e){return e===null?"null":(e instanceof Date&&(e=e.toISOString()),typeof e=="string"?(e==null&&(e=""),"'"+e.replace(/'/g,"''")+"'"):e.toString())}}function cr(i,e,t,n,r){const s=n!==void 0?i.idMetadata.getIdFilter(n):{};return e.find({where:new N(a=>{for(const o of i.idMetadata.fields)a.isEqualTo(o,t[o.key]??s[o.key])})}).then(a=>{if(a.length!=1)throw new Error(`Failed to ${r} row - result contained ${a.length} rows`);return a[0]})}async function ul(i,e,t,n,r){let s="select count(*) as count",a="";const o=[];if(o.push((c,d)=>{d[_o]=Number(c)}),i!=null&&i.group)for(const c of i==null?void 0:i.group)c.isServerExpression||(s+=", "+e.$dbNameOf(c),c.options.sqlExpression&&(s+=" as "+c.key),a==""?a=" group by ":a+=", ",a+=e.$dbNameOf(c)),o.push((d,p)=>{p[c.key]=c.valueConverter.fromDb(d)});for(const c of vo){const d=i==null?void 0:i[c];if(d)for(const p of d){if(!p.isServerExpression){const m=await e.$dbNameOf(p);s+=`, ${u(c,m)} as ${p.key}_${c}`}const y=p.valueType===Number||c=="distinctCount";o.push((m,g)=>{y&&(m=Number(m)),g[p.key]={...g[p.key],[c]:m}})}}if(s+=`
|
|
6
|
+
from `+e.$entityName,i!=null&&i.where){let c=new Xe(t,e);i==null||i.where.__applyToConsumer(c),s+=await c.resolveWhere()}a&&(s+=a);let l="";if(i!=null&&i.orderBy){for(const c of i==null?void 0:i.orderBy){l==""?l=" order by ":l+=", ";let d=c.field&&await e.$dbNameOf(c.field);switch(c.operation){case"count":d=c.operation+"(*)";break;case void 0:break;default:d=u(c.operation,d)}l+=d,c.isDescending&&(l+=" desc"),n&&(c.isDescending?l+=" nulls last":l+=" nulls first")}l&&(s+=l)}if(i!=null&&i.limit){let c=1;i.page&&(c=i.page),c<1&&(c=1),s+=" "+r(i.limit,(c-1)*i.limit)}const f=await t.execute(s);return f.rows.map(c=>{let d={};return o.forEach((p,y)=>p(c[f.getColumnKeyInResultForIndexInSelect(y)],d)),d});function u(c,d){return c==="distinctCount"?`count (distinct ${d})`:`${c}( ${d} )`}}class Xe{constructor(e,t){h(this,"r");h(this,"nameProvider");h(this,"where","");h(this,"_addWhere",!0);h(this,"promises",[]);this.r=e,this.nameProvider=t}async resolveWhere(){for(;this.promises.length>0;){let e=this.promises;this.promises=[];for(const t of e)await t}return this.where}custom(e,t){throw new Error("Custom filter should be translated before it gets here")}or(e){let t="";this.promises.push((async()=>{for(const n of e){let r=new Xe(this.r,this.nameProvider);r._addWhere=!1,n.__applyToConsumer(r);let s=await r.resolveWhere();if(!s)return;s.length>0&&(t.length>0&&(t+=" or "),e.length>1?t+="("+s+")":t+=s)}this.addToWhere("("+t+")")})())}not(e){this.promises.push((async()=>{let t=new Xe(this.r,this.nameProvider);t._addWhere=!1,e.__applyToConsumer(t);let n=await t.resolveWhere();n&&this.addToWhere("not ("+n+")")})())}isNull(e){this.promises.push((async()=>this.addToWhere(this.nameProvider.$dbNameOf(e)+" is null"))())}isNotNull(e){this.promises.push((async()=>this.addToWhere(this.nameProvider.$dbNameOf(e)+" is not null"))())}isIn(e,t){this.promises.push((async()=>{t&&t.length>0?this.addToWhere(this.nameProvider.$dbNameOf(e)+" in ("+t.map(n=>this.r.param(e.valueConverter.toDb(n))).join(",")+")"):this.addToWhere("1 = 0 /*isIn with no values*/")})())}isEqualTo(e,t){this.add(e,t,"=")}isDifferentFrom(e,t){this.add(e,t,"<>")}isGreaterOrEqualTo(e,t){this.add(e,t,">=")}isGreaterThan(e,t){this.add(e,t,">")}isLessOrEqualTo(e,t){this.add(e,t,"<=")}isLessThan(e,t){this.add(e,t,"<")}containsCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('%"+t.replace(/'/g,"''")+"%')")})())}notContainsCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("not lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('%"+t.replace(/'/g,"''")+"%')")})())}startsWithCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('"+t.replace(/'/g,"''")+"%')")})())}endsWithCaseInsensitive(e,t){this.promises.push((async()=>{this.addToWhere("lower ("+this.nameProvider.$dbNameOf(e)+") like lower ('%"+t.replace(/'/g,"''")+"')")})())}add(e,t,n){this.promises.push((async()=>{let r=this.nameProvider.$dbNameOf(e)+" "+n+" "+this.r.param(e.valueConverter.toDb(t));this.addToWhere(r)})())}addToWhere(e){this.where.length==0?this._addWhere&&(this.where+=" where "):this.where+=" and ",this.where+=e}databaseCustom(e){this.promises.push((async()=>{if(e!=null&&e.buildSql){let t=new fl(this.r,this.nameProvider.wrapIdentifier),n=await e.buildSql(t);typeof n!="string"&&(n=t.sql),n&&this.addToWhere("("+n+")")}})())}}class fl{constructor(e,t){h(this,"r");h(this,"wrapIdentifier");h(this,"sql","");h(this,"param",(e,t)=>(typeof t=="object"&&t.valueConverter.toDb&&(e=t.valueConverter.toDb(e)),this.r.param(e)));h(this,"filterToRaw",async(e,t)=>Ft.filterToRaw(e,t,this,void 0,this.wrapIdentifier));this.r=e,this.wrapIdentifier=t,this.param.bind(this),this.filterToRaw.bind(this)}addParameterAndReturnSqlToken(e){return this.param(e)}}function dr(i,e){return i.dbReadOnly||i.isServerExpression||i.options.sqlExpression&&i.dbName!=e.$dbNameOf(i)}async function Kr(i,e){return cl(i,e,!0)}async function cl(i,e,t=!1){let n=typeof e=="function"?{wrapIdentifier:e}:e||{};var r=rl(i);n.wrapIdentifier||(n.wrapIdentifier=Ae.dataProvider.wrapIdentifier),n.wrapIdentifier||(n.wrapIdentifier=a=>a);const s={$entityName:await Xr(r,n.wrapIdentifier),toString:()=>s.$entityName,$dbNameOf:a=>{var o;return typeof a=="string"?o=a:o=a.key,s[o]},wrapIdentifier:n.wrapIdentifier};for(const a of r.fields){let o=await Pi(a,r,n.wrapIdentifier,t);a.options.sqlExpression||(typeof n.tableName=="string"?o=n.wrapIdentifier(n.tableName)+"."+o:n.tableName===!0&&(o=s.$entityName+"."+o)),s[a.key]=o}return s}async function Xr(i,e=t=>t){if(i.options.sqlExpression){if(typeof i.options.sqlExpression=="string")return i.options.sqlExpression;if(typeof i.options.sqlExpression=="function"){const t=i.options.sqlExpression;try{return i.options.sqlExpression="recursive sqlExpression call for entity '"+i.key+"'. ",await t(i)}finally{i.options.sqlExpression=t}}}return e(i.dbName)}const xn=Symbol.for("sqlExpressionInProgressKey");async function Pi(i,e,t=r=>r,n=!1){try{if(i.options.sqlExpression){let a;if(typeof i.options.sqlExpression=="function"){if(i[xn]&&!n)return"recursive sqlExpression call for field '"+i.key+"'. \0";try{i[xn]=!0,a=await i.options.sqlExpression(e),a.includes("\0")||(i.options.sqlExpression=()=>a)}finally{delete i[xn]}}else a=i.options.sqlExpression;return a||i.dbName}const r=fe(i);let s=(r==null?void 0:r.type)==="toOne"&&i.options.field;if(s){let a=e.fields.find(s);if(a)return Pi(a,e,t,n)}return t(i.dbName)}finally{}}function Zr(i,...e){return(t,n)=>{let r=t;for(;r!=null;){for(const a in r)if(Object.prototype.hasOwnProperty.call(r,a)){const o=t[a];o!=null&&o.rawFilterInfo&&(o.rawFilterInfo.key||(o.rawFilterInfo.key=a))}r=Object.getPrototypeOf(r)}let s=a=>{let o={};for(const f of e)f&&(typeof f=="function"?f(o,a):Object.assign(o,f));let l=Object.getPrototypeOf(t);if(l){let f=Te(l,!1);if(f){let u=f(a);u&&(o={...u,...o})}}return o};return E.allEntities.push(t),Jo(t,{key:i}),t[Dr]=s,t[Rr]=i,t}}var Cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},it={},ue={},_e={};Object.defineProperty(_e,"__esModule",{value:!0});_e.output=_e.exists=_e.hash=_e.bytes=_e.bool=_e.number=_e.isBytes=void 0;function En(i){if(!Number.isSafeInteger(i)||i<0)throw new Error(`positive integer expected, not ${i}`)}_e.number=En;function Yr(i){if(typeof i!="boolean")throw new Error(`boolean expected, not ${i}`)}_e.bool=Yr;function xr(i){return i instanceof Uint8Array||i!=null&&typeof i=="object"&&i.constructor.name==="Uint8Array"}_e.isBytes=xr;function Di(i,...e){if(!xr(i))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(i.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${i.length}`)}_e.bytes=Di;function es(i){if(typeof i!="function"||typeof i.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");En(i.outputLen),En(i.blockLen)}_e.hash=es;function ts(i,e=!0){if(i.destroyed)throw new Error("Hash instance has been destroyed");if(e&&i.finished)throw new Error("Hash#digest() has already been called")}_e.exists=ts;function ns(i,e){Di(i);const t=e.outputLen;if(i.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}_e.output=ns;const dl={number:En,bool:Yr,bytes:Di,hash:es,exists:ts,output:ns};_e.default=dl;var U={};Object.defineProperty(U,"__esModule",{value:!0});U.add5L=U.add5H=U.add4H=U.add4L=U.add3H=U.add3L=U.add=U.rotlBL=U.rotlBH=U.rotlSL=U.rotlSH=U.rotr32L=U.rotr32H=U.rotrBL=U.rotrBH=U.rotrSL=U.rotrSH=U.shrSL=U.shrSH=U.toBig=U.split=U.fromBig=void 0;const pn=BigInt(2**32-1),di=BigInt(32);function Ri(i,e=!1){return e?{h:Number(i&pn),l:Number(i>>di&pn)}:{h:Number(i>>di&pn)|0,l:Number(i&pn)|0}}U.fromBig=Ri;function is(i,e=!1){let t=new Uint32Array(i.length),n=new Uint32Array(i.length);for(let r=0;r<i.length;r++){const{h:s,l:a}=Ri(i[r],e);[t[r],n[r]]=[s,a]}return[t,n]}U.split=is;const rs=(i,e)=>BigInt(i>>>0)<<di|BigInt(e>>>0);U.toBig=rs;const ss=(i,e,t)=>i>>>t;U.shrSH=ss;const as=(i,e,t)=>i<<32-t|e>>>t;U.shrSL=as;const os=(i,e,t)=>i>>>t|e<<32-t;U.rotrSH=os;const ls=(i,e,t)=>i<<32-t|e>>>t;U.rotrSL=ls;const us=(i,e,t)=>i<<64-t|e>>>t-32;U.rotrBH=us;const fs=(i,e,t)=>i>>>t-32|e<<64-t;U.rotrBL=fs;const cs=(i,e)=>e;U.rotr32H=cs;const ds=(i,e)=>i;U.rotr32L=ds;const hs=(i,e,t)=>i<<t|e>>>32-t;U.rotlSH=hs;const ps=(i,e,t)=>e<<t|i>>>32-t;U.rotlSL=ps;const ys=(i,e,t)=>e<<t-32|i>>>64-t;U.rotlBH=ys;const ms=(i,e,t)=>i<<t-32|e>>>64-t;U.rotlBL=ms;function gs(i,e,t,n){const r=(e>>>0)+(n>>>0);return{h:i+t+(r/2**32|0)|0,l:r|0}}U.add=gs;const ws=(i,e,t)=>(i>>>0)+(e>>>0)+(t>>>0);U.add3L=ws;const _s=(i,e,t,n)=>e+t+n+(i/2**32|0)|0;U.add3H=_s;const bs=(i,e,t,n)=>(i>>>0)+(e>>>0)+(t>>>0)+(n>>>0);U.add4L=bs;const vs=(i,e,t,n,r)=>e+t+n+r+(i/2**32|0)|0;U.add4H=vs;const ks=(i,e,t,n,r)=>(i>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);U.add5L=ks;const Is=(i,e,t,n,r,s)=>e+t+n+r+s+(i/2**32|0)|0;U.add5H=Is;const hl={fromBig:Ri,split:is,toBig:rs,shrSH:ss,shrSL:as,rotrSH:os,rotrSL:ls,rotrBH:us,rotrBL:fs,rotr32H:cs,rotr32L:ds,rotlSH:hs,rotlSL:ps,rotlBH:ys,rotlBL:ms,add:gs,add3L:ws,add3H:_s,add4L:bs,add4H:vs,add5H:Is,add5L:ks};U.default=hl;var Os={},Bn={};Object.defineProperty(Bn,"__esModule",{value:!0});Bn.crypto=void 0;Bn.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;(function(i){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(i,"__esModule",{value:!0}),i.randomBytes=i.wrapXOFConstructorWithOpts=i.wrapConstructorWithOpts=i.wrapConstructor=i.checkOpts=i.Hash=i.concatBytes=i.toBytes=i.utf8ToBytes=i.asyncLoop=i.nextTick=i.hexToBytes=i.bytesToHex=i.byteSwap32=i.byteSwapIfBE=i.byteSwap=i.isLE=i.rotl=i.rotr=i.createView=i.u32=i.u8=i.isBytes=void 0;const e=Bn,t=_e;function n(_){return _ instanceof Uint8Array||_!=null&&typeof _=="object"&&_.constructor.name==="Uint8Array"}i.isBytes=n;const r=_=>new Uint8Array(_.buffer,_.byteOffset,_.byteLength);i.u8=r;const s=_=>new Uint32Array(_.buffer,_.byteOffset,Math.floor(_.byteLength/4));i.u32=s;const a=_=>new DataView(_.buffer,_.byteOffset,_.byteLength);i.createView=a;const o=(_,A)=>_<<32-A|_>>>A;i.rotr=o;const l=(_,A)=>_<<A|_>>>32-A>>>0;i.rotl=l,i.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=_=>_<<24&4278190080|_<<8&16711680|_>>>8&65280|_>>>24&255;i.byteSwap=f,i.byteSwapIfBE=i.isLE?_=>_:_=>(0,i.byteSwap)(_);function u(_){for(let A=0;A<_.length;A++)_[A]=(0,i.byteSwap)(_[A])}i.byteSwap32=u;const c=Array.from({length:256},(_,A)=>A.toString(16).padStart(2,"0"));function d(_){(0,t.bytes)(_);let A="";for(let F=0;F<_.length;F++)A+=c[_[F]];return A}i.bytesToHex=d;const p={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function y(_){if(_>=p._0&&_<=p._9)return _-p._0;if(_>=p._A&&_<=p._F)return _-(p._A-10);if(_>=p._a&&_<=p._f)return _-(p._a-10)}function m(_){if(typeof _!="string")throw new Error("hex string expected, got "+typeof _);const A=_.length,F=A/2;if(A%2)throw new Error("padded hex string expected, got unpadded hex of length "+A);const B=new Uint8Array(F);for(let x=0,de=0;x<F;x++,de+=2){const Se=y(_.charCodeAt(de)),Ye=y(_.charCodeAt(de+1));if(Se===void 0||Ye===void 0){const st=_[de]+_[de+1];throw new Error('hex string expected, got non-hex character "'+st+'" at index '+de)}B[x]=Se*16+Ye}return B}i.hexToBytes=m;const g=async()=>{};i.nextTick=g;async function I(_,A,F){let B=Date.now();for(let x=0;x<_;x++){F(x);const de=Date.now()-B;de>=0&&de<A||(await(0,i.nextTick)(),B+=de)}}i.asyncLoop=I;function v(_){if(typeof _!="string")throw new Error(`utf8ToBytes expected string, got ${typeof _}`);return new Uint8Array(new TextEncoder().encode(_))}i.utf8ToBytes=v;function O(_){return typeof _=="string"&&(_=v(_)),(0,t.bytes)(_),_}i.toBytes=O;function P(..._){let A=0;for(let B=0;B<_.length;B++){const x=_[B];(0,t.bytes)(x),A+=x.length}const F=new Uint8Array(A);for(let B=0,x=0;B<_.length;B++){const de=_[B];F.set(de,x),x+=de.length}return F}i.concatBytes=P;class W{clone(){return this._cloneInto()}}i.Hash=W;const se={}.toString;function le(_,A){if(A!==void 0&&se.call(A)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(_,A)}i.checkOpts=le;function pe(_){const A=B=>_().update(O(B)).digest(),F=_();return A.outputLen=F.outputLen,A.blockLen=F.blockLen,A.create=()=>_(),A}i.wrapConstructor=pe;function me(_){const A=(B,x)=>_(x).update(O(B)).digest(),F=_({});return A.outputLen=F.outputLen,A.blockLen=F.blockLen,A.create=B=>_(B),A}i.wrapConstructorWithOpts=me;function K(_){const A=(B,x)=>_(x).update(O(B)).digest(),F=_({});return A.outputLen=F.outputLen,A.blockLen=F.blockLen,A.create=B=>_(B),A}i.wrapXOFConstructorWithOpts=K;function X(_=32){if(e.crypto&&typeof e.crypto.getRandomValues=="function")return e.crypto.getRandomValues(new Uint8Array(_));throw new Error("crypto.getRandomValues must be defined")}i.randomBytes=X})(Os);Object.defineProperty(ue,"__esModule",{value:!0});ue.shake256=ue.shake128=ue.keccak_512=ue.keccak_384=ue.keccak_256=ue.keccak_224=ue.sha3_512=ue.sha3_384=ue.sha3_256=ue.sha3_224=ue.Keccak=ue.keccakP=void 0;const vt=_e,zt=U,Ke=Os,As=[],Ss=[],Cs=[],pl=BigInt(0),Nt=BigInt(1),yl=BigInt(2),ml=BigInt(7),gl=BigInt(256),wl=BigInt(113);for(let i=0,e=Nt,t=1,n=0;i<24;i++){[t,n]=[n,(2*t+3*n)%5],As.push(2*(5*n+t)),Ss.push((i+1)*(i+2)/2%64);let r=pl;for(let s=0;s<7;s++)e=(e<<Nt^(e>>ml)*wl)%gl,e&yl&&(r^=Nt<<(Nt<<BigInt(s))-Nt);Cs.push(r)}const[_l,bl]=(0,zt.split)(Cs,!0),hr=(i,e,t)=>t>32?(0,zt.rotlBH)(i,e,t):(0,zt.rotlSH)(i,e,t),pr=(i,e,t)=>t>32?(0,zt.rotlBL)(i,e,t):(0,zt.rotlSL)(i,e,t);function Es(i,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let a=0;a<10;a++)t[a]=i[a]^i[a+10]^i[a+20]^i[a+30]^i[a+40];for(let a=0;a<10;a+=2){const o=(a+8)%10,l=(a+2)%10,f=t[l],u=t[l+1],c=hr(f,u,1)^t[o],d=pr(f,u,1)^t[o+1];for(let p=0;p<50;p+=10)i[a+p]^=c,i[a+p+1]^=d}let r=i[2],s=i[3];for(let a=0;a<24;a++){const o=Ss[a],l=hr(r,s,o),f=pr(r,s,o),u=As[a];r=i[u],s=i[u+1],i[u]=l,i[u+1]=f}for(let a=0;a<50;a+=10){for(let o=0;o<10;o++)t[o]=i[a+o];for(let o=0;o<10;o++)i[a+o]^=~t[(o+2)%10]&t[(o+4)%10]}i[0]^=_l[n],i[1]^=bl[n]}t.fill(0)}ue.keccakP=Es;class on extends Ke.Hash{constructor(e,t,n,r=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,vt.number)(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,Ke.u32)(this.state)}keccak(){Ke.isLE||(0,Ke.byteSwap32)(this.state32),Es(this.state32,this.rounds),Ke.isLE||(0,Ke.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(e){(0,vt.exists)(this);const{blockLen:t,state:n}=this;e=(0,Ke.toBytes)(e);const r=e.length;for(let s=0;s<r;){const a=Math.min(t-this.pos,r-s);for(let o=0;o<a;o++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){(0,vt.exists)(this,!1),(0,vt.bytes)(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,s=e.length;r<s;){this.posOut>=n&&this.keccak();const a=Math.min(n-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,vt.number)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,vt.output)(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:s,enableXOF:a}=this;return e||(e=new on(t,n,r,a,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=r,e.enableXOF=a,e.destroyed=this.destroyed,e}}ue.Keccak=on;const rt=(i,e,t)=>(0,Ke.wrapConstructor)(()=>new on(e,i,t));ue.sha3_224=rt(6,144,224/8);ue.sha3_256=rt(6,136,256/8);ue.sha3_384=rt(6,104,384/8);ue.sha3_512=rt(6,72,512/8);ue.keccak_224=rt(1,144,224/8);ue.keccak_256=rt(1,136,256/8);ue.keccak_384=rt(1,104,384/8);ue.keccak_512=rt(1,72,512/8);const Fs=(i,e,t)=>(0,Ke.wrapXOFConstructorWithOpts)((n={})=>new on(e,i,n.dkLen===void 0?t:n.dkLen,!0));ue.shake128=Fs(31,168,128/8);ue.shake256=Fs(31,136,256/8);const{sha3_512:vl}=ue,Ts=24,Wt=32,hi=(i=4,e=Math.random)=>{let t="";for(;t.length<i;)t=t+Math.floor(e()*36).toString(36);return t};function Ps(i){let e=8n,t=0n;for(const n of i.values()){const r=BigInt(n);t=(t<<e)+r}return t}const Ds=(i="")=>Ps(vl(i)).toString(36).slice(1),yr=Array.from({length:26},(i,e)=>String.fromCharCode(e+97)),kl=i=>yr[Math.floor(i()*yr.length)],Rs=({globalObj:i=typeof Cn<"u"?Cn:typeof window<"u"?window:{},random:e=Math.random}={})=>{const t=Object.keys(i).toString(),n=t.length?t+hi(Wt,e):hi(Wt,e);return Ds(n).substring(0,Wt)},Bs=i=>()=>i++,Il=476782367,Ms=({random:i=Math.random,counter:e=Bs(Math.floor(i()*Il)),length:t=Ts,fingerprint:n=Rs({random:i})}={})=>function(){const s=kl(i),a=Date.now().toString(36),o=e().toString(36),l=hi(t,i),f=`${a+l+o+n}`;return`${s+Ds(f).substring(1,t)}`},Ol=Ms(),Al=(i,{minLength:e=2,maxLength:t=Wt}={})=>{const n=i.length,r=/^[0-9a-z]+$/;try{if(typeof i=="string"&&n>=e&&n<=t&&r.test(i))return!0}finally{}return!1};it.getConstants=()=>({defaultLength:Ts,bigLength:Wt});it.init=Ms;it.createId=Ol;it.bufToBigInt=Ps;it.createCounter=Bs;it.createFingerprint=Rs;it.isCuid=Al;const{createId:Sl,init:Ql,getConstants:zl,isCuid:Kl}=it;var mr=Sl;const gr=gn(i=>!isNaN(i)&&isFinite(i));class ee{static object(...e){return ve(void 0,...e)}static json(...e){let t=e;return t.valueConverter&&!t.valueConverter.fieldTypeInDb&&(t.valueConverter.fieldTypeInDb="json"),ve(void 0,{valueConverter:{fieldTypeInDb:"json"}},...e)}static dateOnly(...e){return ve(()=>Date,{valueConverter:Oe.DateOnly},...e)}static date(...e){return ve(()=>Date,...e)}static integer(...e){return ve(()=>Number,{valueConverter:Oe.Integer,validate:gr},...e)}static autoIncrement(...e){return ve(()=>Number,{allowApiUpdate:!1,dbReadOnly:!0,valueConverter:{...Oe.Integer,fieldTypeInDb:"autoincrement"}},...e)}static number(...e){return ve(()=>Number,{validate:gr},...e)}static createdAt(...e){return ve(()=>Date,{allowApiUpdate:!1,saving:(t,n,{isNew:r})=>{r&&(n.value=new Date)}},...e)}static updatedAt(...e){return ve(()=>Date,{allowApiUpdate:!1,saving:(t,n)=>{n.value=new Date}},...e)}static uuid(...e){return ve(()=>String,{allowApiUpdate:!1,defaultValue:()=>fi(),saving:(t,n)=>{n.value||(n.value=fi())}},...e)}static cuid(...e){return ve(()=>String,{allowApiUpdate:!1,defaultValue:()=>mr(),saving:(t,n)=>{n.value||(n.value=mr())}},...e)}static literal(e,...t){return ee.string({validate:(n,r)=>Re.in(e())(n,r),[Yn]:e},...t)}static enum(e,...t){let n;return ve(()=>e(),{validate:(r,s)=>Re.enum(e())(r,s),[Yn]:()=>wn(e())},...t,r=>{if(r[Yn]=()=>wn(e()),n===void 0){let s=e();n=wn(s).find(o=>typeof o=="string")?Oe.String:Oe.Integer}r.valueConverter?r.valueConverter.fieldTypeInDb||(r.valueConverter.fieldTypeInDb=n.fieldTypeInDb):r.valueConverter=n})}static string(...e){return ve(()=>String,...e)}static boolean(...e){return ve(()=>Boolean,...e)}}class Mn{static toOne(e,t){let n=typeof t=="string"?{field:t}:t||{};return!n.field&&!n.fields&&!n.findOptions?ve(e,{...n,...Gn(e,"reference")}):ve(()=>{},{...n,serverExpression:()=>{},...Gn(e,"toOne")})}static toMany(e,t){return ve(()=>{},{...typeof t=="string"?{field:t}:t,serverExpression:()=>{},...Gn(e,"toMany")})}}function ve(i,...e){return(t,n,r)=>{const s=typeof n=="string"?n:n.name.toString();let a=f=>{let u=Gr(e,f);if(u.required&&(u.validate=_n(u.validate,Re.required,!0)),Ct(u,"maxLength")){let d=u;d.maxLength&&(d.validate=_n(d.validate,Re.maxLength(d.maxLength)))}if(Ct(u,"minLength")){let d=u;d.minLength&&(d.validate=_n(d.validate,Re.minLength(d.minLength)))}!u.valueType&&i&&(u.valueType=i()),u.key||(u.key=s),u.dbName||(u.dbName=u.key);let c=u.valueType;return c||(c=typeof Reflect.getMetadata=="function"?Reflect.getMetadata("design:type",t,s):[],u.valueType=c),u.target||(u.target=t),u};Ns(t);let o=E.columnsOfType.get(t.constructor);o||(o=[],E.columnsOfType.set(t.constructor,o));let l=o.find(f=>f.key==s);if(!l)o.push({key:s,settings:a});else{let f=l.settings;l.settings=u=>{let c=f(u),d=a(u);return Object.assign(c,d)}}}}function Ns(i){if(!i)throw new Error("Set the 'experimentalDecorators:true' option in your 'tsconfig' or 'jsconfig' (target undefined)")}function Cl(i,e,t,n){var r=arguments.length,s=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(i,e,t,n);else for(var o=i.length-1;o>=0;o--)(a=i[o])&&(s=(r<3?a(s):r>3?a(e,t,s):a(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s}function El(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}class Fn extends Qr{constructor(){super(...arguments);h(this,"id")}}Cl([ee.uuid(),El("design:type",String)],Fn.prototype,"id",void 0);/*! *****************************************************************************
|
|
7
|
+
Copyright (C) Microsoft. All rights reserved.
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
9
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
10
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
13
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
14
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
15
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
16
|
+
|
|
17
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
18
|
+
and limitations under the License.
|
|
19
|
+
***************************************************************************** */var wr;(function(i){(function(e){var t=typeof Cn=="object"?Cn:typeof self=="object"?self:typeof this=="object"?this:Function("return this;")(),n=r(i);typeof t.Reflect>"u"?t.Reflect=i:n=r(t.Reflect,n),e(n);function r(s,a){return function(o,l){typeof s[o]!="function"&&Object.defineProperty(s,o,{configurable:!0,writable:!0,value:l}),a&&a(o,l)}}})(function(e){var t=Object.prototype.hasOwnProperty,n=typeof Symbol=="function",r=n&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",s=n&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",a=typeof Object.create=="function",o={__proto__:[]}instanceof Array,l=!a&&!o,f={create:a?function(){return jn(Object.create(null))}:o?function(){return jn({__proto__:null})}:function(){return jn({})},has:l?function(w,b){return t.call(w,b)}:function(w,b){return b in w},get:l?function(w,b){return t.call(w,b)?w[b]:void 0}:function(w,b){return w[b]}},u=Object.getPrototypeOf(Function),c=typeof process=="object"&&process.env&&process.env.REFLECT_METADATA_USE_MAP_POLYFILL==="true",d=!c&&typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Ua(),p=!c&&typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Va(),y=!c&&typeof WeakMap=="function"?WeakMap:Wa(),m=new y;function g(w,b,k,C){if(ge(k)){if(!ji(w))throw new TypeError;if(!Ji(b))throw new TypeError;return K(w,b)}else{if(!ji(w))throw new TypeError;if(!Ie(b))throw new TypeError;if(!Ie(C)&&!ge(C)&&!wt(C))throw new TypeError;return wt(C)&&(C=void 0),k=ze(k),X(w,b,k,C)}}e("decorate",g);function I(w,b){function k(C,M){if(!Ie(C))throw new TypeError;if(!ge(M)&&!$a(M))throw new TypeError;de(w,b,C,M)}return k}e("metadata",I);function v(w,b,k,C){if(!Ie(k))throw new TypeError;return ge(C)||(C=ze(C)),de(w,b,k,C)}e("defineMetadata",v);function O(w,b,k){if(!Ie(b))throw new TypeError;return ge(k)||(k=ze(k)),A(w,b,k)}e("hasMetadata",O);function P(w,b,k){if(!Ie(b))throw new TypeError;return ge(k)||(k=ze(k)),F(w,b,k)}e("hasOwnMetadata",P);function W(w,b,k){if(!Ie(b))throw new TypeError;return ge(k)||(k=ze(k)),B(w,b,k)}e("getMetadata",W);function se(w,b,k){if(!Ie(b))throw new TypeError;return ge(k)||(k=ze(k)),x(w,b,k)}e("getOwnMetadata",se);function le(w,b){if(!Ie(w))throw new TypeError;return ge(b)||(b=ze(b)),Se(w,b)}e("getMetadataKeys",le);function pe(w,b){if(!Ie(w))throw new TypeError;return ge(b)||(b=ze(b)),Ye(w,b)}e("getOwnMetadataKeys",pe);function me(w,b,k){if(!Ie(b))throw new TypeError;ge(k)||(k=ze(k));var C=_(b,k,!1);if(ge(C)||!C.delete(w))return!1;if(C.size>0)return!0;var M=m.get(b);return M.delete(k),M.size>0||m.delete(b),!0}e("deleteMetadata",me);function K(w,b){for(var k=w.length-1;k>=0;--k){var C=w[k],M=C(b);if(!ge(M)&&!wt(M)){if(!Ji(M))throw new TypeError;b=M}}return b}function X(w,b,k,C){for(var M=w.length-1;M>=0;--M){var Ce=w[M],H=Ce(b,k,C);if(!ge(H)&&!wt(H)){if(!Ie(H))throw new TypeError;C=H}}return C}function _(w,b,k){var C=m.get(w);if(ge(C)){if(!k)return;C=new d,m.set(w,C)}var M=C.get(b);if(ge(M)){if(!k)return;M=new d,C.set(b,M)}return M}function A(w,b,k){var C=F(w,b,k);if(C)return!0;var M=qn(b);return wt(M)?!1:A(w,M,k)}function F(w,b,k){var C=_(b,k,!1);return ge(C)?!1:Ma(C.has(w))}function B(w,b,k){var C=F(w,b,k);if(C)return x(w,b,k);var M=qn(b);if(!wt(M))return B(w,M,k)}function x(w,b,k){var C=_(b,k,!1);if(!ge(C))return C.get(w)}function de(w,b,k,C){var M=_(k,C,!0);M.set(w,b)}function Se(w,b){var k=Ye(w,b),C=qn(w);if(C===null)return k;var M=Se(C,b);if(M.length<=0)return k;if(k.length<=0)return M;for(var Ce=new p,H=[],z=0,$=k;z<$.length;z++){var Z=$[z],Y=Ce.has(Z);Y||(Ce.add(Z),H.push(Z))}for(var xe=0,Vi=M;xe<Vi.length;xe++){var Z=Vi[xe],Y=Ce.has(Z);Y||(Ce.add(Z),H.push(Z))}return H}function Ye(w,b){var k=[],C=_(w,b,!1);if(ge(C))return k;for(var M=C.keys(),Ce=La(M),H=0;;){var z=ja(Ce);if(!z)return k.length=H,k;var $=qa(z);try{k[H]=$}catch(Z){try{Ja(Ce)}finally{throw Z}}H++}}function st(w){if(w===null)return 1;switch(typeof w){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return w===null?1:6;default:return 6}}function ge(w){return w===void 0}function wt(w){return w===null}function Da(w){return typeof w=="symbol"}function Ie(w){return typeof w=="object"?w!==null:typeof w=="function"}function Ra(w,b){switch(st(w)){case 0:return w;case 1:return w;case 2:return w;case 3:return w;case 4:return w;case 5:return w}var k="string",C=Ui(w,r);if(C!==void 0){var M=C.call(w,k);if(Ie(M))throw new TypeError;return M}return Ba(w)}function Ba(w,b){var k,C;{var M=w.toString;if(ln(M)){var C=M.call(w);if(!Ie(C))return C}var k=w.valueOf;if(ln(k)){var C=k.call(w);if(!Ie(C))return C}}throw new TypeError}function Ma(w){return!!w}function Na(w){return""+w}function ze(w){var b=Ra(w);return Da(b)?b:Na(b)}function ji(w){return Array.isArray?Array.isArray(w):w instanceof Object?w instanceof Array:Object.prototype.toString.call(w)==="[object Array]"}function ln(w){return typeof w=="function"}function Ji(w){return typeof w=="function"}function $a(w){switch(st(w)){case 3:return!0;case 4:return!0;default:return!1}}function Ui(w,b){var k=w[b];if(k!=null){if(!ln(k))throw new TypeError;return k}}function La(w){var b=Ui(w,s);if(!ln(b))throw new TypeError;var k=b.call(w);if(!Ie(k))throw new TypeError;return k}function qa(w){return w.value}function ja(w){var b=w.next();return b.done?!1:b}function Ja(w){var b=w.return;b&&b.call(w)}function qn(w){var b=Object.getPrototypeOf(w);if(typeof w!="function"||w===u||b!==u)return b;var k=w.prototype,C=k&&Object.getPrototypeOf(k);if(C==null||C===Object.prototype)return b;var M=C.constructor;return typeof M!="function"||M===w?b:M}function Ua(){var w={},b=[],k=function(){function H(z,$,Z){this._index=0,this._keys=z,this._values=$,this._selector=Z}return H.prototype["@@iterator"]=function(){return this},H.prototype[s]=function(){return this},H.prototype.next=function(){var z=this._index;if(z>=0&&z<this._keys.length){var $=this._selector(this._keys[z],this._values[z]);return z+1>=this._keys.length?(this._index=-1,this._keys=b,this._values=b):this._index++,{value:$,done:!1}}return{value:void 0,done:!0}},H.prototype.throw=function(z){throw this._index>=0&&(this._index=-1,this._keys=b,this._values=b),z},H.prototype.return=function(z){return this._index>=0&&(this._index=-1,this._keys=b,this._values=b),{value:z,done:!0}},H}();return function(){function H(){this._keys=[],this._values=[],this._cacheKey=w,this._cacheIndex=-2}return Object.defineProperty(H.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),H.prototype.has=function(z){return this._find(z,!1)>=0},H.prototype.get=function(z){var $=this._find(z,!1);return $>=0?this._values[$]:void 0},H.prototype.set=function(z,$){var Z=this._find(z,!0);return this._values[Z]=$,this},H.prototype.delete=function(z){var $=this._find(z,!1);if($>=0){for(var Z=this._keys.length,Y=$+1;Y<Z;Y++)this._keys[Y-1]=this._keys[Y],this._values[Y-1]=this._values[Y];return this._keys.length--,this._values.length--,z===this._cacheKey&&(this._cacheKey=w,this._cacheIndex=-2),!0}return!1},H.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=w,this._cacheIndex=-2},H.prototype.keys=function(){return new k(this._keys,this._values,C)},H.prototype.values=function(){return new k(this._keys,this._values,M)},H.prototype.entries=function(){return new k(this._keys,this._values,Ce)},H.prototype["@@iterator"]=function(){return this.entries()},H.prototype[s]=function(){return this.entries()},H.prototype._find=function(z,$){return this._cacheKey!==z&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=z)),this._cacheIndex<0&&$&&(this._cacheIndex=this._keys.length,this._keys.push(z),this._values.push(void 0)),this._cacheIndex},H}();function C(H,z){return H}function M(H,z){return z}function Ce(H,z){return[H,z]}}function Va(){return function(){function w(){this._map=new d}return Object.defineProperty(w.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),w.prototype.has=function(b){return this._map.has(b)},w.prototype.add=function(b){return this._map.set(b,b),this},w.prototype.delete=function(b){return this._map.delete(b)},w.prototype.clear=function(){this._map.clear()},w.prototype.keys=function(){return this._map.keys()},w.prototype.values=function(){return this._map.values()},w.prototype.entries=function(){return this._map.entries()},w.prototype["@@iterator"]=function(){return this.keys()},w.prototype[s]=function(){return this.keys()},w}()}function Wa(){var w=16,b=f.create(),k=C();return function(){function $(){this._key=C()}return $.prototype.has=function(Z){var Y=M(Z,!1);return Y!==void 0?f.has(Y,this._key):!1},$.prototype.get=function(Z){var Y=M(Z,!1);return Y!==void 0?f.get(Y,this._key):void 0},$.prototype.set=function(Z,Y){var xe=M(Z,!0);return xe[this._key]=Y,this},$.prototype.delete=function(Z){var Y=M(Z,!1);return Y!==void 0?delete Y[this._key]:!1},$.prototype.clear=function(){this._key=C()},$}();function C(){var $;do $="@@WeakMap@@"+z();while(f.has(b,$));return b[$]=!0,$}function M($,Z){if(!t.call($,k)){if(!Z)return;Object.defineProperty($,k,{value:f.create()})}return $[k]}function Ce($,Z){for(var Y=0;Y<Z;++Y)$[Y]=Math.random()*255|0;return $}function H($){return typeof Uint8Array=="function"?typeof crypto<"u"?crypto.getRandomValues(new Uint8Array($)):typeof msCrypto<"u"?msCrypto.getRandomValues(new Uint8Array($)):Ce(new Uint8Array($),$):Ce(new Array($),$)}function z(){var $=H(w);$[6]=$[6]&79|64,$[8]=$[8]&191|128;for(var Z="",Y=0;Y<w;++Y){var xe=$[Y];(Y===4||Y===6||Y===8)&&(Z+="-"),xe<16&&(Z+="0"),Z+=xe.toString(16).toLowerCase()}return Z}}function jn(w){return w.__=void 0,delete w.__,w}})})(wr||(wr={}));const Tn=class Tn{constructor(e,t,n){h(this,"actionUrl");h(this,"queue");h(this,"allowed");h(this,"doWork");this.actionUrl=e,this.queue=t,this.allowed=n}async run(e,t,n){t===void 0&&(t=Ae.apiClient.url),n||(n=Et(Ae.apiClient.httpClient));let r=await n.post(t+"/"+this.actionUrl,e),s=r;if(s&&s.queuedJobId){let a=E.actionInfo.startBusyWithProgress();try{let o;if(await E.actionInfo.runActionWithoutBlockingUI(async()=>{for(;!o||!o.done;)o&&await new Promise(l=>setTimeout(()=>{l(void 0)},200)),o=await n.post(t+"/"+Tn.apiUrlForJobStatus,{queuedJobId:r.queuedJobId}),o.progress&&a.progress(o.progress)}),o.error)throw o.error;return a.progress(1),o.result}finally{a.close()}}else return r}__register(e){e(this.actionUrl,this.queue,this.allowed,async(t,n,r)=>{try{var s=await this.execute(t,n,r);r.success(s)}catch(a){a.isForbiddenError?r.forbidden():r.error(a,void 0)}})}};h(Tn,"apiUrlForJobStatus","jobStatusInQueue");let Kt=Tn;class pi extends Error{constructor(t="Forbidden"){super(t);h(this,"isForbiddenError",!0)}}class Fl extends Kt{constructor(t,n,r,s){super(t,r.queue??!1,r.allowed);h(this,"types");h(this,"options");h(this,"originalMethod");this.types=n,this.options=r,this.originalMethod=s}async execute(t,n,r){let s={data:{}},a=n.dataProvider;return await qs(n,this.options,async()=>{if(!n.isAllowedForInstance(void 0,this.options.allowed))throw new pi;t.args=await Ls(this.types(),t.args,n,a,r);try{s.data=await this.originalMethod(t.args)}catch(o){throw o}}),s}}function Ge(i){return(e,t,n)=>{const r=typeof t=="string"?t:t.name.toString(),s=n?n.value:e;let a=s;Ns(e);function o(){var u=typeof Reflect.getMetadata=="function"?Reflect.getMetadata("design:paramtypes",e,r):[];return i.paramTypes&&(u=typeof i.paramTypes=="function"?i.paramTypes():i.paramTypes),u}if(e.prototype!==void 0){let u=new Fl((i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+r,()=>o(),i,c=>s.apply(void 0,c));return u.doWork=async(c,d,p,y)=>(c=vr(o(),c),i.blockUser===!1?await E.actionInfo.runActionWithoutBlockingUI(async()=>(await u.run({args:c},p,y)).data):(await u.run({args:c},p,y)).data),a=async function(...c){return Qt()?await s.apply(this,c):await u.doWork(c,void 0)},_r(e,a),a[ci]=u,n?(n.value=a,n):a}let l=E.classHelpers.get(e.constructor);l||(l=new jr,E.classHelpers.set(e.constructor,l));let f={__register(u){let c=new Le;for(const d of l.classes.keys()){let p=l.classes.get(d);p.key||(p.key=c.repo(d).metadata.key),u(p.key+"/"+(i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+r,i?i.queue??!1:!1,i.allowed,async(y,m,g)=>{y.args=y.args.map(v=>$s(v)?void 0:v);let I=i.allowed;try{let v=m,O;await qs(v,i,async()=>{if(y.args=await Ls(o(),y.args,v,v.dataProvider,g),E.allEntities.includes(d)){let P=v.repo(d),W;const se=y.rowInfo;if(se.isNewRow)W=P.create(),await P.getEntityRef(W)._updateEntityBasedOnApi(se.data);else{let pe=await P.find({where:{...P.metadata.idMetadata.getIdFilter(se.id),$and:[P.metadata.options.apiPrefilter??{}]}});if(pe.length!=1)throw new Error("not found or too many matches");W=pe[0],await P.getEntityRef(W)._updateEntityBasedOnApi(se.data)}if(!v.isAllowedForInstance(W,I))throw new pi;let le=ae(W);await le.__validateEntity();try{O={result:await s.apply(W,y.args),rowInfo:{data:await le.toApiJson(),isNewRow:le.isNew(),wasChanged:le.wasChanged(),id:le.getOriginalId()}}}catch(pe){throw le.catchSaveErrors(pe)}}else{let P=new d(v,v.dataProvider),W=ur(P,v);if(await W._updateEntityBasedOnApi(y.fields),!v.isAllowedForInstance(P,I))throw new pi;await W.__validateEntity();try{O={result:await s.apply(P,y.args),fields:await W.toApiJson()}}catch(se){throw W.catchSaveErrors(se)}}}),g.success(O)}catch(v){v.isForbiddenError?g.forbidden():g.error(v,void 0)}})}},doWork:async function(u,c,d,p){if(u=vr(o(),u),E.allEntities.includes(e.constructor)){let y=ae(c);await y.__validateEntity();let m=l.classes.get(c.constructor);m.key||(m.key=y.repository.metadata.key+"_methods");try{let g=await new class extends Kt{constructor(){super(...arguments);h(this,"execute")}}(m.key+"/"+(i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+r,(i==null?void 0:i.queue)??!1,i.allowed).run({args:u,rowInfo:{data:await y.toApiJson(),isNewRow:y.isNew(),wasChanged:y.wasChanged(),id:y.getOriginalId()}},d,p);return await y._updateEntityBasedOnApi(g.rowInfo.data,!0),g.result}catch(g){throw y.catchSaveErrors(g)}}else{let y=ur(c,void 0);try{await y.__validateEntity();let m=await new class extends Kt{constructor(){super(...arguments);h(this,"execute")}}(l.classes.get(c.constructor).key+"/"+(i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+r,(i==null?void 0:i.queue)??!1,i.allowed).run({args:u,fields:await y.toApiJson()},d,p);return await y._updateEntityBasedOnApi(m.fields),m.result}catch(m){throw y.catchSaveErrors(m)}}}};return a=async function(...u){let c=this;return Qt()?await s.apply(c,u):f.doWork(u,c)},_r(e.constructor,a),a[ci]=f,n?(n.value=a,n):a}}const Tl={_isUndefined:!0};function _r(i,e){(i[kr]||(i[kr]=[])).push(e),E.actionInfo.allActions.push(e)}function $s(i){return i&&i._isUndefined}class br{constructor(e){h(this,"res");this.res=e}progress(e){this.res.progress(e)}}function vr(i,e){if(i)for(let t=0;t<i.length;t++){const n=i[t];for(const r of[Le,Ft])(e[t]instanceof r||n==r)&&(e[t]=void 0);if(e[t]!=null){let r={valueType:n};if(r=Ti(r,new Le),Te(n,!1)!=null){let a=ae(e[t]);e[t]=a.getId()}r.valueConverter&&(e[t]=r.valueConverter.toJson(e[t]))}}return e.map(t=>t!==void 0?t:Tl)}async function Ls(i,e,t,n,r){for(let s=0;s<e.length;s++){const a=e[s];$s(a)&&(e[s]=void 0)}if(i)for(let s=0;s<i.length;s++)if(e.length<s&&e.push(void 0),i[s]==Le||i[s]==Le)e[s]=t;else if(i[s]==Ft&&n)e[s]=n;else if(i[s]==br)e[s]=new br(r);else{let a={valueType:i[s]};a=Ti(a,t),a.valueConverter&&(e[s]=a.valueConverter.fromJson(e[s])),Te(i[s],!1)!=null&&(e[s]===null||e[s]===void 0||(e[s]=await t.repo(i[s]).findId(e[s])))}return e}const kr=Symbol.for("classBackendMethodsArray");async function qs(i,e,t){if(e.transactional===void 0||e.transactional===!0)return await Vo(i,t);await t(i.dataProvider)}function js(i,e){return Ae.repo(i,e)}function Nn(i){return i}class Pl{constructor(e,t){h(this,"id");h(this,"caption");h(this,"icon");h(this,"where");h(this,"class");h(this,"hide");this.id=e.toString(),this.caption=(t==null?void 0:t.caption)??this.id,this.icon=t==null?void 0:t.icon,this.where=t==null?void 0:t.where,this.class=t==null?void 0:t.class,this.hide=t==null?void 0:t.hide,t!=null&&t.icon&&t.icon.caption===void 0&&(t.icon.caption=t==null?void 0:t.caption)}}var Dl=Object.defineProperty,Rl=Object.getOwnPropertyDescriptor,Ze=(i,e,t,n)=>{for(var r=n>1?void 0:n?Rl(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Dl(e,t,r),r};let Be=class{constructor(){h(this,"id","");h(this,"entity","");h(this,"entityId","");h(this,"changeDate",new Date);h(this,"userId","");h(this,"changes",[]);h(this,"newRow",!1);h(this,"deleted",!1)}};Ze([ee.cuid()],Be.prototype,"id",2);Ze([ee.string()],Be.prototype,"entity",2);Ze([ee.string()],Be.prototype,"entityId",2);Ze([ee.date()],Be.prototype,"changeDate",2);Ze([ee.string()],Be.prototype,"userId",2);Ze([ee.json({dbName:"changesJson"})],Be.prototype,"changes",2);Ze([ee.boolean()],Be.prototype,"newRow",2);Ze([ee.boolean()],Be.prototype,"deleted",2);Be=Ze([Zr("_ff_change_logs",{caption:"FF Change Logs",allowApiCrud:!1,defaultOrderBy:{changeDate:"desc"}})],Be);async function Bl(i,e,t){var n;if(Qt()){const r=[],s=new Js(i,t),a=(t==null?void 0:t.forceNew)||e.isNew,o=(t==null?void 0:t.forceDate)||new Date;for(const l of s.fields.filter(f=>f.valueChanged()||a&&f.value))try{const f=s.excludedValues.includes(l);r.push({key:l.metadata.key,newValue:f?"***":l.value instanceof Fn?l.value.id:l.metadata.options.valueConverter.toJson(l.value),oldValue:e.isNew?"---":f?"***":l.originalValue instanceof Fn?l.originalValue.id:l.metadata.options.valueConverter.toJson(l.originalValue)})}catch(f){throw console.error(l),f}r.length>0&&await js(Be).insert({changeDate:o,changes:r,entity:e.metadata.key,entityId:e.metadata.idMetadata.getId(i),userId:((n=Ae.user)==null?void 0:n.id)||"",newRow:a})}}async function Ml(i,e,t){var a;const n=[],r=new Js(i,t),s=(t==null?void 0:t.forceDate)||new Date;for(const o of r.fields)try{const l=r.excludedValues.includes(o);n.push({key:o.metadata.key,newValue:l?"***":"---",oldValue:l?"***":o.originalValue instanceof Fn?o.originalValue.id:o.metadata.options.valueConverter.toJson(o.originalValue)})}catch(l){throw console.error(o),l}await js(Be).insert({changeDate:s,changes:n,entity:e.metadata.key,entityId:e.metadata.idMetadata.getId(i),userId:((a=Ae.user)==null?void 0:a.id)||"",deleted:!0})}class Js{constructor(e,t){h(this,"fields");h(this,"excludedFields");h(this,"excludedValues");const n=ae(e);t!=null&&t.excludeColumns?this.excludedFields=t.excludeColumns(n.fields):this.excludedFields=[],t!=null&&t.excludeValues?this.excludedValues=t.excludeValues(n.fields):this.excludedValues=[],this.excludedFields.push(...n.fields.toArray().filter(r=>r.metadata.options.serverExpression)),this.excludedFields.push(...n.fields.toArray().filter(r=>r.metadata.options.sqlExpression)),this.fields=n.fields.toArray().filter(r=>!this.excludedFields.includes(r))}}const $t=i=>{if(i)return Array.isArray(i)?i.map(e=>e.id):i.id};function Bi(i,e){return Zr(i,{...e,allowApiCrud:e.allowApiCrud??$t(e.permissionApiCrud),allowApiDelete:e.allowApiDelete??$t(e.permissionApiDelete),allowApiInsert:e.allowApiInsert??$t(e.permissionApiInsert),allowApiRead:e.allowApiRead??$t(e.permissionApiRead),allowApiUpdate:e.allowApiUpdate??$t(e.permissionApiUpdate),saved:async(t,n)=>{var r;await((r=e==null?void 0:e.saved)==null?void 0:r.call(e,t,n)),e.changeLog===!1||Qt()&&await Bl(t,n,e.changeLog)},deleted:async(t,n)=>{var r;await((r=e==null?void 0:e.deleted)==null?void 0:r.call(e,t,n)),e.changeLog===!1||Qt()&&await Ml(t,n,e.changeLog)}})}const Mi={FF_Role_Admin:"FF_Role.Admin"};var Us=Object.defineProperty,Nl=Object.getOwnPropertyDescriptor,$l=(i,e,t)=>e in i?Us(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ce=(i,e,t,n)=>{for(var r=n>1?void 0:n?Nl(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Us(e,t,r),r},$n=(i,e,t)=>$l(i,typeof e!="symbol"?e+"":e,t);const Ln={FF_Role_Auth_Admin:"FF_Role_Auth.Admin",FF_Role_Auth_Invite:"FF_Role_Auth.Invite"};let qe=class{constructor(){h(this,"id");h(this,"createdAt");h(this,"updatedAt");h(this,"identifier");h(this,"roles",[]);h(this,"accounts");h(this,"sessions")}};ce([ee.cuid()],qe.prototype,"id",2);ce([ee.createdAt()],qe.prototype,"createdAt",2);ce([ee.updatedAt()],qe.prototype,"updatedAt",2);ce([ee.string({validate:[Re.unique(),Re.required(),i=>{var e;if(((e=i.identifier)==null?void 0:e.length)<2)throw"Must be at least 2 characters long"}]})],qe.prototype,"identifier",2);ce([ee.json(()=>[],{inputType:"selectEnum",valueConverter:{toDb:i=>i?i.join(","):[],fromDb:i=>i?i.split(",").map(e=>e.replace("{","").replace("}","")).filter(e=>e!==""):[]}})],qe.prototype,"roles",2);ce([Mn.toMany(()=>Pe,"userId")],qe.prototype,"accounts",2);ce([Mn.toMany(()=>pt,"userId")],qe.prototype,"sessions",2);qe=ce([Bi("ff_auth.users",{allowApiCrud:[Ln.FF_Role_Auth_Admin,Mi.FF_Role_Admin],caption:"FF Auth - Users"})],qe);let Pe=class{constructor(){h(this,"id");h(this,"createdAt");h(this,"updatedAt");h(this,"userId");h(this,"user");h(this,"provider",je.PASSWORD.id);h(this,"providerUserId","");h(this,"hashPassword");h(this,"token");h(this,"expiresAt");h(this,"lastVerifiedAt")}};ce([ee.cuid()],Pe.prototype,"id",2);ce([ee.createdAt()],Pe.prototype,"createdAt",2);ce([ee.updatedAt()],Pe.prototype,"updatedAt",2);ce([ee.string()],Pe.prototype,"userId",2);ce([Mn.toOne(()=>qe,"userId")],Pe.prototype,"user",2);ce([ee.string()],Pe.prototype,"provider",2);ce([ee.string()],Pe.prototype,"providerUserId",2);ce([ee.string({includeInApi:!1,allowNull:!0})],Pe.prototype,"hashPassword",2);ce([ee.string({includeInApi:!1,allowNull:!0})],Pe.prototype,"token",2);ce([ee.date({includeInApi:!1,allowNull:!0})],Pe.prototype,"expiresAt",2);ce([ee.date({includeInApi:!1,allowNull:!0})],Pe.prototype,"lastVerifiedAt",2);Pe=ce([Bi("ff_auth.accounts",{allowApiCrud:[Ln.FF_Role_Auth_Admin,Mi.FF_Role_Admin],caption:"FF Auth - Accounts",changeLog:{excludeColumns:i=>[i.hashPassword,i.token]}})],Pe);let pt=class{constructor(){h(this,"id");h(this,"expiresAt");h(this,"userId");h(this,"user")}};ce([ee.string()],pt.prototype,"id",2);ce([ee.date()],pt.prototype,"expiresAt",2);ce([ee.string()],pt.prototype,"userId",2);ce([Mn.toOne(()=>qe,"userId")],pt.prototype,"user",2);pt=ce([Bi("ff_auth.users_sessions",{allowApiCrud:[Ln.FF_Role_Auth_Admin,Mi.FF_Role_Admin],caption:"FF Auth - Users sessions",changeLog:!1})],pt);let je=class extends Pl{constructor(i,e){super(i,{...e})}};$n(je,"DEMO",new je("DEMO",{caption:"Demo"}));$n(je,"PASSWORD",new je("PASSWORD",{caption:"Password"}));$n(je,"OTP",new je("OTP",{caption:"TOTP"}));$n(je,"OAUTH",new je("OAUTH",{caption:"OAUTH"}));je=ce([il()],je);var Ll=Object.defineProperty,ql=Object.getOwnPropertyDescriptor,Qe=(i,e,t,n)=>{for(var r=ql(e,t),s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(e,t,r)||r);return r&&Ll(e,t,r),r},he,Xt,Zt,Yt,xt,en,tn,nn,rn,sn,an;const Ve=(he=class{static _setAbstraction(e){$e(this,Xt,e.signOut),$e(this,Zt,e.signInDemo),$e(this,Yt,e.invite),$e(this,xt,e.signUpPassword),$e(this,en,e.signInPassword),$e(this,tn,e.forgotPassword),$e(this,nn,e.resetPassword),$e(this,rn,e.signInOTP),$e(this,sn,e.verifyOtp),$e(this,an,e.signInOAuthGetUrl)}static async signOut(){var e;return await Me(e=he,Xt).call(e)}static async signInDemo(e){var t;return await Me(t=he,Zt).call(t,e)}static async invite(e){var t;return await Me(t=he,Yt).call(t,e)}static async signUpPassword(e,t){var n;return await Me(n=he,xt).call(n,e,t)}static async signInPassword(e,t){var n;return await Me(n=he,en).call(n,e,t)}static async forgotPassword(e){var t;return await Me(t=he,tn).call(t,e)}static async resetPassword(e,t){var n;return await Me(n=he,nn).call(n,e,t)}static async signInOTP(e){var t;return await Me(t=he,rn).call(t,e)}static async verifyOtp(e,t){var n;return await Me(n=he,sn).call(n,e,t)}static async signInOAuthGetUrl(e){var t;return await Me(t=he,an).call(t,e)}},Xt=new WeakMap,Zt=new WeakMap,Yt=new WeakMap,xt=new WeakMap,en=new WeakMap,tn=new WeakMap,nn=new WeakMap,rn=new WeakMap,sn=new WeakMap,an=new WeakMap,Ne(he,Xt),Ne(he,Zt),Ne(he,Yt),Ne(he,xt),Ne(he,en),Ne(he,tn),Ne(he,nn),Ne(he,rn),Ne(he,sn),Ne(he,an),he);Qe([Ge({allowed:!0})],Ve,"signOut");Qe([Ge({allowed:!0})],Ve,"signInDemo");Qe([Ge({allowed:Ln.FF_Role_Auth_Invite})],Ve,"invite");Qe([Ge({allowed:!0})],Ve,"signUpPassword");Qe([Ge({allowed:!0})],Ve,"signInPassword");Qe([Ge({allowed:!0})],Ve,"forgotPassword");Qe([Ge({allowed:!0})],Ve,"resetPassword");Qe([Ge({allowed:!0})],Ve,"signInOTP");Qe([Ge({allowed:!0})],Ve,"verifyOtp");Qe([Ge({allowed:!0})],Ve,"signInOAuthGetUrl");let nt=Ve;function Mt(i){i.focus()}const Lt="src/lib/modules/auth/components/ForgotPassword.svelte";function yi(i){var g;let e,t,n,r,s,a,o,l,f,u,c=((g=i[1].ui)==null?void 0:g.strings.send_password_reset_instructions)+"",d,p,y;const m={c:function(){var v;e=L("div"),t=L("p"),n=te(i[2]),r=te(i[3]),s=G(),a=L("form"),o=L("input"),f=G(),u=L("button"),d=te(c),V(t,"class","message"),He(t,"error",i[2]),q(t,Lt,28,2,541),V(o,"type","text"),V(o,"placeholder",l=(v=i[1].ui)==null?void 0:v.strings.email_placeholder),q(o,Lt,30,4,657),q(u,Lt,36,4,804),V(a,"class","svelte-wa5ykb"),q(a,Lt,29,2,612),V(e,"class","login"),q(e,Lt,27,0,519)},l:function(v){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(v,O){j(v,e,O),S(e,t),S(t,n),S(t,r),S(e,s),S(e,a),S(a,o),Ee(o,i[0]),S(a,f),S(a,u),S(u,d),p||(y=[Pn(Mt.call(null,o)),De(o,"input",i[5]),De(a,"submit",Dn(i[4]),!1,!0,!1,!1)],p=!0)},p:function(v,[O]){var P,W;O&4&&ke(n,v[2]),O&4&&He(t,"error",v[2]),O&2&&l!==(l=(P=v[1].ui)==null?void 0:P.strings.email_placeholder)&&V(o,"placeholder",l),O&1&&o.value!==v[0]&&Ee(o,v[0]),O&2&&c!==(c=((W=v[1].ui)==null?void 0:W.strings.send_password_reset_instructions)+"")&&ke(d,c)},i:oe,o:oe,d:function(v){v&&J(e),p=!1,Tt(y)}};return T("SvelteRegisterBlock",{block:m,id:yi.name,type:"component",source:"",ctx:i}),m}function jl(i,e,t){let{$$slots:n={},$$scope:r}=e;gt("ForgotPassword",n,[]);let{firstlyDataAuth:s}=e,{email:a=""}=e,o="",l="";async function f(){try{await nt.forgotPassword(a),window.location.href="/ff/auth/sign-in"}catch(d){d&&t(2,o=d.message??"")}}i.$$.on_mount.push(function(){s===void 0&&!("firstlyDataAuth"in e||i.$$.bound[i.$$.props.firstlyDataAuth])&&console.warn("<ForgotPassword> was created without expected prop 'firstlyDataAuth'")});const u=["firstlyDataAuth","email"];Object.keys(e).forEach(d=>{!~u.indexOf(d)&&d.slice(0,2)!=="$$"&&d!=="slot"&&console.warn(`<ForgotPassword> was created with unknown prop '${d}'`)});function c(){a=this.value,t(0,a)}return i.$$set=d=>{"firstlyDataAuth"in d&&t(1,s=d.firstlyDataAuth),"email"in d&&t(0,a=d.email)},i.$capture_state=()=>({isError:Nn,AuthController:nt,autofocus:Mt,firstlyDataAuth:s,email:a,msgError:o,msgSuccess:l,forgot:f}),i.$inject_state=d=>{"firstlyDataAuth"in d&&t(1,s=d.firstlyDataAuth),"email"in d&&t(0,a=d.email),"msgError"in d&&t(2,o=d.msgError),"msgSuccess"in d&&t(3,l=d.msgSuccess)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[a,s,o,l,f,c]}class Ni extends yt{constructor(e){super(e),mt(this,e,jl,yi,Pt,{firstlyDataAuth:1,email:0}),T("SvelteRegisterComponent",{component:this,tagName:"ForgotPassword",options:e,id:yi.name})}get firstlyDataAuth(){throw new Error("<ForgotPassword>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyDataAuth(e){throw new Error("<ForgotPassword>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get email(){throw new Error("<ForgotPassword>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set email(e){throw new Error("<ForgotPassword>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const kt="src/lib/modules/auth/components/ResetPassword.svelte";function mi(i){var le,pe,me;let e,t,n,r,s,a,o=((le=i[2].ui)==null?void 0:le.strings.password)+"",l,f,u,c,d=((pe=i[2].ui)==null?void 0:pe.strings.confirm)+"",p,y,m,g,I,v=((me=i[2].ui)==null?void 0:me.strings.reset)+"",O,P,W;const se={c:function(){e=L("div"),t=L("p"),n=te(i[3]),r=te(i[4]),s=G(),a=L("form"),l=te(o),f=G(),u=L("input"),c=G(),p=te(d),y=G(),m=L("input"),g=G(),I=L("button"),O=te(v),V(t,"class","message"),He(t,"error",i[3]),q(t,kt,29,2,634),V(u,"type","password"),q(u,kt,32,4,792),V(m,"type","password"),q(m,kt,34,4,887),q(I,kt,35,4,940),V(a,"class","svelte-wa5ykb"),q(a,kt,30,2,705),V(e,"class","login"),q(e,kt,28,0,612)},l:function(X){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(X,_){j(X,e,_),S(e,t),S(t,n),S(t,r),S(e,s),S(e,a),S(a,l),S(a,f),S(a,u),Ee(u,i[0]),S(a,c),S(a,p),S(a,y),S(a,m),Ee(m,i[1]),S(a,g),S(a,I),S(I,O),P||(W=[De(u,"input",i[6]),De(m,"input",i[7]),De(a,"submit",Dn(i[5]),!1,!0,!1,!1)],P=!0)},p:function(X,[_]){var A,F,B;_&8&&ke(n,X[3]),_&16&&ke(r,X[4]),_&8&&He(t,"error",X[3]),_&4&&o!==(o=((A=X[2].ui)==null?void 0:A.strings.password)+"")&&ke(l,o),_&1&&u.value!==X[0]&&Ee(u,X[0]),_&4&&d!==(d=((F=X[2].ui)==null?void 0:F.strings.confirm)+"")&&ke(p,d),_&2&&m.value!==X[1]&&Ee(m,X[1]),_&4&&v!==(v=((B=X[2].ui)==null?void 0:B.strings.reset)+"")&&ke(O,v)},i:oe,o:oe,d:function(X){X&&J(e),P=!1,Tt(W)}};return T("SvelteRegisterBlock",{block:se,id:mi.name,type:"component",source:"",ctx:i}),se}function Jl(i,e,t){let{$$slots:n={},$$scope:r}=e;gt("ResetPassword",n,[]);let{firstlyDataAuth:s}=e,{password1:a=""}=e,{password2:o=""}=e,l="",f="";async function u(){t(3,l=""),t(4,f="");const y=new URL(location.href).searchParams.get("token");try{await nt.resetPassword(y??"",a),window.location.href="/"}catch(m){m&&t(3,l=m.message??"")}}i.$$.on_mount.push(function(){s===void 0&&!("firstlyDataAuth"in e||i.$$.bound[i.$$.props.firstlyDataAuth])&&console.warn("<ResetPassword> was created without expected prop 'firstlyDataAuth'")});const c=["firstlyDataAuth","password1","password2"];Object.keys(e).forEach(y=>{!~c.indexOf(y)&&y.slice(0,2)!=="$$"&&y!=="slot"&&console.warn(`<ResetPassword> was created with unknown prop '${y}'`)});function d(){a=this.value,t(0,a)}function p(){o=this.value,t(1,o)}return i.$$set=y=>{"firstlyDataAuth"in y&&t(2,s=y.firstlyDataAuth),"password1"in y&&t(0,a=y.password1),"password2"in y&&t(1,o=y.password2)},i.$capture_state=()=>({isError:Nn,AuthController:nt,firstlyDataAuth:s,password1:a,password2:o,msgError:l,msgSuccess:f,reset:u}),i.$inject_state=y=>{"firstlyDataAuth"in y&&t(2,s=y.firstlyDataAuth),"password1"in y&&t(0,a=y.password1),"password2"in y&&t(1,o=y.password2),"msgError"in y&&t(3,l=y.msgError),"msgSuccess"in y&&t(4,f=y.msgSuccess)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[a,o,s,l,f,u,d,p]}class $i extends yt{constructor(e){super(e),mt(this,e,Jl,mi,Pt,{firstlyDataAuth:2,password1:0,password2:1}),T("SvelteRegisterComponent",{component:this,tagName:"ResetPassword",options:e,id:mi.name})}get firstlyDataAuth(){throw new Error("<ResetPassword>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyDataAuth(e){throw new Error("<ResetPassword>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get password1(){throw new Error("<ResetPassword>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set password1(e){throw new Error("<ResetPassword>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get password2(){throw new Error("<ResetPassword>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set password2(e){throw new Error("<ResetPassword>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const{Error:lt}=ki,at="src/lib/modules/auth/components/SignIn.svelte";function gi(i){var me,K,X;let e,t,n,r,s,a,o=((me=i[1].ui)==null?void 0:me.strings.email)+"",l,f,u,c,d,p,y=((K=i[1].ui)==null?void 0:K.strings.password)+"",m,g,I,v,O,P=((X=i[1].ui)==null?void 0:X.strings.btn_sign_in)+"",W,se,le;const pe={c:function(){var A;e=L("form"),t=L("p"),n=te(i[3]),r=te(i[4]),s=G(),a=L("label"),l=te(o),f=G(),u=L("input"),d=G(),p=L("label"),m=te(y),g=G(),I=L("input"),v=G(),O=L("button"),W=te(P),V(t,"class","message svelte-1rtdg09"),He(t,"error",i[3]),q(t,at,38,4,731),V(u,"type","text"),V(u,"placeholder",c=(A=i[1].ui)==null?void 0:A.strings.email_placeholder),q(u,at,41,6,860),q(a,at,39,4,804),V(I,"type","password"),q(I,at,50,6,1089),q(p,at,48,4,1030),q(O,at,52,4,1154),V(e,"class","svelte-1rtdg09"),q(e,at,37,2,686)},m:function(A,F){j(A,e,F),S(e,t),S(t,n),S(t,r),S(e,s),S(e,a),S(a,l),S(a,f),S(a,u),Ee(u,i[0]),S(e,d),S(e,p),S(p,m),S(p,g),S(p,I),Ee(I,i[5]),S(e,v),S(e,O),S(O,W),se||(le=[De(u,"input",i[7]),Pn(Mt.call(null,u)),De(I,"input",i[8]),De(e,"submit",Dn(i[6]),!1,!0,!1,!1)],se=!0)},p:function(A,F){var B,x,de,Se;F&8&&ke(n,A[3]),F&16&&ke(r,A[4]),F&8&&He(t,"error",A[3]),F&2&&o!==(o=((B=A[1].ui)==null?void 0:B.strings.email)+"")&&ke(l,o),F&2&&c!==(c=(x=A[1].ui)==null?void 0:x.strings.email_placeholder)&&V(u,"placeholder",c),F&1&&u.value!==A[0]&&Ee(u,A[0]),F&2&&y!==(y=((de=A[1].ui)==null?void 0:de.strings.password)+"")&&ke(m,y),F&32&&I.value!==A[5]&&Ee(I,A[5]),F&2&&P!==(P=((Se=A[1].ui)==null?void 0:Se.strings.btn_sign_in)+"")&&ke(W,P)},d:function(A){A&&J(e),se=!1,Tt(le)}};return T("SvelteRegisterBlock",{block:pe,id:gi.name,type:"if",source:"(27:0) {#if view == 'login'}",ctx:i}),pe}function wi(i){let e,t=i[2]=="login"&&gi(i);const n={c:function(){t&&t.c(),e=Ii()},l:function(s){throw new lt("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(s,a){t&&t.m(s,a),j(s,e,a)},p:function(s,[a]){s[2]=="login"?t?t.p(s,a):(t=gi(s),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:oe,o:oe,d:function(s){s&&J(e),t&&t.d(s)}};return T("SvelteRegisterBlock",{block:n,id:wi.name,type:"component",source:"",ctx:i}),n}function Ul(i,e,t){let{$$slots:n={},$$scope:r}=e;gt("SignIn",n,[]);let{firstlyDataAuth:s}=e,{view:a="login"}=e,{email:o=""}=e,l="",f="",u;async function c(){t(3,l=""),t(4,f="");try{await nt.signInPassword(o,u),window.location.href="/"}catch(g){g&&t(3,l=g.message??"")}}const d=()=>{throw new Error("Not impl yet")};i.$$.on_mount.push(function(){s===void 0&&!("firstlyDataAuth"in e||i.$$.bound[i.$$.props.firstlyDataAuth])&&console.warn("<SignIn> was created without expected prop 'firstlyDataAuth'")});const p=["firstlyDataAuth","view","email"];Object.keys(e).forEach(g=>{!~p.indexOf(g)&&g.slice(0,2)!=="$$"&&g!=="slot"&&console.warn(`<SignIn> was created with unknown prop '${g}'`)});function y(){o=this.value,t(0,o)}function m(){u=this.value,t(5,u)}return i.$$set=g=>{"firstlyDataAuth"in g&&t(1,s=g.firstlyDataAuth),"view"in g&&t(2,a=g.view),"email"in g&&t(0,o=g.email)},i.$capture_state=()=>({AuthController:nt,isError:Nn,autofocus:Mt,firstlyDataAuth:s,view:a,email:o,msgError:l,msgSuccess:f,password:u,signIn:c,handlePin:d}),i.$inject_state=g=>{"firstlyDataAuth"in g&&t(1,s=g.firstlyDataAuth),"view"in g&&t(2,a=g.view),"email"in g&&t(0,o=g.email),"msgError"in g&&t(3,l=g.msgError),"msgSuccess"in g&&t(4,f=g.msgSuccess),"password"in g&&t(5,u=g.password)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[o,s,a,l,f,u,c,y,m]}class Li extends yt{constructor(e){super(e),mt(this,e,Ul,wi,Pt,{firstlyDataAuth:1,view:2,email:0}),T("SvelteRegisterComponent",{component:this,tagName:"SignIn",options:e,id:wi.name})}get firstlyDataAuth(){throw new lt("<SignIn>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyDataAuth(e){throw new lt("<SignIn>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get view(){throw new lt("<SignIn>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set view(e){throw new lt("<SignIn>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get email(){throw new lt("<SignIn>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set email(e){throw new lt("<SignIn>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const{Error:ut}=ki,ot="src/lib/modules/auth/components/SignUp.svelte";function _i(i){var K,X,_;let e,t,n,r,s,a,o=((K=i[1].ui)==null?void 0:K.strings.email)+"",l,f,u,c,d,p,y=((X=i[1].ui)==null?void 0:X.strings.password)+"",m,g,I,v,O,P,W=((_=i[1].ui)==null?void 0:_.strings.btn_sign_up)+"",se,le,pe;const me={c:function(){var F,B;e=L("form"),t=L("p"),n=te(i[3]),r=te(i[4]),s=G(),a=L("label"),l=te(o),f=G(),u=L("input"),d=G(),p=L("label"),m=te(y),g=G(),I=L("input"),O=G(),P=L("button"),se=te(W),V(t,"class","message svelte-1rtdg09"),He(t,"error",i[3]),q(t,ot,38,4,731),V(u,"type","text"),V(u,"placeholder",c=(F=i[1].ui)==null?void 0:F.strings.email_placeholder),q(u,ot,41,6,860),q(a,ot,39,4,804),V(I,"type","password"),V(I,"placeholder",v=(B=i[1].ui)==null?void 0:B.strings.password_placeholder),q(I,ot,50,6,1089),q(p,ot,48,4,1030),q(P,ot,56,4,1247),V(e,"class","svelte-1rtdg09"),q(e,ot,37,2,686)},m:function(F,B){j(F,e,B),S(e,t),S(t,n),S(t,r),S(e,s),S(e,a),S(a,l),S(a,f),S(a,u),Ee(u,i[0]),S(e,d),S(e,p),S(p,m),S(p,g),S(p,I),Ee(I,i[5]),S(e,O),S(e,P),S(P,se),le||(pe=[De(u,"input",i[7]),Pn(Mt.call(null,u)),De(I,"input",i[8]),De(e,"submit",Dn(i[6]),!1,!0,!1,!1)],le=!0)},p:function(F,B){var x,de,Se,Ye,st;B&8&&ke(n,F[3]),B&16&&ke(r,F[4]),B&8&&He(t,"error",F[3]),B&2&&o!==(o=((x=F[1].ui)==null?void 0:x.strings.email)+"")&&ke(l,o),B&2&&c!==(c=(de=F[1].ui)==null?void 0:de.strings.email_placeholder)&&V(u,"placeholder",c),B&1&&u.value!==F[0]&&Ee(u,F[0]),B&2&&y!==(y=((Se=F[1].ui)==null?void 0:Se.strings.password)+"")&&ke(m,y),B&2&&v!==(v=(Ye=F[1].ui)==null?void 0:Ye.strings.password_placeholder)&&V(I,"placeholder",v),B&32&&I.value!==F[5]&&Ee(I,F[5]),B&2&&W!==(W=((st=F[1].ui)==null?void 0:st.strings.btn_sign_up)+"")&&ke(se,W)},d:function(F){F&&J(e),le=!1,Tt(pe)}};return T("SvelteRegisterBlock",{block:me,id:_i.name,type:"if",source:"(27:0) {#if view == 'login'}",ctx:i}),me}function bi(i){let e,t=i[2]=="login"&&_i(i);const n={c:function(){t&&t.c(),e=Ii()},l:function(s){throw new ut("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(s,a){t&&t.m(s,a),j(s,e,a)},p:function(s,[a]){s[2]=="login"?t?t.p(s,a):(t=_i(s),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:oe,o:oe,d:function(s){s&&J(e),t&&t.d(s)}};return T("SvelteRegisterBlock",{block:n,id:bi.name,type:"component",source:"",ctx:i}),n}function Vl(i,e,t){let{$$slots:n={},$$scope:r}=e;gt("SignUp",n,[]);let{firstlyDataAuth:s}=e,{view:a="login"}=e,{email:o=""}=e,l="",f="",u;async function c(){t(3,l=""),t(4,f="");try{await nt.signUpPassword(o,u),window.location.href="/"}catch(g){g&&t(3,l=g.message??"")}}const d=()=>{throw new Error("Not impl yet")};i.$$.on_mount.push(function(){s===void 0&&!("firstlyDataAuth"in e||i.$$.bound[i.$$.props.firstlyDataAuth])&&console.warn("<SignUp> was created without expected prop 'firstlyDataAuth'")});const p=["firstlyDataAuth","view","email"];Object.keys(e).forEach(g=>{!~p.indexOf(g)&&g.slice(0,2)!=="$$"&&g!=="slot"&&console.warn(`<SignUp> was created with unknown prop '${g}'`)});function y(){o=this.value,t(0,o)}function m(){u=this.value,t(5,u)}return i.$$set=g=>{"firstlyDataAuth"in g&&t(1,s=g.firstlyDataAuth),"view"in g&&t(2,a=g.view),"email"in g&&t(0,o=g.email)},i.$capture_state=()=>({AuthController:nt,isError:Nn,autofocus:Mt,firstlyDataAuth:s,view:a,email:o,msgError:l,msgSuccess:f,password:u,signIn:c,handlePin:d}),i.$inject_state=g=>{"firstlyDataAuth"in g&&t(1,s=g.firstlyDataAuth),"view"in g&&t(2,a=g.view),"email"in g&&t(0,o=g.email),"msgError"in g&&t(3,l=g.msgError),"msgSuccess"in g&&t(4,f=g.msgSuccess),"password"in g&&t(5,u=g.password)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[o,s,a,l,f,u,c,y,m]}class qi extends yt{constructor(e){super(e),mt(this,e,Vl,bi,Pt,{firstlyDataAuth:1,view:2,email:0}),T("SvelteRegisterComponent",{component:this,tagName:"SignUp",options:e,id:bi.name})}get firstlyDataAuth(){throw new ut("<SignUp>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyDataAuth(e){throw new ut("<SignUp>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get view(){throw new ut("<SignUp>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set view(e){throw new ut("<SignUp>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get email(){throw new ut("<SignUp>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set email(e){throw new ut("<SignUp>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const ye="src/lib/modules/auth/Page.svelte";function Vs(i){var y,m,g,I,v;let e,t,n,r,s,a,o,l=((y=i[2].ui)==null?void 0:y.strings.app_name)&&Hs(i),f=((m=i[2].ui)==null?void 0:m.paths.sign_up)&&Gs(i),u=((g=i[2].ui)==null?void 0:g.paths.sign_in)&&Xs(i),c=((I=i[2].ui)==null?void 0:I.paths.forgot_password)&&na(i),d=((v=i[2].ui)==null?void 0:v.paths.reset_password)&&aa(i);const p={c:function(){e=L("div"),t=L("div"),l&&l.c(),n=G(),f&&f.c(),r=G(),u&&u.c(),s=G(),c&&c.c(),a=G(),d&&d.c(),V(t,"class","form svelte-ckniid"),q(t,ye,110,8,3685),V(e,"class","centered-layout svelte-ckniid"),q(e,ye,109,6,3647)},m:function(P,W){j(P,e,W),S(e,t),l&&l.m(t,null),S(t,n),f&&f.m(t,null),S(t,r),u&&u.m(t,null),S(t,s),c&&c.m(t,null),S(t,a),d&&d.m(t,null),o=!0},p:function(P,W){var se,le,pe,me,K;(se=P[2].ui)!=null&&se.strings.app_name&&l.p(P,W),(le=P[2].ui)!=null&&le.paths.sign_up&&f.p(P,W),(pe=P[2].ui)!=null&&pe.paths.sign_in&&u.p(P,W),(me=P[2].ui)!=null&&me.paths.forgot_password&&c.p(P,W),(K=P[2].ui)!=null&&K.paths.reset_password&&d.p(P,W)},i:function(P){o||(D(f),D(u),D(c),D(d),o=!0)},o:function(P){R(f),R(u),R(c),R(d),o=!1},d:function(P){P&&J(e),l&&l.d(),f&&f.d(),u&&u.d(),c&&c.d(),d&&d.d()}};return T("SvelteRegisterBlock",{block:p,id:Vs.name,type:"else",source:"(100:4) {:else}",ctx:i}),p}function Ws(i){var v,O,P,W,se,le,pe;let e,t,n,r,s,a,o,l,f,u,c=((v=i[2].ui)==null?void 0:v.strings.app_name)&&fa(i),d=((O=i[2].ui)==null?void 0:O.paths.sign_up)&&ca(i),p=((P=i[2].ui)==null?void 0:P.paths.sign_in)&&ya(i),y=((W=i[2].ui)==null?void 0:W.paths.forgot_password)&&va(i),m=((se=i[2].ui)==null?void 0:se.paths.reset_password)&&Aa(i),g=((pe=(le=i[2].ui)==null?void 0:le.images)==null?void 0:pe.main)&&Fa(i);const I={c:function(){e=L("div"),t=L("div"),n=L("div"),c&&c.c(),r=G(),d&&d.c(),s=G(),p&&p.c(),a=G(),y&&y.c(),o=G(),m&&m.c(),l=G(),f=L("div"),g&&g.c(),V(n,"class","form svelte-ckniid"),q(n,ye,25,10,596),V(t,"class","form-side svelte-ckniid"),q(t,ye,24,8,562),V(f,"class","image-side svelte-ckniid"),q(f,ye,102,8,3433),V(e,"class","split-layout svelte-ckniid"),q(e,ye,23,6,527)},m:function(K,X){j(K,e,X),S(e,t),S(t,n),c&&c.m(n,null),S(n,r),d&&d.m(n,null),S(n,s),p&&p.m(n,null),S(n,a),y&&y.m(n,null),S(n,o),m&&m.m(n,null),S(e,l),S(e,f),g&&g.m(f,null),u=!0},p:function(K,X){var _,A,F,B,x,de,Se;(_=K[2].ui)!=null&&_.strings.app_name&&c.p(K,X),(A=K[2].ui)!=null&&A.paths.sign_up&&d.p(K,X),(F=K[2].ui)!=null&&F.paths.sign_in&&p.p(K,X),(B=K[2].ui)!=null&&B.paths.forgot_password&&y.p(K,X),(x=K[2].ui)!=null&&x.paths.reset_password&&m.p(K,X),(Se=(de=K[2].ui)==null?void 0:de.images)!=null&&Se.main&&g.p(K,X)},i:function(K){u||(D(d),D(p),D(y),D(m),u=!0)},o:function(K){R(d),R(p),R(y),R(m),u=!1},d:function(K){K&&J(e),c&&c.d(),d&&d.d(),p&&p.d(),y&&y.d(),m&&m.d(),g&&g.d()}};return T("SvelteRegisterBlock",{block:I,id:Ws.name,type:"if",source:"(14:4) {#if hasMainImage}",ctx:i}),I}function Hs(i){let e;const t={c:function(){e=L("h1"),e.textContent=`${i[2].ui.strings.app_name}`,V(e,"class","svelte-ckniid"),q(e,ye,112,12,3769)},m:function(r,s){j(r,e,s)},p:oe,d:function(r){r&&J(e)}};return T("SvelteRegisterBlock",{block:t,id:Hs.name,type:"if",source:"(103:10) {#if firstlyDataAuth.ui?.strings.app_name}",ctx:i}),t}function Gs(i){var r;let e,t;e=new Je({props:{path:(r=i[2].ui)==null?void 0:r.paths.sign_up,$$slots:{default:[Ks]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(a,o){ie(e,a,o),t=!0},p:function(a,o){const l={};o&1025&&(l.$$scope={dirty:o,ctx:a}),e.$set(l)},i:function(a){t||(D(e.$$.fragment,a),t=!0)},o:function(a){R(e.$$.fragment,a),t=!1},d:function(a){re(e,a)}};return T("SvelteRegisterBlock",{block:n,id:Gs.name,type:"if",source:"(107:10) {#if firstlyDataAuth.ui?.paths.sign_up}",ctx:i}),n}function Qs(i){let e,t;e=new Ue({props:{href:i[2].ui.paths.sign_in,$$slots:{default:[zs]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(s,a){ie(e,s,a),t=!0},p:function(s,a){const o={};a&1024&&(o.$$scope={dirty:a,ctx:s}),e.$set(o)},i:function(s){t||(D(e.$$.fragment,s),t=!0)},o:function(s){R(e.$$.fragment,s),t=!1},d:function(s){re(e,s)}};return T("SvelteRegisterBlock",{block:n,id:Qs.name,type:"if",source:"(112:16) {#if firstlyDataAuth.ui.paths.sign_in}",ctx:i}),n}function zs(i){let e=i[2].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=te(e)},m:function(s,a){j(s,t,a)},p:oe,d:function(s){s&&J(t)}};return T("SvelteRegisterBlock",{block:n,id:zs.name,type:"slot",source:"(113:18) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function Ks(i){let e,t,n,r,s;function a(u){i[7](u)}let o={firstlyDataAuth:i[2]};i[0]!==void 0&&(o.email=i[0]),e=new qi({props:o,$$inline:!0}),Dt.push(()=>Rt(e,"email",a));let l=i[2].ui.paths.sign_in&&Qs(i);const f={c:function(){ne(e.$$.fragment),n=G(),r=L("div"),l&&l.c(),V(r,"class","form-footer svelte-ckniid"),q(r,ye,119,14,4013)},m:function(c,d){ie(e,c,d),j(c,n,d),j(c,r,d),l&&l.m(r,null),s=!0},p:function(c,d){const p={};!t&&d&1&&(t=!0,p.email=c[0],Bt(()=>t=!1)),e.$set(p),c[2].ui.paths.sign_in&&l.p(c,d)},i:function(c){s||(D(e.$$.fragment,c),D(l),s=!0)},o:function(c){R(e.$$.fragment,c),R(l),s=!1},d:function(c){c&&(J(n),J(r)),re(e,c),l&&l.d()}};return T("SvelteRegisterBlock",{block:f,id:Ks.name,type:"slot",source:"(108:12) <Route path={firstlyDataAuth.ui?.paths.sign_up}>",ctx:i}),f}function Xs(i){var r;let e,t;e=new Je({props:{path:(r=i[2].ui)==null?void 0:r.paths.sign_in,$$slots:{default:[ta]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(a,o){ie(e,a,o),t=!0},p:function(a,o){const l={};o&1025&&(l.$$scope={dirty:o,ctx:a}),e.$set(l)},i:function(a){t||(D(e.$$.fragment,a),t=!0)},o:function(a){R(e.$$.fragment,a),t=!1},d:function(a){re(e,a)}};return T("SvelteRegisterBlock",{block:n,id:Xs.name,type:"if",source:"(121:10) {#if firstlyDataAuth.ui?.paths.sign_in}",ctx:i}),n}function Zs(i){let e,t;e=new Ue({props:{href:i[2].ui.paths.forgot_password,$$slots:{default:[Ys]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(s,a){ie(e,s,a),t=!0},p:function(s,a){const o={};a&1024&&(o.$$scope={dirty:a,ctx:s}),e.$set(o)},i:function(s){t||(D(e.$$.fragment,s),t=!0)},o:function(s){R(e.$$.fragment,s),t=!1},d:function(s){re(e,s)}};return T("SvelteRegisterBlock",{block:n,id:Zs.name,type:"if",source:"(126:16) {#if firstlyDataAuth.ui?.paths.forgot_password}",ctx:i}),n}function Ys(i){let e=i[2].ui.strings.forgot_password+"",t;const n={c:function(){t=te(e)},m:function(s,a){j(s,t,a)},p:oe,d:function(s){s&&J(t)}};return T("SvelteRegisterBlock",{block:n,id:Ys.name,type:"slot",source:"(127:18) <Link href={firstlyDataAuth.ui.paths.forgot_password}>",ctx:i}),n}function xs(i){let e,t,n,r;n=new Ue({props:{href:i[2].ui.paths.sign_up,$$slots:{default:[ea]},$$scope:{ctx:i}},$$inline:!0});const s={c:function(){e=L("hr"),t=G(),ne(n.$$.fragment),q(e,ye,140,18,4861)},m:function(o,l){j(o,e,l),j(o,t,l),ie(n,o,l),r=!0},p:function(o,l){const f={};l&1024&&(f.$$scope={dirty:l,ctx:o}),n.$set(f)},i:function(o){r||(D(n.$$.fragment,o),r=!0)},o:function(o){R(n.$$.fragment,o),r=!1},d:function(o){o&&(J(e),J(t)),re(n,o)}};return T("SvelteRegisterBlock",{block:s,id:xs.name,type:"if",source:"(131:16) {#if firstlyDataAuth.ui?.paths.sign_up}",ctx:i}),s}function ea(i){let e=i[2].ui.strings.btn_sign_up+"",t;const n={c:function(){t=te(e)},m:function(s,a){j(s,t,a)},p:oe,d:function(s){s&&J(t)}};return T("SvelteRegisterBlock",{block:n,id:ea.name,type:"slot",source:"(133:18) <Link href={firstlyDataAuth.ui.paths.sign_up}>",ctx:i}),n}function ta(i){var d,p;let e,t,n,r,s,a;function o(y){i[8](y)}let l={firstlyDataAuth:i[2]};i[0]!==void 0&&(l.email=i[0]),e=new Li({props:l,$$inline:!0}),Dt.push(()=>Rt(e,"email",o));let f=((d=i[2].ui)==null?void 0:d.paths.forgot_password)&&Zs(i),u=((p=i[2].ui)==null?void 0:p.paths.sign_up)&&xs(i);const c={c:function(){ne(e.$$.fragment),n=G(),r=L("div"),f&&f.c(),s=G(),u&&u.c(),V(r,"class","form-footer svelte-ckniid"),q(r,ye,133,14,4511)},m:function(m,g){ie(e,m,g),j(m,n,g),j(m,r,g),f&&f.m(r,null),S(r,s),u&&u.m(r,null),a=!0},p:function(m,g){var v,O;const I={};!t&&g&1&&(t=!0,I.email=m[0],Bt(()=>t=!1)),e.$set(I),(v=m[2].ui)!=null&&v.paths.forgot_password&&f.p(m,g),(O=m[2].ui)!=null&&O.paths.sign_up&&u.p(m,g)},i:function(m){a||(D(e.$$.fragment,m),D(f),D(u),a=!0)},o:function(m){R(e.$$.fragment,m),R(f),R(u),a=!1},d:function(m){m&&(J(n),J(r)),re(e,m),f&&f.d(),u&&u.d()}};return T("SvelteRegisterBlock",{block:c,id:ta.name,type:"slot",source:"(122:12) <Route path={firstlyDataAuth.ui?.paths.sign_in}>",ctx:i}),c}function na(i){var r;let e,t;e=new Je({props:{path:(r=i[2].ui)==null?void 0:r.paths.forgot_password,$$slots:{default:[sa]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(a,o){ie(e,a,o),t=!0},p:function(a,o){const l={};o&1025&&(l.$$scope={dirty:o,ctx:a}),e.$set(l)},i:function(a){t||(D(e.$$.fragment,a),t=!0)},o:function(a){R(e.$$.fragment,a),t=!1},d:function(a){re(e,a)}};return T("SvelteRegisterBlock",{block:n,id:na.name,type:"if",source:"(141:10) {#if firstlyDataAuth.ui?.paths.forgot_password}",ctx:i}),n}function ia(i){let e,t;e=new Ue({props:{href:i[2].ui.paths.sign_in,$$slots:{default:[ra]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(s,a){ie(e,s,a),t=!0},p:function(s,a){const o={};a&1024&&(o.$$scope={dirty:a,ctx:s}),e.$set(o)},i:function(s){t||(D(e.$$.fragment,s),t=!0)},o:function(s){R(e.$$.fragment,s),t=!1},d:function(s){re(e,s)}};return T("SvelteRegisterBlock",{block:n,id:ia.name,type:"if",source:"(146:16) {#if firstlyDataAuth.ui?.paths.sign_in}",ctx:i}),n}function ra(i){let e=i[2].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=te(e)},m:function(s,a){j(s,t,a)},p:oe,d:function(s){s&&J(t)}};return T("SvelteRegisterBlock",{block:n,id:ra.name,type:"slot",source:"(147:18) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function sa(i){var u;let e,t,n,r,s;function a(c){i[9](c)}let o={firstlyDataAuth:i[2]};i[0]!==void 0&&(o.email=i[0]),e=new Ni({props:o,$$inline:!0}),Dt.push(()=>Rt(e,"email",a));let l=((u=i[2].ui)==null?void 0:u.paths.sign_in)&&ia(i);const f={c:function(){ne(e.$$.fragment),n=G(),r=L("div"),l&&l.c(),V(r,"class","form-footer svelte-ckniid"),q(r,ye,153,14,5305)},m:function(d,p){ie(e,d,p),j(d,n,p),j(d,r,p),l&&l.m(r,null),s=!0},p:function(d,p){var m;const y={};!t&&p&1&&(t=!0,y.email=d[0],Bt(()=>t=!1)),e.$set(y),(m=d[2].ui)!=null&&m.paths.sign_in&&l.p(d,p)},i:function(d){s||(D(e.$$.fragment,d),D(l),s=!0)},o:function(d){R(e.$$.fragment,d),R(l),s=!1},d:function(d){d&&(J(n),J(r)),re(e,d),l&&l.d()}};return T("SvelteRegisterBlock",{block:f,id:sa.name,type:"slot",source:"(142:12) <Route path={firstlyDataAuth.ui?.paths.forgot_password}>",ctx:i}),f}function aa(i){var r;let e,t;e=new Je({props:{path:(r=i[2].ui)==null?void 0:r.paths.reset_password,$$slots:{default:[ua]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(a,o){ie(e,a,o),t=!0},p:function(a,o){const l={};o&1024&&(l.$$scope={dirty:o,ctx:a}),e.$set(l)},i:function(a){t||(D(e.$$.fragment,a),t=!0)},o:function(a){R(e.$$.fragment,a),t=!1},d:function(a){re(e,a)}};return T("SvelteRegisterBlock",{block:n,id:aa.name,type:"if",source:"(155:10) {#if firstlyDataAuth.ui?.paths.reset_password}",ctx:i}),n}function oa(i){let e,t;e=new Ue({props:{href:i[2].ui.paths.sign_in,$$slots:{default:[la]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(s,a){ie(e,s,a),t=!0},p:function(s,a){const o={};a&1024&&(o.$$scope={dirty:a,ctx:s}),e.$set(o)},i:function(s){t||(D(e.$$.fragment,s),t=!0)},o:function(s){R(e.$$.fragment,s),t=!1},d:function(s){re(e,s)}};return T("SvelteRegisterBlock",{block:n,id:oa.name,type:"if",source:"(160:16) {#if firstlyDataAuth.ui?.paths.sign_in}",ctx:i}),n}function la(i){let e=i[2].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=te(e)},m:function(s,a){j(s,t,a)},p:oe,d:function(s){s&&J(t)}};return T("SvelteRegisterBlock",{block:n,id:la.name,type:"slot",source:"(161:18) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function ua(i){var o;let e,t,n,r;e=new $i({props:{firstlyDataAuth:i[2]},$$inline:!0});let s=((o=i[2].ui)==null?void 0:o.paths.sign_in)&&oa(i);const a={c:function(){ne(e.$$.fragment),t=G(),n=L("div"),s&&s.c(),V(n,"class","form-footer svelte-ckniid"),q(n,ye,167,14,5814)},m:function(f,u){ie(e,f,u),j(f,t,u),j(f,n,u),s&&s.m(n,null),r=!0},p:function(f,u){var c;(c=f[2].ui)!=null&&c.paths.sign_in&&s.p(f,u)},i:function(f){r||(D(e.$$.fragment,f),D(s),r=!0)},o:function(f){R(e.$$.fragment,f),R(s),r=!1},d:function(f){f&&(J(t),J(n)),re(e,f),s&&s.d()}};return T("SvelteRegisterBlock",{block:a,id:ua.name,type:"slot",source:"(156:12) <Route path={firstlyDataAuth.ui?.paths.reset_password}>",ctx:i}),a}function fa(i){let e;const t={c:function(){e=L("h1"),e.textContent=`${i[2].ui.strings.app_name}`,V(e,"class","svelte-ckniid"),q(e,ye,27,14,684)},m:function(r,s){j(r,e,s)},p:oe,d:function(r){r&&J(e)}};return T("SvelteRegisterBlock",{block:t,id:fa.name,type:"if",source:"(18:12) {#if firstlyDataAuth.ui?.strings.app_name}",ctx:i}),t}function ca(i){var r;let e,t;e=new Je({props:{path:(r=i[2].ui)==null?void 0:r.paths.sign_up,$$slots:{default:[pa]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(a,o){ie(e,a,o),t=!0},p:function(a,o){const l={};o&1025&&(l.$$scope={dirty:o,ctx:a}),e.$set(l)},i:function(a){t||(D(e.$$.fragment,a),t=!0)},o:function(a){R(e.$$.fragment,a),t=!1},d:function(a){re(e,a)}};return T("SvelteRegisterBlock",{block:n,id:ca.name,type:"if",source:"(22:12) {#if firstlyDataAuth.ui?.paths.sign_up}",ctx:i}),n}function da(i){let e,t;e=new Ue({props:{href:i[2].ui.paths.sign_in,$$slots:{default:[ha]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(s,a){ie(e,s,a),t=!0},p:function(s,a){const o={};a&1024&&(o.$$scope={dirty:a,ctx:s}),e.$set(o)},i:function(s){t||(D(e.$$.fragment,s),t=!0)},o:function(s){R(e.$$.fragment,s),t=!1},d:function(s){re(e,s)}};return T("SvelteRegisterBlock",{block:n,id:da.name,type:"if",source:"(27:18) {#if firstlyDataAuth.ui.paths.sign_in}",ctx:i}),n}function ha(i){let e=i[2].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=te(e)},m:function(s,a){j(s,t,a)},p:oe,d:function(s){s&&J(t)}};return T("SvelteRegisterBlock",{block:n,id:ha.name,type:"slot",source:"(28:20) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function pa(i){let e,t,n,r,s;function a(u){i[4](u)}let o={firstlyDataAuth:i[2]};i[0]!==void 0&&(o.email=i[0]),e=new qi({props:o,$$inline:!0}),Dt.push(()=>Rt(e,"email",a));let l=i[2].ui.paths.sign_in&&da(i);const f={c:function(){ne(e.$$.fragment),n=G(),r=L("div"),l&&l.c(),V(r,"class","form-footer svelte-ckniid"),q(r,ye,34,16,938)},m:function(c,d){ie(e,c,d),j(c,n,d),j(c,r,d),l&&l.m(r,null),s=!0},p:function(c,d){const p={};!t&&d&1&&(t=!0,p.email=c[0],Bt(()=>t=!1)),e.$set(p),c[2].ui.paths.sign_in&&l.p(c,d)},i:function(c){s||(D(e.$$.fragment,c),D(l),s=!0)},o:function(c){R(e.$$.fragment,c),R(l),s=!1},d:function(c){c&&(J(n),J(r)),re(e,c),l&&l.d()}};return T("SvelteRegisterBlock",{block:f,id:pa.name,type:"slot",source:"(23:14) <Route path={firstlyDataAuth.ui?.paths.sign_up}>",ctx:i}),f}function ya(i){var r;let e,t;e=new Je({props:{path:(r=i[2].ui)==null?void 0:r.paths.sign_in,$$slots:{default:[ba]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(a,o){ie(e,a,o),t=!0},p:function(a,o){const l={};o&1025&&(l.$$scope={dirty:o,ctx:a}),e.$set(l)},i:function(a){t||(D(e.$$.fragment,a),t=!0)},o:function(a){R(e.$$.fragment,a),t=!1},d:function(a){re(e,a)}};return T("SvelteRegisterBlock",{block:n,id:ya.name,type:"if",source:"(36:12) {#if firstlyDataAuth.ui?.paths.sign_in}",ctx:i}),n}function ma(i){let e,t;e=new Ue({props:{href:i[2].ui.paths.forgot_password,$$slots:{default:[ga]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(s,a){ie(e,s,a),t=!0},p:function(s,a){const o={};a&1024&&(o.$$scope={dirty:a,ctx:s}),e.$set(o)},i:function(s){t||(D(e.$$.fragment,s),t=!0)},o:function(s){R(e.$$.fragment,s),t=!1},d:function(s){re(e,s)}};return T("SvelteRegisterBlock",{block:n,id:ma.name,type:"if",source:"(41:18) {#if firstlyDataAuth.ui?.paths.forgot_password}",ctx:i}),n}function ga(i){let e=i[2].ui.strings.forgot_password+"",t;const n={c:function(){t=te(e)},m:function(s,a){j(s,t,a)},p:oe,d:function(s){s&&J(t)}};return T("SvelteRegisterBlock",{block:n,id:ga.name,type:"slot",source:"(42:20) <Link href={firstlyDataAuth.ui.paths.forgot_password}>",ctx:i}),n}function wa(i){let e,t,n,r;n=new Ue({props:{href:i[2].ui.paths.sign_up,$$slots:{default:[_a]},$$scope:{ctx:i}},$$inline:!0});const s={c:function(){e=L("hr"),t=G(),ne(n.$$.fragment),q(e,ye,55,20,1824)},m:function(o,l){j(o,e,l),j(o,t,l),ie(n,o,l),r=!0},p:function(o,l){const f={};l&1024&&(f.$$scope={dirty:l,ctx:o}),n.$set(f)},i:function(o){r||(D(n.$$.fragment,o),r=!0)},o:function(o){R(n.$$.fragment,o),r=!1},d:function(o){o&&(J(e),J(t)),re(n,o)}};return T("SvelteRegisterBlock",{block:s,id:wa.name,type:"if",source:"(46:18) {#if firstlyDataAuth.ui?.paths.sign_up}",ctx:i}),s}function _a(i){let e=i[2].ui.strings.btn_sign_up+"",t;const n={c:function(){t=te(e)},m:function(s,a){j(s,t,a)},p:oe,d:function(s){s&&J(t)}};return T("SvelteRegisterBlock",{block:n,id:_a.name,type:"slot",source:"(48:20) <Link href={firstlyDataAuth.ui.paths.sign_up}>",ctx:i}),n}function ba(i){var d,p;let e,t,n,r,s,a;function o(y){i[5](y)}let l={firstlyDataAuth:i[2]};i[0]!==void 0&&(l.email=i[0]),e=new Li({props:l,$$inline:!0}),Dt.push(()=>Rt(e,"email",o));let f=((d=i[2].ui)==null?void 0:d.paths.forgot_password)&&ma(i),u=((p=i[2].ui)==null?void 0:p.paths.sign_up)&&wa(i);const c={c:function(){ne(e.$$.fragment),n=G(),r=L("div"),f&&f.c(),s=G(),u&&u.c(),V(r,"class","form-footer svelte-ckniid"),q(r,ye,48,16,1460)},m:function(m,g){ie(e,m,g),j(m,n,g),j(m,r,g),f&&f.m(r,null),S(r,s),u&&u.m(r,null),a=!0},p:function(m,g){var v,O;const I={};!t&&g&1&&(t=!0,I.email=m[0],Bt(()=>t=!1)),e.$set(I),(v=m[2].ui)!=null&&v.paths.forgot_password&&f.p(m,g),(O=m[2].ui)!=null&&O.paths.sign_up&&u.p(m,g)},i:function(m){a||(D(e.$$.fragment,m),D(f),D(u),a=!0)},o:function(m){R(e.$$.fragment,m),R(f),R(u),a=!1},d:function(m){m&&(J(n),J(r)),re(e,m),f&&f.d(),u&&u.d()}};return T("SvelteRegisterBlock",{block:c,id:ba.name,type:"slot",source:"(37:14) <Route path={firstlyDataAuth.ui?.paths.sign_in}>",ctx:i}),c}function va(i){var r;let e,t;e=new Je({props:{path:(r=i[2].ui)==null?void 0:r.paths.forgot_password,$$slots:{default:[Oa]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(a,o){ie(e,a,o),t=!0},p:function(a,o){const l={};o&1025&&(l.$$scope={dirty:o,ctx:a}),e.$set(l)},i:function(a){t||(D(e.$$.fragment,a),t=!0)},o:function(a){R(e.$$.fragment,a),t=!1},d:function(a){re(e,a)}};return T("SvelteRegisterBlock",{block:n,id:va.name,type:"if",source:"(56:12) {#if firstlyDataAuth.ui?.paths.forgot_password}",ctx:i}),n}function ka(i){let e,t;e=new Ue({props:{href:i[2].ui.paths.sign_in,$$slots:{default:[Ia]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(s,a){ie(e,s,a),t=!0},p:function(s,a){const o={};a&1024&&(o.$$scope={dirty:a,ctx:s}),e.$set(o)},i:function(s){t||(D(e.$$.fragment,s),t=!0)},o:function(s){R(e.$$.fragment,s),t=!1},d:function(s){re(e,s)}};return T("SvelteRegisterBlock",{block:n,id:ka.name,type:"if",source:"(61:18) {#if firstlyDataAuth.ui?.paths.sign_in}",ctx:i}),n}function Ia(i){let e=i[2].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=te(e)},m:function(s,a){j(s,t,a)},p:oe,d:function(s){s&&J(t)}};return T("SvelteRegisterBlock",{block:n,id:Ia.name,type:"slot",source:"(62:20) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function Oa(i){var u;let e,t,n,r,s;function a(c){i[6](c)}let o={firstlyDataAuth:i[2]};i[0]!==void 0&&(o.email=i[0]),e=new Ni({props:o,$$inline:!0}),Dt.push(()=>Rt(e,"email",a));let l=((u=i[2].ui)==null?void 0:u.paths.sign_in)&&ka(i);const f={c:function(){ne(e.$$.fragment),n=G(),r=L("div"),l&&l.c(),V(r,"class","form-footer svelte-ckniid"),q(r,ye,68,16,2290)},m:function(d,p){ie(e,d,p),j(d,n,p),j(d,r,p),l&&l.m(r,null),s=!0},p:function(d,p){var m;const y={};!t&&p&1&&(t=!0,y.email=d[0],Bt(()=>t=!1)),e.$set(y),(m=d[2].ui)!=null&&m.paths.sign_in&&l.p(d,p)},i:function(d){s||(D(e.$$.fragment,d),D(l),s=!0)},o:function(d){R(e.$$.fragment,d),R(l),s=!1},d:function(d){d&&(J(n),J(r)),re(e,d),l&&l.d()}};return T("SvelteRegisterBlock",{block:f,id:Oa.name,type:"slot",source:"(57:14) <Route path={firstlyDataAuth.ui?.paths.forgot_password}>",ctx:i}),f}function Aa(i){var r;let e,t;e=new Je({props:{path:(r=i[2].ui)==null?void 0:r.paths.reset_password,$$slots:{default:[Ea]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(a,o){ie(e,a,o),t=!0},p:function(a,o){const l={};o&1024&&(l.$$scope={dirty:o,ctx:a}),e.$set(l)},i:function(a){t||(D(e.$$.fragment,a),t=!0)},o:function(a){R(e.$$.fragment,a),t=!1},d:function(a){re(e,a)}};return T("SvelteRegisterBlock",{block:n,id:Aa.name,type:"if",source:"(70:12) {#if firstlyDataAuth.ui?.paths.reset_password}",ctx:i}),n}function Sa(i){let e,t;e=new Ue({props:{href:i[2].ui.paths.sign_in,$$slots:{default:[Ca]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){ne(e.$$.fragment)},m:function(s,a){ie(e,s,a),t=!0},p:function(s,a){const o={};a&1024&&(o.$$scope={dirty:a,ctx:s}),e.$set(o)},i:function(s){t||(D(e.$$.fragment,s),t=!0)},o:function(s){R(e.$$.fragment,s),t=!1},d:function(s){re(e,s)}};return T("SvelteRegisterBlock",{block:n,id:Sa.name,type:"if",source:"(75:18) {#if firstlyDataAuth.ui?.paths.sign_in}",ctx:i}),n}function Ca(i){let e=i[2].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=te(e)},m:function(s,a){j(s,t,a)},p:oe,d:function(s){s&&J(t)}};return T("SvelteRegisterBlock",{block:n,id:Ca.name,type:"slot",source:"(76:20) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function Ea(i){var o;let e,t,n,r;e=new $i({props:{firstlyDataAuth:i[2]},$$inline:!0});let s=((o=i[2].ui)==null?void 0:o.paths.sign_in)&&Sa(i);const a={c:function(){ne(e.$$.fragment),t=G(),n=L("div"),s&&s.c(),V(n,"class","form-footer svelte-ckniid"),q(n,ye,82,16,2823)},m:function(f,u){ie(e,f,u),j(f,t,u),j(f,n,u),s&&s.m(n,null),r=!0},p:function(f,u){var c;(c=f[2].ui)!=null&&c.paths.sign_in&&s.p(f,u)},i:function(f){r||(D(e.$$.fragment,f),D(s),r=!0)},o:function(f){R(e.$$.fragment,f),R(s),r=!1},d:function(f){f&&(J(t),J(n)),re(e,f),s&&s.d()}};return T("SvelteRegisterBlock",{block:a,id:Ea.name,type:"slot",source:"(71:14) <Route path={firstlyDataAuth.ui?.paths.reset_password}>",ctx:i}),a}function Fa(i){let e,t;const n={c:function(){e=L("img"),xa(e.src,t=i[2].ui.images.main)||V(e,"src",t),V(e,"alt","Authentication"),V(e,"class","svelte-ckniid"),q(e,ye,104,12,3519)},m:function(s,a){j(s,e,a)},p:oe,d:function(s){s&&J(e)}};return T("SvelteRegisterBlock",{block:n,id:Fa.name,type:"if",source:"(95:10) {#if firstlyDataAuth.ui?.images?.main}",ctx:i}),n}function Ta(i){let e,t,n,r,s;const a={c:function(){e=L("div"),t=L("small"),t.textContent="- 404 -",n=G(),r=L("div"),s=L("small"),s.textContent="Nothing to see here",q(t,ye,190,8,6452),V(e,"class","fallback svelte-ckniid"),q(e,ye,189,6,6421),q(s,ye,193,8,6525),V(r,"class","fallback svelte-ckniid"),q(r,ye,192,6,6494)},m:function(l,f){j(l,e,f),S(e,t),j(l,n,f),j(l,r,f),S(r,s)},p:oe,d:function(l){l&&(J(e),J(n),J(r))}};return T("SvelteRegisterBlock",{block:a,id:Ta.name,type:"slot",source:"(180:4) <Route fallback>",ctx:i}),a}function Pa(i){let e,t,n,r,s;const a=[Ws,Vs],o=[];function l(u,c){return u[1]?0:1}e=l(i),t=o[e]=a[e](i),r=new Je({props:{fallback:!0,$$slots:{default:[Ta]},$$scope:{ctx:i}},$$inline:!0});const f={c:function(){t.c(),n=G(),ne(r.$$.fragment)},m:function(c,d){o[e].m(c,d),j(c,n,d),ie(r,c,d),s=!0},p:function(c,d){let p=e;e=l(c),e===p?o[e].p(c,d):(Ar(),R(o[p],1,1,()=>{o[p]=null}),Sr(),t=o[e],t?t.p(c,d):(t=o[e]=a[e](c),t.c()),D(t,1),t.m(n.parentNode,n));const y={};d&1024&&(y.$$scope={dirty:d,ctx:c}),r.$set(y)},i:function(c){s||(D(t),D(r.$$.fragment,c),s=!0)},o:function(c){R(t),R(r.$$.fragment,c),s=!1},d:function(c){c&&J(n),o[e].d(c),re(r,c)}};return T("SvelteRegisterBlock",{block:f,id:Pa.name,type:"slot",source:"(13:2) <Route>",ctx:i}),f}function vi(i){let e,t,n;t=new Je({props:{$$slots:{default:[Pa]},$$scope:{ctx:i}},$$inline:!0});const r={c:function(){e=L("div"),ne(t.$$.fragment),V(e,"class","wrapper svelte-ckniid"),He(e,"with-image",i[1]),q(e,ye,20,0,434)},l:function(a){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(a,o){j(a,e,o),ie(t,e,null),n=!0},p:function(a,[o]){const l={};o&1027&&(l.$$scope={dirty:o,ctx:a}),t.$set(l),(!n||o&2)&&He(e,"with-image",a[1])},i:function(a){n||(D(t.$$.fragment,a),n=!0)},o:function(a){R(t.$$.fragment,a),n=!1},d:function(a){a&&J(e),re(t)}};return T("SvelteRegisterBlock",{block:r,id:vi.name,type:"component",source:"",ctx:i}),r}function Wl(i,e,t){var g,I;let n,{$$slots:r={},$$scope:s}=e;gt("Page",r,[]);let{firstlyData:a}=e,o=a.props,l="";i.$$.on_mount.push(function(){a===void 0&&!("firstlyData"in e||i.$$.bound[i.$$.props.firstlyData])&&console.warn("<Page> was created without expected prop 'firstlyData'")});const f=["firstlyData"];Object.keys(e).forEach(v=>{!~f.indexOf(v)&&v.slice(0,2)!=="$$"&&v!=="slot"&&console.warn(`<Page> was created with unknown prop '${v}'`)});function u(v){l=v,t(0,l)}function c(v){l=v,t(0,l)}function d(v){l=v,t(0,l)}function p(v){l=v,t(0,l)}function y(v){l=v,t(0,l)}function m(v){l=v,t(0,l)}return i.$$set=v=>{"firstlyData"in v&&t(3,a=v.firstlyData)},i.$capture_state=()=>({Link:Ue,Route:Je,ForgotPassword:Ni,ResetPassword:$i,SignIn:Li,SignUp:qi,firstlyData:a,firstlyDataAuth:o,email:l,hasMainImage:n}),i.$inject_state=v=>{"firstlyData"in v&&t(3,a=v.firstlyData),"firstlyDataAuth"in v&&t(2,o=v.firstlyDataAuth),"email"in v&&t(0,l=v.email),"hasMainImage"in v&&t(1,n=v.hasMainImage)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),t(1,n=!!((I=(g=o.ui)==null?void 0:g.images)!=null&&I.main)),[l,n,o,a,u,c,d,p,y,m]}class Xl extends yt{constructor(e){super(e),mt(this,e,Wl,vi,Pt,{firstlyData:3}),T("SvelteRegisterComponent",{component:this,tagName:"Page",options:e,id:vi.name})}get firstlyData(){throw new Error("<Page>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyData(e){throw new Error("<Page>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}export{Xl as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
form.svelte-wa5ykb,form.svelte-1rtdg09{display:flex;flex-direction:column}form.svelte-1rtdg09{display:flex;flex-direction:column}.message.svelte-1rtdg09:empty{display:none}.message.svelte-1rtdg09{background:var(--pico-muted-border-color);padding:var(--pico-form-element-spacing-vertical) var(--pico-form-element-spacing-horizontal);border-radius:var(--pico-border-radius);margin-bottom:calc(var(--pico-typography-spacing-vertical) * 2)}.message.error.svelte-1rtdg09{background:var(--pico-del-color);color:#4c1513}h1.svelte-ckniid.svelte-ckniid{text-align:center;margin-bottom:2rem}.wrapper.svelte-ckniid.svelte-ckniid{min-height:100vh;display:flex;justify-content:center;align-items:center;margin:0 auto}.centered-layout.svelte-ckniid.svelte-ckniid{display:flex;justify-content:center;align-items:center;width:100%}.split-layout.svelte-ckniid.svelte-ckniid{display:flex;width:100%;min-height:100vh}.form-side.svelte-ckniid.svelte-ckniid{width:50%;display:flex;justify-content:center;align-items:center}.image-side.svelte-ckniid.svelte-ckniid{width:50%;height:100vh;overflow:hidden}.image-side.svelte-ckniid img.svelte-ckniid{width:100%;height:100%;object-fit:cover}.form.svelte-ckniid.svelte-ckniid{max-width:360px;width:100%;padding:1rem;display:flex;flex-direction:column}.form-footer.svelte-ckniid.svelte-ckniid{margin-top:1rem;display:flex;flex-direction:column;justify-content:center;align-items:center}.fallback.svelte-ckniid.svelte-ckniid{display:flex;justify-content:center;align-items:center}@media (max-width: 768px){.split-layout.svelte-ckniid.svelte-ckniid{flex-direction:column}.form-side.svelte-ckniid.svelte-ckniid{width:100%;order:2}.image-side.svelte-ckniid.svelte-ckniid{width:100%;height:50vh;order:1}.form.svelte-ckniid.svelte-ckniid{max-width:100%}}
|