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AUkqB,eAAevoB,KAAKsoB,EAAKhd,GCClFqc,oBAAoBa,EAAKV,IACH,oBAAXW,QAA0BA,OAAOC,aAC1CvpB,OAAOipB,eAAeN,EAASW,OAAOC,YAAa,CAAE1pB,MAAO,WAE7DG,OAAOipB,eAAeN,EAAS,aAAc,CAAE9oB,OAAO,4wBCQvD,eAAc,mBAQRuC,YAAYlD,UAAWkN,uBAAyB,WACrDrN,KAAKsK,QAAQ,GAAGsO,MAAMzU,OAAS,GAC/BnE,KAAKsK,QAAQ,GAAGsO,MAAM1U,MAAQ,GAC9BlE,KAAKmjB,YAAY,KAGlB1R,MAAMgZ,KAAK,SAAS,WACnB,qBAGDhZ,MAAMgZ,KAAK,QAAQ,WAMlB,SACA,iBACA,SACA,iBACA,iBACA,iBACA,iBACA,iBACA,iBACA,iBAEAtoB,WAAWxB,SAAS,mBAAmB,6CAA6C,SAAUa,KAAkDC,GAC/I,MAAMgI,EAAUjI,KAAWC,GAG3B,OAFA,uCAAwCgI,GACxC,uCAAqDA,GAC9CA,IACL,cAGJgI,MAAMgZ,KAAK,SAAS,kBACiB,QAA/B,EAAApqB,KAAKgS,QAAQxR,IAAI,sBAAc,eAAEyR,UACrCpK,QAAQC,MAAM,wCACV9H,KAAKsJ,KAAKC,MACb3G,GAAG0H,cAAcxC,MAAM,sCAAsC/H,aAE/D,UACA,kBACA,kBACA,kBACA","sources":["webpack:///../common/Settings.ts","webpack:///../common/libWrapperShared.ts","webpack:///./src/Util.ts","webpack:///./src/archive/DFChatArchive.ts","webpack:///./src/archive/DFChatArchiveManager.ts","webpack:///./src/archive/DFChatArchiveNew.ts","webpack:///./src/archive/DFChatArchiveViewer.ts","webpack:///./src/archive/df-chat-archive.ts","webpack:///./src/chat-time/chat-time.ts","webpack:///./src/edit/DFChatEditor.ts","webpack:///./src/edit/df-chat-edit.ts","webpack:///./src/font-size/font-size.ts","webpack:///./src/logger/DFAdventureLogConfig.ts","webpack:///./src/logger/DFAdventureLogProcessor.ts","webpack:///./src/logger/df-adventure-log.ts","webpack:///./src/merge/chat-merge.ts","webpack:///./src/player-color/PlayerColor.ts","webpack:///./src/privacy/df-chat-privacy.ts","webpack:///./src/scroll-manage/ChatHistoryOptimizer.ts","webpack:///./src/scroll-manage/scroll-manage.ts","webpack:///./src/send/send-button.ts","webpack:///./src/whisper-trunc/whisper-trunc.ts","webpack:///webpack/bootstrap","webpack:///webpack/runtime/define property getters","webpack:///webpack/runtime/hasOwnProperty shorthand","webpack:///webpack/runtime/make namespace object","webpack:///./src/df-chat-enhance.ts"],"sourcesContent":["\ndeclare global {\n\tinterface LenientGlobalVariableTypes {\n\t\tgame: never;\n\t\tcanvas: never;\n\t}\n\tinterface String {\n\t\t/** Localizes the string via the global `game.i18n.localize()` function. */\n\t\tlocalize(): string\n\t}\n\ttype AnyFunction = (...args: any) => any;\n}\n\nexport default class SETTINGS {\n\tstatic MOD_NAME: string;\n\tstatic init(moduleName: string) {\n\t\tthis.MOD_NAME = moduleName;\n\t\tif (!String.prototype.localize) {\n\t\t\tString.prototype.localize = function () {\n\t\t\t\treturn game.i18n.localize(this.valueOf());\n\t\t\t};\n\t\t}\n\t}\n\tstatic register(key: string, config: ClientSettings.PartialSettingConfig) { game.settings.register(SETTINGS.MOD_NAME, key, config); }\n\tstatic registerMenu(key: string, config: ClientSettings.PartialSettingSubmenuConfig) { game.settings.registerMenu(SETTINGS.MOD_NAME, key, config); }\n\tstatic get(key: string): T { return game.settings.get(SETTINGS.MOD_NAME, key); }\n\tstatic async set(key: string, value: T): Promise { return await game.settings.set(SETTINGS.MOD_NAME, key, value); }\n\tstatic default(key: string): T { return game.settings.settings.get(SETTINGS.MOD_NAME + '.' + key).default; }\n\t/** helper for referencing a Typed constructor for the `type` field of a setting { type: SETTINGS.typeOf() } */\n\tstatic typeOf(): ConstructorOf { return Object as any; }\n}\n","import SETTINGS from \"./Settings\";\n\ntype Wrapper = (...args: any) => unknown;\ntype Handler = (wrapped: Wrapper, ...args: any) => unknown;\n\nclass Registration {\n\tnextId = 0;\n\twrappers = new Map();\n\n\thandler(context: any, wrapped: Wrapper, ...args: any): Promise | unknown {\n\t\tlet current = wrapped;\n\t\tfor (const wrapper of this.wrappers.values()) {\n\t\t\tconst next = current;\n\t\t\tcurrent = (...args: any) => wrapper.call(context, next, ...args);\n\t\t}\n\t\treturn current.call(context, ...args);\n\t}\n}\n\nexport default class libWrapperShared {\n\tprivate static registrations = new Map();\n\n\tstatic register(target: string, handler: Handler) {\n\t\tlet registration = this.registrations.get(target);\n\t\tif (!registration) {\n\t\t\tregistration = new Registration();\n\t\t\tlibWrapper.register(SETTINGS.MOD_NAME, target,\n\t\t\t\tfunction (this: any, wrapped: Wrapper, ...args: any) { return registration.handler(this, wrapped, ...args); }, 'WRAPPER');\n\t\t\tthis.registrations.set(target, registration);\n\t\t}\n\t\tconst id = registration.nextId++;\n\t\tregistration.wrappers.set(id, handler);\n\t\treturn id;\n\t}\n\n\tstatic unregister(target: string, id: number): boolean {\n\t\tconst registration = this.registrations.get(target);\n\t\tif (!registration) return false;\n\t\tregistration.wrappers.delete(id);\n\t\tif (registration.wrappers.size === 0) {\n\t\t\tlibWrapper.unregister(SETTINGS.MOD_NAME, target, false);\n\t\t\tthis.registrations.delete(target);\n\t\t}\n\t\treturn true;\n\t}\n}","export default class UTIL {\n\tstatic async requestReload() {\n\t\tif (await Dialog.confirm({\n\t\t\ttitle: \"DF_CHAT_ENHANCE.ReloadGameTitle\".localize(),\n\t\t\tcontent: \"DF_CHAT_ENHANCE.ReloadGameContent\".localize(),\n\t\t\tdefaultYes: true\n\t\t})) {\n\t\t\twindow.location.reload();\n\t\t}\n\t}\n\n\tstatic reloadChatLog() {\n\t\t// @ts-expect-error\n\t\tui.chat._lastId = null;\n\t\tui.chat._state = Application.RENDER_STATES.NONE;\n\t\tui.chat.render(true);\n\t}\n}","import { ChatMessageData } from \"@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs\";\nimport SETTINGS from \"../../../common/Settings\";\n\nexport interface DFChatArchiveEntry {\n\tid: number;\n\tname: string;\n\tvisible: boolean;\n\tfilename: string;\n\tfilepath: string;\n}\n\n\nclass ArchiveFolderMenu extends FormApplication {\n\tstatic get defaultOptions() {\n\t\treturn mergeObject(FormApplication.defaultOptions as Partial, {\n\t\t\twidth: 400,\n\t\t\theight: 125,\n\t\t\tresizable: false,\n\t\t\tminimizable: false,\n\t\t\ttitle: 'DF_CHAT_ARCHIVE.Settings.ArchiveFolder_Name',\n\t\t\ttemplate: \"modules/df-chat-enhance/templates/archive-folder.hbs\",\n\t\t\tsubmitOnClose: false,\n\t\t\tsubmitOnChange: false,\n\t\t\tcloseOnSubmit: true\n\t\t}) as FormApplicationOptions;\n\t}\n\n\tprivate folder = SETTINGS.get(DFChatArchive.PREF_FOLDER);\n\tprivate source = SETTINGS.get(DFChatArchive.PREF_FOLDER_SOURCE);\n\n\tgetData(_options: any): any {\n\t\treturn { path: this.folder };\n\t}\n\n\tasync _renderInner(data: any): Promise> {\n\t\tconst html = await super._renderInner(data);\n\t\tconst input = html.find('input#dfce-ca-folder-path')[0] as HTMLInputElement;\n\t\thtml.find('label>button').on('click', async event => {\n\t\t\tevent.preventDefault();\n\t\t\tconst fp = new FilePicker({\n\t\t\t\ttitle: 'DF_CHAT_ARCHIVE.Settings.ArchiveFolder_Name',\n\t\t\t\ttype: 'folder',\n\t\t\t\tfield: input,\n\t\t\t\tcallback: async (path: string) => {\n\t\t\t\t\tthis.source = fp.activeSource;\n\t\t\t\t\tthis.folder = path;\n\t\t\t\t},\n\t\t\t\tbutton: event.currentTarget\n\t\t\t});\n\t\t\tawait fp.browse(SETTINGS.get(DFChatArchive.PREF_FOLDER));\n\t\t});\n\t\treturn html;\n\t}\n\tprotected async _updateObject() {\n\t\tawait SETTINGS.set(DFChatArchive.PREF_FOLDER, this.folder);\n\t\tawait SETTINGS.set(DFChatArchive.PREF_FOLDER_SOURCE, this.source);\n\t}\n}\n\nexport class DFChatArchive {\n\tprivate static readonly PREF_LOGS = 'logs';\n\tprivate static readonly PREF_CID = 'currentId';\n\tstatic readonly PREF_FOLDER = 'archiveFolder';\n\tstatic readonly PREF_FOLDER_SOURCE = 'archiveFolderSource';\n\tprivate static readonly PREF_FOLDER_MENU = 'archiveFolderMenu';\n\tprivate static _updateListener: () => void = null;\n\n\tprivate static get DATA_FOLDER(): FilePicker.SourceType { return SETTINGS.get(DFChatArchive.PREF_FOLDER_SOURCE); }\n\n\tstatic setUpdateListener(listener: () => void) {\n\t\tthis._updateListener = listener;\n\t}\n\n\tstatic registerSettings() {\n\t\tSETTINGS.register(this.PREF_LOGS, {\n\t\t\tscope: 'world',\n\t\t\tconfig: false,\n\t\t\ttype: Object,\n\t\t\tdefault: [],\n\t\t\tonChange: () => {\n\t\t\t\tif (this._updateListener != null)\n\t\t\t\t\tthis._updateListener();\n\t\t\t}\n\t\t});\n\t\tSETTINGS.register(this.PREF_CID, {\n\t\t\tscope: 'world',\n\t\t\tconfig: false,\n\t\t\ttype: Number,\n\t\t\tdefault: 0\n\t\t});\n\n\t\tSETTINGS.registerMenu(this.PREF_FOLDER_MENU, {\n\t\t\tlabel: 'DF_CHAT_ARCHIVE.Settings.ArchiveFolder_Name',\n\t\t\thint: 'DF_CHAT_ARCHIVE.Settings.ArchiveFolder_Hint',\n\t\t\trestricted: true,\n\t\t\ttype: ArchiveFolderMenu\n\t\t});\n\n\t\tSETTINGS.register(this.PREF_FOLDER, {\n\t\t\tscope: 'world',\n\t\t\tconfig: false,\n\t\t\ttype: String,\n\t\t\tdefault: `worlds/${game.world.id}/chat-archive`,\n\t\t\tonChange: async () => {\n\t\t\t\tawait this.createArchiveFolderIfMissing();\n\t\t\t\tif (this._updateListener != null)\n\t\t\t\t\tthis._updateListener();\n\t\t\t}\n\t\t});\n\t\tSETTINGS.register(this.PREF_FOLDER_SOURCE, {\n\t\t\tscope: 'world',\n\t\t\tconfig: false,\n\t\t\ttype: String,\n\t\t\tdefault: 'data',\n\t\t});\n\t\tthis.createArchiveFolderIfMissing();\n\t}\n\n\tprivate static async createArchiveFolderIfMissing() {\n\t\tconst folder: string = SETTINGS.get(this.PREF_FOLDER);\n\t\tawait FilePicker.browse(this.DATA_FOLDER, folder)\n\t\t\t.catch(async _ => {\n\t\t\t\tif (!await FilePicker.createDirectory(this.DATA_FOLDER, folder, {}))\n\t\t\t\t\tthrow new Error('Could not access the archive folder: ' + folder);\n\t\t\t});\n\t}\n\n\tstatic getLogs(): DFChatArchiveEntry[] { return SETTINGS.get(this.PREF_LOGS); }\n\tstatic getArchive(id: number): DFChatArchiveEntry { return this.getLogs().find(x => x.id == id); }\n\tstatic exists(id: number): boolean { return !!this.getLogs().find(x => x.id == id); }\n\n\tprivate static async _generateChatArchiveFile(id: number, name: string, chats: ChatMessage[] | ChatMessageData[], visible: boolean): Promise {\n\t\t// Get the folder path\n\t\tconst folderPath = SETTINGS.get(this.PREF_FOLDER);\n\t\t// Replace special characters in name to underscores\n\t\tconst safeName = name.replace(/[^ a-z0-9-_()[\\]<>]/gi, '_');\n\t\t// Generate the system safe filename\n\t\tconst fileName = encodeURI(`${id}_${safeName}.json`);\n\t\t// Create the File and contents\n\t\tconst file = new File([JSON.stringify(chats, null, '')], fileName, { type: 'application/json' });\n\t\tconst response: { path?: string; message?: string } = await FilePicker.upload(this.DATA_FOLDER, folderPath, file);\n\t\tif (!response.path) {\n\t\t\tconsole.error(`Could not create archive ${fileName}\\nReason: ${response}`);\n\t\t\tthrow new Error('Could not upload the archive to server: ' + fileName);\n\t\t}\n\t\tconst entry: DFChatArchiveEntry = {\n\t\t\tid: id,\n\t\t\tname: name,\n\t\t\tvisible: visible,\n\t\t\tfilepath: response.path,\n\t\t\tfilename: fileName\n\t\t};\n\t\treturn entry;\n\t}\n\n\tstatic async createChatArchive(name: string, chats: ChatMessage[], visible: boolean): Promise {\n\t\tconst newId = SETTINGS.get(this.PREF_CID) + 1;\n\t\tSETTINGS.set(this.PREF_CID, newId);\n\t\tconst entry = await this._generateChatArchiveFile(newId, name, chats, visible);\n\t\tconst logs = SETTINGS.get(this.PREF_LOGS);\n\t\tlogs.push(entry);\n\t\tawait SETTINGS.set(this.PREF_LOGS, logs);\n\t\tif (this._updateListener != null)\n\t\t\tthis._updateListener();\n\t\treturn entry;\n\t}\n\n\tstatic async getArchiveContents(archive: DFChatArchiveEntry): Promise<(ChatMessage | ChatMessageData)[]> {\n\t\tconst response = await fetch(archive.filepath);\n\t\tconst data = await response.json().catch(error => console.error(`Failed to read JSON for archive ${archive.filepath}\\n${error}`));\n\t\tif (response.ok)\n\t\t\treturn data as (ChatMessage | ChatMessageData)[];\n\t\telse\n\t\t\tthrow new Error('Could not access the archive from server side: ' + archive.filepath);\n\t}\n\n\tstatic async updateChatArchive(archive: DFChatArchiveEntry, newChatData?: (ChatMessage | ChatMessageData)[]): Promise {\n\t\tif (!this.getLogs().find(x => x.id == archive.id))\n\t\t\tthrow new Error('Could not locate an archive for the given ID: ' + archive.id.toString());\n\t\t// If we are updating the contents of an archive\n\t\tif (newChatData) {\n\t\t\tconst folderPath = SETTINGS.get(this.PREF_FOLDER);\n\t\t\tconst file = new File([JSON.stringify(newChatData)], archive.filename, { type: 'application/json' });\n\t\t\tconst response: {\n\t\t\t\tpath?: string;\n\t\t\t\tmessage?: string;\n\t\t\t} = await FilePicker.upload(this.DATA_FOLDER, folderPath, file, {});\n\t\t\tif (!response.path)\n\t\t\t\tthrow new Error('Could not upload the archive to server side: ' + archive.id.toString());\n\t\t}\n\t\tconst logs = this.getLogs();\n\t\tconst idx = logs.findIndex(x => x.id === archive.id);\n\t\tif (idx < 0) return archive;\n\t\tlogs[idx] = archive;\n\t\tawait SETTINGS.set(DFChatArchive.PREF_LOGS, logs);\n\t\treturn archive;\n\t}\n\n\tstatic async deleteAll() {\n\t\tconst folderPath = SETTINGS.get(this.PREF_FOLDER);\n\t\tconst logs = SETTINGS.get(this.PREF_LOGS);\n\t\t// Can not delete files currently, truncate instead to make filtering easier.\n\t\tawait Promise.all(logs.map(archive => {\n\t\t\tconst file = new File([''], archive.filename, { type: 'application/json' });\n\t\t\treturn FilePicker.upload(this.DATA_FOLDER, folderPath, file, {});\n\t\t}));\n\t\tawait SETTINGS.set(this.PREF_LOGS, []);\n\t\tif (this._updateListener != null)\n\t\t\tthis._updateListener();\n\t}\n\n\tstatic async deleteChatArchive(id: number) {\n\t\tconst folderPath = SETTINGS.get(this.PREF_FOLDER);\n\t\tconst logs = SETTINGS.get(this.PREF_LOGS);\n\t\tconst entryIdx = logs.findIndex(x => x.id === id);\n\t\tif (entryIdx < 0) {\n\t\t\tconsole.error(`Could not find entry for ID#${id}`);\n\t\t\treturn;\n\t\t}\n\t\tconst entry = logs[entryIdx];\n\t\t// Cannot delete file currently, instead truncate the file and move along.\n\t\tconst file = new File([''], entry.filename, { type: 'application/json' });\n\t\tawait FilePicker.upload(this.DATA_FOLDER, folderPath, file, {});\n\t\tlogs.splice(entryIdx, 1);\n\t\tawait SETTINGS.set(this.PREF_LOGS, logs);\n\t\tif (this._updateListener != null)\n\t\t\tthis._updateListener();\n\t}\n}\n","import SETTINGS from \"../../../common/Settings\";\nimport { DFChatArchive } from \"./DFChatArchive\";\nimport DFChatArchiveViewer from \"./DFChatArchiveViewer\";\n\nexport default class DFChatArchiveManager extends Application {\n\tstatic readonly PREF_REVERSE_SORT = 'dfca-manager-reverseSort';\n\tstatic chatViewers: Map = new Map();\n\n\tstatic get defaultOptions() {\n\t\treturn mergeObject(Application.defaultOptions as Partial, {\n\t\t\ttemplate: \"modules/df-chat-enhance/templates/archive-manager.hbs\",\n\t\t\tresizable: true,\n\t\t\tminimizable: true,\n\t\t\twidth: 300,\n\t\t\theight: 500,\n\t\t\ttitle: \"DF_CHAT_ARCHIVE.ArchiveManager_Title\".localize()\n\t\t}) as ApplicationOptions;\n\t}\n\n\tgetData(options?: any) {\n\t\tconst data = super.getData(options);\n\t\tlet messages = DFChatArchive.getLogs();\n\t\tif (!game.user.isGM)\n\t\t\tmessages = messages.filter(x => x.visible);\n\t\tmessages = messages.sort((a, b) => a.name.localeCompare(b.name));\n\t\tconst reverseSort = SETTINGS.get(DFChatArchiveManager.PREF_REVERSE_SORT);\n\t\tmergeObject(data, {\n\t\t\tmessages: reverseSort ? messages.reverse() : messages,\n\t\t\tisGM: game.user.isGM,\n\t\t\treverseSort\n\t\t});\n\t\treturn data;\n\t}\n\n\tprivate _subscribeView(element: JQuery) {\n\t\telement.on('click', function () {\n\t\t\tconst id = parseInt($(this).attr('data-id'));\n\t\t\tif (isNaN(id) || !DFChatArchive.exists(id)) {\n\t\t\t\tui.notifications.error('DF_CHAT_ARCHIVE.ArchiveManager_ErrorBadId'.localize());\n\t\t\t\tthrow Error(`Invalid id for Chat Archive: '${$(this).attr('data-id')}'`);\n\t\t\t}\n\t\t\tif (DFChatArchiveManager.chatViewers.has(id)) {\n\t\t\t\tDFChatArchiveManager.chatViewers.get(id).bringToTop();\n\t\t\t} else {\n\t\t\t\tDFChatArchiveManager.chatViewers.set(id, new DFChatArchiveViewer(DFChatArchive.getArchive(id), view => {\n\t\t\t\t\tDFChatArchiveManager.chatViewers.delete(view.archive.id);\n\t\t\t\t}));\n\t\t\t\tDFChatArchiveManager.chatViewers.get(id).render(true);\n\t\t\t}\n\t\t});\n\t}\n\tprivate _subscribeDelete(element: JQuery) {\n\t\telement.on('click', async function () {\n\t\t\tconst id = parseInt($(this).attr('data-id'));\n\t\t\tif (isNaN(id) || !DFChatArchive.exists(id)) {\n\t\t\t\tui.notifications.error('DF_CHAT_ARCHIVE.ArchiveManager_ErrorBadId'.localize());\n\t\t\t\tthrow Error(`Invalid id for Chat Archive: '${$(this).attr('data-id')}'`);\n\t\t\t}\n\t\t\tconst archive = DFChatArchive.getArchive(id);\n\t\t\tawait Dialog.confirm({\n\t\t\t\ttitle: 'DF_CHAT_ARCHIVE.ArchiveManager_ConfirmDeleteArchiveTitle'.localize(),\n\t\t\t\tcontent: 'DF_CHAT_ARCHIVE.ArchiveManager_ConfirmDeleteArchiveContent'.localize().replace('{name}', archive.name),\n\t\t\t\tdefaultYes: false,\n\t\t\t\tyes: async () => await DFChatArchive.deleteChatArchive(id)\n\t\t\t});\n\t\t});\n\t}\n\n\tactivateListeners(html: JQuery) {\n\t\tDFChatArchive.setUpdateListener(this._archiveChanged.bind(this));\n\t\tif (DFChatArchive.getLogs().length > 0)\n\t\t\thtml.find('p.dfca-no-items').hide();\n\t\thtml.find('a[data-type=\"view\"]').each((i, element) => { this._subscribeView($(element)); });\n\t\thtml.find('a[data-type=\"delete\"]').each((i, element) => { this._subscribeDelete($(element)); });\n\t\thtml.find('#dfca-delete-all').on('click', async function () {\n\t\t\tawait Dialog.confirm({\n\t\t\t\ttitle: 'DF_CHAT_ARCHIVE.ArchiveManager_ConfirmDeleteAllTitle'.localize(),\n\t\t\t\tcontent: 'DF_CHAT_ARCHIVE.ArchiveManager_ConfirmDeleteAllMessage1'.localize(),\n\t\t\t\tdefaultYes: false,\n\t\t\t\tyes: async () => {\n\t\t\t\t\tawait Dialog.confirm({\n\t\t\t\t\t\ttitle: 'DF_CHAT_ARCHIVE.ArchiveManager_ConfirmDeleteAllTitle'.localize(),\n\t\t\t\t\t\tcontent: 'DF_CHAT_ARCHIVE.ArchiveManager_ConfirmDeleteAllMessage2'.localize(),\n\t\t\t\t\t\tdefaultYes: false,\n\t\t\t\t\t\tyes: async () => {\n\t\t\t\t\t\t\tawait DFChatArchive.deleteAll();\n\t\t\t\t\t\t\tui.notifications.info('DF_CHAT_ARCHIVE.ArchiveManager_ConfirmDeleteAllComplete'.localize());\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\tconst asc = html.find('#dfca-sort-asc');\n\t\tconst dsc = html.find('#dfca-sort-dsc');\n\t\tasc.on('click', async () => {\n\t\t\tawait SETTINGS.set(DFChatArchiveManager.PREF_REVERSE_SORT, true);\n\t\t\tasc.hide();\n\t\t\tdsc.show();\n\t\t\tthis.render();\n\t\t});\n\t\tdsc.on('click', async () => {\n\t\t\tawait SETTINGS.set(DFChatArchiveManager.PREF_REVERSE_SORT, false);\n\t\t\tdsc.hide();\n\t\t\tasc.show();\n\t\t\tthis.render();\n\t\t});\n\t}\n\n\tclose(options?: any): Promise {\n\t\tDFChatArchive.setUpdateListener(null);\n\t\treturn super.close(options);\n\t}\n\n\tprivate async _archiveChanged() {\n\t\tlet logs = DFChatArchive.getLogs();\n\t\tif (!game.user.isGM)\n\t\t\tlogs = logs.filter(x => x.visible);\n\t\tconst archiveContainer = this.element.find('#dfca-archives');\n\t\tarchiveContainer.empty();\n\t\t// Add new items\n\t\tfor (const archive of logs) {\n\t\t\tconst visible = archive.visible === true\n\t\t\t\t? `` : '';\n\t\t\tconst html = $(`\n\t\t
  • \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\t${archive.name}\n\t\t\t\t\n\t\t\t\t${visible}\n\t\t\t\t\n\t\t\t
    \n\t\t
  • `);\n\t\t\tthis._subscribeView(html.find('a[data-type=\"view\"]'));\n\t\t\tthis._subscribeDelete(html.find('a[data-type=\"delete\"]'));\n\t\t\tarchiveContainer.append(html);\n\t\t}\n\t\tif (archiveContainer[0].children.length == 0)\n\t\t\tthis.element.find('p.dfca-no-items').show();\n\t\telse\n\t\t\tthis.element.find('p.dfca-no-items').hide();\n\t}\n}","import { DFChatArchive } from \"./DFChatArchive\";\nimport SETTINGS from \"../../../common/Settings\";\n\nexport default class DFChatArchiveNew extends FormApplication {\n\tstatic readonly PREF_DELETE = 'new-should-delete';\n\tstatic readonly PREF_HIDE_EXPORT = 'hide-export';\n\tstatic get defaultOptions() {\n\t\treturn mergeObject(FormApplication.defaultOptions, {\n\t\t\ttemplate: \"modules/df-chat-enhance/templates/archive-new.hbs\",\n\t\t\tresizable: false,\n\t\t\tminimizable: false,\n\t\t\ttitle: \"DF_CHAT_ARCHIVE.ArchiveNew_Title\".localize()\n\t\t});\n\t}\n\n\tstatic registerSettings() {\n\t\tSETTINGS.register(DFChatArchiveNew.PREF_DELETE, {\n\t\t\tconfig: false,\n\t\t\tscope: 'world',\n\t\t\ttype: Boolean,\n\t\t\tdefault: true\n\t\t});\n\t}\n\n\tgetData(options?: any) {\n\t\treturn mergeObject(super.getData(options), {\n\t\t\tshouldDelete: SETTINGS.get(DFChatArchiveNew.PREF_DELETE) as boolean\n\t\t});\n\t}\n\n\tasync _updateObject(_event?: any, formData?: any) {\n\t\tSETTINGS.set(DFChatArchiveNew.PREF_DELETE, formData.delete);\n\n\t\tconst name = formData.name;\n\t\tif (!name) {\n\t\t\tui.notifications.warn('DF_CHAT_ARCHIVE.ArchiveNew_ErrorNameMissing'.localize());\n\t\t\tthrow Error('DF_CHAT_ARCHIVE.ArchiveNew_ErrorNameMissing'.localize());\n\t\t}\n\n\t\tlet chats = [...(ui.chat.collection.values())];\n\n\t\t// If we are selecting a date range\n\t\tif (formData['date-or-all'] === 'date') {\n\t\t\tconst fromDate = new Date(formData.from).getTime();\n\t\t\tconst toDate = new Date(formData.to).getTime();\n\t\t\tif (isNaN(fromDate) || isNaN(toDate)) {\n\t\t\t\tui.notifications.warn('DF_CHAT_ARCHIVE.ArchiveNew_ErrorDatesMissing'.localize());\n\t\t\t\tthrow Error('Missing \"from\" and/or \"to\" dates');\n\t\t\t}\n\t\t\tchats = chats.filter((value) => value.data.timestamp >= fromDate && value.data.timestamp <= toDate);\n\t\t}\n\n\t\tui.notifications.info('DF_CHAT_ARCHIVE.ArchiveNew_NoticeSuccess'.localize().replace('{0}', name));\n\t\ttry {\n\t\t\tawait DFChatArchive.createChatArchive(name, chats, formData['visible']);\n\t\t}\n\t\tcatch (e) {\n\t\t\t// We have failed to create an archive so we should return immediately\n\t\t\treturn;\n\t\t}\n\t\t// If we don't want to delete the messages, return\n\t\tif (!formData.delete) return;\n\n\t\tgame.messages.flush();\n\t}\n\n\t_renderInner(data: { shouldDelete: boolean }): Promise> {\n\t\treturn super._renderInner(data)\n\t\t\t.then((html) => {\n\t\t\t\tconst from = html.find('#dfca-from');\n\t\t\t\tconst to = html.find('#dfca-to');\n\t\t\t\thtml.find('#dfca-all').on('change', () => {\n\t\t\t\t\tfrom.prop('disabled', true);\n\t\t\t\t\tto.prop('disabled', true);\n\t\t\t\t\tthis._recalculateDimensions();\n\t\t\t\t});\n\t\t\t\thtml.find('#dfca-date').on('change', () => {\n\t\t\t\t\tfrom.prop('disabled', false);\n\t\t\t\t\tto.prop('disabled', false);\n\t\t\t\t\tthis._recalculateDimensions();\n\t\t\t\t});\n\t\t\t\treturn html;\n\t\t\t});\n\t}\n}","import { ChatMessageData } from '@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs';\nimport { DFChatArchive, DFChatArchiveEntry } from './DFChatArchive';\n\nexport default class DFChatArchiveViewer extends Application {\n\tarchive: DFChatArchiveEntry;\n\tmessages: ChatMessageData[];\n\tonCloseCallBack: (view: DFChatArchiveViewer) => void;\n\tconstructor(archive: DFChatArchiveEntry, onCloseCallBack: (view: DFChatArchiveViewer) => void) {\n\t\tsuper();\n\t\tthis.archive = archive;\n\t\tthis.onCloseCallBack = onCloseCallBack;\n\t}\n\n\tstatic get defaultOptions() {\n\t\treturn mergeObject(Application.defaultOptions as Partial, {\n\t\t\ttemplate: \"modules/df-chat-enhance/templates/archive-viewer.hbs\",\n\t\t\twidth: 300,\n\t\t\theight: 500,\n\t\t\tresizable: true,\n\t\t\ttitle: 'DF_CHAT_ARCHIVE.ArchiveViewer_Title',\n\t\t\tclasses: ['df-chat-log-window']\n\t\t}) as ApplicationOptions;\n\t}\n\n\tgetData(options = {}) {\n\t\tsuper.getData(options);\n\t\treturn {\n\t\t\tname: this.archive.name,\n\t\t\tisGM: game.user.isGM,\n\t\t\tvisible: this.archive.visible ?? false,\n\t\t\tlogId: 'df-chat-log-' + this.archive.id\n\t\t};\n\t}\n\n\t// convert a Unicode string to a string in which\n\t// each 16-bit unit occupies only one byte\n\t/**\n\t * Converts a UTF-16 string to an ASCii string containing the binary data of the UTF-16 text.\n\t * @param data UTF-16 data\n\t * @returns Binary data coerced into a string\n\t */\n\tprivate static toBinary(data: string): string {\n\t\tconst codeUnits = new Uint16Array(data.length);\n\t\tfor (let i = 0; i < codeUnits.length; i++) {\n\t\t\tcodeUnits[i] = data.charCodeAt(i);\n\t\t}\n\t\tconst charCodes = new Uint8Array(codeUnits.buffer);\n\t\tlet result = '';\n\t\tfor (let i = 0; i < charCodes.byteLength; i++) {\n\t\t\tresult += String.fromCharCode(charCodes[i]);\n\t\t}\n\t\treturn result;\n\t}\n\n\t_renderInner(data: any): Promise {\n\t\treturn (super._renderInner(data) as Promise)\n\t\t\t.then(async (html: JQuery) => {\n\t\t\t\thtml.find(\"#visible-df-chat-log-\" + this.archive.id).on('change', async (element) => {\n\t\t\t\t\tthis.archive.visible = (element.target as HTMLInputElement).checked;\n\t\t\t\t\tawait DFChatArchive.updateChatArchive(this.archive);\n\t\t\t\t});\n\t\t\t\thtml.find(\"#edit\").on('click', async () => {\n\t\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\t\tconst dialog = new Dialog({\n\t\t\t\t\t\t\ttitle: \"DF_CHAT_ARCHIVE.ArchiveViewer_NameEdit_Title\".localize(),\n\t\t\t\t\t\t\tcontent: ``,\n\t\t\t\t\t\t\tbuttons: {\n\t\t\t\t\t\t\t\tsave: {\n\t\t\t\t\t\t\t\t\ticon: '',\n\t\t\t\t\t\t\t\t\tlabel: 'DF_CHAT_ARCHIVE.ArchiveViewer_NameEdit_Save'.localize(),\n\t\t\t\t\t\t\t\t\tcallback: async (html) => {\n\t\t\t\t\t\t\t\t\t\tthis.archive.name = $(html).find('#name').val() as string;\n\t\t\t\t\t\t\t\t\t\tawait dialog.close();\n\t\t\t\t\t\t\t\t\t\tawait DFChatArchive.updateChatArchive(this.archive);\n\t\t\t\t\t\t\t\t\t\tawait this.render(false);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tclose: {\n\t\t\t\t\t\t\t\t\ticon: '',\n\t\t\t\t\t\t\t\t\tlabel: 'DF_CHAT_ARCHIVE.ArchiveViewer_NameEdit_Cancel'.localize(),\n\t\t\t\t\t\t\t\t\tcallback: async () => {\n\t\t\t\t\t\t\t\t\t\tawait dialog.close();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdefault: 'save'\n\t\t\t\t\t\t});\n\t\t\t\t\t\tdialog.render(true);\n\t\t\t\t\t}, 1);\n\t\t\t\t});\n\t\t\t\thtml.find('#print').on('click', async () => {\n\t\t\t\t\tconst clone = html.find('#df-chat-log').clone();\n\t\t\t\t\tclone.addClass('df-chat-print');\n\t\t\t\t\t$('body').hide();\n\t\t\t\t\t$('html').addClass('df-chat-print');\n\t\t\t\t\t$('html').append(clone);\n\t\t\t\t\twindow.print();\n\t\t\t\t\tclone.remove();\n\t\t\t\t\t$('html').removeClass('df-chat-print');\n\t\t\t\t\t$('body').show();\n\t\t\t\t});\n\t\t\t\thtml.find('#merge').on('click', async () => {\n\t\t\t\t\tif (DFChatArchive.getLogs().length == 1) {\n\t\t\t\t\t\tui.notifications.info('DF_CHAT_ARCHIVE.ArchiveViewer_Merge_OnlyOneArchive'.localize());\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst dialog: Dialog = new Dialog({\n\t\t\t\t\t\ttitle: 'DF_CHAT_ARCHIVE.ArchiveViewer_Merge_Title'.localize(),\n\t\t\t\t\t\tdefault: 'merge',\n\t\t\t\t\t\tcontent: await renderTemplate('modules/df-chat-enhance/templates/archive-merge.hbs', {\n\t\t\t\t\t\t\tid: this.archive.id,\n\t\t\t\t\t\t\tname: this.archive.name,\n\t\t\t\t\t\t\tarchives: DFChatArchive.getLogs().filter(x => x.id != this.archive.id)\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tbuttons: {\n\t\t\t\t\t\t\tcancel: {\n\t\t\t\t\t\t\t\ticon: '',\n\t\t\t\t\t\t\t\tlabel: 'DF_CHAT_ARCHIVE.ArchiveViewer_Merge_Cancel'.localize(),\n\t\t\t\t\t\t\t\tcallback: async () => await dialog.close()\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmerge: {\n\t\t\t\t\t\t\t\ticon: '',\n\t\t\t\t\t\t\t\tlabel: 'DF_CHAT_ARCHIVE.ArchiveViewer_Merge_Merge'.localize(),\n\t\t\t\t\t\t\t\tcallback: async (html) => {\n\t\t\t\t\t\t\t\t\tconst val = $(html).find('#archive').val() as string;\n\t\t\t\t\t\t\t\t\tif (isNaN(parseInt(val))) return;\n\t\t\t\t\t\t\t\t\tconst id = parseInt(val);\n\t\t\t\t\t\t\t\t\tconst source = DFChatArchive.getLogs().find(x => x.id == id);\n\t\t\t\t\t\t\t\t\tconst currentChats = await DFChatArchive.getArchiveContents(this.archive);\n\t\t\t\t\t\t\t\t\tconst sourceChats = await DFChatArchive.getArchiveContents(source);\n\t\t\t\t\t\t\t\t\tconst mergedChats = (currentChats as ChatMessageData[])\n\t\t\t\t\t\t\t\t\t\t.concat(sourceChats as ChatMessageData[])\n\t\t\t\t\t\t\t\t\t\t.sort((a, b) => a.timestamp - b.timestamp);\n\t\t\t\t\t\t\t\t\tawait DFChatArchive.updateChatArchive(this.archive, mergedChats);\n\t\t\t\t\t\t\t\t\tthis.render(true);\n\t\t\t\t\t\t\t\t\tif (($(html).find('#delete-' + this.archive.id)[0] as HTMLInputElement).checked) {\n\t\t\t\t\t\t\t\t\t\tawait DFChatArchive.deleteChatArchive(id);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tawait dialog.render(true);\n\t\t\t\t});\n\n\t\t\t\thtml.find('#html').on('click', () => {\n\t\t\t\t\tconst data = $('
    ').append(html.find('#df-chat-log').clone()).html();\n\t\t\t\t\tconst anchor = document.createElement('a');\n\t\t\t\t\tanchor.download = encodeURI(this.archive.name) + '.html';\n\t\t\t\t\t// anchor.href = \"data:text/html;base64,\" + btoa(unescape(encodeURIComponent(data)));\n\t\t\t\t\tanchor.href = \"data:text/html,\" + encodeURIComponent(data);\n\t\t\t\t\tanchor.click();\n\t\t\t\t});\n\n\t\t\t\tconst log = html.find('#df-chat-log');\n\t\t\t\tconst messageHtml = [];\n\t\t\t\tthis.messages = (await DFChatArchive.getArchiveContents(this.archive) as ChatMessageData[])\n\t\t\t\t\t.filter(x => game.user.isGM || x.user === game.userId || x.type !== CONST.CHAT_MESSAGE_TYPES.WHISPER || x.whisper.some(x => x === game.userId));\n\n\t\t\t\tconst deletionList: string[] = [];\n\t\t\t\tconst deleteButton = html.find('#dfal-save-changes');\n\t\t\t\tfor (const value of this.messages as ChatMessageData[]) {\n\t\t\t\t\tconst chatMessage = value instanceof ChatMessage ? value : new ChatMessage(value);\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tconst html = await chatMessage.getHTML();\n\t\t\t\t\t\t// if we only have 1 message, don't allow it to be deleted. They might as well just delete the archive\n\t\t\t\t\t\tif (this.messages.length == 1)\n\t\t\t\t\t\t\thtml.find('a.message-delete').hide();\n\t\t\t\t\t\thtml.find('a.message-delete').on('click', (event: JQuery.ClickEvent) => {\n\t\t\t\t\t\t\tconst messageHtml = $(event.target.parentElement?.parentElement?.parentElement?.parentElement);\n\t\t\t\t\t\t\tconst buttonIcon = $(event.target);\n\t\t\t\t\t\t\tif (messageHtml.hasClass('dfal-deleted')) {\n\t\t\t\t\t\t\t\tmessageHtml.removeClass('dfal-deleted');\n\t\t\t\t\t\t\t\tbuttonIcon.removeClass('fa-redo-alt');\n\t\t\t\t\t\t\t\tbuttonIcon.addClass('fa-trash');\n\t\t\t\t\t\t\t\tdeletionList.splice(deletionList.findIndex(x => x === messageHtml.attr('data-message-id')), 1);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tmessageHtml.addClass('dfal-deleted');\n\t\t\t\t\t\t\t\tbuttonIcon.removeClass('fa-trash');\n\t\t\t\t\t\t\t\tbuttonIcon.addClass('fa-redo-alt');\n\t\t\t\t\t\t\t\tdeletionList.push(messageHtml.attr('data-message-id'));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (deletionList.length > 0) deleteButton.show();\n\t\t\t\t\t\t\telse deleteButton.hide();\n\t\t\t\t\t\t});\n\t\t\t\t\t\tmessageHtml.push(html);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tconsole.error(`Chat message ${chatMessage.id} failed to render.\\n${err})`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Prepend the HTML\n\t\t\t\tlog.prepend(messageHtml);\n\n\t\t\t\tdeleteButton.hide();\n\t\t\t\tdeleteButton.on('click', async () => {\n\t\t\t\t\tif (deletionList.length === this.messages.length) {\n\t\t\t\t\t\tui.notifications.warn('DF_CHAT_ARCHIVE.ArchiveViewer_Error_Delete_All'.localize());\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tDialog.confirm({\n\t\t\t\t\t\ttitle: \"DF_CHAT_ARCHIVE.ArchiveViewer_DeleteTitle\".localize(),\n\t\t\t\t\t\tcontent: \"DF_CHAT_ARCHIVE.ArchiveViewer_DeleteContent\".localize(),\n\t\t\t\t\t\tdefaultYes: false,\n\t\t\t\t\t\tyes: async () => {\n\t\t\t\t\t\t\tfor (const id of deletionList) {\n\t\t\t\t\t\t\t\tconst message = html.find(`li[data-message-id=\"${id}\"]`);\n\t\t\t\t\t\t\t\tmessage.hide(500, () => message.remove());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.messages = this.messages.filter((x: any) => !deletionList.includes(x._id));\n\t\t\t\t\t\t\tawait DFChatArchive.updateChatArchive(this.archive, this.messages);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\treturn html;\n\t\t\t});\n\t}\n\tclose(options?: Application.CloseOptions): Promise {\n\t\tthis.onCloseCallBack(this);\n\t\treturn super.close(options);\n\t}\n}","import DFChatArchiveNew from \"./DFChatArchiveNew\";\nimport DFChatArchiveManager from \"./DFChatArchiveManager\";\nimport { DFChatArchive } from \"./DFChatArchive\";\nimport SETTINGS from \"../../../common/Settings\";\n\n\nexport function init() {\n\n\tlet archiveNew: DFChatArchiveNew = null;\n\tlet archiveManager: DFChatArchiveManager = null;\n\n\tDFChatArchive.registerSettings();\n\tDFChatArchiveNew.registerSettings();\n\n\tSETTINGS.register(DFChatArchiveNew.PREF_HIDE_EXPORT, {\n\t\tname: 'DF_CHAT_ARCHIVE.Settings.HideExport',\n\t\tscope: 'world',\n\t\ttype: Boolean,\n\t\tdefault: false,\n\t\tconfig: true,\n\t\tonChange: (newValue) => {\n\t\t\tif (!newValue)\n\t\t\t\t$('#chat-controls .export-log').show();\n\t\t\telse\n\t\t\t\t$('#chat-controls .export-log').hide();\n\t\t}\n\t});\n\n\tSETTINGS.register(DFChatArchiveManager.PREF_REVERSE_SORT, {\n\t\tscope: 'world',\n\t\ttype: Boolean,\n\t\tdefault: false,\n\t\tconfig: false\n\t});\n\n\tHooks.on('renderChatLog', function (chatLog: ChatLog, html: JQuery) {\n\t\tconst archiveButton = $(`\n\t\t`);\n\t\tarchiveButton.on('click', () => {\n\t\t\tif (archiveNew == null) {\n\t\t\t\tarchiveNew = new DFChatArchiveNew({});\n\t\t\t\tarchiveNew.render(true);\n\t\t\t} else {\n\t\t\t\tarchiveNew.bringToTop();\n\t\t\t}\n\t\t});\n\t\thtml.find('.control-buttons')\n\t\t\t.prepend(archiveButton)\n\t\t\t.attr('style', 'flex:0 0 auto;');\n\t\tif (SETTINGS.get(DFChatArchiveNew.PREF_HIDE_EXPORT)) {\n\t\t\thtml.find('.control-buttons .export-log').hide();\n\t\t}\n\t});\n\n\tHooks.on('renderSettings', function (settings: Settings, html: JQuery) {\n\t\tconst archiveManagerHtml = $(`
    \n\t

    ${'DF_CHAT_ARCHIVE.ChatEnhanceSettingGroup'.localize()}

    \n\t\n
    `);\n\t\tarchiveManagerHtml.on('click', () => {\n\t\t\tif (archiveManager == null || ![Application.RENDER_STATES.RENDERED, Application.RENDER_STATES.RENDERING].includes((archiveManager)._state)) {\n\t\t\t\tarchiveManager = new DFChatArchiveManager();\n\t\t\t\tarchiveManager.render(true);\n\t\t\t} else {\n\t\t\t\tarchiveManager.bringToTop();\n\t\t\t}\n\t\t});\n\t\thtml.find('#settings-game').append(archiveManagerHtml);\n\t});\n\tHooks.on('closeDFChatArchiveNew', () => { archiveNew = null; });\n\tHooks.on('closeDFChatArchiveManager', () => { archiveNew = null; });\n\tHooks.on(`renderDFChatArchiveNew`, function (app: any, html: JQuery) {\n\t\thtml.find('input[type=\"text\"]')[0].focus();\n\t});\n}\n","import { ChatMessageData } from \"@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs\";\nimport SETTINGS from \"../../../common/Settings\";\nimport UTIL from \"../Util\";\n\nexport default class ChatTime {\n\n\tprivate static readonly PREF_ENABLED = 'ChatTime.UseSimpleCalender';\n\tprivate static readonly PREF_FORMAT = 'ChatTime.SimpleCalendarFormat';\n\tprivate static readonly FLAG_CHAT_TIME = 'ChatTime.WorldTime';\n\n\tprivate static get enabled() { return SETTINGS.get(this.PREF_ENABLED); }\n\tprivate static get simpleCalendarActive() { return !!game.modules.get('foundryvtt-simple-calendar')?.active; }\n\n\tstatic ready() {\n\t\tif (!this.simpleCalendarActive && game.user.isGM && this.enabled)\n\t\t\tui.notifications.warn('DF_CHAT_TIME.ErrorSimpleCalendarMissing', { permanent: true, localize: true });\n\t}\n\n\tstatic init() {\n\t\tSETTINGS.register(this.PREF_ENABLED, {\n\t\t\tscope: 'world',\n\t\t\ttype: Boolean,\n\t\t\tname: \"DF_CHAT_TIME.EnabledName\",\n\t\t\thint: \"DF_CHAT_TIME.EnabledHint\",\n\t\t\tdefault: false,\n\t\t\tconfig: true,\n\t\t\tonChange: UTIL.reloadChatLog\n\t\t});\n\n\t\tSETTINGS.register(this.PREF_FORMAT, {\n\t\t\tscope: 'world',\n\t\t\ttype: String,\n\t\t\tname: 'DF_CHAT_TIME.FormatName',\n\t\t\thint: 'DF_CHAT_TIME.FormatHint',\n\t\t\tdefault: 'YYYY, MMM DD, HH:mm',\n\t\t\tconfig: this.simpleCalendarActive,\n\t\t\tonChange: UTIL.reloadChatLog\n\t\t});\n\n\t\tlibWrapper.register(SETTINGS.MOD_NAME, 'ChatMessage.implementation.create',\n\t\t\t(wrapped: (...args: any) => unknown, chatData: Partial, createOptions: any) => {\n\t\t\t\tchatData.flags = chatData.flags ?? {};\n\t\t\t\tchatData.flags[SETTINGS.MOD_NAME] = {};\n\t\t\t\t(chatData.flags[SETTINGS.MOD_NAME] as any)[this.FLAG_CHAT_TIME] = game.time.worldTime;\n\t\t\t\treturn wrapped(chatData, createOptions);\n\t\t\t}, 'WRAPPER');\n\n\t\tHooks.on('renderChatMessage', (message: ChatMessage, html: JQuery, _data: any) => {\n\t\t\tif (!this.simpleCalendarActive || !this.enabled) return;\n\t\t\tconst simpleTimestamp = message.getFlag(SETTINGS.MOD_NAME, this.FLAG_CHAT_TIME);\n\t\t\tif (simpleTimestamp === undefined) return;\n\t\t\tconst timeElement = html.find('.message-timestamp');\n\t\t\tconst simpleTimeElement = $(``);\n\t\t\ttimeElement.after(simpleTimeElement);\n\t\t\ttimeElement.hide();\n\t\t});\n\t}\n}","import { ChatMessageData } from \"@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs\";\nimport SETTINGS from \"../../../common/Settings\";\nimport DFChatEdit from \"./df-chat-edit\";\n\n\ndeclare namespace marked {\n\tfunction parse(md: string, options: any): string;\n}\n\nexport default class DFChatEditor extends FormApplication {\n\tprivate chatMessage: ChatMessageData & ChatMessage;\n\tpublic static readonly PREF_MARKDOWN = 'edit-markdown';\n\n\t/**\n\t * Assign the default options which are supported by the entity edit sheet.\n\t * @returns The default options for this FormApplication class\n\t * @override\n\t * @see {@link Application.defaultOptions}\n\t */\n\tstatic get defaultOptions(): FormApplicationOptions {\n\t\treturn mergeObject(FormApplication.defaultOptions as Partial, {\n\t\t\tcloseOnSubmit: true,\n\t\t\teditable: true,\n\t\t\tresizable: true,\n\t\t\twidth: 400,\n\t\t\tpopOut: true,\n\t\t\ttitle: 'DF_CHAT_EDIT.Editor_Title',\n\t\t\ttemplate: 'modules/df-chat-enhance/templates/chat-edit.hbs'\n\t\t}) as FormApplicationOptions;\n\t}\n\n\tconstructor(chatMessage: ChatMessageData & ChatMessage) {\n\t\tsuper({});\n\t\tthis.chatMessage = chatMessage;\n\t}\n\n\t/** @override */\n\tgetData(options?: any): any {\n\n\t\t// Collect the different Actor types and the labels for those types\n\t\tconst types = Object.keys(CONFIG.Actor.typeLabels).map(type => {\n\t\t\treturn { type, label: CONFIG.Actor.typeLabels[type], actors: [] };\n\t\t});\n\t\t// Organize the actors in the current scene into those type categories\n\t\tfor (const type of types) {\n\t\t\ttype.actors = game.scenes.viewed.tokens.contents.filter(x => x.actor.type === type.type).map(x => ({\n\t\t\t\tid: 'token-' + x.id,\n\t\t\t\tname: x.name\n\t\t\t}));\n\t\t}\n\n\t\tlet selected = '';\n\t\tif (this.chatMessage.user)\n\t\t\tselected = 'user-' + this.chatMessage.user;\n\t\tif (this.chatMessage.speaker.token)\n\t\t\tselected = 'token-' + this.chatMessage.speaker.token;\n\n\t\treturn mergeObject(options, {\n\t\t\tselected,\n\t\t\tplayers: game.users.map(x => ({ id: 'user-' + x.id, name: x.name })),\n\t\t\tactorGroups: types.filter(x => x.actors.length > 0),\n\t\t\tmessageText: this.chatMessage.content\n\t\t\t\t.replace(/< *br *\\/?>/gm, '\\n')\n\t\t\t\t.replace(/

    .+/, '')\n\t\t});\n\t}\n\n\t/** @override */\n\tactivateListeners(html: JQuery): void {\n\t\tsuper.activateListeners(html);\n\t\thtml.find('#cancel').on('click', async () => await this.close());\n\t}\n\n\t/** @override */\n\tasync _updateObject(_event?: any, formData?: { content: string, speaker: string }) {\n\t\tlet data = formData.content as string;\n\t\tif (SETTINGS.get(DFChatEditor.PREF_MARKDOWN)) {\n\t\t\tdata = DFChatEditor.processMarkdown(data)[1];\n\t\t} else {\n\t\t\tdata = data.replace(/\\r?\\n/gm, '
    ');\n\t\t}\n\t\tif (SETTINGS.get(DFChatEdit.PREF_SHOW_EDITED) && data.search(/

    /) < 0) {\n\t\t\tdata += `

    ${'DF_CHAT_EDIT.EditedFlag'.localize()}

    `;\n\t\t}\n\n\t\tlet speaker = undefined;\n\t\tlet user = undefined;\n\t\tif (formData.speaker.startsWith('user-')) {\n\t\t\tuser = game.users.get(formData.speaker.substring('user-'.length)).id;\n\t\t\t// @ts-expect-error\n\t\t\tspeaker = ChatMessage._getSpeakerFromUser({ user });\n\t\t} else\n\t\t\tspeaker = ChatMessage.getSpeaker({ token: game.scenes.viewed.tokens.get(formData.speaker.substring('token-'.length)) });\n\t\tif (speaker.alias === undefined)\n\t\t\tspeaker.alias = null;\n\t\tthis.chatMessage.update({ content: data, speaker, user });\n\t}\n\t/** @override */\n\tclose(options?: FormApplication.CloseOptions) {\n\t\tdelete (this.chatMessage).chatEditor;\n\t\treturn super.close(options);\n\t}\n\n\tpublic static processMarkdown(message: string) {\n\t\tconst originalMessage = message;\n\t\tmessage = marked.parse(message, {\n\t\t\theaderIds: false,\n\t\t\tbreaks: true\n\t\t}).trimEnd();\n\t\tif (message.startsWith('

    '))\n\t\t\tmessage = message.substr(3);\n\t\tif (message.endsWith('

    '))\n\t\t\tmessage = message.substr(0, message.length - 4);\n\t\tconst newLine = /(<\\/?[ a-z]+>)\\n(<\\/?[ a-z]+>?)/;\n\t\twhile (newLine.test(message))\n\t\t\tmessage = message.replace(newLine, '$1$2');\n\t\treturn [originalMessage, message];\n\t}\n}","import { ChatMessageData } from \"@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs\";\nimport SETTINGS from \"../../../common/Settings\";\nimport DFChatEditor from './DFChatEditor';\n\nconst PREF_EDIT_ALLOWED = 'edit-allowed';\nconst PREF_GM_ALL = 'gm-edit-all';\nconst PREF_IGNORE_HTML = 'edit-ignore-html';\n\nexport default class DFChatEdit {\n\tstatic readonly PREF_SHOW_EDITED = 'DFChatEdit.ShowEditedLable';\n\n\tstatic ready() {\n\t\tSETTINGS.register(DFChatEditor.PREF_MARKDOWN, {\n\t\t\tname: 'DF_CHAT_EDIT.Settings_MarkdownName',\n\t\t\thint: 'DF_CHAT_EDIT.Settings_MarkdownHint',\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t\tconfig: true,\n\t\t\tscope: 'world'\n\t\t});\n\t\tSETTINGS.register(PREF_EDIT_ALLOWED, {\n\t\t\tname: 'DF_CHAT_EDIT.Settings_AllowEditName',\n\t\t\thint: 'DF_CHAT_EDIT.Settings_AllowEditHint',\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t\tscope: 'world',\n\t\t\tconfig: true\n\t\t});\n\t\tSETTINGS.register(PREF_GM_ALL, {\n\t\t\tname: 'DF_CHAT_EDIT.Settings_GMEditAllName',\n\t\t\thint: 'DF_CHAT_EDIT.Settings_GMEditAllHint',\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t\tconfig: true,\n\t\t\tscope: 'world'\n\t\t});\n\t\tSETTINGS.register(PREF_IGNORE_HTML, {\n\t\t\tname: 'DF_CHAT_EDIT.Settings_IgnoreHtmlName',\n\t\t\thint: 'DF_CHAT_EDIT.Settings_IgnoreHtmlHint',\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t\tconfig: true,\n\t\t\tscope: 'world'\n\t\t});\n\t\tSETTINGS.register(this.PREF_SHOW_EDITED, {\n\t\t\tname: 'DF_CHAT_EDIT.Settings_ShowEditedLabelName',\n\t\t\thint: 'DF_CHAT_EDIT.Settings_ShowEditedLabelHint',\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t\tconfig: true,\n\t\t\tscope: 'world'\n\t\t});\n\n\t\tlibWrapper.register(SETTINGS.MOD_NAME, 'ChatLog.prototype._onChatKeyDown', (wrapper: (..._: any) => void, ...args: any) => {\n\t\t\tconst event = args[0] as KeyboardEvent;\n\t\t\t// We have used the Shift+Up combo to edit previously sent message\n\t\t\tif (event.code === \"ArrowUp\" && event.ctrlKey) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tlet messages = <(ChatMessageData & ChatMessage)[]>[...(ui.chat.collection.values())];\n\t\t\t\t// Perform an inverted sort ( n<0 before, n=0 same, n>0 after )\n\t\t\t\tmessages = messages.sort((a, b) => b.timestamp - a.timestamp);\n\t\t\t\tconst message = messages.find(x => x.user === game.user.id);\n\t\t\t\tif (!message) return;\n\t\t\t\tDFChatEdit.editChatMessage.bind(message)();\n\t\t\t}\n\t\t\telse\n\t\t\t\twrapper(...args);\n\t\t}, 'MIXED');\n\n\t\tlibWrapper.register(SETTINGS.MOD_NAME, 'ChatLog.prototype.processMessage', function (this: ChatLog, wrapper: AnyFunction, message: string) {\n\t\t\tlet originalMessage: string = null;\n\t\t\tif (SETTINGS.get(DFChatEditor.PREF_MARKDOWN)) {\n\t\t\t\tif (message.trim().startsWith('/')) {\n\t\t\t\t\tconst token = message.split(' ')[0].trim();\n\t\t\t\t\tswitch (token) {\n\t\t\t\t\t\tcase '/ooc': /* fall-through */\n\t\t\t\t\t\tcase '/ic': /* fall-through */\n\t\t\t\t\t\tcase '/emote': /* fall-through */\n\t\t\t\t\t\tcase '/whisper': /* fall-through */\n\t\t\t\t\t\tcase '/w':\n\t\t\t\t\t\t\t[originalMessage, message] = DFChatEditor.processMarkdown(message.substr(token.length));\n\t\t\t\t\t\t\toriginalMessage = `${token} ${originalMessage.trimStart()}`;\n\t\t\t\t\t\t\tmessage = `${token} ${message.trimStart()}`;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'log': /* fall-through */\n\t\t\t\t\t\tcase 'gmlog': /* fall-through */\n\t\t\t\t\t\tcase '/gmroll': /* fall-through */\n\t\t\t\t\t\tcase '/blindroll': /* fall-through */\n\t\t\t\t\t\tcase '/selfroll': /* fall-through */\n\t\t\t\t\t\tcase '/r': /* fall-through */\n\t\t\t\t\t\tcase '/roll': /* fall-through */\n\t\t\t\t\t\tdefault: break;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t[originalMessage, message] = DFChatEditor.processMarkdown(message);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst result = wrapper(message);\n\t\t\tif (originalMessage) {\n\t\t\t\tthis._sentMessages.splice(0, 1);\n\t\t\t\tthis._sentMessages.unshift(originalMessage);\n\t\t\t}\n\t\t\treturn result;\n\t\t}, 'WRAPPER');\n\t}\n\n\tstatic appendChatContextMenuOptions(options: ContextMenu.Item[]) {\n\t\toptions.push({\n\t\t\tname: 'DF_CHAT_EDIT.ContextOption',\n\t\t\ticon: '',\n\t\t\tcondition: (header) => {\n\t\t\t\tconst chatData = ui.chat.collection.get($(header).attr('data-message-id'));\n\t\t\t\treturn this.processChatMessage(chatData);\n\t\t\t},\n\t\t\tcallback: (header) => {\n\t\t\t\tconst chatData = ui.chat.collection.get($(header).attr('data-message-id'));\n\t\t\t\tDFChatEdit.editChatMessage.bind(chatData)();\n\t\t\t\treturn {};\n\t\t\t}\n\t\t});\n\t}\n\n\t// Will be bound to the instance of ChatMessage we are observing\n\tstatic async editChatMessage(this: ChatMessageData & ChatMessage) {\n\t\t// Double check permissions\n\t\tif (!SETTINGS.get(PREF_EDIT_ALLOWED)) {\n\t\t\tui.notifications.warn('DF_CHAT_EDIT.Error_NoPermission'.localize());\n\t\t\treturn;\n\t\t}\n\t\tif ((this).chatEditor) {\n\t\t\t(this).chatEditor.bringToTop();\n\t\t} else {\n\t\t\t(this).chatEditor = new DFChatEditor(this);\n\t\t\tawait (this).chatEditor._render(true);\n\t\t}\n\t\t(this).chatEditor.element.find('textarea').focus();\n\t}\n\n\tstatic isHTML(str: string): boolean {\n\t\tconst doc = new DOMParser().parseFromString(str, \"text/html\");\n\t\treturn Array.from(doc.body.childNodes).some(node => {\n\t\t\treturn (node instanceof HTMLElement && !node.classList.contains('df-edited'))\n\t\t\t\t&& !(node instanceof HTMLBRElement)\n\t\t\t\t&& node.nodeType === 1;\n\t\t});\n\t}\n\n\tstatic processChatMessage(chatMessage: ChatMessageData & ChatMessage/*, html: JQuery*/): boolean {\n\t\t// If we are catching the render of an archived message\n\t\tif (!ui.chat.collection.has(chatMessage.id))\n\t\t\treturn false;\n\t\t// Ignore rolls and other people's messages, unless we are the GM and PREF_GM_ALL is true\n\t\tif (!SETTINGS.get(PREF_EDIT_ALLOWED) || chatMessage.isRoll\n\t\t\t|| (chatMessage.user.id !== game.userId && !(game.user.isGM && SETTINGS.get(PREF_GM_ALL))))\n\t\t\treturn false;\n\t\t// If we ignore html and message contains html, return\n\t\tif (SETTINGS.get(PREF_IGNORE_HTML) && DFChatEdit.isHTML(chatMessage.content)) return false;\n\t\treturn true;\n\t}\n}\n","import SETTINGS from \"../../../common/Settings\";\n\nexport default class FontSizePatch {\n\n\tprivate static readonly PREF_SIZE = 'FontSizePatch.FontSize';\n\n\tstatic init() {\n\t\tSETTINGS.register(this.PREF_SIZE, {\n\t\t\tname: 'DF_CHAT_FONT_SIZE.FontSizeName'.localize(),\n\t\t\thint: 'DF_CHAT_FONT_SIZE.FontSizeHint'.localize(),\n\t\t\tconfig: true,\n\t\t\ttype: Number,\n\t\t\tscope: 'client',\n\t\t\trange: {\n\t\t\t\tmin: 10,\n\t\t\t\tmax: 30,\n\t\t\t\tstep: 0.5\n\t\t\t},\n\t\t\tdefault: 14,\n\t\t\tonChange: (newSize) => this.updateFontSize(newSize)\n\t\t});\n\t\tthis.updateFontSize(SETTINGS.get(this.PREF_SIZE));\n\t}\n\n\tprivate static updateFontSize(size: number) {\n\t\t(document.querySelector(':root')).style.setProperty('--dfce-chat-font-size', size.toString() + 'px');\n\t}\n}","import SETTINGS from \"../../../common/Settings\";\nimport DFAdventureLogProcessor from \"./DFAdventureLogProcessor\";\n\n\nexport default class DFAdventureLogConfig extends FormApplication {\n\tstatic readonly PREF_JOURNAL = 'log-journal';\n\tstatic readonly PREF_JOURNAL_GM = 'gmlog-journal';\n\tstatic readonly PREF_CONFIG = 'log-config-menu';\n\n\tstatic get defaultOptions() {\n\t\treturn mergeObject(FormApplication.defaultOptions as Partial, {\n\t\t\ttemplate: \"modules/df-chat-enhance/templates/log-config.hbs\",\n\t\t\tresizable: false,\n\t\t\tminimizable: false,\n\t\t\ttitle: \"DF_CHAT_LOG.Config_Title\".localize()\n\t\t}) as FormApplicationOptions;\n\t}\n\n\tstatic setupSettings() {\n\t\tSETTINGS.register(DFAdventureLogConfig.PREF_JOURNAL, {\n\t\t\tscope: 'world',\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t\tconfig: false\n\t\t});\n\t\tSETTINGS.register(DFAdventureLogConfig.PREF_JOURNAL_GM, {\n\t\t\tscope: 'world',\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t\tconfig: false\n\t\t});\n\t\tSETTINGS.registerMenu(DFAdventureLogConfig.PREF_CONFIG, {\n\t\t\trestricted: true,\n\t\t\ttype: DFAdventureLogConfig,\n\t\t\tlabel: \"DF_CHAT_LOG.Config_Title\",\n\t\t\ticon: 'fas fa-edit'\n\t\t});\n\t}\n\n\tgetData(options?: any) {\n\t\tconst data = super.getData(options);\n\t\tconst keys = game.journal.contents.filter(x => x.pages.contents.some(y => y.type === 'text')).map(x => x.id);\n\t\tconst selectedLog = (SETTINGS.get(DFAdventureLogConfig.PREF_JOURNAL) as string | undefined)?.split('.');\n\t\tconst selectedGMLog = (SETTINGS.get(DFAdventureLogConfig.PREF_JOURNAL_GM) as string | undefined)?.split('.');\n\t\tlet logJournals: any[] = [];\n\t\tlet logJournalPages: any[] = [];\n\t\tlet gmlogJournals: any[] = [];\n\t\tlet gmlogJournalPages: any[] = [];\n\t\tfor (const key of keys) {\n\t\t\tlogJournals.push({\n\t\t\t\tid: key,\n\t\t\t\tname: game.journal.get(key).name,\n\t\t\t\tselected: selectedLog && key === selectedLog[0]\n\t\t\t});\n\t\t\tif (selectedLog && key === selectedLog[0]) {\n\t\t\t\tlogJournalPages = game.journal.get(key).pages.contents.map(x => ({\n\t\t\t\t\tid: key + '.' + x.id,\n\t\t\t\t\tname: x.name,\n\t\t\t\t\tselected: x.id === selectedLog[1]\n\t\t\t\t}));\n\t\t\t}\n\t\t\tgmlogJournals.push({\n\t\t\t\tid: key,\n\t\t\t\tname: game.journal.get(key).name,\n\t\t\t\tselected: selectedGMLog && key === selectedGMLog[0]\n\t\t\t});\n\t\t\tif (selectedGMLog && key === selectedGMLog[0]) {\n\t\t\t\tgmlogJournalPages = game.journal.get(key).pages.contents.map(x => ({\n\t\t\t\t\tid: key + '.' + x.id,\n\t\t\t\t\tname: x.name,\n\t\t\t\t\tselected: x.id === selectedGMLog[1]\n\t\t\t\t}));\n\t\t\t}\n\t\t}\n\t\tlogJournals = logJournals.sort((a, b) => a.name.localeCompare(b.name));\n\t\tgmlogJournals = gmlogJournals.sort((a, b) => a.name.localeCompare(b.name));\n\n\t\tmergeObject(data as any, {\n\t\t\tlogJournals,\n\t\t\tlogJournalPages,\n\t\t\tgmlogJournals,\n\t\t\tgmlogJournalPages\n\t\t});\n\t\treturn data;\n\t}\n\n\tprivate fillPageList(journalId: string, element: JQuery) {\n\t\telement.children().remove();\n\t\tconst journal = game.journal.get(journalId);\n\t\tif (!journal) return;\n\t\tfor (const page of journal.pages.contents.filter(x => x.type == 'text')) {\n\t\t\telement.append(``);\n\t\t}\n\t}\n\n\tactivateListeners(html: JQuery): void {\n\t\thtml.find('#dfal-journal').on('change', event => {\n\t\t\tconst journalId = (event.currentTarget as HTMLSelectElement).value;\n\t\t\tconst pageElement = html.find('#dfal-journal-page');\n\t\t\tthis.fillPageList(journalId, pageElement);\n\t\t});\n\t\thtml.find('#dfal-journal-gm').on('change', event => {\n\t\t\tconst journalId = (event.currentTarget as HTMLSelectElement).value;\n\t\t\tconst pageElement = html.find('#dfal-journal-gm-page');\n\t\t\tthis.fillPageList(journalId, pageElement);\n\t\t});\n\t}\n\n\tasync _updateObject(_event?: any, formData?: any) {\n\t\tconst logJournal = formData['dfal-journal-page'];\n\t\tconst gmlogJournal = formData['dfal-journal-gm-page'];\n\t\tconst clear = formData['dfal-clear'];\n\t\tconst gmClear = formData['dfal-clear-gm'];\n\t\tSETTINGS.set(DFAdventureLogConfig.PREF_JOURNAL, logJournal);\n\t\tSETTINGS.set(DFAdventureLogConfig.PREF_JOURNAL_GM, gmlogJournal);\n\t\tawait DFAdventureLogConfig.initializeJournal(logJournal, clear, false, false);\n\t\tawait DFAdventureLogConfig.initializeJournal(gmlogJournal, gmClear, true, false);\n\t}\n\n\tstatic async initializeJournal(id: string, clear: boolean, isGMOnly: boolean, isPlayerLog: boolean) {\n\t\tconst journalId = id?.split('.');\n\t\tif (!journalId || journalId.length < 2 || !game.journal.has(journalId[0])) return;\n\t\tconst journal = game.journal.get(journalId[0]).pages.get(journalId[1]);\n\t\tif (clear || journal.text.content === null)\n\t\t\tjournal.text.content = '';\n\t\tconst html = $(journal.text.content);\n\t\tconst article = html.find('article[class=\"df-adventure-log\"]');\n\t\tif (article.length != 0) {\n\t\t\tawait DFAdventureLogProcessor.resortLog();\n\t\t\treturn;\n\t\t}\n\t\tawait journal.update({\n\t\t\t'text.content': journal.text.content + `\n\t\t\t
    \n\t\t\t\t

    ${game.i18n.localize(isGMOnly ? 'DF_CHAT_LOG.GMLog_Header' : isPlayerLog ? 'DF_CHAT_LOG.PLog_Header' : 'DF_CHAT_LOG.Log_Header')}

    \n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t`\n\t\t});\n\t}\n}","\nimport { ChatMessageData, ChatMessageDataConstructorData } from \"@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/chatMessageData\";\nimport SETTINGS from \"../../../common/Settings\";\nimport DFChatEditor from \"../edit/DFChatEditor\";\nimport DFAdventureLogConfig from './DFAdventureLogConfig';\n\ndeclare global {\n\tnamespace SimpleCalendar.api {\n\t\tfunction formatDateTime(time: {\n\t\t\tyear: number,\n\t\t\tmonth: number,\n\t\t\tday: number,\n\t\t\thour: number,\n\t\t\tminute: number,\n\t\t\tsecond: number\n\t\t}): { date: string, time: string }\n\t\tfunction formatDateTime(time: {\n\t\t\tyear: number,\n\t\t\tmonth: number,\n\t\t\tday: number,\n\t\t\thour: number,\n\t\t\tminute: number,\n\t\t\tsecond: number\n\t\t}, format: string): string\n\t\tfunction timestamp(): number\n\t\tfunction timestampToDate(timestamp: number): {\n\t\t\tyear: number,\n\t\t\tmonth: number,\n\t\t\tday: number,\n\t\t\thour: number,\n\t\t\tminute: number,\n\t\t\tsecond: number\n\t\t}\n\t}\n}\n\ndeclare global {\n\tinterface String {\n\t\ttrimStart(): string\n\t}\n}\nif (!String.prototype.trimStart) {\n\tString.prototype.trimStart = function () {\n\t\tconst whitespace = [' ', '\\n', '\\r'];\n\t\tlet index = -1;\n\t\tfor (let c = 0; c < this.length; c++) {\n\t\t\tif (whitespace.every(x => x !== this[c])) break;\n\t\t\tindex = c;\n\t\t}\n\t\treturn this.substr(index + 1);\n\t};\n}\n\ndeclare interface ChatCommand {\n\tcommandKey: string;\n\tshouldDisplayToChat: boolean;\n\tinvokeOnCommand: () => void;\n\tcreatedMessageType: number;\n\ticonClass: string;\n\tdescription: string;\n\tgmOnly: boolean;\n}\n\ndeclare class ChatCommands {\n\t/**\n\t * Registers a Chat Command to be handled\n\t */\n\tregisterCommand(command: ChatCommand): void;\n\t/**\n\t * Deregister a Chat Command\n\t */\n\tderegisterCommand(command: ChatCommand): void;\n\tcreateCommandFromData(data: any): ChatCommand;\n}\n\ndeclare class GameExt extends Game {\n\tchatCommands: ChatCommands;\n}\n\nexport default class DFAdventureLogProcessor {\n\tstatic readonly PREF_ENABLE = 'enable-command';\n\tstatic readonly PREF_GMONLY = 'df-log-gmonly';\n\tstatic readonly PREF_GMONLY_WHISPER = 'df-log-gmonly-whisper';\n\tstatic readonly PREF_MESSAGES = 'df-log-messages';\n\tstatic readonly PREF_SORTDESC = 'df-log-sortdesc';\n\tstatic readonly PREF_DISABLE_FORMATTING = 'df-log-disable-format';\n\tstatic readonly PREF_DISABLE_AUTHOR = 'df-log-disable-author';\n\tstatic readonly PREF_SIMPLE_CALENDAR = 'df-log-use-simple-calendar';\n\tstatic readonly PREF_USE_TIME = 'df-log-use-time';\n\tstatic readonly PREF_PLAYER_LOG_JOURNAL = 'PlayerAdventureLog';\n\tstatic logCommand: ChatCommand = null;\n\tstatic gmlogCommand: ChatCommand = null;\n\tstatic plogCommand: ChatCommand = null;\n\n\tstatic appendChatContextMenuOptions(options: ContextMenu.Item[]) {\n\t\toptions.push({\n\t\t\tname: 'DF_CHAT_LOG.ContextMenu_AsEvent',\n\t\t\ticon: '',\n\t\t\tcondition: () => {\n\t\t\t\tconst enabled = SETTINGS.get(DFAdventureLogProcessor.PREF_ENABLE);\n\t\t\t\tconst isGM = game.user.isGM;\n\t\t\t\tconst gmOnly = SETTINGS.get(DFAdventureLogProcessor.PREF_GMONLY);\n\t\t\t\treturn enabled && (!gmOnly || isGM);\n\t\t\t},\n\t\t\tcallback: (header) => {\n\t\t\t\tconst chatData = ui.chat.collection.get($(header).attr('data-message-id'));\n\t\t\t\tDFAdventureLogProcessor.commandProcessor(chatData.content, false, false);\n\t\t\t\treturn {};\n\t\t\t}\n\t\t});\n\t\toptions.push({\n\t\t\tname: 'DF_CHAT_LOG.ContextMenu_AsQuote',\n\t\t\ticon: '',\n\t\t\tcondition: () => {\n\t\t\t\tconst enabled = SETTINGS.get(DFAdventureLogProcessor.PREF_ENABLE);\n\t\t\t\tconst isGM = game.user.isGM;\n\t\t\t\tconst gmOnly = SETTINGS.get(DFAdventureLogProcessor.PREF_GMONLY);\n\t\t\t\treturn enabled && (!gmOnly || isGM);\n\t\t\t},\n\t\t\tcallback: (header) => {\n\t\t\t\tconst chatData = ui.chat.collection.get($(header).attr('data-message-id'));\n\t\t\t\tif (chatData.content.trimStart().startsWith('\"'))\n\t\t\t\t\tDFAdventureLogProcessor.commandProcessor('q ' + chatData.content, false, false);\n\t\t\t\telse\n\t\t\t\t\tDFAdventureLogProcessor.commandProcessor(`q \"${game.users.get(chatData.user).name}\" ${chatData.content}`, false, false);\n\t\t\t\treturn {};\n\t\t\t}\n\t\t});\n\t\toptions.push({\n\t\t\tname: 'DF_CHAT_LOG.ContextMenu_AsGmEvent',\n\t\t\ticon: '',\n\t\t\tcondition: () => {\n\t\t\t\tconst enabled = SETTINGS.get(DFAdventureLogProcessor.PREF_ENABLE);\n\t\t\t\tconst isGM = game.user.isGM;\n\t\t\t\treturn enabled && isGM;\n\t\t\t},\n\t\t\tcallback: (header) => {\n\t\t\t\tconst chatData = ui.chat.collection.get($(header).attr('data-message-id'));\n\t\t\t\tDFAdventureLogProcessor.commandProcessor(chatData.content, true, false);\n\t\t\t\treturn {};\n\t\t\t}\n\t\t});\n\t\toptions.push({\n\t\t\tname: 'DF_CHAT_LOG.ContextMenu_AsGmQuote',\n\t\t\ticon: '',\n\t\t\tcondition: () => {\n\t\t\t\tconst enabled = SETTINGS.get(DFAdventureLogProcessor.PREF_ENABLE);\n\t\t\t\tconst isGM = game.user.isGM;\n\t\t\t\treturn enabled && isGM;\n\t\t\t},\n\t\t\tcallback: (header) => {\n\t\t\t\tconst chatData = ui.chat.collection.get($(header).attr('data-message-id'));\n\t\t\t\tif (chatData.content.trimStart().startsWith('\"'))\n\t\t\t\t\tDFAdventureLogProcessor.commandProcessor('q ' + chatData.content, true, false);\n\t\t\t\telse\n\t\t\t\t\tDFAdventureLogProcessor.commandProcessor(`q \"${game.users.get(chatData.user).name}\" ${chatData.content}`, true, false);\n\t\t\t\treturn {};\n\t\t\t}\n\t\t});\n\t}\n\n\tstatic setupSettings() {\n\t\tSETTINGS.register(DFAdventureLogProcessor.PREF_ENABLE, {\n\t\t\tscope: 'world',\n\t\t\tname: 'DF_CHAT_LOG.Setting.EnableTitle',\n\t\t\thint: 'DF_CHAT_LOG.Setting.EnableHint',\n\t\t\tconfig: true,\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t\tonChange: (enabled: boolean) => {\n\t\t\t\tif (!enabled && !!DFAdventureLogProcessor.logCommand)\n\t\t\t\t\tDFAdventureLogProcessor.deregisterCommand();\n\t\t\t\telse\n\t\t\t\t\tDFAdventureLogProcessor.registerCommand();\n\t\t\t}\n\t\t});\n\t\tSETTINGS.register(DFAdventureLogProcessor.PREF_GMONLY, {\n\t\t\tname: 'DF_CHAT_LOG.Setting.GmOnlyTitle',\n\t\t\thint: 'DF_CHAT_LOG.Setting.GmOnlyHint',\n\t\t\tscope: 'world',\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t\tconfig: true,\n\t\t\tonChange: (gmOnly) => {\n\t\t\t\tif (gmOnly && !game.user.isGM)\n\t\t\t\t\tDFAdventureLogProcessor.deregisterCommand();\n\t\t\t\telse\n\t\t\t\t\tDFAdventureLogProcessor.registerCommand();\n\t\t\t}\n\t\t});\n\t\tSETTINGS.register(DFAdventureLogProcessor.PREF_GMONLY_WHISPER, {\n\t\t\tname: 'DF_CHAT_LOG.Setting.GmOnlyWhisperName',\n\t\t\thint: 'DF_CHAT_LOG.Setting.GmOnlyWhisperHint',\n\t\t\tscope: 'world',\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t\tconfig: true\n\t\t});\n\t\tSETTINGS.register(DFAdventureLogProcessor.PREF_USE_TIME, {\n\t\t\tscope: 'world',\n\t\t\ttype: Boolean,\n\t\t\tname: \"DF_CHAT_LOG.Setting.UseTimeName\",\n\t\t\thint: \"DF_CHAT_LOG.Setting.UseTimeHint\",\n\t\t\tdefault: true,\n\t\t\tconfig: true\n\t\t});\n\t\tSETTINGS.register(DFAdventureLogProcessor.PREF_MESSAGES, {\n\t\t\tname: 'DF_CHAT_LOG.Setting.PrintMessagesName',\n\t\t\thint: 'DF_CHAT_LOG.Setting.PrintMessagesHint',\n\t\t\tscope: 'world',\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t\tconfig: true\n\t\t});\n\t\tSETTINGS.register(DFAdventureLogProcessor.PREF_SORTDESC, {\n\t\t\tname: 'DF_CHAT_LOG.Setting.SortDescendingName',\n\t\t\thint: 'DF_CHAT_LOG.Setting.SortDescendingHint',\n\t\t\tscope: 'world',\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t\tconfig: true,\n\t\t\tonChange: () => this.resortLog()\n\t\t});\n\t\tSETTINGS.register(DFAdventureLogProcessor.PREF_DISABLE_FORMATTING, {\n\t\t\tname: 'DF_CHAT_LOG.Setting.DisableFormatName'.localize(),\n\t\t\thint: 'DF_CHAT_LOG.Setting.DisableFormatHint'.localize(),\n\t\t\tconfig: true,\n\t\t\tscope: 'world',\n\t\t\ttype: Boolean,\n\t\t\tdefault: false\n\t\t});\n\t\tSETTINGS.register(DFAdventureLogProcessor.PREF_DISABLE_AUTHOR, {\n\t\t\tname: 'DF_CHAT_LOG.Setting.DisableEntryAuthorName'.localize(),\n\t\t\thint: 'DF_CHAT_LOG.Setting.DisableEntryAuthorHint'.localize(),\n\t\t\tconfig: true,\n\t\t\tscope: 'world',\n\t\t\ttype: Boolean,\n\t\t\tdefault: false\n\t\t});\n\t\t// If Simple Calendar is enabled\n\t\tif (game.modules.get('foundryvtt-simple-calendar')?.active) {\n\t\t\tSETTINGS.register(DFAdventureLogProcessor.PREF_SIMPLE_CALENDAR, {\n\t\t\t\tscope: 'world',\n\t\t\t\ttype: Boolean,\n\t\t\t\tname: \"DF_CHAT_LOG.Setting.SimpleCalendarName\",\n\t\t\t\thint: \"DF_CHAT_LOG.Setting.SimpleCalendarHint\",\n\t\t\t\tdefault: false,\n\t\t\t\tconfig: true\n\t\t\t});\n\t\t}\n\n\t\tHooks.on('closeDFAdventureLogConfig', () => { DFAdventureLogProcessor.logConfig = null; });\n\t\tif ((game as GameExt).chatCommands)\n\t\t\tDFAdventureLogProcessor.registerCommand();\n\t\telse\n\t\t\tHooks.on('chatCommandsReady', function () { DFAdventureLogProcessor.registerCommand(); });\n\t}\n\n\tstatic deregisterCommand() {\n\t\t(game as GameExt).chatCommands.deregisterCommand(DFAdventureLogProcessor.logCommand);\n\t\t(game as GameExt).chatCommands.deregisterCommand(DFAdventureLogProcessor.plogCommand);\n\t\tif (DFAdventureLogProcessor.gmlogCommand)\n\t\t\t(game as GameExt).chatCommands.deregisterCommand(DFAdventureLogProcessor.gmlogCommand);\n\t\tDFAdventureLogProcessor.logCommand = null;\n\t\tDFAdventureLogProcessor.plogCommand = null;\n\t\tDFAdventureLogProcessor.gmlogCommand = null;\n\t}\n\tstatic registerCommand() {\n\t\tif (!SETTINGS.get(DFAdventureLogProcessor.PREF_ENABLE))\n\t\t\treturn;\n\t\tif (SETTINGS.get(DFAdventureLogProcessor.PREF_GMONLY) && !game.user.isGM)\n\t\t\treturn;\n\t\tif (DFAdventureLogProcessor.logCommand)\n\t\t\treturn;\n\n\t\tDFAdventureLogProcessor.logCommand = (game as GameExt).chatCommands.createCommandFromData({\n\t\t\tcommandKey: \"/log\",\n\t\t\tinvokeOnCommand: async (_cl: any, msg: string, _cd: any) => await DFAdventureLogProcessor.commandProcessor(msg, false, false),\n\t\t\tshouldDisplayToChat: false,\n\t\t\ticonClass: \"fa-edit\",\n\t\t\tdescription: \"DF_CHAT_LOG.CommandDescription\".localize()\n\t\t});\n\t\t(game as GameExt).chatCommands.registerCommand(DFAdventureLogProcessor.logCommand);\n\n\t\tDFAdventureLogProcessor.plogCommand = (game as GameExt).chatCommands.createCommandFromData({\n\t\t\tcommandKey: \"/plog\",\n\t\t\tinvokeOnCommand: async (_cl: any, msg: string, _cd: any) => await DFAdventureLogProcessor.commandProcessor(msg, false, true),\n\t\t\tshouldDisplayToChat: false,\n\t\t\ticonClass: \"fa-edit\",\n\t\t\tdescription: \"DF_CHAT_LOG.PCCommandDescription\".localize()\n\t\t});\n\t\t(game as GameExt).chatCommands.registerCommand(DFAdventureLogProcessor.plogCommand);\n\n\t\t// If we are not the GM, early return to avoid registering the /gmlog command\n\t\tif (!game.user.isGM) return;\n\t\t// Register the /gmlog command\n\t\tDFAdventureLogProcessor.gmlogCommand = (game as GameExt).chatCommands.createCommandFromData({\n\t\t\tcommandKey: \"/gmlog\",\n\t\t\tinvokeOnCommand: async (_cl: any, msg: string, _cd: any) => await DFAdventureLogProcessor.commandProcessor(msg, true, false),\n\t\t\tshouldDisplayToChat: false,\n\t\t\ticonClass: \"fa-edit\",\n\t\t\tdescription: \"DF_CHAT_LOG.GMCommandDescription\".localize()\n\t\t});\n\t\t(game as GameExt).chatCommands.registerCommand(DFAdventureLogProcessor.gmlogCommand);\n\t}\n\n\tprivate static _getTimestamp() {\n\t\tconst useTime = SETTINGS.get(DFAdventureLogProcessor.PREF_USE_TIME);\n\t\tif (game.modules.get('foundryvtt-simple-calendar')?.active && SETTINGS.get(DFAdventureLogProcessor.PREF_SIMPLE_CALENDAR)) {\n\t\t\tconst stamp = SimpleCalendar.api.formatDateTime(SimpleCalendar.api.timestampToDate(SimpleCalendar.api.timestamp()));\n\t\t\treturn useTime ? `${stamp.date} ${stamp.time}` : stamp.date;\n\t\t}\n\t\telse if (useTime)\n\t\t\treturn new Date().toLocaleString('sv').replace(',', '').replace(/ ([AP])/, '$1');\n\t\telse {\n\t\t\treturn new Date().toLocaleString('sv').replace(',', '').replace(/ ([AP])/, '$1').split(' ')[0];\n\t\t}\n\t}\n\n\tprivate static logConfig: DFAdventureLogConfig = null;\n\tstatic async commandProcessor(messageText: string, gmLog: boolean, isPlayerLog: boolean, preventPostToChat = false): Promise {\n\t\tmessageText = messageText.trim();\n\t\tconst tokens = messageText.split(' ');\n\n\t\tif (!SETTINGS.get(DFAdventureLogProcessor.PREF_ENABLE)) {\n\t\t\t(game as GameExt).chatCommands.deregisterCommand(DFAdventureLogProcessor.logCommand);\n\t\t\tui.notifications.warn('DF_CHAT_LOG.Error.Disabled'.localize());\n\t\t\treturn;\n\t\t}\n\n\t\t// If the user did not enter anything, send them a help message\n\t\tif (messageText.length == 0 || tokens.every(x => x.length == 0)) {\n\t\t\tsetTimeout(async () => {\n\t\t\t\tawait Dialog.prompt({\n\t\t\t\t\ttitle: 'DF_CHAT_LOG.HelpDialog_Title'.localize(),\n\t\t\t\t\tlabel: 'OK',\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\t\t\t\t\tcallback: () => { },\n\t\t\t\t\tcontent: await renderTemplate(`modules/df-chat-enhance/templates/lang/log-help.${'DF_CHAT_ENHANCE.LANG'.localize()}.hbs`, {\n\t\t\t\t\t\tisGM: game.user.isGM\n\t\t\t\t\t}),\n\t\t\t\t\toptions: { width: 800 }\n\t\t\t\t});\n\t\t\t}, 1);\n\t\t\treturn;\n\t\t}\n\n\t\tconst speaker = ChatMessage.getSpeaker({ user: game.user });\n\t\tconst messageData: DeepPartial = {\n\t\t\tflavor: '',\n\t\t\tuser: game.user.id,\n\t\t\tspeaker: speaker,\n\t\t\ttype: CONST.CHAT_MESSAGE_TYPES.OOC,\n\t\t\tcontent: '',\n\t\t};\n\t\tlet line: string;\n\t\tconst disableFormatting = SETTINGS.get(DFAdventureLogProcessor.PREF_DISABLE_FORMATTING);\n\t\tconst disableAuthor = isPlayerLog || SETTINGS.get(DFAdventureLogProcessor.PREF_DISABLE_AUTHOR);\n\t\tswitch (tokens[0].toLowerCase()) {\n\t\t\tcase 'config':\n\t\t\t\tif (!game.user.isGM) {\n\t\t\t\t\tui.notifications.warn('DF_CHAT_LOG.Error.ConfigGmOnly'.localize());\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\tif (DFAdventureLogProcessor.logConfig)\n\t\t\t\t\t\tDFAdventureLogProcessor.logConfig.bringToTop();\n\t\t\t\t\telse {\n\t\t\t\t\t\tDFAdventureLogProcessor.logConfig = new DFAdventureLogConfig({});\n\t\t\t\t\t\tDFAdventureLogProcessor.logConfig.render(true);\n\t\t\t\t\t}\n\t\t\t\t}, 1);\n\t\t\t\treturn;\n\t\t\tcase 'q':\n\t\t\tcase 'quote':\n\t\t\t\tmessageText = messageText.replace(tokens[0], '').trimStart();\n\t\t\t\tlet source: string;\n\t\t\t\t// If the token starts with a quote, but does not end with one\n\t\t\t\tif (tokens[1][0] === '\"' && tokens[1][tokens[1].length - 1] !== '\"') {\n\t\t\t\t\t// Extract the quoted Source\n\t\t\t\t\tlet index = -1;\n\t\t\t\t\tfor (let c = 1; c < messageText.length; c++) {\n\t\t\t\t\t\tif (messageText[c] === '\"') {\n\t\t\t\t\t\t\tindex = c;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (index < 0) {\n\t\t\t\t\t\tui.notifications.error('DF_CHAT_LOG.Error.MissingQuote'.localize().replace('{0}', tokens[1]));\n\t\t\t\t\t\tsetTimeout(() => $('#chat-message').val('/log q ' + messageText), 1);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsource = messageText.slice(0, index + 1);\n\t\t\t\t\tmessageText = messageText.slice(index + 1).trimStart();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tsource = tokens[1];\n\t\t\t\tmessageText = DFChatEditor.processMarkdown(messageText)[1].replace(source, '').trim();\n\t\t\t\t// Remove any double-quotes surrounding the source token\n\t\t\t\tsource = source.replace(/\"/gm, '');\n\t\t\t\tmessageData.flavor = `${game.user.name} quoted ${source}`;\n\t\t\t\tmessageData.content = `${messageText}`;\n\t\t\t\tif (messageText.length == 0) {\n\t\t\t\t\tui.notifications.error('DF_CHAT_LOG.Error.MissingMessage'.localize());\n\t\t\t\t\tsetTimeout(() => $('#chat-message').val(`/log q \"${source}\" ${messageText}`), 1);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tline = 'DF_CHAT_LOG.Log_Quote';\n\t\t\t\tif (disableFormatting) line += '_Bland';\n\t\t\t\tif (disableAuthor) line += '_NoAuth';\n\t\t\t\tline = line.localize();\n\t\t\t\tline = line.replace('{0}', this._getTimestamp());\n\t\t\t\tline = line.replace('{1}', game.user.name);\n\t\t\t\tline = line.replace('{2}', source);\n\t\t\t\tmessageText = line.replace('{3}', messageText);\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'event':\n\t\t\t\tmessageText = messageText.replace(tokens[0], '').trim();\n\t\t\t// fallthrough\n\t\t\tdefault:\n\t\t\t\tmessageText = DFChatEditor.processMarkdown(messageText)[1].trim();\n\t\t\t\tmessageData.flavor = 'Event Logged';\n\t\t\t\tmessageData.content = `${messageText}`;\n\t\t\t\tline = 'DF_CHAT_LOG.Log_Event';\n\t\t\t\tif (disableFormatting) line += '_Bland';\n\t\t\t\tif (disableAuthor) line += '_NoAuth';\n\t\t\t\tline = line.localize();\n\t\t\t\tline = line.replace('{0}', this._getTimestamp());\n\t\t\t\tline = line.replace('{1}', game.user.name);\n\t\t\t\tmessageText = line.replace('{2}', messageText);\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// fetch the log to submit to\n\t\tconst journalId = (isPlayerLog ? game.user.getFlag(SETTINGS.MOD_NAME, this.PREF_PLAYER_LOG_JOURNAL) as string :\n\t\t\tSETTINGS.get(gmLog ? DFAdventureLogConfig.PREF_JOURNAL_GM : DFAdventureLogConfig.PREF_JOURNAL))\n\t\t\t?.split('.');\n\t\tif (!journalId || !game.journal.has(journalId[0])) {\n\t\t\tif (isPlayerLog)\n\t\t\t\tui.notifications.error('DF_CHAT_LOG.Error.NoPlayerJournalSet'.localize());\n\t\t\telse if (game.user.isGM)\n\t\t\t\tui.notifications.error('DF_CHAT_LOG.Error.NoJournalSetGM'.localize(), { permanent: true });\n\t\t\telse\n\t\t\t\tui.notifications.warn('DF_CHAT_LOG.Error.NoJournalSet'.localize());\n\t\t\treturn;\n\t\t}\n\t\tconst journal = game.journal.get(journalId[0]).pages.get(journalId[1]);\n\t\tlet html = $(journal.text.content);\n\t\tconst messageHtml = $(messageText);\n\t\tlet section = html.find('section.df-adventure-log');\n\t\tif (section.length == 0) {\n\t\t\tawait DFAdventureLogConfig.initializeJournal(journalId.join('.'), false, gmLog, isPlayerLog);\n\t\t\thtml = $(journal.text.content);\n\t\t\tsection = html.find('section.df-adventure-log');\n\t\t}\n\t\tconst descending = SETTINGS.get(this.PREF_SORTDESC) as boolean;\n\t\tif (descending) section.prepend(messageHtml); else section.append(messageHtml);\n\t\tawait journal.update({ 'text.content': $('
    ').append(html).html() });\n\t\tconst rollType = game.settings.get(\"core\", \"rollMode\");\n\t\tif (game.user.isGM) {\n\t\t\tif (\n\t\t\t\t// If the roll type is anything but Public\n\t\t\t\trollType !== 'publicroll'\n\t\t\t\t// If logs are GM Only and the Whisper All settings is true\n\t\t\t\t|| (SETTINGS.get(DFAdventureLogProcessor.PREF_GMONLY) &&\n\t\t\t\t\tSETTINGS.get(DFAdventureLogProcessor.PREF_GMONLY_WHISPER))\n\t\t\t) {\n\t\t\t\t// Make the message a whisper\n\t\t\t\tmessageData.whisper = [game.user.id];\n\t\t\t}\n\t\t}\n\t\t// All GM and Player logs are whispered\n\t\tif (isPlayerLog || gmLog) {\n\t\t\tmessageData.whisper = [game.user.id];\n\t\t}\n\t\t// Post message to chat if Messages are enabled\n\t\tif (!preventPostToChat && SETTINGS.get(DFAdventureLogProcessor.PREF_MESSAGES))\n\t\t\tawait ChatMessage.create(messageData, {});\n\t}\n\n\tstatic async resortLog() {\n\t\tconst descending = SETTINGS.get(this.PREF_SORTDESC) as boolean;\n\t\tconst journalAll = (SETTINGS.get(DFAdventureLogConfig.PREF_JOURNAL) as string)?.split('.');\n\t\tconst journalGM = (SETTINGS.get(DFAdventureLogConfig.PREF_JOURNAL_GM) as string)?.split('.');\n\n\t\tconst journalSort = async (journal: JournalEntryPage) => {\n\t\t\tconst html = $(journal.text?.content);\n\t\t\tconst article = html.find('article.df-adventure-log');\n\t\t\tconst result = (article.find('p') as any).sort(function (a: HTMLElement, b: HTMLElement) {\n\t\t\t\treturn descending ?\n\t\t\t\t\t$(b).find('span.dfal-ts').text().localeCompare($(a).find('span.dfal-ts').text()) :\n\t\t\t\t\t$(a).find('span.dfal-ts').text().localeCompare($(b).find('span.dfal-ts').text());\n\n\t\t\t});\n\t\t\tarticle.html(result);\n\t\t\tawait journal.update({ 'text.content': $('
    ').append(html).html() });\n\t\t};\n\n\t\tif (game.journal.has(journalAll[0]))\n\t\t\tawait journalSort(game.journal.get(journalAll[0]).pages.get(journalAll[1]));\n\t\tif (game.journal.has(journalGM[0]))\n\t\t\tawait journalSort(game.journal.get(journalGM[0]).pages.get(journalGM[1]));\n\t}\n}","import libWrapperShared from \"../../../common/libWrapperShared\";\nimport SETTINGS from \"../../../common/Settings\";\nimport DFAdventureLogConfig from \"./DFAdventureLogConfig\";\nimport DFAdventureLogProcessor from \"./DFAdventureLogProcessor\";\n\ninterface AdventurLogApi {\n\tevent(message: string, postToChat?: boolean): Promise\n\tpevent(message: string, postToChat?: boolean): Promise\n\tgmevent(message: string, postToChat?: boolean): Promise\n\tquote(speaker: string, message: string, postToChat?: boolean): Promise\n\tpquote(speaker: string, message: string, postToChat?: boolean): Promise\n\tgmquote(speaker: string, message: string, postToChat?: boolean): Promise\n}\ndeclare global {\n\tconst AdventureLog: AdventurLogApi;\n}\n\nexport function init() {\n\tconst api: AdventurLogApi = {\n\t\tevent: (async function (message: string, postToChat = false) {\n\t\t\tDFAdventureLogProcessor.commandProcessor('event ' + message, false, false, !postToChat);\n\t\t}).bind(DFAdventureLogProcessor),\n\n\t\tpevent: (async function (message: string, postToChat = false) {\n\t\t\tDFAdventureLogProcessor.commandProcessor('event ' + message, false, true, !postToChat);\n\t\t}).bind(DFAdventureLogProcessor),\n\n\t\tgmevent: (async function (message: string, postToChat = false) {\n\t\t\tif (game.user.isGM)\n\t\t\t\tDFAdventureLogProcessor.commandProcessor('event ' + message, true, false, !postToChat);\n\t\t\telse ui.notifications.warn(\"DF_CHAT_LOG.Error.ApiLog_NotGm\".localize());\n\t\t}).bind(DFAdventureLogProcessor),\n\n\t\tquote: (async function (speaker: string, message: string, postToChat = false) {\n\t\t\tDFAdventureLogProcessor.commandProcessor(`quote \"${speaker}\" ${message}`, false, false, !postToChat);\n\t\t}).bind(DFAdventureLogProcessor),\n\n\t\tpquote: (async function (speaker: string, message: string, postToChat = false) {\n\t\t\tDFAdventureLogProcessor.commandProcessor(`quote \"${speaker}\" ${message}`, false, true, !postToChat);\n\t\t}).bind(DFAdventureLogProcessor),\n\n\t\tgmquote: (async function (speaker: string, message: string, postToChat = false) {\n\t\t\tif (game.user.isGM)\n\t\t\t\tDFAdventureLogProcessor.commandProcessor(`quote \"${speaker}\" ${message}`, true, false, !postToChat);\n\t\t\telse ui.notifications.warn(\"DF_CHAT_LOG.Error.ApiLog_NotGm\".localize());\n\t\t}).bind(DFAdventureLogProcessor)\n\t};\n\t// @ts-expect-error\n\twindow.AdventureLog = api;\n}\nexport function ready() {\n\tif (!game.modules.get('lib-wrapper')?.active) return;\n\tDFAdventureLogConfig.setupSettings();\n\tDFAdventureLogProcessor.setupSettings();\n\n\tHooks.on('renderUserConfig', (_app: UserConfig, html: JQuery, data: UserConfig.Data) => {\n\t\tconst journal = (data.user.getFlag(SETTINGS.MOD_NAME, DFAdventureLogProcessor.PREF_PLAYER_LOG_JOURNAL))?.split('.');\n\t\tconst template = Handlebars.compile(`\n
    \n\t\n\t
    \n\t\t\n\t
    \n
    \n
    \n\t\n\t
    \n\t\t\n\t
    \n
    \n`);\n\t\tconst journals = ui.journal.documents\n\t\t\t.filter(x => x.testUserPermission(data.user, CONST.DOCUMENT_PERMISSION_LEVELS.OBSERVER))\n\t\t\t.filter(x => x.pages.contents.some(y => y.type === 'text'));\n\t\tconst journalSelection = $(template({\n\t\t\tselected: journal ?? '',\n\t\t\tjournals: [{ id: '', name: '---', selected: !journal }].concat(journals.map(x => ({\n\t\t\t\tid: x.id,\n\t\t\t\tname: x.name,\n\t\t\t\tselected: x.id === journal[0]\n\t\t\t}))),\n\t\t\tpages: journal ? journals.find(x => x.id == journal[0]).pages.contents.filter(x => x.type === 'text').map(x => ({\n\t\t\t\tid: x.id,\n\t\t\t\tname: x.name,\n\t\t\t\tselected: x.id === journal[1]\n\t\t\t})) : []\n\t\t}, {\n\t\t\tallowProtoMethodsByDefault: true,\n\t\t\tallowProtoPropertiesByDefault: true\n\t\t}));\n\t\thtml.find('#characters').parent().before(journalSelection);\n\t\tjournalSelection.find('#dfce-player-log').on('change', event => {\n\t\t\tconst journalId = (event.currentTarget as HTMLSelectElement).value;\n\t\t\tconst pageElement = journalSelection.find('#dfce-player-log-page');\n\t\t\tpageElement.children().remove();\n\t\t\tif (!journalId || journalId.length === 0) return;\n\t\t\tfor (const page of game.journal.get(journalId).pages.contents.filter(x => x.type === 'text')) {\n\t\t\t\tpageElement.append(``);\n\t\t\t}\n\t\t});\n\t});\n\n\tlibWrapperShared.register('UserConfig.prototype._updateObject',\n\t\tasync function (this: UserConfig, wrapped: (...args: any) => any, event: any, formData: { \"player-log-page\": string }) {\n\t\t\tawait this.object.setFlag(SETTINGS.MOD_NAME, DFAdventureLogProcessor.PREF_PLAYER_LOG_JOURNAL, formData[\"player-log-page\"]);\n\t\t\treturn await wrapped(event, formData);\n\t\t});\n\n\tmigrateDataV9toV10();\n}\n\nasync function migrateDataV9toV10() {\n\tif (!game.user.isGM) return;\n\tlet journalId = SETTINGS.get(DFAdventureLogConfig.PREF_JOURNAL);\n\tif (checkJournal(journalId))\n\t\tawait SETTINGS.set(DFAdventureLogConfig.PREF_JOURNAL, await migrateJournalV9toV10(journalId));\n\tjournalId = SETTINGS.get(DFAdventureLogConfig.PREF_JOURNAL_GM);\n\tif (checkJournal(journalId))\n\t\tawait SETTINGS.set(DFAdventureLogConfig.PREF_JOURNAL_GM, await migrateJournalV9toV10(journalId));\n\n\tfor (const user of game.users) {\n\t\tjournalId = user.getFlag(SETTINGS.MOD_NAME, DFAdventureLogProcessor.PREF_PLAYER_LOG_JOURNAL);\n\t\tif (!checkJournal(journalId)) continue;\n\t\tjournalId = await migrateJournalV9toV10(journalId);\n\t\tif (!journalId)\n\t\t\tawait user.unsetFlag(SETTINGS.MOD_NAME, DFAdventureLogProcessor.PREF_PLAYER_LOG_JOURNAL);\n\t\telse\n\t\t\tawait user.setFlag(SETTINGS.MOD_NAME, DFAdventureLogProcessor.PREF_PLAYER_LOG_JOURNAL, journalId);\n\t}\n}\n\nfunction checkJournal(id: string) { return id && id.split('.').length < 2; }\n\nasync function migrateJournalV9toV10(id: string): Promise {\n\tconst journal = game.journal.get(id);\n\tif (!journal) return null;\n\tconst page = journal.pages.contents.find(x => x.type == 'text');\n\tif (!page) return null;\n\treturn journal.id + '.' + page.id;\n}\n","import { ChatMessageData } from \"@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs\";\nimport libWrapperShared from \"../../../common/libWrapperShared\";\nimport SETTINGS from \"../../../common/Settings\";\nimport DFChatArchiveManager from \"../archive/DFChatArchiveManager\";\n\n\nexport default class ChatMerge {\n\n\tprivate static readonly PREF_ENABLED = 'chat-merge-enabled';\n\tprivate static readonly PREF_SPLIT_SPEAKER = 'chat-merge-split-speaker';\n\tprivate static readonly PREF_EPOCH = 'chat-merge-epoch';\n\tprivate static readonly PREF_ALLOW_ROLLS = 'chat-merge-allowRolls';\n\tprivate static readonly PREF_SEPARATE = 'chat-merge-separateWithBorder';\n\tprivate static readonly PREF_HOVER = 'chat-merge-showhover';\n\tprivate static readonly PREF_SHOW_HEADER = 'chat-merge-showheader';\n\n\tprivate static get _enabled(): boolean { return SETTINGS.get(this.PREF_ENABLED); }\n\tprivate static get _epoch(): number { return SETTINGS.get(this.PREF_EPOCH); }\n\tprivate static get _allowRolls(): string { return SETTINGS.get(this.PREF_ALLOW_ROLLS); }\n\tprivate static get _separateWithBorder(): boolean { return SETTINGS.get(this.PREF_SEPARATE); }\n\tprivate static get _showHover(): boolean { return SETTINGS.get(this.PREF_HOVER); }\n\tprivate static get _showHeader(): boolean { return SETTINGS.get(this.PREF_SHOW_HEADER); }\n\n\tstatic init() {\n\t\tSETTINGS.register(this.PREF_ENABLED, {\n\t\t\tname: 'DF_CHAT_MERGE.EnableName',\n\t\t\thint: 'DF_CHAT_MERGE.EnableHint',\n\t\t\tconfig: true,\n\t\t\tscope: 'client',\n\t\t\tdefault: true,\n\t\t\ttype: Boolean,\n\t\t\tonChange: () => this._processAllMessage()\n\t\t});\n\t\tSETTINGS.register(this.PREF_SHOW_HEADER, {\n\t\t\tname: 'DF_CHAT_MERGE.ShowHeaderName',\n\t\t\thint: 'DF_CHAT_MERGE.ShowHeaderHint',\n\t\t\tconfig: true,\n\t\t\tscope: 'client',\n\t\t\tdefault: false,\n\t\t\ttype: Boolean,\n\t\t\tonChange: (newValue: boolean) => {\n\t\t\t\tconst style = (document.querySelector(':root')).style;\n\t\t\t\tstyle.setProperty('--dfce-cm-header', newValue ? '' : 'none');\n\t\t\t\tif (game.user.isGM) {\n\t\t\t\t\tstyle.setProperty('--dfce-cm-header-delete', newValue ? '' : '0');\n\t\t\t\t\tstyle.setProperty('--dfce-cm-header-delete-pad', newValue ? '' : '16px');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tSETTINGS.register(this.PREF_SPLIT_SPEAKER, {\n\t\t\tname: 'DF_CHAT_MERGE.SplitSpeakerName',\n\t\t\thint: 'DF_CHAT_MERGE.SplitSpeakerHint',\n\t\t\tconfig: true,\n\t\t\tscope: 'client',\n\t\t\tdefault: true,\n\t\t\ttype: Boolean,\n\t\t\tonChange: () => this._processAllMessage()\n\t\t});\n\t\tSETTINGS.register(this.PREF_ALLOW_ROLLS, {\n\t\t\tname: 'DF_CHAT_MERGE.AllowRollsName',\n\t\t\thint: 'DF_CHAT_MERGE.AllowRollsHint',\n\t\t\tconfig: true,\n\t\t\tscope: 'client',\n\t\t\tdefault: 'rolls',\n\t\t\ttype: String,\n\t\t\tchoices: {\n\t\t\t\tnone: 'DF_CHAT_MERGE.AllowRollsOptions.none'.localize(),\n\t\t\t\trolls: 'DF_CHAT_MERGE.AllowRollsOptions.rolls'.localize(),\n\t\t\t\tall: 'DF_CHAT_MERGE.AllowRollsOptions.all'.localize()\n\t\t\t},\n\t\t\tonChange: () => this._processAllMessage()\n\t\t});\n\t\tSETTINGS.register(this.PREF_SEPARATE, {\n\t\t\tname: 'DF_CHAT_MERGE.SeparateName',\n\t\t\thint: 'DF_CHAT_MERGE.SeparateHint',\n\t\t\tconfig: true,\n\t\t\tscope: 'client',\n\t\t\tdefault: false,\n\t\t\ttype: Boolean,\n\t\t\tonChange: (newValue: boolean) => {\n\t\t\t\tconst style = (document.querySelector(':root')).style;\n\t\t\t\tstyle.setProperty('--dfce-cm-separation', newValue ? '' : '0');\n\t\t\t}\n\t\t});\n\t\tSETTINGS.register(this.PREF_HOVER, {\n\t\t\tname: 'DF_CHAT_MERGE.HoverName',\n\t\t\thint: 'DF_CHAT_MERGE.HoverHint',\n\t\t\tconfig: true,\n\t\t\tscope: 'client',\n\t\t\tdefault: true,\n\t\t\ttype: Boolean,\n\t\t\tonChange: (newValue: boolean) => {\n\t\t\t\tconst style = (document.querySelector(':root')).style;\n\t\t\t\tnewValue ? style.removeProperty('--dfce-cm-hover-shadow') : style.setProperty('--dfce-cm-hover-shadow', '0px');\n\t\t\t}\n\t\t});\n\t\tSETTINGS.register(this.PREF_EPOCH, {\n\t\t\tname: 'DF_CHAT_MERGE.EpochName',\n\t\t\thint: 'DF_CHAT_MERGE.EpochHint',\n\t\t\tconfig: true,\n\t\t\tscope: 'client',\n\t\t\tdefault: 10,\n\t\t\ttype: Number,\n\t\t\trange: {\n\t\t\t\tmin: 1,\n\t\t\t\tmax: 60,\n\t\t\t\tstep: 1\n\t\t\t},\n\t\t\tonChange: () => this._processAllMessage()\n\t\t});\n\n\t\tlibWrapperShared.register('ChatLog.prototype.deleteMessage', this._deleteMessage.bind(this));\n\t\tHooks.on(\"renderChatMessage\", this._renderChatMessage);\n\t}\n\tstatic ready() {\n\t\tconst style = (document.querySelector(':root')).style;\n\t\tstyle.setProperty('--dfce-cm-separation', this._separateWithBorder ? '' : '0');\n\t\tthis._showHover ? style.removeProperty('--dfce-cm-hover-shadow') : style.setProperty('--dfce-cm-hover-shadow', '0px');\n\t\tstyle.setProperty('--dfce-cm-header', this._showHeader ? '' : 'none');\n\t\tif (game.user.isGM) {\n\t\t\tstyle.setProperty('--dfce-cm-header-delete', this._showHeader ? '' : '0');\n\t\t\tstyle.setProperty('--dfce-cm-header-delete-pad', this._showHeader ? '' : '16px');\n\t\t}\n\t\tthis._processAllMessage(ui.chat.element);\n\t\tHooks.on('renderChatLog', (_: any, html: JQuery) => this._processAllMessage(html));\n\t\tHooks.on('renderDFChatArchiveViewer', (_: any, html: JQuery) => this._processAllMessage(html));\n\t}\n\n\tprivate static _deleteMessage(wrapper: (arg0: any, arg1: any) => any, messageId: string, { deleteAll = false } = {}) {\n\t\t// Ignore the Delete All process. Everything is being obliterated, who cares about the styling\n\t\tif (!deleteAll && this._enabled) {\n\t\t\tconst element = document.querySelector(`li[data-message-id=\"${messageId}\"`);\n\t\t\t// If we were a TOP\n\t\t\tif (element?.classList?.contains('dfce-cm-top')) {\n\t\t\t\telement.classList.remove('dfce-cm-top');\n\t\t\t\t// If the next element was a middle, make it a top\n\t\t\t\tif (element.nextElementSibling.classList.contains('dfce-cm-middle')) {\n\t\t\t\t\telement.nextElementSibling.classList.remove('dfce-cm-middle');\n\t\t\t\t\telement.nextElementSibling.classList.add('dfce-cm-top');\n\t\t\t\t}\n\t\t\t\t// Otherwise, it was a bottom and should now become a normal message again\n\t\t\t\telse element.nextElementSibling.classList.remove('dfce-cm-bottom');\n\t\t\t}\n\t\t\t// If we were a BOTTOM\n\t\t\telse if (element?.classList?.contains('dfce-cm-bottom')) {\n\t\t\t\telement.classList.remove('dfce-cm-bottom');\n\t\t\t\t// If the previous element was a middle, make it a bottom\n\t\t\t\tif (element.previousElementSibling.classList.contains('dfce-cm-middle')) {\n\t\t\t\t\telement.previousElementSibling.classList.remove('dfce-cm-middle');\n\t\t\t\t\telement.previousElementSibling.classList.add('dfce-cm-bottom');\n\t\t\t\t}\n\t\t\t\t// Otherwise, it was a top and should now become a normal message again\n\t\t\t\telse element.previousElementSibling.classList.remove('dfce-cm-top');\n\t\t\t}\n\t\t\t// If we were a MIDDLE, let the above and below snug and they'll be fine\n\t\t\telse if (element?.classList?.contains('dfce-cm-middle'))\n\t\t\t\telement.classList.remove('dfce-cm-middle');\n\t\t}\n\t\treturn wrapper(messageId, { deleteAll });\n\t}\n\n\tprivate static _processAllMessage(element?: JQuery) {\n\t\telement = element ?? $(document.body);\n\t\t// Remove the old CSS class designations\n\t\telement.find('.dfce-cm-top').removeClass('dfce-cm-top');\n\t\telement.find('.dfce-cm-middle').removeClass('dfce-cm-middle');\n\t\telement.find('.dfce-cm-bottom').removeClass('dfce-cm-bottom');\n\t\t// If we are disabled, return\n\t\tif (!ChatMerge._enabled) return;\n\t\t// Collect all rendered chat messages\n\t\tconst messages = element.find('li.chat-message');\n\t\t// Return if there are no messages rendered\n\t\tif (messages.length === 0) return;\n\t\t// Make sure to set the hover colour for the first message since we skip it in the processor bellow.\n\t\tif (messages[0].hasAttribute('style')) {\n\t\t\tmessages[0].style.setProperty('--dfce-mc-border-color', messages[0].style.borderColor);\n\t\t}\n\t\t// Process each message after the first\n\t\tfor (let c = 1; c < messages.length; c++) {\n\t\t\t// Update styling of the chat messages\n\t\t\tthis._styleChatMessages(\n\t\t\t\tgame.messages.get(messages[c].getAttribute('data-message-id')),\n\t\t\t\tmessages[c],\n\t\t\t\tgame.messages.get(messages[c - 1].getAttribute('data-message-id')),\n\t\t\t\tmessages[c - 1]);\n\t\t}\n\t}\n\n\tprivate static _renderChatMessage(message: ChatMessageData, html: JQuery, _cmd: ChatMessageData) {\n\t\tif (!ChatMerge._enabled) return;\n\t\t// Find the most recent message in the chat log\n\t\tconst partnerElem = $(`li.chat-message`).last()[0];\n\t\t// If there is no message, return\n\t\tif (partnerElem === null || partnerElem === undefined) return;\n\t\t// get the ChatMessage document associated with the html\n\t\tconst partner = game.messages.get(partnerElem.getAttribute('data-message-id'));\n\t\tif (!message || !partner) return;\n\t\t// Update styling of the chat messages\n\t\tChatMerge._styleChatMessages(message, html[0], partner, partnerElem);\n\t}\n\n\tprivate static _inTimeFrame(current: number, previous: number): boolean {\n\t\treturn current > previous && (current - previous) < (this._epoch * 1000);\n\t}\n\n\tprivate static _isValidMessage(current: ChatMessageData, previous: ChatMessageData): boolean {\n\t\tconst rolls = this._allowRolls;\n\t\tconst splitSpeaker = SETTINGS.get(this.PREF_SPLIT_SPEAKER);\n\t\tlet userCompare = false;\n\n\t\tconst currData = current ?? current;\n\t\tconst prevData = previous ?? previous;\n\n\t\t// If either message is a Midi-QoL message, ignore it\n\t\tif ((currData?.flags && (currData.flags as Record)['midi-qol']) || (prevData?.flags && (prevData.flags as Record)['midi-qol']))\n\t\t\treturn false;\n\n\t\tif (splitSpeaker) {\n\t\t\t// this is a bit complex, basically we want to group by actors, but if you're not using an actor, group by user instead\n\t\t\tuserCompare = ( // If actors are equal and NOT null\n\t\t\t\tcurrData.speaker.actor === prevData.speaker.actor\n\t\t\t\t&& !!currData.speaker.actor\n\t\t\t) ||\n\t\t\t\t( // If BOTH actors are null and users are equal\n\t\t\t\t\t!currData.speaker.actor\n\t\t\t\t\t&& !prevData.speaker.actor\n\t\t\t\t\t&& currData.user === prevData.user\n\t\t\t\t);\n\t\t} else {\n\t\t\t// If we are not splitting by speaker, just do the simple option of comparing the users\n\t\t\tuserCompare = currData.user === prevData.user;\n\t\t}\n\t\treturn userCompare\n\t\t\t&& this._inTimeFrame(currData.timestamp, prevData.timestamp)\n\t\t\t// Check for merging with roll types\n\t\t\t&& (rolls === 'all'\n\t\t\t\t|| (rolls === 'rolls' && current.isRoll === previous.isRoll)\n\t\t\t\t|| (rolls === 'none' && !current.isRoll && !previous.isRoll));\n\t}\n\n\tprivate static _styleChatMessages(curr: ChatMessageData, currElem: HTMLElement, prev: ChatMessageData, prevElem: HTMLElement) {\n\t\tif (currElem.hasAttribute('style')) {\n\t\t\tcurrElem.style.setProperty('--dfce-mc-border-color', currElem.style.borderColor);\n\t\t}\n\t\t// If we are running in a Chat Archive\n\t\tif (curr === undefined && prev === undefined) {\n\t\t\tconst logId = parseInt(/df-chat-log-(\\d+)/.exec(currElem.parentElement.parentElement.id)[1]);\n\t\t\tif (isNaN(logId)) return;\n\t\t\tconst chatLog = DFChatArchiveManager.chatViewers.get(logId);\n\t\t\tcurr = chatLog.messages.find(x =>\n\t\t\t\t(x.id ?? x._id) == currElem.dataset.messageId);\n\t\t\tprev = chatLog.messages.find(x =>\n\t\t\t\t(x.id ?? x._id) == prevElem.dataset.messageId);\n\t\t}\n\t\tif (!ChatMerge._isValidMessage(curr, prev)) return;\n\t\tif (prevElem.classList.contains('dfce-cm-bottom')) {\n\t\t\tprevElem.classList.remove('dfce-cm-bottom');\n\t\t\tprevElem.classList.add('dfce-cm-middle');\n\t\t} else prevElem.classList.add('dfce-cm-top');\n\t\tcurrElem.classList.add('dfce-cm-bottom');\n\t}\n}","import libWrapperShared from \"../../../common/libWrapperShared\";\nimport SETTINGS from \"../../../common/Settings\";\nimport UTIL from '../Util';\n\nexport default class PlayerColor {\n\tstatic readonly PREF_TINT_BG = 'PlayerColor_TintBackground';\n\tstatic readonly PREF_BORDER_STYLE = 'PlayerColor.BorderStyle';\n\tstatic readonly FLAG_CHAT_COLOR = 'chat-color';\n\n\tstatic init() {\n\t\tSETTINGS.register(PlayerColor.PREF_TINT_BG, {\n\t\t\tconfig: true,\n\t\t\tname: 'DF_CHAT_PLAYER_COLOR.SettingTintBackgroundName',\n\t\t\thint: 'DF_CHAT_PLAYER_COLOR.SettingTintBackgroundHint',\n\t\t\tscope: 'world',\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t\tonChange: UTIL.reloadChatLog\n\t\t});\n\t\tSETTINGS.register(PlayerColor.PREF_BORDER_STYLE, {\n\t\t\tname: 'DF_CHAT_PLAYER_COLOR.SettingBorderStyleName',\n\t\t\thint: 'DF_CHAT_PLAYER_COLOR.SettingBorderStyleHint',\n\t\t\tconfig: true,\n\t\t\ttype: String,\n\t\t\tchoices: {\n\t\t\t\tall: 'DF_CHAT_PLAYER_COLOR.BorderStyle.all',\n\t\t\t\tmine: 'DF_CHAT_PLAYER_COLOR.BorderStyle.mine',\n\t\t\t\tnone: 'DF_CHAT_PLAYER_COLOR.BorderStyle.none'\n\t\t\t},\n\t\t\tdefault: 'all',\n\t\t\tscope: 'client',\n\t\t\tonChange: UTIL.reloadChatLog\n\t\t});\n\n\t\tHooks.on('renderUserConfig', (app: UserConfig, html: JQuery, data: UserConfig.Data) => {\n\t\t\tconst color = data.user.getFlag(SETTINGS.MOD_NAME, PlayerColor.FLAG_CHAT_COLOR) ?? '';\n\t\t\thtml.find('input[name=\"color\"]').parent().parent().after(`\n
    \n\t\n\t
    \n\t\t\n\t\t\n\t
    \n
    `);\n\t\t\tconst chatField = html.find('#chat-color');\n\t\t\tconst chatPicker = html.find('[data-edit=\"chat-color\"]');\n\t\t\t// Make sure to update the color selector if a manual entry occurs\n\t\t\tchatField.on('change', () => chatPicker.val(chatField.val()));\n\t\t\t// Resize the window to encompass the new fields\n\t\t\tapp.element[0].style.height = '';\n\t\t\tapp.setPosition({});\n\t\t});\n\n\t\tlibWrapperShared.register('UserConfig.prototype._updateObject',\n\t\t\tasync function (this: UserConfig, wrapped: (arg0: any, arg1: any) => any, event: any, formData: { \"chat-color\": string }): Promise {\n\t\t\t\tawait this.object.setFlag(SETTINGS.MOD_NAME, PlayerColor.FLAG_CHAT_COLOR, formData[\"chat-color\"]);\n\t\t\t\tawait wrapped(event, formData);\n\t\t\t});\n\n\t\tlibWrapper.register(SETTINGS.MOD_NAME, 'ChatMessage.prototype.getHTML', async function (this: ChatMessage, wrapper: (...arg: any) => Promise>, ...args: any) {\n\t\t\tconst html = await wrapper(...args);\n\t\t\t// If the message has no user bound to it, then it is likely some kind of other message being created by a module. Just return immediately.\n\t\t\tif (!this.user) return html;\n\t\t\tlet chatColor = (this.user.getFlag(SETTINGS.MOD_NAME, PlayerColor.FLAG_CHAT_COLOR))?.trim();\n\t\t\t// If it is a valid color\n\t\t\tif (!chatColor || !/#[a-fA-F0-9]{6,8}/.test(chatColor))\n\t\t\t\tchatColor = this.user.color;\n\n\t\t\t// Set the border colour to its default\n\t\t\tlet borderColour = '#6f6c66';\n\t\t\tswitch (SETTINGS.get(PlayerColor.PREF_BORDER_STYLE)) {\n\t\t\t\tcase 'none': break;\n\t\t\t\tcase 'mine':\n\t\t\t\t\tif (game.userId !== this.data.user) break;\n\t\t\t\t// fallthrough\n\t\t\t\tcase 'all':\n\t\t\t\t\tborderColour = chatColor;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\thtml[0].style.borderColor = borderColour;\n\n\t\t\t// Set the hover border colour to what ever the border colour is\n\t\t\thtml[0].style.setProperty('--dfce-mc-border-color', borderColour);\n\t\t\tif (SETTINGS.get(PlayerColor.PREF_TINT_BG)) {\n\t\t\t\thtml[0].style.backgroundColor = chatColor;\n\t\t\t\thtml[0].style.backgroundImage = 'url(../ui/parchment.jpg)';\n\t\t\t\thtml[0].style.backgroundRepeat = 'repeat';\n\t\t\t\thtml[0].style.backgroundBlendMode = 'screen';\n\t\t\t}\n\t\t\treturn html;\n\t\t}, 'WRAPPER');\n\t}\n}\n","import SETTINGS from \"../../../common/Settings\";\nimport UTIL from \"../Util\";\n\n\nconst ICONS_FOR_KNOWN_ROLL_TYPES: {\n\t[key: string]: string;\n\tpublicroll: string;\n\tgmroll: string;\n\tblindroll: string;\n\tselfroll: string;\n} = {\n\tpublicroll: 'fas fa-dice-d20',\n\tgmroll: 'fas fa-user-secret',\n\tblindroll: 'fas fa-user-ninja',\n\tselfroll: 'fas fa-ghost'\n};\n\ninterface ChatLogData {\n\tuser: User,\n\trollMode: string,\n\trollModes: any,\n\tisStream: boolean\n}\n\nexport default class ChatRollPrivacy {\n\tstatic setup() {\n\t\tgame.keybindings.register(SETTINGS.MOD_NAME, \"roll-mode.publicroll\", {\n\t\t\tname: 'Public Roll',\n\t\t\teditable: [{ key: 'KeyQ', modifiers: [KeyboardManager.MODIFIER_KEYS.ALT] }],\n\t\t\tnamespace: 'Roll Type Shortcuts',\n\t\t\tonDown: () => {\n\t\t\t\t$('#dfcp-rt-buttons > button[data-id=\"publicroll\"]').trigger('click');\n\t\t\t}\n\t\t});\n\t\tgame.keybindings.register(SETTINGS.MOD_NAME, \"roll-mode.gmroll\", {\n\t\t\tname: 'Private GM Roll',\n\t\t\teditable: [{ key: 'KeyW', modifiers: [KeyboardManager.MODIFIER_KEYS.ALT] }],\n\t\t\tnamespace: 'Roll Type Shortcuts',\n\t\t\tonDown: () => {\n\t\t\t\t$('#dfcp-rt-buttons > button[data-id=\"gmroll\"]').trigger('click');\n\t\t\t}\n\t\t});\n\t\tgame.keybindings.register(SETTINGS.MOD_NAME, \"roll-mode.blindroll\", {\n\t\t\tname: 'Blind GM Roll',\n\t\t\teditable: [{ key: 'KeyE', modifiers: [KeyboardManager.MODIFIER_KEYS.ALT] }],\n\t\t\tnamespace: 'Roll Type Shortcuts',\n\t\t\tonDown: () => {\n\t\t\t\t$('#dfcp-rt-buttons > button[data-id=\"blindroll\"]').trigger('click');\n\t\t\t}\n\t\t});\n\t\tgame.keybindings.register(SETTINGS.MOD_NAME, \"roll-mode.selfroll\", {\n\t\t\tname: 'Self Roll',\n\t\t\teditable: [{ key: 'KeyR', modifiers: [KeyboardManager.MODIFIER_KEYS.ALT] }],\n\t\t\tnamespace: 'Roll Type Shortcuts',\n\t\t\tonDown: () => {\n\t\t\t\t$('#dfcp-rt-buttons > button[data-id=\"selfroll\"]').trigger('click');\n\t\t\t}\n\t\t});\n\t}\n\n\tstatic init() {\n\t\tSETTINGS.register('enabled', {\n\t\t\tname: 'DF_CHAT_PRIVACY.Settings_EnableTitle',\n\t\t\thint: 'DF_CHAT_PRIVACY.Settings_EnableHint',\n\t\t\tscope: 'client',\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t\tconfig: true,\n\t\t\tonChange: UTIL.requestReload\n\t\t});\n\t\tSETTINGS.register('replace-buttons', {\n\t\t\tname: 'DF_CHAT_PRIVACY.Settings_ReplaceButtonsTitle',\n\t\t\thint: 'DF_CHAT_PRIVACY.Settings_ReplaceButtonsHint',\n\t\t\tscope: 'client',\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t\tconfig: true,\n\t\t\tonChange: UTIL.requestReload\n\t\t});\n\t\n\t\tif (SETTINGS.get('enabled') === false)\n\t\t\treturn;\n\t\n\t\tHooks.on('renderChatLog', this._handleChatLogRendering);\n\t}\n\n\n\tprivate static calcColour(current: number, count: number): string {\n\t\treturn `rgb(${(current / count) * 255},${(1 - (current / count)) * 255},0)`;\n\t}\n\n\tprivate static async _handleChatLogRendering(chat: ChatLog, html: JQuery, data: ChatLogData) {\n\t\tconst modes = Object.keys(data.rollModes);\n\t\tconst buttons: any[] = [];\n\t\tconst iconKeys = Object.keys(ICONS_FOR_KNOWN_ROLL_TYPES);\n\t\tfor (let c = 0; c < modes.length; c++) {\n\t\t\tconst rt = modes[c];\n\t\t\tif (!(rt in ICONS_FOR_KNOWN_ROLL_TYPES)) {\n\t\t\t\tconsole.warn(Error(`Unknown roll type '${rt}'`));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbuttons.push({\n\t\t\t\trt: rt,\n\t\t\t\tname: data.rollModes[rt],\n\t\t\t\tactive: data.rollMode === rt,\n\t\t\t\ticon: ICONS_FOR_KNOWN_ROLL_TYPES[rt],\n\t\t\t\tcolour: ChatRollPrivacy.calcColour(iconKeys.findIndex(x => x == rt), iconKeys.length)\n\t\t\t});\n\t\t}\n\t\tconst buttonHtml = $(await renderTemplate('modules/df-chat-enhance/templates/privacy-button.hbs', { buttons }));\n\t\tbuttonHtml.find('button').on('click', function () {\n\t\t\tconst rollType = $(this).attr('data-id');\n\t\t\tgame.settings.set(\"core\", \"rollMode\", rollType);\n\t\t\tbuttonHtml.find('button.active').removeClass('active');\n\t\t\t$(this).addClass('active');\n\t\t});\n\t\thtml.find('select[name=rollMode]').after(buttonHtml);\n\t\thtml.find('select[name=rollMode]').remove();\n\t\n\t\tif (!SETTINGS.get('replace-buttons'))\n\t\t\treturn;\n\t\n\t\t// Adjust the button container to remove the extra margin since those buttons are now moving in.\n\t\tbuttonHtml.attr('style', 'margin:0 0 0 0.5em');\n\t\n\t\t// Convert the old tag elements to `);\n\t\t\tbutton.on('click', click);\n\t\t\t// Add a small margin between the first button and the RollTypes\n\t\t\tif (first) {\n\t\t\t\tbutton.attr('style', 'margin-left:0.5em');\n\t\t\t\tfirst = false;\n\t\t\t}\n\t\t\tbuttonHtml.append(button);\n\t\t});\n\t\n\t\thtml.find('#chat-controls div.control-buttons').remove();\n\t}\n}\n","import SETTINGS from \"../../../common/Settings\";\nimport UTIL from \"../Util\";\n\nexport default class ChatHistoryOptimizer {\n\n\tprivate static readonly PREF_ENABLED = 'ChatHistoryOptimizer.Enabled';\n\tprivate static readonly PREF_HISTORY_SIZE = 'ChatHistoryOptimizer.HistorySize';\n\n\tstatic init() {\n\n\t\tSETTINGS.register(this.PREF_ENABLED, {\n\t\t\tname: 'DF_CHAT_SCROLL.HistoryFixEnabledName',\n\t\t\thint: 'DF_CHAT_SCROLL.HistoryFixEnabledHint',\n\t\t\tconfig: true,\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t\tscope: 'world',\n\t\t\tonChange: UTIL.requestReload\n\t\t});\n\t\tSETTINGS.register(this.PREF_HISTORY_SIZE, {\n\t\t\tname: 'DF_CHAT_SCROLL.HistorySizeName',\n\t\t\thint: 'DF_CHAT_SCROLL.HistorySizeHint',\n\t\t\tconfig: true,\n\t\t\ttype: Number,\n\t\t\tdefault: CONFIG.ChatMessage.batchSize,\n\t\t\trange: {\n\t\t\t\tmin: CONFIG.ChatMessage.batchSize,\n\t\t\t\tmax: CONFIG.ChatMessage.batchSize * 5,\n\t\t\t\tstep: CONFIG.ChatMessage.batchSize\n\t\t\t},\n\t\t\tscope: 'world',\n\t\t\tonChange: () => $('#chat-log').trigger('scroll')\n\t\t});\n\n\t\tif (!SETTINGS.get(this.PREF_ENABLED)) return;\n\n\t\tlibWrapper.register(SETTINGS.MOD_NAME, 'ChatLog.prototype._onScrollLog', this._ChatLog_onScrollLog, 'MIXED');\n\n\t\t/**\n\t\t// This is used for DEBUG purposes only\n\t\t// Displays the number of messages being rendered in the Chat Log\n\t\tHooks.on('renderChatLog', (_: any, html: JQuery) => {\n\t\t\thtml.find('#scrollToBottom').after('
    ');\n\t\t});\n\t\tthis._displayMessageCounts(0);\n\t\t/**/\n\t}\n\n\tprivate static _ChatLog_onScrollLog(this: ChatLog, wrapped: (event: any) => Promise, event: any): Promise {\n\t\tif (!this.rendered) return Promise.resolve();\n\t\tconst maxMessageCount = SETTINGS.get(ChatHistoryOptimizer.PREF_HISTORY_SIZE);\n\t\t// Ignore all scroll events when there are not enough messages to even batch\n\t\tif (this.collection.size <= CONFIG.ChatMessage.batchSize) return wrapped(event);\n\t\tconst log = event.target as HTMLElement;\n\t\tconst messages = $(log).find('li.chat-message');\n\n\t\t// Grab the top most message based on current scroll position\n\t\tlet topMessageIndex = -1;\n\n\t\t//! NOTICE! The message list is inverted, it is sorted OLDEST to NEWEST,\n\t\t//! so message[0] is at the very top of the chat log, and message[n] is\n\t\t//! at the very bottom of the chat log.\n\n\t\t// We try to start as close to the actual top message as we can, then traverse either up or down from there\n\t\tconst pct = log.scrollTop / log.scrollHeight;\n\t\tconst chatViewTop = log.scrollTop + messages[0].offsetTop;\n\t\tlet c = Math.trunc(messages.length * pct);\n\t\t// If the estimate is too high up the log, we traverse down\n\t\tif (messages[c].offsetTop < chatViewTop) {\n\t\t\tfor (; c < messages.length; c++) {\n\t\t\t\tif (\n\t\t\t\t\t// If this message is at/on the scroll top\n\t\t\t\t\t(messages[c].offsetTop <= chatViewTop && messages[c].offsetTop + messages[c].offsetHeight >= chatViewTop) ||\n\t\t\t\t\t// If the previous message is above the view, and this one is in the view\n\t\t\t\t\t(c - 1 >= 0 && messages[c].offsetTop >= chatViewTop && messages[c - 1].offsetTop + messages[c - 1].offsetHeight)\n\t\t\t\t) {\n\t\t\t\t\ttopMessageIndex = c;\n\t\t\t\t\t// We should break as soon as we find it\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Otherwise we traverse up the chat log\n\t\telse {\n\t\t\tfor (; c >= 0; c--) {\n\t\t\t\tif (\n\t\t\t\t\t// If this message is at/on the scroll top\n\t\t\t\t\t(messages[c].offsetTop <= chatViewTop && messages[c].offsetTop + messages[c].offsetHeight >= chatViewTop) ||\n\t\t\t\t\t// If the previous message is above the view, and this one is in the view\n\t\t\t\t\t(c - 1 >= 0 && messages[c].offsetTop >= chatViewTop && messages[c - 1].offsetTop + messages[c - 1].offsetHeight)\n\t\t\t\t) {\n\t\t\t\t\ttopMessageIndex = c;\n\t\t\t\t\t// We should break as soon as we find it\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// If we found nothing\n\t\tif (topMessageIndex < 0) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\t// Check if we should load more messages\n\t\tif (topMessageIndex < (CONFIG.ChatMessage.batchSize / 4) && messages.length < this.collection.size) {\n\t\t\t// Add Messages\n\t\t\treturn this._renderBatch(this.element, CONFIG.ChatMessage.batchSize);\n\t\t}\n\t\t// If we don't want to load more, check if we should delete some\n\t\telse if (topMessageIndex > maxMessageCount) {\n\t\t\tconst count = topMessageIndex - (maxMessageCount - 1);\n\t\t\t// Set the Last ID for batch rendering\n\t\t\tthis._lastId = messages[count].dataset.messageId;\n\t\t\t// Remove the messages\n\t\t\tmessages.slice(0, count).remove();\n\t\t}\n\t\treturn Promise.resolve();\n\t}\n\n\tprivate static _lastFrame = 0;\n\tprivate static _displayMessageCounts(time: number) {\n\t\tif (ChatHistoryOptimizer._lastFrame + 500 < time) {\n\t\t\tChatHistoryOptimizer._lastFrame = time;\n\t\t\t$('.dfce-chat-count').each(function (_, element: HTMLElement) {\n\t\t\t\tconst msgCount = $(element).siblings('#chat-log').find('li.chat-message').length;\n\t\t\t\telement.innerText = `${msgCount} / ${ui.chat.collection.size}`;\n\t\t\t});\n\t\t}\n\t\trequestAnimationFrame(ChatHistoryOptimizer._displayMessageCounts);\n\t}\n}","import { ChatMessageData } from \"@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs\";\nimport libWrapperShared from \"../../../common/libWrapperShared\";\nimport SETTINGS from \"../../../common/Settings\";\nimport ChatHistoryOptimizer from \"./ChatHistoryOptimizer\";\n\ndeclare class ChatLogExt extends ChatLog {\n\t_scrollToBottomButton: JQuery;\n}\n\nexport default class ScrollManage {\n\tprivate static readonly PREF_ENABLED = 'scroll-manage-enabled';\n\tprivate static readonly PREF_SCROLL_IF_YOU = 'scroll-manage-scroll-if-you';\n\tprivate static readonly ScrollThreshold = 50;\n\t// private static _scrollToBottomButton: JQuery;\n\tprivate static _deleteMessageRegistrationID: number | null = null;\n\n\n\tstatic get enabled(): boolean { return SETTINGS.get(this.PREF_ENABLED); }\n\tstatic get scrollToBottomIfYouSendMessage(): boolean { return SETTINGS.get(this.PREF_SCROLL_IF_YOU); }\n\n\tstatic init() {\n\t\tHooks.on('renderChatLog', this._renderChatLog.bind(this));\n\n\t\tSETTINGS.register(this.PREF_ENABLED, {\n\t\t\tname: 'DF_CHAT_SCROLL.EnableName',\n\t\t\thint: 'DF_CHAT_SCROLL.EnableHint',\n\t\t\tscope: 'world',\n\t\t\tconfig: true,\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t\tonChange: (newValue) => {\n\t\t\t\tif (newValue) this.register();\n\t\t\t\telse this.unregister();\n\t\t\t}\n\t\t});\n\t\tSETTINGS.register(this.PREF_SCROLL_IF_YOU, {\n\t\t\tname: 'DF_CHAT_SCROLL.ScrollIfYouName',\n\t\t\thint: 'DF_CHAT_SCROLL.ScrollIfYouHint',\n\t\t\tscope: 'world',\n\t\t\tconfig: true,\n\t\t\ttype: Boolean,\n\t\t\tdefault: true\n\t\t});\n\n\t\tChatHistoryOptimizer.init();\n\t}\n\n\tstatic ready() {\n\t\tif (this.enabled)\n\t\t\tthis.register();\n\t}\n\n\tprivate static register() {\n\t\tlibWrapper.register(SETTINGS.MOD_NAME, 'ChatLog.prototype.postOne', this._ChatLog_postOne, 'OVERRIDE');\n\t\tlibWrapper.register(SETTINGS.MOD_NAME, 'ChatLog.prototype.scrollBottom', this._ChatLog_scrollBottom, 'OVERRIDE');\n\t\tthis._deleteMessageRegistrationID = libWrapperShared.register('ChatLog.prototype.deleteMessage', this._ChatLog_deleteMessage);\n\t}\n\tprivate static unregister() {\n\t\tlibWrapper.unregister(SETTINGS.MOD_NAME, 'ChatLog.prototype.postOne', false);\n\t\tlibWrapper.unregister(SETTINGS.MOD_NAME, 'ChatLog.prototype.scrollBottom', false);\n\t\tlibWrapperShared.unregister('ChatLog.prototype.deleteMessage', this._deleteMessageRegistrationID);\n\t}\n\n\tprivate static _renderChatLog(app: ChatLogExt, html: JQuery) {\n\t\tapp._scrollToBottomButton = $(`
    \n\t${'DF_CHAT_SCROLL.NewMessage'.localize()} ${'DF_CHAT_SCROLL.ScrollButton'.localize()}\n
    `);\n\t\tapp._scrollToBottomButton.on('click', () => {\n\t\t\tconst el = app.element;\n\t\t\tconst log = el.length ? el[0].querySelector(\"#chat-log\") : null;\n\t\t\tif (log) {\n\t\t\t\tlog.scrollTo({ behavior: \"smooth\", top: log.scrollHeight });\n\t\t\t}\n\t\t});\n\t\thtml.find('div#chat-controls').before(app._scrollToBottomButton);\n\n\t\thtml.find('ol#chat-log').on('scroll', (event) => {\n\t\t\tif (!app._scrollToBottomButton) return;\n\t\t\tconst element = event.currentTarget;\n\t\t\t// Ignore events when the scroll height is too small to matter\n\t\t\tif (element.clientHeight > element.scrollHeight - this.ScrollThreshold) return;\n\t\t\tif (element.scrollTop < (element.scrollHeight - element.clientHeight) - this.ScrollThreshold)\n\t\t\t\tapp._scrollToBottomButton.show();\n\t\t\telse {\n\t\t\t\tapp._scrollToBottomButton.hide();\n\t\t\t\tapp._scrollToBottomButton.removeClass('new');\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate static _ChatLog_scrollBottom(this: ChatLogExt) {\n\t\tconst el = this.element;\n\t\tconst log = el.length ? el[0].querySelector(\"#chat-log\") : null;\n\t\t// If we are already at the bottom, perform the scroll\n\t\tif (this._scrollToBottomButton.is(':hidden'))\n\t\t\tsetTimeout(() => log.scrollTo({ behavior: 'smooth', top: log.scrollHeight }), 100);\n\t\t// Otherwise do not scroll, but do trigger a scroll event.\n\t\t// Some modules might use this function after manually adding message content to the ChatLog\n\t\telse $('#chat #chat-log').trigger('scroll');\n\t}\n\n\tprivate static async _ChatLog_postOne(this: ChatLogExt, message: ChatMessageData & ChatMessage, notify = false) {\n\t\tif (!message.visible) return;\n\n\t\t// Track internal flags\n\t\tif (!this._lastId) this._lastId = message.id; // Ensure that new messages don't result in batched scrolling\n\t\tif ((message.whisper || []).includes(game.user.id) && !message.isRoll) {\n\t\t\tthis._lastWhisper = message;\n\t\t}\n\n\t\t// Render the message to the log\n\t\tconst element = this.element.find(\"#chat-log\");\n\t\tconst atBottom = element[0].scrollTop >= ((element[0].scrollHeight - element[0].clientHeight) - ScrollManage.ScrollThreshold);\n\t\tconst html = await (message).getHTML();\n\t\telement.append(html);\n\t\tif (atBottom || (ScrollManage.scrollToBottomIfYouSendMessage && message.isAuthor))\n\t\t\telement[0].scrollTo({ top: element[0].scrollHeight, behavior: 'smooth' });\n\t\t// this.scrollBottom();\n\t\telse {\n\t\t\tthis._scrollToBottomButton.addClass('new');\n\t\t}\n\n\t\t// Post notification\n\t\tif (notify) this.notify(message);\n\n\t\t// Update popout tab\n\t\tif (this._popout) await (this._popout).postOne(message, false);\n\t\tif (this.popOut) this.setPosition();\n\t}\n\n\tprivate static _ChatLog_deleteMessage(this: ChatLogExt, wrapped: (...args: any) => unknown, messageId: string, { deleteAll = false }: { deleteAll?: boolean } = {}): unknown {\n\t\tconst result = wrapped(messageId, { deleteAll });\n\t\t// Ignore singular message deletions, only react to a Delete All event.\n\t\t// Also ignore the deletion if the scroll-to-bottom element is already hidden\n\t\tif (!deleteAll || this._scrollToBottomButton.is(':hidden')) return result;\n\t\tthis._scrollToBottomButton.hide();\n\t\tthis._scrollToBottomButton.removeClass('new');\n\t\treturn result;\n\t}\n}","import SETTINGS from \"../../../common/Settings\";\n\nexport default class SendButton {\n\tprivate static readonly PREF_ENABLED = 'SendButton.Enabled';\n\tstatic init() {\n\t\tSETTINGS.register(this.PREF_ENABLED, {\n\t\t\tname: 'DF_CHAT_SEND_BUTTON.EnabledName'.localize(),\n\t\t\thint: 'DF_CHAT_SEND_BUTTON.EnabledHint'.localize(),\n\t\t\tconfig: true,\n\t\t\tscope: 'client',\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t\tonChange: (isActive) => {\n\t\t\t\tif (isActive) {\n\t\t\t\t\tthis._renderChatLog(ui.chat, $('#sidebar #chat'));\n\t\t\t\t\tconst popout = $('#chat-popout');\n\t\t\t\t\tif (popout.length > 0)\n\t\t\t\t\t\tthis._renderChatLog(ui.chat, popout);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t$('.dfce-send-btn').remove();\n\t\t\t\t\t$('#chat-message').each((_a, textarea) => {\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t$(textarea).off('input', textarea.dfce_handler);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tHooks.on('renderChatLog', this._renderChatLog.bind(this));\n\t}\n\n\tprivate static _renderChatLog(app: ChatLog, html: JQuery) {\n\t\tif (!SETTINGS.get(this.PREF_ENABLED)) return;\n\t\tconst sendButton = $('');\n\t\tsendButton.attr('title', 'DF_CHAT_SEND_BUTTON.ButtonTitle'.localize());\n\t\thtml.find('#chat-form').append(sendButton);\n\n\t\tconst textarea = html.find('#chat-message');\n\t\tsendButton.prop('disabled', textarea[0].textLength <= 0 || textarea[0].value.trim().length <= 0);\n\n\t\tsendButton.on('click', async event => {\n\t\t\tevent.preventDefault();\n\t\t\t// @ts-expect-error\n\t\t\tawait ui.chat._onChatKeyDown({\n\t\t\t\tcode: 'Enter',\n\t\t\t\tcurrentTarget: textarea[0],\n\t\t\t\toriginalEvent: {\n\t\t\t\t\tisComposing: false\n\t\t\t\t},\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\t\t\t\tpreventDefault: () => { }\n\t\t\t});\n\t\t\tsetTimeout(() => textarea.trigger('input'), 100);\n\t\t});\n\n\t\tconst handler = (event: JQuery.TriggeredEvent) => {\n\t\t\tconst element = (event.currentTarget as HTMLTextAreaElement);\n\t\t\tsendButton.prop('disabled', element.textLength <= 0 || element.value.trim().length <= 0);\n\t\t};\n\t\t// @ts-expect-error\n\t\ttextarea[0].dfce_handler = handler;\n\t\ttextarea.on('input', handler);\n\t\ttextarea.on('change', handler);\n\t}\n}","import { ChatMessageData } from \"@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs\";\nimport SETTINGS from \"../../../common/Settings\";\n\n\nconst TEMPLATE = \"$0: $1 (+$2 more)\";\nconst LENGTH_ADJUST = ' '.length - 1;\n\n\nexport default class WhisperTruncation {\n\n\tprivate static readonly PREF_ENABLED = 'whisper-trunc_enabled';\n\tprivate static readonly PREF_CHAR_LIMIT = 'whisper-trunc_char-limit';\n\n\tstatic init() {\n\t\tHooks.on('renderChatMessage', this._messageRender.bind(this));\n\t\tSETTINGS.register(this.PREF_ENABLED, {\n\t\t\tname: 'DF_CHAT_WHISPER_TRUNC.SettingEnabledName',\n\t\t\thint: 'DF_CHAT_WHISPER_TRUNC.SettingEnabledHint',\n\t\t\tconfig: true,\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t\tscope: 'world',\n\t\t\tonChange: async () => {\n\t\t\t\t(ui.chat)._state = 0;\n\t\t\t\t(ui.chat)._lastId = null;\n\t\t\t\tawait ui.chat.render(true);\n\t\t\t}\n\t\t});\n\t\tSETTINGS.register(this.PREF_CHAR_LIMIT, {\n\t\t\tname: 'DF_CHAT_WHISPER_TRUNC.SettingCharLimitName',\n\t\t\thint: 'DF_CHAT_WHISPER_TRUNC.SettingCharLimitHint',\n\t\t\tconfig: true,\n\t\t\ttype: Number,\n\t\t\tdefault: 50,\n\t\t\tscope: 'world',\n\t\t\tonChange: async () => {\n\t\t\t\t(ui.chat)._state = 0;\n\t\t\t\t(ui.chat)._lastId = null;\n\t\t\t\tawait ui.chat.render(true);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate static _messageRender(message: ChatMessageData, html: JQuery, _cmd: ChatMessageData) {\n\t\t// ignore regular messages, or whispers with only 1 recipient\n\t\tif (!SETTINGS.get(this.PREF_ENABLED) || !(message.whisper) || message.whisper.length <= 1) return;\n\t\tconst users = message.whisper.map(x => game.users.get(x));\n\t\tlet accum = users[0].name;\n\t\tlet title = this._formatTitle(accum, users.length - 1);\n\t\tlet c = 1;\n\t\tconst CHAR_LIMIT = SETTINGS.get(this.PREF_CHAR_LIMIT);\n\t\tfor (; c < users.length; c++) {\n\t\t\t// Append name to names string\n\t\t\tconst tmpNames = accum + ', ' + users[c].name;\n\t\t\t// Generate a temp title\n\t\t\tconst tmpTitle = this._formatTitle(tmpNames, users.length - c - 1);\n\t\t\t// If the potential title is too large, break so we can use the previous iteration's results\n\t\t\tif (tmpTitle.length - LENGTH_ADJUST > CHAR_LIMIT) break;\n\t\t\t// Set the accum and title to the newly generated values\n\t\t\taccum = tmpNames;\n\t\t\ttitle = tmpTitle;\n\t\t}\n\t\t// If we never ran out of room, exit\n\t\tif (c === users.length) return;\n\t\t// Update the HTML\n\t\tconst newHeader = ` x.name).join(', ')}\">${title}`;\n\t\thtml.find('span.whisper-to').replaceWith(newHeader);\n\t}\n\n\tprivate static _formatTitle(names: string, count: number): string {\n\t\treturn count > 0\n\t\t\t? TEMPLATE\n\t\t\t\t.replace('$0', 'CHAT.To'.localize())\n\t\t\t\t.replace('$1', names)\n\t\t\t\t.replace('$2', count.toString())\n\t\t\t: names;\n\t}\n}","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import * as DFChatArchive from \"./archive/df-chat-archive\";\nimport DFChatEdit from \"./edit/df-chat-edit\";\nimport * as DFAdventureLog from \"./logger/df-adventure-log\";\nimport DFAdventureLogProcessor from \"./logger/DFAdventureLogProcessor\";\nimport ChatMerge from \"./merge/chat-merge\";\nimport ChatRollPrivacy from \"./privacy/df-chat-privacy\";\nimport ScrollManage from \"./scroll-manage/scroll-manage\";\nimport SETTINGS from \"../../common/Settings\";\nimport WhisperTruncation from \"./whisper-trunc/whisper-trunc\";\nimport PlayerColor from './player-color/PlayerColor';\nimport SendButton from \"./send/send-button\";\nimport FontSizePatch from \"./font-size/font-size\";\nimport ChatTime from \"./chat-time/chat-time\";\nSETTINGS.init('df-chat-enhance');\n\ndeclare global {\n\tinterface Application {\n\t\t_recalculateDimensions(): void;\n\t}\n}\n\n(Application.prototype)._recalculateDimensions = function () {\n\tthis.element[0].style.height = '';\n\tthis.element[0].style.width = '';\n\tthis.setPosition({});\n};\n\nHooks.once('setup', function () {\n\tChatRollPrivacy.setup();\n});\n\nHooks.once('init', function () {\n\t/**\n\t * Order here matters! The archive adds a button to the\n\t * chat window, while the privacy changes those buttons\n\t * from
    tags to