firstly 0.0.11 → 0.0.13

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.
Files changed (139) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/esm/BaseEnum.d.ts +2 -0
  3. package/esm/BaseEnum.js +2 -0
  4. package/esm/FF_Fields.js +0 -1
  5. package/esm/ROUTES.d.ts +2 -2
  6. package/esm/ROUTES.js +10 -5
  7. package/esm/SqlDatabase/FF_LogToConsole.d.ts +1 -0
  8. package/esm/SqlDatabase/FF_LogToConsole.js +22 -16
  9. package/esm/api/index.d.ts +20 -21
  10. package/esm/api/index.js +74 -62
  11. package/esm/auth/{client/Auth.d.ts → AuthController.d.ts} +18 -25
  12. package/esm/auth/{client/Auth.js → AuthController.js} +48 -44
  13. package/esm/auth/{client/Entities.d.ts → Entities.d.ts} +4 -3
  14. package/esm/auth/{client/Entities.js → Entities.js} +7 -7
  15. package/esm/auth/README.md +0 -10
  16. package/esm/auth/index.d.ts +5 -149
  17. package/esm/auth/index.js +5 -316
  18. package/esm/auth/{AuthController.server.d.ts → server/AuthController.server.d.ts} +10 -10
  19. package/esm/auth/{AuthController.server.js → server/AuthController.server.js} +133 -171
  20. package/esm/auth/server/handleAuth.d.ts +2 -0
  21. package/esm/auth/server/handleAuth.js +140 -0
  22. package/esm/auth/server/handleGuard.d.ts +16 -0
  23. package/esm/auth/server/handleGuard.js +67 -0
  24. package/esm/auth/server/helperDb.d.ts +10 -0
  25. package/esm/auth/server/helperDb.js +56 -0
  26. package/esm/auth/server/helperFirstly.d.ts +1 -0
  27. package/esm/auth/server/helperFirstly.js +8 -0
  28. package/esm/auth/server/helperOslo.d.ts +7 -0
  29. package/esm/auth/server/helperOslo.js +24 -0
  30. package/esm/auth/server/helperRemultServer.d.ts +5 -0
  31. package/esm/auth/server/helperRemultServer.js +44 -0
  32. package/esm/auth/{RoleHelpers.d.ts → server/helperRole.d.ts} +1 -1
  33. package/esm/auth/{RoleHelpers.js → server/helperRole.js} +1 -1
  34. package/esm/auth/server/index.d.ts +7 -0
  35. package/esm/auth/server/index.js +7 -0
  36. package/esm/auth/server/module.d.ts +257 -0
  37. package/esm/auth/server/module.js +197 -0
  38. package/esm/auth/{providers → server/providers}/github.d.ts +6 -4
  39. package/esm/auth/{providers → server/providers}/github.js +29 -20
  40. package/esm/auth/{providers/index.d.ts → server/providers/helperProvider.d.ts} +0 -2
  41. package/esm/auth/{providers/index.js → server/providers/helperProvider.js} +5 -6
  42. package/esm/auth/static/assets/Page-BUfjaN-D.d.ts +5 -0
  43. package/esm/auth/static/assets/Page-BUfjaN-D.js +19 -0
  44. package/esm/auth/static/assets/Page-CJ58H1vl.css +1 -0
  45. package/esm/auth/static/assets/Page-CaDAqmBS.d.ts +5 -0
  46. package/esm/auth/static/assets/Page-CaDAqmBS.js +1 -0
  47. package/esm/auth/static/assets/Page-DhdZddzJ.d.ts +5 -0
  48. package/esm/auth/static/assets/Page-DhdZddzJ.js +1 -0
  49. package/esm/auth/static/assets/index-BDy4A_14.css +4 -0
  50. package/esm/auth/static/assets/index-D-Ztdt2o.d.ts +54 -0
  51. package/esm/auth/static/assets/index-D-Ztdt2o.js +2 -0
  52. package/esm/auth/static/index.html +11 -11
  53. package/esm/auth/types.d.ts +5 -0
  54. package/esm/bin/cmd.js +122 -54
  55. package/esm/cellsBuildor.js +7 -7
  56. package/esm/changeLog/index.d.ts +0 -36
  57. package/esm/changeLog/index.js +3 -43
  58. package/esm/changeLog/server/index.d.ts +36 -0
  59. package/esm/changeLog/server/index.js +42 -0
  60. package/esm/common.d.ts +5 -0
  61. package/esm/common.js +8 -0
  62. package/esm/cron/{index.d.ts → server/index.d.ts} +1 -1
  63. package/esm/cron/server/index.js +103 -0
  64. package/esm/feedback/FeedbackController.js +4 -5
  65. package/esm/feedback/index.d.ts +0 -16
  66. package/esm/feedback/index.js +0 -11
  67. package/esm/feedback/server/index.d.ts +17 -0
  68. package/esm/feedback/server/index.js +13 -0
  69. package/esm/feedback/ui/DialogIssue.svelte +52 -56
  70. package/esm/feedback/ui/DialogIssues.svelte +71 -71
  71. package/esm/feedback/ui/DialogMilestones.svelte +22 -22
  72. package/esm/helper.js +3 -3
  73. package/esm/index.d.ts +3 -20
  74. package/esm/index.js +3 -10
  75. package/esm/mail/index.d.ts +2 -30
  76. package/esm/mail/index.js +2 -79
  77. package/esm/mail/server/index.d.ts +31 -0
  78. package/esm/mail/server/index.js +88 -0
  79. package/esm/mail/templates/DefaultMail.svelte +17 -17
  80. package/esm/storeItem.js +8 -2
  81. package/esm/storeList.d.ts +1 -1
  82. package/esm/storeList.js +1 -1
  83. package/esm/sveltekit/server/index.d.ts +14 -0
  84. package/esm/sveltekit/server/index.js +24 -0
  85. package/esm/ui/Button.svelte +33 -33
  86. package/esm/ui/Button.svelte.d.ts +2 -2
  87. package/esm/ui/Clipboardable.svelte +11 -8
  88. package/esm/ui/Clipboardable.svelte.d.ts +4 -4
  89. package/esm/ui/Field.svelte +142 -149
  90. package/esm/ui/Field.svelte.d.ts +2 -2
  91. package/esm/ui/FieldGroup.svelte +38 -38
  92. package/esm/ui/Grid.svelte +212 -222
  93. package/esm/ui/GridLoading.svelte +18 -22
  94. package/esm/ui/GridPaginate.svelte +38 -38
  95. package/esm/ui/Icon.svelte +50 -49
  96. package/esm/ui/Icon.svelte.d.ts +18 -18
  97. package/esm/ui/Loading.svelte +5 -2
  98. package/esm/ui/Tooltip.svelte +16 -16
  99. package/esm/ui/dialog/DialogForm.svelte +23 -23
  100. package/esm/ui/dialog/DialogManagement.svelte +74 -74
  101. package/esm/ui/dialog/DialogPrimitive.svelte +50 -51
  102. package/esm/ui/dialog/FormEditAction.svelte +34 -34
  103. package/esm/ui/dialog/dialog.d.ts +2 -2
  104. package/esm/ui/dialog/dialog.js +1 -1
  105. package/esm/ui/internals/FieldContainer.svelte +11 -12
  106. package/esm/ui/internals/FieldContainer.svelte.d.ts +3 -3
  107. package/esm/ui/internals/Input.svelte +25 -25
  108. package/esm/ui/internals/Input.svelte.d.ts +1 -1
  109. package/esm/ui/internals/Textarea.svelte +21 -21
  110. package/esm/ui/internals/Textarea.svelte.d.ts +2 -2
  111. package/esm/ui/internals/select/MultiSelectMelt.svelte +69 -73
  112. package/esm/ui/internals/select/SelectMelt.svelte +86 -86
  113. package/esm/ui/internals/select/SelectRadio.svelte +22 -22
  114. package/esm/ui/link/Link.svelte +14 -14
  115. package/esm/ui/link/Link.svelte.d.ts +3 -4
  116. package/esm/ui/link/LinkPlus.svelte +33 -35
  117. package/esm/vite/index.js +24 -25
  118. package/package.json +50 -42
  119. package/esm/auth/Adapter.d.ts +0 -10
  120. package/esm/auth/Adapter.js +0 -50
  121. package/esm/auth/client/index.d.ts +0 -7
  122. package/esm/auth/client/index.js +0 -7
  123. package/esm/auth/helper.d.ts +0 -6
  124. package/esm/auth/helper.js +0 -14
  125. package/esm/auth/providers/strava.d.ts +0 -30
  126. package/esm/auth/providers/strava.js +0 -60
  127. package/esm/auth/static/assets/Page-BEFYPjis.d.ts +0 -4
  128. package/esm/auth/static/assets/Page-BEFYPjis.js +0 -1
  129. package/esm/auth/static/assets/Page-BGTO8LC5.css +0 -1
  130. package/esm/auth/static/assets/Page-Cfysx_UV.d.ts +0 -6
  131. package/esm/auth/static/assets/Page-Cfysx_UV.js +0 -18
  132. package/esm/auth/static/assets/Page-DtgkOCJs.d.ts +0 -4
  133. package/esm/auth/static/assets/Page-DtgkOCJs.js +0 -1
  134. package/esm/auth/static/assets/index-CR_3yNaJ.css +0 -4
  135. package/esm/auth/static/assets/index-QypqCYwC.d.ts +0 -63
  136. package/esm/auth/static/assets/index-QypqCYwC.js +0 -2
  137. package/esm/cron/index.js +0 -102
  138. package/esm/handle/index.d.ts +0 -7
  139. package/esm/handle/index.js +0 -40
