@ -45,7 +45,6 @@ import type { 
				
			 
			
		
	
		
		
			
				
					 
					 
					  PlatformCapabilities ,  
					 
					 
					  PlatformCapabilities ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					}  from  "@/services/PlatformService" ;  
					 
					 
					}  from  "@/services/PlatformService" ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					import  {  
					 
					 
					import  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					  MASTER_SETTINGS_KEY ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					  type  Settings ,  
					 
					 
					  type  Settings ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					  type  SettingsWithJsonStrings ,  
					 
					 
					  type  SettingsWithJsonStrings ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					}  from  "@/db/tables/settings" ;  
					 
					 
					}  from  "@/db/tables/settings" ;  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					@ -58,8 +57,6 @@ import { 
				
			 
			
		
	
		
		
			
				
					 
					 
					  generateInsertStatement ,  
					 
					 
					  generateInsertStatement ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					  generateUpdateStatement ,  
					 
					 
					  generateUpdateStatement ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					}  from  "@/utils/sqlHelpers" ;  
					 
					 
					}  from  "@/utils/sqlHelpers" ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					// eslint-disable-next-line @typescript-eslint/no-unused-vars
  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					import  {  ActiveIdentity  }  from  "@/db/tables/activeIdentity" ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					// =================================================
  
					 
					 
					// =================================================
  
				
			 
			
		
	
		
		
			
				
					 
					 
					// TYPESCRIPT INTERFACES
  
					 
					 
					// TYPESCRIPT INTERFACES
  
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					@ -198,6 +195,80 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					    // SELF-CONTAINED UTILITY METHODS (no databaseUtil dependency)
  
					 
					 
					    // SELF-CONTAINED UTILITY METHODS (no databaseUtil dependency)
  
				
			 
			
		
	
		
		
			
				
					 
					 
					    // =================================================
  
					 
					 
					    // =================================================
  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					    / * *  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					     *  Ensure  active_identity  table  is  populated  with  data  from  settings  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					     *  This  is  a  one - time  fix  for  the  migration  gap  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					     * /  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					    async  $ensureActiveIdentityPopulated ( ) :  Promise < void >  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      try  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . info (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "[PlatformServiceMixin] $ensureActiveIdentityPopulated() called" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        // Check if active_identity has data
  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        const  activeIdentity  =  await  this . $dbQuery (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "SELECT activeDid FROM active_identity WHERE id = 1" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        const  currentActiveDid  =  activeIdentity ? . values ? . [ 0 ] ? . [ 0 ]  as  string ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . info (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "[PlatformServiceMixin] Current active_identity table state:" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          {  currentActiveDid ,  hasData :  ! ! currentActiveDid  } ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        if  ( ! currentActiveDid )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          logger . info (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            "[PlatformServiceMixin] Active identity table empty, populating from settings" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          // Get activeDid from settings (any row with accountDid)
  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          const  settings  =  await  this . $dbQuery (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            "SELECT accountDid FROM settings WHERE accountDid IS NOT NULL LIMIT 1" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          const  settingsAccountDid  =  settings ? . values ? . [ 0 ] ? . [ 0 ]  as  string ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          logger . info ( "[PlatformServiceMixin] Found settings accountDid:" ,  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            settingsAccountDid ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          } ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          if  ( settingsAccountDid )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            await  this . $dbExec (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              "UPDATE active_identity SET activeDid = ?, lastUpdated = datetime('now') WHERE id = 1" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              [ settingsAccountDid ] ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            logger . info (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              ` [PlatformServiceMixin] Populated active_identity with:  ${ settingsAccountDid } ` ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          }  else  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            // If no settings found, try to get any account DID
  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            const  accounts  =  await  this . $dbQuery (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              "SELECT did FROM accounts LIMIT 1" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            const  accountDid  =  accounts ? . values ? . [ 0 ] ? . [ 0 ]  as  string ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            if  ( accountDid )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              await  this . $dbExec (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					                "UPDATE active_identity SET activeDid = ?, lastUpdated = datetime('now') WHERE id = 1" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					                [ accountDid ] ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              logger . info (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					                ` [PlatformServiceMixin] Populated active_identity with account DID:  ${ accountDid } ` ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            }  else  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              logger . warn (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					                "[PlatformServiceMixin] No accountDid found in settings or accounts table" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            }  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          }  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        }  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      }  catch  ( error )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . warn (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "[PlatformServiceMixin] Failed to populate active_identity:" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          error ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      }  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					    } ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					    / * *  
					 
					 
					    / * *  
				
			 
			
		
	
		
		
			
				
					 
					 
					     *  Update  the  current  activeDid  and  trigger  change  detection  
					 
					 
					     *  Update  the  current  activeDid  and  trigger  change  detection  
				
			 
			
		
	
		
		
			
				
					 
					 
					     *  This  method  should  be  called  when  the  user  switches  identities  
					 
					 
					     *  This  method  should  be  called  when  the  user  switches  identities  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					@ -213,22 +284,18 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					          ` [PlatformServiceMixin] ActiveDid updated from  ${ oldDid }  to  ${ newDid } ` ,  
					 
					 
					          ` [PlatformServiceMixin] ActiveDid updated from  ${ oldDid }  to  ${ newDid } ` ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					        ) ;  
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        // Dual-write to both tables for backward compatibility 
  
					 
					 
					        // Write only to active_identity table (single source of truth) 
  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					        try  {  
					 
					 
					        try  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					          await  this . $dbExec (  
					 
					 
					          await  this . $dbExec (  
				
			 
			
		
	
		
		
			
				
					 
					 
					            "UPDATE active_identity SET activeDid = ?, lastUpdated = datetime('now') WHERE id = 1" ,  
					 
					 
					            "UPDATE active_identity SET activeDid = ?, lastUpdated = datetime('now') WHERE id = 1" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					            [ newDid  ||  "" ] ,  
					 
					 
					            [ newDid  ||  "" ] ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					          ) ;  
					 
					 
					          ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					          await  this . $dbExec ( "UPDATE settings SET activeDid = ? WHERE id = ?" ,  [  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            newDid  ||  "" ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            MASTER_SETTINGS_KEY ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          ] ) ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          logger . debug (  
					 
					 
					          logger . debug (  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					            ` [PlatformServiceMixin] ActiveDid dual-write completed for   ${ newDid } ` ,  
					 
					 
					            ` [PlatformServiceMixin] ActiveDid updated in active_identity table:  ${ newDid } ` ,  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					          ) ;  
					 
					 
					          ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					        }  catch  ( error )  {  
					 
					 
					        }  catch  ( error )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					          logger . error (  
					 
					 
					          logger . error (  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					            ` [PlatformServiceMixin] Error in dual-write for activeDid   ${ newDid } : ` ,  
					 
					 
					            ` [PlatformServiceMixin] Error updating activeDid in active_identity table   ${ newDid } : ` ,  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					            error ,  
					 
					 
					            error ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					          ) ;  
					 
					 
					          ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					          // Continue with in-memory update even if database write fails
  
					 
					 
					          // Continue with in-memory update even if database write fails
  
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					@ -468,10 +535,18 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					      fallback : Settings  |  null  =  null ,  
					 
					 
					      fallback : Settings  |  null  =  null ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					    ) :  Promise < Settings  |  null >  {  
					 
					 
					    ) :  Promise < Settings  |  null >  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					      try  {  
					 
					 
					      try  {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        // Master settings: query by id
  
					 
					 
					        // Get current active identity
  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        const  activeIdentity  =  await  this . $getActiveIdentity ( ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        const  activeDid  =  activeIdentity . activeDid ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        if  ( ! activeDid )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          return  fallback ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        }  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        // Get identity-specific settings
  
				
			 
			
		
	
		
		
			
				
					 
					 
					        const  result  =  await  this . $dbQuery (  
					 
					 
					        const  result  =  await  this . $dbQuery (  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					          "SELECT * FROM settings WHERE id = ?" ,  
					 
					 
					          "SELECT * FROM settings WHERE accountD id = ?" ,  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					          [ MASTER_SETTINGS_KEY ] ,  
					 
					 
					          [ activeDid ] ,  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					        ) ;  
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					        if  ( ! result ? . values ? . length )  {  
					 
					 
					        if  ( ! result ? . values ? . length )  {  
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					@ -508,7 +583,6 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					     *  Handles  the  common  pattern  of  layered  settings  
					 
					 
					     *  Handles  the  common  pattern  of  layered  settings  
				
			 
			
		
	
		
		
			
				
					 
					 
					     * /  
					 
					 
					     * /  
				
			 
			
		
	
		
		
			
				
					 
					 
					    async  $getMergedSettings (  
					 
					 
					    async  $getMergedSettings (  
				
			 
			
		
	
		
		
			
				
					 
					 
					      defaultKey : string ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					      accountDid? : string ,  
					 
					 
					      accountDid? : string ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					      defaultFallback : Settings  =  { } ,  
					 
					 
					      defaultFallback : Settings  =  { } ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					    ) :  Promise < Settings >  {  
					 
					 
					    ) :  Promise < Settings >  {  
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					@ -564,7 +638,6 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					        return  mergedSettings ;  
					 
					 
					        return  mergedSettings ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					      }  catch  ( error )  {  
					 
					 
					      }  catch  ( error )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					        logger . error ( ` [Settings Trace] ❌ Failed to get merged settings: ` ,  {  
					 
					 
					        logger . error ( ` [Settings Trace] ❌ Failed to get merged settings: ` ,  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					          defaultKey ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          accountDid ,  
					 
					 
					          accountDid ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					          error ,  
					 
					 
					          error ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					        } ) ;  
					 
					 
					        } ) ;  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					@ -578,12 +651,29 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					     * /  
					 
					 
					     * /  
				
			 
			
		
	
		
		
			
				
					 
					 
					    async  $getActiveIdentity ( ) :  Promise < {  activeDid : string  } >  {  
					 
					 
					    async  $getActiveIdentity ( ) :  Promise < {  activeDid : string  } >  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					      try  {  
					 
					 
					      try  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . info (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "[PlatformServiceMixin] $getActiveIdentity() called - API layer verification" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        // Ensure the table is populated before reading
  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        await  this . $ensureActiveIdentityPopulated ( ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . debug (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "[PlatformServiceMixin] Getting active identity from active_identity table" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					        const  result  =  await  this . $dbQuery (  
					 
					 
					        const  result  =  await  this . $dbQuery (  
				
			 
			
		
	
		
		
			
				
					 
					 
					          "SELECT activeDid FROM active_identity WHERE id = 1" ,  
					 
					 
					          "SELECT activeDid FROM active_identity WHERE id = 1" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					        ) ;  
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					        if  ( result ? . values ? . length )  {  
					 
					 
					        if  ( result ? . values ? . length )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					          const  activeDid  =  result . values [ 0 ] [ 0 ]  as  string ;  
					 
					 
					          const  activeDid  =  result . values [ 0 ] [ 0 ]  as  string ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          logger . debug ( "[PlatformServiceMixin] Active identity found:" ,  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            activeDid ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          } ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          logger . info (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            "[PlatformServiceMixin] $getActiveIdentity(): activeDid resolved" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            {  activeDid  } ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					          // Validate activeDid exists in accounts
  
					 
					 
					          // Validate activeDid exists in accounts
  
				
			 
			
		
	
		
		
			
				
					 
					 
					          if  ( activeDid )  {  
					 
					 
					          if  ( activeDid )  {  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					@ -593,9 +683,15 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					            ) ;  
					 
					 
					            ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					            if  ( accountExists ? . values ? . length )  {  
					 
					 
					            if  ( accountExists ? . values ? . length )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              logger . debug (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					                "[PlatformServiceMixin] Active identity validated in accounts" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					              return  {  activeDid  } ;  
					 
					 
					              return  {  activeDid  } ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					            }  else  {  
					 
					 
					            }  else  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					              // Clear corrupted activeDid
  
					 
					 
					              // Clear corrupted activeDid
  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              logger . warn (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					                "[PlatformServiceMixin] Active identity not found in accounts, clearing" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					              ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					              await  this . $dbExec (  
					 
					 
					              await  this . $dbExec (  
				
			 
			
		
	
		
		
			
				
					 
					 
					                "UPDATE active_identity SET activeDid = '', lastUpdated = datetime('now') WHERE id = 1" ,  
					 
					 
					                "UPDATE active_identity SET activeDid = '', lastUpdated = datetime('now') WHERE id = 1" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					              ) ;  
					 
					 
					              ) ;  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					@ -604,6 +700,9 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					          }  
					 
					 
					          }  
				
			 
			
		
	
		
		
			
				
					 
					 
					        }  
					 
					 
					        }  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . debug (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "[PlatformServiceMixin] No active identity found, returning empty" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					        return  {  activeDid :  ""  } ;  
					 
					 
					        return  {  activeDid :  ""  } ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					      }  catch  ( error )  {  
					 
					 
					      }  catch  ( error )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					        logger . error (  
					 
					 
					        logger . error (  
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					@ -825,14 +924,14 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					        return  defaults ;  
					 
					 
					        return  defaults ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					      }  
					 
					 
					      }  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					      // FIXED: Remove forced override - respect user preferences 
  
					 
					 
					      // FIXED: Set default apiServer for all platforms, not just Electron 
  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					      // Only set default if no user preference exists
  
					 
					 
					      // Only set default if no user preference exists
  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					      if  ( ! settings . apiServer  &&  process . env . VITE_PLATFORM  ===  "electron"  )  {  
					 
					 
					      if  ( ! settings . apiServer )  {  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					        // Import constants dynamically to get platform-specific values
  
					 
					 
					        // Import constants dynamically to get platform-specific values
  
				
			 
			
		
	
		
		
			
				
					 
					 
					        const  {  DEFAULT_ENDORSER_API_SERVER  }  =  await  import (  
					 
					 
					        const  {  DEFAULT_ENDORSER_API_SERVER  }  =  await  import (  
				
			 
			
		
	
		
		
			
				
					 
					 
					          "../constants/app"  
					 
					 
					          "../constants/app"  
				
			 
			
		
	
		
		
			
				
					 
					 
					        ) ;  
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        // Only set if user hasn't specified a preference 
  
					 
					 
					        // Set default for all platforms when apiServer is empty 
  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					        settings . apiServer  =  DEFAULT_ENDORSER_API_SERVER ;  
					 
					 
					        settings . apiServer  =  DEFAULT_ENDORSER_API_SERVER ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					      }  
					 
					 
					      }  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					@ -858,10 +957,9 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					          return  defaults ;  
					 
					 
					          return  defaults ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					        }  
					 
					 
					        }  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        // Determine which DID to use - prioritize new active_identity table, fallback to settings 
  
					 
					 
					        // Get DID from active_identity table (single source of truth) 
  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					        const  activeIdentity  =  await  this . $getActiveIdentity ( ) ;  
					 
					 
					        const  activeIdentity  =  await  this . $getActiveIdentity ( ) ;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        const  targetDid  =  
					 
					 
					        const  targetDid  =  did  ||  activeIdentity . activeDid ;  
				
			 
			
				
				
			
		
	
		
		
			
				
					 
					 
					          did  ||  activeIdentity . activeDid  ||  defaultSettings . activeDid ;  
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					        // If no target DID, return default settings
  
					 
					 
					        // If no target DID, return default settings
  
				
			 
			
		
	
		
		
			
				
					 
					 
					        if  ( ! targetDid )  {  
					 
					 
					        if  ( ! targetDid )  {  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					@ -870,27 +968,29 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					        // Get merged settings using existing method
  
					 
					 
					        // Get merged settings using existing method
  
				
			 
			
		
	
		
		
			
				
					 
					 
					        const  mergedSettings  =  await  this . $getMergedSettings (  
					 
					 
					        const  mergedSettings  =  await  this . $getMergedSettings (  
				
			 
			
		
	
		
		
			
				
					 
					 
					          MASTER_SETTINGS_KEY ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          targetDid ,  
					 
					 
					          targetDid ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					          defaultSettings ,  
					 
					 
					          defaultSettings ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					        ) ;  
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        // Ensure activeDid comes from new table when available
  
					 
					 
					        // Set activeDid from active_identity table (single source of truth)
  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					        if  ( activeIdentity . activeDid )  {  
					 
					 
					        mergedSettings . activeDid  =  activeIdentity . activeDid ;  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					          mergedSettings . activeDid  =  activeIdentity . activeDid ;  
					 
					 
					        logger . debug (  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					        }  
					 
					 
					          "[PlatformServiceMixin] Using activeDid from active_identity table:" ,  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          {  activeDid : activeIdentity.activeDid  } ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . info (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "[PlatformServiceMixin] $accountSettings() returning activeDid:" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          {  activeDid : mergedSettings.activeDid  } ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        // FIXED: Remove forced override - respect user preferences
  
					 
					 
					        // FIXED: Set default apiServer for all platforms, not just Electron 
  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					        // Only set default if no user preference exists
  
					 
					 
					        // Only set default if no user preference exists
  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        if  (  
					 
					 
					        if  ( ! mergedSettings . apiServer )  {  
				
			 
			
				
				
			
		
	
		
		
			
				
					 
					 
					          ! mergedSettings . apiServer  &&  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          process . env . VITE_PLATFORM  ===  "electron"  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					        )  {  
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
			
				
					 
					 
					          // Import constants dynamically to get platform-specific values
  
					 
					 
					          // Import constants dynamically to get platform-specific values
  
				
			 
			
		
	
		
		
			
				
					 
					 
					          const  {  DEFAULT_ENDORSER_API_SERVER  }  =  await  import (  
					 
					 
					          const  {  DEFAULT_ENDORSER_API_SERVER  }  =  await  import (  
				
			 
			
		
	
		
		
			
				
					 
					 
					            "../constants/app"  
					 
					 
					            "../constants/app"  
				
			 
			
		
	
		
		
			
				
					 
					 
					          ) ;  
					 
					 
					          ) ;  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					          // Only set if user hasn't specified a preference 
  
					 
					 
					          // Set default for all platforms when apiServer is empty 
  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					          mergedSettings . apiServer  =  DEFAULT_ENDORSER_API_SERVER ;  
					 
					 
					          mergedSettings . apiServer  =  DEFAULT_ENDORSER_API_SERVER ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					        }  
					 
					 
					        }  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					@ -928,16 +1028,36 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					    async  $saveSettings ( changes : Partial < Settings > ) :  Promise < boolean >  {  
					 
					 
					    async  $saveSettings ( changes : Partial < Settings > ) :  Promise < boolean >  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					      try  {  
					 
					 
					      try  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					        // Remove fields that shouldn't be updated
  
					 
					 
					        // Remove fields that shouldn't be updated
  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        const  {  accountDid ,  id ,  . . . safeChanges  }  =  changes ;  
					 
					 
					        const  {  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          accountDid ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          id ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          activeDid : activeDidField ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          . . . safeChanges  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        }  =  changes ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					        // eslint-disable-next-line @typescript-eslint/no-unused-vars
  
					 
					 
					        // eslint-disable-next-line @typescript-eslint/no-unused-vars
  
				
			 
			
		
	
		
		
			
				
					 
					 
					        void  accountDid ;  
					 
					 
					        void  accountDid ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					        // eslint-disable-next-line @typescript-eslint/no-unused-vars
  
					 
					 
					        // eslint-disable-next-line @typescript-eslint/no-unused-vars
  
				
			 
			
		
	
		
		
			
				
					 
					 
					        void  id ;  
					 
					 
					        void  id ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        // eslint-disable-next-line @typescript-eslint/no-unused-vars
  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        void  activeDidField ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . debug (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "[PlatformServiceMixin] $saveSettings - Original changes:" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          changes ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . debug (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "[PlatformServiceMixin] $saveSettings - Safe changes:" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          safeChanges ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					        if  ( Object . keys ( safeChanges ) . length  ===  0 )  return  true ;  
					 
					 
					        if  ( Object . keys ( safeChanges ) . length  ===  0 )  return  true ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					        // Convert settings for database storage (handles searchBoxes conversion)
  
					 
					 
					        // Convert settings for database storage (handles searchBoxes conversion)
  
				
			 
			
		
	
		
		
			
				
					 
					 
					        const  convertedChanges  =  this . _convertSettingsForStorage ( safeChanges ) ;  
					 
					 
					        const  convertedChanges  =  this . _convertSettingsForStorage ( safeChanges ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . debug (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "[PlatformServiceMixin] $saveSettings - Converted changes:" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          convertedChanges ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					        const  setParts : string [ ]  =  [ ] ;  
					 
					 
					        const  setParts : string [ ]  =  [ ] ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					        const  params : unknown [ ]  =  [ ] ;  
					 
					 
					        const  params : unknown [ ]  =  [ ] ;  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					@ -949,17 +1069,33 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					          }  
					 
					 
					          }  
				
			 
			
		
	
		
		
			
				
					 
					 
					        } ) ;  
					 
					 
					        } ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . debug (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          "[PlatformServiceMixin] $saveSettings - Set parts:" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          setParts ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        logger . debug ( "[PlatformServiceMixin] $saveSettings - Params:" ,  params ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					        if  ( setParts . length  ===  0 )  return  true ;  
					 
					 
					        if  ( setParts . length  ===  0 )  return  true ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        params . push ( MASTER_SETTINGS_KEY ) ;  
					 
					 
					        // Get current active DID and update that identity's settings
  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					        await  this . $dbExec (  
					 
					 
					        const  activeIdentity  =  await  this . $getActiveIdentity ( ) ;  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					          ` UPDATE settings SET  ${ setParts . join ( ", " ) }  WHERE id = ? ` ,  
					 
					 
					        const  currentActiveDid  =  activeIdentity . activeDid ;  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					          params ,  
					 
					 
					
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					        ) ;  
					 
					 
					        if  ( currentActiveDid )  {  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          params . push ( currentActiveDid ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          await  this . $dbExec (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            ` UPDATE settings SET  ${ setParts . join ( ", " ) }  WHERE accountDid = ? ` ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            params ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        }  else  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          logger . warn (  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					            "[PlatformServiceMixin] No active DID found, cannot save settings" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					          ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        }  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					        // Update activeDid tracking if it changed
  
					 
					 
					        // Update activeDid tracking if it changed
  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        if  ( changes . activeDid  !==  undefined )  {  
					 
					 
					        if  ( activeDidFiel d  !==  undefined )  {  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					          await  this . $updateActiveDid ( changes . activeDid ) ;  
					 
					 
					          await  this . $updateActiveDid ( activeDidFiel d ) ;  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					        }  
					 
					 
					        }  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					        return  true ;  
					 
					 
					        return  true ;  
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					@ -1409,13 +1545,16 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					      fields : string [ ] ,  
					 
					 
					      fields : string [ ] ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					      did? : string ,  
					 
					 
					      did? : string ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					    ) :  Promise < unknown [ ]  |  undefined >  {  
					 
					 
					    ) :  Promise < unknown [ ]  |  undefined >  {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					      // Use correct settings table schema
  
					 
					 
					      // Use current active DID if no specific DID provided
  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					      const  whereClause  =  did  ?  "WHERE accountDid = ?"  :  "WHERE id = ?" ;  
					 
					 
					      const  targetDid  =  did  ||  ( await  this . $getActiveIdentity ( ) ) . activeDid ;  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					      const  params  =  did  ?  [ did ]  :  [ MASTER_SETTINGS_KEY ] ;  
					 
					 
					
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      if  ( ! targetDid )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        return  undefined ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      }  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					      return  await  this . $one (  
					 
					 
					      return  await  this . $one (  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					        ` SELECT  ${ fields . join ( ", " ) }  FROM settings  ${ whereClause } ` ,  
					 
					 
					        ` SELECT  ${ fields . join ( ", " ) }  FROM settings WHERE accountDid = ?  ` ,  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					        params ,  
					 
					 
					        [ targetDid ] ,  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					      ) ;  
					 
					 
					      ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					    } ,  
					 
					 
					    } ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					@ -1655,7 +1794,6 @@ export const PlatformServiceMixin = { 
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					        // Get merged settings
  
					 
					 
					        // Get merged settings
  
				
			 
			
		
	
		
		
			
				
					 
					 
					        const  mergedSettings  =  await  this . $getMergedSettings (  
					 
					 
					        const  mergedSettings  =  await  this . $getMergedSettings (  
				
			 
			
		
	
		
		
			
				
					 
					 
					          MASTER_SETTINGS_KEY ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          did ,  
					 
					 
					          did ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					          defaultSettings  ||  { } ,  
					 
					 
					          defaultSettings  ||  { } ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					        ) ;  
					 
					 
					        ) ;  
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					@ -1697,6 +1835,7 @@ export interface IPlatformServiceMixin { 
				
			 
			
		
	
		
		
			
				
					 
					 
					    accountDid? : string ,  
					 
					 
					    accountDid? : string ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					    defaultFallback? : Settings ,  
					 
					 
					    defaultFallback? : Settings ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					  ) :  Promise < Settings > ;  
					 
					 
					  ) :  Promise < Settings > ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					  $getActiveIdentity ( ) :  Promise < {  activeDid : string  } > ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					  $withTransaction < T > ( callback :  ( )  = >  Promise < T > ) :  Promise < T > ;  
					 
					 
					  $withTransaction < T > ( callback :  ( )  = >  Promise < T > ) :  Promise < T > ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					  isCapacitor : boolean ;  
					 
					 
					  isCapacitor : boolean ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					  isWeb : boolean ;  
					 
					 
					  isWeb : boolean ;