{"version":3,"sources":["jsdelivr-header.js","/npm/@ckeditor/ckeditor5-upload@49.2.0/dist/index.js","/npm/@ckeditor/ckeditor5-upload@49.2.0/src/filereader.ts","/npm/@ckeditor/ckeditor5-upload@49.2.0/src/filerepository.ts","/npm/@ckeditor/ckeditor5-upload@49.2.0/src/adapters/base64uploadadapter.ts","/npm/@ckeditor/ckeditor5-upload@49.2.0/src/adapters/simpleuploadadapter.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;OCNS,eAAgB,WAAc,kCAC9B,cAAe,WAAY,gBAAiB,WAAY,QAAW;;;;ECY5E,MAAM,eAA6D,kBAKnE,IAAa,WAAb,cAAgC,eAC/B,MAKiB,QAMT,MAaR,WAAA,GACC,QAEA,MAAM,EAAS,IAAI,OAAO,WAE1B,KAAK,QAAU,EACf,KAAK,WAAQ,EAEb,KAAK,IAAK,SAAU,GAEpB,EAAO,WAAa,IACnB,KAAK,OAAS,EAAI,OAEpB,CAKA,SAAW,GACV,OAAO,KAAK,QAAQ,KACrB,CAMA,QAAW,GACV,OAAO,KAAK,KACb,CASO,IAAA,CAAM,GACZ,MAAM,EAAS,KAAK,QAGpB,OAFA,KAAK,MAAQ,EAAK,KAEX,IAAI,QAAA,CAAW,EAAS,KAC9B,EAAO,OAAA,KACN,MAAM,EAAS,EAAO,OAEtB,KAAK,MAAQ,EAEb,EAAS,IAGV,EAAO,QAAA,KACN,EAAQ,UAGT,EAAO,QAAA,KACN,EAAQ,YAGT,KAAK,QAAQ,cAAe,IAE9B,CAKO,KAAA,GACN,KAAK,QAAQ,OACd;;;;ECtFD,MAAM,eAA6D,kBAanE,IAAa,eAAb,cAAoC,OAI5B,QAAkC,IAAI,WAgBrC,YAAc,IAAI,IAMlB,eAAuC,KAiC/C,qBAAkB,GACjB,MAAO,gBACR,CAKA,2BAA2B,GAC1B,OAAO,CACR,CAKA,mBAAkB,GACjB,MAAO,CAAE,eACV,CAKA,IAAA,GAEC,KAAK,QAAQ,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OQ,YAAA,CAAc,GAErB,IAAI,EAAU,KAAK,QAAQ,SAAW,CAAC,EAEf,mBAAZ,IACX,EAAU,EAAS,IAIpB,MAAM,EAAkB,KAAK,QAAQ,kBAAmB,EAExD,IAAM,MAAM,KAAc,OAAO,KAAM,GACtC,KAAK,IAAK,iBAAkB,EAAY,EAAS,IAGlD,KAAK,IAAK,gBAAkB,EAG5B,MAAM,EAAO,IAAI,SAEjB,EAAK,OAAQ,SAAU,GAGvB,KAAK,IAAK,KAAM,EACjB;;;;;OJkeQ,oBAAqB,WAAY,WAAY,eAAgB","file":"/npm/@ckeditor/ckeditor5-upload@49.2.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.51.2.\n * Original file: /npm/@ckeditor/ckeditor5-upload@49.2.0/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { PendingActions, Plugin } from \"@ckeditor/ckeditor5-core\";\nimport { CKEditorError, Collection, ObservableMixin, logWarning, uid } from \"@ckeditor/ckeditor5-utils\";\n\n/**\n* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n*/\n/**\n* @module upload/filereader\n*/\nconst FileReaderBase = /* #__PURE__ */ ObservableMixin();\n/**\n* Wrapper over the native `FileReader`.\n*/\nvar FileReader = class extends FileReaderBase {\n\ttotal;\n\t/**\n\t* Instance of native FileReader.\n\t*/\n\t_reader;\n\t/**\n\t* Holds the data of an already loaded file. The file must be first loaded\n\t* by using {@link module:upload/filereader~FileReader#read `read()`}.\n\t*/\n\t_data;\n\t/**\n\t* Creates an instance of the FileReader.\n\t*/\n\tconstructor() {\n\t\tsuper();\n\t\tconst reader = new window.FileReader();\n\t\tthis._reader = reader;\n\t\tthis._data = void 0;\n\t\tthis.set(\"loaded\", 0);\n\t\treader.onprogress = (evt) => {\n\t\t\tthis.loaded = evt.loaded;\n\t\t};\n\t}\n\t/**\n\t* Returns error that occurred during file reading.\n\t*/\n\tget error() {\n\t\treturn this._reader.error;\n\t}\n\t/**\n\t* Holds the data of an already loaded file. The file must be first loaded\n\t* by using {@link module:upload/filereader~FileReader#read `read()`}.\n\t*/\n\tget data() {\n\t\treturn this._data;\n\t}\n\t/**\n\t* Reads the provided file.\n\t*\n\t* @param file Native File object.\n\t* @returns Returns a promise that will be resolved with file's content.\n\t* The promise will be rejected in case of an error or when the reading process is aborted.\n\t*/\n\tread(file) {\n\t\tconst reader = this._reader;\n\t\tthis.total = file.size;\n\t\treturn new Promise((resolve, reject) => {\n\t\t\treader.onload = () => {\n\t\t\t\tconst result = reader.result;\n\t\t\t\tthis._data = result;\n\t\t\t\tresolve(result);\n\t\t\t};\n\t\t\treader.onerror = () => {\n\t\t\t\treject(\"error\");\n\t\t\t};\n\t\t\treader.onabort = () => {\n\t\t\t\treject(\"aborted\");\n\t\t\t};\n\t\t\tthis._reader.readAsDataURL(file);\n\t\t});\n\t}\n\t/**\n\t* Aborts file reader.\n\t*/\n\tabort() {\n\t\tthis._reader.abort();\n\t}\n};\n\n/**\n* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n*/\n/**\n* @module upload/filerepository\n*/\nconst FileLoaderBase = /* #__PURE__ */ ObservableMixin();\n/**\n* File repository plugin. A central point for managing file upload.\n*\n* To use it, first you need an upload adapter. Upload adapter's job is to handle communication with the server\n* (sending the file and handling server's response). You can use one of the existing plugins introducing upload adapters\n* (e.g. {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter}) or write your own one – see\n* the {@glink framework/deep-dive/upload-adapter Custom image upload adapter deep-dive} guide.\n*\n* Then, you can use {@link module:upload/filerepository~FileRepository#createLoader `createLoader()`} and the returned\n* {@link module:upload/filerepository~FileLoader} instance to load and upload files.\n*/\nvar FileRepository = class extends Plugin {\n\t/**\n\t* Collection of loaders associated with this repository.\n\t*/\n\tloaders = new Collection();\n\t/**\n\t* Loaders mappings used to retrieve loaders references.\n\t*/\n\t_loadersMap = /* @__PURE__ */ new Map();\n\t/**\n\t* Reference to a pending action registered in a {@link module:core/pendingactions~PendingActions} plugin\n\t* while upload is in progress. When there is no upload then value is `null`.\n\t*/\n\t_pendingAction = null;\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get pluginName() {\n\t\treturn \"FileRepository\";\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get isOfficialPlugin() {\n\t\treturn true;\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get requires() {\n\t\treturn [PendingActions];\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tinit() {\n\t\tthis.loaders.on(\"change\", () => this._updatePendingAction());\n\t\tthis.set(\"uploaded\", 0);\n\t\tthis.set(\"uploadTotal\", null);\n\t\tthis.bind(\"uploadedPercent\").to(this, \"uploaded\", this, \"uploadTotal\", (uploaded, total) => {\n\t\t\treturn total ? uploaded / total * 100 : 0;\n\t\t});\n\t}\n\t/**\n\t* Returns the loader associated with specified file or promise.\n\t*\n\t* To get loader by id use `fileRepository.loaders.get( id )`.\n\t*\n\t* @param fileOrPromise Native file or promise handle.\n\t*/\n\tgetLoader(fileOrPromise) {\n\t\treturn this._loadersMap.get(fileOrPromise) || null;\n\t}\n\t/**\n\t* Creates a loader instance for the given file.\n\t*\n\t* Requires {@link #createUploadAdapter} factory to be defined.\n\t*\n\t* @param fileOrPromise Native File object or native Promise object which resolves to a File.\n\t*/\n\tcreateLoader(fileOrPromise) {\n\t\tif (!this.createUploadAdapter) {\n\t\t\t/**\n\t\t\t* You need to enable an upload adapter in order to be able to upload files.\n\t\t\t*\n\t\t\t* This warning shows up when {@link module:upload/filerepository~FileRepository} is being used\n\t\t\t* without {@link module:upload/filerepository~FileRepository#createUploadAdapter defining an upload adapter}.\n\t\t\t*\n\t\t\t* **If you see this warning when using one of the now deprecated CKEditor 5 builds**\n\t\t\t* it means that you did not configure any of the upload adapters available by default in those builds.\n\t\t\t*\n\t\t\t* Predefined builds are a deprecated solution and we strongly advise\n\t\t\t* {@glink updating/nim-migration/migration-to-new-installation-methods migrating to new installation methods}.\n\t\t\t*\n\t\t\t* See the {@glink features/images/image-upload/image-upload comprehensive \"Image upload overview\"} to learn which upload\n\t\t\t* adapters are available in the builds and how to configure them.\n\t\t\t*\n\t\t\t* Otherwise, if you see this warning, there is a chance that you enabled\n\t\t\t* a feature like {@link module:image/imageupload~ImageUpload},\n\t\t\t* or {@link module:image/imageupload/imageuploadui~ImageUploadUI} but you did not enable any upload adapter.\n\t\t\t* You can choose one of the existing upload adapters listed in the\n\t\t\t* {@glink features/images/image-upload/image-upload \"Image upload overview\"}.\n\t\t\t*\n\t\t\t* You can also implement your {@glink framework/deep-dive/upload-adapter own image upload adapter}.\n\t\t\t*\n\t\t\t* @error filerepository-no-upload-adapter\n\t\t\t*/\n\t\t\tlogWarning(\"filerepository-no-upload-adapter\");\n\t\t\treturn null;\n\t\t}\n\t\tconst loader = new FileLoader(Promise.resolve(fileOrPromise), this.createUploadAdapter);\n\t\tthis.loaders.add(loader);\n\t\tthis._loadersMap.set(fileOrPromise, loader);\n\t\tif (fileOrPromise instanceof Promise) loader.file.then((file) => {\n\t\t\tthis._loadersMap.set(file, loader);\n\t\t}).catch(() => {});\n\t\tloader.on(\"change:uploaded\", () => {\n\t\t\tlet aggregatedUploaded = 0;\n\t\t\tfor (const loader of this.loaders) aggregatedUploaded += loader.uploaded;\n\t\t\tthis.uploaded = aggregatedUploaded;\n\t\t});\n\t\tloader.on(\"change:uploadTotal\", () => {\n\t\t\tlet aggregatedTotal = 0;\n\t\t\tfor (const loader of this.loaders) if (loader.uploadTotal) aggregatedTotal += loader.uploadTotal;\n\t\t\tthis.uploadTotal = aggregatedTotal;\n\t\t});\n\t\treturn loader;\n\t}\n\t/**\n\t* Destroys the given loader.\n\t*\n\t* @param fileOrPromiseOrLoader File or Promise associated with that loader or loader itself.\n\t*/\n\tdestroyLoader(fileOrPromiseOrLoader) {\n\t\tconst loader = fileOrPromiseOrLoader instanceof FileLoader ? fileOrPromiseOrLoader : this.getLoader(fileOrPromiseOrLoader);\n\t\tloader._destroy();\n\t\tthis.loaders.remove(loader);\n\t\tthis._loadersMap.forEach((value, key) => {\n\t\t\tif (value === loader) this._loadersMap.delete(key);\n\t\t});\n\t}\n\t/**\n\t* Registers or deregisters pending action bound with upload progress.\n\t*/\n\t_updatePendingAction() {\n\t\tconst pendingActions = this.editor.plugins.get(PendingActions);\n\t\tif (this.loaders.length) {\n\t\t\tif (!this._pendingAction) {\n\t\t\t\tconst t = this.editor.t;\n\t\t\t\tconst getMessage = (value) => `${t(\"Upload in progress\")} ${parseInt(value)}%.`;\n\t\t\t\tthis._pendingAction = pendingActions.add(getMessage(this.uploadedPercent));\n\t\t\t\tthis._pendingAction.bind(\"message\").to(this, \"uploadedPercent\", getMessage);\n\t\t\t}\n\t\t} else {\n\t\t\tpendingActions.remove(this._pendingAction);\n\t\t\tthis._pendingAction = null;\n\t\t}\n\t}\n};\n/**\n* File loader class.\n*\n* It is used to control the process of reading the file and uploading it using the specified upload adapter.\n*/\nvar FileLoader = class extends FileLoaderBase {\n\t/**\n\t* Unique id of FileLoader instance.\n\t*\n\t* @readonly\n\t*/\n\tid;\n\t/**\n\t* Additional wrapper over the initial file promise passed to this loader.\n\t*/\n\t_filePromiseWrapper;\n\t/**\n\t* Adapter instance associated with this file loader.\n\t*/\n\t_adapter;\n\t/**\n\t* FileReader used by FileLoader.\n\t*/\n\t_reader;\n\t/**\n\t* Creates a new instance of `FileLoader`.\n\t*\n\t* @param filePromise A promise which resolves to a file instance.\n\t* @param uploadAdapterCreator The function which returns {@link module:upload/filerepository~UploadAdapter} instance.\n\t*/\n\tconstructor(filePromise, uploadAdapterCreator) {\n\t\tsuper();\n\t\tthis.id = uid();\n\t\tthis._filePromiseWrapper = this._createFilePromiseWrapper(filePromise);\n\t\tthis._adapter = uploadAdapterCreator(this);\n\t\tthis._reader = new FileReader();\n\t\tthis.set(\"status\", \"idle\");\n\t\tthis.set(\"uploaded\", 0);\n\t\tthis.set(\"uploadTotal\", null);\n\t\tthis.bind(\"uploadedPercent\").to(this, \"uploaded\", this, \"uploadTotal\", (uploaded, total) => {\n\t\t\treturn total ? uploaded / total * 100 : 0;\n\t\t});\n\t\tthis.set(\"uploadResponse\", null);\n\t}\n\t/**\n\t* A `Promise` which resolves to a `File` instance associated with this file loader.\n\t*/\n\tget file() {\n\t\tif (!this._filePromiseWrapper) return Promise.resolve(null);\n\t\telse return this._filePromiseWrapper.promise.then((file) => this._filePromiseWrapper ? file : null);\n\t}\n\t/**\n\t* Returns the file data. To read its data, you need for first load the file\n\t* by using the {@link module:upload/filerepository~FileLoader#read `read()`} method.\n\t*/\n\tget data() {\n\t\treturn this._reader.data;\n\t}\n\t/**\n\t* Reads file using {@link module:upload/filereader~FileReader}.\n\t*\n\t* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `filerepository-read-wrong-status` when status\n\t* is different than `idle`.\n\t*\n\t* Example usage:\n\t*\n\t* ```ts\n\t* fileLoader.read()\n\t* \t.then( data => { ... } )\n\t* \t.catch( err => {\n\t* \t\tif ( err === 'aborted' ) {\n\t* \t\t\tconsole.log( 'Reading aborted.' );\n\t* \t\t} else {\n\t* \t\t\tconsole.log( 'Reading error.', err );\n\t* \t\t}\n\t* \t} );\n\t* ```\n\t*\n\t* @returns Returns promise that will be resolved with read data. Promise will be rejected if error\n\t* occurs or if read process is aborted.\n\t*/\n\tread() {\n\t\tif (this.status != \"idle\")\n /**\n\t\t* You cannot call read if the status is different than idle.\n\t\t*\n\t\t* @error filerepository-read-wrong-status\n\t\t*/\n\t\tthrow new CKEditorError(\"filerepository-read-wrong-status\", this);\n\t\tthis.status = \"reading\";\n\t\treturn this.file.then((file) => this._reader.read(file)).then((data) => {\n\t\t\tif (this.status !== \"reading\") throw this.status;\n\t\t\tthis.status = \"idle\";\n\t\t\treturn data;\n\t\t}).catch((err) => {\n\t\t\tif (err === \"aborted\") {\n\t\t\t\tthis.status = \"aborted\";\n\t\t\t\tthrow \"aborted\";\n\t\t\t}\n\t\t\tthis.status = \"error\";\n\t\t\tthrow this._reader.error ? this._reader.error : err;\n\t\t});\n\t}\n\t/**\n\t* Reads file using the provided {@link module:upload/filerepository~UploadAdapter}.\n\t*\n\t* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `filerepository-upload-wrong-status` when status\n\t* is different than `idle`.\n\t* Example usage:\n\t*\n\t* ```ts\n\t* fileLoader.upload()\n\t* \t.then( data => { ... } )\n\t* \t.catch( e => {\n\t* \t\tif ( e === 'aborted' ) {\n\t* \t\t\tconsole.log( 'Uploading aborted.' );\n\t* \t\t} else {\n\t* \t\t\tconsole.log( 'Uploading error.', e );\n\t* \t\t}\n\t* \t} );\n\t* ```\n\t*\n\t* @returns Returns promise that will be resolved with response data. Promise will be rejected if error\n\t* occurs or if read process is aborted.\n\t*/\n\tupload() {\n\t\tif (this.status != \"idle\")\n /**\n\t\t* You cannot call upload if the status is different than idle.\n\t\t*\n\t\t* @error filerepository-upload-wrong-status\n\t\t*/\n\t\tthrow new CKEditorError(\"filerepository-upload-wrong-status\", this);\n\t\tthis.status = \"uploading\";\n\t\treturn this.file.then(() => this._adapter.upload()).then((data) => {\n\t\t\tthis.uploadResponse = data;\n\t\t\tthis.status = \"idle\";\n\t\t\treturn data;\n\t\t}).catch((err) => {\n\t\t\tif (this.status === \"aborted\") throw \"aborted\";\n\t\t\tthis.status = \"error\";\n\t\t\tthrow err;\n\t\t});\n\t}\n\t/**\n\t* Aborts loading process.\n\t*/\n\tabort() {\n\t\tconst status = this.status;\n\t\tthis.status = \"aborted\";\n\t\tif (!this._filePromiseWrapper.isFulfilled) {\n\t\t\tthis._filePromiseWrapper.promise.catch(() => {});\n\t\t\tthis._filePromiseWrapper.rejecter(\"aborted\");\n\t\t} else if (status == \"reading\") this._reader.abort();\n\t\telse if (status == \"uploading\" && this._adapter.abort) this._adapter.abort();\n\t\tthis._destroy();\n\t}\n\t/**\n\t* Performs cleanup.\n\t*\n\t* @internal\n\t*/\n\t_destroy() {\n\t\tthis._filePromiseWrapper = void 0;\n\t\tthis._reader = void 0;\n\t\tthis._adapter = void 0;\n\t\tthis.uploadResponse = void 0;\n\t}\n\t/**\n\t* Wraps a given file promise into another promise giving additional\n\t* control (resolving, rejecting, checking if fulfilled) over it.\n\t*\n\t* @param filePromise The initial file promise to be wrapped.\n\t*/\n\t_createFilePromiseWrapper(filePromise) {\n\t\tconst wrapper = {};\n\t\twrapper.promise = new Promise((resolve, reject) => {\n\t\t\twrapper.rejecter = reject;\n\t\t\twrapper.isFulfilled = false;\n\t\t\tfilePromise.then((file) => {\n\t\t\t\twrapper.isFulfilled = true;\n\t\t\t\tresolve(file);\n\t\t\t}).catch((err) => {\n\t\t\t\twrapper.isFulfilled = true;\n\t\t\t\treject(err);\n\t\t\t});\n\t\t});\n\t\treturn wrapper;\n\t}\n};\n\n/**\n* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n*/\n/**\n* @module upload/adapters/base64uploadadapter\n*/\n/**\n* A plugin that converts images inserted into the editor into [Base64 strings](https://en.wikipedia.org/wiki/Base64)\n* in the {@glink getting-started/setup/getting-and-setting-data editor output}.\n*\n* This kind of image upload does not require server processing – images are stored with the rest of the text and\n* displayed by the web browser without additional requests.\n*\n* Check out the {@glink features/images/image-upload/image-upload comprehensive \"Image upload overview\"} to learn about\n* other ways to upload images into CKEditor 5.\n*/\nvar Base64UploadAdapter = class extends Plugin {\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get requires() {\n\t\treturn [FileRepository];\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get pluginName() {\n\t\treturn \"Base64UploadAdapter\";\n\t}\n\t/**\n\t* @inheritDoc\n\t* @internal\n\t*/\n\tstatic get licenseFeatureCode() {\n\t\treturn \"B64A\";\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get isOfficialPlugin() {\n\t\treturn true;\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get isPremiumPlugin() {\n\t\treturn true;\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tinit() {\n\t\tthis.editor.plugins.get(FileRepository).createUploadAdapter = (loader) => new Adapter$1(loader);\n\t}\n};\n/**\n* The upload adapter that converts images inserted into the editor into Base64 strings.\n*/\nvar Adapter$1 = class {\n\t/**\n\t* `FileLoader` instance to use during the upload.\n\t*/\n\tloader;\n\treader;\n\t/**\n\t* Creates a new adapter instance.\n\t*/\n\tconstructor(loader) {\n\t\tthis.loader = loader;\n\t}\n\t/**\n\t* Starts the upload process.\n\t*\n\t* @see module:upload/filerepository~UploadAdapter#upload\n\t*/\n\tupload() {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst reader = this.reader = new window.FileReader();\n\t\t\treader.addEventListener(\"load\", () => {\n\t\t\t\tresolve({ default: reader.result });\n\t\t\t});\n\t\t\treader.addEventListener(\"error\", (err) => {\n\t\t\t\treject(err);\n\t\t\t});\n\t\t\treader.addEventListener(\"abort\", () => {\n\t\t\t\treject();\n\t\t\t});\n\t\t\tthis.loader.file.then((file) => {\n\t\t\t\treader.readAsDataURL(file);\n\t\t\t});\n\t\t});\n\t}\n\t/**\n\t* Aborts the upload process.\n\t*\n\t* @see module:upload/filerepository~UploadAdapter#abort\n\t*/\n\tabort() {\n\t\tthis.reader.abort();\n\t}\n};\n\n/**\n* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n*/\n/**\n* @module upload/adapters/simpleuploadadapter\n*/\n/**\n* The Simple upload adapter allows uploading images to an application running on your server using\n* the [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) API with a\n* minimal {@link module:upload/uploadconfig~SimpleUploadConfig editor configuration}.\n*\n* ```ts\n* ClassicEditor\n* \t.create( {\n* \t\tsimpleUpload: {\n* \t\t\tuploadUrl: 'http://example.com',\n* \t\t\theaders: {\n* \t\t\t\t...\n* \t\t\t}\n* \t\t}\n* \t} )\n* \t.then( ... )\n* \t.catch( ... );\n* ```\n*\n* See the {@glink features/images/image-upload/simple-upload-adapter \"Simple upload adapter\"} guide to learn how to\n* learn more about the feature (configuration, server–side requirements, etc.).\n*\n* Check out the {@glink features/images/image-upload/image-upload comprehensive \"Image upload overview\"} to learn about\n* other ways to upload images into CKEditor 5.\n*/\nvar SimpleUploadAdapter = class extends Plugin {\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get requires() {\n\t\treturn [FileRepository];\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get pluginName() {\n\t\treturn \"SimpleUploadAdapter\";\n\t}\n\t/**\n\t* @inheritDoc\n\t* @internal\n\t*/\n\tstatic get licenseFeatureCode() {\n\t\treturn \"SUA\";\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get isOfficialPlugin() {\n\t\treturn true;\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tstatic get isPremiumPlugin() {\n\t\treturn true;\n\t}\n\t/**\n\t* @inheritDoc\n\t*/\n\tinit() {\n\t\tconst options = this.editor.config.get(\"simpleUpload\");\n\t\tif (!options) return;\n\t\tif (!options.uploadUrl) {\n\t\t\t/**\n\t\t\t* The {@link module:upload/uploadconfig~SimpleUploadConfig#uploadUrl `config.simpleUpload.uploadUrl`}\n\t\t\t* configuration required by the {@link module:upload/adapters/simpleuploadadapter~SimpleUploadAdapter `SimpleUploadAdapter`}\n\t\t\t* is missing. Make sure the correct URL is specified for the image upload to work properly.\n\t\t\t*\n\t\t\t* @error simple-upload-adapter-missing-uploadurl\n\t\t\t*/\n\t\t\tlogWarning(\"simple-upload-adapter-missing-uploadurl\");\n\t\t\treturn;\n\t\t}\n\t\tthis.editor.plugins.get(FileRepository).createUploadAdapter = (loader) => {\n\t\t\treturn new Adapter(loader, options);\n\t\t};\n\t}\n};\n/**\n* Upload adapter.\n*/\nvar Adapter = class {\n\t/**\n\t* FileLoader instance to use during the upload.\n\t*/\n\tloader;\n\t/**\n\t* The configuration of the adapter.\n\t*/\n\toptions;\n\txhr;\n\t/**\n\t* Creates a new adapter instance.\n\t*/\n\tconstructor(loader, options) {\n\t\tthis.loader = loader;\n\t\tthis.options = options;\n\t}\n\t/**\n\t* Starts the upload process.\n\t*\n\t* @see module:upload/filerepository~UploadAdapter#upload\n\t*/\n\tupload() {\n\t\treturn this.loader.file.then((file) => new Promise((resolve, reject) => {\n\t\t\tthis._initRequest();\n\t\t\tthis._initListeners(resolve, reject, file);\n\t\t\tthis._sendRequest(file);\n\t\t}));\n\t}\n\t/**\n\t* Aborts the upload process.\n\t*\n\t* @see module:upload/filerepository~UploadAdapter#abort\n\t*/\n\tabort() {\n\t\tif (this.xhr) this.xhr.abort();\n\t}\n\t/**\n\t* Initializes the `XMLHttpRequest` object using the URL specified as\n\t* {@link module:upload/uploadconfig~SimpleUploadConfig#uploadUrl `simpleUpload.uploadUrl`} in the editor's\n\t* configuration.\n\t*/\n\t_initRequest() {\n\t\tconst xhr = this.xhr = new XMLHttpRequest();\n\t\txhr.open(\"POST\", this.options.uploadUrl, true);\n\t\txhr.responseType = \"json\";\n\t}\n\t/**\n\t* Initializes XMLHttpRequest listeners\n\t*\n\t* @param resolve Callback function to be called when the request is successful.\n\t* @param reject Callback function to be called when the request cannot be completed.\n\t* @param file Native File object.\n\t*/\n\t_initListeners(resolve, reject, file) {\n\t\tconst xhr = this.xhr;\n\t\tconst loader = this.loader;\n\t\tconst genericErrorText = `Couldn't upload file: ${file.name}.`;\n\t\txhr.addEventListener(\"error\", () => reject(genericErrorText));\n\t\txhr.addEventListener(\"abort\", () => reject());\n\t\txhr.addEventListener(\"load\", () => {\n\t\t\tconst response = xhr.response;\n\t\t\tif (!response || response.error) return reject(response && response.error && response.error.message ? response.error.message : genericErrorText);\n\t\t\tconst urls = response.url ? { default: response.url } : response.urls;\n\t\t\tresolve({\n\t\t\t\t...response,\n\t\t\t\turls\n\t\t\t});\n\t\t});\n\t\t/* v8 ignore else -- @preserve */\n\t\tif (xhr.upload) xhr.upload.addEventListener(\"progress\", (evt) => {\n\t\t\t/* v8 ignore else -- @preserve */\n\t\t\tif (evt.lengthComputable) {\n\t\t\t\tloader.uploadTotal = evt.total;\n\t\t\t\tloader.uploaded = evt.loaded;\n\t\t\t}\n\t\t});\n\t}\n\t/**\n\t* Prepares the data and sends the request.\n\t*\n\t* @param file File instance to be uploaded.\n\t*/\n\t_sendRequest(file) {\n\t\tlet headers = this.options.headers || {};\n\t\tif (typeof headers === \"function\") headers = headers(file);\n\t\tconst withCredentials = this.options.withCredentials || false;\n\t\tfor (const headerName of Object.keys(headers)) this.xhr.setRequestHeader(headerName, headers[headerName]);\n\t\tthis.xhr.withCredentials = withCredentials;\n\t\tconst data = new FormData();\n\t\tdata.append(\"upload\", file);\n\t\tthis.xhr.send(data);\n\t}\n};\n\n/**\n* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n*/\n\nexport { Base64UploadAdapter, FileLoader, FileReader, FileRepository, SimpleUploadAdapter };\n//# sourceMappingURL=index.js.map","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n\n/**\n * @module upload/filereader\n */\n\nimport { ObservableMixin, type ObservableMixinConstructor } from '@ckeditor/ckeditor5-utils';\n\ntype DomFileReader = globalThis.FileReader;\n\nconst FileReaderBase: ObservableMixinConstructor = /* #__PURE__ */ ObservableMixin();\n\n/**\n * Wrapper over the native `FileReader`.\n */\nexport class FileReader extends FileReaderBase {\n\tpublic total!: number;\n\n\t/**\n\t * Instance of native FileReader.\n\t */\n\tprivate readonly _reader: DomFileReader;\n\n\t/**\n\t * Holds the data of an already loaded file. The file must be first loaded\n\t * by using {@link module:upload/filereader~FileReader#read `read()`}.\n\t */\n\tprivate _data?: string;\n\n\t/**\n\t * Number of bytes loaded.\n\t *\n\t * @readonly\n\t * @observable\n\t */\n\tdeclare public loaded: number;\n\n\t/**\n\t * Creates an instance of the FileReader.\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\tconst reader = new window.FileReader();\n\n\t\tthis._reader = reader;\n\t\tthis._data = undefined;\n\n\t\tthis.set( 'loaded', 0 );\n\n\t\treader.onprogress = evt => {\n\t\t\tthis.loaded = evt.loaded;\n\t\t};\n\t}\n\n\t/**\n\t * Returns error that occurred during file reading.\n\t */\n\tpublic get error(): DOMException | null {\n\t\treturn this._reader.error;\n\t}\n\n\t/**\n\t * Holds the data of an already loaded file. The file must be first loaded\n\t * by using {@link module:upload/filereader~FileReader#read `read()`}.\n\t */\n\tpublic get data(): string | undefined {\n\t\treturn this._data;\n\t}\n\n\t/**\n\t * Reads the provided file.\n\t *\n\t * @param file Native File object.\n\t * @returns Returns a promise that will be resolved with file's content.\n\t * The promise will be rejected in case of an error or when the reading process is aborted.\n\t */\n\tpublic read( file: File ): Promise<string> {\n\t\tconst reader = this._reader;\n\t\tthis.total = file.size;\n\n\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\treader.onload = () => {\n\t\t\t\tconst result = reader.result as string;\n\n\t\t\t\tthis._data = result;\n\n\t\t\t\tresolve( result );\n\t\t\t};\n\n\t\t\treader.onerror = () => {\n\t\t\t\treject( 'error' );\n\t\t\t};\n\n\t\t\treader.onabort = () => {\n\t\t\t\treject( 'aborted' );\n\t\t\t};\n\n\t\t\tthis._reader.readAsDataURL( file );\n\t\t} );\n\t}\n\n\t/**\n\t * Aborts file reader.\n\t */\n\tpublic abort(): void {\n\t\tthis._reader.abort();\n\t}\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n\n/**\n * @module upload/filerepository\n */\n\nimport { Plugin, PendingActions, type PendingAction, type PluginDependenciesOf } from '@ckeditor/ckeditor5-core';\n\nimport {\n\tCKEditorError,\n\tCollection,\n\tObservableMixin,\n\tlogWarning,\n\tuid,\n\ttype ObservableChangeEvent,\n\ttype CollectionChangeEvent,\n\ttype ObservableMixinConstructor\n} from '@ckeditor/ckeditor5-utils';\n\nimport { FileReader } from './filereader.js';\n\nconst FileLoaderBase: ObservableMixinConstructor = /* #__PURE__ */ ObservableMixin();\n\n/**\n * File repository plugin. A central point for managing file upload.\n *\n * To use it, first you need an upload adapter. Upload adapter's job is to handle communication with the server\n * (sending the file and handling server's response). You can use one of the existing plugins introducing upload adapters\n * (e.g. {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter}) or write your own one – see\n * the {@glink framework/deep-dive/upload-adapter Custom image upload adapter deep-dive} guide.\n *\n * Then, you can use {@link module:upload/filerepository~FileRepository#createLoader `createLoader()`} and the returned\n * {@link module:upload/filerepository~FileLoader} instance to load and upload files.\n */\nexport class FileRepository extends Plugin {\n\t/**\n\t * Collection of loaders associated with this repository.\n\t */\n\tpublic loaders: Collection<FileLoader> = new Collection<FileLoader>();\n\n\t/**\n\t * A factory function which should be defined before using `FileRepository`.\n\t *\n\t * It should return a new instance of {@link module:upload/filerepository~UploadAdapter} that will be used to upload files.\n\t * {@link module:upload/filerepository~FileLoader} instance associated with the adapter\n\t * will be passed to that function.\n\t *\n\t * For more information and example see {@link module:upload/filerepository~UploadAdapter}.\n\t */\n\tpublic declare createUploadAdapter?: ( loader: FileLoader ) => UploadAdapter;\n\n\t/**\n\t * Loaders mappings used to retrieve loaders references.\n\t */\n\tprivate _loadersMap = new Map<File | Promise<File>, FileLoader>();\n\n\t/**\n\t * Reference to a pending action registered in a {@link module:core/pendingactions~PendingActions} plugin\n\t * while upload is in progress. When there is no upload then value is `null`.\n\t */\n\tprivate _pendingAction: PendingAction | null = null;\n\n\t/**\n\t * Number of bytes uploaded.\n\t *\n\t * @readonly\n\t * @observable\n\t */\n\tdeclare public uploaded: number;\n\n\t/**\n\t * Number of total bytes to upload.\n\t *\n\t * It might be different than the file size because of headers and additional data.\n\t * It contains `null` if value is not available yet, so it's better to use {@link #uploadedPercent} to monitor\n\t * the progress.\n\t *\n\t * @readonly\n\t * @observable\n\t */\n\tdeclare public uploadTotal: number | null;\n\n\t/**\n\t * Upload progress in percents.\n\t *\n\t * @readonly\n\t * @observable\n\t */\n\tdeclare public uploadedPercent: number;\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get pluginName() {\n\t\treturn 'FileRepository' as const;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static override get isOfficialPlugin(): true {\n\t\treturn true;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get requires(): PluginDependenciesOf<[ PendingActions ]> {\n\t\treturn [ PendingActions ];\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic init(): void {\n\t\t// Keeps upload in a sync with pending actions.\n\t\tthis.loaders.on<CollectionChangeEvent>( 'change', () => this._updatePendingAction() );\n\n\t\tthis.set( 'uploaded', 0 );\n\t\tthis.set( 'uploadTotal', null );\n\n\t\tthis.bind( 'uploadedPercent' ).to( this, 'uploaded', this, 'uploadTotal', ( uploaded, total ) => {\n\t\t\treturn total ? ( uploaded / total * 100 ) : 0;\n\t\t} );\n\t}\n\n\t/**\n\t * Returns the loader associated with specified file or promise.\n\t *\n\t * To get loader by id use `fileRepository.loaders.get( id )`.\n\t *\n\t * @param fileOrPromise Native file or promise handle.\n\t */\n\tpublic getLoader( fileOrPromise: File | Promise<File> ): FileLoader | null {\n\t\treturn this._loadersMap.get( fileOrPromise ) || null;\n\t}\n\n\t/**\n\t * Creates a loader instance for the given file.\n\t *\n\t * Requires {@link #createUploadAdapter} factory to be defined.\n\t *\n\t * @param fileOrPromise Native File object or native Promise object which resolves to a File.\n\t */\n\tpublic createLoader( fileOrPromise: File | Promise<File> ): FileLoader | null {\n\t\tif ( !this.createUploadAdapter ) {\n\t\t\t/**\n\t\t\t * You need to enable an upload adapter in order to be able to upload files.\n\t\t\t *\n\t\t\t * This warning shows up when {@link module:upload/filerepository~FileRepository} is being used\n\t\t\t * without {@link module:upload/filerepository~FileRepository#createUploadAdapter defining an upload adapter}.\n\t\t\t *\n\t\t\t * **If you see this warning when using one of the now deprecated CKEditor 5 builds**\n\t\t\t * it means that you did not configure any of the upload adapters available by default in those builds.\n\t\t\t *\n\t\t\t * Predefined builds are a deprecated solution and we strongly advise\n\t\t\t * {@glink updating/nim-migration/migration-to-new-installation-methods migrating to new installation methods}.\n\t\t\t *\n\t\t\t * See the {@glink features/images/image-upload/image-upload comprehensive \"Image upload overview\"} to learn which upload\n\t\t\t * adapters are available in the builds and how to configure them.\n\t\t\t *\n\t\t\t * Otherwise, if you see this warning, there is a chance that you enabled\n\t\t\t * a feature like {@link module:image/imageupload~ImageUpload},\n\t\t\t * or {@link module:image/imageupload/imageuploadui~ImageUploadUI} but you did not enable any upload adapter.\n\t\t\t * You can choose one of the existing upload adapters listed in the\n\t\t\t * {@glink features/images/image-upload/image-upload \"Image upload overview\"}.\n\t\t\t *\n\t\t\t * You can also implement your {@glink framework/deep-dive/upload-adapter own image upload adapter}.\n\t\t\t *\n\t\t\t * @error filerepository-no-upload-adapter\n\t\t\t */\n\t\t\tlogWarning( 'filerepository-no-upload-adapter' );\n\n\t\t\treturn null;\n\t\t}\n\n\t\tconst loader = new FileLoader( Promise.resolve( fileOrPromise ), this.createUploadAdapter );\n\n\t\tthis.loaders.add( loader );\n\t\tthis._loadersMap.set( fileOrPromise, loader );\n\n\t\t// Store also file => loader mapping so loader can be retrieved by file instance returned upon Promise resolution.\n\t\tif ( fileOrPromise instanceof Promise ) {\n\t\t\tloader.file\n\t\t\t\t.then( file => {\n\t\t\t\t\tthis._loadersMap.set( file!, loader );\n\t\t\t\t} )\n\t\t\t\t// Every then() must have a catch().\n\t\t\t\t// File loader state (and rejections) are handled in read() and upload().\n\t\t\t\t// Also, see the \"does not swallow the file promise rejection\" test.\n\t\t\t\t.catch( () => {} );\n\t\t}\n\n\t\tloader.on<ObservableChangeEvent>( 'change:uploaded', () => {\n\t\t\tlet aggregatedUploaded = 0;\n\n\t\t\tfor ( const loader of this.loaders ) {\n\t\t\t\taggregatedUploaded += loader.uploaded;\n\t\t\t}\n\n\t\t\tthis.uploaded = aggregatedUploaded;\n\t\t} );\n\n\t\tloader.on<ObservableChangeEvent>( 'change:uploadTotal', () => {\n\t\t\tlet aggregatedTotal = 0;\n\n\t\t\tfor ( const loader of this.loaders ) {\n\t\t\t\tif ( loader.uploadTotal ) {\n\t\t\t\t\taggregatedTotal += loader.uploadTotal;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.uploadTotal = aggregatedTotal;\n\t\t} );\n\n\t\treturn loader;\n\t}\n\n\t/**\n\t * Destroys the given loader.\n\t *\n\t * @param fileOrPromiseOrLoader File or Promise associated with that loader or loader itself.\n\t */\n\tpublic destroyLoader( fileOrPromiseOrLoader: File | Promise<File> | FileLoader ): void {\n\t\tconst loader = fileOrPromiseOrLoader instanceof FileLoader ? fileOrPromiseOrLoader : this.getLoader( fileOrPromiseOrLoader )!;\n\n\t\tloader._destroy();\n\n\t\tthis.loaders.remove( loader );\n\n\t\tthis._loadersMap.forEach( ( value, key ) => {\n\t\t\tif ( value === loader ) {\n\t\t\t\tthis._loadersMap.delete( key );\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * Registers or deregisters pending action bound with upload progress.\n\t */\n\tprivate _updatePendingAction(): void {\n\t\tconst pendingActions = this.editor.plugins.get( PendingActions );\n\n\t\tif ( this.loaders.length ) {\n\t\t\tif ( !this._pendingAction ) {\n\t\t\t\tconst t = this.editor.t;\n\t\t\t\tconst getMessage = ( value: number ) => `${ t( 'Upload in progress' ) } ${ parseInt( value as any ) }%.`;\n\n\t\t\t\tthis._pendingAction = pendingActions.add( getMessage( this.uploadedPercent ) );\n\t\t\t\tthis._pendingAction.bind( 'message' ).to( this, 'uploadedPercent', getMessage );\n\t\t\t}\n\t\t} else {\n\t\t\tpendingActions.remove( this._pendingAction! );\n\t\t\tthis._pendingAction = null;\n\t\t}\n\t}\n}\n\n/**\n * File loader class.\n *\n * It is used to control the process of reading the file and uploading it using the specified upload adapter.\n */\nclass FileLoader extends FileLoaderBase {\n\t/**\n\t * Unique id of FileLoader instance.\n\t *\n\t * @readonly\n\t */\n\tpublic readonly id: string;\n\n\t/**\n\t * Additional wrapper over the initial file promise passed to this loader.\n\t */\n\tprivate _filePromiseWrapper: FilePromiseWrapper;\n\n\t/**\n\t * Adapter instance associated with this file loader.\n\t */\n\tprivate _adapter: UploadAdapter;\n\n\t/**\n\t * FileReader used by FileLoader.\n\t */\n\tprivate _reader: FileReader;\n\n\t/**\n\t * Current status of FileLoader. It can be one of the following:\n\t *\n\t * * 'idle',\n\t * * 'reading',\n\t * * 'uploading',\n\t * * 'aborted',\n\t * * 'error'.\n\t *\n\t * When reading status can change in a following way:\n\t *\n\t * `idle` -> `reading` -> `idle`\n\t * `idle` -> `reading -> `aborted`\n\t * `idle` -> `reading -> `error`\n\t *\n\t * When uploading status can change in a following way:\n\t *\n\t * `idle` -> `uploading` -> `idle`\n\t * `idle` -> `uploading` -> `aborted`\n\t * `idle` -> `uploading` -> `error`\n\t *\n\t * @readonly\n\t * @observable\n\t */\n\tdeclare public status: 'idle' | 'reading' | 'uploading' | 'aborted' | 'error';\n\n\t/**\n\t * Number of bytes uploaded.\n\t *\n\t * @readonly\n\t * @observable\n\t */\n\tdeclare public uploaded: number;\n\n\t/**\n\t * Number of total bytes to upload.\n\t *\n\t * @readonly\n\t * @observable\n\t */\n\tdeclare public uploadTotal: number | null;\n\n\t/**\n\t * Upload progress in percents.\n\t *\n\t * @readonly\n\t * @observable\n\t */\n\tdeclare public uploadedPercent: number;\n\n\t/**\n\t * Response of the upload.\n\t *\n\t * @readonly\n\t * @observable\n\t */\n\tdeclare public uploadResponse?: UploadResponse | null;\n\n\t/**\n\t * Creates a new instance of `FileLoader`.\n\t *\n\t * @param filePromise A promise which resolves to a file instance.\n\t * @param uploadAdapterCreator The function which returns {@link module:upload/filerepository~UploadAdapter} instance.\n\t */\n\tconstructor( filePromise: Promise<File>, uploadAdapterCreator: ( loader: FileLoader ) => UploadAdapter ) {\n\t\tsuper();\n\n\t\tthis.id = uid();\n\t\tthis._filePromiseWrapper = this._createFilePromiseWrapper( filePromise );\n\t\tthis._adapter = uploadAdapterCreator( this );\n\t\tthis._reader = new FileReader();\n\n\t\tthis.set( 'status', 'idle' );\n\t\tthis.set( 'uploaded', 0 );\n\t\tthis.set( 'uploadTotal', null );\n\n\t\tthis.bind( 'uploadedPercent' ).to( this, 'uploaded', this, 'uploadTotal', ( uploaded, total ) => {\n\t\t\treturn total ? ( uploaded / total * 100 ) : 0;\n\t\t} );\n\n\t\tthis.set( 'uploadResponse', null );\n\t}\n\n\t/**\n\t * A `Promise` which resolves to a `File` instance associated with this file loader.\n\t */\n\tpublic get file(): Promise<File | null> {\n\t\tif ( !this._filePromiseWrapper ) {\n\t\t\t// Loader was destroyed, return promise which resolves to null.\n\t\t\treturn Promise.resolve( null );\n\t\t} else {\n\t\t\t// The `this._filePromiseWrapper.promise` is chained and not simply returned to handle a case when:\n\t\t\t//\n\t\t\t//\t\t* The `loader.file.then( ... )` is called by external code (returned promise is pending).\n\t\t\t//\t\t* Then `loader._destroy()` is called (call is synchronous) which destroys the `loader`.\n\t\t\t//\t\t* Promise returned by the first `loader.file.then( ... )` call is resolved.\n\t\t\t//\n\t\t\t// Returning `this._filePromiseWrapper.promise` will still resolve to a `File` instance so there\n\t\t\t// is an additional check needed in the chain to see if `loader` was destroyed in the meantime.\n\t\t\treturn this._filePromiseWrapper.promise.then( file => this._filePromiseWrapper ? file : null );\n\t\t}\n\t}\n\n\t/**\n\t * Returns the file data. To read its data, you need for first load the file\n\t * by using the {@link module:upload/filerepository~FileLoader#read `read()`} method.\n\t */\n\tpublic get data(): string | undefined {\n\t\treturn this._reader.data;\n\t}\n\n\t/**\n\t * Reads file using {@link module:upload/filereader~FileReader}.\n\t *\n\t * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `filerepository-read-wrong-status` when status\n\t * is different than `idle`.\n\t *\n\t * Example usage:\n\t *\n\t * ```ts\n\t * fileLoader.read()\n\t * \t.then( data => { ... } )\n\t * \t.catch( err => {\n\t * \t\tif ( err === 'aborted' ) {\n\t * \t\t\tconsole.log( 'Reading aborted.' );\n\t * \t\t} else {\n\t * \t\t\tconsole.log( 'Reading error.', err );\n\t * \t\t}\n\t * \t} );\n\t * ```\n\t *\n\t * @returns Returns promise that will be resolved with read data. Promise will be rejected if error\n\t * occurs or if read process is aborted.\n\t */\n\tpublic read(): Promise<string> {\n\t\tif ( this.status != 'idle' ) {\n\t\t\t/**\n\t\t\t * You cannot call read if the status is different than idle.\n\t\t\t *\n\t\t\t * @error filerepository-read-wrong-status\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'filerepository-read-wrong-status', this );\n\t\t}\n\n\t\tthis.status = 'reading';\n\n\t\treturn this.file\n\t\t\t.then( file => this._reader.read( file! ) )\n\t\t\t.then( data => {\n\t\t\t\t// Edge case: reader was aborted after file was read - double check for proper status.\n\t\t\t\t// It can happen when image was deleted during its upload.\n\t\t\t\tif ( this.status !== 'reading' ) {\n\t\t\t\t\tthrow this.status;\n\t\t\t\t}\n\n\t\t\t\tthis.status = 'idle';\n\n\t\t\t\treturn data;\n\t\t\t} )\n\t\t\t.catch( err => {\n\t\t\t\tif ( err === 'aborted' ) {\n\t\t\t\t\tthis.status = 'aborted';\n\t\t\t\t\tthrow 'aborted';\n\t\t\t\t}\n\n\t\t\t\tthis.status = 'error';\n\t\t\t\tthrow this._reader.error ? this._reader.error : err;\n\t\t\t} );\n\t}\n\n\t/**\n\t * Reads file using the provided {@link module:upload/filerepository~UploadAdapter}.\n\t *\n\t * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `filerepository-upload-wrong-status` when status\n\t * is different than `idle`.\n\t * Example usage:\n\t *\n\t * ```ts\n\t * fileLoader.upload()\n\t * \t.then( data => { ... } )\n\t * \t.catch( e => {\n\t * \t\tif ( e === 'aborted' ) {\n\t * \t\t\tconsole.log( 'Uploading aborted.' );\n\t * \t\t} else {\n\t * \t\t\tconsole.log( 'Uploading error.', e );\n\t * \t\t}\n\t * \t} );\n\t * ```\n\t *\n\t * @returns Returns promise that will be resolved with response data. Promise will be rejected if error\n\t * occurs or if read process is aborted.\n\t */\n\tpublic upload(): Promise<UploadResponse> {\n\t\tif ( this.status != 'idle' ) {\n\t\t\t/**\n\t\t\t * You cannot call upload if the status is different than idle.\n\t\t\t *\n\t\t\t * @error filerepository-upload-wrong-status\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'filerepository-upload-wrong-status', this );\n\t\t}\n\n\t\tthis.status = 'uploading';\n\n\t\treturn this.file\n\t\t\t.then( () => this._adapter.upload() )\n\t\t\t.then( data => {\n\t\t\t\tthis.uploadResponse = data;\n\t\t\t\tthis.status = 'idle';\n\n\t\t\t\treturn data;\n\t\t\t} )\n\t\t\t.catch( err => {\n\t\t\t\tif ( this.status === 'aborted' ) {\n\t\t\t\t\tthrow 'aborted';\n\t\t\t\t}\n\n\t\t\t\tthis.status = 'error';\n\t\t\t\tthrow err;\n\t\t\t} );\n\t}\n\n\t/**\n\t * Aborts loading process.\n\t */\n\tpublic abort(): void {\n\t\tconst status = this.status;\n\t\tthis.status = 'aborted';\n\n\t\tif ( !this._filePromiseWrapper.isFulfilled ) {\n\t\t\t// Edge case: file loader is aborted before read() is called\n\t\t\t// so it might happen that no one handled the rejection of this promise.\n\t\t\t// See https://github.com/ckeditor/ckeditor5-upload/pull/100\n\t\t\tthis._filePromiseWrapper.promise.catch( () => {} );\n\n\t\t\tthis._filePromiseWrapper.rejecter( 'aborted' );\n\t\t} else if ( status == 'reading' ) {\n\t\t\tthis._reader.abort();\n\t\t} else if ( status == 'uploading' && this._adapter.abort ) {\n\t\t\tthis._adapter.abort();\n\t\t}\n\n\t\tthis._destroy();\n\t}\n\n\t/**\n\t * Performs cleanup.\n\t *\n\t * @internal\n\t */\n\tpublic _destroy(): void {\n\t\tthis._filePromiseWrapper = undefined as any;\n\t\tthis._reader = undefined as any;\n\t\tthis._adapter = undefined as any;\n\t\tthis.uploadResponse = undefined;\n\t}\n\n\t/**\n\t * Wraps a given file promise into another promise giving additional\n\t * control (resolving, rejecting, checking if fulfilled) over it.\n\t *\n\t * @param filePromise The initial file promise to be wrapped.\n\t */\n\tprivate _createFilePromiseWrapper( filePromise: Promise<File> ): FilePromiseWrapper {\n\t\tconst wrapper: Partial<FilePromiseWrapper> = {};\n\n\t\twrapper.promise = new Promise<File>( ( resolve, reject ) => {\n\t\t\twrapper.rejecter = reject;\n\t\t\twrapper.isFulfilled = false;\n\n\t\t\tfilePromise\n\t\t\t\t.then( file => {\n\t\t\t\t\twrapper.isFulfilled = true;\n\t\t\t\t\tresolve( file );\n\t\t\t\t} )\n\t\t\t\t.catch( err => {\n\t\t\t\t\twrapper.isFulfilled = true;\n\t\t\t\t\treject( err );\n\t\t\t\t} );\n\t\t} );\n\n\t\treturn wrapper as FilePromiseWrapper;\n\t}\n}\n\nexport { FileLoader };\n\n/**\n * Upload adapter interface used by the {@link module:upload/filerepository~FileRepository file repository}\n * to handle file upload. An upload adapter is a bridge between the editor and server that handles file uploads.\n * It should contain a logic necessary to initiate an upload process and monitor its progress.\n *\n * Learn how to develop your own upload adapter for CKEditor 5 in the\n * {@glink framework/deep-dive/upload-adapter \"Custom upload adapter\"} guide.\n *\n * @interface UploadAdapter\n */\nexport interface UploadAdapter {\n\n\t/**\n\t * Executes the upload process.\n\t * This method should return a promise that will resolve when data will be uploaded to server. Promise should be\n\t * resolved with an object containing information about uploaded file:\n\t *\n\t * ```json\n\t * {\n\t * \tdefault: 'http://server/default-size.image.png'\n\t * }\n\t * ```\n\t *\n\t * Additionally, other image sizes can be provided:\n\t *\n\t * ```json\n\t * {\n\t * \tdefault: 'http://server/default-size.image.png',\n\t * \t'160': 'http://server/size-160.image.png',\n\t * \t'500': 'http://server/size-500.image.png',\n\t * \t'1000': 'http://server/size-1000.image.png',\n\t * \t'1052': 'http://server/default-size.image.png'\n\t * }\n\t * ```\n\t *\n\t * You can also pass additional properties from the server. In this case you need to wrap URLs\n\t * in the `urls` object and pass additional properties along the `urls` property.\n\t *\n\t * ```json\n\t * {\n\t * \tmyCustomProperty: 'foo',\n\t * \turls: {\n\t * \t\tdefault: 'http://server/default-size.image.png',\n\t * \t\t'160': 'http://server/size-160.image.png',\n\t * \t\t'500': 'http://server/size-500.image.png',\n\t * \t\t'1000': 'http://server/size-1000.image.png',\n\t * \t\t'1052': 'http://server/default-size.image.png'\n\t * \t}\n\t * }\n\t * ```\n\t *\n\t * NOTE: When returning multiple images, the widest returned one should equal the default one. It is essential to\n\t * correctly set `width` attribute of the image.\n\t *\n\t * Take a look at {@link module:upload/filerepository~UploadAdapter example Adapter implementation} and\n\t * {@link module:upload/filerepository~FileRepository#createUploadAdapter createUploadAdapter method}.\n\t *\n\t * @returns Promise that should be resolved when data is uploaded.\n\t */\n\tupload(): Promise<UploadResponse>;\n\n\t/**\n\t * Aborts the upload process.\n\t * After aborting it should reject promise returned from {@link #upload upload()}.\n\t *\n\t * Take a look at {@link module:upload/filerepository~UploadAdapter example Adapter implementation} and\n\t * {@link module:upload/filerepository~FileRepository#createUploadAdapter createUploadAdapter method}.\n\t */\n\tabort?(): void;\n}\n\nexport type UploadResponse = Record<string, unknown>;\n\n/**\n * Object returned by {@link module:upload/filerepository~FileLoader#_createFilePromiseWrapper} method\n * to add more control over the initial file promise passed to {@link module:upload/filerepository~FileLoader}.\n */\ntype FilePromiseWrapper = {\n\n\t/**\n\t * Wrapper promise which can be chained for further processing.\n\t */\n\tpromise: Promise<File>;\n\n\t/**\n\t * Rejects the promise when called.\n\t */\n\trejecter: ( reason?: unknown ) => void;\n\n\t/**\n\t * Whether original promise is already fulfilled.\n\t */\n\tisFulfilled: boolean;\n};\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n\n/**\n * @module upload/adapters/base64uploadadapter\n */\n\nimport { Plugin, type PluginDependenciesOf } from '@ckeditor/ckeditor5-core';\nimport { FileRepository, type UploadResponse, type FileLoader, type UploadAdapter } from '../filerepository.js';\n\ntype DomFileReader = globalThis.FileReader;\n\n/**\n * A plugin that converts images inserted into the editor into [Base64 strings](https://en.wikipedia.org/wiki/Base64)\n * in the {@glink getting-started/setup/getting-and-setting-data editor output}.\n *\n * This kind of image upload does not require server processing – images are stored with the rest of the text and\n * displayed by the web browser without additional requests.\n *\n * Check out the {@glink features/images/image-upload/image-upload comprehensive \"Image upload overview\"} to learn about\n * other ways to upload images into CKEditor 5.\n */\nexport class Base64UploadAdapter extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get requires(): PluginDependenciesOf<[ FileRepository ]> {\n\t\treturn [ FileRepository ];\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get pluginName() {\n\t\treturn 'Base64UploadAdapter' as const;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t * @internal\n\t */\n\tpublic static get licenseFeatureCode(): string {\n\t\treturn 'B64A';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static override get isOfficialPlugin(): true {\n\t\treturn true;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static override get isPremiumPlugin(): true {\n\t\treturn true;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic init(): void {\n\t\tthis.editor.plugins.get( FileRepository ).createUploadAdapter = loader => new Adapter( loader );\n\t}\n}\n\n/**\n * The upload adapter that converts images inserted into the editor into Base64 strings.\n */\nclass Adapter implements UploadAdapter {\n\t/**\n\t * `FileLoader` instance to use during the upload.\n\t */\n\tpublic loader: FileLoader;\n\n\tpublic reader?: DomFileReader;\n\n\t/**\n\t * Creates a new adapter instance.\n\t */\n\tconstructor( loader: FileLoader ) {\n\t\tthis.loader = loader;\n\t}\n\n\t/**\n\t * Starts the upload process.\n\t *\n\t * @see module:upload/filerepository~UploadAdapter#upload\n\t */\n\tpublic upload(): Promise<UploadResponse> {\n\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\tconst reader = this.reader = new window.FileReader();\n\n\t\t\treader.addEventListener( 'load', () => {\n\t\t\t\tresolve( { default: reader.result } );\n\t\t\t} );\n\n\t\t\treader.addEventListener( 'error', err => {\n\t\t\t\treject( err );\n\t\t\t} );\n\n\t\t\treader.addEventListener( 'abort', () => {\n\t\t\t\treject();\n\t\t\t} );\n\n\t\t\tthis.loader.file.then( file => {\n\t\t\t\treader.readAsDataURL( file! );\n\t\t\t} );\n\t\t} );\n\t}\n\n\t/**\n\t * Aborts the upload process.\n\t *\n\t * @see module:upload/filerepository~UploadAdapter#abort\n\t */\n\tpublic abort(): void {\n\t\tthis.reader!.abort();\n\t}\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n\n/**\n * @module upload/adapters/simpleuploadadapter\n */\n\nimport { Plugin, type PluginDependenciesOf } from '@ckeditor/ckeditor5-core';\nimport { FileRepository, type UploadResponse, type FileLoader, type UploadAdapter } from '../filerepository.js';\nimport type { SimpleUploadConfig } from '../uploadconfig.js';\nimport { logWarning } from '@ckeditor/ckeditor5-utils';\n\n/**\n * The Simple upload adapter allows uploading images to an application running on your server using\n * the [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) API with a\n * minimal {@link module:upload/uploadconfig~SimpleUploadConfig editor configuration}.\n *\n * ```ts\n * ClassicEditor\n * \t.create( {\n * \t\tsimpleUpload: {\n * \t\t\tuploadUrl: 'http://example.com',\n * \t\t\theaders: {\n * \t\t\t\t...\n * \t\t\t}\n * \t\t}\n * \t} )\n * \t.then( ... )\n * \t.catch( ... );\n * ```\n *\n * See the {@glink features/images/image-upload/simple-upload-adapter \"Simple upload adapter\"} guide to learn how to\n * learn more about the feature (configuration, server–side requirements, etc.).\n *\n * Check out the {@glink features/images/image-upload/image-upload comprehensive \"Image upload overview\"} to learn about\n * other ways to upload images into CKEditor 5.\n */\nexport class SimpleUploadAdapter extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get requires(): PluginDependenciesOf<[ FileRepository ]> {\n\t\treturn [ FileRepository ];\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get pluginName() {\n\t\treturn 'SimpleUploadAdapter' as const;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t * @internal\n\t */\n\tpublic static get licenseFeatureCode(): string {\n\t\treturn 'SUA';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static override get isOfficialPlugin(): true {\n\t\treturn true;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static override get isPremiumPlugin(): true {\n\t\treturn true;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic init(): void {\n\t\tconst options = this.editor.config.get( 'simpleUpload' );\n\n\t\tif ( !options ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( !options.uploadUrl ) {\n\t\t\t/**\n\t\t\t * The {@link module:upload/uploadconfig~SimpleUploadConfig#uploadUrl `config.simpleUpload.uploadUrl`}\n\t\t\t * configuration required by the {@link module:upload/adapters/simpleuploadadapter~SimpleUploadAdapter `SimpleUploadAdapter`}\n\t\t\t * is missing. Make sure the correct URL is specified for the image upload to work properly.\n\t\t\t *\n\t\t\t * @error simple-upload-adapter-missing-uploadurl\n\t\t\t */\n\t\t\tlogWarning( 'simple-upload-adapter-missing-uploadurl' );\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.editor.plugins.get( FileRepository ).createUploadAdapter = loader => {\n\t\t\treturn new Adapter( loader, options );\n\t\t};\n\t}\n}\n\n/**\n * Upload adapter.\n */\nclass Adapter implements UploadAdapter {\n\t/**\n\t * FileLoader instance to use during the upload.\n\t */\n\tpublic loader: FileLoader;\n\n\t/**\n\t * The configuration of the adapter.\n\t */\n\tpublic options: SimpleUploadConfig;\n\n\tprivate xhr?: XMLHttpRequest;\n\n\t/**\n\t * Creates a new adapter instance.\n\t */\n\tconstructor( loader: FileLoader, options: SimpleUploadConfig ) {\n\t\tthis.loader = loader;\n\t\tthis.options = options;\n\t}\n\n\t/**\n\t * Starts the upload process.\n\t *\n\t * @see module:upload/filerepository~UploadAdapter#upload\n\t */\n\tpublic upload(): Promise<UploadResponse> {\n\t\treturn this.loader.file\n\t\t\t.then( file => new Promise( ( resolve, reject ) => {\n\t\t\t\tthis._initRequest();\n\t\t\t\tthis._initListeners( resolve, reject, file! );\n\t\t\t\tthis._sendRequest( file! );\n\t\t\t} ) );\n\t}\n\n\t/**\n\t * Aborts the upload process.\n\t *\n\t * @see module:upload/filerepository~UploadAdapter#abort\n\t */\n\tpublic abort(): void {\n\t\tif ( this.xhr ) {\n\t\t\tthis.xhr.abort();\n\t\t}\n\t}\n\n\t/**\n\t * Initializes the `XMLHttpRequest` object using the URL specified as\n\t * {@link module:upload/uploadconfig~SimpleUploadConfig#uploadUrl `simpleUpload.uploadUrl`} in the editor's\n\t * configuration.\n\t */\n\tprivate _initRequest(): void {\n\t\tconst xhr = this.xhr = new XMLHttpRequest();\n\n\t\txhr.open( 'POST', this.options.uploadUrl, true );\n\t\txhr.responseType = 'json';\n\t}\n\n\t/**\n\t * Initializes XMLHttpRequest listeners\n\t *\n\t * @param resolve Callback function to be called when the request is successful.\n\t * @param reject Callback function to be called when the request cannot be completed.\n\t * @param file Native File object.\n\t */\n\tprivate _initListeners(\n\t\tresolve: ( result: UploadResponse ) => void,\n\t\treject: ( message?: string ) => void,\n\t\tfile: File\n\t): void {\n\t\tconst xhr = this.xhr!;\n\t\tconst loader = this.loader;\n\t\tconst genericErrorText = `Couldn't upload file: ${ file.name }.`;\n\n\t\txhr.addEventListener( 'error', () => reject( genericErrorText ) );\n\t\txhr.addEventListener( 'abort', () => reject() );\n\t\txhr.addEventListener( 'load', () => {\n\t\t\tconst response = xhr.response;\n\n\t\t\tif ( !response || response.error ) {\n\t\t\t\treturn reject( response && response.error && response.error.message ? response.error.message : genericErrorText );\n\t\t\t}\n\n\t\t\tconst urls = response.url ? { default: response.url } : response.urls;\n\n\t\t\t// Resolve with the normalized `urls` property and pass the rest of the response\n\t\t\t// to allow customizing the behavior of features relying on the upload adapters.\n\t\t\tresolve( {\n\t\t\t\t...response,\n\t\t\t\turls\n\t\t\t} );\n\t\t} );\n\n\t\t// Upload progress when it is supported.\n\t\t/* v8 ignore else -- @preserve */\n\t\tif ( xhr.upload ) {\n\t\t\txhr.upload.addEventListener( 'progress', evt => {\n\t\t\t\t/* v8 ignore else -- @preserve */\n\t\t\t\tif ( evt.lengthComputable ) {\n\t\t\t\t\tloader.uploadTotal = evt.total;\n\t\t\t\t\tloader.uploaded = evt.loaded;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\t/**\n\t * Prepares the data and sends the request.\n\t *\n\t * @param file File instance to be uploaded.\n\t */\n\tprivate _sendRequest( file: File ): void {\n\t\t// Set headers if specified.\n\t\tlet headers = this.options.headers || {};\n\n\t\tif ( typeof headers === 'function' ) {\n\t\t\theaders = headers( file );\n\t\t}\n\n\t\t// Use the withCredentials flag if specified.\n\t\tconst withCredentials = this.options.withCredentials || false;\n\n\t\tfor ( const headerName of Object.keys( headers ) ) {\n\t\t\tthis.xhr!.setRequestHeader( headerName, headers[ headerName ] );\n\t\t}\n\n\t\tthis.xhr!.withCredentials = withCredentials;\n\n\t\t// Prepare the form data.\n\t\tconst data = new FormData();\n\n\t\tdata.append( 'upload', file );\n\n\t\t// Send the request.\n\t\tthis.xhr!.send( data );\n\t}\n}\n"]}