package Ġio . g rim locations . ui . view model . reducer Ċ Ċ import Ġio . g rim locations . data . dto . Location DTO Ċ import Ġio . g rim locations . data . dto . Meta DTO Ċ import Ġio . g rim locations . data . dto . contains Profile Mod Difficulty Ċ import Ġio . g rim locations . data . dto . first Container Ċ import Ġio . g rim locations . data . repo .* Ċ import Ġio . g rim locations . data . repo . action .* Ċ import Ġio . g rim locations . framework . data . dto . replace DTO Ċ import Ġio . g rim locations . framework . ui . getState Ċ import Ġio . g rim locations . framework . ui . setState Ċ import Ġio . g rim locations . framework . util . await All Ċ import Ġio . g rim locations . framework . util . extension . as Path ToFile Ċ import Ġio . g rim locations . framework . util . guard Let Ċ import Ġio . g rim locations . ui . GL StateManager Ċ import Ġio . g rim locations . ui . view model . state . Editor State Ċ import Ġio . g rim locations . ui . view model . state . PMD Manager State Ċ import Ġio . g rim locations . ui . view model . state . container . PMD Container Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . sync . Mutex Ċ import Ġkotlinx . coroutines . sync . with Lock Ċ import Ġkotlinx . coroutines . with Context Ċ import Ġjava . io . File ĊĊ Ċ @ Suppress (" UN CHECK ED _ CAST ") Ċ suspend Ġfun ĠGL StateManager . load Editor State ( ĊĠĠĠ Ġprevious State : ĠEditor State ? Ġ= Ġnull Ċ ) Ġ{ ĊĠĠĠ Ġval Ġ( pmd Map , Ġmeta ) Ġ= Ġawait All ( ĊĠĠĠĠĠĠĠ Ġrepository . get Profiles Mods Diff icult ies Async (), ĊĠĠĠĠĠĠĠ Ġrepository . get Meta Async () ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġif Ġ( previous State Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontainer Ġ= Ġp md Map . first Container () ĊĠĠĠĠĠĠĠ Ġval Ġloc List Ġ= Ġrepository . get Locations Async ( container ). await () ĊĊĠĠĠĠĠĠĠ ĠsetState ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEditor State ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprofile Map Ġ= Ġp md Map , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected PMD Left Ġ= Ġcontainer , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected PM DR ight Ġ= Ġcontainer . copy (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlocations Left Ġ= Ġloc List , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlocations Right Ġ= Ġloc List . toSet (), Ġ// copies Ġthe Ġlist , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactive PMD Ġ= Ġmeta . active PMD , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis GD Running Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Left Ġ= Ġset Of (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Right Ġ= Ġset Of (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis Edit Location Left Popup Open Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis Edit Location Right Popup Open Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis Load Locations Popup Open Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis Properties Popup Open Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis Confirm Delete Left Popup Open Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis Confirm Delete Right Popup Open Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis PMD Manager View Open Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġselected PMD Left Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( pmd Map . contains Profile Mod Difficulty ( previous State . selected PMD Left )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprevious State . selected PMD Left ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġp md Map . first Container () ĊĊĠĠĠĠĠĠĠ Ġval Ġselected PM DR ight Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( pmd Map . contains Profile Mod Difficulty ( previous State . selected PM DR ight )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprevious State . selected PM DR ight ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġp md Map . first Container () ĊĊĠĠĠĠĠĠĠ Ġval Ġ( loc List 1 , Ġloc List 2 ) Ġ= Ġawait All ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . get Locations Async ( selected PMD Left ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . get Locations Async ( selected PM DR ight ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠsetState ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprevious State . copy ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected PMD Left Ġ= Ġselected PMD Left , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected PM DR ight Ġ= Ġselected PM DR ight , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprofile Map Ġ= Ġp md Map , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlocations Left Ġ= Ġloc List 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Left Ġ= Ġloc List 1 . filter Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprevious State . selected Locations Left . find Ġ{ Ġl Ġ-> Ġl . id Ġ== Ġit . id Ġ} Ġ!= Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ}. toSet (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlocations Right Ġ= Ġloc List 2 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Right Ġ= Ġloc List 2 . filter Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprevious State . selected Locations Right . find Ġ{ Ġl Ġ-> Ġl . id Ġ== Ġit . id Ġ} Ġ!= Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ}. toSet (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactive PMD Ġ= Ġmeta . active PMD , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . reset Selected PMD Left () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( selected PMD Left Ġ= Ġs . profile Map . first Container ())) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . reset Selected PM DR ight () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( selected PM DR ight Ġ= Ġs . profile Map . first Container ())) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . reset Selected PMD s () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġs . copy ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected PMD Left Ġ= Ġs . profile Map . first Container (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected PM DR ight Ġ= Ġs . profile Map . first Container (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . open Confirm Delete Left () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Confirm Delete Left Popup Open Ġ= Ġtrue )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . close Confirm Delete Left () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Confirm Delete Left Popup Open Ġ= Ġfalse )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . open Confirm Delete Right () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Confirm Delete Right Popup Open Ġ= Ġtrue )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . close Confirm Delete Right () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Confirm Delete Right Popup Open Ġ= Ġfalse )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . open Edit Location Left () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Edit Location Left Popup Open Ġ= Ġtrue )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . close Edit Location Left () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Edit Location Left Popup Open Ġ= Ġfalse )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . open Edit Location Right () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Edit Location Right Popup Open Ġ= Ġtrue )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . close Edit Location Right () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Edit Location Right Popup Open Ġ= Ġfalse )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . open Properties View () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Properties Popup Open Ġ= Ġtrue )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . close Properties View () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Properties Popup Open Ġ= Ġfalse )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . open Load Locations View () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Load Locations Popup Open Ġ= Ġtrue )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . close Load Locations View () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is Load Locations Popup Open Ġ= Ġfalse )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . open PMD Manager View () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is PMD Manager View Open Ġ= Ġtrue )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . close PMD Manager View () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ Ġload Editor State ( s . copy ( is PMD Manager View Open Ġ= Ġfalse )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . reload Editor State ( state : ĠEditor State ? Ġ= Ġnull ) Ġ{ ĊĠĠĠ Ġload Editor State ( state Ġ?: ĠgetState ()) Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . update If GD Running (): ĠBoolean Ġ{ ĊĠĠĠ Ġval Ġis Running Ġ= Ġrepository . is GD Running () ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĊĠĠĠ Ġif Ġ( s . is GD Running Ġ!= Ġis Running ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠsetState ( s . copy ( is GD Running Ġ= Ġis Running )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġis Running Ċ } Ċ Ċ private Ġconst Ġval ĠTE LE PORT _ LIST _ FILENAME Ġ= Ġ" G rim Internals _ Teleport List . txt " Ċ private Ġconst Ġval ĠCHAR _ FILENAME Ġ= Ġ" G rim Locations _ Char . txt " Ċ private Ġvar Ġlocations _ file _ last _ modified : ĠLong ? Ġ= Ġnull Ċ private Ġvar Ġchar _ file _ last _ modified : ĠLong ? Ġ= Ġnull Ċ private Ġval Ġlocations File Mutex Ġ= ĠMutex () Ċ Ċ suspend Ġfun ĠGL StateManager . perform File Checks And Load s () Ġ{ ĊĠĠĠ Ġval Ġmeta Ġ= Ġrepository . get Meta Async (). await () ĊĠĠĠ Ġperform Active P md File Check And Load ( meta ) ĊĠĠĠ Ġperform Locations File Check And Load ( meta ) Ċ } Ċ Ċ private Ġsuspend Ġfun ĠGL StateManager . perform Locations File Check And Load ( meta : ĠMeta DTO ) Ġ{ ĊĠĠĠ Ġguard Let ( meta . install Location , Ġmeta . active PMD ) Ġ{ Ġloc , Ġp md Ġ-> ĊĠĠĠĠĠĠĠ Ġlocations File Mutex . with Lock Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġfile Ġ= ĠFile ( loc . as Path ToFile ( TELE PORT _ LIST _ FILENAME )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġlast Modified Ġ= Ġrepository . getFile LastModified ( file ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( lastModified Ġ!= Ġnull Ġ&& Ġlocations _ file _ last _ modified Ġ!= Ġlast Modified ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . create Locations FromFile ( file , Ġp md ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlocations _ file _ last _ modified Ġ= Ġrepository . getFile LastModified ( file ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġreload Editor State () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġsuspend Ġfun ĠGL StateManager . perform Active P md File Check And Load ( meta : ĠMeta DTO ) Ġ{ ĊĠĠĠ Ġmeta . install Location ?. let Ġ{ Ġloc Ġ-> ĊĠĠĠĠĠĠĠ Ġval Ġchar File Ġ= ĠFile ( loc . as Path ToFile ( CHAR _ FILENAME )) ĊĠĠĠĠĠĠĠ Ġval Ġlast Modified Ġ= Ġrepository . getFile LastModified ( char File ) ĊĊĠĠĠĠĠĠĠ Ġif Ġ( lastModified Ġ!= Ġnull Ġ&& Ġ( meta . active PMD Ġ== Ġnull Ġ|| Ġchar _ file _ last _ modified Ġ!= Ġlast Modified )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtele port File Ġ= ĠFile ( loc . as Path ToFile ( TELE PORT _ LIST _ FILENAME )) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . create And SetActive P md ( char File , Ġtele port File , Ġmeta . active PMD ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchar _ file _ last _ modified Ġ= Ġlast Modified ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlocations _ file _ last _ modified Ġ= Ġrepository . getFile LastModified ( tele port File ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreload Editor State () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġsuspend Ġfun ĠGL StateManager . copy Active PMD To Locations File ( pmd c : ĠP MD Container ) Ġ{ ĊĠĠĠ Ġval Ġmeta Ġ= Ġrepository . get Meta Async (). await () ĊĠĠĠ Ġif Ġ( pmd c Ġ== Ġmeta . active PMD ) Ġ{ ĊĠĠĠĠĠĠĠ Ġguard Let ( meta . install Location , Ġmeta . active PMD ) Ġ{ Ġloc , Ġp md Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlocations File Mutex . with Lock Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġfile Ġ= ĠFile ( loc . as Path ToFile ( TELE PORT _ LIST _ FILENAME )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . write Locations ToFile ( file , Ġp md ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlocations _ file _ last _ modified Ġ= Ġrepository . getFile LastModified ( file ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . select Locations Left ( loc : ĠSet < Location DTO >) Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġs . copy ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Left Ġ= Ġloc ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . select Locations Right ( loc : ĠSet < Location DTO >) Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġs . copy ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Right Ġ= Ġloc ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ // suspend Ġfun ĠGL StateManager . de select Locations Left ( loc : ĠSet < Location DTO >) Ġ{ Ċ // ĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() Ċ // ĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ Ċ // ĠĠĠĠĠĠĠ ĠsetState ( s . copy ( Ċ // ĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Left Ġ= Ġs . selected Locations Left . to Mutable Set (). apply Ġ{ Ġremove All ( loc ) Ġ} Ċ // ĠĠĠĠĠĠĠ Ġ)) Ċ // ĠĠĠ Ġ} Ċ //} Ċ // Ċ // suspend Ġfun ĠGL StateManager . de select Locations Right ( loc : ĠSet < Location DTO >) Ġ{ Ċ // ĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() Ċ // ĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ Ċ // ĠĠĠĠĠĠĠ ĠsetState ( s . copy ( Ċ // ĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Right Ġ= Ġs . selected Locations Right . to Mutable Set (). apply Ġ{ Ġremove All ( loc ) Ġ} Ċ // ĠĠĠĠĠĠĠ Ġ)) Ċ // ĠĠĠ Ġ} Ċ //} Ċ Ċ suspend Ġfun ĠGL StateManager . select PMD Left ( pmd : ĠP MD Container ) Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġval Ġlo cs Ġ= Ġrepository . get Locations Async ( pmd ). await () ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġs . copy ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected PMD Left Ġ= Ġp md , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlocations Left Ġ= Ġlo cs , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Left Ġ= Ġset Of () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . select PM DR ight ( pmd : ĠP MD Container ) Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġval Ġlo cs Ġ= Ġrepository . get Locations Async ( pmd ). await () ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ ĠsetState ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġs . copy ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected PM DR ight Ġ= Ġp md , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlocations Right Ġ= Ġlo cs , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Right Ġ= Ġset Of () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . copy Left Selected To Right () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġrepository . copy Locations To PMD ( ĊĠĠĠĠĠĠĠ Ġp md Container Ġ= Ġs . selected PM DR ight , ĊĠĠĠĠĠĠĠ Ġselected Locations Ġ= Ġs . selected Locations Left , ĊĠĠĠĠĠĠĠ Ġother Selected Locations Ġ= Ġs . selected Locations Right ĊĠĠĠ Ġ). await () ĊĠĠĠ Ġcopy Active PMD To Locations File ( s . selected PM DR ight ) ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ Ġreload Editor State () ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . copy Right Selected To Left () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġrepository . copy Locations To PMD ( ĊĠĠĠĠĠĠĠ Ġp md Container Ġ= Ġs . selected PMD Left , ĊĠĠĠĠĠĠĠ Ġselected Locations Ġ= Ġs . selected Locations Right , ĊĠĠĠĠĠĠĠ Ġother Selected Locations Ġ= Ġs . selected Locations Left ĊĠĠĠ Ġ). await () ĊĠĠĠ Ġcopy Active PMD To Locations File ( s . selected PMD Left ) ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ Ġreload Editor State () ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . move Selected Left Up () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġrepository . decrement Locations Order Async ( ĊĠĠĠĠĠĠĠ Ġp md Container Ġ= Ġs . selected PMD Left , ĊĠĠĠĠĠĠĠ Ġlocations Ġ= Ġs . selected Locations Left ĊĠĠĠ Ġ). await () ĊĠĠĠ Ġcopy Active PMD To Locations File ( s . selected PMD Left ) ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ Ġreload Editor State () ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . move Selected Left Down () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġrepository . increment Locations Order Async ( ĊĠĠĠĠĠĠĠ Ġp md Container Ġ= Ġs . selected PMD Left , ĊĠĠĠĠĠĠĠ Ġlocations Ġ= Ġs . selected Locations Left ĊĠĠĠ Ġ). await () ĊĠĠĠ Ġcopy Active PMD To Locations File ( s . selected PMD Left ) ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ Ġreload Editor State () ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . move Selected Right Up () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġrepository . decrement Locations Order Async ( ĊĠĠĠĠĠĠĠ Ġp md Container Ġ= Ġs . selected PM DR ight , ĊĠĠĠĠĠĠĠ Ġlocations Ġ= Ġs . selected Locations Right ĊĠĠĠ Ġ). await () ĊĠĠĠ Ġcopy Active PMD To Locations File ( s . selected PM DR ight ) ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ Ġreload Editor State () ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . move Selected Right Down () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġrepository . increment Locations Order Async ( ĊĠĠĠĠĠĠĠ Ġp md Container Ġ= Ġs . selected PM DR ight , ĊĠĠĠĠĠĠĠ Ġlocations Ġ= Ġs . selected Locations Right ĊĠĠĠ Ġ). await () ĊĠĠĠ Ġcopy Active PMD To Locations File ( s . selected PM DR ight ) ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ Ġreload Editor State () ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . delete Selected Left () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġrepository . delete Locations Async ( s . selected PMD Left , Ġs . selected Locations Left ). await () ĊĠĠĠ Ġcopy Active PMD To Locations File ( s . selected PMD Left ) ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ Ġreload Editor State () ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . delete Selected Right () Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġrepository . delete Locations Async ( s . selected PM DR ight , Ġs . selected Locations Right ). await () ĊĠĠĠ Ġcopy Active PMD To Locations File ( s . selected PM DR ight ) ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ Ġreload Editor State () ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . update And Close Location Left ( loc : ĠLocation DTO ) Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġupdate And Close Location ( loc , Ġs . selected PMD Left , Ġs ) Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . update And Close Location Right ( loc : ĠLocation DTO ) Ġ{ ĊĠĠĠ Ġval Ġs Ġ= ĠgetState < Editor State >() ĊĠĠĠ Ġupdate And Close Location ( loc , Ġs . selected PM DR ight , Ġs ) Ċ } Ċ Ċ private Ġsuspend Ġfun ĠGL StateManager . update And Close Location ( location : ĠLocation DTO , Ġp md : ĠP MD Container , Ġs : ĠEditor State ) Ġ{ ĊĠĠĠ Ġif Ġ( repository . update Location Async ( location ). await () Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠ Ġcopy Active PMD To Locations File ( pmd ) ĊĠĠĠĠĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠsetState ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġs . copy ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlocations Right Ġ= Ġs . locations Right . replace DTO ( location ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlocations Left Ġ= Ġs . locations Left . replace DTO ( location ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Right Ġ= Ġs . selected Locations Right . replace DTO ( location ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected Locations Left Ġ= Ġs . selected Locations Left . replace DTO ( location ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis Edit Location Left Popup Open Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis Edit Location Right Popup Open Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ suspend Ġfun ĠGL StateManager . clear Active PMD () Ġ{ ĊĠĠĠ Ġrepository . clear Active PMD () ĊĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ Ġload Editor State ( getState ()) ĊĠĠĠ Ġ} Ċ }