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,GACpD;AAAA,EACA,OAAc,OAAO,IAAc,EAAA;AAC/B,IAAA,mBAAA,CAAmB,KAAM,EAAA,CAAA;AACzB,IAAI,IAAA;AACA,MAAA,IAAI,IAAM,EAAA;AACN,QAAA,mBAAA,CAAmB,OAAW,GAAA,IAAA,CAAA;AAAA,OAE7B,MAAA;AACD,QAAA,OAAA,CAAQ,KAAK,iCAAiC,CAAA,CAAA;AAAA,OAClD;AAAA,aAEG,CAAG,EAAA;AACN,MAAQ,OAAA,CAAA,KAAA,CAAM,kCAAkC,CAAC,CAAA,CAAA;AAAA,KACrD;AAAA,GACJ;AACJ,CAAA,CAAA;AAzGqB,mBAAA,CACF,UAAiD,EAAC,CAAA;AADrE,IAAqB,kBAArB,GAAA","file":"StorageManager.mjs","sourcesContent":["/**\n * This function is used to create a deep copy of the element\n * @param element The element to be copied\n * @returns The copied element\n */\nexport function createExportableElement<T>(element: T): T {\n    try {\n        let elementString = JSON.stringify(element)\n        return JSON.parse(elementString)\n    }\n    catch (e) {\n        console.error(\"[Pixi'VN] Error creating exportable element\", e)\n        throw new Error(\"[Pixi'VN] Error creating exportable element\")\n    }\n}\n","import { createExportableElement } from \"../functions/ExportUtility\"\nimport { ExportedStorage } from \"../interface/export\"\nimport { StorageElementType } from \"../types/StorageElementType\"\n\nexport default class GameStorageManager {\n    private static storage: { [key: string]: StorageElementType } = {}\n    private constructor() { }\n    public static get keysSystem() {\n        return {\n            /**\n             * The key of the current dialogue memory\n             */\n            CURRENT_DIALOGUE_MEMORY_KEY: \"___current_dialogue_memory___\",\n            /**\n             * The key of the last dialogue added in the step memory\n             */\n            LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY: \"___last_dialogue_added_in_step_memory___\",\n            /**\n             * The key of the current menu options memory\n             */\n            CURRENT_MENU_OPTIONS_MEMORY_KEY: \"___current_menu_options_memory___\",\n            /**\n             * The key of the last menu options added in the step memory\n             */\n            LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY: \"___last_menu_options_added_in_step_memory___\",\n            /**\n             * The key of the characters memory\n             */\n            CHARACTER_CATEGORY_KEY: \"___character___\",\n            /**\n             * The key of the flags memory\n             */\n            FLAGS_CATEGORY_KEY: \"___flags___\",\n            /**\n             * This variable is used to add the next dialog text into the current dialog memory.\n             * This value was added to introduce Ink Glue functionality https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#glue\n             */\n            ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY: \"___glue___\",\n        }\n    }\n    /**\n     * Set a variable in the storage\n     * @param key The key of the variable\n     * @param value The value of the variable. If undefined, the variable will be removed\n     * @returns\n     */\n    public static setVariable(key: string, value: StorageElementType) {\n        key = key.toLowerCase()\n        if (value === undefined || value === null) {\n            if (GameStorageManager.storage.hasOwnProperty(key)) {\n                delete GameStorageManager.storage[key]\n            }\n            return\n        }\n        GameStorageManager.storage[key] = value\n    }\n    /**\n     * Get a variable from the storage\n     * @param key The key of the variable\n     * @returns The value of the variable. If the variable does not exist, it will return undefined\n     */\n    public static getVariable<T extends StorageElementType>(key: string): T | undefined {\n        key = key.toLowerCase()\n        if (GameStorageManager.storage.hasOwnProperty(key)) {\n            return GameStorageManager.storage[key] as T\n        }\n        return undefined\n    }\n    /**\n     * Remove a variable from the storage\n     * @param key The key of the variable\n     * @returns\n     */\n    public static removeVariable(key: string) {\n        key = key.toLowerCase()\n        if (GameStorageManager.storage.hasOwnProperty(key)) {\n            delete GameStorageManager.storage[key]\n        }\n    }\n    /**\n     * Clear the storage and the oidsUsed\n     * @returns\n     */\n    public static clear() {\n        GameStorageManager.storage = {}\n    }\n    public static exportJson(): string {\n        return JSON.stringify(this.export())\n    }\n    public static export(): ExportedStorage {\n        return createExportableElement(GameStorageManager.storage)\n    }\n    public static importJson(dataString: string) {\n        GameStorageManager.import(JSON.parse(dataString))\n    }\n    public static import(data: object) {\n        GameStorageManager.clear()\n        try {\n            if (data) {\n                GameStorageManager.storage = (data as ExportedStorage)\n            }\n            else {\n                console.warn(\"[Pixi'VN] No storage data found\")\n            }\n        }\n        catch (e) {\n            console.error(\"[Pixi'VN] Error importing data\", e)\n        }\n    }\n}\n"]}