@@ -1,18 +0,0 @@
1
- var Ps=Object.defineProperty;var Fs=(i,e,t)=>e in i?Ps(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var d=(i,e,t)=>Fs(i,typeof e!="symbol"?e+"":e,t);import{n as le,s as Ds,r as dt,a as ht,i as Rs,g as Ms,S as Ye,b as et,c as qi,d as J,e as Jn,v as lt,f as ut,h as tt,j as si,k as ln,o as oi,l as un,m as Ns,p as ji,q as Un,t as G,u as $,w as Ls,x as z,y as Bs,z as X,A as Ji,B as Ui,C as Wi,D as gn,E as ai,F as qs,G as q,H as li,I as j,J as en,K as Ce,L as js,M as ie,N as x,O as Q,P as Ue,Q as C,R as ke,T as tn,U as de,V as me,W as we,X as ge,Y as Wn,Z as Vn,_ as Hn}from"./index-QypqCYwC.js";function Js(i,e){const t={},n={},r={$$scope:1};let s=i.length;for(;s--;){const o=i[s],a=e[s];if(a){for(const l in o)l in a||(n[l]=1);for(const l in a)r[l]||(t[l]=a[l],r[l]=1);i[s]=a}else for(const l in o)r[l]=1}for(const o in n)o in t||(t[o]=void 0);return t}const rt=[];function Qn(i,e){return{subscribe:St(i,e).subscribe}}function St(i,e=le){let t;const n=new Set;function r(a){if(ht(i,a)&&(i=a,t)){const l=!rt.length;for(const f of n)f[1](),rt.push(f,i);if(l){for(let f=0;f<rt.length;f+=2)rt[f][0](rt[f+1]);rt.length=0}}}function s(a){r(a(i))}function o(a,l=le){const f=[a,l];return n.add(f),n.size===1&&(t=e(r,s)||le),a(i),()=>{n.delete(f),n.size===0&&t&&(t(),t=null)}}return{set:r,update:s,subscribe:o}}function nn(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 Qn(t,(o,a)=>{let l=!1;const f=[];let u=0,c=le;const h=()=>{if(u)return;c();const y=e(n?f[0]:f,o,a);s?o(y):c=Rs(y)?y:le},p=r.map((y,_)=>Ds(y,w=>{f[_]=w,u&=~(1<<_),l&&h()},()=>{u|=1<<_}));return l=!0,h(),function(){dt(p),c(),l=!1}})}const Us=i=>{const{subscribe:e,update:t}=St(i);return{subscribe:e,set:(n={})=>{t(r=>Object.assign(r,n))}}},Je=Us({mode:"window",basePath:null}),fn=(i=Ms(Je).mode)=>{let e="popstate";i==="window"&&(e="popstate"),i==="hash"&&(e="hashchange"),window.dispatchEvent(new Event(e))},ui={go:(i=0)=>{history.go(i),fn()},push:(i,e=null)=>{history.pushState(e,"",i),fn()},replace:(i,e=null)=>{history.replaceState(e,"",i),fn()}},Ws=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]}`:""}},fi=()=>{const{pathname:i,search:e,hash:t}=document.location;return{path:i,query:e,hash:t}},ci=()=>{let i=document.location.hash.substring(1);return i[0]!=="/"&&(i="/"+i),Ws(i)},Vs=Qn(fi(),i=>{const e=()=>i(fi());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),Hs=Qn(ci(),i=>{const e=()=>i(ci());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}),$n=nn([Je,Vs,Hs],([i,e,t],n)=>{i.mode==="window"&&n(e),i.mode==="hash"&&n(t)}),cn=nn($n,i=>i.path);nn($n,i=>i.query);nn($n,i=>i.hash);const kt=i=>i.split(/(?=\/)/),Vi=()=>{let i=0;return()=>i++},bn=(i,e)=>e===null?i:i.startsWith(e)?i.slice(e.length):i,{Error:vt}=Jn;function vn(i){let e;const t=i[11].default,n=ji(t,i,i[10],null),r={c:function(){n&&n.c()},m:function(o,a){n&&n.m(o,a),e=!0},p:function(o,a){n&&n.p&&(!e||a&1024)&&Ji(n,t,o,o[10],e?Wi(t,o[10],a,null):Ui(o[10]),null)},i:function(o){e||($(n,o),e=!0)},o:function(o){z(n,o),e=!1},d:function(o){n&&n.d(o)}};return J("SvelteRegisterBlock",{block:r,id:vn.name,type:"if",source:"(98:0) {#if isRouteActive(getPathWithoutBase($globalPath, $options.basePath), $route, $contextChildRoutes)}",ctx:i}),r}function _n(i){let e=kn(bn(i[1],i[2].basePath),i[0],i[3]),t,n,r=e&&vn(i);const s={c:function(){r&&r.c(),t=Un()},l:function(a){throw new vt("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(a,l){r&&r.m(a,l),G(a,t,l),n=!0},p:function(a,[l]){l&15&&(e=kn(bn(a[1],a[2].basePath),a[0],a[3])),e?r?(r.p(a,l),l&15&&$(r,1)):(r=vn(a),r.c(),$(r,1),r.m(t.parentNode,t)):r&&(Ls(),z(r,1,1,()=>{r=null}),Bs())},i:function(a){n||($(r),n=!0)},o:function(a){z(r),n=!1},d:function(a){a&&X(t),r&&r.d(a)}};return J("SvelteRegisterBlock",{block:s,id:_n.name,type:"component",source:"",ctx:i}),s}const di=(i,e,t,n,r)=>{const s=(f,u,c)=>{const h=kt(u).filter(p=>p!=="/").length;return(c??0)+(f?1:h)},o=(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)},a=s(t,n,r==null?void 0:r.depth),l={id:i,root:e,fallback:t,path:n,depth:a};return o(l,r),l},hi=()=>{const{subscribe:i,update:e}=St([]);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))}},kn=(i,e,t)=>{const n=(f,u,c,h)=>{let p=kt(f).filter(w=>w!=="/"),y=kt(c).filter(w=>w!=="/"),_="";if(c==="/")return u||p.length===h;for(let w=h-y.length;w<h;w++)_=_+p[w];return c===_},r=(f,u,c)=>{var y,_,w,v;let h=kt(f).filter(I=>I!=="/"),p=!1;for(let I=0;I<(c==null?void 0:c.length)&&!p;I++)(y=c[I])!=null&&y.fallback||(p=n(f,((_=c[I])==null?void 0:_.root)??!1,((w=c[I])==null?void 0:w.path)??"",((v=c[I])==null?void 0:v.depth)??0));return h.length>=u&&!p},{root:s,fallback:o,path:a,depth:l}=e;return o?r(i,l,t):n(i,s,a,l)},pi=Vi(),Mt={},dn={};function Qs(i,e,t){let n,r,s,o,a;lt(cn,"globalPath"),ut(i,cn,E=>t(1,s=E)),lt(Je,"options"),ut(i,Je,E=>t(2,o=E));let{$$slots:l={},$$scope:f}=e;tt("Route",l,["default"]);const u=pi(),c=!si(Mt);let{fallback:h=!1}=e,{path:p="/"}=e;const y=St();lt(y,"route"),ut(i,y,E=>t(0,n=E));const _=ln(Mt);lt(_,"contextRoute"),ut(i,_,E=>t(9,r=E));const w=hi(),v=ln(dn);lt(v,"contextChildRoutes"),ut(i,v,E=>t(3,a=E)),oi(()=>v==null?void 0:v.remove(n)),un(Mt,y),un(dn,w);const I=["fallback","path"];return Object.keys(e).forEach(E=>{!~I.indexOf(E)&&E.slice(0,2)!=="$$"&&E!=="slot"&&console.warn(`<Route> was created with unknown prop '${E}'`)}),i.$$set=E=>{"fallback"in E&&t(7,h=E.fallback),"path"in E&&t(8,p=E.path),"$$scope"in E&&t(10,f=E.$$scope)},i.$capture_state=()=>({writable:St,createIdIssuer:Vi,getPathSegments:kt,getRoute:di,createChildRoutes:hi,isRouteActive:kn,getId:pi,routeContextKey:Mt,childRoutesContextKey:dn,onDestroy:oi,getContext:ln,setContext:un,hasContext:si,globalPath:cn,options:Je,getPathWithoutBase:bn,id:u,root:c,fallback:h,path:p,route:y,contextRoute:_,childRoutes:w,contextChildRoutes:v,$route:n,$contextRoute:r,$globalPath:s,$options:o,$contextChildRoutes:a}),i.$inject_state=E=>{"fallback"in E&&t(7,h=E.fallback),"path"in E&&t(8,p=E.path)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),i.$$.update=()=>{i.$$.dirty&896&&Ns(y,n=di(u,c,h,p,r),n),i.$$.dirty&1&&(v==null||v.update(n))},[n,s,o,a,y,_,v,h,p,r,f,l]}class nt extends Ye{constructor(e){super(e),et(this,e,Qs,_n,qi,{fallback:7,path:8}),J("SvelteRegisterComponent",{component:this,tagName:"Route",options:e,id:_n.name})}get fallback(){throw new vt("<Route>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set fallback(e){throw new vt("<Route>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get path(){throw new vt("<Route>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set path(e){throw new vt("<Route>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const yi=i=>{var a;const e=(a=i.target)==null?void 0:a.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,o=new URL(t).origin!==document.location.origin;if(n||r||s||o)return!0;t===document.location.href?ui.replace(t):ui.push(t),i.preventDefault()},Hi=i=>(i.addEventListener("click",yi),{destroy:()=>{i.removeEventListener("click",yi)}}),$s="home/jycouet/udev/gh/dp/my-minion-mr/node_modules/.pnpm/svelte-micro@2.5.7_svelte@4.2.18/node_modules/svelte-micro/dist/lib/components/Link.svelte";function In(i){let e,t,n,r;const s=i[5].default,o=ji(s,i,i[4],null);let a=[{href:i[0]},i[1]],l={};for(let u=0;u<a.length;u+=1)l=gn(l,a[u]);const f={c:function(){e=q("a"),o&&o.c(),li(e,l),j(e,$s,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,h){G(c,e,h),o&&o.m(e,null),t=!0,n||(r=[en(Hi.call(null,e)),Ce(e,"click",i[6],!1,!1,!1,!1)],n=!0)},p:function(c,[h]){o&&o.p&&(!t||h&16)&&Ji(o,s,c,c[4],t?Wi(s,c[4],h,null):Ui(c[4]),null),li(e,l=Js(a,[(!t||h&1)&&{href:c[0]},h&2&&c[1]]))},i:function(c){t||($(o,c),t=!0)},o:function(c){z(o,c),t=!1},d:function(c){c&&X(e),o&&o.d(c),n=!1,dt(r)}};return J("SvelteRegisterBlock",{block:f,id:In.name,type:"component",source:"",ctx:i}),f}const mi=(i,e,t)=>(i==="hash"?"#":"")+(e??"")+t;function Gs(i,e,t){let n;const r=["href"];let s=ai(e,r),o;lt(Je,"options"),ut(i,Je,c=>t(3,o=c));let{$$slots:a={},$$scope:l}=e;tt("Link",a,["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){js.call(this,i,c)}return i.$$set=c=>{e=gn(gn({},e),qs(c)),t(1,s=ai(e,r)),"href"in c&&t(2,f=c.href),"$$scope"in c&&t(4,l=c.$$scope)},i.$capture_state=()=>({getFormatedHref:mi,options:Je,linkHandle:Hi,href:f,formatedHref:n,$options:o}),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=mi(o.mode,o.basePath,f))},[n,s,f,o,l,a,u]}class pt extends Ye{constructor(e){super(e),et(this,e,Gs,In,qi,{href:2}),J("SvelteRegisterComponent",{component:this,tagName:"Link",options:e,id:In.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/>'")}}var Qt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};class xe{constructor(...e){d(this,"fields");d(this,"options",{});d(this,"target");d(this,"readonly",!0);d(this,"allowNull",!1);d(this,"dbReadOnly",!1);d(this,"isServerExpression",!1);d(this,"key","");d(this,"caption","");d(this,"inputType","");d(this,"dbName","");d(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,o)=>{t[s.key]=s.valueConverter.fromJson(r[o])}),t}}function te(i,e=!0){var n;let t=i[ze];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 ze=Symbol.for("entityMember"),Xs=Symbol.for("entityInfo"),zs=Symbol.for("entityInfo_key");function Oe(i,e=!0){if(i===void 0){if(e)throw new Error("Undefined is not an entity :)");return}let t=i[Xs];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 xs(i){return i[zs]}const Ks=Symbol.for("relationInfo");function Zs(i){return i==null?void 0:i[Ks]}const On=Symbol.for("fieldRelationInfo");function oe(i){return i[On]}function Ys(i,e,t){for(const n of i.fields.toArray()){const r=Zs(n.options);if(r&&!n[On]){const s=r.toType(),o=e.repo(s,t),a=n.options;n[On]={type:r.type,toEntity:s,options:a,toRepo:o,getFields:()=>{let l=a.field,f={fields:a.fields,compoundIdField:void 0};function u(p){return Error(`Error for relation: "${n.key}" to "${o.metadata.key}": `+p)}let c=()=>l||f.fields;if(r.type==="toMany"&&!c()){for(const p of o.fields.toArray())if(!c()){const y=oe(p),_=p.options;if(y&&y.toEntity===i.metadata.entityType){if(y.type==="reference")l=p.key;else if(y.type==="toOne"){if(_.field)l=_.field;else if(_.fields){let w={};for(const v in _.fields)if(Object.prototype.hasOwnProperty.call(_.fields,v)){const I=_.fields[v];w[I]=v}f.fields=w}}}}if(!c())throw u("No matching field found on target. Please specify field/fields")}function h(p,y){const _=y.fields.find(p);if(!_)throw u(`Field "${p}" was not found in "${y.key}".`);return _}r.type==="reference"&&(l=n.key),l&&(r.type==="toOne"||r.type==="reference"?o.metadata.idMetadata.field instanceof xe?f.compoundIdField=l:f.fields={[o.metadata.idMetadata.field.key]:l}:i.metadata.idMetadata.field instanceof xe?f.compoundIdField=l:f.fields={[l]:i.metadata.idMetadata.field.key});for(const p in f.fields)Object.prototype.hasOwnProperty.call(f.fields,p)&&(h(p,o.metadata),h(f.fields[p],i.metadata));return f}}}}}class F{constructor(e){d(this,"apply");this.apply=e}static throwErrorIfFilterIsEmpty(e,t){if(F.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(!F.isFilterEmpty(t))return!1}if(e.$or){for(const t of e.$or)if(F.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 zt;return await F.fromEntityFilter(e,t).__applyToConsumer(n),n.preciseValues}async getPreciseValues(){const e=new zt;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{[Ke+n.key]:r}},{rawFilterInfo:n})}static entityFilterToJson(e,t){return F.fromEntityFilter(e,t).toJson()}static entityFilterFromJson(e,t){return Jt(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 no(...s.map(o=>F.fromEntityFilter(e,o))));else if(r=="$not")n.push(new io(F.fromEntityFilter(e,s)));else if(r=="$and")n.push(new wi(...s.map(o=>F.fromEntityFilter(e,o))));else if(r.startsWith(Ke))n.push(new F(o=>{o.custom(r.substring(Ke.length),s)}));else if(r==Qi)n.push(new F(o=>o.databaseCustom(s)));else{const o=e.fields[r],a=oe(o),l=o.options;let f=(a==null?void 0:a.type)==="toOne"?l.fields?new to(o,e.fields,l):new eo(e.fields[l.field]):new $t(o),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 h=s[c];switch(c){case"$gte":case">=":n.push(f.isGreaterOrEqualTo(h)),u=!0;break;case"$gt":case">":n.push(f.isGreaterThan(h)),u=!0;break;case"$lte":case"<=":n.push(f.isLessOrEqualTo(h)),u=!0;break;case"$lt":case"<":n.push(f.isLessThan(h)),u=!0;break;case"$ne":case"!=":case"$nin":u=!0,Array.isArray(h)?n.push(f.isNotIn(h)):n.push(f.isDifferentFrom(h));break;case"$in":u=!0,n.push(f.isIn(h));break;case"$contains":u=!0,n.push(f.contains(h));break;case"$startsWith":u=!0,n.push(f.startsWith(h));break;case"$endsWith":u=!0,n.push(f.endsWith(h));break;case"$notContains":u=!0,n.push(f.notContains(h));break}}Array.isArray(s)&&(u=!0,n.push(f.isIn(s)))}!u&&s!==void 0&&n.push(f.isEqualTo(s))}}return new wi(...n)}__applyToConsumer(e){this.apply(e)}static async resolve(e){return typeof e=="function"?await e():e}toJson(){let e=new Gt;return this.__applyToConsumer(e),e.result}static async translateCustomWhere(e,t,n){let r=new Xt(async(s,o)=>{let a=[];for(const l in t.entityType){const f=t.entityType[l];f&&f.rawFilterInfo&&f.rawFilterInfo.rawFilterTranslator&&f.rawFilterInfo.key==s&&a.push(await F.fromEntityFilter(t,await f.rawFilterInfo.rawFilterTranslator(o,n)))}return a});return e.__applyToConsumer(r),await r.resolve(),e=new F(s=>r.applyTo(s)),e}}class $t{constructor(e){d(this,"metadata");this.metadata=e}processVal(e){if(Oe(this.metadata.valueType,!1)){if(e==null){if(e===null&&!this.metadata.allowNull){const n=oe(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:te(e).getId()}return e}contains(e){return new F(t=>t.containsCaseInsensitive(this.metadata,e))}notContains(e){return new F(t=>t.notContainsCaseInsensitive(this.metadata,e))}startsWith(e){return new F(t=>t.startsWithCaseInsensitive(this.metadata,e))}endsWith(e){return new F(t=>t.endsWithCaseInsensitive(this.metadata,e))}isLessThan(e){return e=this.processVal(e),new F(t=>t.isLessThan(this.metadata,e))}isGreaterOrEqualTo(e){return e=this.processVal(e),new F(t=>t.isGreaterOrEqualTo(this.metadata,e))}isNotIn(e){return new F(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 F(t=>t.isNotNull(this.metadata)):new F(t=>t.isDifferentFrom(this.metadata,e))}isLessOrEqualTo(e){return e=this.processVal(e),new F(t=>t.isLessOrEqualTo(this.metadata,e))}isGreaterThan(e){return e=this.processVal(e),new F(t=>t.isGreaterThan(this.metadata,e))}isEqualTo(e){return e=this.processVal(e),e==null&&this.metadata.allowNull?new F(t=>t.isNull(this.metadata)):new F(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 F(t=>t.isEqualTo(this.metadata,e[0])):new F(t=>t.isIn(this.metadata,e))}}class eo extends $t{processVal(e){return e?typeof e=="string"||typeof e=="number"?e:te(e).getId():null}}class to{constructor(e,t,n){d(this,"metadata");d(this,"fields");d(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 F(t=>{e.forEach(n=>this.isDifferentFrom(n).__applyToConsumer(t))})}isDifferentFrom(e){return new F(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 F(o=>new $t(this.fields.find(s)).isDifferentFrom(e[r]).__applyToConsumer(o)))}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 F(t=>{for(const n in this.relationOptions.fields)if(Object.prototype.hasOwnProperty.call(this.relationOptions.fields,n)){const r=this.relationOptions.fields[n];new $t(this.fields.find(r)).isEqualTo(e[n]).__applyToConsumer(t)}})}isIn(e){return new F(t=>{t.or(e.map(n=>this.isEqualTo(n)))})}}class wi extends F{constructor(...t){super(n=>{for(const r of this.filters)r&&r.__applyToConsumer(n)});d(this,"filters");this.filters=t}add(t){this.filters.push(t)}}class no extends F{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)});d(this,"filters");this.filters=t}}class io extends F{constructor(t){super(n=>{n.not(t)});d(this,"filter");this.filter=t}}const Ke="$custom$",Qi="$db$",En="$an array";class Gt{constructor(){d(this,"result",{});d(this,"hasUndefined",!1)}databaseCustom(e){throw new Error("database custom is not allowed with api calls.")}custom(e,t){Array.isArray(t)&&(t={[En]:t}),this.add(Ke+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 Gt;return t.__applyToConsumer(n),n.result}))}not(e){let t=new Gt;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 Jt(i,e){let t={};function n(a){t.$and||(t.$and=[]),t.$and.push(a)}function r(a,l){t[a]===void 0?t[a]=l:n({[a]:l})}[...i.fields].forEach(a=>{function l(u,c,h=!1,p=!1){let y=e.get(a.key+u);if(y!==void 0){let _=w=>{let v=w;if(h){let E;typeof w=="string"?E=JSON.parse(w):E=w,v=E.map(M=>p?M:a.valueConverter.fromJson(M))}else v=p?v:a.valueConverter.fromJson(v);let I=c(v);I!==void 0&&r(a.key,I)};if(!h&&y instanceof Array)y.forEach(w=>{_(w)});else{h&&typeof y=="string"&&(y=JSON.parse(y));const w=o(y);for(const v of w)_(v)}}}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(a.key+".null");if(f)switch(f=f.toString().trim().toLowerCase(),f){case"y":case"true":case"yes":r(a.key,null);break;default:r(a.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=o(s).map(f=>({$or:f.map(u=>Jt(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 a=o(s);const l=[];for(const f of a)if(Array.isArray(f))for(const u of f)l.push({$not:Jt(i,{get:c=>u[c]})});else l.push({$not:Jt(i,{get:u=>f[u]})});l.length==1&&!t.$not?t=l[0]:n({$and:l})}for(const a in i.entityType){const l=i.entityType[a];if(l&&l.rawFilterInfo&&l.rawFilterInfo.rawFilterTranslator){let f=e.get(Ke+a);if(f!==void 0){const u=c=>{c[En]!=null&&(c=c[En]),r(Ke+a,c)};Array.isArray(f)?f.forEach(c=>u(c)):u(f)}}}return t;function o(a){if(!Array.isArray(a))return[a];const l=[],f=[];for(const u of a)Array.isArray(u)?f.push(u):l.push(u);return f.push(l),f}}class Xt{constructor(e){d(this,"translateCustom");d(this,"commands",[]);d(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 Xt(this.translateCustom);return n.__applyToConsumer(r),await r.resolve(),new F(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 Xt(this.translateCustom);e.__applyToConsumer(n),await n.resolve(),t=new F(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 zt{constructor(){d(this,"rawValues",{});d(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=oe(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 zt;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 ro={};const hn=Symbol.for("remult-static1");let Ut={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:()=>{}})},captionTransformer:void 0,defaultDataProvider:()=>{}};typeof process<"u"&&ro.IGNORE_GLOBAL_REMULT_IN_TESTS||typeof globalThis[hn]>"u"?(globalThis[hn]=Ut,Ut.remultFactory=()=>$i()):Ut=globalThis[hn];const T=Ut;function $i(){return T.defaultRemult||(T.defaultRemult=T.defaultRemultFactory()),T.defaultRemult}function so(){T.remultFactory=()=>$i()}function Ze(i){const e=i;if(typeof e[Ct]=="function")return e[Ct]();throw Error("Error getting repository internal from "+i)}const Ct=Symbol.for("getInternal");class oo{constructor(){d(this,"iAmRemultProxy",!0);d(this,"repoCache",new Map);d(this,"repo",(...e)=>{let t=T,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 T.remultFactory().repo(...e).metadata.fields},[Ct](){return t.remultFactory().repo(...e)[Ct]()},relations:s=>t.remultFactory().repo(...e).relations(s),validate:(s,...o)=>t.remultFactory().repo(...e).validate(s,...o),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),findFirst:(...s)=>t.remultFactory().repo(...e).findFirst(...s),findOne:(...s)=>t.remultFactory().repo(...e).findOne(...s),findId:(s,o)=>t.remultFactory().repo(...e).findId(s,o),toJson:s=>t.remultFactory().repo(...e).toJson(s),fromJson:(s,o)=>t.remultFactory().repo(...e).fromJson(s,o),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 T.remultFactory().repo(...e).metadata},query:(...s)=>t.remultFactory().repo(...e).query(...s),save:s=>t.remultFactory().repo(...e).save(s),update:(s,o)=>t.remultFactory().repo(...e).update(s,o)},n.set(e[1],r),r)})}get liveQuerySubscriber(){return T.remultFactory().liveQuerySubscriber}set liveQuerySubscriber(e){T.remultFactory().liveQuerySubscriber=e}get liveQueryStorage(){return T.remultFactory().liveQueryStorage}set liveQueryStorage(e){T.remultFactory().liveQueryStorage=e}get liveQueryPublisher(){return T.remultFactory().liveQueryPublisher}set liveQueryPublisher(e){T.remultFactory().liveQueryPublisher=e}call(e,t,...n){return T.remultFactory().call(e,t,...n)}get context(){return T.remultFactory().context}get dataProvider(){return T.remultFactory().dataProvider}set dataProvider(e){T.remultFactory().dataProvider=e}get repCache(){return T.remultFactory().repCache}authenticated(){return T.remultFactory().authenticated()}isAllowed(e){return T.remultFactory().isAllowed(e)}isAllowedForInstance(e,t){return T.remultFactory().isAllowedForInstance(e,t)}clearAllCache(){return T.remultFactory().clearAllCache()}get user(){return T.remultFactory().user}set user(e){T.remultFactory().user=e}get apiClient(){return T.remultFactory().apiClient}set apiClient(e){T.remultFactory().apiClient=e}get subscriptionServer(){return T.remultFactory().subscriptionServer}set subscriptionServer(e){T.remultFactory().subscriptionServer=e}}const Se=new oo;function ao(i){return i.replace(/([A-Z])/g," $1").replace(/^./,e=>e.toUpperCase()).replace("Email","eMail").replace(" I D"," ID")}class lo{constructor(e,t,n){d(this,"repository");d(this,"isReferenceRelation");d(this,"allowNull");d(this,"storedItem");d(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:Ze(this.repository)._getCachedByIdAsync(e,!1)}get(e){if(e==null)return null;const t=Ze(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=te(e,!1);t&&!this.isReferenceRelation?(Ze(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 gi{constructor(e){d(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)}}}const Gi={error500RetryCount:4};function Pt(i){if(!i)return new bi;let e;return e||Xi(i)&&(e=new uo(i)),e||typeof i=="function"&&(e=new bi(i)),e}function Xi(i){let e=i;return!!(e&&e.get&&e.put&&e.post&&e.delete)}class uo{constructor(e){d(this,"http");this.http=e}async post(e,t){return await xt(()=>Nt(this.http.post(e,t)))}delete(e){return Nt(this.http.delete(e))}put(e,t){return Nt(this.http.put(e,t))}async get(e){return await xt(()=>Nt(this.http.get(e)))}}async function xt(i){var t,n,r,s;let e=0;for(;;)try{return await i()}catch(o){if(((t=o.message)!=null&&t.startsWith("Error occurred while trying to proxy")||(n=o.message)!=null&&n.startsWith("Error occured while trying to proxy")||(r=o.message)!=null&&r.includes("http proxy error")||(s=o.message)!=null&&s.startsWith("Gateway Timeout")||o.status==500)&&e++<Gi.error500RetryCount){await new Promise((a,l)=>{setTimeout(()=>{a({})},500)});continue}throw o}}function Nt(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?t.data:t).catch(async t=>{throw await fo(t)})}async function fo(i){var s,o,a;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=(o=e==null?void 0:e.response)==null?void 0:o.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=(a=e.response)==null?void 0:a.status),n!=null&&(t.httpStatusCode=n);var r=Object.assign(t,{});return r}class zi{constructor(e){d(this,"apiProvider");d(this,"isProxy",!0);this.apiProvider=e}getEntityDataProvider(e){return new co(()=>{var n;let t=(n=this.apiProvider())==null?void 0:n.url;return t==null&&(t="/api"),t+"/"+e.key},()=>Pt(this.apiProvider().httpClient),e)}async transaction(e){throw new Error("Method not implemented.")}}function Gn(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=oe(e.fields.find(n));s&&(r=Gn(r,s.toRepo.metadata))}t[n]=r}i={...i,include:t}}return i.where&&(i={...i,where:F.entityFilterToJson(e,i.where)}),i.load&&(i={...i,load:i.load(e.fields).map(t=>t.key)}),i}class co{constructor(e,t,n){d(this,"url");d(this,"http");d(this,"entity");this.url=e,this.http=t,this.entity=n}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)}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 gi(this.url()),r;if(e){if(e.where&&(r=e.where.toJson(),po(r,n)&&(r=void 0)),e.orderBy&&e.orderBy.Segments){let o="",a="",l=!1;e.orderBy.Segments.forEach(f=>{o.length>0&&(o+=",",a+=","),o+=f.field.key,a+=f.isDescending?"desc":"asc",f.isDescending&&(l=!0)}),o&&n.add("_sort",o),l&&n.add("_order",a)}e.limit&&n.add("_limit",e.limit),e.page&&n.add("_page",e.page)}const s=(o,a)=>{let l=new gi(n.url);return!o&&r&&(o="get"),o&&l.add("__action",o),r?(a={set:a,where:r},this.http().post(l.url,a)):this.http()[t](l.url,a)};return{createKey:()=>JSON.stringify({url:n,filterObject:r}),run:s,subscribe:async o=>({result:await s(yo+o),unsubscribe:async()=>T.actionInfo.runActionWithoutBlockingUI(()=>this.http().post(this.url()+"?__action=endLiveQuery",{id:o}))})}}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(F.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 bi{constructor(e){d(this,"fetch");this.fetch=e}async get(e){return await xt(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 xt(()=>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=>ho(r)).catch(async r=>{throw await r})}}function ho(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 po(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(Ke)?e.add(t,JSON.stringify(n)):e.add(t,n)}return!0}const yo="liveQuery-";var Lt,mo=new Uint8Array(16);function wo(){if(!Lt&&(Lt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Lt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Lt(mo)}const go=/^(?:[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 bo(i){return typeof i=="string"&&go.test(i)}var ce=[];for(var pn=0;pn<256;++pn)ce.push((pn+256).toString(16).substr(1));function vo(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(ce[i[e+0]]+ce[i[e+1]]+ce[i[e+2]]+ce[i[e+3]]+"-"+ce[i[e+4]]+ce[i[e+5]]+"-"+ce[i[e+6]]+ce[i[e+7]]+"-"+ce[i[e+8]]+ce[i[e+9]]+"-"+ce[i[e+10]]+ce[i[e+11]]+ce[i[e+12]]+ce[i[e+13]]+ce[i[e+14]]+ce[i[e+15]]).toLowerCase();if(!bo(t))throw TypeError("Stringified UUID is invalid");return t}function Sn(i,e,t){i=i||{};var n=i.random||(i.rng||wo)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,vo(n)}class Ie{constructor(...e){d(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 Ie;for(const t of this.Segments)e.Segments.push({field:t.field,isDescending:!t.isDescending});return e}compare(e,t,n){n||(n=s=>s.key);let r=0;for(let s=0;s<this.Segments.length;s++){let o=this.Segments[s],a=vi(e[n(o.field)]),l=vi(t[n(o.field)]);if(a>l?r=1:a<l&&(r=-1),r!=0)return o.isDescending&&(r*=-1),r}return r}static translateOrderByToSort(e,t){let n=new Ie;if(t){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const s=t[r];let o=e.fields.find(r);const a=l=>{switch(s){case"desc":n.Segments.push({field:l,isDescending:!0});break;case"asc":n.Segments.push({field:l})}};if(o){const l=oe(o);if((l==null?void 0:l.type)==="toOne"){const f=l.options;if(typeof f.field=="string")a(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];a(e.fields.find(c.toString()))}}}else a(o)}}}return n}static createUniqueSort(e,t){(!t||Object.keys(t).length===0)&&e.options.defaultOrderBy&&(t=Ie.translateOrderByToSort(e,e.options.defaultOrderBy)),t||(t=new Ie);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 vi(i){return i==null||i==null?i:i.id!==void 0?i.id:i}const yn="stream";class _o{constructor(e,t,n){d(this,"repo");d(this,"query");d(this,"queryChannel");d(this,"subscribeCode");d(this,"unsubscribe",()=>{});d(this,"defaultQueryState",[]);d(this,"listeners",[]);d(this,"id",Sn());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 Ze(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=Ie.translateOrderByToSort(this.repo.metadata,this.query.options.orderBy);this.defaultQueryState.sort((s,o)=>r.compare(s,o))}});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 Ze(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 ko="_liveQueryKeepAlive";class Io{constructor(e,t){d(this,"apiProvider");d(this,"getUserId");d(this,"queries",new Map);d(this,"channels",new Map);d(this,"client");d(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 Oo);try{s.unsubscribe=await r.subscribe(e,o=>this.wrapMessageHandling(()=>s.handle(o)),o=>{t.error(o)})}catch(o){throw t.error(o),o}}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(Ze(e)._buildEntityDataProviderFindOptions(t).then(o=>{if(!r)return;const{createKey:a,subscribe:l}=new zi(this.apiProvider).getEntityDataProvider(e.metadata).buildFindRequest(o),f=a();let u=this.queries.get(f);u?u.sendDefaultState(n.next):(this.queries.set(f,u=new _o(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(h=>h.error(c))}}).then(c=>{if(u.listeners.length==0){c();return}this.runPromise(l(u.queryChannel).then(h=>{if(u.listeners.length===0){h.unsubscribe(),c();return}this.runPromise(u.setAllItems(h.result)),u.unsubscribe=()=>{u.unsubscribe=()=>{},c(),this.runPromise(h.unsubscribe())}}).catch(h=>{u.listeners.forEach(p=>p.error(h)),c(),this.queries.delete(f)}))})).catch(c=>{u.listeners.forEach(h=>h.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(o=>{n.error(o)})),()=>{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 T.actionInfo.runActionWithoutBlockingUI(()=>Pt(t.httpClient).post(t.url+"/"+ko,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 Oo{constructor(){d(this,"unsubscribe",()=>{});d(this,"listeners",[])}async handle(e){for(const t of this.listeners)t.next(e)}}class Xn{openConnection(e){let t;const n=new Map,r=Pt(Se.apiClient.httpClient);let s=!1,o;const a={close(){o.close()},async subscribe(u,c){let h=n.get(u);return h||(n.set(u,h=[]),await f(u)),h.push(c),()=>{h.splice(h.indexOf(c,1)),h.length==0&&(T.actionInfo.runActionWithoutBlockingUI(()=>r.post(Se.apiClient.url+"/"+yn+"/unsubscribe",{channel:u,clientId:t})),n.delete(u))}}},l=()=>new Promise(u=>{h();let c=0;function h(){o&&o.close(),o=Xn.createEventSource(Se.apiClient.url+"/"+yn),o.onmessage=p=>{let y=JSON.parse(p.data);const _=n.get(y.channel);_&&_.forEach(w=>w(y.data))},o.onerror=p=>{console.error("Live Query Event Source Error",p),o.close(),c++<Gi.error500RetryCount&&setTimeout(()=>{h()},500)},o.addEventListener("connectionId",async p=>{if(t=p.data,s){for(const y of n.keys())await f(y);e()}else s=!0,u(a)})}});return l();async function f(u){await T.actionInfo.runActionWithoutBlockingUI(()=>r.post(Se.apiClient.url+"/"+yn+"/subscribe",{channel:u,clientId:t}))===Eo&&await l()}}static createEventSource(e){return new EventSource(e,{withCredentials:!0})}}const Eo="client connection not found",Cn=Symbol.for("serverActionField");class So{constructor(e){d(this,"remultObjectStorage");this.remultObjectStorage=e}static enable(){T.remultFactory=()=>{const e=T.asyncContext.getStore();if(e)return e.remult;throw new Error("remult object was requested outside of a valid context, try running it within initApi or a remult request cycle")}}static disable(){so()}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;const t=(n=this.remultObjectStorage)==null?void 0:n.getStore();t&&(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()}}T.asyncContext||(T.asyncContext=new So(void 0));function Tn(){return T.actionInfo.runningOnServer||!Se.dataProvider.isProxy}class Pe{constructor(e){d(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 zn(e,this,t,Mo(e,this))),Ys(r,this,t)),r});d(this,"user");d(this,"dataProvider",new zi(()=>this.apiClient));d(this,"repCache",new Map);d(this,"liveQueryStorage");d(this,"subscriptionServer");d(this,"liveQueryPublisher",{itemChanged:async()=>{}});d(this,"liveQuerySubscriber",new Io(()=>this.apiClient,()=>{var e;return(e=this.user)==null?void 0:e.id}));d(this,"context",{});d(this,"apiClient",{url:"/api",subscriptionClient:new Xn});if(e&&e.getEntityDataProvider){this.dataProvider=e;return}if(Xi(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)}}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)}call(e,t,...n){const r=e[Cn];if(!r.doWork)throw Error("The method received is not a valid backend method");return r.doWork(n,t,this.apiClient.url,Pt(this.apiClient.httpClient))}clearAllCache(){this.repCache.clear()}}d(Pe,"onFind",(e,t)=>{}),d(Pe,"entityRefInit");T.defaultRemultFactory=()=>new Pe;class Co{constructor(){d(this,"classes",new Map)}}const To={defaultPageSize:200};async function xi(i,e){const t=new Ao(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 Ao{constructor(e){d(this,"orig");d(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(o=>o.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 An(i,e){return e&&Object.assign(i,e),i}class De{}d(De,"number","number"),d(De,"date","date"),d(De,"checkbox","checkbox"),d(De,"password","password"),d(De,"email","email"),d(De,"tel","tel"),d(De,"time","time");const L=class L{};d(L,"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=>L.Date.fromJson(e),toInput:e=>L.Date.toJson(e),displayValue:e=>e?e.toLocaleString():""}),d(L,"DateOnly",{fromInput:e=>L.DateOnly.fromJson(e),toInput:e=>L.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:De.date,toDb:e=>e?L.DateOnly.fromJson(L.DateOnly.toJson(e)):null,fromDb:e=>L.Date.fromDb(e),fieldTypeInDb:"date",displayValue:e=>e?e.toLocaleDateString(void 0):""}),d(L,"DateOnlyString",{...L.DateOnly,toDb:e=>{let t=L.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))}}),d(L,"Boolean",{toDb:e=>e,inputType:De.checkbox,fromDb:e=>L.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=>L.Boolean.fromJson(e),toInput:e=>L.Boolean.toJson(e)}),d(L,"Number",{fromDb:e=>{if(e===null)return null;if(e!==void 0)return+e},toDb:e=>e,fromJson:e=>L.Number.fromDb(e),toJson:e=>L.Number.toDb(e),fromInput:(e,t)=>{let n=+e;if(e!=null)return n},toInput:(e,t)=>(e==null?void 0:e.toString())??"",inputType:De.number}),d(L,"String",{fromDb:st,toDb:st,fromJson:st,toJson:st,fromInput:st,toInput:st}),d(L,"Integer",{...L.Number,toJson:e=>{let t=L.Number.toDb(e);return t&&+(+t).toFixed(0)},toDb:e=>L.Integer.toJson(e),fieldTypeInDb:"integer"}),d(L,"Default",{fromJson:e=>e,toJson:e=>e,fromDb:e=>L.JsonString.fromDb(e),toDb:e=>L.JsonString.toDb(e),fromInput:e=>L.Default.fromJson(e),toInput:e=>L.Default.toJson(e),displayValue:e=>e+"",fieldTypeInDb:"",inputType:"text"}),d(L,"JsonString",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e==null?null:e?JSON.parse(L.JsonString.fromJson(e)):void 0,toDb:e=>e!==void 0?e===null?null:JSON.stringify(L.JsonString.toJson(e)):void 0,fromInput:e=>L.JsonString.fromJson(e),toInput:e=>L.JsonString.toJson(e)}),d(L,"JsonValue",{fromJson:e=>e,toJson:e=>e,fromDb:e=>e,toDb:e=>e,fromInput:e=>L.JsonString.fromJson(e),toInput:e=>L.JsonString.toJson(e),fieldTypeInDb:"json"});let ye=L;function st(i){return i==null?i:typeof i!="string"?i.toString():i}function _i(i,e,t){let n=F.fromEntityFilter(i,e);const r=()=>{};n&&n.__applyToConsumer({custom:r,databaseCustom:r,containsCaseInsensitive:r,notContainsCaseInsensitive:r,startsWithCaseInsensitive:r,endsWithCaseInsensitive:r,isDifferentFrom:r,isEqualTo:(s,o)=>{t[s.key]=o},isGreaterOrEqualTo:r,isGreaterThan:r,isIn:r,isLessOrEqualTo:r,isLessThan:r,isNotNull:r,isNull:r,not:r,or:r})}class ki{constructor(){d(this,"entityLoaders",new Map);d(this,"promises",[])}load(e,t){let n=this.entityLoaders.get(e.entityType);n||this.entityLoaders.set(e.entityType,n=new Po(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 Po{constructor(e){d(this,"rel");d(this,"queries",new Map);this.rel=e}find(e){const{where:t,...n}=Gn(e,this.rel.metadata),r=JSON.stringify(n);let s=this.queries.get(r);return s||this.queries.set(r,s=new Fo(this.rel)),s.find(e,t)}}class Fo{constructor(e){d(this,"rel");d(this,"pendingInStatements",new Map);d(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 o=this.pendingInStatements.get(s[0]);o||this.pendingInStatements.set(s[0],o=new Do(this.rel,s[0],e)),this.whereVariations.set(n,r={result:o.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 Do{constructor(e,t,n){d(this,"rel");d(this,"key");d(this,"options");d(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 a=te(s).fields.find(this.key),l=oe(a.metadata),f=(l==null?void 0:l.type)==="reference"?a.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,o=new Promise((a,l)=>{r=a,s=l});this.values.set(t,n={value:t,resolve:r,reject:s,result:o})}return n.result}}const pe=class pe{};d(pe,"required",_t(async(e,t)=>t.value!=null&&t.value!=null&&t.value!=="","Should not be empty")),d(pe,"unique",_t(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")),d(pe,"uniqueOnBackend",_t(async(e,t)=>t.isBackend()&&(t.isNew||t.valueChanged())?await t.entityRef.repository.count({[t.metadata.key]:t.value})==0:!0,pe.unique.defaultMessage)),d(pe,"regex",wt((e,t)=>t.test(e))),d(pe,"email",Wt(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),"Invalid Email")),d(pe,"url",Wt(e=>!!new URL(e),"Invalid Url")),d(pe,"in",wt((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(", ")}`)),d(pe,"notNull",Wt(e=>e!=null,"Should not be null")),d(pe,"enum",wt((e,t)=>Object.values(t).includes(e),e=>`Value must be one of ${Vt(e).join(", ")}`)),d(pe,"relationExists",_t(async(e,t)=>t.valueIsNull()||!t.isBackend()?!0:!!await t.load(),"Relation value does not exist")),d(pe,"maxLength",wt((e,t)=>e.length<=t,e=>`Value must be at most ${e} characters`)),d(pe,"minLength",wt((e,t)=>e.length>=t,e=>`Value must be at least ${e} characters`)),d(pe,"defaultMessage","Invalid value");let Be=pe;function _t(i,e){const t=async(r,s,o)=>{const a=await i(r,s);typeof a=="string"&&a.length>0?s.error=a:a||(s.error=typeof o=="function"&&o(r,s,void 0)||o||typeof e=="function"&&e(r,s,void 0)||e||Be.defaultMessage)},n=(r,s,o)=>typeof r=="string"||r==="function"||r===void 0&&s===void 0?async(a,l,f)=>await t(a,l,r||f):t(r,s,o);return Object.defineProperty(n,"defaultMessage",{get:()=>e,set:r=>{e=r},enumerable:!0}),Object.assign(n,{withMessage:r=>async(s,o)=>n(s,o,r)})}function Wt(i,e){return _t((t,n)=>n.value===void 0||n.value===null?!0:i(n.value),e)}function wt(i,e){const t=Ro((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 Ro(i,e,t=!1){return Object.assign((r,s)=>async(o,a)=>{const l=await i(o,a,r);typeof l=="string"?a.error=l:l||(a.error=s?typeof s=="function"?t?s(r):s(o,a,r):s:e?typeof e=="function"?e(o,a,r):e:Be.defaultMessage)},{get defaultMessage(){return e},set defaultMessage(r){e=r}})}function Vt(i){return Object.values(i).filter(e=>typeof i[e]!="number")}function Ht(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 It(i,e){return typeof i[e]<"u"}class zn{constructor(e,t,n,r,s){d(this,"_entity");d(this,"_remult");d(this,"_dataProvider");d(this,"_info");d(this,"_defaultFindOptions");d(this,"__edp");d(this,"_idCache",new Map);d(this,"listeners");d(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}}[Ct](){return this}async _createAfterFilter(e,t){let n=new Map;for(const o of Ie.translateOrderByToSort(this.metadata,e).Segments){let a=t[o.field.key];n.set(o.field.key,a)}let r={$or:[]},s=[];for(const o of Ie.translateOrderByToSort(this.metadata,e).Segments){let a={};for(const l of s)a[l.key]=n.get(l.key);s.push(o.field),o.isDescending?a[o.field.key]={$lt:n.get(o.field.key)}:a[o.field.key]={$gt:n.get(o.field.key)},r.$or.push(a)}return r}relations(e){return new Proxy({},{get:(t,n)=>{const r=this.fields.find(n),s=oe(r);if(!s)throw Error(n+" is not a relation");const{toRepo:o,returnNull:a,returnUndefined:l}=this._getFocusedRelationRepo(r,e);return s.type==="toMany"?o:{findOne:f=>a?Promise.resolve(null):l?Promise.resolve(void 0):o.findFirst({},f)}}})}_getFocusedRelationRepo(e,t){const n=oe(e);let r=n.toRepo,{findOptions:s,returnNull:o,returnUndefined:a}=this._findOptionsBasedOnRelation(n,e,void 0,t,r);return{toRepo:new zn(r._entity,r._remult,r._dataProvider,r._info,s),returnNull:o,returnUndefined:a}}get _edp(){return this.__edp?this.__edp:this.__edp=this._dataProvider.getEntityDataProvider(this.metadata)}_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 Uo(e,this)}getEntityRef(e){let t=e[ze];return t||(this._fixTypes(e),t=new Bt(this._info,e,this,this._edp,this._remult,!0),Object.defineProperty(e,ze,{get:()=>t}),t.saveOriginalData()),t}async delete(e){const t=te(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 te(r).delete()}}let n=this._getRefForExistingRow(e,void 0);return this._dataProvider.isProxy||await n.reload(),n.delete()}async insert(e){if(Array.isArray(e))if(this._dataProvider.isProxy){let t=[],n=[];for(const r of e){let s=te(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 Ot(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=te(e,!1);if(t){if(!t.isNew())throw"Item is not new";return await t.save()}else return await this.getEntityRef(this.create(e)).save()}}get fields(){return this.metadata.fields}async validate(e,...t){{let n=te(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}}}async updateMany({where:e,set:t}){if(F.throwErrorIfFilterIsEmpty(e,"updateMany"),this._dataProvider.isProxy)return this._edp.updateMany(await this._translateWhereToFilter(e),t);{let n=0;for await(const r of this.query({where:e}))An(r,t),await te(r).save(),n++;return n}}async update(e,t){{let r=te(t,!1);if(r)return await r.save()}{let r=te(e,!1);if(r)return An(e,t),r.save()}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 o=n.fields[s];if(t[s]===void 0&&oe(o.metadata))continue;o&&(r[s]=t[s])}return await this._fixTypes(r),await n.save()}}_getRefForExistingRow(e,t){let n=te(e,!1);if(!n){const r=new this._entity(this._remult);for(const o of this._fieldsOf(e)){const a=o.key;r[a]=e[a]}this._fixTypes(r);let s=new Bt(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,ze,{get:()=>s})}return n}async save(e){if(Array.isArray(e))return Ot(e,t=>this.save(t));{let t=te(e,!1);if(t)return await t.save();if(e instanceof nr)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){e||(e={}),this._defaultFindOptions&&(e={...this._defaultFindOptions,...e});let r=await this._buildEntityDataProviderFindOptions(e);t&&(delete r.orderBy,delete r.limit),Pe.onFind(this._info,e);const s=await this._edp.find(r);return await this._loadManyToOneForManyRows(s,e,n)}async find(e,t=!1){const n=new ki,r=await this._rawFind(e,t,n);return await n.resolveAll(),r}async _buildEntityDataProviderFindOptions(e){let t={};return t={},(!e.orderBy||Object.keys(e.orderBy).length===0)&&(e.orderBy=this._info.entityInfo.defaultOrderBy),t.where=await this._translateWhereToFilter(e.where),e.orderBy!==void 0&&(t.orderBy=Ie.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 ki,r=await this._loadManyToOneForManyRows(e.map(s=>{let o={};for(const a of this.metadata.fields.toArray())o[a.key]=a.valueConverter.fromJson(s[a.key]);return o}),t,n);return await n.resolveAll(),r}async _loadManyToOneForManyRows(e,t,n){var a;let r;t!=null&&t.load&&(r=t.load(this.metadata.fields));for(const l of this.metadata.fields)if(Oe(l.valueType,!1)&&!oe(l)){let c=!l.options.lazy;if(r!==void 0&&(c=r.includes(l)),c){let h=this._remult.repo(l.valueType),p=[];for(const y of e){let _=y[l.key];_!=null&&!p.includes(_)&&!h._idCache.has(_+"")&&p.push(_)}p.length>0&&await s(h,p)}}async function s(l,f){let u=await l.find({where:l.metadata.idMetadata.getIdFilter(...f)},!0);for(const c of u)l._addToCache(c)}let o=await Ot(e,async l=>await this._mapRawDataToResult(l,r));for(const l of this.metadata.fields){let f=oe(l),u=l.options.defaultIncluded;const c=(a=t==null?void 0:t.include)==null?void 0:a[l.key];if(c!==void 0&&(u=c),f&&u){const h=f.toRepo;for(const p of o){let{findOptions:y,returnNull:_}=this._findOptionsBasedOnRelation(f,l,u,p,h);const w=l.key;if(_)p[w]=null;else{const v=f.toEntity,I=h;n.load({entityType:v,find:E=>I._rawFind(E,!1,n),metadata:I.metadata},y).then(E=>{E.length==0&&f.type=="toOne"||(p[w]=f.type!=="toMany"?E.length==0?null:E[0]:E)})}}}}return o}_findOptionsBasedOnRelation(e,t,n,r,s){let o=!1,a=!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(),h=p=>{let y=e.type==="reference"?te(r).fields.find(t.key).getId():r[p];return(e.type==="toOne"||e.type==="reference")&&(y===null?o=!0:y===void 0?a=!0:e.type==="reference"&&typeof y=="object"&&(y=s.metadata.idMetadata.getId(y))),y};c.compoundIdField&&(e.type==="toMany"?l.push({[c.compoundIdField]:this.metadata.idMetadata.getId(r)}):l.push(s.metadata.idMetadata.getIdFilter(h(c.compoundIdField))));for(const p in c.fields)Object.prototype.hasOwnProperty.call(c.fields,p)&&l.push({[p]:h(c.fields[p])});return f.where={$and:l},(e.type==="toOne"||e.type==="reference")&&f.orderBy&&(f.limit=1),{findOptions:f,returnNull:o,returnUndefined:a}}async _mapRawDataToResult(e,t){let n=new this._entity(this._remult),r=new Bt(this._info,n,this,this._edp,this._remult,!1);return Object.defineProperty(n,ze,{get:()=>r}),await r.loadDataFrom(e,t),r.saveOriginalData(),n}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(Oe(r.valueType,!1)){let a=e[r.key];typeof a=="string"||typeof a=="number"?n[s]=a:n[s]=this._remult.repo(r.valueType).fromJson(a)}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 Bt(this._info,n,this,this._edp,this._remult,!1);return Object.defineProperty(n,ze,{get:()=>r}),r.saveOriginalData(),n}}async count(e){return this._edp.count(await this._translateWhereToFilter(e))}async deleteMany({where:e}){if(F.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}))await te(n).delete(),t++;return t}}async findOne(e,t=!1){let n,r,s=e??{};if(s.useCache){let o=Gn(s,this.metadata),a=JSON.stringify(o);if(r=this._cache.get(a),r!==void 0)if(r.value&&this.getEntityRef(r.value).wasDeleted())r=void 0,this._cache.delete(a);else return r.promise;else r={value:void 0,promise:void 0},this._cache.set(a,r)}return n=this.find({...s,limit:1},t).then(async o=>{let a;return o.length>0&&(a=o[0]),!a&&s.createIfNotFound&&(a=this.create(),s.where&&await _i(this.metadata,s.where,a)),a}),r&&(r.promise=n=n.then(o=>(r.value=o,o))),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&&(_i(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:o=>F.getPreciseValues(this.metadata,o||t)})),this.metadata.options.backendPrefilter&&(t={$and:[t,await F.resolve(this.metadata.options.backendPrefilter)]}));let n=await F.fromEntityFilter(this.metadata,t);return n&&!this._dataProvider.isProxy&&(n=await F.translateCustomWhere(n,this.metadata,this._remult)),n}}function Mo(i,e){let t=T.columnsOfType.get(i);t||T.columnsOfType.set(i,t=[]);let n=Oe(i)(e),r=xs(i),s=Object.getPrototypeOf(i);for(;s!=null;){let o=T.columnsOfType.get(s);o&&t.unshift(...o.filter(l=>!t.find(f=>f.key==l.key)));let a=Oe(s,!1);if(a){let l=a(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(h,p)=>{await c(h,p),await l[u](h,p)}}}s=Object.getPrototypeOf(s)}return new qo(Zi(t,e),n,e,i,r)}class Ki{constructor(e,t,n,r){d(this,"fieldsMetadata");d(this,"instance");d(this,"remult");d(this,"isNewRow");d(this,"_error");d(this,"_subscribers");d(this,"_isLoading",!1);d(this,"lookups",new Map);d(this,"errors");d(this,"originalValues",{});this.fieldsMetadata=e,this.instance=t,this.remult=n,this.isNewRow=r;{let s=n;s!=null&&s.iAmRemultProxy&&(n=T.remultFactory())}for(const s of e)if(Oe(s.valueType,!1)&&n){let a=new lo(n.repo(s.valueType),!!oe(s),s.allowNull);this.lookups.set(s.key,a);let l=t[s.key],f;Object.defineProperty(t,s.key,{get:()=>(this._subscribers&&(this._subscribers.reportObserved(),f||(f=this.fields.find(s.key),f._subscribers||(f._subscribers=new qt)),f._subscribers.reportObserved()),a.item),set:u=>{var c;a.set(u),(c=this._subscribers)==null||c.reportChanged(),f||(f=this.fields.find(s.key),f._subscribers||(f._subscribers=new qt)),f._subscribers.reportChanged()},enumerable:!0}),a.set(l)}else{const a=oe(s);if((a==null?void 0:a.type)==="toOne"){let l=t.hasOwnProperty(s.key),f=t[s.key];r&&!f&&(l=!1),Object.defineProperty(t,s.key,{get:()=>f,set:u=>{if(f=u,u===void 0)return;const c=s.options;if(c.field&&(this.instance[c.field]=a.toRepo.metadata.idMetadata.getId(u)),c.fields){for(const h in c.fields)if(Object.prototype.hasOwnProperty.call(c.fields,h)){const p=c.fields[h];this.instance[p]=u==null?null:u[h]}}},enumerable:!0}),l&&(t[s.key]=f)}}}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 qt;const e=this._subscribers;for(const t of this.fieldsMetadata){let n=Oe(t.valueType,!1),r=this.fields.find(t.key);if(r._subscribers=new qt,!(n&&this.remult)){let s=this.instance[t.key];Object.defineProperty(this.instance,t.key,{get:()=>(e.reportObserved(),r._subscribers.reportObserved(),s),set:o=>{s=o,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 Ot([...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 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 o=oe(n);r?s=r.id:s=this.instance[n.key],o&&e&&!n.allowNull&&s==null&&(o.toRepo.metadata.idMetadata.field.valueType===Number?s=0:s=""),(!o||o.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,o=this.lookups.get(r.key),a=!1;o?e?(s=o.toJson(),a=!0,n[r.key]=s):s=o.id:oe(r)&&!e?a=!0:(s=this.instance[r.key],this.remult||s&&Oe(s.constructor,!1)&&(s=te(s).getId())),a||(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 Ot([...this.fields].filter(r=>!oe(r.metadata)),r=>r.load())}}class Bt extends Ki{constructor(t,n,r,s,o,a){super(t.fieldsMetadata,n,o,a);d(this,"info");d(this,"repo");d(this,"edp");d(this,"_isNew");d(this,"repository");d(this,"metadata");d(this,"_wasDeleted",!1);d(this,"_columns");d(this,"_saving",!1);d(this,"id");d(this,"originalId");if(this.info=t,this.repo=r,this.edp=s,this._isNew=a,this.repository=r,this.metadata=t,a)for(const l of t.fieldsMetadata){const f=l.key;l.options.defaultValue&&n[f]===void 0&&(typeof l.options.defaultValue=="function"?n[f]=l.options.defaultValue(n):n[f]||(n[f]=l.options.defaultValue))}this.info.entityInfo.entityRefInit&&this.info.entityInfo.entityRefInit(this,n),Pe.entityRefInit&&Pe.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 xe?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 Kt(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,o=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,o);this.info.entityInfo.saving&&await this.info.entityInfo.saving(this.instance,o)}this.__assertValidity();let a=this.copyDataToObject(this.isNew()),l=[];for(const c of this.metadata.fields)if(c.dbReadOnly||t!==void 0&&!t.includes(c.key)){a[c.key]=void 0,l.push(c.key);let h=this.fields.find(c);h.value=h.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(a);else{let c={},h=!1;for(const p in a)if(Object.prototype.hasOwnProperty.call(a,p)){const y=a[p];this.fields.find(p).valueChanged()&&!l.includes(p)&&(c[p]=y,h=!0)}if(!h)return this.instance;s?f=(await this.edp.find({where:await this.getIdFilter()}))[0]:f=await this.edp.update(this.id,c)}if(f&&await this.loadDataFrom(f),o.id=this.getId(),!this.repo._dataProvider.isProxy&&(this.info.entityInfo.saved&&await this.info.entityInfo.saved(this.instance,o),this.repo.listeners))for(const c of this.repo.listeners)await((r=c.saved)==null?void 0:r.call(c,this.instance,u));return await 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()),n=[];for(const r of this.metadata.fields)if(r.dbReadOnly){t[r.key]=void 0,n.push(r.key);let s=this.fields.find(r);s.value=s.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&&await this.edp.delete(this.id),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));await 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&&!oe(r)&&await s.waitLoad():n.includes(r)&&await s.waitLoad()):oe(r)||(this.instance[r.key]=t[r.key])}await this.calcServerExpression(),this.id=this.getId()}getOriginalId(){return this.originalId}async calcServerExpression(){if(Tn())for(const t of this.info.fieldsMetadata)t.options.serverExpression&&(this.instance[t.key]=await t.options.serverExpression(this.instance))}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=oe(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 Kt(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 Ii=Symbol.for("controllerColumns");function Zi(i,e){return i.map(t=>xn(t.settings(e),e))}function Oi(i,e){const t=e||Se;let n=i[Ii];if(n||(n=i[ze]),!n){let r=T.columnsOfType.get(i.constructor);r||T.columnsOfType.set(i.constructor,r=[]);let s=Object.getPrototypeOf(i.constructor);for(;s!=null;){let o=T.columnsOfType.get(s);o&&r.unshift(...o.filter(a=>!r.find(l=>l.key==a.key))),s=Object.getPrototypeOf(s)}i[Ii]=n=new No(Zi(r,t).map(o=>new er(o,void 0,t)),i,t)}return n}class No extends Ki{constructor(t,n,r){super(t,n,r,!1);d(this,"fields");let s=[],o={find:a=>o[typeof a=="string"?a:a.key],[Symbol.iterator]:()=>s[Symbol.iterator](),toArray:()=>s};for(const a of t)s.push(o[a.key]=new Kt(a.options,a,n,void 0,this));this.fields=o}async __performColumnAndEntityValidations(){for(const t of this.fields)t instanceof Kt&&await t.__performValidation()}}class Kt{constructor(e,t,n,r,s){d(this,"settings");d(this,"metadata");d(this,"container");d(this,"helper");d(this,"rowBase");d(this,"_subscribers");d(this,"target");d(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=oe(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,o,a;return!((a=(o=(s=n.rowBase)==null?void 0:s.remult)==null?void 0:o.dataProvider)!=null&&a.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 Lo={transformCaption:(i,e,t,n)=>t};const Bo=T.captionTransformer||(T.captionTransformer=Lo);function Yi(i,e,t,n){let r;return typeof i=="function"?t&&(r=i(t)):i&&(r=i),r=Bo.transformCaption(t,e,r??"",n),r||(e?ao(e):"")}class er{constructor(e,t,n){d(this,"settings");d(this,"entityDefs");d(this,"remult");d(this,"options");d(this,"target");d(this,"readonly",!1);d(this,"valueConverter");d(this,"allowNull");d(this,"caption");d(this,"dbName");d(this,"inputType");d(this,"key");d(this,"isServerExpression",!1);d(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 o=r[s];return typeof o=="function"?(...a)=>{try{return r[s](...a)}catch(l){const f=`${String(s)} failed for value ${a==null?void 0:a[0]}. Error: ${typeof l=="string"?l:l.message}`;throw{message:this.caption+": "+f,modelState:{[this.key]:f}}}}:o}}),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=Yi(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 Kn(this,this.entityDefs)}get dbReadOnly(){return!!this.settings.dbReadOnly}}class qo{constructor(e,t,n,r,s){d(this,"entityInfo");d(this,"remult");d(this,"entityType");d(this,"key");d(this,"options");d(this,"fieldsMetadata",[]);d(this,"idMetadata",{getId:e=>{if(e==null)return e;const t=te(e,!1);return t?t.getId():this.idMetadata.field instanceof xe?this.idMetadata.field.getId(e):e[this.idMetadata.field.key]},field:void 0,get fields(){return this.field instanceof xe?this.field.fields:[this.field]},createIdInFilter:e=>e.length>0?{$or:e.map(t=>this.idMetadata.getIdFilter(te(t).getId()))}:{[this.fields.toArray()[0].key]:[]},isIdField:e=>e.key==this.idMetadata.field.key,getIdFilter:(...e)=>{if(this.idMetadata.field instanceof xe){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}}});d(this,"fields");d(this,"dbName");d(this,"caption");if(this.entityInfo=t,this.remult=n,this.entityType=r,this.key=s,this.options=t,this.options.allowApiCrud!==void 0){let a;typeof this.options.allowApiCrud=="function"?a=(l,f)=>this.options.allowApiCrud(f):a=this.options.allowApiCrud,this.options.allowApiDelete===void 0&&(this.entityInfo.allowApiDelete=a),this.options.allowApiInsert===void 0&&(this.entityInfo.allowApiInsert=a),this.options.allowApiUpdate===void 0&&(this.entityInfo.allowApiUpdate=a),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 o={find:a=>o[typeof a=="string"?a:a.key],[Symbol.iterator]:()=>this.fieldsMetadata[Symbol.iterator](),toArray:()=>this.fieldsMetadata};for(const a of e)this.fieldsMetadata.push(o[a.key]=new er(a,this,n));if(this.fields=o,this.caption=Yi(t.caption,this.key,n,this),t.id){let a=typeof t.id=="function"?t.id(this.fields):Object.keys(t.id).map(l=>this.fields.find(l));Array.isArray(a)?a.length>1?this.idMetadata.field=new xe(...a):a.length==1&&(this.idMetadata.field=a[0]):this.idMetadata.field=a}if(!this.idMetadata.field){const a=this.fields.id;a?this.idMetadata.field=a: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=te(e,!1);return t||this.remult.repo(this.entityType).getEntityRef({...e})}getDbName(){return sr(this)}}function jo(i){var e,t;return((t=(e=i.options)==null?void 0:e.valueConverter)==null?void 0:t.fieldTypeInDb)==="autoincrement"}const Jo=Symbol.for("storableMember"),mn=Symbol.for("fieldOptionalValues");function tr(i,e){let t={};for(const n of i)if(n)if(typeof n=="function")n(t,e);else{const{validate:r,...s}=n;t.validate=Ht(t.validate,r),Object.assign(t,s)}return t}function xn(i,e){if(i.valueType){let r=i.valueType[Jo];r&&(i=tr([...r,i],e))}if(i.valueType==String){let r=i;i.valueConverter||(r.valueConverter=ye.String)}if(i.valueType==Number){let r=i;i.valueConverter||(r.valueConverter=ye.Number)}if(i.valueType==Date){let r=i;i.valueConverter||(r.valueConverter=ye.Date)}if(i.valueType==Boolean){let r=i;r.valueConverter||(r.valueConverter=ye.Boolean)}if(!i.valueConverter){if(Oe(i.valueType,!1)){let s;i.valueConverter={toDb:o=>o,fromDb:o=>o},i.valueConverter=new Proxy(i.valueConverter,{get(o,a){if(o[a]===void 0&&s===void 0){if(a==="inputType")return"";s=e.repo(i.valueType).metadata.idMetadata.field.valueType===Number;for(const l of["fieldTypeInDb","toJson","fromJson","toDb","fromDb"])o[l]=s?ye.Integer[l]:ye.String[l]}return o[a]},set(o,a,l,f){return o[a]=l,!0}})}else i.valueConverter=ye.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 nr{get _(){return te(this)}save(){return te(this).save()}assign(e){return An(this,e),this}delete(){return this._.delete()}isNew(){return this._.isNew()}get $(){return this._.fields}}class Uo{constructor(e,t){d(this,"options");d(this,"repo");d(this,"_count");this.options=e,this.repo=t,this.options||(this.options={}),this.options.pageSize||(this.options.pageSize=To.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=Ie.createUniqueEntityOrderBy(this.repo.metadata,this.options.orderBy);let t=await this.repo.find({where:{$and:[this.options.where,e]},orderBy:this.options.orderBy,limit:this.options.pageSize,load:this.options.load,include:this.options.include}),n=()=>{throw new Error("no more pages")},r=t.length==this.options.pageSize;if(r){let s=await this.repo._createAfterFilter(this.options.orderBy,t[t.length-1]);n=()=>this.paginator(s)}return{count:()=>this.count(),hasNextPage:r,items:t,nextPage:n}}[Symbol.asyncIterator](){this.options.where||(this.options.where={});let e=this.options.orderBy;this.options.orderBy=Ie.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 o=n;if(n?n=await n.nextPage():n=await this.paginator(),t=0,n.items.length==0)return{value:void 0,done:!0};if(((o==null?void 0:o.items.length)??!1)&&this.repo.getEntityRef(o.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 qt{constructor(){d(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 Wo(i){return i.metadata?i.metadata:Oe(i,!1)?Se.repo(i).metadata:i}function Vo(i){return Oe(i,!1)?Se.repo(i):i}async function Ot(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 ft=class ft{constructor(e){d(this,"sql");d(this,"wrapIdentifier",e=>e);d(this,"provideMigrationBuilder");d(this,"createdEntities",[]);d(this,"end");this.sql=e,e.wrapIdentifier&&(this.wrapIdentifier=t=>e.wrapIdentifier(t)),It(e,"provideMigrationBuilder")&&(this.provideMigrationBuilder=t=>e.provideMigrationBuilder(t)),It(e,"end")&&(this.end=()=>e.end())}static getDb(e){const t=e||Se.dataProvider;if(It(t,"createCommand"))return t;throw"the data provider is not an SqlCommandFactory"}createCommand(){return new Qo(this.sql.createCommand(),ft.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:ye.JsonString.toDb,fromDb:ye.JsonString.fromDb});return new ir(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 ft({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{[Qi]:{buildSql:e}}}static async filterToRaw(e,t,n,r,s){n||(n=new $o);const o=Vo(e);var a=new je(n,r||await rr(o.metadata,s));return a._addWhere=!1,await(await Ze(o)._translateWhereToFilter(t)).__applyToConsumer(a),await a.resolveWhere()}};d(ft,"LogToConsole",!1),d(ft,"durationThreshold",0);let ct=ft;const Ho=new Map([["INSERT","⚪"],["SELECT","🔵"],["UPDATE","🟣"],["DELETE","🟤"],["CREATE","🟩"],["ALTER","🟨"],["DROP","🟥"],["TRUNCATE","⬛"],["GRANT","🟪"],["REVOKE","🟫"]]);class Qo{constructor(e,t){d(this,"origin");d(this,"logToConsole");d(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>ct.durationThreshold){const s=t/1e3;if(this.logToConsole==="oneLiner"){const o=e.replace(/(\r\n|\n|\r|\t)/gm," ").replace(/ +/g," ").trim(),a=o.split(" ")[0].toUpperCase();console.info(`${Ho.get(a)||"💢"} (${s.toFixed(3)}) ${o} ${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 ir{constructor(e,t,n,r){d(this,"entity");d(this,"sql");d(this,"iAmUsed");d(this,"strategy");this.entity=e,this.sql=t,this.iAmUsed=n,this.strategy=r}async init(){let e=await rr(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 je(r,t);e.__applyToConsumer(s),n+=await s.resolveWhere()}return r.execute(n).then(s=>Number(s.rows[0].count))}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 o=new je(s,t);e.where.__applyToConsumer(o),r+=await o.resolveWhere()}if(e.limit&&(e.orderBy=Ie.createUniqueSort(this.entity,e.orderBy)),e.orderBy||(e.orderBy=Ie.createUniqueSort(this.entity,new Ie)),e.orderBy){let o=!0,a=[];for(const l of e.orderBy.Segments)a.push(l);for(const l of a)o?(r+=" Order By ",o=!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 o=1;e.page&&(o=e.page),o<1&&(o=1),r+=" "+this.strategy.getLimitSqlSyntax(e.limit,(o-1)*e.limit)}}return s.execute(r).then(o=>o.rows.map(a=>this.buildResultRow(n,a,o)))}buildResultRow(e,t,n){let r={};for(let s=0;s<e.length;s++){const o=e[s];try{r[o.key]=o.valueConverter.fromDb(t[n.getColumnKeyInResultForIndexInSelect(s)])}catch(a){throw new Error("Failed to load from db:"+o.key+`\r
5
- `+a)}}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 ",o=!1;for(const h of this.entity.fields)if(!Si(h,n)){if(t[h.key]!==void 0){let p=h.valueConverter.toDb(t[h.key]);p!==void 0&&(o?s+=", ":o=!0,s+=n.$dbNameOf(h)+" = "+r.param(p))}}const a=this.entity.idMetadata.getIdFilter(e);let l=new je(r,n);F.fromEntityFilter(this.entity,a).__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(h=>{var p,y;if((y=(p=this.sql._getSourceSql()).afterMutation)==null||y.call(p),!c)return Ei(this.entity,this,t,e,"update");if(h.rows.length!=1)throw new Error("Failed to update row with id "+e+", rows updated: "+h.rows.length);return this.buildResultRow(f,h.rows[0],h)})}async delete(e){let t=await this.init(),n=this.sql.createCommand(),r=new je(n,t);F.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 o,a;(a=(o=this.sql._getSourceSql()).afterMutation)==null||a.call(o)})}async insert(e){let t=await this.init(),n=this.sql.createCommand(),r="",s="",o=!1;for(const u of this.entity.fields)if(!Si(u,t)){let c=u.valueConverter.toDb(e[u.key]);c!=null&&(o?(r+=", ",s+=", "):o=!0,r+=t.$dbNameOf(u),s+=n.param(c))}let a=`insert into ${t.$entityName} (${r}) values (${s})`,{colKeys:l,select:f}=this.buildSelect(t);return this.sql._getSourceSql().doesNotSupportReturningSyntax||(a+=" returning "+f),await n.execute(a).then(u=>{var c,h;if((h=(c=this.sql._getSourceSql()).afterMutation)==null||h.call(c),this.sql._getSourceSql().doesNotSupportReturningSyntax)if(jo(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 F(y=>y.isEqualTo(this.entity.idMetadata.field,p))}).then(y=>y[0])}else return Ei(this.entity,this,e,void 0,"insert");return this.buildResultRow(l,u.rows[0],u)})}}d(ir,"LogToConsole",!1);class $o{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 Ei(i,e,t,n,r){const s=n!==void 0?i.idMetadata.getIdFilter(n):{};return e.find({where:new F(o=>{for(const a of i.idMetadata.fields)o.isEqualTo(a,t[a.key]??s[a.key])})}).then(o=>{if(o.length!=1)throw new Error(`Failed to ${r} row - result contained ${o.length} rows`);return o[0]})}class je{constructor(e,t){d(this,"r");d(this,"nameProvider");d(this,"where","");d(this,"_addWhere",!0);d(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 je(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 je(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 Go(this.r,this.nameProvider.wrapIdentifier),n=await e.buildSql(t);typeof n!="string"&&(n=t.sql),n&&this.addToWhere("("+n+")")}})())}}class Go{constructor(e,t){d(this,"r");d(this,"wrapIdentifier");d(this,"sql","");d(this,"param",(e,t)=>(typeof t=="object"&&t.valueConverter.toDb&&(e=t.valueConverter.toDb(e)),this.r.param(e)));d(this,"filterToRaw",async(e,t)=>ct.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 Si(i,e){return i.dbReadOnly||i.isServerExpression||i.options.sqlExpression&&i.dbName!=e.$dbNameOf(i)}async function rr(i,e){return Xo(i,e,!0)}async function Xo(i,e,t=!1){let n=typeof e=="function"?{wrapIdentifier:e}:e||{};var r=Wo(i);n.wrapIdentifier||(n.wrapIdentifier=Se.dataProvider.wrapIdentifier),n.wrapIdentifier||(n.wrapIdentifier=o=>o);const s={$entityName:await sr(r,n.wrapIdentifier),toString:()=>s.$entityName,$dbNameOf:o=>{var a;return typeof o=="string"?a=o:a=o.key,s[a]},wrapIdentifier:n.wrapIdentifier};for(const o of r.fields){let a=await Kn(o,r,n.wrapIdentifier,t);o.options.sqlExpression||(typeof n.tableName=="string"?a=n.wrapIdentifier(n.tableName)+"."+a:n.tableName===!0&&(a=s.$entityName+"."+a)),s[o.key]=a}return s}async function sr(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 wn=Symbol.for("sqlExpressionInProgressKey");async function Kn(i,e,t=r=>r,n=!1){try{if(i.options.sqlExpression){let o;if(typeof i.options.sqlExpression=="function"){if(i[wn]&&!n)return"recursive sqlExpression call for field '"+i.key+"'. ";try{i[wn]=!0,o=await i.options.sqlExpression(e),i.options.sqlExpression=()=>o}finally{delete i[wn]}}else o=i.options.sqlExpression;return o||i.dbName}const r=oe(i);let s=(r==null?void 0:r.type)==="toOne"&&i.options.field;if(s){let o=e.fields.find(s);if(o)return Kn(o,e,t,n)}return t(i.dbName)}finally{}}var Ve={},Z={},fe={};Object.defineProperty(fe,"__esModule",{value:!0});fe.output=fe.exists=fe.hash=fe.bytes=fe.bool=fe.number=fe.isBytes=void 0;function Zt(i){if(!Number.isSafeInteger(i)||i<0)throw new Error(`positive integer expected, not ${i}`)}fe.number=Zt;function or(i){if(typeof i!="boolean")throw new Error(`boolean expected, not ${i}`)}fe.bool=or;function ar(i){return i instanceof Uint8Array||i!=null&&typeof i=="object"&&i.constructor.name==="Uint8Array"}fe.isBytes=ar;function Zn(i,...e){if(!ar(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}`)}fe.bytes=Zn;function lr(i){if(typeof i!="function"||typeof i.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Zt(i.outputLen),Zt(i.blockLen)}fe.hash=lr;function ur(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")}fe.exists=ur;function fr(i,e){Zn(i);const t=e.outputLen;if(i.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}fe.output=fr;const zo={number:Zt,bool:or,bytes:Zn,hash:lr,exists:ur,output:fr};fe.default=zo;var R={};Object.defineProperty(R,"__esModule",{value:!0});R.add5L=R.add5H=R.add4H=R.add4L=R.add3H=R.add3L=R.add=R.rotlBL=R.rotlBH=R.rotlSL=R.rotlSH=R.rotr32L=R.rotr32H=R.rotrBL=R.rotrBH=R.rotrSL=R.rotrSH=R.shrSL=R.shrSH=R.toBig=R.split=R.fromBig=void 0;const jt=BigInt(2**32-1),Pn=BigInt(32);function Yn(i,e=!1){return e?{h:Number(i&jt),l:Number(i>>Pn&jt)}:{h:Number(i>>Pn&jt)|0,l:Number(i&jt)|0}}R.fromBig=Yn;function cr(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:o}=Yn(i[r],e);[t[r],n[r]]=[s,o]}return[t,n]}R.split=cr;const dr=(i,e)=>BigInt(i>>>0)<<Pn|BigInt(e>>>0);R.toBig=dr;const hr=(i,e,t)=>i>>>t;R.shrSH=hr;const pr=(i,e,t)=>i<<32-t|e>>>t;R.shrSL=pr;const yr=(i,e,t)=>i>>>t|e<<32-t;R.rotrSH=yr;const mr=(i,e,t)=>i<<32-t|e>>>t;R.rotrSL=mr;const wr=(i,e,t)=>i<<64-t|e>>>t-32;R.rotrBH=wr;const gr=(i,e,t)=>i>>>t-32|e<<64-t;R.rotrBL=gr;const br=(i,e)=>e;R.rotr32H=br;const vr=(i,e)=>i;R.rotr32L=vr;const _r=(i,e,t)=>i<<t|e>>>32-t;R.rotlSH=_r;const kr=(i,e,t)=>e<<t|i>>>32-t;R.rotlSL=kr;const Ir=(i,e,t)=>e<<t-32|i>>>64-t;R.rotlBH=Ir;const Or=(i,e,t)=>i<<t-32|e>>>64-t;R.rotlBL=Or;function Er(i,e,t,n){const r=(e>>>0)+(n>>>0);return{h:i+t+(r/2**32|0)|0,l:r|0}}R.add=Er;const Sr=(i,e,t)=>(i>>>0)+(e>>>0)+(t>>>0);R.add3L=Sr;const Cr=(i,e,t,n)=>e+t+n+(i/2**32|0)|0;R.add3H=Cr;const Tr=(i,e,t,n)=>(i>>>0)+(e>>>0)+(t>>>0)+(n>>>0);R.add4L=Tr;const Ar=(i,e,t,n,r)=>e+t+n+r+(i/2**32|0)|0;R.add4H=Ar;const Pr=(i,e,t,n,r)=>(i>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);R.add5L=Pr;const Fr=(i,e,t,n,r,s)=>e+t+n+r+s+(i/2**32|0)|0;R.add5H=Fr;const xo={fromBig:Yn,split:cr,toBig:dr,shrSH:hr,shrSL:pr,rotrSH:yr,rotrSL:mr,rotrBH:wr,rotrBL:gr,rotr32H:br,rotr32L:vr,rotlSH:_r,rotlSL:kr,rotlBH:Ir,rotlBL:Or,add:Er,add3L:Sr,add3H:Cr,add4L:Tr,add4H:Ar,add5H:Fr,add5L:Pr};R.default=xo;var Dr={},rn={};Object.defineProperty(rn,"__esModule",{value:!0});rn.crypto=void 0;rn.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=rn,t=fe;function n(g){return g instanceof Uint8Array||g!=null&&typeof g=="object"&&g.constructor.name==="Uint8Array"}i.isBytes=n;const r=g=>new Uint8Array(g.buffer,g.byteOffset,g.byteLength);i.u8=r;const s=g=>new Uint32Array(g.buffer,g.byteOffset,Math.floor(g.byteLength/4));i.u32=s;const o=g=>new DataView(g.buffer,g.byteOffset,g.byteLength);i.createView=o;const a=(g,O)=>g<<32-O|g>>>O;i.rotr=a;const l=(g,O)=>g<<O|g>>>32-O>>>0;i.rotl=l,i.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=g=>g<<24&4278190080|g<<8&16711680|g>>>8&65280|g>>>24&255;i.byteSwap=f,i.byteSwapIfBE=i.isLE?g=>g:g=>(0,i.byteSwap)(g);function u(g){for(let O=0;O<g.length;O++)g[O]=(0,i.byteSwap)(g[O])}i.byteSwap32=u;const c=Array.from({length:256},(g,O)=>O.toString(16).padStart(2,"0"));function h(g){(0,t.bytes)(g);let O="";for(let A=0;A<g.length;A++)O+=c[g[A]];return O}i.bytesToHex=h;const p={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function y(g){if(g>=p._0&&g<=p._9)return g-p._0;if(g>=p._A&&g<=p._F)return g-(p._A-10);if(g>=p._a&&g<=p._f)return g-(p._a-10)}function _(g){if(typeof g!="string")throw new Error("hex string expected, got "+typeof g);const O=g.length,A=O/2;if(O%2)throw new Error("padded hex string expected, got unpadded hex of length "+O);const W=new Uint8Array(A);for(let K=0,se=0;K<A;K++,se+=2){const Te=y(g.charCodeAt(se)),mt=y(g.charCodeAt(se+1));if(Te===void 0||mt===void 0){const Dt=g[se]+g[se+1];throw new Error('hex string expected, got non-hex character "'+Dt+'" at index '+se)}W[K]=Te*16+mt}return W}i.hexToBytes=_;const w=async()=>{};i.nextTick=w;async function v(g,O,A){let W=Date.now();for(let K=0;K<g;K++){A(K);const se=Date.now()-W;se>=0&&se<O||(await(0,i.nextTick)(),W+=se)}}i.asyncLoop=v;function I(g){if(typeof g!="string")throw new Error(`utf8ToBytes expected string, got ${typeof g}`);return new Uint8Array(new TextEncoder().encode(g))}i.utf8ToBytes=I;function E(g){return typeof g=="string"&&(g=I(g)),(0,t.bytes)(g),g}i.toBytes=E;function M(...g){let O=0;for(let W=0;W<g.length;W++){const K=g[W];(0,t.bytes)(K),O+=K.length}const A=new Uint8Array(O);for(let W=0,K=0;W<g.length;W++){const se=g[W];A.set(se,K),K+=se.length}return A}i.concatBytes=M;class U{clone(){return this._cloneInto()}}i.Hash=U;const ne={}.toString;function re(g,O){if(O!==void 0&&ne.call(O)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(g,O)}i.checkOpts=re;function ue(g){const O=W=>g().update(E(W)).digest(),A=g();return O.outputLen=A.outputLen,O.blockLen=A.blockLen,O.create=()=>g(),O}i.wrapConstructor=ue;function Ee(g){const O=(W,K)=>g(K).update(E(W)).digest(),A=g({});return O.outputLen=A.outputLen,O.blockLen=A.blockLen,O.create=W=>g(W),O}i.wrapConstructorWithOpts=Ee;function be(g){const O=(W,K)=>g(K).update(E(W)).digest(),A=g({});return O.outputLen=A.outputLen,O.blockLen=A.blockLen,O.create=W=>g(W),O}i.wrapXOFConstructorWithOpts=be;function Y(g=32){if(e.crypto&&typeof e.crypto.getRandomValues=="function")return e.crypto.getRandomValues(new Uint8Array(g));throw new Error("crypto.getRandomValues must be defined")}i.randomBytes=Y})(Dr);Object.defineProperty(Z,"__esModule",{value:!0});Z.shake256=Z.shake128=Z.keccak_512=Z.keccak_384=Z.keccak_256=Z.keccak_224=Z.sha3_512=Z.sha3_384=Z.sha3_256=Z.sha3_224=Z.Keccak=Z.keccakP=void 0;const ot=fe,Tt=R,Le=Dr,Rr=[],Mr=[],Nr=[],Ko=BigInt(0),gt=BigInt(1),Zo=BigInt(2),Yo=BigInt(7),ea=BigInt(256),ta=BigInt(113);for(let i=0,e=gt,t=1,n=0;i<24;i++){[t,n]=[n,(2*t+3*n)%5],Rr.push(2*(5*n+t)),Mr.push((i+1)*(i+2)/2%64);let r=Ko;for(let s=0;s<7;s++)e=(e<<gt^(e>>Yo)*ta)%ea,e&Zo&&(r^=gt<<(gt<<BigInt(s))-gt);Nr.push(r)}const[na,ia]=(0,Tt.split)(Nr,!0),Ci=(i,e,t)=>t>32?(0,Tt.rotlBH)(i,e,t):(0,Tt.rotlSH)(i,e,t),Ti=(i,e,t)=>t>32?(0,Tt.rotlBL)(i,e,t):(0,Tt.rotlSL)(i,e,t);function Lr(i,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=i[o]^i[o+10]^i[o+20]^i[o+30]^i[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,f=t[l],u=t[l+1],c=Ci(f,u,1)^t[a],h=Ti(f,u,1)^t[a+1];for(let p=0;p<50;p+=10)i[o+p]^=c,i[o+p+1]^=h}let r=i[2],s=i[3];for(let o=0;o<24;o++){const a=Mr[o],l=Ci(r,s,a),f=Ti(r,s,a),u=Rr[o];r=i[u],s=i[u+1],i[u]=l,i[u+1]=f}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=i[o+a];for(let a=0;a<10;a++)i[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}i[0]^=na[n],i[1]^=ia[n]}t.fill(0)}Z.keccakP=Lr;class Ft extends Le.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,ot.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,Le.u32)(this.state)}keccak(){Le.isLE||(0,Le.byteSwap32)(this.state32),Lr(this.state32,this.rounds),Le.isLE||(0,Le.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(e){(0,ot.exists)(this);const{blockLen:t,state:n}=this;e=(0,Le.toBytes)(e);const r=e.length;for(let s=0;s<r;){const o=Math.min(t-this.pos,r-s);for(let a=0;a<o;a++)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,ot.exists)(this,!1),(0,ot.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 o=Math.min(n-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}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,ot.number)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,ot.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:o}=this;return e||(e=new Ft(t,n,r,o,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=o,e.destroyed=this.destroyed,e}}Z.Keccak=Ft;const He=(i,e,t)=>(0,Le.wrapConstructor)(()=>new Ft(e,i,t));Z.sha3_224=He(6,144,224/8);Z.sha3_256=He(6,136,256/8);Z.sha3_384=He(6,104,384/8);Z.sha3_512=He(6,72,512/8);Z.keccak_224=He(1,144,224/8);Z.keccak_256=He(1,136,256/8);Z.keccak_384=He(1,104,384/8);Z.keccak_512=He(1,72,512/8);const Br=(i,e,t)=>(0,Le.wrapXOFConstructorWithOpts)((n={})=>new Ft(e,i,n.dkLen===void 0?t:n.dkLen,!0));Z.shake128=Br(31,168,128/8);Z.shake256=Br(31,136,256/8);const{sha3_512:ra}=Z,qr=24,Et=32,Fn=(i=4,e=Math.random)=>{let t="";for(;t.length<i;)t=t+Math.floor(e()*36).toString(36);return t};function jr(i){let e=8n,t=0n;for(const n of i.values()){const r=BigInt(n);t=(t<<e)+r}return t}const Jr=(i="")=>jr(ra(i)).toString(36).slice(1),Ai=Array.from({length:26},(i,e)=>String.fromCharCode(e+97)),sa=i=>Ai[Math.floor(i()*Ai.length)],Ur=({globalObj:i=typeof Qt<"u"?Qt:typeof window<"u"?window:{},random:e=Math.random}={})=>{const t=Object.keys(i).toString(),n=t.length?t+Fn(Et,e):Fn(Et,e);return Jr(n).substring(0,Et)},Wr=i=>()=>i++,oa=476782367,Vr=({random:i=Math.random,counter:e=Wr(Math.floor(i()*oa)),length:t=qr,fingerprint:n=Ur({random:i})}={})=>function(){const s=sa(i),o=Date.now().toString(36),a=e().toString(36),l=Fn(t,i),f=`${o+l+a+n}`;return`${s+Jr(f).substring(1,t)}`},aa=Vr(),la=(i,{minLength:e=2,maxLength:t=Et}={})=>{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};Ve.getConstants=()=>({defaultLength:qr,bigLength:Et});Ve.init=Vr;Ve.createId=aa;Ve.bufToBigInt=jr;Ve.createCounter=Wr;Ve.createFingerprint=Ur;Ve.isCuid=la;const{createId:ua,init:Oa,getConstants:Ea,isCuid:Sa}=Ve;var Pi=ua;const Fi=Wt(i=>!isNaN(i)&&isFinite(i));class ei{static object(...e){return _e(void 0,...e)}static json(...e){let t=e;return t.valueConverter&&!t.valueConverter.fieldTypeInDb&&(t.valueConverter.fieldTypeInDb="json"),_e(void 0,{valueConverter:{fieldTypeInDb:"json"}},...e)}static dateOnly(...e){return _e(()=>Date,{valueConverter:ye.DateOnly},...e)}static date(...e){return _e(()=>Date,...e)}static integer(...e){return _e(()=>Number,{valueConverter:ye.Integer,validate:Fi},...e)}static autoIncrement(...e){return _e(()=>Number,{allowApiUpdate:!1,dbReadOnly:!0,valueConverter:{...ye.Integer,fieldTypeInDb:"autoincrement"}},...e)}static number(...e){return _e(()=>Number,{validate:Fi},...e)}static createdAt(...e){return _e(()=>Date,{allowApiUpdate:!1,saving:(t,n,{isNew:r})=>{r&&(n.value=new Date)}},...e)}static updatedAt(...e){return _e(()=>Date,{allowApiUpdate:!1,saving:(t,n)=>{n.value=new Date}},...e)}static uuid(...e){return _e(()=>String,{allowApiUpdate:!1,defaultValue:()=>Sn(),saving:(t,n)=>{n.value||(n.value=Sn())}},...e)}static cuid(...e){return _e(()=>String,{allowApiUpdate:!1,defaultValue:()=>Pi(),saving:(t,n)=>{n.value||(n.value=Pi())}},...e)}static literal(e,...t){return ei.string({validate:(n,r)=>Be.in(e())(n,r),[mn]:e},...t)}static enum(e,...t){let n;return _e(()=>e(),{validate:(r,s)=>Be.enum(e())(r,s),[mn]:()=>Vt(e())},...t,r=>{if(r[mn]=()=>Vt(e()),n===void 0){let s=e();n=Vt(s).find(a=>typeof a=="string")?ye.String:ye.Integer}r.valueConverter?r.valueConverter.fieldTypeInDb||(r.valueConverter.fieldTypeInDb=n.fieldTypeInDb):r.valueConverter=n})}static string(...e){return _e(()=>String,...e)}static boolean(...e){return _e(()=>Boolean,...e)}}function _e(i,...e){return(t,n,r)=>{const s=typeof n=="string"?n:n.name.toString();let o=f=>{let u=tr(e,f);if(u.required&&(u.validate=Ht(u.validate,Be.required,!0)),It(u,"maxLength")){let h=u;h.maxLength&&(h.validate=Ht(h.validate,Be.maxLength(h.maxLength)))}if(It(u,"minLength")){let h=u;h.minLength&&(h.validate=Ht(h.validate,Be.minLength(h.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};Hr(t);let a=T.columnsOfType.get(t.constructor);a||(a=[],T.columnsOfType.set(t.constructor,a));let l=a.find(f=>f.key==s);if(!l)a.push({key:s,settings:o});else{let f=l.settings;l.settings=u=>{let c=f(u),h=o(u);return Object.assign(c,h)}}}}function Hr(i){if(!i)throw new Error("Set the 'experimentalDecorators:true' option in your 'tsconfig' or 'jsconfig' (target undefined)")}function fa(i,e,t,n){var r=arguments.length,s=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(i,e,t,n);else for(var a=i.length-1;a>=0;a--)(o=i[a])&&(s=(r<3?o(s):r>3?o(e,t,s):o(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s}function ca(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}class da extends nr{constructor(){super(...arguments);d(this,"id")}}fa([ei.uuid(),ca("design:type",String)],da.prototype,"id",void 0);var Di={};/*! *****************************************************************************
6
- Copyright (C) Microsoft. All rights reserved.
7
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
8
- this file except in compliance with the License. You may obtain a copy of the
9
- License at http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
13
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
14
- MERCHANTABLITY OR NON-INFRINGEMENT.
15
-
16
- See the Apache Version 2.0 License for specific language governing permissions
17
- and limitations under the License.
18
- ***************************************************************************** */var Ri;(function(i){(function(e){var t=typeof Qt=="object"?Qt: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,o){return function(a,l){typeof s[a]!="function"&&Object.defineProperty(s,a,{configurable:!0,writable:!0,value:l}),o&&o(a,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",o=typeof Object.create=="function",a={__proto__:[]}instanceof Array,l=!o&&!a,f={create:o?function(){return an(Object.create(null))}:a?function(){return an({__proto__:null})}:function(){return an({})},has:l?function(m,b){return t.call(m,b)}:function(m,b){return b in m},get:l?function(m,b){return t.call(m,b)?m[b]:void 0}:function(m,b){return m[b]}},u=Object.getPrototypeOf(Function),c=typeof process=="object"&&Di&&Di.REFLECT_METADATA_USE_MAP_POLYFILL==="true",h=!c&&typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Cs(),p=!c&&typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Ts(),y=!c&&typeof WeakMap=="function"?WeakMap:As(),_=new y;function w(m,b,k,S){if(ae(k)){if(!ti(m))throw new TypeError;if(!ni(b))throw new TypeError;return be(m,b)}else{if(!ti(m))throw new TypeError;if(!he(b))throw new TypeError;if(!he(S)&&!ae(S)&&!it(S))throw new TypeError;return it(S)&&(S=void 0),k=Ne(k),Y(m,b,k,S)}}e("decorate",w);function v(m,b){function k(S,P){if(!he(S))throw new TypeError;if(!ae(P)&&!ks(P))throw new TypeError;se(m,b,S,P)}return k}e("metadata",v);function I(m,b,k,S){if(!he(k))throw new TypeError;return ae(S)||(S=Ne(S)),se(m,b,k,S)}e("defineMetadata",I);function E(m,b,k){if(!he(b))throw new TypeError;return ae(k)||(k=Ne(k)),O(m,b,k)}e("hasMetadata",E);function M(m,b,k){if(!he(b))throw new TypeError;return ae(k)||(k=Ne(k)),A(m,b,k)}e("hasOwnMetadata",M);function U(m,b,k){if(!he(b))throw new TypeError;return ae(k)||(k=Ne(k)),W(m,b,k)}e("getMetadata",U);function ne(m,b,k){if(!he(b))throw new TypeError;return ae(k)||(k=Ne(k)),K(m,b,k)}e("getOwnMetadata",ne);function re(m,b){if(!he(m))throw new TypeError;return ae(b)||(b=Ne(b)),Te(m,b)}e("getMetadataKeys",re);function ue(m,b){if(!he(m))throw new TypeError;return ae(b)||(b=Ne(b)),mt(m,b)}e("getOwnMetadataKeys",ue);function Ee(m,b,k){if(!he(b))throw new TypeError;ae(k)||(k=Ne(k));var S=g(b,k,!1);if(ae(S)||!S.delete(m))return!1;if(S.size>0)return!0;var P=_.get(b);return P.delete(k),P.size>0||_.delete(b),!0}e("deleteMetadata",Ee);function be(m,b){for(var k=m.length-1;k>=0;--k){var S=m[k],P=S(b);if(!ae(P)&&!it(P)){if(!ni(P))throw new TypeError;b=P}}return b}function Y(m,b,k,S){for(var P=m.length-1;P>=0;--P){var ve=m[P],N=ve(b,k,S);if(!ae(N)&&!it(N)){if(!he(N))throw new TypeError;S=N}}return S}function g(m,b,k){var S=_.get(m);if(ae(S)){if(!k)return;S=new h,_.set(m,S)}var P=S.get(b);if(ae(P)){if(!k)return;P=new h,S.set(b,P)}return P}function O(m,b,k){var S=A(m,b,k);if(S)return!0;var P=on(b);return it(P)?!1:O(m,P,k)}function A(m,b,k){var S=g(b,k,!1);return ae(S)?!1:vs(S.has(m))}function W(m,b,k){var S=A(m,b,k);if(S)return K(m,b,k);var P=on(b);if(!it(P))return W(m,P,k)}function K(m,b,k){var S=g(b,k,!1);if(!ae(S))return S.get(m)}function se(m,b,k,S){var P=g(k,S,!0);P.set(m,b)}function Te(m,b){var k=mt(m,b),S=on(m);if(S===null)return k;var P=Te(S,b);if(P.length<=0)return k;if(k.length<=0)return P;for(var ve=new p,N=[],B=0,D=k;B<D.length;B++){var V=D[B],H=ve.has(V);H||(ve.add(V),N.push(V))}for(var qe=0,ri=P;qe<ri.length;qe++){var V=ri[qe],H=ve.has(V);H||(ve.add(V),N.push(V))}return N}function mt(m,b){var k=[],S=g(m,b,!1);if(ae(S))return k;for(var P=S.keys(),ve=Is(P),N=0;;){var B=Es(ve);if(!B)return k.length=N,k;var D=Os(B);try{k[N]=D}catch(V){try{Ss(ve)}finally{throw V}}N++}}function Dt(m){if(m===null)return 1;switch(typeof m){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return m===null?1:6;default:return 6}}function ae(m){return m===void 0}function it(m){return m===null}function ws(m){return typeof m=="symbol"}function he(m){return typeof m=="object"?m!==null:typeof m=="function"}function gs(m,b){switch(Dt(m)){case 0:return m;case 1:return m;case 2:return m;case 3:return m;case 4:return m;case 5:return m}var k="string",S=ii(m,r);if(S!==void 0){var P=S.call(m,k);if(he(P))throw new TypeError;return P}return bs(m)}function bs(m,b){var k,S;{var P=m.toString;if(Rt(P)){var S=P.call(m);if(!he(S))return S}var k=m.valueOf;if(Rt(k)){var S=k.call(m);if(!he(S))return S}}throw new TypeError}function vs(m){return!!m}function _s(m){return""+m}function Ne(m){var b=gs(m);return ws(b)?b:_s(b)}function ti(m){return Array.isArray?Array.isArray(m):m instanceof Object?m instanceof Array:Object.prototype.toString.call(m)==="[object Array]"}function Rt(m){return typeof m=="function"}function ni(m){return typeof m=="function"}function ks(m){switch(Dt(m)){case 3:return!0;case 4:return!0;default:return!1}}function ii(m,b){var k=m[b];if(k!=null){if(!Rt(k))throw new TypeError;return k}}function Is(m){var b=ii(m,s);if(!Rt(b))throw new TypeError;var k=b.call(m);if(!he(k))throw new TypeError;return k}function Os(m){return m.value}function Es(m){var b=m.next();return b.done?!1:b}function Ss(m){var b=m.return;b&&b.call(m)}function on(m){var b=Object.getPrototypeOf(m);if(typeof m!="function"||m===u||b!==u)return b;var k=m.prototype,S=k&&Object.getPrototypeOf(k);if(S==null||S===Object.prototype)return b;var P=S.constructor;return typeof P!="function"||P===m?b:P}function Cs(){var m={},b=[],k=function(){function N(B,D,V){this._index=0,this._keys=B,this._values=D,this._selector=V}return N.prototype["@@iterator"]=function(){return this},N.prototype[s]=function(){return this},N.prototype.next=function(){var B=this._index;if(B>=0&&B<this._keys.length){var D=this._selector(this._keys[B],this._values[B]);return B+1>=this._keys.length?(this._index=-1,this._keys=b,this._values=b):this._index++,{value:D,done:!1}}return{value:void 0,done:!0}},N.prototype.throw=function(B){throw this._index>=0&&(this._index=-1,this._keys=b,this._values=b),B},N.prototype.return=function(B){return this._index>=0&&(this._index=-1,this._keys=b,this._values=b),{value:B,done:!0}},N}();return function(){function N(){this._keys=[],this._values=[],this._cacheKey=m,this._cacheIndex=-2}return Object.defineProperty(N.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),N.prototype.has=function(B){return this._find(B,!1)>=0},N.prototype.get=function(B){var D=this._find(B,!1);return D>=0?this._values[D]:void 0},N.prototype.set=function(B,D){var V=this._find(B,!0);return this._values[V]=D,this},N.prototype.delete=function(B){var D=this._find(B,!1);if(D>=0){for(var V=this._keys.length,H=D+1;H<V;H++)this._keys[H-1]=this._keys[H],this._values[H-1]=this._values[H];return this._keys.length--,this._values.length--,B===this._cacheKey&&(this._cacheKey=m,this._cacheIndex=-2),!0}return!1},N.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=m,this._cacheIndex=-2},N.prototype.keys=function(){return new k(this._keys,this._values,S)},N.prototype.values=function(){return new k(this._keys,this._values,P)},N.prototype.entries=function(){return new k(this._keys,this._values,ve)},N.prototype["@@iterator"]=function(){return this.entries()},N.prototype[s]=function(){return this.entries()},N.prototype._find=function(B,D){return this._cacheKey!==B&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=B)),this._cacheIndex<0&&D&&(this._cacheIndex=this._keys.length,this._keys.push(B),this._values.push(void 0)),this._cacheIndex},N}();function S(N,B){return N}function P(N,B){return B}function ve(N,B){return[N,B]}}function Ts(){return function(){function m(){this._map=new h}return Object.defineProperty(m.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),m.prototype.has=function(b){return this._map.has(b)},m.prototype.add=function(b){return this._map.set(b,b),this},m.prototype.delete=function(b){return this._map.delete(b)},m.prototype.clear=function(){this._map.clear()},m.prototype.keys=function(){return this._map.keys()},m.prototype.values=function(){return this._map.values()},m.prototype.entries=function(){return this._map.entries()},m.prototype["@@iterator"]=function(){return this.keys()},m.prototype[s]=function(){return this.keys()},m}()}function As(){var m=16,b=f.create(),k=S();return function(){function D(){this._key=S()}return D.prototype.has=function(V){var H=P(V,!1);return H!==void 0?f.has(H,this._key):!1},D.prototype.get=function(V){var H=P(V,!1);return H!==void 0?f.get(H,this._key):void 0},D.prototype.set=function(V,H){var qe=P(V,!0);return qe[this._key]=H,this},D.prototype.delete=function(V){var H=P(V,!1);return H!==void 0?delete H[this._key]:!1},D.prototype.clear=function(){this._key=S()},D}();function S(){var D;do D="@@WeakMap@@"+B();while(f.has(b,D));return b[D]=!0,D}function P(D,V){if(!t.call(D,k)){if(!V)return;Object.defineProperty(D,k,{value:f.create()})}return D[k]}function ve(D,V){for(var H=0;H<V;++H)D[H]=Math.random()*255|0;return D}function N(D){return typeof Uint8Array=="function"?typeof crypto<"u"?crypto.getRandomValues(new Uint8Array(D)):typeof msCrypto<"u"?msCrypto.getRandomValues(new Uint8Array(D)):ve(new Uint8Array(D),D):ve(new Array(D),D)}function B(){var D=N(m);D[6]=D[6]&79|64,D[8]=D[8]&191|128;for(var V="",H=0;H<m;++H){var qe=D[H];(H===4||H===6||H===8)&&(V+="-"),qe<16&&(V+="0"),V+=qe.toString(16).toLowerCase()}return V}}function an(m){return m.__=void 0,delete m.__,m}})})(Ri||(Ri={}));const Yt=class Yt{constructor(e,t,n){d(this,"actionUrl");d(this,"queue");d(this,"allowed");d(this,"doWork");this.actionUrl=e,this.queue=t,this.allowed=n}async run(e,t,n){t===void 0&&(t=Se.apiClient.url),n||(n=Pt(Se.apiClient.httpClient));let r=await n.post(t+"/"+this.actionUrl,e),s=r;if(s&&s.queuedJobId){let o=T.actionInfo.startBusyWithProgress();try{let a;if(await T.actionInfo.runActionWithoutBlockingUI(async()=>{for(;!a||!a.done;)a&&await new Promise(l=>setTimeout(()=>{l(void 0)},200)),a=await n.post(t+"/"+Yt.apiUrlForJobStatus,{queuedJobId:r.queuedJobId}),a.progress&&o.progress(a.progress)}),a.error)throw a.error;return o.progress(1),a.result}finally{o.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(o){o.isForbiddenError?r.forbidden():r.error(o,void 0)}})}};d(Yt,"apiUrlForJobStatus","jobStatusInQueue");let At=Yt;class Dn extends Error{constructor(t="Forbidden"){super(t);d(this,"isForbiddenError",!0)}}class ha extends At{constructor(t,n,r,s){super(t,r.queue??!1,r.allowed);d(this,"types");d(this,"options");d(this,"originalMethod");this.types=n,this.options=r,this.originalMethod=s}async execute(t,n,r){let s={data:{}},o=n.dataProvider;return await xi(n,async()=>{if(!n.isAllowedForInstance(void 0,this.options.allowed))throw new Dn;t.args=await $r(this.types(),t.args,n,o,r);try{s.data=await this.originalMethod(t.args)}catch(a){throw a}}),s}}function Re(i){return(e,t,n)=>{const r=typeof t=="string"?t:t.name.toString(),s=n?n.value:e;let o=s;Hr(e);function a(){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 ha((i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+r,()=>a(),i,c=>s.apply(void 0,c));return u.doWork=async(c,h,p,y)=>(c=Li(a(),c),i.blockUser===!1?await T.actionInfo.runActionWithoutBlockingUI(async()=>(await u.run({args:c},p,y)).data):(await u.run({args:c},p,y)).data),o=async function(...c){return Tn()?await s.apply(this,c):await u.doWork(c,void 0)},Mi(e,o),o[Cn]=u,n?(n.value=o,n):o}let l=T.classHelpers.get(e.constructor);l||(l=new Co,T.classHelpers.set(e.constructor,l));let f={__register(u){let c=new Pe;for(const h of l.classes.keys()){let p=l.classes.get(h);p.key||(p.key=c.repo(h).metadata.key),u(p.key+"/"+(i!=null&&i.apiPrefix?i.apiPrefix+"/":"")+r,i?i.queue??!1:!1,i.allowed,async(y,_,w)=>{y.args=y.args.map(I=>Qr(I)?void 0:I);let v=i.allowed;try{let I=_,E;await xi(I,async()=>{if(y.args=await $r(a(),y.args,I,I.dataProvider,w),T.allEntities.includes(h)){let M=I.repo(h),U;const ne=y.rowInfo;if(ne.isNewRow)U=M.create(),await M.getEntityRef(U)._updateEntityBasedOnApi(ne.data);else{let ue=await M.find({where:{...M.metadata.idMetadata.getIdFilter(ne.id),$and:[M.metadata.options.apiPrefilter??{}]}});if(ue.length!=1)throw new Error("not found or too many matches");U=ue[0],await M.getEntityRef(U)._updateEntityBasedOnApi(ne.data)}if(!I.isAllowedForInstance(U,v))throw new Dn;let re=te(U);await re.__validateEntity();try{E={result:await s.apply(U,y.args),rowInfo:{data:await re.toApiJson(),isNewRow:re.isNew(),wasChanged:re.wasChanged(),id:re.getOriginalId()}}}catch(ue){throw re.catchSaveErrors(ue)}}else{let M=new h(I,I.dataProvider),U=Oi(M,I);if(await U._updateEntityBasedOnApi(y.fields),!I.isAllowedForInstance(M,v))throw new Dn;await U.__validateEntity();try{E={result:await s.apply(M,y.args),fields:await U.toApiJson()}}catch(ne){throw U.catchSaveErrors(ne)}}}),w.success(E)}catch(I){I.isForbiddenError?w.forbidden():w.error(I,void 0)}})}},doWork:async function(u,c,h,p){if(u=Li(a(),u),T.allEntities.includes(e.constructor)){let y=te(c);await y.__validateEntity();let _=l.classes.get(c.constructor);_.key||(_.key=y.repository.metadata.key+"_methods");try{let w=await new class extends At{constructor(){super(...arguments);d(this,"execute")}}(_.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()}},h,p);return await y._updateEntityBasedOnApi(w.rowInfo.data,!0),w.result}catch(w){throw y.catchSaveErrors(w)}}else{let y=Oi(c,void 0);try{await y.__validateEntity();let _=await new class extends At{constructor(){super(...arguments);d(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()},h,p);return await y._updateEntityBasedOnApi(_.fields),_.result}catch(_){throw y.catchSaveErrors(_)}}}};return o=async function(...u){let c=this;return Tn()?await s.apply(c,u):f.doWork(u,c)},Mi(e.constructor,o),o[Cn]=f,n?(n.value=o,n):o}}const pa={_isUndefined:!0};function Mi(i,e){(i[Bi]||(i[Bi]=[])).push(e),T.actionInfo.allActions.push(e)}function Qr(i){return i&&i._isUndefined}class Ni{constructor(e){d(this,"res");this.res=e}progress(e){this.res.progress(e)}}function Li(i,e){if(i)for(let t=0;t<i.length;t++){const n=i[t];for(const r of[Pe,ct])(e[t]instanceof r||n==r)&&(e[t]=void 0);if(e[t]!=null){let r={valueType:n};if(r=xn(r,new Pe),Oe(n,!1)!=null){let o=te(e[t]);e[t]=o.getId()}r.valueConverter&&(e[t]=r.valueConverter.toJson(e[t]))}}return e.map(t=>t!==void 0?t:pa)}async function $r(i,e,t,n,r){for(let s=0;s<e.length;s++){const o=e[s];Qr(o)&&(e[s]=void 0)}if(i)for(let s=0;s<i.length;s++)if(e.length<s&&e.push(void 0),i[s]==Pe||i[s]==Pe)e[s]=t;else if(i[s]==ct&&n)e[s]=n;else if(i[s]==Ni)e[s]=new Ni(r);else{let o={valueType:i[s]};o=xn(o,t),o.valueConverter&&(e[s]=o.valueConverter.fromJson(e[s])),Oe(i[s],!1)!=null&&(e[s]===null||e[s]===void 0||(e[s]=await t.repo(i[s]).findId(e[s])))}return e}const Bi=Symbol.for("classBackendMethodsArray");T.actionInfo;function sn(i){return i}var ya=Object.defineProperty,ma=Object.getOwnPropertyDescriptor,Me=(i,e,t,n)=>{for(var r=ma(e,t),s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(e,t,r)||r);return r&&ya(e,t,r),r},ee;const Fe=(ee=class{static async signOut(){return await ee.signOutFn()}static async signInDemo(e){return await ee.signInDemoFn(e)}static async invite(e){return await ee.inviteFn(e)}static async signUpPassword(e,t){return await ee.signUpPasswordFn(e,t)}static async signInPassword(e,t){return await ee.signInPasswordFn(e,t)}static async forgotPassword(e){return await ee.forgotPasswordFn(e)}static async resetPassword(e,t){return await ee.resetPasswordFn(e,t)}static async signInOTP(e){return await ee.signInOTPFn(e)}static async verifyOtp(e,t){return await ee.verifyOtpFn(e,t)}static async signInOAuthGetUrl(e){return await ee.signInOAuthGetUrlFn(e)}},d(ee,"signOutFn"),d(ee,"signInDemoFn"),d(ee,"inviteFn"),d(ee,"signUpPasswordFn"),d(ee,"signInPasswordFn"),d(ee,"forgotPasswordFn"),d(ee,"resetPasswordFn"),d(ee,"signInOTPFn"),d(ee,"verifyOtpFn"),d(ee,"signInOAuthGetUrlFn"),ee);Me([Re({allowed:!0})],Fe,"signOut");Me([Re({allowed:!0})],Fe,"signInDemo");Me([Re({allowed:!0})],Fe,"invite");Me([Re({allowed:!0})],Fe,"signUpPassword");Me([Re({allowed:!0})],Fe,"signInPassword");Me([Re({allowed:!0})],Fe,"forgotPassword");Me([Re({allowed:!0})],Fe,"resetPassword");Me([Re({allowed:!0})],Fe,"signInOTP");Me([Re({allowed:!0})],Fe,"verifyOtp");Me([Re({allowed:!0})],Fe,"signInOAuthGetUrl");let We=Fe;function yt(i){i.focus()}const bt="src/lib/modules/auth/components/ForgotPassword.svelte";function Rn(i){var w;let e,t,n,r,s,o,a,l,f,u,c=((w=i[1].ui)==null?void 0:w.strings.send_password_reset_instructions)+"",h,p,y;const _={c:function(){var I;e=q("div"),t=q("p"),n=ie(i[2]),r=ie(i[3]),s=x(),o=q("form"),a=q("input"),f=x(),u=q("button"),h=ie(c),Q(t,"class","message"),Ue(t,"error",i[2]),j(t,bt,27,2,528),Q(a,"type","text"),Q(a,"placeholder",l=(I=i[1].ui)==null?void 0:I.strings.email_placeholder),j(a,bt,29,4,644),j(u,bt,35,4,791),Q(o,"class","s-KT008SdmQprk"),j(o,bt,28,2,599),Q(e,"class","login"),j(e,bt,26,0,506)},l:function(I){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(I,E){G(I,e,E),C(e,t),C(t,n),C(t,r),C(e,s),C(e,o),C(o,a),ke(a,i[0]),C(o,f),C(o,u),C(u,h),p||(y=[en(yt.call(null,a)),Ce(a,"input",i[5]),Ce(o,"submit",tn(i[4]),!1,!0,!1,!1)],p=!0)},p:function(I,[E]){var M,U;E&4&&de(n,I[2]),E&4&&Ue(t,"error",I[2]),E&2&&l!==(l=(M=I[1].ui)==null?void 0:M.strings.email_placeholder)&&Q(a,"placeholder",l),E&1&&a.value!==I[0]&&ke(a,I[0]),E&2&&c!==(c=((U=I[1].ui)==null?void 0:U.strings.send_password_reset_instructions)+"")&&de(h,c)},i:le,o:le,d:function(I){I&&X(e),p=!1,dt(y)}};return J("SvelteRegisterBlock",{block:_,id:Rn.name,type:"component",source:"",ctx:i}),_}function wa(i,e,t){let{$$slots:n={},$$scope:r}=e;tt("ForgotPassword",n,[]);let{firstlyDataAuth:s}=e,{email:o=""}=e,a="",l="";async function f(){try{await We.forgotPassword(o),window.location.href="/ff/auth/sign-in"}catch(h){h&&t(2,a=h.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(h=>{!~u.indexOf(h)&&h.slice(0,2)!=="$$"&&h!=="slot"&&console.warn(`<ForgotPassword> was created with unknown prop '${h}'`)});function c(){o=this.value,t(0,o)}return i.$$set=h=>{"firstlyDataAuth"in h&&t(1,s=h.firstlyDataAuth),"email"in h&&t(0,o=h.email)},i.$capture_state=()=>({isError:sn,Auth:We,autofocus:yt,firstlyDataAuth:s,email:o,msgError:a,msgSuccess:l,forgot:f}),i.$inject_state=h=>{"firstlyDataAuth"in h&&t(1,s=h.firstlyDataAuth),"email"in h&&t(0,o=h.email),"msgError"in h&&t(2,a=h.msgError),"msgSuccess"in h&&t(3,l=h.msgSuccess)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[o,s,a,l,f,c]}class Gr extends Ye{constructor(e){super(e),et(this,e,wa,Rn,ht,{firstlyDataAuth:1,email:0}),J("SvelteRegisterComponent",{component:this,tagName:"ForgotPassword",options:e,id:Rn.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 at="src/lib/modules/auth/components/ResetPassword.svelte";function Mn(i){var re,ue,Ee;let e,t,n,r,s,o,a=((re=i[2].ui)==null?void 0:re.strings.password)+"",l,f,u,c,h=((ue=i[2].ui)==null?void 0:ue.strings.confirm)+"",p,y,_,w,v,I=((Ee=i[2].ui)==null?void 0:Ee.strings.reset)+"",E,M,U;const ne={c:function(){e=q("div"),t=q("p"),n=ie(i[3]),r=ie(i[4]),s=x(),o=q("form"),l=ie(a),f=x(),u=q("input"),c=x(),p=ie(h),y=x(),_=q("input"),w=x(),v=q("button"),E=ie(I),Q(t,"class","message"),Ue(t,"error",i[3]),j(t,at,28,2,621),Q(u,"type","password"),j(u,at,31,4,779),Q(_,"type","password"),j(_,at,33,4,874),j(v,at,34,4,927),Q(o,"class","s-N0DaQgJ_T5_C"),j(o,at,29,2,692),Q(e,"class","login"),j(e,at,27,0,599)},l:function(Y){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(Y,g){G(Y,e,g),C(e,t),C(t,n),C(t,r),C(e,s),C(e,o),C(o,l),C(o,f),C(o,u),ke(u,i[0]),C(o,c),C(o,p),C(o,y),C(o,_),ke(_,i[1]),C(o,w),C(o,v),C(v,E),M||(U=[Ce(u,"input",i[6]),Ce(_,"input",i[7]),Ce(o,"submit",tn(i[5]),!1,!0,!1,!1)],M=!0)},p:function(Y,[g]){var O,A,W;g&8&&de(n,Y[3]),g&16&&de(r,Y[4]),g&8&&Ue(t,"error",Y[3]),g&4&&a!==(a=((O=Y[2].ui)==null?void 0:O.strings.password)+"")&&de(l,a),g&1&&u.value!==Y[0]&&ke(u,Y[0]),g&4&&h!==(h=((A=Y[2].ui)==null?void 0:A.strings.confirm)+"")&&de(p,h),g&2&&_.value!==Y[1]&&ke(_,Y[1]),g&4&&I!==(I=((W=Y[2].ui)==null?void 0:W.strings.reset)+"")&&de(E,I)},i:le,o:le,d:function(Y){Y&&X(e),M=!1,dt(U)}};return J("SvelteRegisterBlock",{block:ne,id:Mn.name,type:"component",source:"",ctx:i}),ne}function ga(i,e,t){let{$$slots:n={},$$scope:r}=e;tt("ResetPassword",n,[]);let{firstlyDataAuth:s}=e,{password1:o=""}=e,{password2:a=""}=e,l="",f="";async function u(){t(3,l=""),t(4,f="");const y=new URL(location.href).searchParams.get("token");try{await We.resetPassword(y??"",o),window.location.href="/"}catch(_){_&&t(3,l=_.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 h(){o=this.value,t(0,o)}function p(){a=this.value,t(1,a)}return i.$$set=y=>{"firstlyDataAuth"in y&&t(2,s=y.firstlyDataAuth),"password1"in y&&t(0,o=y.password1),"password2"in y&&t(1,a=y.password2)},i.$capture_state=()=>({isError:sn,Auth:We,firstlyDataAuth:s,password1:o,password2:a,msgError:l,msgSuccess:f,reset:u}),i.$inject_state=y=>{"firstlyDataAuth"in y&&t(2,s=y.firstlyDataAuth),"password1"in y&&t(0,o=y.password1),"password2"in y&&t(1,a=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),[o,a,s,l,f,u,h,p]}class Xr extends Ye{constructor(e){super(e),et(this,e,ga,Mn,ht,{firstlyDataAuth:2,password1:0,password2:1}),J("SvelteRegisterComponent",{component:this,tagName:"ResetPassword",options:e,id:Mn.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:Ge}=Jn,Qe="src/lib/modules/auth/components/SignIn.svelte";function Nn(i){var Ee,be,Y;let e,t,n,r,s,o,a=((Ee=i[1].ui)==null?void 0:Ee.strings.email)+"",l,f,u,c,h,p,y=((be=i[1].ui)==null?void 0:be.strings.password)+"",_,w,v,I,E,M=((Y=i[1].ui)==null?void 0:Y.strings.btn_sign_in)+"",U,ne,re;const ue={c:function(){var O;e=q("form"),t=q("p"),n=ie(i[3]),r=ie(i[4]),s=x(),o=q("label"),l=ie(a),f=x(),u=q("input"),h=x(),p=q("label"),_=ie(y),w=x(),v=q("input"),I=x(),E=q("button"),U=ie(M),Q(t,"class","message s-85Tmcm64bnMI"),Ue(t,"error",i[3]),j(t,Qe,37,4,718),Q(u,"type","text"),Q(u,"placeholder",c=(O=i[1].ui)==null?void 0:O.strings.email_placeholder),j(u,Qe,40,6,847),j(o,Qe,38,4,791),Q(v,"type","password"),j(v,Qe,49,6,1076),j(p,Qe,47,4,1017),j(E,Qe,51,4,1141),Q(e,"class","s-85Tmcm64bnMI"),j(e,Qe,36,2,673)},m:function(O,A){G(O,e,A),C(e,t),C(t,n),C(t,r),C(e,s),C(e,o),C(o,l),C(o,f),C(o,u),ke(u,i[0]),C(e,h),C(e,p),C(p,_),C(p,w),C(p,v),ke(v,i[5]),C(e,I),C(e,E),C(E,U),ne||(re=[Ce(u,"input",i[7]),en(yt.call(null,u)),Ce(v,"input",i[8]),Ce(e,"submit",tn(i[6]),!1,!0,!1,!1)],ne=!0)},p:function(O,A){var W,K,se,Te;A&8&&de(n,O[3]),A&16&&de(r,O[4]),A&8&&Ue(t,"error",O[3]),A&2&&a!==(a=((W=O[1].ui)==null?void 0:W.strings.email)+"")&&de(l,a),A&2&&c!==(c=(K=O[1].ui)==null?void 0:K.strings.email_placeholder)&&Q(u,"placeholder",c),A&1&&u.value!==O[0]&&ke(u,O[0]),A&2&&y!==(y=((se=O[1].ui)==null?void 0:se.strings.password)+"")&&de(_,y),A&32&&v.value!==O[5]&&ke(v,O[5]),A&2&&M!==(M=((Te=O[1].ui)==null?void 0:Te.strings.btn_sign_in)+"")&&de(U,M)},d:function(O){O&&X(e),ne=!1,dt(re)}};return J("SvelteRegisterBlock",{block:ue,id:Nn.name,type:"if",source:"(27:0) {#if view == 'login'}",ctx:i}),ue}function Ln(i){let e,t=i[2]=="login"&&Nn(i);const n={c:function(){t&&t.c(),e=Un()},l:function(s){throw new Ge("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(s,o){t&&t.m(s,o),G(s,e,o)},p:function(s,[o]){s[2]=="login"?t?t.p(s,o):(t=Nn(s),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:le,o:le,d:function(s){s&&X(e),t&&t.d(s)}};return J("SvelteRegisterBlock",{block:n,id:Ln.name,type:"component",source:"",ctx:i}),n}function ba(i,e,t){let{$$slots:n={},$$scope:r}=e;tt("SignIn",n,[]);let{firstlyDataAuth:s}=e,{view:o="login"}=e,{email:a=""}=e,l="",f="",u;async function c(){t(3,l=""),t(4,f="");try{await We.signInPassword(a,u),window.location.href="/"}catch(w){w&&t(3,l=w.message??"")}}const h=()=>{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(w=>{!~p.indexOf(w)&&w.slice(0,2)!=="$$"&&w!=="slot"&&console.warn(`<SignIn> was created with unknown prop '${w}'`)});function y(){a=this.value,t(0,a)}function _(){u=this.value,t(5,u)}return i.$$set=w=>{"firstlyDataAuth"in w&&t(1,s=w.firstlyDataAuth),"view"in w&&t(2,o=w.view),"email"in w&&t(0,a=w.email)},i.$capture_state=()=>({Auth:We,isError:sn,autofocus:yt,firstlyDataAuth:s,view:o,email:a,msgError:l,msgSuccess:f,password:u,signIn:c,handlePin:h}),i.$inject_state=w=>{"firstlyDataAuth"in w&&t(1,s=w.firstlyDataAuth),"view"in w&&t(2,o=w.view),"email"in w&&t(0,a=w.email),"msgError"in w&&t(3,l=w.msgError),"msgSuccess"in w&&t(4,f=w.msgSuccess),"password"in w&&t(5,u=w.password)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[a,s,o,l,f,u,c,y,_]}class zr extends Ye{constructor(e){super(e),et(this,e,ba,Ln,ht,{firstlyDataAuth:1,view:2,email:0}),J("SvelteRegisterComponent",{component:this,tagName:"SignIn",options:e,id:Ln.name})}get firstlyDataAuth(){throw new Ge("<SignIn>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyDataAuth(e){throw new Ge("<SignIn>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get view(){throw new Ge("<SignIn>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set view(e){throw new Ge("<SignIn>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get email(){throw new Ge("<SignIn>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set email(e){throw new Ge("<SignIn>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const{Error:Xe}=Jn,$e="src/lib/modules/auth/components/SignUp.svelte";function Bn(i){var Ee,be,Y;let e,t,n,r,s,o,a=((Ee=i[1].ui)==null?void 0:Ee.strings.email)+"",l,f,u,c,h,p,y=((be=i[1].ui)==null?void 0:be.strings.password)+"",_,w,v,I,E,M=((Y=i[1].ui)==null?void 0:Y.strings.btn_sign_up)+"",U,ne,re;const ue={c:function(){var O;e=q("form"),t=q("p"),n=ie(i[3]),r=ie(i[4]),s=x(),o=q("label"),l=ie(a),f=x(),u=q("input"),h=x(),p=q("label"),_=ie(y),w=x(),v=q("input"),I=x(),E=q("button"),U=ie(M),Q(t,"class","message s-FRwn6sVlvC6z"),Ue(t,"error",i[3]),j(t,$e,37,4,718),Q(u,"type","text"),Q(u,"placeholder",c=(O=i[1].ui)==null?void 0:O.strings.email_placeholder),j(u,$e,40,6,847),j(o,$e,38,4,791),Q(v,"type","password"),j(v,$e,49,6,1076),j(p,$e,47,4,1017),j(E,$e,51,4,1141),Q(e,"class","s-FRwn6sVlvC6z"),j(e,$e,36,2,673)},m:function(O,A){G(O,e,A),C(e,t),C(t,n),C(t,r),C(e,s),C(e,o),C(o,l),C(o,f),C(o,u),ke(u,i[0]),C(e,h),C(e,p),C(p,_),C(p,w),C(p,v),ke(v,i[5]),C(e,I),C(e,E),C(E,U),ne||(re=[Ce(u,"input",i[7]),en(yt.call(null,u)),Ce(v,"input",i[8]),Ce(e,"submit",tn(i[6]),!1,!0,!1,!1)],ne=!0)},p:function(O,A){var W,K,se,Te;A&8&&de(n,O[3]),A&16&&de(r,O[4]),A&8&&Ue(t,"error",O[3]),A&2&&a!==(a=((W=O[1].ui)==null?void 0:W.strings.email)+"")&&de(l,a),A&2&&c!==(c=(K=O[1].ui)==null?void 0:K.strings.email_placeholder)&&Q(u,"placeholder",c),A&1&&u.value!==O[0]&&ke(u,O[0]),A&2&&y!==(y=((se=O[1].ui)==null?void 0:se.strings.password)+"")&&de(_,y),A&32&&v.value!==O[5]&&ke(v,O[5]),A&2&&M!==(M=((Te=O[1].ui)==null?void 0:Te.strings.btn_sign_up)+"")&&de(U,M)},d:function(O){O&&X(e),ne=!1,dt(re)}};return J("SvelteRegisterBlock",{block:ue,id:Bn.name,type:"if",source:"(27:0) {#if view == 'login'}",ctx:i}),ue}function qn(i){let e,t=i[2]=="login"&&Bn(i);const n={c:function(){t&&t.c(),e=Un()},l:function(s){throw new Xe("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(s,o){t&&t.m(s,o),G(s,e,o)},p:function(s,[o]){s[2]=="login"?t?t.p(s,o):(t=Bn(s),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:le,o:le,d:function(s){s&&X(e),t&&t.d(s)}};return J("SvelteRegisterBlock",{block:n,id:qn.name,type:"component",source:"",ctx:i}),n}function va(i,e,t){let{$$slots:n={},$$scope:r}=e;tt("SignUp",n,[]);let{firstlyDataAuth:s}=e,{view:o="login"}=e,{email:a=""}=e,l="",f="",u;async function c(){t(3,l=""),t(4,f="");try{await We.signUpPassword(a,u),window.location.href="/"}catch(w){w&&t(3,l=w.message??"")}}const h=()=>{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(w=>{!~p.indexOf(w)&&w.slice(0,2)!=="$$"&&w!=="slot"&&console.warn(`<SignUp> was created with unknown prop '${w}'`)});function y(){a=this.value,t(0,a)}function _(){u=this.value,t(5,u)}return i.$$set=w=>{"firstlyDataAuth"in w&&t(1,s=w.firstlyDataAuth),"view"in w&&t(2,o=w.view),"email"in w&&t(0,a=w.email)},i.$capture_state=()=>({Auth:We,isError:sn,autofocus:yt,firstlyDataAuth:s,view:o,email:a,msgError:l,msgSuccess:f,password:u,signIn:c,handlePin:h}),i.$inject_state=w=>{"firstlyDataAuth"in w&&t(1,s=w.firstlyDataAuth),"view"in w&&t(2,o=w.view),"email"in w&&t(0,a=w.email),"msgError"in w&&t(3,l=w.msgError),"msgSuccess"in w&&t(4,f=w.msgSuccess),"password"in w&&t(5,u=w.password)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[a,s,o,l,f,u,c,y,_]}class xr extends Ye{constructor(e){super(e),et(this,e,va,qn,ht,{firstlyDataAuth:1,view:2,email:0}),J("SvelteRegisterComponent",{component:this,tagName:"SignUp",options:e,id:qn.name})}get firstlyDataAuth(){throw new Xe("<SignUp>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set firstlyDataAuth(e){throw new Xe("<SignUp>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get view(){throw new Xe("<SignUp>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set view(e){throw new Xe("<SignUp>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get email(){throw new Xe("<SignUp>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set email(e){throw new Xe("<SignUp>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}const Ae="src/lib/modules/auth/Page.svelte";function Kr(i){var r;let e,t;e=new nt({props:{path:(r=i[1].ui)==null?void 0:r.paths.sign_up,$$slots:{default:[es]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(o,a){we(e,o,a),t=!0},p:function(o,a){const l={};a&65&&(l.$$scope={dirty:a,ctx:o}),e.$set(l)},i:function(o){t||($(e.$$.fragment,o),t=!0)},o:function(o){z(e.$$.fragment,o),t=!1},d:function(o){ge(e,o)}};return J("SvelteRegisterBlock",{block:n,id:Kr.name,type:"if",source:"(14:6) {#if firstlyDataAuth.ui?.paths.sign_up}",ctx:i}),n}function Zr(i){let e,t;e=new pt({props:{href:i[1].ui.paths.sign_in,$$slots:{default:[Yr]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(s,o){we(e,s,o),t=!0},p:function(s,o){const a={};o&64&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i:function(s){t||($(e.$$.fragment,s),t=!0)},o:function(s){z(e.$$.fragment,s),t=!1},d:function(s){ge(e,s)}};return J("SvelteRegisterBlock",{block:n,id:Zr.name,type:"if",source:"(19:12) {#if firstlyDataAuth.ui.paths.sign_in}",ctx:i}),n}function Yr(i){let e=i[1].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=ie(e)},m:function(s,o){G(s,t,o)},p:le,d:function(s){s&&X(t)}};return J("SvelteRegisterBlock",{block:n,id:Yr.name,type:"slot",source:"(20:14) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function es(i){let e,t,n,r,s;function o(u){i[3](u)}let a={firstlyDataAuth:i[1]};i[0]!==void 0&&(a.email=i[0]),e=new xr({props:a,$$inline:!0}),Wn.push(()=>Vn(e,"email",o));let l=i[1].ui.paths.sign_in&&Zr(i);const f={c:function(){me(e.$$.fragment),n=x(),r=q("div"),l&&l.c(),Q(r,"class","form-footer s-NO-a_LAEXXH5"),j(r,Ae,22,10,599)},m:function(c,h){we(e,c,h),G(c,n,h),G(c,r,h),l&&l.m(r,null),s=!0},p:function(c,h){const p={};!t&&h&1&&(t=!0,p.email=c[0],Hn(()=>t=!1)),e.$set(p),c[1].ui.paths.sign_in&&l.p(c,h)},i:function(c){s||($(e.$$.fragment,c),$(l),s=!0)},o:function(c){z(e.$$.fragment,c),z(l),s=!1},d:function(c){c&&(X(n),X(r)),ge(e,c),l&&l.d()}};return J("SvelteRegisterBlock",{block:f,id:es.name,type:"slot",source:"(15:8) <Route path={firstlyDataAuth.ui?.paths.sign_up}>",ctx:i}),f}function ts(i){var r;let e,t;e=new nt({props:{path:(r=i[1].ui)==null?void 0:r.paths.sign_in,$$slots:{default:[os]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(o,a){we(e,o,a),t=!0},p:function(o,a){const l={};a&65&&(l.$$scope={dirty:a,ctx:o}),e.$set(l)},i:function(o){t||($(e.$$.fragment,o),t=!0)},o:function(o){z(e.$$.fragment,o),t=!1},d:function(o){ge(e,o)}};return J("SvelteRegisterBlock",{block:n,id:ts.name,type:"if",source:"(28:6) {#if firstlyDataAuth.ui?.paths.sign_in}",ctx:i}),n}function ns(i){let e,t;e=new pt({props:{href:i[1].ui.paths.forgot_password,$$slots:{default:[is]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(s,o){we(e,s,o),t=!0},p:function(s,o){const a={};o&64&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i:function(s){t||($(e.$$.fragment,s),t=!0)},o:function(s){z(e.$$.fragment,s),t=!1},d:function(s){ge(e,s)}};return J("SvelteRegisterBlock",{block:n,id:ns.name,type:"if",source:"(33:12) {#if firstlyDataAuth.ui?.paths.forgot_password}",ctx:i}),n}function is(i){let e=i[1].ui.strings.forgot_password+"",t;const n={c:function(){t=ie(e)},m:function(s,o){G(s,t,o)},p:le,d:function(s){s&&X(t)}};return J("SvelteRegisterBlock",{block:n,id:is.name,type:"slot",source:"(34:14) <Link href={firstlyDataAuth.ui.paths.forgot_password}>",ctx:i}),n}function rs(i){let e,t;e=new pt({props:{href:i[1].ui.paths.sign_up,$$slots:{default:[ss]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(s,o){we(e,s,o),t=!0},p:function(s,o){const a={};o&64&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i:function(s){t||($(e.$$.fragment,s),t=!0)},o:function(s){z(e.$$.fragment,s),t=!1},d:function(s){ge(e,s)}};return J("SvelteRegisterBlock",{block:n,id:rs.name,type:"if",source:"(39:12) {#if firstlyDataAuth.ui?.paths.sign_up}",ctx:i}),n}function ss(i){let e=i[1].ui.strings.btn_sign_up+"",t;const n={c:function(){t=ie(e)},m:function(s,o){G(s,t,o)},p:le,d:function(s){s&&X(t)}};return J("SvelteRegisterBlock",{block:n,id:ss.name,type:"slot",source:"(40:14) <Link href={firstlyDataAuth.ui.paths.sign_up}>",ctx:i}),n}function os(i){var y,_;let e,t,n,r,s,o,a,l;function f(w){i[4](w)}let u={firstlyDataAuth:i[1]};i[0]!==void 0&&(u.email=i[0]),e=new zr({props:u,$$inline:!0}),Wn.push(()=>Vn(e,"email",f));let c=((y=i[1].ui)==null?void 0:y.paths.forgot_password)&&ns(i),h=((_=i[1].ui)==null?void 0:_.paths.sign_up)&&rs(i);const p={c:function(){me(e.$$.fragment),n=x(),r=q("div"),c&&c.c(),s=x(),o=q("hr"),a=x(),h&&h.c(),j(o,Ae,42,12,1317),Q(r,"class","form-footer s-NO-a_LAEXXH5"),j(r,Ae,36,10,1049)},m:function(v,I){we(e,v,I),G(v,n,I),G(v,r,I),c&&c.m(r,null),C(r,s),C(r,o),C(r,a),h&&h.m(r,null),l=!0},p:function(v,I){var M,U;const E={};!t&&I&1&&(t=!0,E.email=v[0],Hn(()=>t=!1)),e.$set(E),(M=v[1].ui)!=null&&M.paths.forgot_password&&c.p(v,I),(U=v[1].ui)!=null&&U.paths.sign_up&&h.p(v,I)},i:function(v){l||($(e.$$.fragment,v),$(c),$(h),l=!0)},o:function(v){z(e.$$.fragment,v),z(c),z(h),l=!1},d:function(v){v&&(X(n),X(r)),ge(e,v),c&&c.d(),h&&h.d()}};return J("SvelteRegisterBlock",{block:p,id:os.name,type:"slot",source:"(29:8) <Route path={firstlyDataAuth.ui?.paths.sign_in}>",ctx:i}),p}function as(i){var r;let e,t;e=new nt({props:{path:(r=i[1].ui)==null?void 0:r.paths.forgot_password,$$slots:{default:[fs]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(o,a){we(e,o,a),t=!0},p:function(o,a){const l={};a&65&&(l.$$scope={dirty:a,ctx:o}),e.$set(l)},i:function(o){t||($(e.$$.fragment,o),t=!0)},o:function(o){z(e.$$.fragment,o),t=!1},d:function(o){ge(e,o)}};return J("SvelteRegisterBlock",{block:n,id:as.name,type:"if",source:"(48:6) {#if firstlyDataAuth.ui?.paths.forgot_password}",ctx:i}),n}function ls(i){let e,t;e=new pt({props:{href:i[1].ui.paths.sign_in,$$slots:{default:[us]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(s,o){we(e,s,o),t=!0},p:function(s,o){const a={};o&64&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i:function(s){t||($(e.$$.fragment,s),t=!0)},o:function(s){z(e.$$.fragment,s),t=!1},d:function(s){ge(e,s)}};return J("SvelteRegisterBlock",{block:n,id:ls.name,type:"if",source:"(53:12) {#if firstlyDataAuth.ui?.paths.sign_in}",ctx:i}),n}function us(i){let e=i[1].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=ie(e)},m:function(s,o){G(s,t,o)},p:le,d:function(s){s&&X(t)}};return J("SvelteRegisterBlock",{block:n,id:us.name,type:"slot",source:"(54:14) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function fs(i){var u;let e,t,n,r,s;function o(c){i[5](c)}let a={firstlyDataAuth:i[1]};i[0]!==void 0&&(a.email=i[0]),e=new Gr({props:a,$$inline:!0}),Wn.push(()=>Vn(e,"email",o));let l=((u=i[1].ui)==null?void 0:u.paths.sign_in)&&ls(i);const f={c:function(){me(e.$$.fragment),n=x(),r=q("div"),l&&l.c(),Q(r,"class","form-footer s-NO-a_LAEXXH5"),j(r,Ae,56,10,1769)},m:function(h,p){we(e,h,p),G(h,n,p),G(h,r,p),l&&l.m(r,null),s=!0},p:function(h,p){var _;const y={};!t&&p&1&&(t=!0,y.email=h[0],Hn(()=>t=!1)),e.$set(y),(_=h[1].ui)!=null&&_.paths.sign_in&&l.p(h,p)},i:function(h){s||($(e.$$.fragment,h),$(l),s=!0)},o:function(h){z(e.$$.fragment,h),z(l),s=!1},d:function(h){h&&(X(n),X(r)),ge(e,h),l&&l.d()}};return J("SvelteRegisterBlock",{block:f,id:fs.name,type:"slot",source:"(49:8) <Route path={firstlyDataAuth.ui?.paths.forgot_password}>",ctx:i}),f}function cs(i){var r;let e,t;e=new nt({props:{path:(r=i[1].ui)==null?void 0:r.paths.reset_password,$$slots:{default:[ps]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(o,a){we(e,o,a),t=!0},p:function(o,a){const l={};a&64&&(l.$$scope={dirty:a,ctx:o}),e.$set(l)},i:function(o){t||($(e.$$.fragment,o),t=!0)},o:function(o){z(e.$$.fragment,o),t=!1},d:function(o){ge(e,o)}};return J("SvelteRegisterBlock",{block:n,id:cs.name,type:"if",source:"(62:6) {#if firstlyDataAuth.ui?.paths.reset_password}",ctx:i}),n}function ds(i){let e,t;e=new pt({props:{href:i[1].ui.paths.sign_in,$$slots:{default:[hs]},$$scope:{ctx:i}},$$inline:!0});const n={c:function(){me(e.$$.fragment)},m:function(s,o){we(e,s,o),t=!0},p:function(s,o){const a={};o&64&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i:function(s){t||($(e.$$.fragment,s),t=!0)},o:function(s){z(e.$$.fragment,s),t=!1},d:function(s){ge(e,s)}};return J("SvelteRegisterBlock",{block:n,id:ds.name,type:"if",source:"(67:12) {#if firstlyDataAuth.ui?.paths.sign_in}",ctx:i}),n}function hs(i){let e=i[1].ui.strings.back_to_sign_in+"",t;const n={c:function(){t=ie(e)},m:function(s,o){G(s,t,o)},p:le,d:function(s){s&&X(t)}};return J("SvelteRegisterBlock",{block:n,id:hs.name,type:"slot",source:"(68:14) <Link href={firstlyDataAuth.ui.paths.sign_in}>",ctx:i}),n}function ps(i){var a;let e,t,n,r;e=new Xr({props:{firstlyDataAuth:i[1]},$$inline:!0});let s=((a=i[1].ui)==null?void 0:a.paths.sign_in)&&ds(i);const o={c:function(){me(e.$$.fragment),t=x(),n=q("div"),s&&s.c(),Q(n,"class","form-footer s-NO-a_LAEXXH5"),j(n,Ae,70,10,2230)},m:function(f,u){we(e,f,u),G(f,t,u),G(f,n,u),s&&s.m(n,null),r=!0},p:function(f,u){var c;(c=f[1].ui)!=null&&c.paths.sign_in&&s.p(f,u)},i:function(f){r||($(e.$$.fragment,f),$(s),r=!0)},o:function(f){z(e.$$.fragment,f),z(s),r=!1},d:function(f){f&&(X(t),X(n)),ge(e,f),s&&s.d()}};return J("SvelteRegisterBlock",{block:o,id:ps.name,type:"slot",source:"(63:8) <Route path={firstlyDataAuth.ui?.paths.reset_password}>",ctx:i}),o}function ys(i){let e,t,n,r,s;const o={c:function(){e=q("div"),t=q("small"),t.textContent="- 404 -",n=x(),r=q("div"),s=q("small"),s.textContent="Nothing to see here",j(t,Ae,82,10,2581),Q(e,"class","fallback s-NO-a_LAEXXH5"),j(e,Ae,81,8,2548),j(s,Ae,85,10,2660),Q(r,"class","fallback s-NO-a_LAEXXH5"),j(r,Ae,84,8,2627)},m:function(l,f){G(l,e,f),C(e,t),G(l,n,f),G(l,r,f),C(r,s)},p:le,d:function(l){l&&(X(e),X(n),X(r))}};return J("SvelteRegisterBlock",{block:o,id:ys.name,type:"slot",source:"(76:6) <Route fallback>",ctx:i}),o}function ms(i){var h,p,y,_;let e,t,n,r,s,o,a=((h=i[1].ui)==null?void 0:h.paths.sign_up)&&Kr(i),l=((p=i[1].ui)==null?void 0:p.paths.sign_in)&&ts(i),f=((y=i[1].ui)==null?void 0:y.paths.forgot_password)&&as(i),u=((_=i[1].ui)==null?void 0:_.paths.reset_password)&&cs(i);s=new nt({props:{fallback:!0,$$slots:{default:[ys]},$$scope:{ctx:i}},$$inline:!0});const c={c:function(){a&&a.c(),e=x(),l&&l.c(),t=x(),f&&f.c(),n=x(),u&&u.c(),r=x(),me(s.$$.fragment)},m:function(v,I){a&&a.m(v,I),G(v,e,I),l&&l.m(v,I),G(v,t,I),f&&f.m(v,I),G(v,n,I),u&&u.m(v,I),G(v,r,I),we(s,v,I),o=!0},p:function(v,I){var M,U,ne,re;(M=v[1].ui)!=null&&M.paths.sign_up&&a.p(v,I),(U=v[1].ui)!=null&&U.paths.sign_in&&l.p(v,I),(ne=v[1].ui)!=null&&ne.paths.forgot_password&&f.p(v,I),(re=v[1].ui)!=null&&re.paths.reset_password&&u.p(v,I);const E={};I&64&&(E.$$scope={dirty:I,ctx:v}),s.$set(E)},i:function(v){o||($(a),$(l),$(f),$(u),$(s.$$.fragment,v),o=!0)},o:function(v){z(a),z(l),z(f),z(u),z(s.$$.fragment,v),o=!1},d:function(v){v&&(X(e),X(t),X(n),X(r)),a&&a.d(v),l&&l.d(v),f&&f.d(v),u&&u.d(v),ge(s,v)}};return J("SvelteRegisterBlock",{block:c,id:ms.name,type:"slot",source:"(13:4) <Route>",ctx:i}),c}function jn(i){let e,t,n,r;n=new nt({props:{$$slots:{default:[ms]},$$scope:{ctx:i}},$$inline:!0});const s={c:function(){e=q("div"),t=q("div"),me(n.$$.fragment),Q(t,"class","form s-NO-a_LAEXXH5"),j(t,Ae,16,2,404),Q(e,"class","wrapper s-NO-a_LAEXXH5"),j(e,Ae,15,0,380)},l:function(a){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(a,l){G(a,e,l),C(e,t),we(n,t,null),r=!0},p:function(a,[l]){const f={};l&65&&(f.$$scope={dirty:l,ctx:a}),n.$set(f)},i:function(a){r||($(n.$$.fragment,a),r=!0)},o:function(a){z(n.$$.fragment,a),r=!1},d:function(a){a&&X(e),ge(n)}};return J("SvelteRegisterBlock",{block:s,id:jn.name,type:"component",source:"",ctx:i}),s}function _a(i,e,t){let{$$slots:n={},$$scope:r}=e;tt("Page",n,[]);let{firstlyData:s}=e,o=s.props,a="";i.$$.on_mount.push(function(){s===void 0&&!("firstlyData"in e||i.$$.bound[i.$$.props.firstlyData])&&console.warn("<Page> was created without expected prop 'firstlyData'")});const l=["firstlyData"];Object.keys(e).forEach(h=>{!~l.indexOf(h)&&h.slice(0,2)!=="$$"&&h!=="slot"&&console.warn(`<Page> was created with unknown prop '${h}'`)});function f(h){a=h,t(0,a)}function u(h){a=h,t(0,a)}function c(h){a=h,t(0,a)}return i.$$set=h=>{"firstlyData"in h&&t(2,s=h.firstlyData)},i.$capture_state=()=>({Link:pt,Route:nt,ForgotPassword:Gr,ResetPassword:Xr,SignIn:zr,SignUp:xr,firstlyData:s,firstlyDataAuth:o,email:a}),i.$inject_state=h=>{"firstlyData"in h&&t(2,s=h.firstlyData),"firstlyDataAuth"in h&&t(1,o=h.firstlyDataAuth),"email"in h&&t(0,a=h.email)},e&&"$$inject"in e&&i.$inject_state(e.$$inject),[a,o,s,f,u,c]}class Ca extends Ye{constructor(e){super(e),et(this,e,_a,jn,ht,{firstlyData:2}),J("SvelteRegisterComponent",{component:this,tagName:"Page",options:e,id:jn.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{Ca as default};
@@ -1,4 +0,0 @@
1
- export { v as default };
2
- declare class v extends l {
3
- }
4
- import { S as l } from "./index-QypqCYwC.js";
@@ -1 +0,0 @@
1
- import{S as l,b as d,a as f,d as i,h as m,M as p,t as u,n as r,z as h}from"./index-QypqCYwC.js";function c(a){let e;const n={c:function(){e=p("Hello from files")},l:function(t){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(t,o){u(t,e,o)},p:r,i:r,o:r,d:function(t){t&&h(e)}};return i("SvelteRegisterBlock",{block:n,id:c.name,type:"component",source:"",ctx:a}),n}function w(a,e){let{$$slots:n={},$$scope:s}=e;m("Page",n,[]);const t=[];return Object.keys(e).forEach(o=>{!~t.indexOf(o)&&o.slice(0,2)!=="$$"&&o!=="slot"&&console.warn(`<Page> was created with unknown prop '${o}'`)}),[]}class v extends l{constructor(e){super(e),d(this,e,w,c,f,{}),i("SvelteRegisterComponent",{component:this,tagName:"Page",options:e,id:c.name})}}export{v as default};