package Ġcom . p unto gr is . re cap . feature _ re cap . presentation . re cap _ detail Ċ Ċ import Ġandroidx . lifecycle . Saved State Handle Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . as LiveData Ċ import Ġandroidx . lifecycle . live Data Ċ import Ġcom . p unto gr is . re cap . core . domain . use _ case . GetCurrent Auth User UseCase Ċ import Ġcom . p unto gr is . re cap . core . domain . use _ case . is LoggedIn Ċ import Ġcom . p unto gr is . re cap . core . utils . Resource Ċ import Ġcom . p unto gr is . re cap . feature _ re cap . domain . model . Re cap Ċ import Ġcom . p unto gr is . re cap . feature _ re cap . domain . use _ case . Get Re cap Interactions UseCase Ċ import Ġcom . p unto gr is . re cap . feature _ re cap . domain . use _ case . Get Re cap UseCase Ċ import Ġdagger . h ilt . android . lifecycle . H ilt ViewModel Ċ import Ġkotlinx . coroutines . flow . Mutable State Flow Ċ import Ġkotlinx . coroutines . flow . as State Flow Ċ import Ġjavax . inject . Inject Ċ Ċ @ H ilt ViewModel Ċ class ĠRe cap ViewModel Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġget Re cap : ĠGet Re cap UseCase , ĊĠĠĠ Ġget Re cap Interactions : ĠGet Re cap Interactions UseCase , ĊĠĠĠ Ġprivate Ġval Ġsaved State Handle : ĠSaved State Handle , ĊĠĠĠ Ġprivate Ġval ĠgetCurrent Auth User UseCase : ĠGetCurrent Auth User UseCase Ċ ) Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġfun Ġre cap Id From Args () Ġ= ĊĠĠĠĠĠĠĠ Ġsaved State Handle . get < Re cap >(" re cap ") ?. id Ġ?: Ġsaved State Handle . get < String >(" re cap Id ") !! ĊĊĠĠĠ Ġval Ġre cap Interactions Ġ= Ġget Re cap Interactions ( re cap Id From Args ()). as LiveData () ĊĊĠĠĠ Ġprivate Ġval Ġ_ re cap Ġ= ĠMutable State Flow ( Re cap ()) ĊĠĠĠ Ġval Ġre cap Ġ= Ġ_ re cap . as State Flow () ĊĊĠĠĠ Ġval Ġre cap State Ġ= Ġlive Data Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġre cap Id Args Ġ= Ġsaved State Handle . get < String >(" re cap Id ") ĊĠĠĠĠĠĠĠ Ġif Ġ( re cap Id Args Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġemit ( get Re cap ( re cap Id Args )) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġemit ( Resource . Success ( saved State Handle . get < Re cap >(" re cap ") !! )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġupdate Re cap ( re cap : ĠRe cap ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ re cap . value Ġ= Ġre cap ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġis User LoggedIn () Ġ= ĠgetCurrent Auth User UseCase . is LoggedIn () Ċ Ċ }