#include "ui/error_box.hpp"
#include "ui/nvg_util.hpp"
#include "app.hpp"
#include "i18n.hpp"

namespace sphaira::ui {
namespace {

// SOURCE: https://switchbrew.org/w/index.php?title=Error_codes
using PathPair = std::pair<Result, const char*>;
constexpr PathPair HOS_MODULES[] {
    PathPair{1, "Svc"},
    PathPair{2, "Fs"},
    PathPair{3, "Os"},
    PathPair{4, "Htcs"},
    PathPair{5, "Ncm"},
    PathPair{6, "Dd"},
    PathPair{7, "Osdbg"},
    PathPair{8, "Lr"},
    PathPair{9, "Ldr"},
    PathPair{10, "Sf"},
    PathPair{11, "Sf_Hipc"},
    PathPair{12, "Tma"},
    PathPair{13, "Dmnt"},
    PathPair{14, "Gds"},
    PathPair{15, "Pm"},
    PathPair{16, "Ns"},
    PathPair{17, "Bsdsockets"},
    PathPair{18, "Htc"},
    PathPair{19, "Tsc"},
    PathPair{20, "Kvdb"},
    PathPair{21, "Sm"},
    PathPair{22, "Ro"},
    PathPair{23, "Gc"},
    PathPair{24, "Sdmmc"},
    PathPair{25, "Ovln"},
    PathPair{26, "Spl"},
    PathPair{27, "Socket"},
    PathPair{29, "Htclow"},
    PathPair{30, "Ddsf"},
    PathPair{31, "Htcfs"},
    PathPair{32, "Async"},
    PathPair{33, "Util"},
    PathPair{35, "Tipc"},
    PathPair{37, "Anif"},
    PathPair{39, "Crt"},
    PathPair{100, "Eth"},
    PathPair{101, "I2c"},
    PathPair{102, "Gpio"},
    PathPair{103, "Uart"},
    PathPair{104, "Cpad"},
    PathPair{105, "Settings"},
    PathPair{106, "Ftm"},
    PathPair{107, "Wlan"},
    PathPair{108, "Xcd"},
    PathPair{109, "Tmp451"},
    PathPair{110, "Nifm"},
    PathPair{111, "Codec"},
    PathPair{112, "Lsm6ds3"},
    PathPair{113, "Bluetooth"},
    PathPair{114, "Vi"},
    PathPair{115, "Nfp"},
    PathPair{116, "Time"},
    PathPair{117, "Fgm"},
    PathPair{118, "Oe"},
    PathPair{119, "Bh1730fvc"},
    PathPair{120, "Pcie"},
    PathPair{121, "Friends"},
    PathPair{122, "Bcat"},
    PathPair{123, "Ssl"},
    PathPair{124, "Account"},
    PathPair{125, "News"},
    PathPair{126, "Mii"},
    PathPair{127, "Nfc"},
    PathPair{128, "Am"},
    PathPair{129, "Prepo"},
    PathPair{130, "Ahid"},
    PathPair{131, "Applet"},
    PathPair{132, "Ae"},
    PathPair{133, "Pcv"},
    PathPair{134, "Usb_Pd"},
    PathPair{135, "Bpc"},
    PathPair{136, "Psm"},
    PathPair{137, "Nim"},
    PathPair{138, "Psc"},
    PathPair{139, "Tc"},
    PathPair{140, "Usb"},
    PathPair{141, "Nsd"},
    PathPair{142, "Pctl"},
    PathPair{143, "Btm"},
    PathPair{144, "La"},
    PathPair{145, "Es"},
    PathPair{146, "Ngc"},
    PathPair{147, "Erpt"},
    PathPair{148, "Apm"},
    PathPair{149, "Cec"},
    PathPair{150, "Profiler"},
    PathPair{151, "Eupld"},
    PathPair{152, "Lidbe"},
    PathPair{153, "Audio"},
    PathPair{154, "Npns"},
    PathPair{155, "Http"},
    PathPair{156, "Idle"},
    PathPair{157, "Arp"},
    PathPair{158, "Updater"},
    PathPair{159, "Swkbd"},
    PathPair{160, "Netdiag"},
    PathPair{161, "Nfc_Mifare"},
    PathPair{162, "Err"},
    PathPair{163, "Fatal"},
    PathPair{164, "Ec"},
    PathPair{165, "Spsm"},
    PathPair{166, "Aoc"},
    PathPair{167, "Bgtc"},
    PathPair{168, "Creport"},
    PathPair{169, "Sasbus"},
    PathPair{170, "Pl"},
    PathPair{172, "Audioctrl"},
    PathPair{173, "Lbl"},
    PathPair{175, "Jit"},
    PathPair{176, "Hdcp"},
    PathPair{177, "Omm"},
    PathPair{178, "Pdm"},
    PathPair{179, "Olsc"},
    PathPair{180, "Srepo"},
    PathPair{181, "Dauth"},
    PathPair{182, "Stdfu"},
    PathPair{183, "Dbg"},
    PathPair{186, "Dhcps"},
    PathPair{187, "Spi"},
    PathPair{188, "Avm"},
    PathPair{189, "Pwm"},
    PathPair{191, "Rtc"},
    PathPair{192, "Regulator"},
    PathPair{193, "Led"},
    PathPair{195, "Sio"},
    PathPair{196, "Pcm"},
    PathPair{197, "Clkrst"},
    PathPair{198, "Powctl"},
    PathPair{201, "Audio_Old"},
    PathPair{202, "Hid"},
    PathPair{203, "Ldn"},
    PathPair{204, "Cs"},
    PathPair{205, "Irsensor"},
    PathPair{206, "Capsrv"},
    PathPair{208, "Manu"},
    PathPair{209, "Atk"},
    PathPair{210, "Web"},
    PathPair{211, "Lcs"},
    PathPair{212, "Grc"},
    PathPair{213, "Repair"},
    PathPair{214, "Album"},
    PathPair{215, "Rid"},
    PathPair{216, "Migration"},
    PathPair{217, "Migration_Idc"},
    PathPair{218, "Hidbus"},
    PathPair{219, "Ens"},
    PathPair{223, "Websocket"},
    PathPair{227, "Dcdmtp"},
    PathPair{228, "Pgl"},
    PathPair{229, "Notification"},
    PathPair{230, "Ins"},
    PathPair{231, "Lp2p"},
    PathPair{232, "Rcd"},
    PathPair{233, "Icm40607"},
    PathPair{235, "Prc"},
    PathPair{237, "Tma_Htc"},
    PathPair{238, "Ectx"},
    PathPair{239, "Mnpp"},
    PathPair{240, "Hshl"},
    PathPair{242, "Capmtp"},
    PathPair{244, "Dp2hdmi"},
    PathPair{245, "Cradle"},
    PathPair{246, "Sprofile"},
    PathPair{248, "Icm42607p"},
    PathPair{250, "Ndrm"},
    PathPair{251, "Fst2"},
    PathPair{306, "Nex"},
    PathPair{321, "Npln"},
    PathPair{499, "Tspm"},
    PathPair{500, "Devmenu"},
};

#if 1
constexpr PathPair HOS_RESULT[] = {
    PathPair{0xE01, "OutOfSessions"},
    PathPair{0x1C01, "InvalidArgument"},
    PathPair{0x4201, "NotImplemented"},
    PathPair{0x6C01, "StopProcessingException"},
    PathPair{0x7201, "NoSynchronizationObject"},
    PathPair{0x7601, "TerminationRequested"},
    PathPair{0x8C01, "NoEvent"},
    PathPair{0xCA01, "InvalidSize"},
    PathPair{0xCC01, "InvalidAddress"},
    PathPair{0xCE01, "OutOfResource"},
    PathPair{0xD001, "OutOfMemory"},
    PathPair{0xD201, "OutOfHandles"},
    PathPair{0xD401, "InvalidCurrentMemory"},
    PathPair{0xD801, "InvalidNewMemoryPermission"},
    PathPair{0xDC01, "InvalidMemoryRegion"},
    PathPair{0xE001, "InvalidPriority"},
    PathPair{0xE201, "InvalidCoreId"},
    PathPair{0xE401, "InvalidHandle"},
    PathPair{0xE601, "InvalidPointer"},
    PathPair{0xE801, "InvalidCombination"},
    PathPair{0xEA01, "TimedOut"},
    PathPair{0xEC01, "Cancelled"},
    PathPair{0xEE01, "OutOfRange"},
    PathPair{0xF001, "InvalidEnumValue"},
    PathPair{0xF201, "NotFound"},
    PathPair{0xF401, "Busy"},
    PathPair{0xF601, "SessionClosed"},
    PathPair{0xF801, "NotHandled"},
    PathPair{0xFA01, "InvalidState"},
    PathPair{0xFC01, "ReservedUsed"},
    PathPair{0xFE01, "NotSupported"},
    PathPair{0x10001, "Debug"},
    PathPair{0x10201, "NoThread"},
    PathPair{0x10401, "UnknownThread"},
    PathPair{0x10601, "PortClosed"},
    PathPair{0x10801, "LimitReached"},
    PathPair{0x10A01, "InvalidMemoryPool"},
    PathPair{0x20401, "ReceiveListBroken"},
    PathPair{0x20601, "OutOfAddressSpace"},
    PathPair{0x20801, "MessageTooLarge"},
    PathPair{0x40A01, "InvalidProcessId"},
    PathPair{0x40C01, "InvalidThreadId"},
    PathPair{0x40E01, "InvalidId"},
    PathPair{0x41001, "ProcessTerminated"},
    PathPair{0x202, "ResultPathNotFound"},
    PathPair{0x402, "ResultPathAlreadyExists"},
    PathPair{0xE02, "ResultTargetLocked"},
    PathPair{0x4602, "UsableSpaceNotEnoughMmcCalibration"},
    PathPair{0x4802, "UsableSpaceNotEnoughMmcSafe"},
    PathPair{0x4A02, "UsableSpaceNotEnoughMmcUser"},
    PathPair{0x4C02, "UsableSpaceNotEnoughMmcSystem"},
    PathPair{0x4E02, "ResultUsableSpaceNotEnoughSdCard"},
    PathPair{0x6402, "ResultUnsupportedSdkVersion"},
    PathPair{0x7802, "ResultMountNameAlreadyExists"},
    PathPair{0x7D202, "ResultPartitionNotFound"},
    PathPair{0x7D402, "ResultTargetNotFound"},
    PathPair{0xFA202, "PortSdCardNoDevice"},
    PathPair{0x13B002, "GameCardCardNotInserted"},
    PathPair{0x13B402, "GameCardCardNotActivated"},
    PathPair{0x13D802, "GameCardInvalidSecureAccess"},
    PathPair{0x13DA02, "GameCardInvalidNormalAccess"},
    PathPair{0x13DC02, "GameCardInvalidAccessAcrossMode"},
    PathPair{0x13E002, "GameCardInitialDataMismatch"},
    PathPair{0x13E202, "GameCardInitialNotFilledWithZero"},
    PathPair{0x13E402, "GameCardKekIndexMismatch"},
    PathPair{0x13EE02, "GameCardCardHeaderReadFailure"},
    PathPair{0x145002, "GameCardShouldTransitFromInitialToNormal"},
    PathPair{0x145202, "GameCardShouldTransitFromNormalModeToSecure"},
    PathPair{0x145402, "GameCardShouldTransitFromNormalModeToDebug"},
    PathPair{0x149402, "GameCardSendFirmwareFailure"},
    PathPair{0x149A02, "GameCardReceiveCertificateFailure"},
    PathPair{0x14A002, "GameCardSendSocCertificateFailure"},
    PathPair{0x14AA02, "GameCardReceiveRandomValueFailure"},
    PathPair{0x14AC02, "GameCardSendRandomValueFailure"},
    PathPair{0x14B602, "GameCardReceiveDeviceChallengeFailure"},
    PathPair{0x14B802, "GameCardRespondDeviceChallengeFailure"},
    PathPair{0x14BA02, "GameCardSendHostChallengeFailure"},
    PathPair{0x14BC02, "GameCardReceiveChallengeResponseFailure"},
    PathPair{0x14BE02, "GameCardChallengeAndResponseFailure"},
    PathPair{0x14D802, "GameCardSplGenerateRandomBytesFailure"},
    PathPair{0x14DE02, "GameCardReadRegisterFailure"},
    PathPair{0x14E002, "GameCardWriteRegisterFailure"},
    PathPair{0x14E202, "GameCardEnableCardBusFailure"},
    PathPair{0x14E402, "GameCardGetCardHeaderFailure"},
    PathPair{0x14E602, "GameCardAsicStatusError"},
    PathPair{0x14E802, "GameCardChangeGcModeToSecureFailure"},
    PathPair{0x14EA02, "GameCardChangeGcModeToDebugFailure"},
    PathPair{0x14EC02, "GameCardReadRmaInfoFailure"},
    PathPair{0x150802, "GameCardStateCardSecureModeRequired"},
    PathPair{0x150A02, "GameCardStateCardDebugModeRequired"},
    PathPair{0x155602, "GameCardCommandReadId1Failure"},
    PathPair{0x155802, "GameCardCommandReadId2Failure"},
    PathPair{0x155A02, "GameCardCommandReadId3Failure"},
    PathPair{0x155E02, "GameCardCommandReadPageFailure"},
    PathPair{0x156202, "GameCardCommandWritePageFailure"},
    PathPair{0x156402, "GameCardCommandRefreshFailure"},
    PathPair{0x156C02, "GameCardCommandReadCrcFailure"},
    PathPair{0x156E02, "GameCardCommandEraseFailure"},
    PathPair{0x157002, "GameCardCommandReadDevParamFailure"},
    PathPair{0x157202, "GameCardCommandWriteDevParamFailure"},
    PathPair{0x16B002, "GameCardDebugCardReceivedIdMismatch"},
    PathPair{0x16B202, "GameCardDebugCardId1Mismatch"},
    PathPair{0x16B402, "GameCardDebugCardId2Mismatch"},
    PathPair{0x171402, "GameCardFsCheckHandleInGetStatusFailure"},
    PathPair{0x172002, "GameCardFsCheckHandleInCreateReadOnlyFailure"},
    PathPair{0x172202, "GameCardFsCheckHandleInCreateSecureReadOnlyFailure"},
    PathPair{0x177202, "ResultNotImplemented"},
    PathPair{0x177602, "ResultAlreadyExists"},
    PathPair{0x177A02, "ResultOutOfRange"},
    PathPair{0x190202, "AllocationMemoryFailedInFatFileSystemA"},
    PathPair{0x190402, "AllocationMemoryFailedInFatFileSystemB"},
    PathPair{0x190602, "AllocationMemoryFailedInFatFileSystemC"},
    PathPair{0x190802, "AllocationMemoryFailedInFatFileSystemD"},
    PathPair{0x190A02, "AllocationMemoryFailedInFatFileSystemE"},
    PathPair{0x190C02, "AllocationMemoryFailedInFatFileSystemF"},
    PathPair{0x190E02, "AllocationMemoryFailedInFatFileSystemG"},
    PathPair{0x191002, "AllocationMemoryFailedInFatFileSystemH"},
    PathPair{0x195802, "AllocationMemoryFailedInSdCardA"},
    PathPair{0x195A02, "AllocationMemoryFailedInSdCardB"},
    PathPair{0x195C02, "AllocationMemoryFailedInSystemSaveDataA"},
    PathPair{0x195E02, "AllocationMemoryFailedInRomFsFileSystemA"},
    PathPair{0x196002, "AllocationMemoryFailedInRomFsFileSystemB"},
    PathPair{0x196202, "AllocationMemoryFailedInRomFsFileSystemC"},
    PathPair{0x1A3E02, "AllocationMemoryFailedInSdmmcStorageServiceA"},
    PathPair{0x1A4002, "AllocationMemoryFailedInBuiltInStorageCreatorA"},
    PathPair{0x1A4A02, "AllocationMemoryFailedInRegisterA"},
    PathPair{0x21BC02, "IncorrectSaveDataFileSystemMagicCode"},
    PathPair{0x234202, "InvalidAcidFileSize"},
    PathPair{0x234402, "InvalidAcidSize"},
    PathPair{0x234602, "InvalidAcid"},
    PathPair{0x234802, "AcidVerificationFailed"},
    PathPair{0x234A02, "InvalidNcaSignature"},
    PathPair{0x234C02, "NcaHeaderSignature1VerificationFailed"},
    PathPair{0x234E02, "NcaHeaderSignature2VerificationFailed"},
    PathPair{0x235002, "NcaFsHeaderHashVerificationFailed"},
    PathPair{0x235202, "InvalidNcaKeyIndex"},
    PathPair{0x235602, "InvalidNcaFsHeaderEncryptionType"},
    PathPair{0x235802, "InvalidNcaPatchInfoIndirectSize"},
    PathPair{0x235A02, "InvalidNcaPatchInfoAesCtrExSize"},
    PathPair{0x235C02, "InvalidNcaPatchInfoAesCtrExOffset"},
    PathPair{0x235E02, "InvalidNcaId"},
    PathPair{0x236002, "InvalidNcaHeader"},
    PathPair{0x236202, "InvalidNcaFsHeader"},
    PathPair{0x236802, "InvalidHierarchicalSha256BlockSize"},
    PathPair{0x236A02, "InvalidHierarchicalSha256LayerCount"},
    PathPair{0x236C02, "HierarchicalSha256BaseStorageTooLarge"},
    PathPair{0x236E02, "HierarchicalSha256HashVerificationFailed"},
    PathPair{0x244402, "InvalidSha256PartitionHashTarget"},
    PathPair{0x244602, "Sha256PartitionHashVerificationFailed"},
    PathPair{0x244802, "PartitionSignatureVerificationFailed"},
    PathPair{0x244A02, "Sha256PartitionSignatureVerificationFailed"},
    PathPair{0x244C02, "InvalidPartitionEntryOffset"},
    PathPair{0x244E02, "InvalidSha256PartitionMetaDataSize"},
    PathPair{0x249802, "InvalidFatFileNumber"},
    PathPair{0x249C02, "InvalidFatFormatBisUser"},
    PathPair{0x249E02, "InvalidFatFormatBisSystem"},
    PathPair{0x24A002, "InvalidFatFormatBisSafe"},
    PathPair{0x24A202, "InvalidFatFormatBisCalibration"},
    PathPair{0x250E02, "AesXtsFileSystemFileHeaderCorruptedOnFileOpen"},
    PathPair{0x251002, "AesXtsFileSystemFileNoHeaderOnFileOpen"},
    PathPair{0x280202, "FatFsFormatUnsupportedSize"},
    PathPair{0x280402, "FatFsFormatInvalidBpb"},
    PathPair{0x280602, "FatFsFormatInvalidParameter"},
    PathPair{0x280802, "FatFsFormatIllegalSectorsA"},
    PathPair{0x280A02, "FatFsFormatIllegalSectorsB"},
    PathPair{0x280C02, "FatFsFormatIllegalSectorsC"},
    PathPair{0x280E02, "FatFsFormatIllegalSectorsD"},
    PathPair{0x296A02, "UnexpectedInMountTableA"},
    PathPair{0x2EE602, "ResultTooLongPath"},
    PathPair{0x2EE802, "ResultInvalidCharacter"},
    PathPair{0x2EEA02, "ResultInvalidPathFormat"},
    PathPair{0x2EEC02, "ResultDirectoryUnobtainable"},
    PathPair{0x2F5A02, "ResultInvalidOffset"},
    PathPair{0x2F5C02, "ResultInvalidSize"},
    PathPair{0x2F5E02, "ResultNullptrArgument"},
    PathPair{0x2F6002, "ResultInvalidAlignment"},
    PathPair{0x2F6202, "ResultInvalidMountName"},
    PathPair{0x2F6402, "ResultExtensionSizeTooLarge"},
    PathPair{0x2F6602, "ResultExtensionSizeInvalid"},
    PathPair{0x307202, "ResultFileExtensionWithoutOpenModeAllowAppend"},
    PathPair{0x313A02, "UnsupportedCommitTarget"},
    PathPair{0x313C02, "UnsupportedSetSizeForNotResizableSubStorage"},
    PathPair{0x313E02, "UnsupportedSetSizeForResizableSubStorage"},
    PathPair{0x314002, "UnsupportedSetSizeForMemoryStorage"},
    PathPair{0x314202, "UnsupportedOperateRangeForMemoryStorage"},
    PathPair{0x314402, "UnsupportedOperateRangeForFileStorage"},
    PathPair{0x314602, "UnsupportedOperateRangeForFileHandleStorage"},
    PathPair{0x314802, "UnsupportedOperateRangeForSwitchStorage"},
    PathPair{0x314A02, "UnsupportedOperateRangeForStorageServiceObjectAdapter"},
    PathPair{0x314C02, "UnsupportedWriteForAesCtrCounterExtendedStorage"},
    PathPair{0x314E02, "UnsupportedSetSizeForAesCtrCounterExtendedStorage"},
    PathPair{0x315002, "UnsupportedOperateRangeForAesCtrCounterExtendedStorage"},
    PathPair{0x315202, "UnsupportedWriteForAesCtrStorageExternal"},
    PathPair{0x315402, "UnsupportedSetSizeForAesCtrStorageExternal"},
    PathPair{0x315602, "UnsupportedSetSizeForAesCtrStorage"},
    PathPair{0x315802, "UnsupportedSetSizeForHierarchicalIntegrityVerificationStorage"},
    PathPair{0x315A02, "UnsupportedOperateRangeForHierarchicalIntegrityVerificationStorage"},
    PathPair{0x315C02, "UnsupportedSetSizeForIntegrityVerificationStorage"},
    PathPair{0x315E02, "UnsupportedOperateRangeForWritableIntegrityVerificationStorage"},
    PathPair{0x316002, "UnsupportedOperateRangeForIntegrityVerificationStorage"},
    PathPair{0x316202, "UnsupportedSetSizeForBlockCacheBufferedStorage"},
    PathPair{0x316402, "UnsupportedOperateRangeForWritableBlockCacheBufferedStorage"},
    PathPair{0x316602, "UnsupportedOperateRangeForBlockCacheBufferedStorage"},
    PathPair{0x316802, "UnsupportedWriteForIndirectStorage"},
    PathPair{0x316A02, "UnsupportedSetSizeForIndirectStorage"},
    PathPair{0x316C02, "UnsupportedOperateRangeForIndirectStorage"},
    PathPair{0x316E02, "UnsupportedWriteForZeroStorage"},
    PathPair{0x317002, "UnsupportedSetSizeForZeroStorage"},
    PathPair{0x317202, "UnsupportedSetSizeForHierarchicalSha256Storage"},
    PathPair{0x317402, "UnsupportedWriteForReadOnlyBlockCacheStorage"},
    PathPair{0x317602, "UnsupportedSetSizeForReadOnlyBlockCacheStorage"},
    PathPair{0x317802, "UnsupportedSetSizeForIntegrityRomFsStorage"},
    PathPair{0x317A02, "UnsupportedSetSizeForDuplexStorage"},
    PathPair{0x317C02, "UnsupportedOperateRangeForDuplexStorage"},
    PathPair{0x317E02, "UnsupportedSetSizeForHierarchicalDuplexStorage"},
    PathPair{0x318002, "UnsupportedGetSizeForRemapStorage"},
    PathPair{0x318202, "UnsupportedSetSizeForRemapStorage"},
    PathPair{0x318402, "UnsupportedOperateRangeForRemapStorage"},
    PathPair{0x318602, "UnsupportedSetSizeForIntegritySaveDataStorage"},
    PathPair{0x318802, "UnsupportedOperateRangeForIntegritySaveDataStorage"},
    PathPair{0x318A02, "UnsupportedSetSizeForJournalIntegritySaveDataStorage"},
    PathPair{0x318C02, "UnsupportedOperateRangeForJournalIntegritySaveDataStorage"},
    PathPair{0x318E02, "UnsupportedGetSizeForJournalStorage"},
    PathPair{0x319002, "UnsupportedSetSizeForJournalStorage"},
    PathPair{0x319202, "UnsupportedOperateRangeForJournalStorage"},
    PathPair{0x319402, "UnsupportedSetSizeForUnionStorage"},
    PathPair{0x319602, "UnsupportedSetSizeForAllocationTableStorage"},
    PathPair{0x319802, "UnsupportedReadForWriteOnlyGameCardStorage"},
    PathPair{0x319A02, "UnsupportedSetSizeForWriteOnlyGameCardStorage"},
    PathPair{0x319C02, "UnsupportedWriteForReadOnlyGameCardStorage"},
    PathPair{0x319E02, "UnsupportedSetSizeForReadOnlyGameCardStorage"},
    PathPair{0x31A002, "UnsupportedOperateRangeForReadOnlyGameCardStorage"},
    PathPair{0x31A202, "UnsupportedSetSizeForSdmmcStorage"},
    PathPair{0x31A402, "UnsupportedOperateRangeForSdmmcStorage"},
    PathPair{0x31A602, "UnsupportedOperateRangeForFatFile"},
    PathPair{0x31A802, "UnsupportedOperateRangeForStorageFile"},
    PathPair{0x31AA02, "UnsupportedSetSizeForInternalStorageConcatenationFile"},
    PathPair{0x31AC02, "UnsupportedOperateRangeForInternalStorageConcatenationFile"},
    PathPair{0x31AE02, "UnsupportedQueryEntryForConcatenationFileSystem"},
    PathPair{0x31B002, "UnsupportedOperateRangeForConcatenationFile"},
    PathPair{0x31B202, "UnsupportedSetSizeForZeroBitmapFile"},
    PathPair{0x31B402, "UnsupportedOperateRangeForFileServiceObjectAdapter"},
    PathPair{0x31B602, "UnsupportedOperateRangeForAesXtsFile"},
    PathPair{0x31B802, "UnsupportedWriteForRomFsFileSystem"},
    PathPair{0x31BA02, "UnsupportedCommitProvisionallyForRomFsFileSystem"},
    PathPair{0x31BC02, "UnsupportedGetTotalSpaceSizeForRomFsFileSystem"},
    PathPair{0x31BE02, "UnsupportedWriteForRomFsFile"},
    PathPair{0x31C002, "UnsupportedOperateRangeForRomFsFile"},
    PathPair{0x31C202, "UnsupportedWriteForReadOnlyFileSystem"},
    PathPair{0x31C402, "UnsupportedCommitProvisionallyForReadOnlyFileSystem"},
    PathPair{0x31C602, "UnsupportedGetTotalSpaceSizeForReadOnlyFileSystem"},
    PathPair{0x31C802, "UnsupportedWriteForReadOnlyFile"},
    PathPair{0x31CA02, "UnsupportedOperateRangeForReadOnlyFile"},
    PathPair{0x31CC02, "UnsupportedWriteForPartitionFileSystem"},
    PathPair{0x31CE02, "UnsupportedCommitProvisionallyForPartitionFileSystem"},
    PathPair{0x31D002, "UnsupportedWriteForPartitionFile"},
    PathPair{0x31D202, "UnsupportedOperateRangeForPartitionFile"},
    PathPair{0x31D402, "UnsupportedOperateRangeForTmFileSystemFile"},
    PathPair{0x31D602, "UnsupportedWriteForSaveDataInternalStorageFileSystem"},
    PathPair{0x31DC02, "UnsupportedCommitProvisionallyForApplicationTemporaryFileSystem"},
    PathPair{0x31DE02, "UnsupportedCommitProvisionallyForSaveDataFileSystem"},
    PathPair{0x31E002, "UnsupportedCommitProvisionallyForDirectorySaveDataFileSystem"},
    PathPair{0x31E202, "UnsupportedWriteForZeroBitmapHashStorageFile"},
    PathPair{0x31E402, "UnsupportedSetSizeForZeroBitmapHashStorageFile"},
    PathPair{0x326602, "ResultNcaExternalKeyUnregisteredDeprecated"},
    PathPair{0x326E02, "ResultFileNotClosed"},
    PathPair{0x327002, "ResultDirectoryNotClosed"},
    PathPair{0x327202, "ResultWriteModeFileNotClosed"},
    PathPair{0x327402, "ResultAllocatorAlreadyRegistered"},
    PathPair{0x327602, "ResultDefaultAllocatorAlreadyUsed"},
    PathPair{0x327A02, "ResultAllocatorAlignmentViolation"},
    PathPair{0x328202, "ResultUserNotExist"},
    PathPair{0x339402, "FileNotFound"},
    PathPair{0x339602, "DirectoryNotFound"},
    PathPair{0x346402, "MappingTableFull"},
    PathPair{0x346A02, "OpenCountLimit"},
    PathPair{0x346C02, "MultiCommitFileSystemLimit"},
    PathPair{0x353602, "MapFull"},
    PathPair{0x35F202, "NotMounted"},
    PathPair{0x3DBC02, "DbmKeyNotFound"},
    PathPair{0x3DBE02, "DbmFileNotFound"},
    PathPair{0x3DC002, "DbmDirectoryNotFound"},
    PathPair{0x3DC402, "DbmAlreadyExists"},
    PathPair{0x3DC602, "DbmKeyFull"},
    PathPair{0x3DC802, "DbmDirectoryEntryFull"},
    PathPair{0x3DCA02, "DbmFileEntryFull"},
    PathPair{0x3DD402, "DbmInvalidOperation"},
    PathPair{0x203, "ResultNoPermission"},
    PathPair{0x403, "ResultAccessViolation"},
    PathPair{0x603, "ResultBadRequest"},
    PathPair{0x803, "ResultBusy"},
    PathPair{0xA03, "ResultDeadlock"},
    PathPair{0xC03, "ResultInvalidAddress"},
    PathPair{0xE03, "ResultInvalidParameter"},
    PathPair{0x1003, "ResultOutOfMemory"},
    PathPair{0x1203, "ResultOutOfResource"},
    PathPair{0x3EA03, "InvalidHandle"},
    PathPair{0x3EC03, "InvalidCurrentMemoryState"},
    PathPair{0x3EE03, "InvalidTransferMemoryState"},
    PathPair{0x3F003, "InvalidTransferMemorySize"},
    PathPair{0x7FE03, "ResultInternalError"},
    PathPair{0xA05, "ContentNotFound"},
    PathPair{0xE05, "ContentMetaNotFound"},
    PathPair{0x1805, "UnknownStorage"},
    PathPair{0xDC05, "InvalidContentMetaDatabase"},
    PathPair{0x17C05, "WriteToReadOnlyContentStorage"},
    PathPair{0x806, "InvalidMemoryState"},
    PathPair{0x1006, "InvalidHandle"},
    PathPair{0x408, "ProgramNotFound"},
    PathPair{0x608, "DataNotFound"},
    PathPair{0x808, "UnknownResolver"},
    PathPair{0xA08, "ApplicationNotFound"},
    PathPair{0xC08, "HtmlDocumentNotFound"},
    PathPair{0xE08, "AddOnContentNotFound"},
    PathPair{0x1008, "ControlNotFound"},
    PathPair{0x1208, "LegalInformationNotFound"},
    PathPair{0x1408, "DebugProgramNotFound"},
    PathPair{0x209, "TooLongArgument"},
    PathPair{0x409, "TooManyArguments"},
    PathPair{0x609, "TooLargeMeta"},
    PathPair{0x809, "InvalidMeta"},
    PathPair{0xA09, "InvalidNso"},
    PathPair{0xC09, "InvalidPath"},
    PathPair{0xE09, "TooManyProcesses"},
    PathPair{0x1009, "NotPinned"},
    PathPair{0x1209, "InvalidProgramId"},
    PathPair{0x1409, "InvalidVersion"},
    PathPair{0x6609, "InsufficientAddressSpace"},
    PathPair{0x6809, "InvalidNro"},
    PathPair{0x6A09, "InvalidNrr"},
    PathPair{0x6C09, "InvalidSignature"},
    PathPair{0x6E09, "InsufficientNroRegistrations"},
    PathPair{0x7009, "InsufficientNrrRegistrations"},
    PathPair{0x7209, "NroAlreadyLoaded"},
    PathPair{0xA209, "InvalidAddress"},
    PathPair{0xA409, "InvalidSize"},
    PathPair{0xA809, "NotLoaded"},
    PathPair{0xAA09, "NotRegistered"},
    PathPair{0xAE09, "InvalidProcess"},
    PathPair{0xC809, "UnknownCapability"},
    PathPair{0xCE09, "InvalidCapabilityKernelFlags"},
    PathPair{0xD009, "InvalidCapabilitySyscallMask"},
    PathPair{0xD409, "InvalidCapabilityMapRange"},
    PathPair{0xD609, "InvalidCapabilityMapPage"},
    PathPair{0xDE09, "InvalidCapabilityInterruptPair"},
    PathPair{0xE209, "InvalidCapabilityApplicationType"},
    PathPair{0xE409, "InvalidCapabilityKernelVersion"},
    PathPair{0xE609, "InvalidCapabilityHandleTable"},
    PathPair{0xE809, "InvalidCapabilityDebugFlags"},
    PathPair{0x1940A, "InvalidCmifHeaderSize"},
    PathPair{0x1A60A, "InvalidCmifInHeader"},
    PathPair{0x1A80A, "InvalidCmifOutHeader"},
    PathPair{0x1BA0A, "UnknownMethodId"},
    PathPair{0x1D60A, "InvalidInObjectCount"},
    PathPair{0x1D80A, "InvalidOutObjectCount"},
    PathPair{0x25A0A, "OutOfDomainEntry"},
    PathPair{0x20B, "NotSupported"},
    PathPair{0xCC0B, "OutOfSessionMemory"},
    PathPair{0x11A0B, "InsufficientPointerTransferBuffer"},
    PathPair{0x1900B, "OutOfDomains"},
    PathPair{0x25A0B, "SessionClosed"},
    PathPair{0x3240B, "InvalidRequestSize"},
    PathPair{0x3260B, "UnknownCommandType"},
    PathPair{0x3D60B, "TargetNotDomain"},
    PathPair{0x20F, "ProcessNotFound"},
    PathPair{0x60F, "NotTerminated"},
    PathPair{0xA0F, "ApplicationRunning"},
    PathPair{0x410, "Title-id not found."},
    PathPair{0xF010, "Sysupdate not required."},
    PathPair{0x1F610, "Unexpected StorageId."},
    PathPair{0x2A810, "IsAnyInternetRequestAccepted with the output from GetClientId returned false."},
    PathPair{0x64210, "SystemDeliveryInfo system_delivery_protocol_version is less than the system-setting."},
    PathPair{0x64410, "SystemDeliveryInfo system_delivery_protocol_version is larger than the system-setting."},
    PathPair{0x6F810, "Unknown state ref-count is zero."},
    PathPair{0x74610, "Invalid SystemDeliveryInfo HMAC / invalid Meta Id."},
    PathPair{0x215, "OutOfProcesses"},
    PathPair{0x415, "InvalidClient"},
    PathPair{0x615, "OutOfSessions"},
    PathPair{0x815, "AlreadyRegistered"},
    PathPair{0xA15, "OutOfServices"},
    PathPair{0xC15, "InvalidServiceName"},
    PathPair{0xE15, "NotRegistered"},
    PathPair{0x1015, "NotAllowed"},
    PathPair{0x1215, "TooLargeAccessControl"},
    PathPair{0x416, "ResultOutOfAddressSpace"},
    PathPair{0x616, "ResultNroAlreadyLoaded"},
    PathPair{0x816, "ResultInvalidNroImage"},
    PathPair{0xC16, "ResultInvalidNrrImage"},
    PathPair{0x1016, "ResultMaxRegistration"},
    PathPair{0x1216, "ResultNotAuthorized"},
    PathPair{0x80216, "InvalidAddress"},
    PathPair{0x80416, "InvalidSize"},
    PathPair{0x80816, "NotLoaded"},
    PathPair{0x80A16, "NotRegistered"},
    PathPair{0x80C16, "InvalidSession"},
    PathPair{0x80E16, "InvalidProcess"},
    PathPair{0x21A, "SecureMonitorNotImplemented"},
    PathPair{0x41A, "SecureMonitorInvalidArgument"},
    PathPair{0x61A, "SecureMonitorBusy"},
    PathPair{0x81A, "SecureMonitorNoAsyncOperation"},
    PathPair{0xA1A, "SecureMonitorInvalidAsyncOperation"},
    PathPair{0xC1A, "SecureMonitorNotPermitted"},
    PathPair{0xC81A, "InvalidSize"},
    PathPair{0xCA1A, "UnknownSecureMonitorError"},
    PathPair{0xCC1A, "DecryptionFailed"},
    PathPair{0xD01A, "OutOfKeySlots"},
    PathPair{0xD21A, "InvalidKeySlot"},
    PathPair{0xD41A, "BootReasonAlreadySet"},
    PathPair{0xD61A, "BootReasonNotSet"},
    PathPair{0xD81A, "InvalidArgument"},
    PathPair{0x1423, "Invalid command ID received by tipc processor."},
    PathPair{0x1E23, "Invalid message format received by tipc processor."},
    PathPair{0xC823, "Tipc request was deferred for future processing (internal to the processor, never returned externally)."},
    PathPair{0xCA23, "Tipc object was closed (via close command 0xF, internal, never returned externally)."},
    PathPair{0x19269, "SettingsNameNull"},
    PathPair{0x19469, "SettingsItemKeyNull"},
    PathPair{0x19669, "SettingsItemValueNull"},
    PathPair{0x19A69, "SettingsItemValueBufferNull"},
    PathPair{0x1A069, "Null setting value size buffer."},
    PathPair{0x1A269, "Null debug mode flag buffer."},
    PathPair{0x1BA69, "SettingsNameEmpty"},
    PathPair{0x1BC69, "SettingsItemKeyEmpty"},
    PathPair{0x1E269, "SettingsNameTooLong"},
    PathPair{0x1E469, "SettingsItemKeyTooLong"},
    PathPair{0x20A69, "SettingsNameInvalidFormat"},
    PathPair{0x20C69, "SettingsItemKeyInvalidFormat"},
    PathPair{0x4DA69, "Null language code buffer."},
    PathPair{0x4E269, "Language out of valid range."},
    PathPair{0x4EE69, "Null network settings buffer."},
    PathPair{0x4F069, "Null network settings output count buffer."},
    PathPair{0x50269, "Null backlight settings buffer."},
    PathPair{0x51669, "Null Bluetooth device setting buffer."},
    PathPair{0x51869, "Null Bluetooth device setting output count buffer."},
    PathPair{0x51A69, "Null Bluetooth enable flag buffer."},
    PathPair{0x51C69, "Null Bluetooth AFH enable flag buffer."},
    PathPair{0x51E69, "Null Bluetooth boost enable flag buffer."},
    PathPair{0x52069, "Null BLE pairing settings buffer."},
    PathPair{0x52269, "Null BLE pairing settings entry count buffer."},
    PathPair{0x52A69, "Null external steady clock source ID buffer."},
    PathPair{0x52C69, "Null user system clock context buffer."},
    PathPair{0x52E69, "Null network system clock context buffer."},
    PathPair{0x53069, "Null user system clock automatic correction enabled flag buffer."},
    PathPair{0x53269, "Null shutdown RTC value buffer."},
    PathPair{0x53469, "Null external steady clock internal offset buffer."},
    PathPair{0x53E69, "Null account settings buffer."},
    PathPair{0x55269, "Null audio volume buffer."},
    PathPair{0x55669, "Null ForceMuteOnHeadphoneRemoved buffer."},
    PathPair{0x55869, "Null headphone volume warning count buffer."},
    PathPair{0x55E69, "Invalid audio output mode."},
    PathPair{0x56069, "Null headphone volume update flag buffer."},
    PathPair{0x56669, "Null console information upload flag buffer."},
    PathPair{0x57A69, "Null automatic application download flag buffer."},
    PathPair{0x57C69, "Null notification settings buffer."},
    PathPair{0x57E69, "Null account notification settings entry count buffer."},
    PathPair{0x58069, "Null account notification settings buffer."},
    PathPair{0x58E69, "Null vibration master volume buffer."},
    PathPair{0x59069, "Null NX controller settings buffer."},
    PathPair{0x59269, "Null NX controller settings entry count buffer."},
    PathPair{0x59469, "Null USB full key enable flag buffer."},
    PathPair{0x5A269, "Null TV settings buffer."},
    PathPair{0x5A469, "Null EDID buffer."},
    PathPair{0x5B669, "Null data deletion settings buffer."},
    PathPair{0x5CA69, "Null initial system applet program ID buffer."},
    PathPair{0x5CC69, "Null overlay disp program ID buffer."},
    PathPair{0x5CE69, "Null IsInRepairProcess buffer."},
    PathPair{0x5D069, "Null RequiresRunRepairTimeReviser buffer."},
    PathPair{0x5DE69, "Null device timezone location name buffer."},
    PathPair{0x5F269, "Null primary album storage buffer."},
    PathPair{0x60669, "Null USB 3.0 enable flag buffer."},
    PathPair{0x60869, "Null USB Type-C power source circuit version buffer."},
    PathPair{0x61A69, "Null battery lot buffer."},
    PathPair{0x62E69, "Null serial number buffer."},
    PathPair{0x64269, "Null lock screen flag buffer."},
    PathPair{0x64669, "Null color set ID buffer."},
    PathPair{0x64869, "Null quest flag buffer."},
    PathPair{0x64A69, "Null wireless certification file size buffer."},
    PathPair{0x64C69, "Null wireless certification file buffer."},
    PathPair{0x64E69, "Null initial launch settings buffer."},
    PathPair{0x65069, "Null device nickname buffer."},
    PathPair{0x65269, "Null battery percentage flag buffer."},
    PathPair{0x65469, "Null applet launch flags buffer."},
    PathPair{0x7E869, "Null wireless LAN enable flag buffer."},
    PathPair{0x7FA69, "Null product model buffer."},
    PathPair{0x80E69, "Null NFC enable flag buffer."},
    PathPair{0x82269, "Null ECI device certificate buffer."},
    PathPair{0x82469, "Null E-Ticket device certificate buffer."},
    PathPair{0x83669, "Null sleep settings buffer."},
    PathPair{0x84A69, "Null EULA version buffer."},
    PathPair{0x84C69, "Null EULA version entry count buffer."},
    PathPair{0x85E69, "Null LDN channel buffer."},
    PathPair{0x87269, "Null SSL key buffer."},
    PathPair{0x87469, "Null SSL certificate buffer."},
    PathPair{0x88669, "Null telemetry flags buffer."},
    PathPair{0x89A69, "Null Gamecard key buffer."},
    PathPair{0x89C69, "Null Gamecard certificate buffer."},
    PathPair{0x8AE69, "Null PTM battery lot buffer."},
    PathPair{0x8B069, "Null PTM fuel gauge parameter buffer."},
    PathPair{0x8C269, "Null ECI device key buffer."},
    PathPair{0x8C469, "Null E-Ticket device key buffer."},
    PathPair{0x8D669, "Null speaker parameter buffer."},
    PathPair{0x8EA69, "Null firmware version buffer."},
    PathPair{0x8EC69, "Null firmware version digest buffer."},
    PathPair{0x8EE69, "Null rebootless system update version buffer."},
    PathPair{0x8FE69, "Null Mii author ID buffer."},
    PathPair{0x91269, "Null fatal flags buffer."},
    PathPair{0x92669, "Null auto update enable flag buffer."},
    PathPair{0x93A69, "Null external RTC reset flag buffer."},
    PathPair{0x94E69, "Null push notification activity mode buffer."},
    PathPair{0x96269, "Null service discovery control setting buffer."},
    PathPair{0x97669, "Null error report share permission buffer."},
    PathPair{0x98A69, "Null LCD vendor ID buffer."},
    PathPair{0x99E69, "Null console SixAxis sensor acceleration bias buffer."},
    PathPair{0x9A069, "Null console SixAxis sensor angular velocity bias buffer."},
    PathPair{0x9A269, "Null console SixAxis sensor acceleration gain buffer."},
    PathPair{0x9A469, "Null console SixAxis sensor angular velocity gain buffer."},
    PathPair{0x9A669, "Null console SixAxis sensor angular velocity time bias buffer."},
    PathPair{0x9A869, "Null console SixAxis sensor angular acceleration buffer."},
    PathPair{0x9B269, "Null keyboard layout buffer."},
    PathPair{0x9BA69, "Invalid keyboard layout."},
    PathPair{0x9C669, "Null web inspector flag buffer."},
    PathPair{0x9C869, "Null allowed SSL hosts buffer."},
    PathPair{0x9CA69, "Null allowed SSL hosts entry count buffer."},
    PathPair{0x9CC69, "Null host FS mount point buffer."},
    PathPair{0x9EE69, "Null Amiibo key buffer."},
    PathPair{0x9F069, "Null Amiibo ECQV certificate buffer."},
    PathPair{0x9F269, "Null Amiibo ECDSA certificate buffer."},
    PathPair{0x9F469, "Null Amiibo ECQV BLS key buffer."},
    PathPair{0x9F669, "Null Amiibo ECQV BLS certificate buffer."},
    PathPair{0x9F869, "Null Amiibo ECQV BLS root certificate buffer."},
    PathPair{0x272, "ResultOperationFailed"},
    PathPair{0xC72, "ResultNotSupported"},
    PathPair{0x74, "ResultNotInitialized"},
    PathPair{0x274, "ResultNoCapability"},
    PathPair{0xCC74, "OffsetInvalid"},
    PathPair{0xCE74, "UninitializedClock"},
    PathPair{0x19074, "ResultNotComparable"},
    PathPair{0x19274, "ResultOverflowed"},
    PathPair{0x64274, "ResultOutOfMemory"},
    PathPair{0x70A74, "InvalidPointer"},
    PathPair{0x70C74, "OutOfRange"},
    PathPair{0x70E74, "InvalidTimeZoneBinary"},
    PathPair{0x7BA74, "NotFound"},
    PathPair{0x7BC74, "NotImplemented"},
    PathPair{0xC79, "ResultInternetRequestNotAccepted"},
    PathPair{0x27A, "ResultInvalidArgument"},
    PathPair{0x47A, "ResultNotFound"},
    PathPair{0x67A, "ResultLocked"},
    PathPair{0x87A, "ResultAlreadyMounted"},
    PathPair{0xA7A, "ResultNotMounted"},
    PathPair{0xC7A, "ResultAlreadyOpened"},
    PathPair{0xE7A, "ResultNotOpened"},
    PathPair{0x107A, "ResultInternetRequestNotAccepted"},
    PathPair{0xA07A, "ResultPassphraseNotSaved"},
    PathPair{0xA27A, "ResultDataVerificationFailed"},
    PathPair{0xB47A, "ResultNotPermitted"},
    PathPair{0xC47A, "ResultInvalidOperation"},
    PathPair{0x167B, "ResultErrorLower"},
    PathPair{0x1A7B, "ResultInternalLogicError"},
    PathPair{0xCC7B, "ResultInsufficientMemory"},
    PathPair{0xE87B, "ResultInvalidSocketDescriptor"},
    PathPair{0x1027B, "ResultInvalidCrlFormat"},
    PathPair{0x1987B, "ResultIoWouldBlock"},
    PathPair{0x19A7B, "ResultIoTimeout"},
    PathPair{0x19C7B, "ResultIoAborted"},
    PathPair{0x1A07B, "ResultNoConnection"},
    PathPair{0x1A27B, "ResultConnectionReset"},
    PathPair{0x1A47B, "ResultConnectionAborted"},
    PathPair{0x1A67B, "ResultSocketShutdown"},
    PathPair{0x1A87B, "ResultNetworkDown"},
    PathPair{0x1AE7B, "ResultClientPkiAlreadyRegistered"},
    PathPair{0x1B47B, "ResultMaxServerPkiRegistered"},
    PathPair{0x25A7B, "ResultSslErrorInvalidCertDomain"},
    PathPair{0x25C7B, "ResultSslErrorNoCertificate"},
    PathPair{0x25E7B, "ResultSslErrorExpiredCertificate"},
    PathPair{0x2607B, "ResultSslErrorRevokedCertificate"},
    PathPair{0x2627B, "ResultSslErrorUnsupportedCertificate"},
    PathPair{0x2647B, "ResultSslErrorUnknownCertificate"},
    PathPair{0x2667B, "ResultSslErrorBadCertificate"},
    PathPair{0x2687B, "ResultSslErrorUnkownCa"},
    PathPair{0x26A7B, "ResultSslErrorAccessDenied"},
    PathPair{0x26C7B, "ResultSslErrorReceivedUnkownData"},
    PathPair{0x26E7B, "ResultSslErrorReceivedMalformedData"},
    PathPair{0x2707B, "ResultSslErrorReceivedUnexpectedHandshakeData"},
    PathPair{0x2727B, "ResultSslErrorReceivedUnexpectedRecordData"},
    PathPair{0x2747B, "ResultSslErrorReceivedTooLongRecord"},
    PathPair{0x2767B, "ResultSslErrorUnexpectedHelloVerifyRequest"},
    PathPair{0x2787B, "ResultSslErrorUnexpectedCertificateStatusResponse"},
    PathPair{0x27A7B, "ResultSslErrorInconsistentSignAlgorithm"},
    PathPair{0x27C7B, "ResultSslErrorInsufficientSecurity"},
    PathPair{0x27E7B, "ResultSslErrorDecryptionWithInvalidMac"},
    PathPair{0x2827B, "ResultSslErrorDigestCalculationFailed"},
    PathPair{0x2847B, "ResultSslErrorMacCalculationFailed"},
    PathPair{0x2887B, "ResultSslErrorNoExtendedField"},
    PathPair{0x28A7B, "ResultSslErrorUntrustedOid"},
    PathPair{0x28C7B, "ResultSslErrorInvalidPolicy"},
    PathPair{0x2947B, "ResultSslErrorDecompressionFailed"},
    PathPair{0xBBA7B, "ResultSslAlertCloseNotify"},
    PathPair{0xBBC7B, "ResultSslAlertUnexpectedMessage"},
    PathPair{0xBBE7B, "ResultSslAlertBadRecordMac"},
    PathPair{0xBC07B, "ResultSslAlertDecriptionFailed"},
    PathPair{0xBC27B, "ResultSslAlertRecordOverfrlow"},
    PathPair{0xBC47B, "ResultSslAlertDecompressionFailure"},
    PathPair{0xBC67B, "ResultSslAlertHandshakeFailure"},
    PathPair{0xBCA7B, "ResultSslAlertBadCertificate"},
    PathPair{0xBCC7B, "ResultSslAlertUnsupportedCertificate"},
    PathPair{0xBCE7B, "ResultSslAlertCertificateRevoked"},
    PathPair{0xBD07B, "ResultSslAlertCertificateExpired"},
    PathPair{0xBD27B, "ResultSslAlertCertificateUnkown"},
    PathPair{0xBD47B, "ResultSslAlertIllegalParameter"},
    PathPair{0xBD67B, "ResultSslAlertUnknownCa"},
    PathPair{0xBD87B, "ResultSslAlertAccessDenied"},
    PathPair{0xBDA7B, "ResultSslAlertDecodeError"},
    PathPair{0xBDC7B, "ResultSslAlertDecryptError"},
    PathPair{0xBDE7B, "ResultSslAlertExportRestriction"},
    PathPair{0xBE07B, "ResultSslAlertProtocolVersion"},
    PathPair{0xBE27B, "ResultSslAlertInsufficientSecurity"},
    PathPair{0xBE47B, "ResultSslAlertInternalError"},
    PathPair{0xBE67B, "ResultSslAlertInappropriateFallback"},
    PathPair{0xBE87B, "ResultSslAlertUserCancelled"},
    PathPair{0xBEA7B, "ResultSslAlertNoRenegotiation"},
    PathPair{0xBEC7B, "ResultSslAlertUnsupportedExtention"},
    PathPair{0xBEE7B, "ResultSslAlertCertificateUnobtainable"},
    PathPair{0xBF07B, "ResultSslAlertUnrecognizedName"},
    PathPair{0xBF27B, "ResultSslAlertBadCertificateStatusResponse"},
    PathPair{0xBF47B, "ResultSslAlertBadCertificateHashValue"},
    PathPair{0x27127B, "Converted from NSS SSL error -12155 (SSL_ERROR_RX_SHORT_DTLS_READ)."},
    PathPair{0x271E7B, "Out-of-bounds error during error conversion."},
    PathPair{0x7C, "ResultCancelled"},
    PathPair{0x27C, "ResultCancelledByUser"},
    PathPair{0x287C, "ResultInvalidUserId"},
    PathPair{0x2A7C, "ResultInvalidUserPosition"},
    PathPair{0x2C7C, "ResultInvalidApplication"},
    PathPair{0x3C7C, "ResultNullptr"},
    PathPair{0x3E7C, "ResultInsufficientBuffer"},
    PathPair{0x407C, "ResultInvalidArrayLength"},
    PathPair{0x427C, "ResultInvalidStringFormat"},
    PathPair{0x447C, "ResultValueOutOfRange"},
    PathPair{0x507C, "ResultInvalidObjectAccess"},
    PathPair{0x527C, "ResultInvalidProtocolAccess"},
    PathPair{0x767C, "ResultInternetConnectionRequestNotAccepted"},
    PathPair{0xC87C, "ResultUserNotExist"},
    PathPair{0xCA7C, "ResultUserAlreadyOpened"},
    PathPair{0xCC7C, "ResultUserAlreadyClosed"},
    PathPair{0xCE7C, "ResultUserReferred"},
    PathPair{0xD07C, "ResultUserUnqualified"},
    PathPair{0xD27C, "ResultNeverBeenQualified"},
    PathPair{0x1907C, "ResultNetworkServiceAccountRegistrationRequired"},
    PathPair{0x1A47C, "ResultNetworkServiceAccountCredentialBroken"},
    PathPair{0x1A67C, "ResultNetworkServiceAccountUnmanaged"},
    PathPair{0x1A87C, "ResultNetworkServiceAccountBanned"},
    PathPair{0x1CC7C, "ResultNintendoAccountLinkageBroken"},
    PathPair{0x1E07C, "ResultNintendoAccountStateOtherButInteractionRequired"},
    PathPair{0x1E27C, "ResultNintendoAccountStateDeleted"},
    PathPair{0x1E47C, "ResultNintendoAccountStateBanned"},
    PathPair{0x1E67C, "ResultNintendoAccountStateSuspended"},
    PathPair{0x1E87C, "ResultNintendoAccountStateWithdrawn"},
    PathPair{0x1EA7C, "ResultNintendoAccountStateTermsAgreementRequired"},
    PathPair{0x2067C, "ResultNintendoAccountStateReauthorizationRequired"},
    PathPair{0x17707C, "ResultUnacceptableSystemVersion"},
    PathPair{0x17727C, "ResultUnacceptableApplicationVersion"},
    PathPair{0x1F4E7C, "Account Permanent Ban"},
    PathPair{0x23387C, "Account Permanent Ban"},
    PathPair{0x234A7C, "Account Ban"},
    PathPair{0x24027C, "Service Discontinued"},
    PathPair{0x27107C, "ResultInvalidParams"},
    PathPair{0x27127C, "ResultInvalidRequest"},
    PathPair{0x27147C, "ResultInvalidDeviceAccount"},
    PathPair{0x27167C, "ResultInvalidNdasAppAuthnToken"},
    PathPair{0x27187C, "ResultInvalidIdp"},
    PathPair{0x271A7C, "ResultInvalidIdpAccount"},
    PathPair{0x271C7C, "ResultLinkedUserNotFound"},
    PathPair{0x271E7C, "ResultInvalidFriendCodeFormat"},
    PathPair{0x27207C, "ResultUserLinkNotExist"},
    PathPair{0x27D87C, "ResultInvalidRawContent"},
    PathPair{0x27DA7C, "ResultInsufficientScope"},
    PathPair{0x27DC7C, "ResultForbidden"},
    PathPair{0x27DE7C, "ResultUnavailableDeviceAccount"},
    PathPair{0x27E07C, "ResultResourceIsNotFound"},
    PathPair{0x27E27C, "ResultMethodNotAllowed"},
    PathPair{0x27E47C, "ResultNotAcceptableLanguage"},
    PathPair{0x27E67C, "ResultResourceAlreadyExists"},
    PathPair{0x27E87C, "ResultUserLinkAlreadyExists"},
    PathPair{0x27EA7C, "ResultPreconditionFailed"},
    PathPair{0x27EC7C, "ResultFriendCodeUnregenerableState"},
    PathPair{0x27EE7C, "ResultBannedUser"},
    PathPair{0x27F07C, "ResultDeletedUser"},
    PathPair{0x27F27C, "ResultMembershipRequired"},
    PathPair{0x27F47C, "ResultBannedUserByApplication"},
    PathPair{0x28A07C, "ResultInternalServerError"},
    PathPair{0x28B47C, "ResultCouldNotConfirmMembership"},
    PathPair{0x29027C, "ResultUnderMaintenance"},
    PathPair{0x27E, "ResultInvalid"},
    PathPair{0x87E, "ResultNotFound"},
    PathPair{0xCE7E, "Invalid database signature value (should be NFDB)."},
    PathPair{0xD27E, "Invalid database entry count."},
    PathPair{0x1987E, "ResultDevelopmentOnly"},
    PathPair{0x480, "IStorage not available."},
    PathPair{0x680, "No messages."},
    PathPair{0x4680, "Error while launching applet."},
    PathPair{0x4A80, "Title-ID not found. Caused by code 0x410 when applet launch fails."},
    PathPair{0x3E880, "Invalid input."},
    PathPair{0x3EC80, "IStorage has already been opened by another accessor."},
    PathPair{0x3EE80, "IStorage Read/Write out-of-bounds."},
    PathPair{0x3F480, "Invalid parameters."},
    PathPair{0x3FE80, "IStorage opened as wrong type (data opened as transfermem, transfermem opened as data)."},
    PathPair{0x40080, "Unbalanced fatal section leave (returned when executing LeaveFatalSection without a preceding EnterFatalSection call)."},
    PathPair{0x40C80, "Null object."},
    PathPair{0x4B080, "Failed to allocate memory for IStorage."},
    PathPair{0x59080, "Thread stack pool exhausted (out of memory)."},
    PathPair{0x79C80, "DebugMode not enabled."},
    PathPair{0x7A880, "am.debug!dev_function setting needs to be set / DebugMode not enabled."},
    PathPair{0x7CC80, "Not implemented."},
    PathPair{0xCC81, "Transmission not agreed."},
    PathPair{0xD281, "Network unavailable."},
    PathPair{0x7DA81, "HTTP error: Couldnt resolve proxy."},
    PathPair{0x7DC81, "HTTP error: Couldnt resolve host."},
    PathPair{0x7DE81, "HTTP error: Couldnt connect."},
    PathPair{0x7FE81, "HTTP error: Write error."},
    PathPair{0x80481, "HTTP error: Read error."},
    PathPair{0x80681, "HTTP error: Out of memory."},
    PathPair{0x80881, "HTTP error: Operation timedout."},
    PathPair{0x81681, "HTTP error: SSL connect error."},
    PathPair{0x83681, "HTTP error: Peer failed verification."},
    PathPair{0x83881, "HTTP error: Got nothing."},
    PathPair{0x83E81, "HTTP error: Send error."},
    PathPair{0x84081, "HTTP error: Recv error."},
    PathPair{0x84481, "HTTP error: SSL cert problem."},
    PathPair{0x84681, "HTTP error: SSL cipher."},
    PathPair{0x84881, "HTTP error: SSL CA cert."},
    PathPair{0x12C081, "Server error: Status 400."},
    PathPair{0x12C281, "Server error: Status 401."},
    PathPair{0x12C681, "Server error: Status 403."},
    PathPair{0x138881, "Server error: Status 500."},
    PathPair{0x138E81, "Server error: Status 503."},
    PathPair{0x139081, "Server error: Status 504."},
    PathPair{0xA83, "Unrecognized applet ID."},
    PathPair{0x485, "Invalid DVFS table ID."},
    PathPair{0x685, "DVFS table ID for debug only."},
    PathPair{0x885, "Invalid parameter."},
    PathPair{0x1489, "Already initialized."},
    PathPair{0x3C89, "Task not found."},
    PathPair{0x5089, "Memory allocation failed / bad input."},
    PathPair{0x29489, "ContentMetaType doesn't match SystemUpdate."},
    PathPair{0x271289, "One of the following socket errors occurred: ENETDOWN, ECONNRESET, EHOSTDOWN, EHOSTUNREACH, or EPIPE., Also occurs when the received size doesn't match the expected size (recvfrom() ret with meta_size data receiving)."},
    PathPair{0x272489, "Socket was shutdown() due to the async operation being cancelled."},
    PathPair{0x273889, "Too many internal output entries with nim cmd42, system is Internet-connected, or an unrecognized socket error occured."},
    PathPair{0x27D889, "Connection timeout."},
    PathPair{0x2A4489, "Invalid ID."},
    PathPair{0x2A5889, "Invalid magicnum. Can also be caused by the connection being closed by the peer, since non-negative return values from recv() are ignored in this case."},
    PathPair{0x2A6C89, "Invalid data_size."},
    PathPair{0x2A8089, "The input ContentMetaKey doesn't match the ContentMetaKey in state."},
    PathPair{0x2A9489, "Invalid meta_size."},
    PathPair{0x36B289, "HTTP invalid response code (>=600)."},
    PathPair{0x36B489, "HTTP invalid client response code (4xx)."},
    PathPair{0x36B689, "HTTP invalid server response code (5xx)."},
    PathPair{0x36B889, "HTTP invalid redirect response code (3xx)."},
    PathPair{0x3CF089, "Unknown/invalid libcurl error."},
    PathPair{0x68A, "NotInitialized"},
    PathPair{0x28C, "ResultInterfaceInvalid"},
    PathPair{0xA8C, "ResultMemAllocFailure"},
    PathPair{0x108C, "ResultInternalStateError"},
    PathPair{0x1E8C, "ResultEndpointStateInvalid"},
    PathPair{0x2A8C, "ResultUrbLimitExceeded"},
    PathPair{0x608C, "ResultInvalidDeviceState"},
    PathPair{0x628C, "ResultUsbEndpointAlreadyOpen"},
    PathPair{0x648C, "ResultInvalidAlternateSetting"},
    PathPair{0x668C, "USB data-transfer in progress."},
    PathPair{0x868C, "ResultPlatformInvalid"},
    PathPair{0xC88C, "ResultInvalidArgument"},
    PathPair{0xCA8C, "ResultInvalidOffset"},
    PathPair{0xCC8C, "ResultInvalidSize"},
    PathPair{0xCE8C, "ResultInvalidAlignment"},
    PathPair{0xD48C, "Invalid descriptor."},
    PathPair{0x1928C, "ResultOperationDenied"},
    PathPair{0x1BE8E, "IsAnyInternetRequestAccepted with the output from GetClientId returned false."},
    PathPair{0x290, "Exited Abnormally (ExitReason == Abormal)."},
    PathPair{0x690, "Canceled (ExitReason == Canceled)."},
    PathPair{0x890, "Rejected."},
    PathPair{0xA90, "Exited Unexpectedly (ExitReason == Unexpected)."},
    PathPair{0x293, "NotInitialized"},
    PathPair{0x493, "AlreadyInitialized"},
    PathPair{0x693, "OutOfArraySpace"},
    PathPair{0x893, "OutOfFieldSpace"},
    PathPair{0xA93, "OutOfMemory"},
    PathPair{0xC93, "NotSupported"},
    PathPair{0xE93, "InvalidArgument"},
    PathPair{0x1093, "NotFound"},
    PathPair{0x1293, "FieldCategoryMismatch"},
    PathPair{0x1493, "FieldTypeMismatch"},
    PathPair{0x1693, "AlreadyExists"},
    PathPair{0x1893, "CorruptJournal"},
    PathPair{0x1A93, "CategoryNotFound"},
    PathPair{0x1C93, "RequiredContextMissing"},
    PathPair{0x1E93, "RequiredFieldMissing"},
    PathPair{0x2093, "FormatterError"},
    PathPair{0x2293, "InvalidPowerState"},
    PathPair{0x2493, "ArrayFieldTooLarge"},
    PathPair{0x2693, "AlreadyOwned"},
    PathPair{0x299, "ResultNotFound"},
    PathPair{0x499, "ResultOperationFailed"},
    PathPair{0x699, "ResultInvalidSampleRate"},
    PathPair{0x899, "ResultInsufficientBuffer"},
    PathPair{0x1099, "Too many buffers are still unreleased."},
    PathPair{0x1499, "ResultInvalidChannelCount"},
    PathPair{0x40299, "ResultNotSupported"},
    PathPair{0xC0099, "Invalid handle."},
    PathPair{0xC0899, "Audio output was already started."},
    PathPair{0x3C9D, "Address is NULL."},
    PathPair{0x3E9D, "PID is NULL."},
    PathPair{0x549D, "Already bound."},
    PathPair{0xCC9D, "Invalid PID."},
    PathPair{0x49E, "BootImagePackageNotFound"},
    PathPair{0x69E, "InvalidBootImagePackage"},
    PathPair{0x89E, "TooSmallWorkBuffer"},
    PathPair{0xA9E, "NotAlignedWorkBuffer"},
    PathPair{0xC9E, "NeedsRepairBootImages"},
    PathPair{0x29F, "ResultCanceled"},
    PathPair{0x2A2, "ApplicationAborted"},
    PathPair{0x4A2, "SystemModuleAborted"},
    PathPair{0x6A2, "ApplicationExitTimeout"},
    PathPair{0x8A2, "ForcedShutdownDetected"},
    PathPair{0xC8A2, "UnacceptableApplicationVersion"},
    PathPair{0xCAA2, "UnacceptableAddOnContentVersion"},
    PathPair{0xAA3, "InRepairWithoutVolHeld"},
    PathPair{0xCA3, "InRepairWithoutTimeReviserCartridge"},
    PathPair{0x70A4, "ResultInternetRequestNotAccepted"},
    PathPair{0xA8, "UndefinedInstruction"},
    PathPair{0x2A8, "InstructionAbort"},
    PathPair{0x4A8, "DataAbort"},
    PathPair{0x6A8, "AlignmentFault"},
    PathPair{0x8A8, "DebuggerAttached"},
    PathPair{0xAA8, "BreakPoint"},
    PathPair{0xCA8, "UserBreak"},
    PathPair{0xEA8, "DebuggerBreak"},
    PathPair{0x10A8, "UndefinedSystemCall"},
    PathPair{0x12A8, "MemorySystemError"},
    PathPair{0xC6A8, "IncompleteReport"},
    PathPair{0x4AF, "Bad version returned from calling the nnjitpluginGetVersion symbol."},
    PathPair{0xCAAF, "Input NRO/NRR are too large for the storage buffer."},
    PathPair{0x4B0AF, "Symbol funcptr used by this cmd is not initialized (Control/GenerateCode)."},
    PathPair{0x4B2AF, "DllPlugin Not initialized, or plugin NRO has already been loaded."},
    PathPair{0x4B4AF, "An error was returned from calling the symbol funcptr with the Control cmd."},
    PathPair{0xC8B2, "Invalid user ID."},
    PathPair{0xCAB2, "User does not exist."},
    PathPair{0x12CB2, "Service unavailable."},
    PathPair{0x190B2, "File storage failure."},
    PathPair{0xAB4, "Invalid event ID."},
    PathPair{0x7D0B5, "Invalid ELicense ID."},
    PathPair{0x1F4EB5, "Device authentication error: System update required."},
    PathPair{0x1F50B5, "Device authentication error: Permanant Ban."},
    PathPair{0x1F52B5, "Device authentication error: Internal server error."},
    PathPair{0x1F54B5, "Device authentication error: Under maintenance."},
    PathPair{0x1F62B5, "Device authentication error: Ban."},
    PathPair{0x58ACA, "Npad ID is out of range."},
    PathPair{0x2032CA, "ButtonConfigSettings IsFull flag is clear."},
    PathPair{0x28CB, "The [6.0.0+] Authentication challenge failed."},
    PathPair{0x82CB, "ResultNetworkNotFound"},
    PathPair{0x84CB, "ResultConnectionTimeout"},
    PathPair{0x86CB, "ResultConnectionRejected"},
    PathPair{0xC2CB, "Matching LocalCommunicationId not found in the user-process control.nacp."},
    PathPair{0xE2CB, "ResultLowerVersion"},
    PathPair{0xE4CB, "ResultHigherVersion"},
    PathPair{0xF0CD, "IrsensorNotReady"},
    PathPair{0x198CD, "IR camera invalid handle value."},
    PathPair{0x1A8CD, "IR camera handle pointer is null."},
    PathPair{0x6CE, "AlbumWorkMemoryError"},
    PathPair{0x10CE, "AlbumOutOfRange"},
    PathPair{0x18CE, "AlbumInvalidTimestamp"},
    PathPair{0x1ACE, "AlbumInvalidStorage"},
    PathPair{0x1CCE, "AlbumInvalidFileContents"},
    PathPair{0x2ACE, "AlbumIsNotMounted"},
    PathPair{0x2CCE, "AlbumFileNotFound"},
    PathPair{0x30CE, "AlbumInvalidFileData"},
    PathPair{0x3CCE, "AlbumReadBufferShortage"},
    PathPair{0xAF2CE, "InternalAlbumLimitationFileCountLimit"},
    PathPair{0x4DA, "StatusManager entry IsValid flag not set, or controller-update currently in-progress."},
    PathPair{0x6DA, "Controller-update failed via the LibraryApplet."},
    PathPair{0x8DA, "Invalid BusHandle."},
    PathPair{0xADA, "StatusManager entry flag +0x0 not set, or device not connected."},
    PathPair{0xEDA, "PollingReceivedData not available."},
    PathPair{0x10DA, "StatusManager entry DeviceEnabled flag not set, or flag +0x0 not set."},
    PathPair{0x12DA, "ExternalDeviceId mismatch."},
    PathPair{0x14DA, "BusHandle already initialized."},
    PathPair{0x104E7, "Nullptr passed to the LocalCommunicationId control.nacp validation func."},
    PathPair{0x140E7, "GroupInfo field out of range."},
    PathPair{0x142E7, "SupportedPlatform not appropriate for this operation."},
    PathPair{0x146E7, "Invalid ServiceName."},
    PathPair{0x148E7, "Must provide PresharedBinaryKey."},
    PathPair{0x1C0E7, "Requested Priority value not allowed."},
    PathPair{0x1C2E7, "Matching LocalCommunicationId not found in the user-process control.nacp."},
    PathPair{0x200E7, "Invalid flag."},
    PathPair{0x204E7, "Invalid SupportedPlatform."},
    PathPair{0x208E7, "Invalid StaticAesKeyIndex."},
    PathPair{0x20AE7, "MemberCountMax cannot be greater than 8."},
    PathPair{0x210E7, "GroupInfo+8F must be 0x20."},
};
#endif

// 1.6 MiB (1,704,522)
// 1.6 MiB (1,712,714)
// 1.7 MiB (1,774,154)
} // namespace

ErrorBox::ErrorBox(Result code, const std::string& message)
: m_code{code}
, m_message{message} {

    m_pos.w = 770.f;
    m_pos.h = 430.f;
    m_pos.x = 255;
    m_pos.y = 145;

    SetAction(Button::A, Action{[this](){
        SetPop();
    }});

    // try and find module
    for (auto& [m, str] : HOS_MODULES) {
        if (m == R_MODULE(m_code)) {
            m_module_str = str;
        }
    }

    // try and find error
    #if 1
    for (auto& [m, str] : HOS_RESULT) {
        if (m == m_code) {
            m_description_str = str;
        }
    }
    #endif

    if (m_module_str.empty()) {
        char buf[64];
        std::snprintf(buf, sizeof(buf), "%u", R_MODULE(m_code));
        m_module_str = buf;
    }

    if (m_description_str.empty()) {
        char buf[64];
        std::snprintf(buf, sizeof(buf), "%u", R_DESCRIPTION(m_code));
        m_description_str = buf;
    }

    App::PlaySoundEffect(SoundEffect::SoundEffect_Error);
}

auto ErrorBox::Update(Controller* controller, TouchInfo* touch) -> void {
    Widget::Update(controller, touch);
}

auto ErrorBox::OnLayoutChange() -> void {

}

auto ErrorBox::Draw(NVGcontext* vg, Theme* theme) -> void {
    gfx::dimBackground(vg);
    gfx::drawRect(vg, m_pos, theme->elements[ThemeEntryID_SELECTED].colour);

    const Vec4 box = { 455, 470, 365, 65 };
    const auto center_x = m_pos.x + m_pos.w/2;

    gfx::drawTextArgs(vg, center_x, 180, 63, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, gfx::Colour::RED, "\uE140");
    gfx::drawTextArgs(vg, center_x, 270, 25, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, theme->elements[ThemeEntryID_TEXT].colour, "Error code: 0x%X Module: %s Description: %s", m_code, m_module_str.c_str(), m_description_str.c_str());
    gfx::drawTextArgs(vg, center_x, 325, 23, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, theme->elements[ThemeEntryID_TEXT].colour, "%s", m_message.c_str());
    gfx::drawTextArgs(vg, center_x, 380, 20, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, gfx::Colour::SILVER, "If this message appears repeatedly, please open an issue."_i18n.c_str());
    gfx::drawTextArgs(vg, center_x, 415, 20, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, gfx::Colour::SILVER, "https://github.com/ITotalJustice/sphaira/issues");
    gfx::drawRectOutline(vg, 4.f, theme->elements[ThemeEntryID_SELECTED_OVERLAY].colour, box, theme->elements[ThemeEntryID_SELECTED].colour);
    gfx::drawTextArgs(vg, center_x, box.y + box.h/2, 23, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE, gfx::Colour::WHITE, "OK"_i18n.c_str());
}

} // namespace sphaira::ui
