package Ġdev . in mo . micro _ utils . repos . map pers Ċ Ċ import Ġdev . in mo . micro _ utils . pagination . Pagination Ċ import Ġdev . in mo . micro _ utils . pagination . Pagination Result Ċ import Ġdev . in mo . micro _ utils . repos .* Ċ import Ġkotlinx . coroutines . flow . Flow Ċ import Ġkotlinx . coroutines . flow . map Ċ Ċ open Ġclass ĠMapper Read Standard KeyValue Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value >( ĊĠĠĠ Ġprivate Ġval Ġto : ĠRead Standard KeyValue Repo < To Key , ĠTo Value >, ĊĠĠĠ Ġmapper : ĠMapper Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value > Ċ ) Ġ: ĠRead Standard KeyValue Repo < From Key , ĠFrom Value >, ĠMapper Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value > Ġby Ġmapper Ġ{ ĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġget ( k : ĠFrom Key ): ĠFrom Value ? Ġ= Ġto . get ( ĊĠĠĠĠĠĠĠ Ġk . to Out Key () ĊĠĠĠ Ġ) Ġ? . to Inner Value () ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġvalues ( ĊĠĠĠĠĠĠĠ Ġpagination : ĠPagination , ĊĠĠĠĠĠĠĠ Ġreversed : ĠBoolean ĊĠĠĠ Ġ): ĠPagination Result < From Value > Ġ= Ġto . values ( ĊĠĠĠĠĠĠĠ Ġpagination , ĊĠĠĠĠĠĠĠ Ġreversed ĊĠĠĠ Ġ). let Ġ{ ĊĠĠĠĠĠĠĠ ĠPagination Result ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . page , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . pages Number , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . results . map Ġ{ Ġit . to Inner Value () Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . size ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġkeys ( ĊĠĠĠĠĠĠĠ Ġpagination : ĠPagination , ĊĠĠĠĠĠĠĠ Ġreversed : ĠBoolean ĊĠĠĠ Ġ): ĠPagination Result < From Key > Ġ= Ġto . keys ( ĊĠĠĠĠĠĠĠ Ġpagination , ĊĠĠĠĠĠĠĠ Ġreversed ĊĠĠĠ Ġ). let Ġ{ ĊĠĠĠĠĠĠĠ ĠPagination Result ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . page , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . pages Number , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . results . map Ġ{ Ġit . to Inner Key () Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . size ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġkeys ( ĊĠĠĠĠĠĠĠ Ġv : ĠFrom Value , ĊĠĠĠĠĠĠĠ Ġpagination : ĠPagination , ĊĠĠĠĠĠĠĠ Ġreversed : ĠBoolean ĊĠĠĠ Ġ): ĠPagination Result < From Key > Ġ= Ġto . keys ( ĊĠĠĠĠĠĠĠ Ġv . to Out Value (), ĊĠĠĠĠĠĠĠ Ġpagination , ĊĠĠĠĠĠĠĠ Ġreversed ĊĠĠĠ Ġ). let Ġ{ ĊĠĠĠĠĠĠĠ ĠPagination Result ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . page , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . pages Number , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . results . map Ġ{ Ġit . to Inner Key () Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . size ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġcontains ( key : ĠFrom Key ): ĠBoolean Ġ= Ġto . contains ( ĊĠĠĠĠĠĠĠ Ġkey . to Out Key () ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġcount (): ĠLong Ġ= Ġto . count () Ċ } Ċ Ċ @ Suppress (" NOTH ING _ TO _ INLINE ") Ċ inline Ġfun Ġ< From Key , ĠFrom Value , ĠTo Key , ĠTo Value > ĠRead Standard KeyValue Repo < To Key , ĠTo Value >. with Mapper ( ĊĠĠĠ Ġmapper : ĠMapper Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value > Ċ ): ĠRead Standard KeyValue Repo < From Key , ĠFrom Value > Ġ= ĠMapper Read Standard KeyValue Repo ( this , Ġmapper ) Ċ Ċ @ Suppress (" NOTH ING _ TO _ INLINE ") Ċ inline Ġfun Ġ< re ified ĠFrom Key , Ġre ified ĠFrom Value , Ġre ified ĠTo Key , Ġre ified ĠTo Value > ĠRead Standard KeyValue Repo < To Key , ĠTo Value >. with Mapper ( ĊĠĠĠ Ġcross inline Ġkey From To To : Ġsuspend ĠFrom Key . () Ġ-> ĠTo Key Ġ= Ġ{ Ġthis Ġas ĠTo Key Ġ}, ĊĠĠĠ Ġcross inline Ġvalue From To To : Ġsuspend ĠFrom Value . () Ġ-> ĠTo Value Ġ= Ġ{ Ġthis Ġas ĠTo Value Ġ}, ĊĠĠĠ Ġcross inline Ġkey To To From : Ġsuspend ĠTo Key . () Ġ-> ĠFrom Key Ġ= Ġ{ Ġthis Ġas ĠFrom Key Ġ}, ĊĠĠĠ Ġcross inline Ġvalue To To From : Ġsuspend ĠTo Value . () Ġ-> ĠFrom Value Ġ= Ġ{ Ġthis Ġas ĠFrom Value Ġ}, Ċ ): ĠRead Standard KeyValue Repo < From Key , ĠFrom Value > Ġ= Ġwith Mapper ( ĊĠĠĠ Ġmapper ( key From To To , Ġvalue From To To , Ġkey To To From , Ġvalue To To From ) Ċ ) Ċ Ċ open Ġclass ĠMapper Write Standard KeyValue Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value >( ĊĠĠĠ Ġprivate Ġval Ġto : ĠWrite Standard KeyValue Repo < To Key , ĠTo Value >, ĊĠĠĠ Ġmapper : ĠMapper Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value > Ċ ) Ġ: ĠWrite Standard KeyValue Repo < From Key , ĠFrom Value >, ĠMapper Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value > Ġby Ġmapper Ġ{ ĊĠĠĠ Ġoverride Ġval Ġon NewValue : ĠFlow < Pair < From Key , ĠFrom Value >> Ġ= Ġto . on NewValue . map Ġ{ Ġ( k , Ġv ) Ġ-> ĊĠĠĠĠĠĠĠ Ġk . to Inner Key () Ġto Ġv . to Inner Value () ĊĠĠĠ Ġ} ĊĠĠĠ Ġoverride Ġval Ġon Value Removed : ĠFlow < From Key > Ġ= Ġto . on Value Removed . map Ġ{ Ġk Ġ-> ĊĠĠĠĠĠĠĠ Ġk . to Inner Key () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġset ( toSet : ĠMap < From Key , ĠFrom Value >) Ġ= Ġto . set ( ĊĠĠĠĠĠĠĠ Ġto Set . map Ġ{ Ġ( k , Ġv ) Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġk . to Out Key () Ġto Ġv . to Out Value () ĊĠĠĠĠĠĠĠ Ġ}. toMap () ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġunset ( to Unset : ĠList < From Key >) Ġ= Ġto . unset ( ĊĠĠĠĠĠĠĠ Ġto Unset . map Ġ{ Ġk Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġk . to Out Key () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġunset With Values ( to Unset : ĠList < From Value >) Ġ= Ġto . unset With Values ( ĊĠĠĠĠĠĠĠ Ġto Unset . map Ġ{ Ġit . to Out Value () Ġ} ĊĠĠĠ Ġ) Ċ } Ċ Ċ @ Suppress (" NOTH ING _ TO _ INLINE ") Ċ inline Ġfun Ġ< From Key , ĠFrom Value , ĠTo Key , ĠTo Value > ĠWrite Standard KeyValue Repo < To Key , ĠTo Value >. with Mapper ( ĊĠĠĠ Ġmapper : ĠMapper Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value > Ċ ): ĠWrite Standard KeyValue Repo < From Key , ĠFrom Value > Ġ= ĠMapper Write Standard KeyValue Repo ( this , Ġmapper ) Ċ Ċ @ Suppress (" NOTH ING _ TO _ INLINE ") Ċ inline Ġfun Ġ< re ified ĠFrom Key , Ġre ified ĠFrom Value , Ġre ified ĠTo Key , Ġre ified ĠTo Value > ĠWrite Standard KeyValue Repo < To Key , ĠTo Value >. with Mapper ( ĊĠĠĠ Ġcross inline Ġkey From To To : Ġsuspend ĠFrom Key . () Ġ-> ĠTo Key Ġ= Ġ{ Ġthis Ġas ĠTo Key Ġ}, ĊĠĠĠ Ġcross inline Ġvalue From To To : Ġsuspend ĠFrom Value . () Ġ-> ĠTo Value Ġ= Ġ{ Ġthis Ġas ĠTo Value Ġ}, ĊĠĠĠ Ġcross inline Ġkey To To From : Ġsuspend ĠTo Key . () Ġ-> ĠFrom Key Ġ= Ġ{ Ġthis Ġas ĠFrom Key Ġ}, ĊĠĠĠ Ġcross inline Ġvalue To To From : Ġsuspend ĠTo Value . () Ġ-> ĠFrom Value Ġ= Ġ{ Ġthis Ġas ĠFrom Value Ġ}, Ċ ): ĠWrite Standard KeyValue Repo < From Key , ĠFrom Value > Ġ= Ġwith Mapper ( ĊĠĠĠ Ġmapper ( key From To To , Ġvalue From To To , Ġkey To To From , Ġvalue To To From ) Ċ ) Ċ Ċ open Ġclass ĠMapper Standard KeyValue Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value >( ĊĠĠĠ Ġprivate Ġval Ġto : ĠStandard KeyValue Repo < To Key , ĠTo Value >, ĊĠĠĠ Ġmapper : ĠMapper Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value > Ċ ) Ġ: ĠStandard KeyValue Repo < From Key , ĠFrom Value >, ĊĠĠĠ ĠMapper Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value > Ġby Ġmapper , ĊĠĠĠ ĠRead Standard KeyValue Repo < From Key , ĠFrom Value > Ġby ĠMapper Read Standard KeyValue Repo ( to , Ġmapper ), ĊĠĠĠ ĠWrite Standard KeyValue Repo < From Key , ĠFrom Value > Ġby ĠMapper Write Standard KeyValue Repo ( to , Ġmapper ) Ċ Ċ @ Suppress (" NOTH ING _ TO _ INLINE ") Ċ inline Ġfun Ġ< From Key , ĠFrom Value , ĠTo Key , ĠTo Value > ĠStandard KeyValue Repo < To Key , ĠTo Value >. with Mapper ( ĊĠĠĠ Ġmapper : ĠMapper Repo < From Key , ĠFrom Value , ĠTo Key , ĠTo Value > Ċ ): ĠStandard KeyValue Repo < From Key , ĠFrom Value > Ġ= ĠMapper Standard KeyValue Repo ( this , Ġmapper ) Ċ Ċ @ Suppress (" NOTH ING _ TO _ INLINE ") Ċ inline Ġfun Ġ< re ified ĠFrom Key , Ġre ified ĠFrom Value , Ġre ified ĠTo Key , Ġre ified ĠTo Value > ĠStandard KeyValue Repo < To Key , ĠTo Value >. with Mapper ( ĊĠĠĠ Ġcross inline Ġkey From To To : Ġsuspend ĠFrom Key . () Ġ-> ĠTo Key Ġ= Ġ{ Ġthis Ġas ĠTo Key Ġ}, ĊĠĠĠ Ġcross inline Ġvalue From To To : Ġsuspend ĠFrom Value . () Ġ-> ĠTo Value Ġ= Ġ{ Ġthis Ġas ĠTo Value Ġ}, ĊĠĠĠ Ġcross inline Ġkey To To From : Ġsuspend ĠTo Key . () Ġ-> ĠFrom Key Ġ= Ġ{ Ġthis Ġas ĠFrom Key Ġ}, ĊĠĠĠ Ġcross inline Ġvalue To To From : Ġsuspend ĠTo Value . () Ġ-> ĠFrom Value Ġ= Ġ{ Ġthis Ġas ĠFrom Value Ġ}, Ċ ): ĠStandard KeyValue Repo < From Key , ĠFrom Value > Ġ= Ġwith Mapper ( ĊĠĠĠ Ġmapper ( key From To To , Ġvalue From To To , Ġkey To To From , Ġvalue To To From ) Ċ ) Ċ