{"version":3,"sources":["https://lively-kernel.org/lively4/lively4-jsx/src/client/reactive/components/rewritten/conduit/src/stores/userStore.js"],"names":["agent","UserStore","pullUser","user","updateUser","newUser","err","forgetUser","undefined"],"mappings":"AAAA;;;;;;;;;;;;;;;;;AAEOA,W;;;;;;;;;;;;;;;;;;;;;;;AAEP,YAAMC,SAAN,CAAgB;;AAEdC,mBAAW;AACT,0CAAmB,IAAnB;AACA,iKAAOF,KAAP,qCACQ,CAAC,EAAEG,IAAF,EAAD;AAAA;AACA,iIAAmBA,IAAnB;AADA,WADR,gBAGW;AACH,mDAAmB,KAAnB;AADG,WAHX;AAKD;;AAEDC,mBAAWC,OAAX,EAAoB;AAAA;;AAClB,2CAAoB,IAApB;AACA,mLAAOL,KAAP,yGAAuBK,OAAvB,cACQ,CAAC,EAAEF,IAAF,EAAD;AAAA;AACA,iIAAmBA,IAAnB;AADA,WADR,cAGSG,OAAO;AAAA;;AACZ,mDAA0B,8MAAgBA,GAAhB,wIAAqCA,GAArC,kCAA1B;AACD,WALH,gBAMW;AACH,oDAAoB,KAApB;AADG,WANX;AAQD;;AAEDC,qBAAa;AACX,+GAAmBC,SAAnB;AACD;AAzBa;;;;;;;;;;;;;;;;;;yBA4BD,2FAAIP,SAAJ,G","file":"userStore.js","sourcesContent":["'enable aexpr';\n\nimport agent from 'src/client/reactive/components/rewritten/conduit/src/agent.js';\n\nclass UserStore {\n\n  pullUser() {\n    this.loadingUser = true;\n    return agent.Auth.current()\n      .then(({ user }) => \n            this.currentUser = user)\n      .finally(() => \n            this.loadingUser = false);\n  }\n\n  updateUser(newUser) {\n    this.updatingUser = true;\n    return agent.Auth.save(newUser)\n      .then(({ user }) => \n            this.currentUser = user)\n      .catch(err => {\n        this.updatingUserErrors = err.response && err.response.body && err.response.body.errors;\n      })\n      .finally(() => \n            this.updatingUser = false);\n  }\n\n  forgetUser() {\n    this.currentUser = undefined;\n  }\n}\n\nexport default new UserStore();"]}