{"version":3,"mappings":";wNAKA,MAAMA,EAAwB,CAAC,gBAAiB,qBAAqB,EAE/DC,EAAyB,CAC9B,aACA,kBACA,sBACA,8BACA,yBACA,mBACA,qBACA,oBACA,oBACA,kBACA,mBACA,gBACA,WACA,YACA,WACA,WACA,gBACA,WACA,qBACA,cACA,aACA,gBACA,oBACD,EAEI,CAAC,GAAG,cAAc,eAAiB,CAAC,GAAG,cAAc,YACxDA,EAAuB,KAAK,UAAU,EClBvC,SAASC,GAA2B,CACnC,OAAMC,EAAA,IAAC,OAAO,iCAAuB,kHACtC,CAEI,OAAO,IAAI,OAAW,IACzBC,EAAO,MAAM,6BAA6B,EAE1C,IAAI,OAAO,gBAAgB,CAC1B,GAAI,OACJ,MAAO,CAAC,GAAGJ,EAAuB,GAAGC,CAAsB,EAC3D,UAAWC,EACX,MAAO,KACP,MAAO,UACP,WAAY,GACZ,iBAAkB,MAAOG,GAAa,CAErC,MAAMC,EAAU,OAAO,KAAK,MAAM,iBAClC,GAAIA,aAAmB,KACtB,UAAWC,KAAUD,EACpB,GAAIC,GAAQ,SAAWF,EAAS,QAAUE,GAAQ,MAAO,CACxDH,EAAO,MAAM,8BAA+B,CAC3C,OAAQC,EAAS,MACxB,CAAO,EACD,MAAME,EAAO,KAAI,EACjB,MACD,EAGH,CACF,CAAE","names":["openMimetypesMarkdown","openMimetypesPlainText","AsyncTextViewerComponent","__vitePreload","logger","fileInfo","editors","editor"],"ignoreList":[],"sources":["../src/helpers/mime.js","../src/viewer.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nconst openMimetypesMarkdown = ['text/markdown', 'text/x-web-markdown']\n\nconst openMimetypesPlainText = [\n\t'text/plain',\n\t'application/cmd',\n\t'application/x-empty',\n\t'application/x-msdos-program',\n\t'application/javascript',\n\t'application/json',\n\t'application/x-perl',\n\t'application/x-php',\n\t'application/x-tex',\n\t'application/xml',\n\t'application/yaml',\n\t'text/asciidoc',\n\t'text/css',\n\t'text/html',\n\t'text/org',\n\t'text/x-c',\n\t'text/x-c++src',\n\t'text/x-h',\n\t'text/x-java-source',\n\t'text/x-ldif',\n\t'text/x-nfo',\n\t'text/x-python',\n\t'text/x-shellscript',\n]\n\nif (!OC.appswebroots?.richdocuments && !OC.appswebroots?.onlyoffice) {\n\topenMimetypesPlainText.push('text/csv')\n}\n\nconst openMimetypes = [...openMimetypesMarkdown, ...openMimetypesPlainText]\n\nexport { openMimetypes, openMimetypesMarkdown, openMimetypesPlainText }\n","/**\n * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n// eslint-disable-next-line import/no-unresolved, n/no-missing-import\nimport 'vite/modulepreload-polyfill'\n\nimport { logger } from './helpers/logger.js'\nimport { openMimetypesMarkdown, openMimetypesPlainText } from './helpers/mime.js'\n\n/**\n * Wrapper for async registration of ViewerComponent.\n * Note: it should be named function - the name is used for component registration.\n *\n * @return {Promise<import('./views/ViewerView.js')>} ViewerComponent\n */\nfunction AsyncTextViewerComponent() {\n\treturn import('./views/ViewerView.js')\n}\n\nif (typeof OCA.Viewer === 'undefined') {\n\tlogger.error('Viewer app is not installed')\n} else {\n\tOCA.Viewer.registerHandler({\n\t\tid: 'text',\n\t\tmimes: [...openMimetypesMarkdown, ...openMimetypesPlainText],\n\t\tcomponent: AsyncTextViewerComponent,\n\t\tgroup: null,\n\t\ttheme: 'default',\n\t\tcanCompare: true,\n\t\tdownloadCallback: async (fileInfo) => {\n\t\t\t// Save any unsaved changes before download\n\t\t\tconst editors = window.OCA?.Text?.editorComponents\n\t\t\tif (editors instanceof Set) {\n\t\t\t\tfor (const editor of editors) {\n\t\t\t\t\tif (editor?.fileId === fileInfo.fileid && editor?.dirty) {\n\t\t\t\t\t\tlogger.debug('Saving file before download', {\n\t\t\t\t\t\t\tfileId: fileInfo.fileid,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tawait editor.save()\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n}\n"],"file":"text-viewer.mjs"}