diff --git a/Build/package-lock.json b/Build/package-lock.json index 986955fae73795a6594794c062cdcfdd3ebb91a3..ea2cb61ba212a9f5655d3d1e4bac7426f9532a3c 100644 --- a/Build/package-lock.json +++ b/Build/package-lock.json @@ -148,7 +148,7 @@ "stylelint": "^14.11.0", "stylelint-order": "^5.0.0", "stylelint-scss": "^4.6.0", - "terser": "^5.17.1", + "terser": "^5.22.0", "typescript": "~5.2.2" }, "engines": { @@ -1502,9 +1502,9 @@ } }, "node_modules/@jridgewell/source-map": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", - "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.5.tgz", + "integrity": "sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==", "dependencies": { "@jridgewell/gen-mapping": "^0.3.0", "@jridgewell/trace-mapping": "^0.3.9" @@ -3490,9 +3490,9 @@ } }, "node_modules/acorn": { - "version": "8.8.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz", - "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==", + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "bin": { "acorn": "bin/acorn" }, @@ -12508,12 +12508,12 @@ } }, "node_modules/terser": { - "version": "5.17.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.17.1.tgz", - "integrity": "sha512-hVl35zClmpisy6oaoKALOpS0rDYLxRFLHhRuDlEGTKey9qHjS1w9GMORjuwIMt70Wan4lwsLYyWDVnWgF+KUEw==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.22.0.tgz", + "integrity": "sha512-hHZVLgRA2z4NWcN6aS5rQDc+7Dcy58HOf2zbYwmFcQ+ua3h6eEFf5lIDKTzbWwlazPyOZsFQO8V80/IjVNExEw==", "dependencies": { - "@jridgewell/source-map": "^0.3.2", - "acorn": "^8.5.0", + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.8.2", "commander": "^2.20.0", "source-map-support": "~0.5.20" }, diff --git a/Build/package.json b/Build/package.json index ebbc768191bcb5115c4cfe6645ce5b6f3a335090..da84998cc851966266df465ea2fec8e5fd9d8968 100644 --- a/Build/package.json +++ b/Build/package.json @@ -71,7 +71,7 @@ "stylelint": "^14.11.0", "stylelint-order": "^5.0.0", "stylelint-scss": "^4.6.0", - "terser": "^5.17.1", + "terser": "^5.22.0", "typescript": "~5.2.2" }, "scripts": { diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/drag-uploader.js b/typo3/sysext/backend/Resources/Public/JavaScript/drag-uploader.js index 63d419bd4a8da1fd29322301a437f7893eeca132..6d07d9bb1ecc28508e51b4b7435245f3e6219006 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/drag-uploader.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/drag-uploader.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -import DocumentService from"@typo3/core/document-service.js";import $ from"jquery";import{DateTime}from"luxon";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import{MessageUtility}from"@typo3/backend/utility/message-utility.js";import NProgress from"nprogress";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import{default as Modal,Sizes as ModalSizes}from"@typo3/backend/modal.js";import Notification from"@typo3/backend/notification.js";import ImmediateAction from"@typo3/backend/action-button/immediate-action.js";import Md5 from"@typo3/backend/hashing/md5.js";import"@typo3/backend/element/icon-element.js";var Action;!function(e){e.OVERRIDE="replace",e.RENAME="rename",e.SKIP="cancel",e.USE_EXISTING="useExisting"}(Action||(Action={}));class DragUploaderPlugin{constructor(e){this.askForOverride=[],this.percentagePerFile=1,this.dragStartedInDocument=!1,this.hideDropzone=e=>{e.stopPropagation(),e.preventDefault(),this.$dropzone.hide(),this.$dropzone.removeClass("drop-status-ok"),this.manuallyTriggered=!1},this.dragFileIntoDocument=e=>(this.dragStartedInDocument||(e.stopPropagation(),e.preventDefault(),$(e.currentTarget).addClass("drop-in-progress"),this.$element.get(0)?.offsetParent&&this.showDropzone()),!1),this.dragAborted=e=>(e.stopPropagation(),e.preventDefault(),$(e.currentTarget).removeClass("drop-in-progress"),this.dragStartedInDocument=!1,!1),this.ignoreDrop=e=>(e.stopPropagation(),e.preventDefault(),this.dragAborted(e),!1),this.handleDrop=e=>{this.ignoreDrop(e),this.hideDropzone(e),this.processFiles(e.originalEvent.dataTransfer.files)},this.fileInDropzone=()=>{this.$dropzone.addClass("drop-status-ok")},this.fileOutOfDropzone=()=>{this.$dropzone.removeClass("drop-status-ok"),this.manuallyTriggered||this.$dropzone.hide()},this.$body=$("body"),this.$element=$(e);const t=void 0!==this.$element.data("dropzoneTrigger");this.$trigger=$(this.$element.data("dropzoneTrigger")),this.defaultAction=this.$element.data("defaultAction")||Action.SKIP,this.$dropzone=$("<div />").addClass("dropzone").hide(),this.irreObjectUid=this.$element.data("fileIrreObject");const i=this.$element.data("dropzoneTarget");if(this.irreObjectUid&&0!==this.$element.nextAll(i).length?(this.dropZoneInsertBefore=!0,this.$dropzone.insertBefore(i)):(this.dropZoneInsertBefore=!1,this.$dropzone.insertAfter(i)),this.$dropzoneMask=$("<div />").addClass("dropzone-mask").appendTo(this.$dropzone),this.fileInput=document.createElement("input"),this.fileInput.setAttribute("type","file"),this.fileInput.setAttribute("multiple","multiple"),this.fileInput.setAttribute("name","files[]"),this.fileInput.classList.add("upload-file-picker"),this.$body.append(this.fileInput),this.$fileList=$(this.$element.data("progress-container")),this.fileListColumnCount=$("thead tr:first th",this.$fileList).length+1,this.filesExtensionsAllowed=this.$element.data("file-allowed"),this.filesExtensionsDisallowed=this.$element.data("file-disallowed"),this.fileDenyPattern=this.$element.data("file-deny-pattern")?new RegExp(this.$element.data("file-deny-pattern"),"i"):null,this.maxFileSize=parseInt(this.$element.data("max-file-size"),10),this.target=this.$element.data("target-folder"),this.reloadUrl=this.$element.data("reload-url"),this.browserCapabilities={fileReader:"undefined"!=typeof FileReader,DnD:"draggable"in document.createElement("span"),Progress:"upload"in new XMLHttpRequest},this.browserCapabilities.DnD){if(this.$body.on("dragstart",(()=>{this.dragStartedInDocument=!0})),this.$body.on("dragover",this.dragFileIntoDocument),this.$body.on("dragend",this.dragAborted),this.$body.on("drop",this.ignoreDrop),this.$dropzone.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragleave",this.fileOutOfDropzone),this.$dropzoneMask.on("drop",(e=>this.handleDrop(e))),this.$dropzone.prepend('<button type="button" class="dropzone-hint" aria-labelledby="dropzone-title"><div class="dropzone-hint-media"><div class="dropzone-hint-icon"></div></div><div class="dropzone-hint-body"><h3 id="dropzone-title" class="dropzone-hint-title">'+TYPO3.lang["file_upload.dropzonehint.title"]+'</h3><p class="dropzone-hint-message">'+TYPO3.lang["file_upload.dropzonehint.message"]+"</p></div></div>").on("click",(()=>{this.fileInput.click()})),$('<button type="button" />').addClass("dropzone-close").attr("aria-label",TYPO3.lang["file_upload.dropzone.close"]).on("click",this.hideDropzone).appendTo(this.$dropzone),0===this.$fileList.length){this.$fileList=$("<table />").attr("id","typo3-filelist").addClass("table table-striped table-hover upload-queue").html("<tbody></tbody>");const e=$("<div/>",{class:"table-fit"}).hide().append(this.$fileList);this.dropZoneInsertBefore?e.insertAfter(this.$dropzone):e.insertBefore(this.$dropzone),this.fileListColumnCount=8,this.manualTable=!0}this.fileInput.addEventListener("change",(e=>{this.hideDropzone(e),this.processFiles(this.fileInput.files)})),document.addEventListener("keydown",(e=>{"Escape"===e.code&&this.$dropzone.is(":visible")&&this.hideDropzone(e)})),this.bindUploadButton(!0===t?this.$trigger:this.$element)}else console.warn("Browser has no Drag and drop capabilities; cannot initialize DragUploader")}showDropzone(){this.$dropzone.show()}processFiles(e){this.queueLength=e.length,this.$fileList.parent().is(":visible")||(this.$fileList.parent().show(),this.$fileList.closest(".t3-filelist-table-container")?.removeClass("hidden"),this.$fileList.closest("form")?.find(".t3-filelist-info-container")?.hide()),NProgress.start(),this.percentagePerFile=1/e.length;const t=[];Array.from(e).forEach((e=>{const i=new AjaxRequest(TYPO3.settings.ajaxUrls.file_exists).withQueryArguments({fileName:e.name,fileTarget:this.target}).get({cache:"no-cache"}).then((async t=>{const i=await t.resolve();void 0!==i.uid?(this.askForOverride.push({original:i,uploaded:e,action:this.irreObjectUid?Action.USE_EXISTING:this.defaultAction}),NProgress.inc(this.percentagePerFile)):new FileQueueItem(this,e,Action.SKIP)}));t.push(i)})),Promise.all(t).then((()=>{this.drawOverrideModal(),NProgress.done()})),this.fileInput.value=""}bindUploadButton(e){e.on("click",(e=>{e.preventDefault(),this.fileInput.click(),this.showDropzone(),this.manuallyTriggered=!0}))}decrementQueueLength(e){if(this.queueLength>0&&(this.queueLength--,0===this.queueLength)){const t=e&&e.length?5e3:0;if(t)for(const t of e)Notification.showMessage(t.title,t.message,t.severity);this.reloadUrl&&setTimeout((()=>{Notification.info(TYPO3.lang["file_upload.reload.filelist"],TYPO3.lang["file_upload.reload.filelist.message"],10,[{label:TYPO3.lang["file_upload.reload.filelist.actions.dismiss"]},{label:TYPO3.lang["file_upload.reload.filelist.actions.reload"],action:new ImmediateAction((()=>{top.list_frame.document.location.href=this.reloadUrl}))}])}),t)}}drawOverrideModal(){const e=Object.keys(this.askForOverride).length;if(0===e)return;const t=$("<div/>").append($("<p/>").text(TYPO3.lang["file_upload.existingfiles.description"]),$("<table/>",{class:"table"}).append($("<thead/>").append($("<tr />").append($("<th/>"),$("<th/>").text(TYPO3.lang["file_upload.header.originalFile"]),$("<th/>").text(TYPO3.lang["file_upload.header.uploadedFile"]),$("<th/>").text(TYPO3.lang["file_upload.header.action"])))));for(let i=0;i<e;++i){const e=$("<tr />").append($("<td />").append(""!==this.askForOverride[i].original.thumbUrl?$("<img />",{src:this.askForOverride[i].original.thumbUrl,height:40}):$(this.askForOverride[i].original.icon)),$("<td />").html(this.askForOverride[i].original.name+" ("+DragUploader.fileSizeAsString(this.askForOverride[i].original.size)+")<br>"+DateTime.fromSeconds(this.askForOverride[i].original.mtime).toLocaleString(DateTime.DATETIME_MED)),$("<td />").html(this.askForOverride[i].uploaded.name+" ("+DragUploader.fileSizeAsString(this.askForOverride[i].uploaded.size)+")<br>"+DateTime.fromMillis(this.askForOverride[i].uploaded.lastModified).toLocaleString(DateTime.DATETIME_MED)),$("<td />").append($("<select />",{class:"form-select t3js-actions","data-override":i}).append(this.irreObjectUid?$("<option/>").val(Action.USE_EXISTING).text(TYPO3.lang["file_upload.actions.use_existing"]):"",$("<option />",{selected:this.defaultAction===Action.SKIP}).val(Action.SKIP).text(TYPO3.lang["file_upload.actions.skip"]),$("<option />",{selected:this.defaultAction===Action.RENAME}).val(Action.RENAME).text(TYPO3.lang["file_upload.actions.rename"]),$("<option />",{selected:this.defaultAction===Action.OVERRIDE}).val(Action.OVERRIDE).text(TYPO3.lang["file_upload.actions.override"]))));t.find("table").append("<tbody />").append(e)}const i=Modal.advanced({title:TYPO3.lang["file_upload.existingfiles.title"],content:t,severity:SeverityEnum.warning,buttons:[{text:$(this).data("button-close-text")||TYPO3.lang["file_upload.button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:$(this).data("button-ok-text")||TYPO3.lang["file_upload.button.continue"]||"Continue with selected actions",btnClass:"btn-warning",name:"continue"}],additionalCssClasses:["modal-inner-scroll"],size:ModalSizes.large,callback:e=>{$(e).find(".modal-footer").prepend($("<label/>").text(TYPO3.lang["file_upload.actions.all.label"]),$("<span/>").append($("<select/>",{class:"form-select t3js-actions-all"}).append($("<option/>").val("").text(TYPO3.lang["file_upload.actions.all.empty"]),this.irreObjectUid?$("<option/>").val(Action.USE_EXISTING).text(TYPO3.lang["file_upload.actions.all.use_existing"]):"",$("<option/>",{selected:this.defaultAction===Action.SKIP}).val(Action.SKIP).text(TYPO3.lang["file_upload.actions.all.skip"]),$("<option/>",{selected:this.defaultAction===Action.RENAME}).val(Action.RENAME).text(TYPO3.lang["file_upload.actions.all.rename"]),$("<option/>",{selected:this.defaultAction===Action.OVERRIDE}).val(Action.OVERRIDE).text(TYPO3.lang["file_upload.actions.all.override"]))))}}),s=$(i);s.on("change",".t3js-actions-all",(e=>{const t=$(e.currentTarget).val();if(""!==t)for(const e of i.querySelectorAll(".t3js-actions")){const i=parseInt(e.dataset.override,10);e.value=t,e.disabled=!0,this.askForOverride[i].action=e.value}else i.querySelectorAll(".t3js-actions").forEach((e=>e.disabled=!1))})),s.on("change",".t3js-actions",(e=>{const t=$(e.currentTarget),i=parseInt(t.data("override"),10);this.askForOverride[i].action=t.val()})),i.addEventListener("button.clicked",(e=>{const t=e.target;if("cancel"===t.name)this.askForOverride=[],Modal.dismiss();else if("continue"===t.name){for(const e of this.askForOverride)e.action===Action.USE_EXISTING?DragUploader.addFileToIrre(this.irreObjectUid,e.original):e.action!==Action.SKIP&&new FileQueueItem(this,e.uploaded,e.action);this.askForOverride=[],i.hideModal()}})),i.addEventListener("typo3-modal-hidden",(()=>{this.askForOverride=[]}))}}class FileQueueItem{constructor(e,t,i){if(this.dragUploader=e,this.file=t,this.override=i,this.$row=$("<tr />").addClass("upload-queue-item uploading"),this.dragUploader.manualTable||(this.$selector=$("<td />").addClass("col-checkbox").appendTo(this.$row)),this.$iconCol=$("<td />",{class:"col-icon"}).appendTo(this.$row),this.$fileName=$("<td />",{class:"col-title col-responsive"}).text(t.name).appendTo(this.$row),this.$progress=$("<td />").attr("colspan",this.dragUploader.fileListColumnCount-this.$row.find("td").length).appendTo(this.$row),this.$progressContainer=$("<div />").addClass("upload-queue-progress").appendTo(this.$progress),this.$progressBar=$("<div />").addClass("upload-queue-progress-bar").appendTo(this.$progressContainer),this.$progressPercentage=$("<span />").addClass("upload-queue-progress-percentage").appendTo(this.$progressContainer),this.$progressMessage=$("<span />").addClass("upload-queue-progress-message").appendTo(this.$progressContainer),0===$("tbody tr.upload-queue-item",this.dragUploader.$fileList).length?(this.$row.prependTo($("tbody",this.dragUploader.$fileList)),this.$row.addClass("last")):this.$row.insertBefore($("tbody tr.upload-queue-item:first",this.dragUploader.$fileList)),this.$selector&&this.$selector.html('<span class="form-check form-check-type-toggle"><input type="checkbox" class="form-check-input t3js-multi-record-selection-check" disabled/></span>'),this.$iconCol.html('<typo3-backend-icon identifier="mimetypes-other-other" />'),this.dragUploader.maxFileSize>0&&this.file.size>this.dragUploader.maxFileSize)this.updateMessage(TYPO3.lang["file_upload.maxFileSizeExceeded"].replace(/\{0\}/g,this.file.name).replace(/\{1\}/g,DragUploader.fileSizeAsString(this.dragUploader.maxFileSize))),this.$row.addClass("error");else if(this.dragUploader.fileDenyPattern&&this.file.name.match(this.dragUploader.fileDenyPattern))this.updateMessage(TYPO3.lang["file_upload.fileNotAllowed"].replace(/\{0\}/g,this.file.name)),this.$row.addClass("error");else if(this.checkAllowedExtensions())if(this.checkDisallowedExtensions()){this.updateMessage("- "+DragUploader.fileSizeAsString(this.file.size));const e=new FormData;e.append("data[upload][1][target]",this.dragUploader.target),e.append("data[upload][1][data]","1"),e.append("overwriteExistingFiles",this.override),e.append("redirect",""),e.append("upload_1",this.file);const t=new XMLHttpRequest;t.onreadystatechange=()=>{if(t.readyState===XMLHttpRequest.DONE)if(200===t.status)try{const e=JSON.parse(t.responseText);e.hasErrors?this.uploadError(t):this.uploadSuccess(e)}catch(e){this.uploadError(t)}else this.uploadError(t)},t.upload.addEventListener("progress",(e=>this.updateProgress(e))),t.open("POST",TYPO3.settings.ajaxUrls.file_process),t.send(e)}else this.updateMessage(TYPO3.lang["file_upload.fileExtensionDisallowed"].replace(/\{0\}/g,this.dragUploader.filesExtensionsDisallowed)),this.$row.addClass("error");else this.updateMessage(TYPO3.lang["file_upload.fileExtensionExpected"].replace(/\{0\}/g,this.dragUploader.filesExtensionsAllowed)),this.$row.addClass("error")}updateMessage(e){this.$progressMessage.text(e)}removeProgress(){this.$progress&&this.$progress.remove()}uploadStart(){this.$progressPercentage.text("(0%)"),this.$progressBar.width("1%"),this.dragUploader.$trigger.trigger("uploadStart",[this])}uploadError(e){const t=TYPO3.lang["file_upload.uploadFailed"].replace(/\{0\}/g,this.file.name);this.updateMessage(t);try{const t=JSON.parse(e.responseText).messages;if(this.$progressPercentage.text(""),t&&t.length)for(const e of t)Notification.showMessage(e.title,e.message,e.severity,10)}catch(e){}this.$row.addClass("error"),this.dragUploader.decrementQueueLength(),this.dragUploader.$trigger.trigger("uploadError",[this,e])}updateProgress(e){const t=Math.round(e.loaded/e.total*100)+"%";this.$progressBar.outerWidth(t),this.$progressPercentage.text(t),this.dragUploader.$trigger.trigger("updateProgress",[this,t,e])}uploadSuccess(e){if(e.upload){this.dragUploader.decrementQueueLength(e.messages),this.$row.removeClass("uploading"),this.$row.prop("data-type","file"),this.$row.prop("data-file-uid",e.upload[0].uid),this.$fileName.text(e.upload[0].name),this.$progressPercentage.text(""),this.$progressMessage.text("100%"),this.$progressBar.outerWidth("100%");const t=String(e.upload[0].id);if(this.$selector){const e=this.$selector.find("input")?.get(0);e&&(e.removeAttribute("disabled"),e.setAttribute("name","CBC[_FILE|"+Md5.hash(t)+"]"),e.setAttribute("value",t))}e.upload[0].icon&&this.$iconCol.html('<a href="#" data-contextmenu-trigger="click" data-contextmenu-uid="'+t+'" data-contextmenu-table="sys_file">'+e.upload[0].icon+"</span></a>"),this.dragUploader.irreObjectUid?(DragUploader.addFileToIrre(this.dragUploader.irreObjectUid,e.upload[0]),setTimeout((()=>{this.$row.remove(),0===$("tr",this.dragUploader.$fileList).length&&(this.dragUploader.$fileList.hide(),this.dragUploader.$fileList.closest(".t3-filelist-table-container")?.addClass("hidden"),this.dragUploader.$trigger.trigger("uploadSuccess",[this,e]))}),3e3)):setTimeout((()=>{this.showFileInfo(e.upload[0]),this.dragUploader.$trigger.trigger("uploadSuccess",[this,e])}),3e3)}}showFileInfo(e){this.removeProgress(),document.querySelector("#filelist-searchterm")?.value&&$("<td />").text(e.path).appendTo(this.$row),$("<td />",{class:"col-control"}).text("").appendTo(this.$row),$("<td />").text(TYPO3.lang["type.file"]+" ("+e.extension.toUpperCase()+")").appendTo(this.$row),$("<td />").text(DragUploader.fileSizeAsString(e.size)).appendTo(this.$row);let t="";e.permissions.read&&(t+='<strong class="text-danger">'+TYPO3.lang["permissions.read"]+"</strong>"),e.permissions.write&&(t+='<strong class="text-danger">'+TYPO3.lang["permissions.write"]+"</strong>"),$("<td />").html(t).appendTo(this.$row),$("<td />").text("-").appendTo(this.$row);for(let e=this.$row.find("td").length;e<this.dragUploader.fileListColumnCount;e++)$("<td />").text("").appendTo(this.$row)}checkAllowedExtensions(){if(!this.dragUploader.filesExtensionsAllowed)return!0;const e=this.file.name.split(".").pop(),t=this.dragUploader.filesExtensionsAllowed.split(",");return-1!==$.inArray(e.toLowerCase(),t)}checkDisallowedExtensions(){if(!this.dragUploader.filesExtensionsDisallowed)return!0;const e=this.file.name.split(".").pop(),t=this.dragUploader.filesExtensionsDisallowed.split(",");return-1===$.inArray(e.toLowerCase(),t)}}class DragUploader{static fileSizeAsString(e){const t=e/1024;let i="";return i=t>1024?(t/1024).toFixed(1)+" MB":t.toFixed(1)+" KB",i}static addFileToIrre(e,t){const i={actionName:"typo3:foreignRelation:insert",objectGroup:e,table:"sys_file",uid:t.uid};MessageUtility.send(i)}static init(){const e=this.options;$.fn.extend({dragUploader:function(e){return this.each(((t,i)=>{const s=$(i);let o=s.data("DragUploaderPlugin");o||s.data("DragUploaderPlugin",o=new DragUploaderPlugin(i)),"string"==typeof e&&o[e]()}))}}),DocumentService.ready().then((()=>{$(".t3js-drag-uploader").dragUploader(e)}));new MutationObserver((()=>{$(".t3js-drag-uploader").dragUploader(e)})).observe(document,{childList:!0,subtree:!0})}}export const initialize=function(){DragUploader.init()};DragUploader.init(); \ No newline at end of file +import DocumentService from"@typo3/core/document-service.js";import $ from"jquery";import{DateTime}from"luxon";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import{MessageUtility}from"@typo3/backend/utility/message-utility.js";import NProgress from"nprogress";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import{default as Modal,Sizes as ModalSizes}from"@typo3/backend/modal.js";import Notification from"@typo3/backend/notification.js";import ImmediateAction from"@typo3/backend/action-button/immediate-action.js";import Md5 from"@typo3/backend/hashing/md5.js";import"@typo3/backend/element/icon-element.js";var Action;!function(e){e.OVERRIDE="replace",e.RENAME="rename",e.SKIP="cancel",e.USE_EXISTING="useExisting"}(Action||(Action={}));class DragUploaderPlugin{constructor(e){this.askForOverride=[],this.percentagePerFile=1,this.dragStartedInDocument=!1,this.hideDropzone=e=>{e.stopPropagation(),e.preventDefault(),this.$dropzone.hide(),this.$dropzone.removeClass("drop-status-ok"),this.manuallyTriggered=!1},this.dragFileIntoDocument=e=>(this.dragStartedInDocument||(e.stopPropagation(),e.preventDefault(),$(e.currentTarget).addClass("drop-in-progress"),this.$element.get(0)?.offsetParent&&this.showDropzone()),!1),this.dragAborted=e=>(e.stopPropagation(),e.preventDefault(),$(e.currentTarget).removeClass("drop-in-progress"),this.dragStartedInDocument=!1,!1),this.ignoreDrop=e=>(e.stopPropagation(),e.preventDefault(),this.dragAborted(e),!1),this.handleDrop=e=>{this.ignoreDrop(e),this.hideDropzone(e),this.processFiles(e.originalEvent.dataTransfer.files)},this.fileInDropzone=()=>{this.$dropzone.addClass("drop-status-ok")},this.fileOutOfDropzone=()=>{this.$dropzone.removeClass("drop-status-ok"),this.manuallyTriggered||this.$dropzone.hide()},this.$body=$("body"),this.$element=$(e);const t=void 0!==this.$element.data("dropzoneTrigger");this.$trigger=$(this.$element.data("dropzoneTrigger")),this.defaultAction=this.$element.data("defaultAction")||Action.SKIP,this.$dropzone=$("<div />").addClass("dropzone").hide(),this.irreObjectUid=this.$element.data("fileIrreObject");const i=this.$element.data("dropzoneTarget");if(this.irreObjectUid&&0!==this.$element.nextAll(i).length?(this.dropZoneInsertBefore=!0,this.$dropzone.insertBefore(i)):(this.dropZoneInsertBefore=!1,this.$dropzone.insertAfter(i)),this.$dropzoneMask=$("<div />").addClass("dropzone-mask").appendTo(this.$dropzone),this.fileInput=document.createElement("input"),this.fileInput.setAttribute("type","file"),this.fileInput.setAttribute("multiple","multiple"),this.fileInput.setAttribute("name","files[]"),this.fileInput.classList.add("upload-file-picker"),this.$body.append(this.fileInput),this.$fileList=$(this.$element.data("progress-container")),this.fileListColumnCount=$("thead tr:first th",this.$fileList).length+1,this.filesExtensionsAllowed=this.$element.data("file-allowed"),this.filesExtensionsDisallowed=this.$element.data("file-disallowed"),this.fileDenyPattern=this.$element.data("file-deny-pattern")?new RegExp(this.$element.data("file-deny-pattern"),"i"):null,this.maxFileSize=parseInt(this.$element.data("max-file-size"),10),this.target=this.$element.data("target-folder"),this.reloadUrl=this.$element.data("reload-url"),this.browserCapabilities={fileReader:"undefined"!=typeof FileReader,DnD:"draggable"in document.createElement("span"),Progress:"upload"in new XMLHttpRequest},this.browserCapabilities.DnD){if(this.$body.on("dragstart",(()=>{this.dragStartedInDocument=!0})),this.$body.on("dragover",this.dragFileIntoDocument),this.$body.on("dragend",this.dragAborted),this.$body.on("drop",this.ignoreDrop),this.$dropzone.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragleave",this.fileOutOfDropzone),this.$dropzoneMask.on("drop",(e=>this.handleDrop(e))),this.$dropzone.prepend('<button type="button" class="dropzone-hint" aria-labelledby="dropzone-title"><div class="dropzone-hint-media"><div class="dropzone-hint-icon"></div></div><div class="dropzone-hint-body"><h3 id="dropzone-title" class="dropzone-hint-title">'+TYPO3.lang["file_upload.dropzonehint.title"]+'</h3><p class="dropzone-hint-message">'+TYPO3.lang["file_upload.dropzonehint.message"]+"</p></div></div>").on("click",(()=>{this.fileInput.click()})),$('<button type="button" />').addClass("dropzone-close").attr("aria-label",TYPO3.lang["file_upload.dropzone.close"]).on("click",this.hideDropzone).appendTo(this.$dropzone),0===this.$fileList.length){this.$fileList=$("<table />").attr("id","typo3-filelist").addClass("table table-striped table-hover upload-queue").html("<tbody></tbody>");const e=$("<div/>",{class:"table-fit"}).hide().append(this.$fileList);this.dropZoneInsertBefore?e.insertAfter(this.$dropzone):e.insertBefore(this.$dropzone),this.fileListColumnCount=8,this.manualTable=!0}this.fileInput.addEventListener("change",(e=>{this.hideDropzone(e),this.processFiles(this.fileInput.files)})),document.addEventListener("keydown",(e=>{"Escape"===e.code&&this.$dropzone.is(":visible")&&this.hideDropzone(e)})),this.bindUploadButton(!0===t?this.$trigger:this.$element)}else console.warn("Browser has no Drag and drop capabilities; cannot initialize DragUploader")}showDropzone(){this.$dropzone.show()}processFiles(e){this.queueLength=e.length,this.$fileList.parent().is(":visible")||(this.$fileList.parent().show(),this.$fileList.closest(".t3-filelist-table-container")?.removeClass("hidden"),this.$fileList.closest("form")?.find(".t3-filelist-info-container")?.hide()),NProgress.start(),this.percentagePerFile=1/e.length;const t=[];Array.from(e).forEach((e=>{const i=new AjaxRequest(TYPO3.settings.ajaxUrls.file_exists).withQueryArguments({fileName:e.name,fileTarget:this.target}).get({cache:"no-cache"}).then((async t=>{const i=await t.resolve();void 0!==i.uid?(this.askForOverride.push({original:i,uploaded:e,action:this.irreObjectUid?Action.USE_EXISTING:this.defaultAction}),NProgress.inc(this.percentagePerFile)):new FileQueueItem(this,e,Action.SKIP)}));t.push(i)})),Promise.all(t).then((()=>{this.drawOverrideModal(),NProgress.done()})),this.fileInput.value=""}bindUploadButton(e){e.on("click",(e=>{e.preventDefault(),this.fileInput.click(),this.showDropzone(),this.manuallyTriggered=!0}))}decrementQueueLength(e){if(this.queueLength>0&&(this.queueLength--,0===this.queueLength)){const t=e&&e.length?5e3:0;if(t)for(const t of e)Notification.showMessage(t.title,t.message,t.severity);this.reloadUrl&&setTimeout((()=>{Notification.info(TYPO3.lang["file_upload.reload.filelist"],TYPO3.lang["file_upload.reload.filelist.message"],10,[{label:TYPO3.lang["file_upload.reload.filelist.actions.dismiss"]},{label:TYPO3.lang["file_upload.reload.filelist.actions.reload"],action:new ImmediateAction((()=>{top.list_frame.document.location.href=this.reloadUrl}))}])}),t)}}drawOverrideModal(){const e=Object.keys(this.askForOverride).length;if(0===e)return;const t=$("<div/>").append($("<p/>").text(TYPO3.lang["file_upload.existingfiles.description"]),$("<table/>",{class:"table"}).append($("<thead/>").append($("<tr />").append($("<th/>"),$("<th/>").text(TYPO3.lang["file_upload.header.originalFile"]),$("<th/>").text(TYPO3.lang["file_upload.header.uploadedFile"]),$("<th/>").text(TYPO3.lang["file_upload.header.action"])))));for(let i=0;i<e;++i){const e=$("<tr />").append($("<td />").append(""!==this.askForOverride[i].original.thumbUrl?$("<img />",{src:this.askForOverride[i].original.thumbUrl,height:40}):$(this.askForOverride[i].original.icon)),$("<td />").html(this.askForOverride[i].original.name+" ("+DragUploader.fileSizeAsString(this.askForOverride[i].original.size)+")<br>"+DateTime.fromSeconds(this.askForOverride[i].original.mtime).toLocaleString(DateTime.DATETIME_MED)),$("<td />").html(this.askForOverride[i].uploaded.name+" ("+DragUploader.fileSizeAsString(this.askForOverride[i].uploaded.size)+")<br>"+DateTime.fromMillis(this.askForOverride[i].uploaded.lastModified).toLocaleString(DateTime.DATETIME_MED)),$("<td />").append($("<select />",{class:"form-select t3js-actions","data-override":i}).append(this.irreObjectUid?$("<option/>").val(Action.USE_EXISTING).text(TYPO3.lang["file_upload.actions.use_existing"]):"",$("<option />",{selected:this.defaultAction===Action.SKIP}).val(Action.SKIP).text(TYPO3.lang["file_upload.actions.skip"]),$("<option />",{selected:this.defaultAction===Action.RENAME}).val(Action.RENAME).text(TYPO3.lang["file_upload.actions.rename"]),$("<option />",{selected:this.defaultAction===Action.OVERRIDE}).val(Action.OVERRIDE).text(TYPO3.lang["file_upload.actions.override"]))));t.find("table").append("<tbody />").append(e)}const i=Modal.advanced({title:TYPO3.lang["file_upload.existingfiles.title"],content:t,severity:SeverityEnum.warning,buttons:[{text:$(this).data("button-close-text")||TYPO3.lang["file_upload.button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:$(this).data("button-ok-text")||TYPO3.lang["file_upload.button.continue"]||"Continue with selected actions",btnClass:"btn-warning",name:"continue"}],additionalCssClasses:["modal-inner-scroll"],size:ModalSizes.large,callback:e=>{$(e).find(".modal-footer").prepend($("<label/>").text(TYPO3.lang["file_upload.actions.all.label"]),$("<span/>").append($("<select/>",{class:"form-select t3js-actions-all"}).append($("<option/>").val("").text(TYPO3.lang["file_upload.actions.all.empty"]),this.irreObjectUid?$("<option/>").val(Action.USE_EXISTING).text(TYPO3.lang["file_upload.actions.all.use_existing"]):"",$("<option/>",{selected:this.defaultAction===Action.SKIP}).val(Action.SKIP).text(TYPO3.lang["file_upload.actions.all.skip"]),$("<option/>",{selected:this.defaultAction===Action.RENAME}).val(Action.RENAME).text(TYPO3.lang["file_upload.actions.all.rename"]),$("<option/>",{selected:this.defaultAction===Action.OVERRIDE}).val(Action.OVERRIDE).text(TYPO3.lang["file_upload.actions.all.override"]))))}}),s=$(i);s.on("change",".t3js-actions-all",(e=>{const t=$(e.currentTarget).val();if(""!==t)for(const e of i.querySelectorAll(".t3js-actions")){const i=parseInt(e.dataset.override,10);e.value=t,e.disabled=!0,this.askForOverride[i].action=e.value}else i.querySelectorAll(".t3js-actions").forEach((e=>e.disabled=!1))})),s.on("change",".t3js-actions",(e=>{const t=$(e.currentTarget),i=parseInt(t.data("override"),10);this.askForOverride[i].action=t.val()})),i.addEventListener("button.clicked",(e=>{const t=e.target;if("cancel"===t.name)this.askForOverride=[],Modal.dismiss();else if("continue"===t.name){for(const e of this.askForOverride)e.action===Action.USE_EXISTING?DragUploader.addFileToIrre(this.irreObjectUid,e.original):e.action!==Action.SKIP&&new FileQueueItem(this,e.uploaded,e.action);this.askForOverride=[],i.hideModal()}})),i.addEventListener("typo3-modal-hidden",(()=>{this.askForOverride=[]}))}}class FileQueueItem{constructor(e,t,i){if(this.dragUploader=e,this.file=t,this.override=i,this.$row=$("<tr />").addClass("upload-queue-item uploading"),this.dragUploader.manualTable||(this.$selector=$("<td />").addClass("col-checkbox").appendTo(this.$row)),this.$iconCol=$("<td />",{class:"col-icon"}).appendTo(this.$row),this.$fileName=$("<td />",{class:"col-title col-responsive"}).text(t.name).appendTo(this.$row),this.$progress=$("<td />").attr("colspan",this.dragUploader.fileListColumnCount-this.$row.find("td").length).appendTo(this.$row),this.$progressContainer=$("<div />").addClass("upload-queue-progress").appendTo(this.$progress),this.$progressBar=$("<div />").addClass("upload-queue-progress-bar").appendTo(this.$progressContainer),this.$progressPercentage=$("<span />").addClass("upload-queue-progress-percentage").appendTo(this.$progressContainer),this.$progressMessage=$("<span />").addClass("upload-queue-progress-message").appendTo(this.$progressContainer),0===$("tbody tr.upload-queue-item",this.dragUploader.$fileList).length?(this.$row.prependTo($("tbody",this.dragUploader.$fileList)),this.$row.addClass("last")):this.$row.insertBefore($("tbody tr.upload-queue-item:first",this.dragUploader.$fileList)),this.$selector&&this.$selector.html('<span class="form-check form-check-type-toggle"><input type="checkbox" class="form-check-input t3js-multi-record-selection-check" disabled/></span>'),this.$iconCol.html('<typo3-backend-icon identifier="mimetypes-other-other" />'),this.dragUploader.maxFileSize>0&&this.file.size>this.dragUploader.maxFileSize)this.updateMessage(TYPO3.lang["file_upload.maxFileSizeExceeded"].replace(/\{0\}/g,this.file.name).replace(/\{1\}/g,DragUploader.fileSizeAsString(this.dragUploader.maxFileSize))),this.$row.addClass("error");else if(this.dragUploader.fileDenyPattern&&this.file.name.match(this.dragUploader.fileDenyPattern))this.updateMessage(TYPO3.lang["file_upload.fileNotAllowed"].replace(/\{0\}/g,this.file.name)),this.$row.addClass("error");else if(this.checkAllowedExtensions())if(this.checkDisallowedExtensions()){this.updateMessage("- "+DragUploader.fileSizeAsString(this.file.size));const e=new FormData;e.append("data[upload][1][target]",this.dragUploader.target),e.append("data[upload][1][data]","1"),e.append("overwriteExistingFiles",this.override),e.append("redirect",""),e.append("upload_1",this.file);const t=new XMLHttpRequest;t.onreadystatechange=()=>{if(t.readyState===XMLHttpRequest.DONE)if(200===t.status)try{const e=JSON.parse(t.responseText);e.hasErrors?this.uploadError(t):this.uploadSuccess(e)}catch(e){this.uploadError(t)}else this.uploadError(t)},t.upload.addEventListener("progress",(e=>this.updateProgress(e))),t.open("POST",TYPO3.settings.ajaxUrls.file_process),t.send(e)}else this.updateMessage(TYPO3.lang["file_upload.fileExtensionDisallowed"].replace(/\{0\}/g,this.dragUploader.filesExtensionsDisallowed)),this.$row.addClass("error");else this.updateMessage(TYPO3.lang["file_upload.fileExtensionExpected"].replace(/\{0\}/g,this.dragUploader.filesExtensionsAllowed)),this.$row.addClass("error")}updateMessage(e){this.$progressMessage.text(e)}removeProgress(){this.$progress&&this.$progress.remove()}uploadStart(){this.$progressPercentage.text("(0%)"),this.$progressBar.width("1%"),this.dragUploader.$trigger.trigger("uploadStart",[this])}uploadError(e){const t=TYPO3.lang["file_upload.uploadFailed"].replace(/\{0\}/g,this.file.name);this.updateMessage(t);try{const t=JSON.parse(e.responseText).messages;if(this.$progressPercentage.text(""),t&&t.length)for(const e of t)Notification.showMessage(e.title,e.message,e.severity,10)}catch(e){}this.$row.addClass("error"),this.dragUploader.decrementQueueLength(),this.dragUploader.$trigger.trigger("uploadError",[this,e])}updateProgress(e){const t=Math.round(e.loaded/e.total*100)+"%";this.$progressBar.outerWidth(t),this.$progressPercentage.text(t),this.dragUploader.$trigger.trigger("updateProgress",[this,t,e])}uploadSuccess(e){if(e.upload){this.dragUploader.decrementQueueLength(e.messages),this.$row.removeClass("uploading"),this.$row.prop("data-type","file"),this.$row.prop("data-file-uid",e.upload[0].uid),this.$fileName.text(e.upload[0].name),this.$progressPercentage.text(""),this.$progressMessage.text("100%"),this.$progressBar.outerWidth("100%");const t=String(e.upload[0].id);if(this.$selector){const e=this.$selector.find("input")?.get(0);e&&(e.removeAttribute("disabled"),e.setAttribute("name","CBC[_FILE|"+Md5.hash(t)+"]"),e.setAttribute("value",t))}e.upload[0].icon&&this.$iconCol.html('<a href="#" data-contextmenu-trigger="click" data-contextmenu-uid="'+t+'" data-contextmenu-table="sys_file">'+e.upload[0].icon+"</span></a>"),this.dragUploader.irreObjectUid?(DragUploader.addFileToIrre(this.dragUploader.irreObjectUid,e.upload[0]),setTimeout((()=>{this.$row.remove(),0===$("tr",this.dragUploader.$fileList).length&&(this.dragUploader.$fileList.hide(),this.dragUploader.$fileList.closest(".t3-filelist-table-container")?.addClass("hidden"),this.dragUploader.$trigger.trigger("uploadSuccess",[this,e]))}),3e3)):setTimeout((()=>{this.showFileInfo(e.upload[0]),this.dragUploader.$trigger.trigger("uploadSuccess",[this,e])}),3e3)}}showFileInfo(e){this.removeProgress(),document.querySelector("#filelist-searchterm")?.value&&$("<td />").text(e.path).appendTo(this.$row),$("<td />",{class:"col-control"}).text("").appendTo(this.$row),$("<td />").text(TYPO3.lang["type.file"]+" ("+e.extension.toUpperCase()+")").appendTo(this.$row),$("<td />").text(DragUploader.fileSizeAsString(e.size)).appendTo(this.$row);let t="";e.permissions.read&&(t+='<strong class="text-danger">'+TYPO3.lang["permissions.read"]+"</strong>"),e.permissions.write&&(t+='<strong class="text-danger">'+TYPO3.lang["permissions.write"]+"</strong>"),$("<td />").html(t).appendTo(this.$row),$("<td />").text("-").appendTo(this.$row);for(let e=this.$row.find("td").length;e<this.dragUploader.fileListColumnCount;e++)$("<td />").text("").appendTo(this.$row)}checkAllowedExtensions(){if(!this.dragUploader.filesExtensionsAllowed)return!0;const e=this.file.name.split(".").pop(),t=this.dragUploader.filesExtensionsAllowed.split(",");return-1!==$.inArray(e.toLowerCase(),t)}checkDisallowedExtensions(){if(!this.dragUploader.filesExtensionsDisallowed)return!0;const e=this.file.name.split(".").pop(),t=this.dragUploader.filesExtensionsDisallowed.split(",");return-1===$.inArray(e.toLowerCase(),t)}}class DragUploader{static fileSizeAsString(e){const t=e/1024;let i="";return i=t>1024?(t/1024).toFixed(1)+" MB":t.toFixed(1)+" KB",i}static addFileToIrre(e,t){const i={actionName:"typo3:foreignRelation:insert",objectGroup:e,table:"sys_file",uid:t.uid};MessageUtility.send(i)}static init(){const e=this.options;$.fn.extend({dragUploader:function(e){return this.each(((t,i)=>{const s=$(i);let o=s.data("DragUploaderPlugin");o||s.data("DragUploaderPlugin",o=new DragUploaderPlugin(i)),"string"==typeof e&&o[e]()}))}}),DocumentService.ready().then((()=>{$(".t3js-drag-uploader").dragUploader(e)}));new MutationObserver((()=>{$(".t3js-drag-uploader").dragUploader(e)})).observe(document,{childList:!0,subtree:!0})}}export const initialize=function(){DragUploader.init()};initialize(); \ No newline at end of file diff --git a/typo3/sysext/core/Resources/Public/JavaScript/Contrib/bootstrap.js b/typo3/sysext/core/Resources/Public/JavaScript/Contrib/bootstrap.js index 5cd2edba4b74eee85e7b8faf5c91fe84c0908939..65cb953a8f71f95b80d87b4d88c8815494c689c8 100644 --- a/typo3/sysext/core/Resources/Public/JavaScript/Contrib/bootstrap.js +++ b/typo3/sysext/core/Resources/Public/JavaScript/Contrib/bootstrap.js @@ -4,4 +4,4 @@ import $ from"jquery";window.jQuery=$;var top="top",bottom="bottom",right="right * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ -const elementMap=new Map,Data={set(e,t,n){elementMap.has(e)||elementMap.set(e,new Map);const i=elementMap.get(e);i.has(t)||0===i.size?i.set(t,n):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(i.keys())[0]}.`)},get:(e,t)=>elementMap.has(e)&&elementMap.get(e).get(t)||null,remove(e,t){if(!elementMap.has(e))return;const n=elementMap.get(e);n.delete(t),0===n.size&&elementMap.delete(e)}},MAX_UID=1e6,MILLISECONDS_MULTIPLIER=1e3,TRANSITION_END="transitionend",parseSelector=e=>(e&&window.CSS&&window.CSS.escape&&(e=e.replace(/#([^\s"#']+)/g,((e,t)=>`#${CSS.escape(t)}`))),e),toType=e=>null==e?`${e}`:Object.prototype.toString.call(e).match(/\s([a-z]+)/i)[1].toLowerCase(),getUID=e=>{do{e+=Math.floor(1e6*Math.random())}while(document.getElementById(e));return e},getTransitionDurationFromElement=e=>{if(!e)return 0;let{transitionDuration:t,transitionDelay:n}=window.getComputedStyle(e);const i=Number.parseFloat(t),s=Number.parseFloat(n);return i||s?(t=t.split(",")[0],n=n.split(",")[0],1e3*(Number.parseFloat(t)+Number.parseFloat(n))):0},triggerTransitionEnd=e=>{e.dispatchEvent(new Event(TRANSITION_END))},isElement=e=>!(!e||"object"!=typeof e)&&(void 0!==e.jquery&&(e=e[0]),void 0!==e.nodeType),getElement=e=>isElement(e)?e.jquery?e[0]:e:"string"==typeof e&&e.length>0?document.querySelector(parseSelector(e)):null,isVisible=e=>{if(!isElement(e)||0===e.getClientRects().length)return!1;const t="visible"===getComputedStyle(e).getPropertyValue("visibility"),n=e.closest("details:not([open])");if(!n)return t;if(n!==e){const t=e.closest("summary");if(t&&t.parentNode!==n)return!1;if(null===t)return!1}return t},isDisabled=e=>!e||e.nodeType!==Node.ELEMENT_NODE||(!!e.classList.contains("disabled")||(void 0!==e.disabled?e.disabled:e.hasAttribute("disabled")&&"false"!==e.getAttribute("disabled"))),findShadowRoot=e=>{if(!document.documentElement.attachShadow)return null;if("function"==typeof e.getRootNode){const t=e.getRootNode();return t instanceof ShadowRoot?t:null}return e instanceof ShadowRoot?e:e.parentNode?findShadowRoot(e.parentNode):null},noop=()=>{},reflow=e=>{e.offsetHeight},getjQuery=()=>window.jQuery&&!document.body.hasAttribute("data-bs-no-jquery")?window.jQuery:null,DOMContentLoadedCallbacks=[],onDOMContentLoaded=e=>{"loading"===document.readyState?(DOMContentLoadedCallbacks.length||document.addEventListener("DOMContentLoaded",(()=>{for(const e of DOMContentLoadedCallbacks)e()})),DOMContentLoadedCallbacks.push(e)):e()},isRTL=()=>"rtl"===document.documentElement.dir,defineJQueryPlugin=e=>{var t;t=()=>{const t=getjQuery();if(t){const n=e.NAME,i=t.fn[n];t.fn[n]=e.jQueryInterface,t.fn[n].Constructor=e,t.fn[n].noConflict=()=>(t.fn[n]=i,e.jQueryInterface)}},"loading"===document.readyState?(DOMContentLoadedCallbacks.length||document.addEventListener("DOMContentLoaded",(()=>{for(const e of DOMContentLoadedCallbacks)e()})),DOMContentLoadedCallbacks.push(t)):t()},execute=(e,t=[],n=e)=>"function"==typeof e?e(...t):n,executeAfterTransition=(e,t,n=!0)=>{if(!n)return void execute(e);const i=getTransitionDurationFromElement(t)+5;let s=!1;const o=({target:n})=>{n===t&&(s=!0,t.removeEventListener(TRANSITION_END,o),execute(e))};t.addEventListener(TRANSITION_END,o),setTimeout((()=>{s||triggerTransitionEnd(t)}),i)},getNextActiveElement=(e,t,n,i)=>{const s=e.length;let o=e.indexOf(t);return-1===o?!n&&i?e[s-1]:e[0]:(o+=n?1:-1,i&&(o=(o+s)%s),e[Math.max(0,Math.min(o,s-1))])},namespaceRegex=/[^.]*(?=\..*)\.|.*/,stripNameRegex=/\..*/,stripUidRegex=/::\d+$/,eventRegistry={};let uidEvent=1;const customEvents={mouseenter:"mouseover",mouseleave:"mouseout"},nativeEvents=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]);function makeEventUid(e,t){return t&&`${t}::${uidEvent++}`||e.uidEvent||uidEvent++}function getElementEvents(e){const t=makeEventUid(e);return e.uidEvent=t,eventRegistry[t]=eventRegistry[t]||{},eventRegistry[t]}function bootstrapHandler(e,t){return function n(i){return hydrateObj(i,{delegateTarget:e}),n.oneOff&&EventHandler.off(e,i.type,t),t.apply(e,[i])}}function bootstrapDelegationHandler(e,t,n){return function i(s){const o=e.querySelectorAll(t);for(let{target:r}=s;r&&r!==this;r=r.parentNode)for(const a of o)if(a===r)return hydrateObj(s,{delegateTarget:r}),i.oneOff&&EventHandler.off(e,s.type,t,n),n.apply(r,[s])}}function findHandler(e,t,n=null){return Object.values(e).find((e=>e.callable===t&&e.delegationSelector===n))}function normalizeParameters(e,t,n){const i="string"==typeof t,s=i?n:t||n;let o=getTypeEvent(e);return nativeEvents.has(o)||(o=e),[i,s,o]}function addHandler(e,t,n,i,s){if("string"!=typeof t||!e)return;let[o,r,a]=normalizeParameters(t,n,i);if(t in customEvents){const e=e=>function(t){if(!t.relatedTarget||t.relatedTarget!==t.delegateTarget&&!t.delegateTarget.contains(t.relatedTarget))return e.call(this,t)};r=e(r)}const l=getElementEvents(e),c=l[a]||(l[a]={}),d=findHandler(c,r,o?n:null);if(d)return void(d.oneOff=d.oneOff&&s);const u=makeEventUid(r,t.replace(namespaceRegex,"")),h=o?bootstrapDelegationHandler(e,n,r):bootstrapHandler(e,r);h.delegationSelector=o?n:null,h.callable=r,h.oneOff=s,h.uidEvent=u,c[u]=h,e.addEventListener(a,h,o)}function removeHandler(e,t,n,i,s){const o=findHandler(t[n],i,s);o&&(e.removeEventListener(n,o,Boolean(s)),delete t[n][o.uidEvent])}function removeNamespacedHandlers(e,t,n,i){const s=t[n]||{};for(const[o,r]of Object.entries(s))o.includes(i)&&removeHandler(e,t,n,r.callable,r.delegationSelector)}function getTypeEvent(e){return e=e.replace(stripNameRegex,""),customEvents[e]||e}const EventHandler={on(e,t,n,i){addHandler(e,t,n,i,!1)},one(e,t,n,i){addHandler(e,t,n,i,!0)},off(e,t,n,i){if("string"!=typeof t||!e)return;const[s,o,r]=normalizeParameters(t,n,i),a=r!==t,l=getElementEvents(e),c=l[r]||{},d=t.startsWith(".");if(void 0===o){if(d)for(const n of Object.keys(l))removeNamespacedHandlers(e,l,n,t.slice(1));for(const[n,i]of Object.entries(c)){const s=n.replace(stripUidRegex,"");a&&!t.includes(s)||removeHandler(e,l,r,i.callable,i.delegationSelector)}}else{if(!Object.keys(c).length)return;removeHandler(e,l,r,o,s?n:null)}},trigger(e,t,n){if("string"!=typeof t||!e)return null;const i=getjQuery();let s=null,o=!0,r=!0,a=!1;t!==getTypeEvent(t)&&i&&(s=i.Event(t,n),i(e).trigger(s),o=!s.isPropagationStopped(),r=!s.isImmediatePropagationStopped(),a=s.isDefaultPrevented());const l=hydrateObj(new Event(t,{bubbles:o,cancelable:!0}),n);return a&&l.preventDefault(),r&&e.dispatchEvent(l),l.defaultPrevented&&s&&s.preventDefault(),l}};function hydrateObj(e,t={}){for(const[n,i]of Object.entries(t))try{e[n]=i}catch(t){Object.defineProperty(e,n,{configurable:!0,get:()=>i})}return e}function normalizeData(e){if("true"===e)return!0;if("false"===e)return!1;if(e===Number(e).toString())return Number(e);if(""===e||"null"===e)return null;if("string"!=typeof e)return e;try{return JSON.parse(decodeURIComponent(e))}catch(t){return e}}function normalizeDataKey(e){return e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`))}const Manipulator={setDataAttribute(e,t,n){e.setAttribute(`data-bs-${normalizeDataKey(t)}`,n)},removeDataAttribute(e,t){e.removeAttribute(`data-bs-${normalizeDataKey(t)}`)},getDataAttributes(e){if(!e)return{};const t={},n=Object.keys(e.dataset).filter((e=>e.startsWith("bs")&&!e.startsWith("bsConfig")));for(const i of n){let n=i.replace(/^bs/,"");n=n.charAt(0).toLowerCase()+n.slice(1,n.length),t[n]=normalizeData(e.dataset[i])}return t},getDataAttribute:(e,t)=>normalizeData(e.getAttribute(`data-bs-${normalizeDataKey(t)}`))};class Config{static get Default(){return{}}static get DefaultType(){return{}}static get NAME(){throw new Error('You have to implement the static method "NAME", for each component!')}_getConfig(e){return e=this._mergeConfigObj(e),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}_configAfterMerge(e){return e}_mergeConfigObj(e,t){const n=isElement(t)?Manipulator.getDataAttribute(t,"config"):{};return{...this.constructor.Default,..."object"==typeof n?n:{},...isElement(t)?Manipulator.getDataAttributes(t):{},..."object"==typeof e?e:{}}}_typeCheckConfig(e,t=this.constructor.DefaultType){for(const[i,s]of Object.entries(t)){const t=e[i],o=isElement(t)?"element":null==(n=t)?`${n}`:Object.prototype.toString.call(n).match(/\s([a-z]+)/i)[1].toLowerCase();if(!new RegExp(s).test(o))throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${i}" provided type "${o}" but expected type "${s}".`)}var n}}const VERSION="5.3.1";class BaseComponent extends Config{constructor(e,t){super(),(e=getElement(e))&&(this._element=e,this._config=this._getConfig(t),Data.set(this._element,this.constructor.DATA_KEY,this))}dispose(){Data.remove(this._element,this.constructor.DATA_KEY),EventHandler.off(this._element,this.constructor.EVENT_KEY);for(const e of Object.getOwnPropertyNames(this))this[e]=null}_queueCallback(e,t,n=!0){executeAfterTransition(e,t,n)}_getConfig(e){return e=this._mergeConfigObj(e,this._element),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}static getInstance(e){return Data.get(getElement(e),this.DATA_KEY)}static getOrCreateInstance(e,t={}){return this.getInstance(e)||new this(e,"object"==typeof t?t:null)}static get VERSION(){return"5.3.1"}static get DATA_KEY(){return`bs.${this.NAME}`}static get EVENT_KEY(){return`.${this.DATA_KEY}`}static eventName(e){return`${e}${this.EVENT_KEY}`}}const getSelector=e=>{let t=e.getAttribute("data-bs-target");if(!t||"#"===t){let n=e.getAttribute("href");if(!n||!n.includes("#")&&!n.startsWith("."))return null;n.includes("#")&&!n.startsWith("#")&&(n=`#${n.split("#")[1]}`),t=n&&"#"!==n?n.trim():null}return parseSelector(t)},SelectorEngine={find:(e,t=document.documentElement)=>[].concat(...Element.prototype.querySelectorAll.call(t,e)),findOne:(e,t=document.documentElement)=>Element.prototype.querySelector.call(t,e),children:(e,t)=>[].concat(...e.children).filter((e=>e.matches(t))),parents(e,t){const n=[];let i=e.parentNode.closest(t);for(;i;)n.push(i),i=i.parentNode.closest(t);return n},prev(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return[n];n=n.previousElementSibling}return[]},next(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return[n];n=n.nextElementSibling}return[]},focusableChildren(e){const t=["a","button","input","textarea","select","details","[tabindex]",'[contenteditable="true"]'].map((e=>`${e}:not([tabindex^="-"])`)).join(",");return this.find(t,e).filter((e=>!isDisabled(e)&&isVisible(e)))},getSelectorFromElement(e){const t=getSelector(e);return t&&SelectorEngine.findOne(t)?t:null},getElementFromSelector(e){const t=getSelector(e);return t?SelectorEngine.findOne(t):null},getMultipleElementsFromSelector(e){const t=getSelector(e);return t?SelectorEngine.find(t):[]}},enableDismissTrigger=(e,t="hide")=>{const n=`click.dismiss${e.EVENT_KEY}`,i=e.NAME;EventHandler.on(document,n,`[data-bs-dismiss="${i}"]`,(function(n){if(["A","AREA"].includes(this.tagName)&&n.preventDefault(),isDisabled(this))return;const s=SelectorEngine.getElementFromSelector(this)||this.closest(`.${i}`);e.getOrCreateInstance(s)[t]()}))},NAME$f="alert",DATA_KEY$a="bs.alert",EVENT_KEY$b=".bs.alert",EVENT_CLOSE="close.bs.alert",EVENT_CLOSED="closed.bs.alert",CLASS_NAME_FADE$5="fade",CLASS_NAME_SHOW$8="show";class Alert extends BaseComponent{static get NAME(){return NAME$f}close(){if(EventHandler.trigger(this._element,EVENT_CLOSE).defaultPrevented)return;this._element.classList.remove("show");const e=this._element.classList.contains("fade");this._queueCallback((()=>this._destroyElement()),this._element,e)}_destroyElement(){this._element.remove(),EventHandler.trigger(this._element,EVENT_CLOSED),this.dispose()}static jQueryInterface(e){return this.each((function(){const t=Alert.getOrCreateInstance(this);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e](this)}}))}}enableDismissTrigger(Alert,"close"),defineJQueryPlugin(Alert);const NAME$e="button",DATA_KEY$9="bs.button",EVENT_KEY$a=`.${DATA_KEY$9}`,DATA_API_KEY$6=".data-api",CLASS_NAME_ACTIVE$3="active",SELECTOR_DATA_TOGGLE$5='[data-bs-toggle="button"]',EVENT_CLICK_DATA_API$6=`click${EVENT_KEY$a}.data-api`;class Button extends BaseComponent{static get NAME(){return NAME$e}toggle(){this._element.setAttribute("aria-pressed",this._element.classList.toggle("active"))}static jQueryInterface(e){return this.each((function(){const t=Button.getOrCreateInstance(this);"toggle"===e&&t[e]()}))}}EventHandler.on(document,EVENT_CLICK_DATA_API$6,SELECTOR_DATA_TOGGLE$5,(e=>{e.preventDefault();const t=e.target.closest(SELECTOR_DATA_TOGGLE$5);Button.getOrCreateInstance(t).toggle()})),defineJQueryPlugin(Button);const NAME$d="swipe",EVENT_KEY$9=".bs.swipe",EVENT_TOUCHSTART="touchstart.bs.swipe",EVENT_TOUCHMOVE="touchmove.bs.swipe",EVENT_TOUCHEND="touchend.bs.swipe",EVENT_POINTERDOWN="pointerdown.bs.swipe",EVENT_POINTERUP="pointerup.bs.swipe",POINTER_TYPE_TOUCH="touch",POINTER_TYPE_PEN="pen",CLASS_NAME_POINTER_EVENT="pointer-event",SWIPE_THRESHOLD=40,Default$c={endCallback:null,leftCallback:null,rightCallback:null},DefaultType$c={endCallback:"(function|null)",leftCallback:"(function|null)",rightCallback:"(function|null)"};class Swipe extends Config{constructor(e,t){super(),this._element=e,e&&Swipe.isSupported()&&(this._config=this._getConfig(t),this._deltaX=0,this._supportPointerEvents=Boolean(window.PointerEvent),this._initEvents())}static get Default(){return Default$c}static get DefaultType(){return DefaultType$c}static get NAME(){return NAME$d}dispose(){EventHandler.off(this._element,".bs.swipe")}_start(e){this._supportPointerEvents?this._eventIsPointerPenTouch(e)&&(this._deltaX=e.clientX):this._deltaX=e.touches[0].clientX}_end(e){this._eventIsPointerPenTouch(e)&&(this._deltaX=e.clientX-this._deltaX),this._handleSwipe(),execute(this._config.endCallback)}_move(e){this._deltaX=e.touches&&e.touches.length>1?0:e.touches[0].clientX-this._deltaX}_handleSwipe(){const e=Math.abs(this._deltaX);if(e<=40)return;const t=e/this._deltaX;this._deltaX=0,t&&execute(t>0?this._config.rightCallback:this._config.leftCallback)}_initEvents(){this._supportPointerEvents?(EventHandler.on(this._element,EVENT_POINTERDOWN,(e=>this._start(e))),EventHandler.on(this._element,EVENT_POINTERUP,(e=>this._end(e))),this._element.classList.add("pointer-event")):(EventHandler.on(this._element,EVENT_TOUCHSTART,(e=>this._start(e))),EventHandler.on(this._element,EVENT_TOUCHMOVE,(e=>this._move(e))),EventHandler.on(this._element,EVENT_TOUCHEND,(e=>this._end(e))))}_eventIsPointerPenTouch(e){return this._supportPointerEvents&&("pen"===e.pointerType||"touch"===e.pointerType)}static isSupported(){return"ontouchstart"in document.documentElement||navigator.maxTouchPoints>0}}const NAME$c="carousel",DATA_KEY$8="bs.carousel",EVENT_KEY$8=`.${DATA_KEY$8}`,DATA_API_KEY$5=".data-api",ARROW_LEFT_KEY$1="ArrowLeft",ARROW_RIGHT_KEY$1="ArrowRight",TOUCHEVENT_COMPAT_WAIT=500,ORDER_NEXT="next",ORDER_PREV="prev",DIRECTION_LEFT="left",DIRECTION_RIGHT="right",EVENT_SLIDE=`slide${EVENT_KEY$8}`,EVENT_SLID=`slid${EVENT_KEY$8}`,EVENT_KEYDOWN$1=`keydown${EVENT_KEY$8}`,EVENT_MOUSEENTER$1=`mouseenter${EVENT_KEY$8}`,EVENT_MOUSELEAVE$1=`mouseleave${EVENT_KEY$8}`,EVENT_DRAG_START=`dragstart${EVENT_KEY$8}`,EVENT_LOAD_DATA_API$3=`load${EVENT_KEY$8}.data-api`,EVENT_CLICK_DATA_API$5=`click${EVENT_KEY$8}.data-api`,CLASS_NAME_CAROUSEL="carousel",CLASS_NAME_ACTIVE$2="active",CLASS_NAME_SLIDE="slide",CLASS_NAME_END="carousel-item-end",CLASS_NAME_START="carousel-item-start",CLASS_NAME_NEXT="carousel-item-next",CLASS_NAME_PREV="carousel-item-prev",SELECTOR_ACTIVE=".active",SELECTOR_ITEM=".carousel-item",SELECTOR_ACTIVE_ITEM=".active.carousel-item",SELECTOR_ITEM_IMG=".carousel-item img",SELECTOR_INDICATORS=".carousel-indicators",SELECTOR_DATA_SLIDE="[data-bs-slide], [data-bs-slide-to]",SELECTOR_DATA_RIDE='[data-bs-ride="carousel"]',KEY_TO_DIRECTION={ArrowLeft:"right",ArrowRight:"left"},Default$b={interval:5e3,keyboard:!0,pause:"hover",ride:!1,touch:!0,wrap:!0},DefaultType$b={interval:"(number|boolean)",keyboard:"boolean",pause:"(string|boolean)",ride:"(boolean|string)",touch:"boolean",wrap:"boolean"};class Carousel extends BaseComponent{constructor(e,t){super(e,t),this._interval=null,this._activeElement=null,this._isSliding=!1,this.touchTimeout=null,this._swipeHelper=null,this._indicatorsElement=SelectorEngine.findOne(SELECTOR_INDICATORS,this._element),this._addEventListeners(),"carousel"===this._config.ride&&this.cycle()}static get Default(){return Default$b}static get DefaultType(){return DefaultType$b}static get NAME(){return NAME$c}next(){this._slide("next")}nextWhenVisible(){!document.hidden&&isVisible(this._element)&&this.next()}prev(){this._slide("prev")}pause(){this._isSliding&&triggerTransitionEnd(this._element),this._clearInterval()}cycle(){this._clearInterval(),this._updateInterval(),this._interval=setInterval((()=>this.nextWhenVisible()),this._config.interval)}_maybeEnableCycle(){this._config.ride&&(this._isSliding?EventHandler.one(this._element,EVENT_SLID,(()=>this.cycle())):this.cycle())}to(e){const t=this._getItems();if(e>t.length-1||e<0)return;if(this._isSliding)return void EventHandler.one(this._element,EVENT_SLID,(()=>this.to(e)));const n=this._getItemIndex(this._getActive());if(n===e)return;const i=e>n?"next":"prev";this._slide(i,t[e])}dispose(){this._swipeHelper&&this._swipeHelper.dispose(),super.dispose()}_configAfterMerge(e){return e.defaultInterval=e.interval,e}_addEventListeners(){this._config.keyboard&&EventHandler.on(this._element,EVENT_KEYDOWN$1,(e=>this._keydown(e))),"hover"===this._config.pause&&(EventHandler.on(this._element,EVENT_MOUSEENTER$1,(()=>this.pause())),EventHandler.on(this._element,EVENT_MOUSELEAVE$1,(()=>this._maybeEnableCycle()))),this._config.touch&&Swipe.isSupported()&&this._addTouchEventListeners()}_addTouchEventListeners(){for(const e of SelectorEngine.find(SELECTOR_ITEM_IMG,this._element))EventHandler.on(e,EVENT_DRAG_START,(e=>e.preventDefault()));const e={leftCallback:()=>this._slide(this._directionToOrder("left")),rightCallback:()=>this._slide(this._directionToOrder("right")),endCallback:()=>{"hover"===this._config.pause&&(this.pause(),this.touchTimeout&&clearTimeout(this.touchTimeout),this.touchTimeout=setTimeout((()=>this._maybeEnableCycle()),500+this._config.interval))}};this._swipeHelper=new Swipe(this._element,e)}_keydown(e){if(/input|textarea/i.test(e.target.tagName))return;const t=KEY_TO_DIRECTION[e.key];t&&(e.preventDefault(),this._slide(this._directionToOrder(t)))}_getItemIndex(e){return this._getItems().indexOf(e)}_setActiveIndicatorElement(e){if(!this._indicatorsElement)return;const t=SelectorEngine.findOne(".active",this._indicatorsElement);t.classList.remove("active"),t.removeAttribute("aria-current");const n=SelectorEngine.findOne(`[data-bs-slide-to="${e}"]`,this._indicatorsElement);n&&(n.classList.add("active"),n.setAttribute("aria-current","true"))}_updateInterval(){const e=this._activeElement||this._getActive();if(!e)return;const t=Number.parseInt(e.getAttribute("data-bs-interval"),10);this._config.interval=t||this._config.defaultInterval}_slide(e,t=null){if(this._isSliding)return;const n=this._getActive(),i="next"===e,s=t||getNextActiveElement(this._getItems(),n,i,this._config.wrap);if(s===n)return;const o=this._getItemIndex(s),r=t=>EventHandler.trigger(this._element,t,{relatedTarget:s,direction:this._orderToDirection(e),from:this._getItemIndex(n),to:o});if(r(EVENT_SLIDE).defaultPrevented)return;if(!n||!s)return;const a=Boolean(this._interval);this.pause(),this._isSliding=!0,this._setActiveIndicatorElement(o),this._activeElement=s;const l=i?CLASS_NAME_START:CLASS_NAME_END,c=i?CLASS_NAME_NEXT:CLASS_NAME_PREV;s.classList.add(c),reflow(s),n.classList.add(l),s.classList.add(l);this._queueCallback((()=>{s.classList.remove(l,c),s.classList.add("active"),n.classList.remove("active",c,l),this._isSliding=!1,r(EVENT_SLID)}),n,this._isAnimated()),a&&this.cycle()}_isAnimated(){return this._element.classList.contains("slide")}_getActive(){return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM,this._element)}_getItems(){return SelectorEngine.find(SELECTOR_ITEM,this._element)}_clearInterval(){this._interval&&(clearInterval(this._interval),this._interval=null)}_directionToOrder(e){return isRTL()?"left"===e?"prev":"next":"left"===e?"next":"prev"}_orderToDirection(e){return isRTL()?"prev"===e?"left":"right":"prev"===e?"right":"left"}static jQueryInterface(e){return this.each((function(){const t=Carousel.getOrCreateInstance(this,e);if("number"!=typeof e){if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e]()}}else t.to(e)}))}}EventHandler.on(document,EVENT_CLICK_DATA_API$5,SELECTOR_DATA_SLIDE,(function(e){const t=SelectorEngine.getElementFromSelector(this);if(!t||!t.classList.contains("carousel"))return;e.preventDefault();const n=Carousel.getOrCreateInstance(t),i=this.getAttribute("data-bs-slide-to");return i?(n.to(i),void n._maybeEnableCycle()):"next"===Manipulator.getDataAttribute(this,"slide")?(n.next(),void n._maybeEnableCycle()):(n.prev(),void n._maybeEnableCycle())})),EventHandler.on(window,EVENT_LOAD_DATA_API$3,(()=>{const e=SelectorEngine.find(SELECTOR_DATA_RIDE);for(const t of e)Carousel.getOrCreateInstance(t)})),defineJQueryPlugin(Carousel);const NAME$b="collapse",DATA_KEY$7="bs.collapse",EVENT_KEY$7=`.${DATA_KEY$7}`,DATA_API_KEY$4=".data-api",EVENT_SHOW$6=`show${EVENT_KEY$7}`,EVENT_SHOWN$6=`shown${EVENT_KEY$7}`,EVENT_HIDE$6=`hide${EVENT_KEY$7}`,EVENT_HIDDEN$6=`hidden${EVENT_KEY$7}`,EVENT_CLICK_DATA_API$4=`click${EVENT_KEY$7}.data-api`,CLASS_NAME_SHOW$7="show",CLASS_NAME_COLLAPSE="collapse",CLASS_NAME_COLLAPSING="collapsing",CLASS_NAME_COLLAPSED="collapsed",CLASS_NAME_DEEPER_CHILDREN=":scope .collapse .collapse",CLASS_NAME_HORIZONTAL="collapse-horizontal",WIDTH="width",HEIGHT="height",SELECTOR_ACTIVES=".collapse.show, .collapse.collapsing",SELECTOR_DATA_TOGGLE$4='[data-bs-toggle="collapse"]',Default$a={parent:null,toggle:!0},DefaultType$a={parent:"(null|element)",toggle:"boolean"};class Collapse extends BaseComponent{constructor(e,t){super(e,t),this._isTransitioning=!1,this._triggerArray=[];const n=SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);for(const e of n){const t=SelectorEngine.getSelectorFromElement(e),n=SelectorEngine.find(t).filter((e=>e===this._element));null!==t&&n.length&&this._triggerArray.push(e)}this._initializeChildren(),this._config.parent||this._addAriaAndCollapsedClass(this._triggerArray,this._isShown()),this._config.toggle&&this.toggle()}static get Default(){return Default$a}static get DefaultType(){return DefaultType$a}static get NAME(){return NAME$b}toggle(){this._isShown()?this.hide():this.show()}show(){if(this._isTransitioning||this._isShown())return;let e=[];if(this._config.parent&&(e=this._getFirstLevelChildren(SELECTOR_ACTIVES).filter((e=>e!==this._element)).map((e=>Collapse.getOrCreateInstance(e,{toggle:!1})))),e.length&&e[0]._isTransitioning)return;if(EventHandler.trigger(this._element,EVENT_SHOW$6).defaultPrevented)return;for(const t of e)t.hide();const t=this._getDimension();this._element.classList.remove("collapse"),this._element.classList.add("collapsing"),this._element.style[t]=0,this._addAriaAndCollapsedClass(this._triggerArray,!0),this._isTransitioning=!0;const n=`scroll${t[0].toUpperCase()+t.slice(1)}`;this._queueCallback((()=>{this._isTransitioning=!1,this._element.classList.remove("collapsing"),this._element.classList.add("collapse","show"),this._element.style[t]="",EventHandler.trigger(this._element,EVENT_SHOWN$6)}),this._element,!0),this._element.style[t]=`${this._element[n]}px`}hide(){if(this._isTransitioning||!this._isShown())return;if(EventHandler.trigger(this._element,EVENT_HIDE$6).defaultPrevented)return;const e=this._getDimension();this._element.style[e]=`${this._element.getBoundingClientRect()[e]}px`,reflow(this._element),this._element.classList.add("collapsing"),this._element.classList.remove("collapse","show");for(const e of this._triggerArray){const t=SelectorEngine.getElementFromSelector(e);t&&!this._isShown(t)&&this._addAriaAndCollapsedClass([e],!1)}this._isTransitioning=!0;this._element.style[e]="",this._queueCallback((()=>{this._isTransitioning=!1,this._element.classList.remove("collapsing"),this._element.classList.add("collapse"),EventHandler.trigger(this._element,EVENT_HIDDEN$6)}),this._element,!0)}_isShown(e=this._element){return e.classList.contains("show")}_configAfterMerge(e){return e.toggle=Boolean(e.toggle),e.parent=getElement(e.parent),e}_getDimension(){return this._element.classList.contains("collapse-horizontal")?WIDTH:HEIGHT}_initializeChildren(){if(!this._config.parent)return;const e=this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4);for(const t of e){const e=SelectorEngine.getElementFromSelector(t);e&&this._addAriaAndCollapsedClass([t],this._isShown(e))}}_getFirstLevelChildren(e){const t=SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN,this._config.parent);return SelectorEngine.find(e,this._config.parent).filter((e=>!t.includes(e)))}_addAriaAndCollapsedClass(e,t){if(e.length)for(const n of e)n.classList.toggle("collapsed",!t),n.setAttribute("aria-expanded",t)}static jQueryInterface(e){const t={};return"string"==typeof e&&/show|hide/.test(e)&&(t.toggle=!1),this.each((function(){const n=Collapse.getOrCreateInstance(this,t);if("string"==typeof e){if(void 0===n[e])throw new TypeError(`No method named "${e}"`);n[e]()}}))}}EventHandler.on(document,EVENT_CLICK_DATA_API$4,SELECTOR_DATA_TOGGLE$4,(function(e){("A"===e.target.tagName||e.delegateTarget&&"A"===e.delegateTarget.tagName)&&e.preventDefault();for(const e of SelectorEngine.getMultipleElementsFromSelector(this))Collapse.getOrCreateInstance(e,{toggle:!1}).toggle()})),defineJQueryPlugin(Collapse);const NAME$a="dropdown",DATA_KEY$6="bs.dropdown",EVENT_KEY$6=`.${DATA_KEY$6}`,DATA_API_KEY$3=".data-api",ESCAPE_KEY$2="Escape",TAB_KEY$1="Tab",ARROW_UP_KEY$1="ArrowUp",ARROW_DOWN_KEY$1="ArrowDown",RIGHT_MOUSE_BUTTON=2,EVENT_HIDE$5=`hide${EVENT_KEY$6}`,EVENT_HIDDEN$5=`hidden${EVENT_KEY$6}`,EVENT_SHOW$5=`show${EVENT_KEY$6}`,EVENT_SHOWN$5=`shown${EVENT_KEY$6}`,EVENT_CLICK_DATA_API$3=`click${EVENT_KEY$6}.data-api`,EVENT_KEYDOWN_DATA_API=`keydown${EVENT_KEY$6}.data-api`,EVENT_KEYUP_DATA_API=`keyup${EVENT_KEY$6}.data-api`,CLASS_NAME_SHOW$6="show",CLASS_NAME_DROPUP="dropup",CLASS_NAME_DROPEND="dropend",CLASS_NAME_DROPSTART="dropstart",CLASS_NAME_DROPUP_CENTER="dropup-center",CLASS_NAME_DROPDOWN_CENTER="dropdown-center",SELECTOR_DATA_TOGGLE$3='[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)',SELECTOR_DATA_TOGGLE_SHOWN=`${SELECTOR_DATA_TOGGLE$3}.show`,SELECTOR_MENU=".dropdown-menu",SELECTOR_NAVBAR=".navbar",SELECTOR_NAVBAR_NAV=".navbar-nav",SELECTOR_VISIBLE_ITEMS=".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)",PLACEMENT_TOP=isRTL()?"top-end":"top-start",PLACEMENT_TOPEND=isRTL()?"top-start":"top-end",PLACEMENT_BOTTOM=isRTL()?"bottom-end":"bottom-start",PLACEMENT_BOTTOMEND=isRTL()?"bottom-start":"bottom-end",PLACEMENT_RIGHT=isRTL()?"left-start":"right-start",PLACEMENT_LEFT=isRTL()?"right-start":"left-start",PLACEMENT_TOPCENTER="top",PLACEMENT_BOTTOMCENTER="bottom",Default$9={autoClose:!0,boundary:"clippingParents",display:"dynamic",offset:[0,2],popperConfig:null,reference:"toggle"},DefaultType$9={autoClose:"(boolean|string)",boundary:"(string|element)",display:"string",offset:"(array|string|function)",popperConfig:"(null|object|function)",reference:"(string|element|object)"};class Dropdown extends BaseComponent{constructor(e,t){super(e,t),this._popper=null,this._parent=this._element.parentNode,this._menu=SelectorEngine.next(this._element,SELECTOR_MENU)[0]||SelectorEngine.prev(this._element,SELECTOR_MENU)[0]||SelectorEngine.findOne(SELECTOR_MENU,this._parent),this._inNavbar=this._detectNavbar()}static get Default(){return Default$9}static get DefaultType(){return DefaultType$9}static get NAME(){return NAME$a}toggle(){return this._isShown()?this.hide():this.show()}show(){if(isDisabled(this._element)||this._isShown())return;const e={relatedTarget:this._element};if(!EventHandler.trigger(this._element,EVENT_SHOW$5,e).defaultPrevented){if(this._createPopper(),"ontouchstart"in document.documentElement&&!this._parent.closest(".navbar-nav"))for(const e of[].concat(...document.body.children))EventHandler.on(e,"mouseover",noop);this._element.focus(),this._element.setAttribute("aria-expanded",!0),this._menu.classList.add("show"),this._element.classList.add("show"),EventHandler.trigger(this._element,EVENT_SHOWN$5,e)}}hide(){if(isDisabled(this._element)||!this._isShown())return;const e={relatedTarget:this._element};this._completeHide(e)}dispose(){this._popper&&this._popper.destroy(),super.dispose()}update(){this._inNavbar=this._detectNavbar(),this._popper&&this._popper.update()}_completeHide(e){if(!EventHandler.trigger(this._element,EVENT_HIDE$5,e).defaultPrevented){if("ontouchstart"in document.documentElement)for(const e of[].concat(...document.body.children))EventHandler.off(e,"mouseover",noop);this._popper&&this._popper.destroy(),this._menu.classList.remove("show"),this._element.classList.remove("show"),this._element.setAttribute("aria-expanded","false"),Manipulator.removeDataAttribute(this._menu,"popper"),EventHandler.trigger(this._element,EVENT_HIDDEN$5,e)}}_getConfig(e){if("object"==typeof(e=super._getConfig(e)).reference&&!isElement(e.reference)&&"function"!=typeof e.reference.getBoundingClientRect)throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);return e}_createPopper(){if(void 0===Popper)throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org)");let e=this._element;"parent"===this._config.reference?e=this._parent:isElement(this._config.reference)?e=getElement(this._config.reference):"object"==typeof this._config.reference&&(e=this._config.reference);const t=this._getPopperConfig();this._popper=createPopper(e,this._menu,t)}_isShown(){return this._menu.classList.contains("show")}_getPlacement(){const e=this._parent;if(e.classList.contains("dropend"))return PLACEMENT_RIGHT;if(e.classList.contains("dropstart"))return PLACEMENT_LEFT;if(e.classList.contains("dropup-center"))return"top";if(e.classList.contains("dropdown-center"))return"bottom";const t="end"===getComputedStyle(this._menu).getPropertyValue("--bs-position").trim();return e.classList.contains("dropup")?t?PLACEMENT_TOPEND:PLACEMENT_TOP:t?PLACEMENT_BOTTOMEND:PLACEMENT_BOTTOM}_detectNavbar(){return null!==this._element.closest(".navbar")}_getOffset(){const{offset:e}=this._config;return"string"==typeof e?e.split(",").map((e=>Number.parseInt(e,10))):"function"==typeof e?t=>e(t,this._element):e}_getPopperConfig(){const e={placement:this._getPlacement(),modifiers:[{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"offset",options:{offset:this._getOffset()}}]};return(this._inNavbar||"static"===this._config.display)&&(Manipulator.setDataAttribute(this._menu,"popper","static"),e.modifiers=[{name:"applyStyles",enabled:!1}]),{...e,...execute(this._config.popperConfig,[e])}}_selectMenuItem({key:e,target:t}){const n=SelectorEngine.find(SELECTOR_VISIBLE_ITEMS,this._menu).filter((e=>isVisible(e)));n.length&&getNextActiveElement(n,t,e===ARROW_DOWN_KEY$1,!n.includes(t)).focus()}static jQueryInterface(e){return this.each((function(){const t=Dropdown.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e]()}}))}static clearMenus(e){if(2===e.button||"keyup"===e.type&&"Tab"!==e.key)return;const t=SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);for(const n of t){const t=Dropdown.getInstance(n);if(!t||!1===t._config.autoClose)continue;const i=e.composedPath(),s=i.includes(t._menu);if(i.includes(t._element)||"inside"===t._config.autoClose&&!s||"outside"===t._config.autoClose&&s)continue;if(t._menu.contains(e.target)&&("keyup"===e.type&&"Tab"===e.key||/input|select|option|textarea|form/i.test(e.target.tagName)))continue;const o={relatedTarget:t._element};"click"===e.type&&(o.clickEvent=e),t._completeHide(o)}}static dataApiKeydownHandler(e){const t=/input|textarea/i.test(e.target.tagName),n="Escape"===e.key,i=[ARROW_UP_KEY$1,ARROW_DOWN_KEY$1].includes(e.key);if(!i&&!n)return;if(t&&!n)return;e.preventDefault();const s=this.matches(SELECTOR_DATA_TOGGLE$3)?this:SelectorEngine.prev(this,SELECTOR_DATA_TOGGLE$3)[0]||SelectorEngine.next(this,SELECTOR_DATA_TOGGLE$3)[0]||SelectorEngine.findOne(SELECTOR_DATA_TOGGLE$3,e.delegateTarget.parentNode),o=Dropdown.getOrCreateInstance(s);if(i)return e.stopPropagation(),o.show(),void o._selectMenuItem(e);o._isShown()&&(e.stopPropagation(),o.hide(),s.focus())}}EventHandler.on(document,EVENT_KEYDOWN_DATA_API,SELECTOR_DATA_TOGGLE$3,Dropdown.dataApiKeydownHandler),EventHandler.on(document,EVENT_KEYDOWN_DATA_API,SELECTOR_MENU,Dropdown.dataApiKeydownHandler),EventHandler.on(document,EVENT_CLICK_DATA_API$3,Dropdown.clearMenus),EventHandler.on(document,EVENT_KEYUP_DATA_API,Dropdown.clearMenus),EventHandler.on(document,EVENT_CLICK_DATA_API$3,SELECTOR_DATA_TOGGLE$3,(function(e){e.preventDefault(),Dropdown.getOrCreateInstance(this).toggle()})),defineJQueryPlugin(Dropdown);const NAME$9="backdrop",CLASS_NAME_FADE$4="fade",CLASS_NAME_SHOW$5="show",EVENT_MOUSEDOWN=`mousedown.bs.${NAME$9}`,Default$8={className:"modal-backdrop",clickCallback:null,isAnimated:!1,isVisible:!0,rootElement:"body"},DefaultType$8={className:"string",clickCallback:"(function|null)",isAnimated:"boolean",isVisible:"boolean",rootElement:"(element|string)"};class Backdrop extends Config{constructor(e){super(),this._config=this._getConfig(e),this._isAppended=!1,this._element=null}static get Default(){return Default$8}static get DefaultType(){return DefaultType$8}static get NAME(){return NAME$9}show(e){if(!this._config.isVisible)return void execute(e);this._append();const t=this._getElement();this._config.isAnimated&&reflow(t),t.classList.add("show"),this._emulateAnimation((()=>{execute(e)}))}hide(e){this._config.isVisible?(this._getElement().classList.remove("show"),this._emulateAnimation((()=>{this.dispose(),execute(e)}))):execute(e)}dispose(){this._isAppended&&(EventHandler.off(this._element,EVENT_MOUSEDOWN),this._element.remove(),this._isAppended=!1)}_getElement(){if(!this._element){const e=document.createElement("div");e.className=this._config.className,this._config.isAnimated&&e.classList.add("fade"),this._element=e}return this._element}_configAfterMerge(e){return e.rootElement=getElement(e.rootElement),e}_append(){if(this._isAppended)return;const e=this._getElement();this._config.rootElement.append(e),EventHandler.on(e,EVENT_MOUSEDOWN,(()=>{execute(this._config.clickCallback)})),this._isAppended=!0}_emulateAnimation(e){executeAfterTransition(e,this._getElement(),this._config.isAnimated)}}const NAME$8="focustrap",DATA_KEY$5="bs.focustrap",EVENT_KEY$5=`.${DATA_KEY$5}`,EVENT_FOCUSIN$2=`focusin${EVENT_KEY$5}`,EVENT_KEYDOWN_TAB=`keydown.tab${EVENT_KEY$5}`,TAB_KEY="Tab",TAB_NAV_FORWARD="forward",TAB_NAV_BACKWARD="backward",Default$7={autofocus:!0,trapElement:null},DefaultType$7={autofocus:"boolean",trapElement:"element"};class FocusTrap extends Config{constructor(e){super(),this._config=this._getConfig(e),this._isActive=!1,this._lastTabNavDirection=null}static get Default(){return Default$7}static get DefaultType(){return DefaultType$7}static get NAME(){return NAME$8}activate(){this._isActive||(this._config.autofocus&&this._config.trapElement.focus(),EventHandler.off(document,EVENT_KEY$5),EventHandler.on(document,EVENT_FOCUSIN$2,(e=>this._handleFocusin(e))),EventHandler.on(document,EVENT_KEYDOWN_TAB,(e=>this._handleKeydown(e))),this._isActive=!0)}deactivate(){this._isActive&&(this._isActive=!1,EventHandler.off(document,EVENT_KEY$5))}_handleFocusin(e){const{trapElement:t}=this._config;if(e.target===document||e.target===t||t.contains(e.target))return;const n=SelectorEngine.focusableChildren(t);0===n.length?t.focus():"backward"===this._lastTabNavDirection?n[n.length-1].focus():n[0].focus()}_handleKeydown(e){"Tab"===e.key&&(this._lastTabNavDirection=e.shiftKey?"backward":"forward")}}const SELECTOR_FIXED_CONTENT=".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",SELECTOR_STICKY_CONTENT=".sticky-top",PROPERTY_PADDING="padding-right",PROPERTY_MARGIN="margin-right";class ScrollBarHelper{constructor(){this._element=document.body}getWidth(){const e=document.documentElement.clientWidth;return Math.abs(window.innerWidth-e)}hide(){const e=this.getWidth();this._disableOverFlow(),this._setElementAttributes(this._element,"padding-right",(t=>t+e)),this._setElementAttributes(SELECTOR_FIXED_CONTENT,"padding-right",(t=>t+e)),this._setElementAttributes(".sticky-top","margin-right",(t=>t-e))}reset(){this._resetElementAttributes(this._element,"overflow"),this._resetElementAttributes(this._element,"padding-right"),this._resetElementAttributes(SELECTOR_FIXED_CONTENT,"padding-right"),this._resetElementAttributes(".sticky-top","margin-right")}isOverflowing(){return this.getWidth()>0}_disableOverFlow(){this._saveInitialAttribute(this._element,"overflow"),this._element.style.overflow="hidden"}_setElementAttributes(e,t,n){const i=this.getWidth();this._applyManipulationCallback(e,(e=>{if(e!==this._element&&window.innerWidth>e.clientWidth+i)return;this._saveInitialAttribute(e,t);const s=window.getComputedStyle(e).getPropertyValue(t);e.style.setProperty(t,`${n(Number.parseFloat(s))}px`)}))}_saveInitialAttribute(e,t){const n=e.style.getPropertyValue(t);n&&Manipulator.setDataAttribute(e,t,n)}_resetElementAttributes(e,t){this._applyManipulationCallback(e,(e=>{const n=Manipulator.getDataAttribute(e,t);null!==n?(Manipulator.removeDataAttribute(e,t),e.style.setProperty(t,n)):e.style.removeProperty(t)}))}_applyManipulationCallback(e,t){if(isElement(e))t(e);else for(const n of SelectorEngine.find(e,this._element))t(n)}}const NAME$7="modal",DATA_KEY$4="bs.modal",EVENT_KEY$4=".bs.modal",DATA_API_KEY$2=".data-api",ESCAPE_KEY$1="Escape",EVENT_HIDE$4="hide.bs.modal",EVENT_HIDE_PREVENTED$1="hidePrevented.bs.modal",EVENT_HIDDEN$4="hidden.bs.modal",EVENT_SHOW$4="show.bs.modal",EVENT_SHOWN$4="shown.bs.modal",EVENT_RESIZE$1="resize.bs.modal",EVENT_CLICK_DISMISS="click.dismiss.bs.modal",EVENT_MOUSEDOWN_DISMISS="mousedown.dismiss.bs.modal",EVENT_KEYDOWN_DISMISS$1="keydown.dismiss.bs.modal",EVENT_CLICK_DATA_API$2="click.bs.modal.data-api",CLASS_NAME_OPEN="modal-open",CLASS_NAME_FADE$3="fade",CLASS_NAME_SHOW$4="show",CLASS_NAME_STATIC="modal-static",OPEN_SELECTOR$1=".modal.show",SELECTOR_DIALOG=".modal-dialog",SELECTOR_MODAL_BODY=".modal-body",SELECTOR_DATA_TOGGLE$2='[data-bs-toggle="modal"]',Default$6={backdrop:!0,focus:!0,keyboard:!0},DefaultType$6={backdrop:"(boolean|string)",focus:"boolean",keyboard:"boolean"};class Modal extends BaseComponent{constructor(e,t){super(e,t),this._dialog=SelectorEngine.findOne(".modal-dialog",this._element),this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._isShown=!1,this._isTransitioning=!1,this._scrollBar=new ScrollBarHelper,this._addEventListeners()}static get Default(){return Default$6}static get DefaultType(){return DefaultType$6}static get NAME(){return NAME$7}toggle(e){return this._isShown?this.hide():this.show(e)}show(e){if(this._isShown||this._isTransitioning)return;EventHandler.trigger(this._element,EVENT_SHOW$4,{relatedTarget:e}).defaultPrevented||(this._isShown=!0,this._isTransitioning=!0,this._scrollBar.hide(),document.body.classList.add("modal-open"),this._adjustDialog(),this._backdrop.show((()=>this._showElement(e))))}hide(){if(!this._isShown||this._isTransitioning)return;EventHandler.trigger(this._element,EVENT_HIDE$4).defaultPrevented||(this._isShown=!1,this._isTransitioning=!0,this._focustrap.deactivate(),this._element.classList.remove("show"),this._queueCallback((()=>this._hideModal()),this._element,this._isAnimated()))}dispose(){EventHandler.off(window,".bs.modal"),EventHandler.off(this._dialog,".bs.modal"),this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}handleUpdate(){this._adjustDialog()}_initializeBackDrop(){return new Backdrop({isVisible:Boolean(this._config.backdrop),isAnimated:this._isAnimated()})}_initializeFocusTrap(){return new FocusTrap({trapElement:this._element})}_showElement(e){document.body.contains(this._element)||document.body.append(this._element),this._element.style.display="block",this._element.removeAttribute("aria-hidden"),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.scrollTop=0;const t=SelectorEngine.findOne(".modal-body",this._dialog);t&&(t.scrollTop=0),reflow(this._element),this._element.classList.add("show");this._queueCallback((()=>{this._config.focus&&this._focustrap.activate(),this._isTransitioning=!1,EventHandler.trigger(this._element,EVENT_SHOWN$4,{relatedTarget:e})}),this._dialog,this._isAnimated())}_addEventListeners(){EventHandler.on(this._element,EVENT_KEYDOWN_DISMISS$1,(e=>{"Escape"===e.key&&(this._config.keyboard?this.hide():this._triggerBackdropTransition())})),EventHandler.on(window,EVENT_RESIZE$1,(()=>{this._isShown&&!this._isTransitioning&&this._adjustDialog()})),EventHandler.on(this._element,EVENT_MOUSEDOWN_DISMISS,(e=>{EventHandler.one(this._element,EVENT_CLICK_DISMISS,(t=>{this._element===e.target&&this._element===t.target&&("static"!==this._config.backdrop?this._config.backdrop&&this.hide():this._triggerBackdropTransition())}))}))}_hideModal(){this._element.style.display="none",this._element.setAttribute("aria-hidden",!0),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._isTransitioning=!1,this._backdrop.hide((()=>{document.body.classList.remove("modal-open"),this._resetAdjustments(),this._scrollBar.reset(),EventHandler.trigger(this._element,EVENT_HIDDEN$4)}))}_isAnimated(){return this._element.classList.contains("fade")}_triggerBackdropTransition(){if(EventHandler.trigger(this._element,EVENT_HIDE_PREVENTED$1).defaultPrevented)return;const e=this._element.scrollHeight>document.documentElement.clientHeight,t=this._element.style.overflowY;"hidden"===t||this._element.classList.contains("modal-static")||(e||(this._element.style.overflowY="hidden"),this._element.classList.add("modal-static"),this._queueCallback((()=>{this._element.classList.remove("modal-static"),this._queueCallback((()=>{this._element.style.overflowY=t}),this._dialog)}),this._dialog),this._element.focus())}_adjustDialog(){const e=this._element.scrollHeight>document.documentElement.clientHeight,t=this._scrollBar.getWidth(),n=t>0;if(n&&!e){const e=isRTL()?"paddingLeft":"paddingRight";this._element.style[e]=`${t}px`}if(!n&&e){const e=isRTL()?"paddingRight":"paddingLeft";this._element.style[e]=`${t}px`}}_resetAdjustments(){this._element.style.paddingLeft="",this._element.style.paddingRight=""}static jQueryInterface(e,t){return this.each((function(){const n=Modal.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===n[e])throw new TypeError(`No method named "${e}"`);n[e](t)}}))}}EventHandler.on(document,EVENT_CLICK_DATA_API$2,SELECTOR_DATA_TOGGLE$2,(function(e){const t=SelectorEngine.getElementFromSelector(this);["A","AREA"].includes(this.tagName)&&e.preventDefault(),EventHandler.one(t,EVENT_SHOW$4,(e=>{e.defaultPrevented||EventHandler.one(t,EVENT_HIDDEN$4,(()=>{isVisible(this)&&this.focus()}))}));const n=SelectorEngine.findOne(".modal.show");n&&Modal.getInstance(n).hide();Modal.getOrCreateInstance(t).toggle(this)})),enableDismissTrigger(Modal),defineJQueryPlugin(Modal);const NAME$6="offcanvas",DATA_KEY$3="bs.offcanvas",EVENT_KEY$3=`.${DATA_KEY$3}`,DATA_API_KEY$1=".data-api",EVENT_LOAD_DATA_API$2=`load${EVENT_KEY$3}.data-api`,ESCAPE_KEY="Escape",CLASS_NAME_SHOW$3="show",CLASS_NAME_SHOWING$1="showing",CLASS_NAME_HIDING="hiding",CLASS_NAME_BACKDROP="offcanvas-backdrop",OPEN_SELECTOR=".offcanvas.show",EVENT_SHOW$3=`show${EVENT_KEY$3}`,EVENT_SHOWN$3=`shown${EVENT_KEY$3}`,EVENT_HIDE$3=`hide${EVENT_KEY$3}`,EVENT_HIDE_PREVENTED=`hidePrevented${EVENT_KEY$3}`,EVENT_HIDDEN$3=`hidden${EVENT_KEY$3}`,EVENT_RESIZE=`resize${EVENT_KEY$3}`,EVENT_CLICK_DATA_API$1=`click${EVENT_KEY$3}.data-api`,EVENT_KEYDOWN_DISMISS=`keydown.dismiss${EVENT_KEY$3}`,SELECTOR_DATA_TOGGLE$1='[data-bs-toggle="offcanvas"]',Default$5={backdrop:!0,keyboard:!0,scroll:!1},DefaultType$5={backdrop:"(boolean|string)",keyboard:"boolean",scroll:"boolean"};class Offcanvas extends BaseComponent{constructor(e,t){super(e,t),this._isShown=!1,this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._addEventListeners()}static get Default(){return Default$5}static get DefaultType(){return DefaultType$5}static get NAME(){return NAME$6}toggle(e){return this._isShown?this.hide():this.show(e)}show(e){if(this._isShown)return;if(EventHandler.trigger(this._element,EVENT_SHOW$3,{relatedTarget:e}).defaultPrevented)return;this._isShown=!0,this._backdrop.show(),this._config.scroll||(new ScrollBarHelper).hide(),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.classList.add("showing");this._queueCallback((()=>{this._config.scroll&&!this._config.backdrop||this._focustrap.activate(),this._element.classList.add("show"),this._element.classList.remove("showing"),EventHandler.trigger(this._element,EVENT_SHOWN$3,{relatedTarget:e})}),this._element,!0)}hide(){if(!this._isShown)return;if(EventHandler.trigger(this._element,EVENT_HIDE$3).defaultPrevented)return;this._focustrap.deactivate(),this._element.blur(),this._isShown=!1,this._element.classList.add("hiding"),this._backdrop.hide();this._queueCallback((()=>{this._element.classList.remove("show","hiding"),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._config.scroll||(new ScrollBarHelper).reset(),EventHandler.trigger(this._element,EVENT_HIDDEN$3)}),this._element,!0)}dispose(){this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}_initializeBackDrop(){const e=Boolean(this._config.backdrop);return new Backdrop({className:CLASS_NAME_BACKDROP,isVisible:e,isAnimated:!0,rootElement:this._element.parentNode,clickCallback:e?()=>{"static"!==this._config.backdrop?this.hide():EventHandler.trigger(this._element,EVENT_HIDE_PREVENTED)}:null})}_initializeFocusTrap(){return new FocusTrap({trapElement:this._element})}_addEventListeners(){EventHandler.on(this._element,EVENT_KEYDOWN_DISMISS,(e=>{"Escape"===e.key&&(this._config.keyboard?this.hide():EventHandler.trigger(this._element,EVENT_HIDE_PREVENTED))}))}static jQueryInterface(e){return this.each((function(){const t=Offcanvas.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e](this)}}))}}EventHandler.on(document,EVENT_CLICK_DATA_API$1,SELECTOR_DATA_TOGGLE$1,(function(e){const t=SelectorEngine.getElementFromSelector(this);if(["A","AREA"].includes(this.tagName)&&e.preventDefault(),isDisabled(this))return;EventHandler.one(t,EVENT_HIDDEN$3,(()=>{isVisible(this)&&this.focus()}));const n=SelectorEngine.findOne(OPEN_SELECTOR);n&&n!==t&&Offcanvas.getInstance(n).hide();Offcanvas.getOrCreateInstance(t).toggle(this)})),EventHandler.on(window,EVENT_LOAD_DATA_API$2,(()=>{for(const e of SelectorEngine.find(OPEN_SELECTOR))Offcanvas.getOrCreateInstance(e).show()})),EventHandler.on(window,EVENT_RESIZE,(()=>{for(const e of SelectorEngine.find("[aria-modal][class*=show][class*=offcanvas-]"))"fixed"!==getComputedStyle(e).position&&Offcanvas.getOrCreateInstance(e).hide()})),enableDismissTrigger(Offcanvas),defineJQueryPlugin(Offcanvas);const ARIA_ATTRIBUTE_PATTERN=/^aria-[\w-]*$/i,DefaultAllowlist={"*":["class","dir","id","lang","role",ARIA_ATTRIBUTE_PATTERN],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","srcset","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},uriAttributes=new Set(["background","cite","href","itemtype","longdesc","poster","src","xlink:href"]),SAFE_URL_PATTERN=/^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i,allowedAttribute=(e,t)=>{const n=e.nodeName.toLowerCase();return t.includes(n)?!uriAttributes.has(n)||Boolean(SAFE_URL_PATTERN.test(e.nodeValue)):t.filter((e=>e instanceof RegExp)).some((e=>e.test(n)))};function sanitizeHtml(e,t,n){if(!e.length)return e;if(n&&"function"==typeof n)return n(e);const i=(new window.DOMParser).parseFromString(e,"text/html"),s=[].concat(...i.body.querySelectorAll("*"));for(const e of s){const n=e.nodeName.toLowerCase();if(!Object.keys(t).includes(n)){e.remove();continue}const i=[].concat(...e.attributes),s=[].concat(t["*"]||[],t[n]||[]);for(const t of i)allowedAttribute(t,s)||e.removeAttribute(t.nodeName)}return i.body.innerHTML}const NAME$5="TemplateFactory",Default$4={allowList:DefaultAllowlist,content:{},extraClass:"",html:!1,sanitize:!0,sanitizeFn:null,template:"<div></div>"},DefaultType$4={allowList:"object",content:"object",extraClass:"(string|function)",html:"boolean",sanitize:"boolean",sanitizeFn:"(null|function)",template:"string"},DefaultContentType={entry:"(string|element|function|null)",selector:"(string|element)"};class TemplateFactory extends Config{constructor(e){super(),this._config=this._getConfig(e)}static get Default(){return Default$4}static get DefaultType(){return DefaultType$4}static get NAME(){return NAME$5}getContent(){return Object.values(this._config.content).map((e=>this._resolvePossibleFunction(e))).filter(Boolean)}hasContent(){return this.getContent().length>0}changeContent(e){return this._checkContent(e),this._config.content={...this._config.content,...e},this}toHtml(){const e=document.createElement("div");e.innerHTML=this._maybeSanitize(this._config.template);for(const[t,n]of Object.entries(this._config.content))this._setContent(e,n,t);const t=e.children[0],n=this._resolvePossibleFunction(this._config.extraClass);return n&&t.classList.add(...n.split(" ")),t}_typeCheckConfig(e){super._typeCheckConfig(e),this._checkContent(e.content)}_checkContent(e){for(const[t,n]of Object.entries(e))super._typeCheckConfig({selector:t,entry:n},DefaultContentType)}_setContent(e,t,n){const i=SelectorEngine.findOne(n,e);i&&((t=this._resolvePossibleFunction(t))?isElement(t)?this._putElementInTemplate(getElement(t),i):this._config.html?i.innerHTML=this._maybeSanitize(t):i.textContent=t:i.remove())}_maybeSanitize(e){return this._config.sanitize?sanitizeHtml(e,this._config.allowList,this._config.sanitizeFn):e}_resolvePossibleFunction(e){return execute(e,[this])}_putElementInTemplate(e,t){if(this._config.html)return t.innerHTML="",void t.append(e);t.textContent=e.textContent}}const NAME$4="tooltip",DISALLOWED_ATTRIBUTES=new Set(["sanitize","allowList","sanitizeFn"]),CLASS_NAME_FADE$2="fade",CLASS_NAME_MODAL="modal",CLASS_NAME_SHOW$2="show",SELECTOR_TOOLTIP_INNER=".tooltip-inner",SELECTOR_MODAL=".modal",EVENT_MODAL_HIDE="hide.bs.modal",TRIGGER_HOVER="hover",TRIGGER_FOCUS="focus",TRIGGER_CLICK="click",TRIGGER_MANUAL="manual",EVENT_HIDE$2="hide",EVENT_HIDDEN$2="hidden",EVENT_SHOW$2="show",EVENT_SHOWN$2="shown",EVENT_INSERTED="inserted",EVENT_CLICK$1="click",EVENT_FOCUSIN$1="focusin",EVENT_FOCUSOUT$1="focusout",EVENT_MOUSEENTER="mouseenter",EVENT_MOUSELEAVE="mouseleave",AttachmentMap={AUTO:"auto",TOP:"top",RIGHT:isRTL()?"left":"right",BOTTOM:"bottom",LEFT:isRTL()?"right":"left"},Default$3={allowList:DefaultAllowlist,animation:!0,boundary:"clippingParents",container:!1,customClass:"",delay:0,fallbackPlacements:["top","right","bottom","left"],html:!1,offset:[0,6],placement:"top",popperConfig:null,sanitize:!0,sanitizeFn:null,selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',title:"",trigger:"hover focus"},DefaultType$3={allowList:"object",animation:"boolean",boundary:"(string|element)",container:"(string|element|boolean)",customClass:"(string|function)",delay:"(number|object)",fallbackPlacements:"array",html:"boolean",offset:"(array|string|function)",placement:"(string|function)",popperConfig:"(null|object|function)",sanitize:"boolean",sanitizeFn:"(null|function)",selector:"(string|boolean)",template:"string",title:"(string|element|function)",trigger:"string"};class Tooltip extends BaseComponent{constructor(e,t){if(void 0===Popper)throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");super(e,t),this._isEnabled=!0,this._timeout=0,this._isHovered=null,this._activeTrigger={},this._popper=null,this._templateFactory=null,this._newContent=null,this.tip=null,this._setListeners(),this._config.selector||this._fixTitle()}static get Default(){return Default$3}static get DefaultType(){return DefaultType$3}static get NAME(){return NAME$4}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}toggleEnabled(){this._isEnabled=!this._isEnabled}toggle(){this._isEnabled&&(this._activeTrigger.click=!this._activeTrigger.click,this._isShown()?this._leave():this._enter())}dispose(){clearTimeout(this._timeout),EventHandler.off(this._element.closest(".modal"),"hide.bs.modal",this._hideModalHandler),this._element.getAttribute("data-bs-original-title")&&this._element.setAttribute("title",this._element.getAttribute("data-bs-original-title")),this._disposePopper(),super.dispose()}show(){if("none"===this._element.style.display)throw new Error("Please use show on visible elements");if(!this._isWithContent()||!this._isEnabled)return;const e=EventHandler.trigger(this._element,this.constructor.eventName("show")),t=(findShadowRoot(this._element)||this._element.ownerDocument.documentElement).contains(this._element);if(e.defaultPrevented||!t)return;this._disposePopper();const n=this._getTipElement();this._element.setAttribute("aria-describedby",n.getAttribute("id"));const{container:i}=this._config;if(this._element.ownerDocument.documentElement.contains(this.tip)||(i.append(n),EventHandler.trigger(this._element,this.constructor.eventName("inserted"))),this._popper=this._createPopper(n),n.classList.add("show"),"ontouchstart"in document.documentElement)for(const e of[].concat(...document.body.children))EventHandler.on(e,"mouseover",noop);this._queueCallback((()=>{EventHandler.trigger(this._element,this.constructor.eventName("shown")),!1===this._isHovered&&this._leave(),this._isHovered=!1}),this.tip,this._isAnimated())}hide(){if(!this._isShown())return;if(EventHandler.trigger(this._element,this.constructor.eventName("hide")).defaultPrevented)return;if(this._getTipElement().classList.remove("show"),"ontouchstart"in document.documentElement)for(const e of[].concat(...document.body.children))EventHandler.off(e,"mouseover",noop);this._activeTrigger.click=!1,this._activeTrigger.focus=!1,this._activeTrigger.hover=!1,this._isHovered=null;this._queueCallback((()=>{this._isWithActiveTrigger()||(this._isHovered||this._disposePopper(),this._element.removeAttribute("aria-describedby"),EventHandler.trigger(this._element,this.constructor.eventName("hidden")))}),this.tip,this._isAnimated())}update(){this._popper&&this._popper.update()}_isWithContent(){return Boolean(this._getTitle())}_getTipElement(){return this.tip||(this.tip=this._createTipElement(this._newContent||this._getContentForTemplate())),this.tip}_createTipElement(e){const t=this._getTemplateFactory(e).toHtml();if(!t)return null;t.classList.remove("fade","show"),t.classList.add(`bs-${this.constructor.NAME}-auto`);const n=getUID(this.constructor.NAME).toString();return t.setAttribute("id",n),this._isAnimated()&&t.classList.add("fade"),t}setContent(e){this._newContent=e,this._isShown()&&(this._disposePopper(),this.show())}_getTemplateFactory(e){return this._templateFactory?this._templateFactory.changeContent(e):this._templateFactory=new TemplateFactory({...this._config,content:e,extraClass:this._resolvePossibleFunction(this._config.customClass)}),this._templateFactory}_getContentForTemplate(){return{".tooltip-inner":this._getTitle()}}_getTitle(){return this._resolvePossibleFunction(this._config.title)||this._element.getAttribute("data-bs-original-title")}_initializeOnDelegatedTarget(e){return this.constructor.getOrCreateInstance(e.delegateTarget,this._getDelegateConfig())}_isAnimated(){return this._config.animation||this.tip&&this.tip.classList.contains("fade")}_isShown(){return this.tip&&this.tip.classList.contains("show")}_createPopper(e){const t=execute(this._config.placement,[this,e,this._element]),n=AttachmentMap[t.toUpperCase()];return createPopper(this._element,e,this._getPopperConfig(n))}_getOffset(){const{offset:e}=this._config;return"string"==typeof e?e.split(",").map((e=>Number.parseInt(e,10))):"function"==typeof e?t=>e(t,this._element):e}_resolvePossibleFunction(e){return execute(e,[this._element])}_getPopperConfig(e){const t={placement:e,modifiers:[{name:"flip",options:{fallbackPlacements:this._config.fallbackPlacements}},{name:"offset",options:{offset:this._getOffset()}},{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"arrow",options:{element:`.${this.constructor.NAME}-arrow`}},{name:"preSetPlacement",enabled:!0,phase:"beforeMain",fn:e=>{this._getTipElement().setAttribute("data-popper-placement",e.state.placement)}}]};return{...t,...execute(this._config.popperConfig,[t])}}_setListeners(){const e=this._config.trigger.split(" ");for(const t of e)if("click"===t)EventHandler.on(this._element,this.constructor.eventName("click"),this._config.selector,(e=>{this._initializeOnDelegatedTarget(e).toggle()}));else if("manual"!==t){const e="hover"===t?this.constructor.eventName("mouseenter"):this.constructor.eventName("focusin"),n="hover"===t?this.constructor.eventName("mouseleave"):this.constructor.eventName("focusout");EventHandler.on(this._element,e,this._config.selector,(e=>{const t=this._initializeOnDelegatedTarget(e);t._activeTrigger["focusin"===e.type?"focus":"hover"]=!0,t._enter()})),EventHandler.on(this._element,n,this._config.selector,(e=>{const t=this._initializeOnDelegatedTarget(e);t._activeTrigger["focusout"===e.type?"focus":"hover"]=t._element.contains(e.relatedTarget),t._leave()}))}this._hideModalHandler=()=>{this._element&&this.hide()},EventHandler.on(this._element.closest(".modal"),"hide.bs.modal",this._hideModalHandler)}_fixTitle(){const e=this._element.getAttribute("title");e&&(this._element.getAttribute("aria-label")||this._element.textContent.trim()||this._element.setAttribute("aria-label",e),this._element.setAttribute("data-bs-original-title",e),this._element.removeAttribute("title"))}_enter(){this._isShown()||this._isHovered?this._isHovered=!0:(this._isHovered=!0,this._setTimeout((()=>{this._isHovered&&this.show()}),this._config.delay.show))}_leave(){this._isWithActiveTrigger()||(this._isHovered=!1,this._setTimeout((()=>{this._isHovered||this.hide()}),this._config.delay.hide))}_setTimeout(e,t){clearTimeout(this._timeout),this._timeout=setTimeout(e,t)}_isWithActiveTrigger(){return Object.values(this._activeTrigger).includes(!0)}_getConfig(e){const t=Manipulator.getDataAttributes(this._element);for(const e of Object.keys(t))DISALLOWED_ATTRIBUTES.has(e)&&delete t[e];return e={...t,..."object"==typeof e&&e?e:{}},e=this._mergeConfigObj(e),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}_configAfterMerge(e){return e.container=!1===e.container?document.body:getElement(e.container),"number"==typeof e.delay&&(e.delay={show:e.delay,hide:e.delay}),"number"==typeof e.title&&(e.title=e.title.toString()),"number"==typeof e.content&&(e.content=e.content.toString()),e}_getDelegateConfig(){const e={};for(const[t,n]of Object.entries(this._config))this.constructor.Default[t]!==n&&(e[t]=n);return e.selector=!1,e.trigger="manual",e}_disposePopper(){this._popper&&(this._popper.destroy(),this._popper=null),this.tip&&(this.tip.remove(),this.tip=null)}static jQueryInterface(e){return this.each((function(){const t=Tooltip.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e]()}}))}}defineJQueryPlugin(Tooltip);const NAME$3="popover",SELECTOR_TITLE=".popover-header",SELECTOR_CONTENT=".popover-body",Default$2={...Tooltip.Default,content:"",offset:[0,8],placement:"right",template:'<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>',trigger:"click"},DefaultType$2={...Tooltip.DefaultType,content:"(null|string|element|function)"};class Popover extends Tooltip{static get Default(){return Default$2}static get DefaultType(){return DefaultType$2}static get NAME(){return NAME$3}_isWithContent(){return this._getTitle()||this._getContent()}_getContentForTemplate(){return{[SELECTOR_TITLE]:this._getTitle(),".popover-body":this._getContent()}}_getContent(){return this._resolvePossibleFunction(this._config.content)}static jQueryInterface(e){return this.each((function(){const t=Popover.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e]()}}))}}defineJQueryPlugin(Popover);const NAME$2="scrollspy",DATA_KEY$2="bs.scrollspy",EVENT_KEY$2=`.${DATA_KEY$2}`,DATA_API_KEY=".data-api",EVENT_ACTIVATE=`activate${EVENT_KEY$2}`,EVENT_CLICK=`click${EVENT_KEY$2}`,EVENT_LOAD_DATA_API$1=`load${EVENT_KEY$2}.data-api`,CLASS_NAME_DROPDOWN_ITEM="dropdown-item",CLASS_NAME_ACTIVE$1="active",SELECTOR_DATA_SPY='[data-bs-spy="scroll"]',SELECTOR_TARGET_LINKS="[href]",SELECTOR_NAV_LIST_GROUP=".nav, .list-group",SELECTOR_NAV_LINKS=".nav-link",SELECTOR_NAV_ITEMS=".nav-item",SELECTOR_LIST_ITEMS=".list-group-item",SELECTOR_LINK_ITEMS=".nav-link, .nav-item > .nav-link, .list-group-item",SELECTOR_DROPDOWN=".dropdown",SELECTOR_DROPDOWN_TOGGLE$1=".dropdown-toggle",Default$1={offset:null,rootMargin:"0px 0px -25%",smoothScroll:!1,target:null,threshold:[.1,.5,1]},DefaultType$1={offset:"(number|null)",rootMargin:"string",smoothScroll:"boolean",target:"element",threshold:"array"};class ScrollSpy extends BaseComponent{constructor(e,t){super(e,t),this._targetLinks=new Map,this._observableSections=new Map,this._rootElement="visible"===getComputedStyle(this._element).overflowY?null:this._element,this._activeTarget=null,this._observer=null,this._previousScrollData={visibleEntryTop:0,parentScrollTop:0},this.refresh()}static get Default(){return Default$1}static get DefaultType(){return DefaultType$1}static get NAME(){return NAME$2}refresh(){this._initializeTargetsAndObservables(),this._maybeEnableSmoothScroll(),this._observer?this._observer.disconnect():this._observer=this._getNewObserver();for(const e of this._observableSections.values())this._observer.observe(e)}dispose(){this._observer.disconnect(),super.dispose()}_configAfterMerge(e){return e.target=getElement(e.target)||document.body,e.rootMargin=e.offset?`${e.offset}px 0px -30%`:e.rootMargin,"string"==typeof e.threshold&&(e.threshold=e.threshold.split(",").map((e=>Number.parseFloat(e)))),e}_maybeEnableSmoothScroll(){this._config.smoothScroll&&(EventHandler.off(this._config.target,EVENT_CLICK),EventHandler.on(this._config.target,EVENT_CLICK,"[href]",(e=>{const t=this._observableSections.get(e.target.hash);if(t){e.preventDefault();const n=this._rootElement||window,i=t.offsetTop-this._element.offsetTop;if(n.scrollTo)return void n.scrollTo({top:i,behavior:"smooth"});n.scrollTop=i}})))}_getNewObserver(){const e={root:this._rootElement,threshold:this._config.threshold,rootMargin:this._config.rootMargin};return new IntersectionObserver((e=>this._observerCallback(e)),e)}_observerCallback(e){const t=e=>this._targetLinks.get(`#${e.target.id}`),n=e=>{this._previousScrollData.visibleEntryTop=e.target.offsetTop,this._process(t(e))},i=(this._rootElement||document.documentElement).scrollTop,s=i>=this._previousScrollData.parentScrollTop;this._previousScrollData.parentScrollTop=i;for(const o of e){if(!o.isIntersecting){this._activeTarget=null,this._clearActiveClass(t(o));continue}const e=o.target.offsetTop>=this._previousScrollData.visibleEntryTop;if(s&&e){if(n(o),!i)return}else s||e||n(o)}}_initializeTargetsAndObservables(){this._targetLinks=new Map,this._observableSections=new Map;const e=SelectorEngine.find("[href]",this._config.target);for(const t of e){if(!t.hash||isDisabled(t))continue;const e=SelectorEngine.findOne(decodeURI(t.hash),this._element);isVisible(e)&&(this._targetLinks.set(decodeURI(t.hash),t),this._observableSections.set(t.hash,e))}}_process(e){this._activeTarget!==e&&(this._clearActiveClass(this._config.target),this._activeTarget=e,e.classList.add("active"),this._activateParents(e),EventHandler.trigger(this._element,EVENT_ACTIVATE,{relatedTarget:e}))}_activateParents(e){if(e.classList.contains("dropdown-item"))SelectorEngine.findOne(".dropdown-toggle",e.closest(".dropdown")).classList.add("active");else for(const t of SelectorEngine.parents(e,".nav, .list-group"))for(const e of SelectorEngine.prev(t,SELECTOR_LINK_ITEMS))e.classList.add("active")}_clearActiveClass(e){e.classList.remove("active");const t=SelectorEngine.find("[href].active",e);for(const e of t)e.classList.remove("active")}static jQueryInterface(e){return this.each((function(){const t=ScrollSpy.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e]()}}))}}EventHandler.on(window,EVENT_LOAD_DATA_API$1,(()=>{for(const e of SelectorEngine.find(SELECTOR_DATA_SPY))ScrollSpy.getOrCreateInstance(e)})),defineJQueryPlugin(ScrollSpy);const NAME$1="tab",DATA_KEY$1="bs.tab",EVENT_KEY$1=".bs.tab",EVENT_HIDE$1="hide.bs.tab",EVENT_HIDDEN$1="hidden.bs.tab",EVENT_SHOW$1="show.bs.tab",EVENT_SHOWN$1="shown.bs.tab",EVENT_CLICK_DATA_API="click.bs.tab",EVENT_KEYDOWN="keydown.bs.tab",EVENT_LOAD_DATA_API="load.bs.tab",ARROW_LEFT_KEY="ArrowLeft",ARROW_RIGHT_KEY="ArrowRight",ARROW_UP_KEY="ArrowUp",ARROW_DOWN_KEY="ArrowDown",HOME_KEY="Home",END_KEY="End",CLASS_NAME_ACTIVE="active",CLASS_NAME_FADE$1="fade",CLASS_NAME_SHOW$1="show",CLASS_DROPDOWN="dropdown",SELECTOR_DROPDOWN_TOGGLE=".dropdown-toggle",SELECTOR_DROPDOWN_MENU=".dropdown-menu",NOT_SELECTOR_DROPDOWN_TOGGLE=":not(.dropdown-toggle)",SELECTOR_TAB_PANEL='.list-group, .nav, [role="tablist"]',SELECTOR_OUTER=".nav-item, .list-group-item",SELECTOR_INNER='.nav-link:not(.dropdown-toggle), .list-group-item:not(.dropdown-toggle), [role="tab"]:not(.dropdown-toggle)',SELECTOR_DATA_TOGGLE='[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]',SELECTOR_INNER_ELEM=`${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`,SELECTOR_DATA_TOGGLE_ACTIVE='.active[data-bs-toggle="tab"], .active[data-bs-toggle="pill"], .active[data-bs-toggle="list"]';class Tab extends BaseComponent{constructor(e){super(e),this._parent=this._element.closest(SELECTOR_TAB_PANEL),this._parent&&(this._setInitialAttributes(this._parent,this._getChildren()),EventHandler.on(this._element,EVENT_KEYDOWN,(e=>this._keydown(e))))}static get NAME(){return"tab"}show(){const e=this._element;if(this._elemIsActive(e))return;const t=this._getActiveElem(),n=t?EventHandler.trigger(t,EVENT_HIDE$1,{relatedTarget:e}):null;EventHandler.trigger(e,EVENT_SHOW$1,{relatedTarget:t}).defaultPrevented||n&&n.defaultPrevented||(this._deactivate(t,e),this._activate(e,t))}_activate(e,t){if(!e)return;e.classList.add("active"),this._activate(SelectorEngine.getElementFromSelector(e));this._queueCallback((()=>{"tab"===e.getAttribute("role")?(e.removeAttribute("tabindex"),e.setAttribute("aria-selected",!0),this._toggleDropDown(e,!0),EventHandler.trigger(e,EVENT_SHOWN$1,{relatedTarget:t})):e.classList.add("show")}),e,e.classList.contains("fade"))}_deactivate(e,t){if(!e)return;e.classList.remove("active"),e.blur(),this._deactivate(SelectorEngine.getElementFromSelector(e));this._queueCallback((()=>{"tab"===e.getAttribute("role")?(e.setAttribute("aria-selected",!1),e.setAttribute("tabindex","-1"),this._toggleDropDown(e,!1),EventHandler.trigger(e,EVENT_HIDDEN$1,{relatedTarget:t})):e.classList.remove("show")}),e,e.classList.contains("fade"))}_keydown(e){if(![ARROW_LEFT_KEY,ARROW_RIGHT_KEY,ARROW_UP_KEY,ARROW_DOWN_KEY,HOME_KEY,END_KEY].includes(e.key))return;e.stopPropagation(),e.preventDefault();const t=this._getChildren().filter((e=>!isDisabled(e)));let n;if([HOME_KEY,END_KEY].includes(e.key))n=t[e.key===HOME_KEY?0:t.length-1];else{const i=[ARROW_RIGHT_KEY,ARROW_DOWN_KEY].includes(e.key);n=getNextActiveElement(t,e.target,i,!0)}n&&(n.focus({preventScroll:!0}),Tab.getOrCreateInstance(n).show())}_getChildren(){return SelectorEngine.find(SELECTOR_INNER_ELEM,this._parent)}_getActiveElem(){return this._getChildren().find((e=>this._elemIsActive(e)))||null}_setInitialAttributes(e,t){this._setAttributeIfNotExists(e,"role","tablist");for(const e of t)this._setInitialAttributesOnChild(e)}_setInitialAttributesOnChild(e){e=this._getInnerElement(e);const t=this._elemIsActive(e),n=this._getOuterElement(e);e.setAttribute("aria-selected",t),n!==e&&this._setAttributeIfNotExists(n,"role","presentation"),t||e.setAttribute("tabindex","-1"),this._setAttributeIfNotExists(e,"role","tab"),this._setInitialAttributesOnTargetPanel(e)}_setInitialAttributesOnTargetPanel(e){const t=SelectorEngine.getElementFromSelector(e);t&&(this._setAttributeIfNotExists(t,"role","tabpanel"),e.id&&this._setAttributeIfNotExists(t,"aria-labelledby",`${e.id}`))}_toggleDropDown(e,t){const n=this._getOuterElement(e);if(!n.classList.contains("dropdown"))return;const i=(e,i)=>{const s=SelectorEngine.findOne(e,n);s&&s.classList.toggle(i,t)};i(".dropdown-toggle","active"),i(".dropdown-menu","show"),n.setAttribute("aria-expanded",t)}_setAttributeIfNotExists(e,t,n){e.hasAttribute(t)||e.setAttribute(t,n)}_elemIsActive(e){return e.classList.contains("active")}_getInnerElement(e){return e.matches(SELECTOR_INNER_ELEM)?e:SelectorEngine.findOne(SELECTOR_INNER_ELEM,e)}_getOuterElement(e){return e.closest(SELECTOR_OUTER)||e}static jQueryInterface(e){return this.each((function(){const t=Tab.getOrCreateInstance(this);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e]()}}))}}EventHandler.on(document,"click.bs.tab",SELECTOR_DATA_TOGGLE,(function(e){["A","AREA"].includes(this.tagName)&&e.preventDefault(),isDisabled(this)||Tab.getOrCreateInstance(this).show()})),EventHandler.on(window,"load.bs.tab",(()=>{for(const e of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE))Tab.getOrCreateInstance(e)})),defineJQueryPlugin(Tab);const NAME="toast",DATA_KEY="bs.toast",EVENT_KEY=`.${DATA_KEY}`,EVENT_MOUSEOVER=`mouseover${EVENT_KEY}`,EVENT_MOUSEOUT=`mouseout${EVENT_KEY}`,EVENT_FOCUSIN=`focusin${EVENT_KEY}`,EVENT_FOCUSOUT=`focusout${EVENT_KEY}`,EVENT_HIDE=`hide${EVENT_KEY}`,EVENT_HIDDEN=`hidden${EVENT_KEY}`,EVENT_SHOW=`show${EVENT_KEY}`,EVENT_SHOWN=`shown${EVENT_KEY}`,CLASS_NAME_FADE="fade",CLASS_NAME_HIDE="hide",CLASS_NAME_SHOW="show",CLASS_NAME_SHOWING="showing",DefaultType={animation:"boolean",autohide:"boolean",delay:"number"},Default={animation:!0,autohide:!0,delay:5e3};class Toast extends BaseComponent{constructor(e,t){super(e,t),this._timeout=null,this._hasMouseInteraction=!1,this._hasKeyboardInteraction=!1,this._setListeners()}static get Default(){return Default}static get DefaultType(){return DefaultType}static get NAME(){return NAME}show(){if(EventHandler.trigger(this._element,EVENT_SHOW).defaultPrevented)return;this._clearTimeout(),this._config.animation&&this._element.classList.add("fade");this._element.classList.remove("hide"),reflow(this._element),this._element.classList.add("show","showing"),this._queueCallback((()=>{this._element.classList.remove("showing"),EventHandler.trigger(this._element,EVENT_SHOWN),this._maybeScheduleHide()}),this._element,this._config.animation)}hide(){if(!this.isShown())return;if(EventHandler.trigger(this._element,EVENT_HIDE).defaultPrevented)return;this._element.classList.add("showing"),this._queueCallback((()=>{this._element.classList.add("hide"),this._element.classList.remove("showing","show"),EventHandler.trigger(this._element,EVENT_HIDDEN)}),this._element,this._config.animation)}dispose(){this._clearTimeout(),this.isShown()&&this._element.classList.remove("show"),super.dispose()}isShown(){return this._element.classList.contains("show")}_maybeScheduleHide(){this._config.autohide&&(this._hasMouseInteraction||this._hasKeyboardInteraction||(this._timeout=setTimeout((()=>{this.hide()}),this._config.delay)))}_onInteraction(e,t){switch(e.type){case"mouseover":case"mouseout":this._hasMouseInteraction=t;break;case"focusin":case"focusout":this._hasKeyboardInteraction=t}if(t)return void this._clearTimeout();const n=e.relatedTarget;this._element===n||this._element.contains(n)||this._maybeScheduleHide()}_setListeners(){EventHandler.on(this._element,EVENT_MOUSEOVER,(e=>this._onInteraction(e,!0))),EventHandler.on(this._element,EVENT_MOUSEOUT,(e=>this._onInteraction(e,!1))),EventHandler.on(this._element,EVENT_FOCUSIN,(e=>this._onInteraction(e,!0))),EventHandler.on(this._element,EVENT_FOCUSOUT,(e=>this._onInteraction(e,!1)))}_clearTimeout(){clearTimeout(this._timeout),this._timeout=null}static jQueryInterface(e){return this.each((function(){const t=Toast.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e](this)}}))}}enableDismissTrigger(Toast),defineJQueryPlugin(Toast);export{Alert,Button,Carousel,Collapse,Dropdown,Modal,Offcanvas,Popover,ScrollSpy,Tab,Toast,Tooltip}; +const elementMap=new Map,Data={set(e,t,n){elementMap.has(e)||elementMap.set(e,new Map);const i=elementMap.get(e);i.has(t)||0===i.size?i.set(t,n):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(i.keys())[0]}.`)},get:(e,t)=>elementMap.has(e)&&elementMap.get(e).get(t)||null,remove(e,t){if(!elementMap.has(e))return;const n=elementMap.get(e);n.delete(t),0===n.size&&elementMap.delete(e)}},MAX_UID=1e6,MILLISECONDS_MULTIPLIER=1e3,TRANSITION_END="transitionend",parseSelector=e=>(e&&window.CSS&&window.CSS.escape&&(e=e.replace(/#([^\s"#']+)/g,((e,t)=>`#${CSS.escape(t)}`))),e),toType=e=>null==e?`${e}`:Object.prototype.toString.call(e).match(/\s([a-z]+)/i)[1].toLowerCase(),getUID=e=>{do{e+=Math.floor(1e6*Math.random())}while(document.getElementById(e));return e},getTransitionDurationFromElement=e=>{if(!e)return 0;let{transitionDuration:t,transitionDelay:n}=window.getComputedStyle(e);const i=Number.parseFloat(t),s=Number.parseFloat(n);return i||s?(t=t.split(",")[0],n=n.split(",")[0],1e3*(Number.parseFloat(t)+Number.parseFloat(n))):0},triggerTransitionEnd=e=>{e.dispatchEvent(new Event(TRANSITION_END))},isElement=e=>!(!e||"object"!=typeof e)&&(void 0!==e.jquery&&(e=e[0]),void 0!==e.nodeType),getElement=e=>isElement(e)?e.jquery?e[0]:e:"string"==typeof e&&e.length>0?document.querySelector(parseSelector(e)):null,isVisible=e=>{if(!isElement(e)||0===e.getClientRects().length)return!1;const t="visible"===getComputedStyle(e).getPropertyValue("visibility"),n=e.closest("details:not([open])");if(!n)return t;if(n!==e){const t=e.closest("summary");if(t&&t.parentNode!==n)return!1;if(null===t)return!1}return t},isDisabled=e=>!e||e.nodeType!==Node.ELEMENT_NODE||(!!e.classList.contains("disabled")||(void 0!==e.disabled?e.disabled:e.hasAttribute("disabled")&&"false"!==e.getAttribute("disabled"))),findShadowRoot=e=>{if(!document.documentElement.attachShadow)return null;if("function"==typeof e.getRootNode){const t=e.getRootNode();return t instanceof ShadowRoot?t:null}return e instanceof ShadowRoot?e:e.parentNode?findShadowRoot(e.parentNode):null},noop=()=>{},reflow=e=>{e.offsetHeight},getjQuery=()=>window.jQuery&&!document.body.hasAttribute("data-bs-no-jquery")?window.jQuery:null,DOMContentLoadedCallbacks=[],onDOMContentLoaded=e=>{"loading"===document.readyState?(DOMContentLoadedCallbacks.length||document.addEventListener("DOMContentLoaded",(()=>{for(const e of DOMContentLoadedCallbacks)e()})),DOMContentLoadedCallbacks.push(e)):e()},isRTL=()=>"rtl"===document.documentElement.dir,defineJQueryPlugin=e=>{onDOMContentLoaded((()=>{const t=getjQuery();if(t){const n=e.NAME,i=t.fn[n];t.fn[n]=e.jQueryInterface,t.fn[n].Constructor=e,t.fn[n].noConflict=()=>(t.fn[n]=i,e.jQueryInterface)}}))},execute=(e,t=[],n=e)=>"function"==typeof e?e(...t):n,executeAfterTransition=(e,t,n=!0)=>{if(!n)return void execute(e);const i=getTransitionDurationFromElement(t)+5;let s=!1;const o=({target:n})=>{n===t&&(s=!0,t.removeEventListener(TRANSITION_END,o),execute(e))};t.addEventListener(TRANSITION_END,o),setTimeout((()=>{s||triggerTransitionEnd(t)}),i)},getNextActiveElement=(e,t,n,i)=>{const s=e.length;let o=e.indexOf(t);return-1===o?!n&&i?e[s-1]:e[0]:(o+=n?1:-1,i&&(o=(o+s)%s),e[Math.max(0,Math.min(o,s-1))])},namespaceRegex=/[^.]*(?=\..*)\.|.*/,stripNameRegex=/\..*/,stripUidRegex=/::\d+$/,eventRegistry={};let uidEvent=1;const customEvents={mouseenter:"mouseover",mouseleave:"mouseout"},nativeEvents=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]);function makeEventUid(e,t){return t&&`${t}::${uidEvent++}`||e.uidEvent||uidEvent++}function getElementEvents(e){const t=makeEventUid(e);return e.uidEvent=t,eventRegistry[t]=eventRegistry[t]||{},eventRegistry[t]}function bootstrapHandler(e,t){return function n(i){return hydrateObj(i,{delegateTarget:e}),n.oneOff&&EventHandler.off(e,i.type,t),t.apply(e,[i])}}function bootstrapDelegationHandler(e,t,n){return function i(s){const o=e.querySelectorAll(t);for(let{target:r}=s;r&&r!==this;r=r.parentNode)for(const a of o)if(a===r)return hydrateObj(s,{delegateTarget:r}),i.oneOff&&EventHandler.off(e,s.type,t,n),n.apply(r,[s])}}function findHandler(e,t,n=null){return Object.values(e).find((e=>e.callable===t&&e.delegationSelector===n))}function normalizeParameters(e,t,n){const i="string"==typeof t,s=i?n:t||n;let o=getTypeEvent(e);return nativeEvents.has(o)||(o=e),[i,s,o]}function addHandler(e,t,n,i,s){if("string"!=typeof t||!e)return;let[o,r,a]=normalizeParameters(t,n,i);if(t in customEvents){const e=e=>function(t){if(!t.relatedTarget||t.relatedTarget!==t.delegateTarget&&!t.delegateTarget.contains(t.relatedTarget))return e.call(this,t)};r=e(r)}const l=getElementEvents(e),c=l[a]||(l[a]={}),d=findHandler(c,r,o?n:null);if(d)return void(d.oneOff=d.oneOff&&s);const u=makeEventUid(r,t.replace(namespaceRegex,"")),h=o?bootstrapDelegationHandler(e,n,r):bootstrapHandler(e,r);h.delegationSelector=o?n:null,h.callable=r,h.oneOff=s,h.uidEvent=u,c[u]=h,e.addEventListener(a,h,o)}function removeHandler(e,t,n,i,s){const o=findHandler(t[n],i,s);o&&(e.removeEventListener(n,o,Boolean(s)),delete t[n][o.uidEvent])}function removeNamespacedHandlers(e,t,n,i){const s=t[n]||{};for(const[o,r]of Object.entries(s))o.includes(i)&&removeHandler(e,t,n,r.callable,r.delegationSelector)}function getTypeEvent(e){return e=e.replace(stripNameRegex,""),customEvents[e]||e}const EventHandler={on(e,t,n,i){addHandler(e,t,n,i,!1)},one(e,t,n,i){addHandler(e,t,n,i,!0)},off(e,t,n,i){if("string"!=typeof t||!e)return;const[s,o,r]=normalizeParameters(t,n,i),a=r!==t,l=getElementEvents(e),c=l[r]||{},d=t.startsWith(".");if(void 0===o){if(d)for(const n of Object.keys(l))removeNamespacedHandlers(e,l,n,t.slice(1));for(const[n,i]of Object.entries(c)){const s=n.replace(stripUidRegex,"");a&&!t.includes(s)||removeHandler(e,l,r,i.callable,i.delegationSelector)}}else{if(!Object.keys(c).length)return;removeHandler(e,l,r,o,s?n:null)}},trigger(e,t,n){if("string"!=typeof t||!e)return null;const i=getjQuery();let s=null,o=!0,r=!0,a=!1;t!==getTypeEvent(t)&&i&&(s=i.Event(t,n),i(e).trigger(s),o=!s.isPropagationStopped(),r=!s.isImmediatePropagationStopped(),a=s.isDefaultPrevented());const l=hydrateObj(new Event(t,{bubbles:o,cancelable:!0}),n);return a&&l.preventDefault(),r&&e.dispatchEvent(l),l.defaultPrevented&&s&&s.preventDefault(),l}};function hydrateObj(e,t={}){for(const[n,i]of Object.entries(t))try{e[n]=i}catch(t){Object.defineProperty(e,n,{configurable:!0,get:()=>i})}return e}function normalizeData(e){if("true"===e)return!0;if("false"===e)return!1;if(e===Number(e).toString())return Number(e);if(""===e||"null"===e)return null;if("string"!=typeof e)return e;try{return JSON.parse(decodeURIComponent(e))}catch(t){return e}}function normalizeDataKey(e){return e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`))}const Manipulator={setDataAttribute(e,t,n){e.setAttribute(`data-bs-${normalizeDataKey(t)}`,n)},removeDataAttribute(e,t){e.removeAttribute(`data-bs-${normalizeDataKey(t)}`)},getDataAttributes(e){if(!e)return{};const t={},n=Object.keys(e.dataset).filter((e=>e.startsWith("bs")&&!e.startsWith("bsConfig")));for(const i of n){let n=i.replace(/^bs/,"");n=n.charAt(0).toLowerCase()+n.slice(1,n.length),t[n]=normalizeData(e.dataset[i])}return t},getDataAttribute:(e,t)=>normalizeData(e.getAttribute(`data-bs-${normalizeDataKey(t)}`))};class Config{static get Default(){return{}}static get DefaultType(){return{}}static get NAME(){throw new Error('You have to implement the static method "NAME", for each component!')}_getConfig(e){return e=this._mergeConfigObj(e),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}_configAfterMerge(e){return e}_mergeConfigObj(e,t){const n=isElement(t)?Manipulator.getDataAttribute(t,"config"):{};return{...this.constructor.Default,..."object"==typeof n?n:{},...isElement(t)?Manipulator.getDataAttributes(t):{},..."object"==typeof e?e:{}}}_typeCheckConfig(e,t=this.constructor.DefaultType){for(const[n,i]of Object.entries(t)){const t=e[n],s=isElement(t)?"element":toType(t);if(!new RegExp(i).test(s))throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${n}" provided type "${s}" but expected type "${i}".`)}}}const VERSION="5.3.1";class BaseComponent extends Config{constructor(e,t){super(),(e=getElement(e))&&(this._element=e,this._config=this._getConfig(t),Data.set(this._element,this.constructor.DATA_KEY,this))}dispose(){Data.remove(this._element,this.constructor.DATA_KEY),EventHandler.off(this._element,this.constructor.EVENT_KEY);for(const e of Object.getOwnPropertyNames(this))this[e]=null}_queueCallback(e,t,n=!0){executeAfterTransition(e,t,n)}_getConfig(e){return e=this._mergeConfigObj(e,this._element),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}static getInstance(e){return Data.get(getElement(e),this.DATA_KEY)}static getOrCreateInstance(e,t={}){return this.getInstance(e)||new this(e,"object"==typeof t?t:null)}static get VERSION(){return"5.3.1"}static get DATA_KEY(){return`bs.${this.NAME}`}static get EVENT_KEY(){return`.${this.DATA_KEY}`}static eventName(e){return`${e}${this.EVENT_KEY}`}}const getSelector=e=>{let t=e.getAttribute("data-bs-target");if(!t||"#"===t){let n=e.getAttribute("href");if(!n||!n.includes("#")&&!n.startsWith("."))return null;n.includes("#")&&!n.startsWith("#")&&(n=`#${n.split("#")[1]}`),t=n&&"#"!==n?n.trim():null}return parseSelector(t)},SelectorEngine={find:(e,t=document.documentElement)=>[].concat(...Element.prototype.querySelectorAll.call(t,e)),findOne:(e,t=document.documentElement)=>Element.prototype.querySelector.call(t,e),children:(e,t)=>[].concat(...e.children).filter((e=>e.matches(t))),parents(e,t){const n=[];let i=e.parentNode.closest(t);for(;i;)n.push(i),i=i.parentNode.closest(t);return n},prev(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return[n];n=n.previousElementSibling}return[]},next(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return[n];n=n.nextElementSibling}return[]},focusableChildren(e){const t=["a","button","input","textarea","select","details","[tabindex]",'[contenteditable="true"]'].map((e=>`${e}:not([tabindex^="-"])`)).join(",");return this.find(t,e).filter((e=>!isDisabled(e)&&isVisible(e)))},getSelectorFromElement(e){const t=getSelector(e);return t&&SelectorEngine.findOne(t)?t:null},getElementFromSelector(e){const t=getSelector(e);return t?SelectorEngine.findOne(t):null},getMultipleElementsFromSelector(e){const t=getSelector(e);return t?SelectorEngine.find(t):[]}},enableDismissTrigger=(e,t="hide")=>{const n=`click.dismiss${e.EVENT_KEY}`,i=e.NAME;EventHandler.on(document,n,`[data-bs-dismiss="${i}"]`,(function(n){if(["A","AREA"].includes(this.tagName)&&n.preventDefault(),isDisabled(this))return;const s=SelectorEngine.getElementFromSelector(this)||this.closest(`.${i}`);e.getOrCreateInstance(s)[t]()}))},NAME$f="alert",DATA_KEY$a="bs.alert",EVENT_KEY$b=".bs.alert",EVENT_CLOSE="close.bs.alert",EVENT_CLOSED="closed.bs.alert",CLASS_NAME_FADE$5="fade",CLASS_NAME_SHOW$8="show";class Alert extends BaseComponent{static get NAME(){return NAME$f}close(){if(EventHandler.trigger(this._element,EVENT_CLOSE).defaultPrevented)return;this._element.classList.remove("show");const e=this._element.classList.contains("fade");this._queueCallback((()=>this._destroyElement()),this._element,e)}_destroyElement(){this._element.remove(),EventHandler.trigger(this._element,EVENT_CLOSED),this.dispose()}static jQueryInterface(e){return this.each((function(){const t=Alert.getOrCreateInstance(this);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e](this)}}))}}enableDismissTrigger(Alert,"close"),defineJQueryPlugin(Alert);const NAME$e="button",DATA_KEY$9="bs.button",EVENT_KEY$a=`.${DATA_KEY$9}`,DATA_API_KEY$6=".data-api",CLASS_NAME_ACTIVE$3="active",SELECTOR_DATA_TOGGLE$5='[data-bs-toggle="button"]',EVENT_CLICK_DATA_API$6=`click${EVENT_KEY$a}.data-api`;class Button extends BaseComponent{static get NAME(){return NAME$e}toggle(){this._element.setAttribute("aria-pressed",this._element.classList.toggle("active"))}static jQueryInterface(e){return this.each((function(){const t=Button.getOrCreateInstance(this);"toggle"===e&&t[e]()}))}}EventHandler.on(document,EVENT_CLICK_DATA_API$6,SELECTOR_DATA_TOGGLE$5,(e=>{e.preventDefault();const t=e.target.closest(SELECTOR_DATA_TOGGLE$5);Button.getOrCreateInstance(t).toggle()})),defineJQueryPlugin(Button);const NAME$d="swipe",EVENT_KEY$9=".bs.swipe",EVENT_TOUCHSTART="touchstart.bs.swipe",EVENT_TOUCHMOVE="touchmove.bs.swipe",EVENT_TOUCHEND="touchend.bs.swipe",EVENT_POINTERDOWN="pointerdown.bs.swipe",EVENT_POINTERUP="pointerup.bs.swipe",POINTER_TYPE_TOUCH="touch",POINTER_TYPE_PEN="pen",CLASS_NAME_POINTER_EVENT="pointer-event",SWIPE_THRESHOLD=40,Default$c={endCallback:null,leftCallback:null,rightCallback:null},DefaultType$c={endCallback:"(function|null)",leftCallback:"(function|null)",rightCallback:"(function|null)"};class Swipe extends Config{constructor(e,t){super(),this._element=e,e&&Swipe.isSupported()&&(this._config=this._getConfig(t),this._deltaX=0,this._supportPointerEvents=Boolean(window.PointerEvent),this._initEvents())}static get Default(){return Default$c}static get DefaultType(){return DefaultType$c}static get NAME(){return NAME$d}dispose(){EventHandler.off(this._element,".bs.swipe")}_start(e){this._supportPointerEvents?this._eventIsPointerPenTouch(e)&&(this._deltaX=e.clientX):this._deltaX=e.touches[0].clientX}_end(e){this._eventIsPointerPenTouch(e)&&(this._deltaX=e.clientX-this._deltaX),this._handleSwipe(),execute(this._config.endCallback)}_move(e){this._deltaX=e.touches&&e.touches.length>1?0:e.touches[0].clientX-this._deltaX}_handleSwipe(){const e=Math.abs(this._deltaX);if(e<=40)return;const t=e/this._deltaX;this._deltaX=0,t&&execute(t>0?this._config.rightCallback:this._config.leftCallback)}_initEvents(){this._supportPointerEvents?(EventHandler.on(this._element,EVENT_POINTERDOWN,(e=>this._start(e))),EventHandler.on(this._element,EVENT_POINTERUP,(e=>this._end(e))),this._element.classList.add("pointer-event")):(EventHandler.on(this._element,EVENT_TOUCHSTART,(e=>this._start(e))),EventHandler.on(this._element,EVENT_TOUCHMOVE,(e=>this._move(e))),EventHandler.on(this._element,EVENT_TOUCHEND,(e=>this._end(e))))}_eventIsPointerPenTouch(e){return this._supportPointerEvents&&("pen"===e.pointerType||"touch"===e.pointerType)}static isSupported(){return"ontouchstart"in document.documentElement||navigator.maxTouchPoints>0}}const NAME$c="carousel",DATA_KEY$8="bs.carousel",EVENT_KEY$8=`.${DATA_KEY$8}`,DATA_API_KEY$5=".data-api",ARROW_LEFT_KEY$1="ArrowLeft",ARROW_RIGHT_KEY$1="ArrowRight",TOUCHEVENT_COMPAT_WAIT=500,ORDER_NEXT="next",ORDER_PREV="prev",DIRECTION_LEFT="left",DIRECTION_RIGHT="right",EVENT_SLIDE=`slide${EVENT_KEY$8}`,EVENT_SLID=`slid${EVENT_KEY$8}`,EVENT_KEYDOWN$1=`keydown${EVENT_KEY$8}`,EVENT_MOUSEENTER$1=`mouseenter${EVENT_KEY$8}`,EVENT_MOUSELEAVE$1=`mouseleave${EVENT_KEY$8}`,EVENT_DRAG_START=`dragstart${EVENT_KEY$8}`,EVENT_LOAD_DATA_API$3=`load${EVENT_KEY$8}.data-api`,EVENT_CLICK_DATA_API$5=`click${EVENT_KEY$8}.data-api`,CLASS_NAME_CAROUSEL="carousel",CLASS_NAME_ACTIVE$2="active",CLASS_NAME_SLIDE="slide",CLASS_NAME_END="carousel-item-end",CLASS_NAME_START="carousel-item-start",CLASS_NAME_NEXT="carousel-item-next",CLASS_NAME_PREV="carousel-item-prev",SELECTOR_ACTIVE=".active",SELECTOR_ITEM=".carousel-item",SELECTOR_ACTIVE_ITEM=".active.carousel-item",SELECTOR_ITEM_IMG=".carousel-item img",SELECTOR_INDICATORS=".carousel-indicators",SELECTOR_DATA_SLIDE="[data-bs-slide], [data-bs-slide-to]",SELECTOR_DATA_RIDE='[data-bs-ride="carousel"]',KEY_TO_DIRECTION={ArrowLeft:"right",ArrowRight:"left"},Default$b={interval:5e3,keyboard:!0,pause:"hover",ride:!1,touch:!0,wrap:!0},DefaultType$b={interval:"(number|boolean)",keyboard:"boolean",pause:"(string|boolean)",ride:"(boolean|string)",touch:"boolean",wrap:"boolean"};class Carousel extends BaseComponent{constructor(e,t){super(e,t),this._interval=null,this._activeElement=null,this._isSliding=!1,this.touchTimeout=null,this._swipeHelper=null,this._indicatorsElement=SelectorEngine.findOne(SELECTOR_INDICATORS,this._element),this._addEventListeners(),"carousel"===this._config.ride&&this.cycle()}static get Default(){return Default$b}static get DefaultType(){return DefaultType$b}static get NAME(){return NAME$c}next(){this._slide("next")}nextWhenVisible(){!document.hidden&&isVisible(this._element)&&this.next()}prev(){this._slide("prev")}pause(){this._isSliding&&triggerTransitionEnd(this._element),this._clearInterval()}cycle(){this._clearInterval(),this._updateInterval(),this._interval=setInterval((()=>this.nextWhenVisible()),this._config.interval)}_maybeEnableCycle(){this._config.ride&&(this._isSliding?EventHandler.one(this._element,EVENT_SLID,(()=>this.cycle())):this.cycle())}to(e){const t=this._getItems();if(e>t.length-1||e<0)return;if(this._isSliding)return void EventHandler.one(this._element,EVENT_SLID,(()=>this.to(e)));const n=this._getItemIndex(this._getActive());if(n===e)return;const i=e>n?"next":"prev";this._slide(i,t[e])}dispose(){this._swipeHelper&&this._swipeHelper.dispose(),super.dispose()}_configAfterMerge(e){return e.defaultInterval=e.interval,e}_addEventListeners(){this._config.keyboard&&EventHandler.on(this._element,EVENT_KEYDOWN$1,(e=>this._keydown(e))),"hover"===this._config.pause&&(EventHandler.on(this._element,EVENT_MOUSEENTER$1,(()=>this.pause())),EventHandler.on(this._element,EVENT_MOUSELEAVE$1,(()=>this._maybeEnableCycle()))),this._config.touch&&Swipe.isSupported()&&this._addTouchEventListeners()}_addTouchEventListeners(){for(const e of SelectorEngine.find(SELECTOR_ITEM_IMG,this._element))EventHandler.on(e,EVENT_DRAG_START,(e=>e.preventDefault()));const e={leftCallback:()=>this._slide(this._directionToOrder("left")),rightCallback:()=>this._slide(this._directionToOrder("right")),endCallback:()=>{"hover"===this._config.pause&&(this.pause(),this.touchTimeout&&clearTimeout(this.touchTimeout),this.touchTimeout=setTimeout((()=>this._maybeEnableCycle()),500+this._config.interval))}};this._swipeHelper=new Swipe(this._element,e)}_keydown(e){if(/input|textarea/i.test(e.target.tagName))return;const t=KEY_TO_DIRECTION[e.key];t&&(e.preventDefault(),this._slide(this._directionToOrder(t)))}_getItemIndex(e){return this._getItems().indexOf(e)}_setActiveIndicatorElement(e){if(!this._indicatorsElement)return;const t=SelectorEngine.findOne(".active",this._indicatorsElement);t.classList.remove("active"),t.removeAttribute("aria-current");const n=SelectorEngine.findOne(`[data-bs-slide-to="${e}"]`,this._indicatorsElement);n&&(n.classList.add("active"),n.setAttribute("aria-current","true"))}_updateInterval(){const e=this._activeElement||this._getActive();if(!e)return;const t=Number.parseInt(e.getAttribute("data-bs-interval"),10);this._config.interval=t||this._config.defaultInterval}_slide(e,t=null){if(this._isSliding)return;const n=this._getActive(),i="next"===e,s=t||getNextActiveElement(this._getItems(),n,i,this._config.wrap);if(s===n)return;const o=this._getItemIndex(s),r=t=>EventHandler.trigger(this._element,t,{relatedTarget:s,direction:this._orderToDirection(e),from:this._getItemIndex(n),to:o});if(r(EVENT_SLIDE).defaultPrevented)return;if(!n||!s)return;const a=Boolean(this._interval);this.pause(),this._isSliding=!0,this._setActiveIndicatorElement(o),this._activeElement=s;const l=i?CLASS_NAME_START:CLASS_NAME_END,c=i?CLASS_NAME_NEXT:CLASS_NAME_PREV;s.classList.add(c),reflow(s),n.classList.add(l),s.classList.add(l);this._queueCallback((()=>{s.classList.remove(l,c),s.classList.add("active"),n.classList.remove("active",c,l),this._isSliding=!1,r(EVENT_SLID)}),n,this._isAnimated()),a&&this.cycle()}_isAnimated(){return this._element.classList.contains("slide")}_getActive(){return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM,this._element)}_getItems(){return SelectorEngine.find(SELECTOR_ITEM,this._element)}_clearInterval(){this._interval&&(clearInterval(this._interval),this._interval=null)}_directionToOrder(e){return isRTL()?"left"===e?"prev":"next":"left"===e?"next":"prev"}_orderToDirection(e){return isRTL()?"prev"===e?"left":"right":"prev"===e?"right":"left"}static jQueryInterface(e){return this.each((function(){const t=Carousel.getOrCreateInstance(this,e);if("number"!=typeof e){if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e]()}}else t.to(e)}))}}EventHandler.on(document,EVENT_CLICK_DATA_API$5,SELECTOR_DATA_SLIDE,(function(e){const t=SelectorEngine.getElementFromSelector(this);if(!t||!t.classList.contains("carousel"))return;e.preventDefault();const n=Carousel.getOrCreateInstance(t),i=this.getAttribute("data-bs-slide-to");return i?(n.to(i),void n._maybeEnableCycle()):"next"===Manipulator.getDataAttribute(this,"slide")?(n.next(),void n._maybeEnableCycle()):(n.prev(),void n._maybeEnableCycle())})),EventHandler.on(window,EVENT_LOAD_DATA_API$3,(()=>{const e=SelectorEngine.find(SELECTOR_DATA_RIDE);for(const t of e)Carousel.getOrCreateInstance(t)})),defineJQueryPlugin(Carousel);const NAME$b="collapse",DATA_KEY$7="bs.collapse",EVENT_KEY$7=`.${DATA_KEY$7}`,DATA_API_KEY$4=".data-api",EVENT_SHOW$6=`show${EVENT_KEY$7}`,EVENT_SHOWN$6=`shown${EVENT_KEY$7}`,EVENT_HIDE$6=`hide${EVENT_KEY$7}`,EVENT_HIDDEN$6=`hidden${EVENT_KEY$7}`,EVENT_CLICK_DATA_API$4=`click${EVENT_KEY$7}.data-api`,CLASS_NAME_SHOW$7="show",CLASS_NAME_COLLAPSE="collapse",CLASS_NAME_COLLAPSING="collapsing",CLASS_NAME_COLLAPSED="collapsed",CLASS_NAME_DEEPER_CHILDREN=":scope .collapse .collapse",CLASS_NAME_HORIZONTAL="collapse-horizontal",WIDTH="width",HEIGHT="height",SELECTOR_ACTIVES=".collapse.show, .collapse.collapsing",SELECTOR_DATA_TOGGLE$4='[data-bs-toggle="collapse"]',Default$a={parent:null,toggle:!0},DefaultType$a={parent:"(null|element)",toggle:"boolean"};class Collapse extends BaseComponent{constructor(e,t){super(e,t),this._isTransitioning=!1,this._triggerArray=[];const n=SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);for(const e of n){const t=SelectorEngine.getSelectorFromElement(e),n=SelectorEngine.find(t).filter((e=>e===this._element));null!==t&&n.length&&this._triggerArray.push(e)}this._initializeChildren(),this._config.parent||this._addAriaAndCollapsedClass(this._triggerArray,this._isShown()),this._config.toggle&&this.toggle()}static get Default(){return Default$a}static get DefaultType(){return DefaultType$a}static get NAME(){return NAME$b}toggle(){this._isShown()?this.hide():this.show()}show(){if(this._isTransitioning||this._isShown())return;let e=[];if(this._config.parent&&(e=this._getFirstLevelChildren(SELECTOR_ACTIVES).filter((e=>e!==this._element)).map((e=>Collapse.getOrCreateInstance(e,{toggle:!1})))),e.length&&e[0]._isTransitioning)return;if(EventHandler.trigger(this._element,EVENT_SHOW$6).defaultPrevented)return;for(const t of e)t.hide();const t=this._getDimension();this._element.classList.remove("collapse"),this._element.classList.add("collapsing"),this._element.style[t]=0,this._addAriaAndCollapsedClass(this._triggerArray,!0),this._isTransitioning=!0;const n=`scroll${t[0].toUpperCase()+t.slice(1)}`;this._queueCallback((()=>{this._isTransitioning=!1,this._element.classList.remove("collapsing"),this._element.classList.add("collapse","show"),this._element.style[t]="",EventHandler.trigger(this._element,EVENT_SHOWN$6)}),this._element,!0),this._element.style[t]=`${this._element[n]}px`}hide(){if(this._isTransitioning||!this._isShown())return;if(EventHandler.trigger(this._element,EVENT_HIDE$6).defaultPrevented)return;const e=this._getDimension();this._element.style[e]=`${this._element.getBoundingClientRect()[e]}px`,reflow(this._element),this._element.classList.add("collapsing"),this._element.classList.remove("collapse","show");for(const e of this._triggerArray){const t=SelectorEngine.getElementFromSelector(e);t&&!this._isShown(t)&&this._addAriaAndCollapsedClass([e],!1)}this._isTransitioning=!0;this._element.style[e]="",this._queueCallback((()=>{this._isTransitioning=!1,this._element.classList.remove("collapsing"),this._element.classList.add("collapse"),EventHandler.trigger(this._element,EVENT_HIDDEN$6)}),this._element,!0)}_isShown(e=this._element){return e.classList.contains("show")}_configAfterMerge(e){return e.toggle=Boolean(e.toggle),e.parent=getElement(e.parent),e}_getDimension(){return this._element.classList.contains("collapse-horizontal")?WIDTH:HEIGHT}_initializeChildren(){if(!this._config.parent)return;const e=this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4);for(const t of e){const e=SelectorEngine.getElementFromSelector(t);e&&this._addAriaAndCollapsedClass([t],this._isShown(e))}}_getFirstLevelChildren(e){const t=SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN,this._config.parent);return SelectorEngine.find(e,this._config.parent).filter((e=>!t.includes(e)))}_addAriaAndCollapsedClass(e,t){if(e.length)for(const n of e)n.classList.toggle("collapsed",!t),n.setAttribute("aria-expanded",t)}static jQueryInterface(e){const t={};return"string"==typeof e&&/show|hide/.test(e)&&(t.toggle=!1),this.each((function(){const n=Collapse.getOrCreateInstance(this,t);if("string"==typeof e){if(void 0===n[e])throw new TypeError(`No method named "${e}"`);n[e]()}}))}}EventHandler.on(document,EVENT_CLICK_DATA_API$4,SELECTOR_DATA_TOGGLE$4,(function(e){("A"===e.target.tagName||e.delegateTarget&&"A"===e.delegateTarget.tagName)&&e.preventDefault();for(const e of SelectorEngine.getMultipleElementsFromSelector(this))Collapse.getOrCreateInstance(e,{toggle:!1}).toggle()})),defineJQueryPlugin(Collapse);const NAME$a="dropdown",DATA_KEY$6="bs.dropdown",EVENT_KEY$6=`.${DATA_KEY$6}`,DATA_API_KEY$3=".data-api",ESCAPE_KEY$2="Escape",TAB_KEY$1="Tab",ARROW_UP_KEY$1="ArrowUp",ARROW_DOWN_KEY$1="ArrowDown",RIGHT_MOUSE_BUTTON=2,EVENT_HIDE$5=`hide${EVENT_KEY$6}`,EVENT_HIDDEN$5=`hidden${EVENT_KEY$6}`,EVENT_SHOW$5=`show${EVENT_KEY$6}`,EVENT_SHOWN$5=`shown${EVENT_KEY$6}`,EVENT_CLICK_DATA_API$3=`click${EVENT_KEY$6}.data-api`,EVENT_KEYDOWN_DATA_API=`keydown${EVENT_KEY$6}.data-api`,EVENT_KEYUP_DATA_API=`keyup${EVENT_KEY$6}.data-api`,CLASS_NAME_SHOW$6="show",CLASS_NAME_DROPUP="dropup",CLASS_NAME_DROPEND="dropend",CLASS_NAME_DROPSTART="dropstart",CLASS_NAME_DROPUP_CENTER="dropup-center",CLASS_NAME_DROPDOWN_CENTER="dropdown-center",SELECTOR_DATA_TOGGLE$3='[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)',SELECTOR_DATA_TOGGLE_SHOWN=`${SELECTOR_DATA_TOGGLE$3}.show`,SELECTOR_MENU=".dropdown-menu",SELECTOR_NAVBAR=".navbar",SELECTOR_NAVBAR_NAV=".navbar-nav",SELECTOR_VISIBLE_ITEMS=".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)",PLACEMENT_TOP=isRTL()?"top-end":"top-start",PLACEMENT_TOPEND=isRTL()?"top-start":"top-end",PLACEMENT_BOTTOM=isRTL()?"bottom-end":"bottom-start",PLACEMENT_BOTTOMEND=isRTL()?"bottom-start":"bottom-end",PLACEMENT_RIGHT=isRTL()?"left-start":"right-start",PLACEMENT_LEFT=isRTL()?"right-start":"left-start",PLACEMENT_TOPCENTER="top",PLACEMENT_BOTTOMCENTER="bottom",Default$9={autoClose:!0,boundary:"clippingParents",display:"dynamic",offset:[0,2],popperConfig:null,reference:"toggle"},DefaultType$9={autoClose:"(boolean|string)",boundary:"(string|element)",display:"string",offset:"(array|string|function)",popperConfig:"(null|object|function)",reference:"(string|element|object)"};class Dropdown extends BaseComponent{constructor(e,t){super(e,t),this._popper=null,this._parent=this._element.parentNode,this._menu=SelectorEngine.next(this._element,SELECTOR_MENU)[0]||SelectorEngine.prev(this._element,SELECTOR_MENU)[0]||SelectorEngine.findOne(SELECTOR_MENU,this._parent),this._inNavbar=this._detectNavbar()}static get Default(){return Default$9}static get DefaultType(){return DefaultType$9}static get NAME(){return NAME$a}toggle(){return this._isShown()?this.hide():this.show()}show(){if(isDisabled(this._element)||this._isShown())return;const e={relatedTarget:this._element};if(!EventHandler.trigger(this._element,EVENT_SHOW$5,e).defaultPrevented){if(this._createPopper(),"ontouchstart"in document.documentElement&&!this._parent.closest(".navbar-nav"))for(const e of[].concat(...document.body.children))EventHandler.on(e,"mouseover",noop);this._element.focus(),this._element.setAttribute("aria-expanded",!0),this._menu.classList.add("show"),this._element.classList.add("show"),EventHandler.trigger(this._element,EVENT_SHOWN$5,e)}}hide(){if(isDisabled(this._element)||!this._isShown())return;const e={relatedTarget:this._element};this._completeHide(e)}dispose(){this._popper&&this._popper.destroy(),super.dispose()}update(){this._inNavbar=this._detectNavbar(),this._popper&&this._popper.update()}_completeHide(e){if(!EventHandler.trigger(this._element,EVENT_HIDE$5,e).defaultPrevented){if("ontouchstart"in document.documentElement)for(const e of[].concat(...document.body.children))EventHandler.off(e,"mouseover",noop);this._popper&&this._popper.destroy(),this._menu.classList.remove("show"),this._element.classList.remove("show"),this._element.setAttribute("aria-expanded","false"),Manipulator.removeDataAttribute(this._menu,"popper"),EventHandler.trigger(this._element,EVENT_HIDDEN$5,e)}}_getConfig(e){if("object"==typeof(e=super._getConfig(e)).reference&&!isElement(e.reference)&&"function"!=typeof e.reference.getBoundingClientRect)throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);return e}_createPopper(){if(void 0===Popper)throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org)");let e=this._element;"parent"===this._config.reference?e=this._parent:isElement(this._config.reference)?e=getElement(this._config.reference):"object"==typeof this._config.reference&&(e=this._config.reference);const t=this._getPopperConfig();this._popper=createPopper(e,this._menu,t)}_isShown(){return this._menu.classList.contains("show")}_getPlacement(){const e=this._parent;if(e.classList.contains("dropend"))return PLACEMENT_RIGHT;if(e.classList.contains("dropstart"))return PLACEMENT_LEFT;if(e.classList.contains("dropup-center"))return"top";if(e.classList.contains("dropdown-center"))return"bottom";const t="end"===getComputedStyle(this._menu).getPropertyValue("--bs-position").trim();return e.classList.contains("dropup")?t?PLACEMENT_TOPEND:PLACEMENT_TOP:t?PLACEMENT_BOTTOMEND:PLACEMENT_BOTTOM}_detectNavbar(){return null!==this._element.closest(".navbar")}_getOffset(){const{offset:e}=this._config;return"string"==typeof e?e.split(",").map((e=>Number.parseInt(e,10))):"function"==typeof e?t=>e(t,this._element):e}_getPopperConfig(){const e={placement:this._getPlacement(),modifiers:[{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"offset",options:{offset:this._getOffset()}}]};return(this._inNavbar||"static"===this._config.display)&&(Manipulator.setDataAttribute(this._menu,"popper","static"),e.modifiers=[{name:"applyStyles",enabled:!1}]),{...e,...execute(this._config.popperConfig,[e])}}_selectMenuItem({key:e,target:t}){const n=SelectorEngine.find(SELECTOR_VISIBLE_ITEMS,this._menu).filter((e=>isVisible(e)));n.length&&getNextActiveElement(n,t,e===ARROW_DOWN_KEY$1,!n.includes(t)).focus()}static jQueryInterface(e){return this.each((function(){const t=Dropdown.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e]()}}))}static clearMenus(e){if(2===e.button||"keyup"===e.type&&"Tab"!==e.key)return;const t=SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);for(const n of t){const t=Dropdown.getInstance(n);if(!t||!1===t._config.autoClose)continue;const i=e.composedPath(),s=i.includes(t._menu);if(i.includes(t._element)||"inside"===t._config.autoClose&&!s||"outside"===t._config.autoClose&&s)continue;if(t._menu.contains(e.target)&&("keyup"===e.type&&"Tab"===e.key||/input|select|option|textarea|form/i.test(e.target.tagName)))continue;const o={relatedTarget:t._element};"click"===e.type&&(o.clickEvent=e),t._completeHide(o)}}static dataApiKeydownHandler(e){const t=/input|textarea/i.test(e.target.tagName),n="Escape"===e.key,i=[ARROW_UP_KEY$1,ARROW_DOWN_KEY$1].includes(e.key);if(!i&&!n)return;if(t&&!n)return;e.preventDefault();const s=this.matches(SELECTOR_DATA_TOGGLE$3)?this:SelectorEngine.prev(this,SELECTOR_DATA_TOGGLE$3)[0]||SelectorEngine.next(this,SELECTOR_DATA_TOGGLE$3)[0]||SelectorEngine.findOne(SELECTOR_DATA_TOGGLE$3,e.delegateTarget.parentNode),o=Dropdown.getOrCreateInstance(s);if(i)return e.stopPropagation(),o.show(),void o._selectMenuItem(e);o._isShown()&&(e.stopPropagation(),o.hide(),s.focus())}}EventHandler.on(document,EVENT_KEYDOWN_DATA_API,SELECTOR_DATA_TOGGLE$3,Dropdown.dataApiKeydownHandler),EventHandler.on(document,EVENT_KEYDOWN_DATA_API,SELECTOR_MENU,Dropdown.dataApiKeydownHandler),EventHandler.on(document,EVENT_CLICK_DATA_API$3,Dropdown.clearMenus),EventHandler.on(document,EVENT_KEYUP_DATA_API,Dropdown.clearMenus),EventHandler.on(document,EVENT_CLICK_DATA_API$3,SELECTOR_DATA_TOGGLE$3,(function(e){e.preventDefault(),Dropdown.getOrCreateInstance(this).toggle()})),defineJQueryPlugin(Dropdown);const NAME$9="backdrop",CLASS_NAME_FADE$4="fade",CLASS_NAME_SHOW$5="show",EVENT_MOUSEDOWN=`mousedown.bs.${NAME$9}`,Default$8={className:"modal-backdrop",clickCallback:null,isAnimated:!1,isVisible:!0,rootElement:"body"},DefaultType$8={className:"string",clickCallback:"(function|null)",isAnimated:"boolean",isVisible:"boolean",rootElement:"(element|string)"};class Backdrop extends Config{constructor(e){super(),this._config=this._getConfig(e),this._isAppended=!1,this._element=null}static get Default(){return Default$8}static get DefaultType(){return DefaultType$8}static get NAME(){return NAME$9}show(e){if(!this._config.isVisible)return void execute(e);this._append();const t=this._getElement();this._config.isAnimated&&reflow(t),t.classList.add("show"),this._emulateAnimation((()=>{execute(e)}))}hide(e){this._config.isVisible?(this._getElement().classList.remove("show"),this._emulateAnimation((()=>{this.dispose(),execute(e)}))):execute(e)}dispose(){this._isAppended&&(EventHandler.off(this._element,EVENT_MOUSEDOWN),this._element.remove(),this._isAppended=!1)}_getElement(){if(!this._element){const e=document.createElement("div");e.className=this._config.className,this._config.isAnimated&&e.classList.add("fade"),this._element=e}return this._element}_configAfterMerge(e){return e.rootElement=getElement(e.rootElement),e}_append(){if(this._isAppended)return;const e=this._getElement();this._config.rootElement.append(e),EventHandler.on(e,EVENT_MOUSEDOWN,(()=>{execute(this._config.clickCallback)})),this._isAppended=!0}_emulateAnimation(e){executeAfterTransition(e,this._getElement(),this._config.isAnimated)}}const NAME$8="focustrap",DATA_KEY$5="bs.focustrap",EVENT_KEY$5=`.${DATA_KEY$5}`,EVENT_FOCUSIN$2=`focusin${EVENT_KEY$5}`,EVENT_KEYDOWN_TAB=`keydown.tab${EVENT_KEY$5}`,TAB_KEY="Tab",TAB_NAV_FORWARD="forward",TAB_NAV_BACKWARD="backward",Default$7={autofocus:!0,trapElement:null},DefaultType$7={autofocus:"boolean",trapElement:"element"};class FocusTrap extends Config{constructor(e){super(),this._config=this._getConfig(e),this._isActive=!1,this._lastTabNavDirection=null}static get Default(){return Default$7}static get DefaultType(){return DefaultType$7}static get NAME(){return NAME$8}activate(){this._isActive||(this._config.autofocus&&this._config.trapElement.focus(),EventHandler.off(document,EVENT_KEY$5),EventHandler.on(document,EVENT_FOCUSIN$2,(e=>this._handleFocusin(e))),EventHandler.on(document,EVENT_KEYDOWN_TAB,(e=>this._handleKeydown(e))),this._isActive=!0)}deactivate(){this._isActive&&(this._isActive=!1,EventHandler.off(document,EVENT_KEY$5))}_handleFocusin(e){const{trapElement:t}=this._config;if(e.target===document||e.target===t||t.contains(e.target))return;const n=SelectorEngine.focusableChildren(t);0===n.length?t.focus():"backward"===this._lastTabNavDirection?n[n.length-1].focus():n[0].focus()}_handleKeydown(e){"Tab"===e.key&&(this._lastTabNavDirection=e.shiftKey?"backward":"forward")}}const SELECTOR_FIXED_CONTENT=".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",SELECTOR_STICKY_CONTENT=".sticky-top",PROPERTY_PADDING="padding-right",PROPERTY_MARGIN="margin-right";class ScrollBarHelper{constructor(){this._element=document.body}getWidth(){const e=document.documentElement.clientWidth;return Math.abs(window.innerWidth-e)}hide(){const e=this.getWidth();this._disableOverFlow(),this._setElementAttributes(this._element,"padding-right",(t=>t+e)),this._setElementAttributes(SELECTOR_FIXED_CONTENT,"padding-right",(t=>t+e)),this._setElementAttributes(".sticky-top","margin-right",(t=>t-e))}reset(){this._resetElementAttributes(this._element,"overflow"),this._resetElementAttributes(this._element,"padding-right"),this._resetElementAttributes(SELECTOR_FIXED_CONTENT,"padding-right"),this._resetElementAttributes(".sticky-top","margin-right")}isOverflowing(){return this.getWidth()>0}_disableOverFlow(){this._saveInitialAttribute(this._element,"overflow"),this._element.style.overflow="hidden"}_setElementAttributes(e,t,n){const i=this.getWidth();this._applyManipulationCallback(e,(e=>{if(e!==this._element&&window.innerWidth>e.clientWidth+i)return;this._saveInitialAttribute(e,t);const s=window.getComputedStyle(e).getPropertyValue(t);e.style.setProperty(t,`${n(Number.parseFloat(s))}px`)}))}_saveInitialAttribute(e,t){const n=e.style.getPropertyValue(t);n&&Manipulator.setDataAttribute(e,t,n)}_resetElementAttributes(e,t){this._applyManipulationCallback(e,(e=>{const n=Manipulator.getDataAttribute(e,t);null!==n?(Manipulator.removeDataAttribute(e,t),e.style.setProperty(t,n)):e.style.removeProperty(t)}))}_applyManipulationCallback(e,t){if(isElement(e))t(e);else for(const n of SelectorEngine.find(e,this._element))t(n)}}const NAME$7="modal",DATA_KEY$4="bs.modal",EVENT_KEY$4=".bs.modal",DATA_API_KEY$2=".data-api",ESCAPE_KEY$1="Escape",EVENT_HIDE$4="hide.bs.modal",EVENT_HIDE_PREVENTED$1="hidePrevented.bs.modal",EVENT_HIDDEN$4="hidden.bs.modal",EVENT_SHOW$4="show.bs.modal",EVENT_SHOWN$4="shown.bs.modal",EVENT_RESIZE$1="resize.bs.modal",EVENT_CLICK_DISMISS="click.dismiss.bs.modal",EVENT_MOUSEDOWN_DISMISS="mousedown.dismiss.bs.modal",EVENT_KEYDOWN_DISMISS$1="keydown.dismiss.bs.modal",EVENT_CLICK_DATA_API$2="click.bs.modal.data-api",CLASS_NAME_OPEN="modal-open",CLASS_NAME_FADE$3="fade",CLASS_NAME_SHOW$4="show",CLASS_NAME_STATIC="modal-static",OPEN_SELECTOR$1=".modal.show",SELECTOR_DIALOG=".modal-dialog",SELECTOR_MODAL_BODY=".modal-body",SELECTOR_DATA_TOGGLE$2='[data-bs-toggle="modal"]',Default$6={backdrop:!0,focus:!0,keyboard:!0},DefaultType$6={backdrop:"(boolean|string)",focus:"boolean",keyboard:"boolean"};class Modal extends BaseComponent{constructor(e,t){super(e,t),this._dialog=SelectorEngine.findOne(".modal-dialog",this._element),this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._isShown=!1,this._isTransitioning=!1,this._scrollBar=new ScrollBarHelper,this._addEventListeners()}static get Default(){return Default$6}static get DefaultType(){return DefaultType$6}static get NAME(){return NAME$7}toggle(e){return this._isShown?this.hide():this.show(e)}show(e){if(this._isShown||this._isTransitioning)return;EventHandler.trigger(this._element,EVENT_SHOW$4,{relatedTarget:e}).defaultPrevented||(this._isShown=!0,this._isTransitioning=!0,this._scrollBar.hide(),document.body.classList.add("modal-open"),this._adjustDialog(),this._backdrop.show((()=>this._showElement(e))))}hide(){if(!this._isShown||this._isTransitioning)return;EventHandler.trigger(this._element,EVENT_HIDE$4).defaultPrevented||(this._isShown=!1,this._isTransitioning=!0,this._focustrap.deactivate(),this._element.classList.remove("show"),this._queueCallback((()=>this._hideModal()),this._element,this._isAnimated()))}dispose(){EventHandler.off(window,".bs.modal"),EventHandler.off(this._dialog,".bs.modal"),this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}handleUpdate(){this._adjustDialog()}_initializeBackDrop(){return new Backdrop({isVisible:Boolean(this._config.backdrop),isAnimated:this._isAnimated()})}_initializeFocusTrap(){return new FocusTrap({trapElement:this._element})}_showElement(e){document.body.contains(this._element)||document.body.append(this._element),this._element.style.display="block",this._element.removeAttribute("aria-hidden"),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.scrollTop=0;const t=SelectorEngine.findOne(".modal-body",this._dialog);t&&(t.scrollTop=0),reflow(this._element),this._element.classList.add("show");this._queueCallback((()=>{this._config.focus&&this._focustrap.activate(),this._isTransitioning=!1,EventHandler.trigger(this._element,EVENT_SHOWN$4,{relatedTarget:e})}),this._dialog,this._isAnimated())}_addEventListeners(){EventHandler.on(this._element,EVENT_KEYDOWN_DISMISS$1,(e=>{"Escape"===e.key&&(this._config.keyboard?this.hide():this._triggerBackdropTransition())})),EventHandler.on(window,EVENT_RESIZE$1,(()=>{this._isShown&&!this._isTransitioning&&this._adjustDialog()})),EventHandler.on(this._element,EVENT_MOUSEDOWN_DISMISS,(e=>{EventHandler.one(this._element,EVENT_CLICK_DISMISS,(t=>{this._element===e.target&&this._element===t.target&&("static"!==this._config.backdrop?this._config.backdrop&&this.hide():this._triggerBackdropTransition())}))}))}_hideModal(){this._element.style.display="none",this._element.setAttribute("aria-hidden",!0),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._isTransitioning=!1,this._backdrop.hide((()=>{document.body.classList.remove("modal-open"),this._resetAdjustments(),this._scrollBar.reset(),EventHandler.trigger(this._element,EVENT_HIDDEN$4)}))}_isAnimated(){return this._element.classList.contains("fade")}_triggerBackdropTransition(){if(EventHandler.trigger(this._element,EVENT_HIDE_PREVENTED$1).defaultPrevented)return;const e=this._element.scrollHeight>document.documentElement.clientHeight,t=this._element.style.overflowY;"hidden"===t||this._element.classList.contains("modal-static")||(e||(this._element.style.overflowY="hidden"),this._element.classList.add("modal-static"),this._queueCallback((()=>{this._element.classList.remove("modal-static"),this._queueCallback((()=>{this._element.style.overflowY=t}),this._dialog)}),this._dialog),this._element.focus())}_adjustDialog(){const e=this._element.scrollHeight>document.documentElement.clientHeight,t=this._scrollBar.getWidth(),n=t>0;if(n&&!e){const e=isRTL()?"paddingLeft":"paddingRight";this._element.style[e]=`${t}px`}if(!n&&e){const e=isRTL()?"paddingRight":"paddingLeft";this._element.style[e]=`${t}px`}}_resetAdjustments(){this._element.style.paddingLeft="",this._element.style.paddingRight=""}static jQueryInterface(e,t){return this.each((function(){const n=Modal.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===n[e])throw new TypeError(`No method named "${e}"`);n[e](t)}}))}}EventHandler.on(document,EVENT_CLICK_DATA_API$2,SELECTOR_DATA_TOGGLE$2,(function(e){const t=SelectorEngine.getElementFromSelector(this);["A","AREA"].includes(this.tagName)&&e.preventDefault(),EventHandler.one(t,EVENT_SHOW$4,(e=>{e.defaultPrevented||EventHandler.one(t,EVENT_HIDDEN$4,(()=>{isVisible(this)&&this.focus()}))}));const n=SelectorEngine.findOne(".modal.show");n&&Modal.getInstance(n).hide();Modal.getOrCreateInstance(t).toggle(this)})),enableDismissTrigger(Modal),defineJQueryPlugin(Modal);const NAME$6="offcanvas",DATA_KEY$3="bs.offcanvas",EVENT_KEY$3=`.${DATA_KEY$3}`,DATA_API_KEY$1=".data-api",EVENT_LOAD_DATA_API$2=`load${EVENT_KEY$3}.data-api`,ESCAPE_KEY="Escape",CLASS_NAME_SHOW$3="show",CLASS_NAME_SHOWING$1="showing",CLASS_NAME_HIDING="hiding",CLASS_NAME_BACKDROP="offcanvas-backdrop",OPEN_SELECTOR=".offcanvas.show",EVENT_SHOW$3=`show${EVENT_KEY$3}`,EVENT_SHOWN$3=`shown${EVENT_KEY$3}`,EVENT_HIDE$3=`hide${EVENT_KEY$3}`,EVENT_HIDE_PREVENTED=`hidePrevented${EVENT_KEY$3}`,EVENT_HIDDEN$3=`hidden${EVENT_KEY$3}`,EVENT_RESIZE=`resize${EVENT_KEY$3}`,EVENT_CLICK_DATA_API$1=`click${EVENT_KEY$3}.data-api`,EVENT_KEYDOWN_DISMISS=`keydown.dismiss${EVENT_KEY$3}`,SELECTOR_DATA_TOGGLE$1='[data-bs-toggle="offcanvas"]',Default$5={backdrop:!0,keyboard:!0,scroll:!1},DefaultType$5={backdrop:"(boolean|string)",keyboard:"boolean",scroll:"boolean"};class Offcanvas extends BaseComponent{constructor(e,t){super(e,t),this._isShown=!1,this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._addEventListeners()}static get Default(){return Default$5}static get DefaultType(){return DefaultType$5}static get NAME(){return NAME$6}toggle(e){return this._isShown?this.hide():this.show(e)}show(e){if(this._isShown)return;if(EventHandler.trigger(this._element,EVENT_SHOW$3,{relatedTarget:e}).defaultPrevented)return;this._isShown=!0,this._backdrop.show(),this._config.scroll||(new ScrollBarHelper).hide(),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.classList.add("showing");this._queueCallback((()=>{this._config.scroll&&!this._config.backdrop||this._focustrap.activate(),this._element.classList.add("show"),this._element.classList.remove("showing"),EventHandler.trigger(this._element,EVENT_SHOWN$3,{relatedTarget:e})}),this._element,!0)}hide(){if(!this._isShown)return;if(EventHandler.trigger(this._element,EVENT_HIDE$3).defaultPrevented)return;this._focustrap.deactivate(),this._element.blur(),this._isShown=!1,this._element.classList.add("hiding"),this._backdrop.hide();this._queueCallback((()=>{this._element.classList.remove("show","hiding"),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._config.scroll||(new ScrollBarHelper).reset(),EventHandler.trigger(this._element,EVENT_HIDDEN$3)}),this._element,!0)}dispose(){this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}_initializeBackDrop(){const e=Boolean(this._config.backdrop);return new Backdrop({className:CLASS_NAME_BACKDROP,isVisible:e,isAnimated:!0,rootElement:this._element.parentNode,clickCallback:e?()=>{"static"!==this._config.backdrop?this.hide():EventHandler.trigger(this._element,EVENT_HIDE_PREVENTED)}:null})}_initializeFocusTrap(){return new FocusTrap({trapElement:this._element})}_addEventListeners(){EventHandler.on(this._element,EVENT_KEYDOWN_DISMISS,(e=>{"Escape"===e.key&&(this._config.keyboard?this.hide():EventHandler.trigger(this._element,EVENT_HIDE_PREVENTED))}))}static jQueryInterface(e){return this.each((function(){const t=Offcanvas.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e](this)}}))}}EventHandler.on(document,EVENT_CLICK_DATA_API$1,SELECTOR_DATA_TOGGLE$1,(function(e){const t=SelectorEngine.getElementFromSelector(this);if(["A","AREA"].includes(this.tagName)&&e.preventDefault(),isDisabled(this))return;EventHandler.one(t,EVENT_HIDDEN$3,(()=>{isVisible(this)&&this.focus()}));const n=SelectorEngine.findOne(OPEN_SELECTOR);n&&n!==t&&Offcanvas.getInstance(n).hide();Offcanvas.getOrCreateInstance(t).toggle(this)})),EventHandler.on(window,EVENT_LOAD_DATA_API$2,(()=>{for(const e of SelectorEngine.find(OPEN_SELECTOR))Offcanvas.getOrCreateInstance(e).show()})),EventHandler.on(window,EVENT_RESIZE,(()=>{for(const e of SelectorEngine.find("[aria-modal][class*=show][class*=offcanvas-]"))"fixed"!==getComputedStyle(e).position&&Offcanvas.getOrCreateInstance(e).hide()})),enableDismissTrigger(Offcanvas),defineJQueryPlugin(Offcanvas);const ARIA_ATTRIBUTE_PATTERN=/^aria-[\w-]*$/i,DefaultAllowlist={"*":["class","dir","id","lang","role",ARIA_ATTRIBUTE_PATTERN],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","srcset","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},uriAttributes=new Set(["background","cite","href","itemtype","longdesc","poster","src","xlink:href"]),SAFE_URL_PATTERN=/^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i,allowedAttribute=(e,t)=>{const n=e.nodeName.toLowerCase();return t.includes(n)?!uriAttributes.has(n)||Boolean(SAFE_URL_PATTERN.test(e.nodeValue)):t.filter((e=>e instanceof RegExp)).some((e=>e.test(n)))};function sanitizeHtml(e,t,n){if(!e.length)return e;if(n&&"function"==typeof n)return n(e);const i=(new window.DOMParser).parseFromString(e,"text/html"),s=[].concat(...i.body.querySelectorAll("*"));for(const e of s){const n=e.nodeName.toLowerCase();if(!Object.keys(t).includes(n)){e.remove();continue}const i=[].concat(...e.attributes),s=[].concat(t["*"]||[],t[n]||[]);for(const t of i)allowedAttribute(t,s)||e.removeAttribute(t.nodeName)}return i.body.innerHTML}const NAME$5="TemplateFactory",Default$4={allowList:DefaultAllowlist,content:{},extraClass:"",html:!1,sanitize:!0,sanitizeFn:null,template:"<div></div>"},DefaultType$4={allowList:"object",content:"object",extraClass:"(string|function)",html:"boolean",sanitize:"boolean",sanitizeFn:"(null|function)",template:"string"},DefaultContentType={entry:"(string|element|function|null)",selector:"(string|element)"};class TemplateFactory extends Config{constructor(e){super(),this._config=this._getConfig(e)}static get Default(){return Default$4}static get DefaultType(){return DefaultType$4}static get NAME(){return NAME$5}getContent(){return Object.values(this._config.content).map((e=>this._resolvePossibleFunction(e))).filter(Boolean)}hasContent(){return this.getContent().length>0}changeContent(e){return this._checkContent(e),this._config.content={...this._config.content,...e},this}toHtml(){const e=document.createElement("div");e.innerHTML=this._maybeSanitize(this._config.template);for(const[t,n]of Object.entries(this._config.content))this._setContent(e,n,t);const t=e.children[0],n=this._resolvePossibleFunction(this._config.extraClass);return n&&t.classList.add(...n.split(" ")),t}_typeCheckConfig(e){super._typeCheckConfig(e),this._checkContent(e.content)}_checkContent(e){for(const[t,n]of Object.entries(e))super._typeCheckConfig({selector:t,entry:n},DefaultContentType)}_setContent(e,t,n){const i=SelectorEngine.findOne(n,e);i&&((t=this._resolvePossibleFunction(t))?isElement(t)?this._putElementInTemplate(getElement(t),i):this._config.html?i.innerHTML=this._maybeSanitize(t):i.textContent=t:i.remove())}_maybeSanitize(e){return this._config.sanitize?sanitizeHtml(e,this._config.allowList,this._config.sanitizeFn):e}_resolvePossibleFunction(e){return execute(e,[this])}_putElementInTemplate(e,t){if(this._config.html)return t.innerHTML="",void t.append(e);t.textContent=e.textContent}}const NAME$4="tooltip",DISALLOWED_ATTRIBUTES=new Set(["sanitize","allowList","sanitizeFn"]),CLASS_NAME_FADE$2="fade",CLASS_NAME_MODAL="modal",CLASS_NAME_SHOW$2="show",SELECTOR_TOOLTIP_INNER=".tooltip-inner",SELECTOR_MODAL=".modal",EVENT_MODAL_HIDE="hide.bs.modal",TRIGGER_HOVER="hover",TRIGGER_FOCUS="focus",TRIGGER_CLICK="click",TRIGGER_MANUAL="manual",EVENT_HIDE$2="hide",EVENT_HIDDEN$2="hidden",EVENT_SHOW$2="show",EVENT_SHOWN$2="shown",EVENT_INSERTED="inserted",EVENT_CLICK$1="click",EVENT_FOCUSIN$1="focusin",EVENT_FOCUSOUT$1="focusout",EVENT_MOUSEENTER="mouseenter",EVENT_MOUSELEAVE="mouseleave",AttachmentMap={AUTO:"auto",TOP:"top",RIGHT:isRTL()?"left":"right",BOTTOM:"bottom",LEFT:isRTL()?"right":"left"},Default$3={allowList:DefaultAllowlist,animation:!0,boundary:"clippingParents",container:!1,customClass:"",delay:0,fallbackPlacements:["top","right","bottom","left"],html:!1,offset:[0,6],placement:"top",popperConfig:null,sanitize:!0,sanitizeFn:null,selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',title:"",trigger:"hover focus"},DefaultType$3={allowList:"object",animation:"boolean",boundary:"(string|element)",container:"(string|element|boolean)",customClass:"(string|function)",delay:"(number|object)",fallbackPlacements:"array",html:"boolean",offset:"(array|string|function)",placement:"(string|function)",popperConfig:"(null|object|function)",sanitize:"boolean",sanitizeFn:"(null|function)",selector:"(string|boolean)",template:"string",title:"(string|element|function)",trigger:"string"};class Tooltip extends BaseComponent{constructor(e,t){if(void 0===Popper)throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");super(e,t),this._isEnabled=!0,this._timeout=0,this._isHovered=null,this._activeTrigger={},this._popper=null,this._templateFactory=null,this._newContent=null,this.tip=null,this._setListeners(),this._config.selector||this._fixTitle()}static get Default(){return Default$3}static get DefaultType(){return DefaultType$3}static get NAME(){return NAME$4}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}toggleEnabled(){this._isEnabled=!this._isEnabled}toggle(){this._isEnabled&&(this._activeTrigger.click=!this._activeTrigger.click,this._isShown()?this._leave():this._enter())}dispose(){clearTimeout(this._timeout),EventHandler.off(this._element.closest(".modal"),"hide.bs.modal",this._hideModalHandler),this._element.getAttribute("data-bs-original-title")&&this._element.setAttribute("title",this._element.getAttribute("data-bs-original-title")),this._disposePopper(),super.dispose()}show(){if("none"===this._element.style.display)throw new Error("Please use show on visible elements");if(!this._isWithContent()||!this._isEnabled)return;const e=EventHandler.trigger(this._element,this.constructor.eventName("show")),t=(findShadowRoot(this._element)||this._element.ownerDocument.documentElement).contains(this._element);if(e.defaultPrevented||!t)return;this._disposePopper();const n=this._getTipElement();this._element.setAttribute("aria-describedby",n.getAttribute("id"));const{container:i}=this._config;if(this._element.ownerDocument.documentElement.contains(this.tip)||(i.append(n),EventHandler.trigger(this._element,this.constructor.eventName("inserted"))),this._popper=this._createPopper(n),n.classList.add("show"),"ontouchstart"in document.documentElement)for(const e of[].concat(...document.body.children))EventHandler.on(e,"mouseover",noop);this._queueCallback((()=>{EventHandler.trigger(this._element,this.constructor.eventName("shown")),!1===this._isHovered&&this._leave(),this._isHovered=!1}),this.tip,this._isAnimated())}hide(){if(!this._isShown())return;if(EventHandler.trigger(this._element,this.constructor.eventName("hide")).defaultPrevented)return;if(this._getTipElement().classList.remove("show"),"ontouchstart"in document.documentElement)for(const e of[].concat(...document.body.children))EventHandler.off(e,"mouseover",noop);this._activeTrigger.click=!1,this._activeTrigger.focus=!1,this._activeTrigger.hover=!1,this._isHovered=null;this._queueCallback((()=>{this._isWithActiveTrigger()||(this._isHovered||this._disposePopper(),this._element.removeAttribute("aria-describedby"),EventHandler.trigger(this._element,this.constructor.eventName("hidden")))}),this.tip,this._isAnimated())}update(){this._popper&&this._popper.update()}_isWithContent(){return Boolean(this._getTitle())}_getTipElement(){return this.tip||(this.tip=this._createTipElement(this._newContent||this._getContentForTemplate())),this.tip}_createTipElement(e){const t=this._getTemplateFactory(e).toHtml();if(!t)return null;t.classList.remove("fade","show"),t.classList.add(`bs-${this.constructor.NAME}-auto`);const n=getUID(this.constructor.NAME).toString();return t.setAttribute("id",n),this._isAnimated()&&t.classList.add("fade"),t}setContent(e){this._newContent=e,this._isShown()&&(this._disposePopper(),this.show())}_getTemplateFactory(e){return this._templateFactory?this._templateFactory.changeContent(e):this._templateFactory=new TemplateFactory({...this._config,content:e,extraClass:this._resolvePossibleFunction(this._config.customClass)}),this._templateFactory}_getContentForTemplate(){return{".tooltip-inner":this._getTitle()}}_getTitle(){return this._resolvePossibleFunction(this._config.title)||this._element.getAttribute("data-bs-original-title")}_initializeOnDelegatedTarget(e){return this.constructor.getOrCreateInstance(e.delegateTarget,this._getDelegateConfig())}_isAnimated(){return this._config.animation||this.tip&&this.tip.classList.contains("fade")}_isShown(){return this.tip&&this.tip.classList.contains("show")}_createPopper(e){const t=execute(this._config.placement,[this,e,this._element]),n=AttachmentMap[t.toUpperCase()];return createPopper(this._element,e,this._getPopperConfig(n))}_getOffset(){const{offset:e}=this._config;return"string"==typeof e?e.split(",").map((e=>Number.parseInt(e,10))):"function"==typeof e?t=>e(t,this._element):e}_resolvePossibleFunction(e){return execute(e,[this._element])}_getPopperConfig(e){const t={placement:e,modifiers:[{name:"flip",options:{fallbackPlacements:this._config.fallbackPlacements}},{name:"offset",options:{offset:this._getOffset()}},{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"arrow",options:{element:`.${this.constructor.NAME}-arrow`}},{name:"preSetPlacement",enabled:!0,phase:"beforeMain",fn:e=>{this._getTipElement().setAttribute("data-popper-placement",e.state.placement)}}]};return{...t,...execute(this._config.popperConfig,[t])}}_setListeners(){const e=this._config.trigger.split(" ");for(const t of e)if("click"===t)EventHandler.on(this._element,this.constructor.eventName("click"),this._config.selector,(e=>{this._initializeOnDelegatedTarget(e).toggle()}));else if("manual"!==t){const e="hover"===t?this.constructor.eventName("mouseenter"):this.constructor.eventName("focusin"),n="hover"===t?this.constructor.eventName("mouseleave"):this.constructor.eventName("focusout");EventHandler.on(this._element,e,this._config.selector,(e=>{const t=this._initializeOnDelegatedTarget(e);t._activeTrigger["focusin"===e.type?"focus":"hover"]=!0,t._enter()})),EventHandler.on(this._element,n,this._config.selector,(e=>{const t=this._initializeOnDelegatedTarget(e);t._activeTrigger["focusout"===e.type?"focus":"hover"]=t._element.contains(e.relatedTarget),t._leave()}))}this._hideModalHandler=()=>{this._element&&this.hide()},EventHandler.on(this._element.closest(".modal"),"hide.bs.modal",this._hideModalHandler)}_fixTitle(){const e=this._element.getAttribute("title");e&&(this._element.getAttribute("aria-label")||this._element.textContent.trim()||this._element.setAttribute("aria-label",e),this._element.setAttribute("data-bs-original-title",e),this._element.removeAttribute("title"))}_enter(){this._isShown()||this._isHovered?this._isHovered=!0:(this._isHovered=!0,this._setTimeout((()=>{this._isHovered&&this.show()}),this._config.delay.show))}_leave(){this._isWithActiveTrigger()||(this._isHovered=!1,this._setTimeout((()=>{this._isHovered||this.hide()}),this._config.delay.hide))}_setTimeout(e,t){clearTimeout(this._timeout),this._timeout=setTimeout(e,t)}_isWithActiveTrigger(){return Object.values(this._activeTrigger).includes(!0)}_getConfig(e){const t=Manipulator.getDataAttributes(this._element);for(const e of Object.keys(t))DISALLOWED_ATTRIBUTES.has(e)&&delete t[e];return e={...t,..."object"==typeof e&&e?e:{}},e=this._mergeConfigObj(e),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}_configAfterMerge(e){return e.container=!1===e.container?document.body:getElement(e.container),"number"==typeof e.delay&&(e.delay={show:e.delay,hide:e.delay}),"number"==typeof e.title&&(e.title=e.title.toString()),"number"==typeof e.content&&(e.content=e.content.toString()),e}_getDelegateConfig(){const e={};for(const[t,n]of Object.entries(this._config))this.constructor.Default[t]!==n&&(e[t]=n);return e.selector=!1,e.trigger="manual",e}_disposePopper(){this._popper&&(this._popper.destroy(),this._popper=null),this.tip&&(this.tip.remove(),this.tip=null)}static jQueryInterface(e){return this.each((function(){const t=Tooltip.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e]()}}))}}defineJQueryPlugin(Tooltip);const NAME$3="popover",SELECTOR_TITLE=".popover-header",SELECTOR_CONTENT=".popover-body",Default$2={...Tooltip.Default,content:"",offset:[0,8],placement:"right",template:'<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>',trigger:"click"},DefaultType$2={...Tooltip.DefaultType,content:"(null|string|element|function)"};class Popover extends Tooltip{static get Default(){return Default$2}static get DefaultType(){return DefaultType$2}static get NAME(){return NAME$3}_isWithContent(){return this._getTitle()||this._getContent()}_getContentForTemplate(){return{[SELECTOR_TITLE]:this._getTitle(),".popover-body":this._getContent()}}_getContent(){return this._resolvePossibleFunction(this._config.content)}static jQueryInterface(e){return this.each((function(){const t=Popover.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e]()}}))}}defineJQueryPlugin(Popover);const NAME$2="scrollspy",DATA_KEY$2="bs.scrollspy",EVENT_KEY$2=`.${DATA_KEY$2}`,DATA_API_KEY=".data-api",EVENT_ACTIVATE=`activate${EVENT_KEY$2}`,EVENT_CLICK=`click${EVENT_KEY$2}`,EVENT_LOAD_DATA_API$1=`load${EVENT_KEY$2}.data-api`,CLASS_NAME_DROPDOWN_ITEM="dropdown-item",CLASS_NAME_ACTIVE$1="active",SELECTOR_DATA_SPY='[data-bs-spy="scroll"]',SELECTOR_TARGET_LINKS="[href]",SELECTOR_NAV_LIST_GROUP=".nav, .list-group",SELECTOR_NAV_LINKS=".nav-link",SELECTOR_NAV_ITEMS=".nav-item",SELECTOR_LIST_ITEMS=".list-group-item",SELECTOR_LINK_ITEMS=".nav-link, .nav-item > .nav-link, .list-group-item",SELECTOR_DROPDOWN=".dropdown",SELECTOR_DROPDOWN_TOGGLE$1=".dropdown-toggle",Default$1={offset:null,rootMargin:"0px 0px -25%",smoothScroll:!1,target:null,threshold:[.1,.5,1]},DefaultType$1={offset:"(number|null)",rootMargin:"string",smoothScroll:"boolean",target:"element",threshold:"array"};class ScrollSpy extends BaseComponent{constructor(e,t){super(e,t),this._targetLinks=new Map,this._observableSections=new Map,this._rootElement="visible"===getComputedStyle(this._element).overflowY?null:this._element,this._activeTarget=null,this._observer=null,this._previousScrollData={visibleEntryTop:0,parentScrollTop:0},this.refresh()}static get Default(){return Default$1}static get DefaultType(){return DefaultType$1}static get NAME(){return NAME$2}refresh(){this._initializeTargetsAndObservables(),this._maybeEnableSmoothScroll(),this._observer?this._observer.disconnect():this._observer=this._getNewObserver();for(const e of this._observableSections.values())this._observer.observe(e)}dispose(){this._observer.disconnect(),super.dispose()}_configAfterMerge(e){return e.target=getElement(e.target)||document.body,e.rootMargin=e.offset?`${e.offset}px 0px -30%`:e.rootMargin,"string"==typeof e.threshold&&(e.threshold=e.threshold.split(",").map((e=>Number.parseFloat(e)))),e}_maybeEnableSmoothScroll(){this._config.smoothScroll&&(EventHandler.off(this._config.target,EVENT_CLICK),EventHandler.on(this._config.target,EVENT_CLICK,"[href]",(e=>{const t=this._observableSections.get(e.target.hash);if(t){e.preventDefault();const n=this._rootElement||window,i=t.offsetTop-this._element.offsetTop;if(n.scrollTo)return void n.scrollTo({top:i,behavior:"smooth"});n.scrollTop=i}})))}_getNewObserver(){const e={root:this._rootElement,threshold:this._config.threshold,rootMargin:this._config.rootMargin};return new IntersectionObserver((e=>this._observerCallback(e)),e)}_observerCallback(e){const t=e=>this._targetLinks.get(`#${e.target.id}`),n=e=>{this._previousScrollData.visibleEntryTop=e.target.offsetTop,this._process(t(e))},i=(this._rootElement||document.documentElement).scrollTop,s=i>=this._previousScrollData.parentScrollTop;this._previousScrollData.parentScrollTop=i;for(const o of e){if(!o.isIntersecting){this._activeTarget=null,this._clearActiveClass(t(o));continue}const e=o.target.offsetTop>=this._previousScrollData.visibleEntryTop;if(s&&e){if(n(o),!i)return}else s||e||n(o)}}_initializeTargetsAndObservables(){this._targetLinks=new Map,this._observableSections=new Map;const e=SelectorEngine.find("[href]",this._config.target);for(const t of e){if(!t.hash||isDisabled(t))continue;const e=SelectorEngine.findOne(decodeURI(t.hash),this._element);isVisible(e)&&(this._targetLinks.set(decodeURI(t.hash),t),this._observableSections.set(t.hash,e))}}_process(e){this._activeTarget!==e&&(this._clearActiveClass(this._config.target),this._activeTarget=e,e.classList.add("active"),this._activateParents(e),EventHandler.trigger(this._element,EVENT_ACTIVATE,{relatedTarget:e}))}_activateParents(e){if(e.classList.contains("dropdown-item"))SelectorEngine.findOne(".dropdown-toggle",e.closest(".dropdown")).classList.add("active");else for(const t of SelectorEngine.parents(e,".nav, .list-group"))for(const e of SelectorEngine.prev(t,SELECTOR_LINK_ITEMS))e.classList.add("active")}_clearActiveClass(e){e.classList.remove("active");const t=SelectorEngine.find("[href].active",e);for(const e of t)e.classList.remove("active")}static jQueryInterface(e){return this.each((function(){const t=ScrollSpy.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e]()}}))}}EventHandler.on(window,EVENT_LOAD_DATA_API$1,(()=>{for(const e of SelectorEngine.find(SELECTOR_DATA_SPY))ScrollSpy.getOrCreateInstance(e)})),defineJQueryPlugin(ScrollSpy);const NAME$1="tab",DATA_KEY$1="bs.tab",EVENT_KEY$1=".bs.tab",EVENT_HIDE$1="hide.bs.tab",EVENT_HIDDEN$1="hidden.bs.tab",EVENT_SHOW$1="show.bs.tab",EVENT_SHOWN$1="shown.bs.tab",EVENT_CLICK_DATA_API="click.bs.tab",EVENT_KEYDOWN="keydown.bs.tab",EVENT_LOAD_DATA_API="load.bs.tab",ARROW_LEFT_KEY="ArrowLeft",ARROW_RIGHT_KEY="ArrowRight",ARROW_UP_KEY="ArrowUp",ARROW_DOWN_KEY="ArrowDown",HOME_KEY="Home",END_KEY="End",CLASS_NAME_ACTIVE="active",CLASS_NAME_FADE$1="fade",CLASS_NAME_SHOW$1="show",CLASS_DROPDOWN="dropdown",SELECTOR_DROPDOWN_TOGGLE=".dropdown-toggle",SELECTOR_DROPDOWN_MENU=".dropdown-menu",NOT_SELECTOR_DROPDOWN_TOGGLE=":not(.dropdown-toggle)",SELECTOR_TAB_PANEL='.list-group, .nav, [role="tablist"]',SELECTOR_OUTER=".nav-item, .list-group-item",SELECTOR_INNER='.nav-link:not(.dropdown-toggle), .list-group-item:not(.dropdown-toggle), [role="tab"]:not(.dropdown-toggle)',SELECTOR_DATA_TOGGLE='[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]',SELECTOR_INNER_ELEM=`${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`,SELECTOR_DATA_TOGGLE_ACTIVE='.active[data-bs-toggle="tab"], .active[data-bs-toggle="pill"], .active[data-bs-toggle="list"]';class Tab extends BaseComponent{constructor(e){super(e),this._parent=this._element.closest(SELECTOR_TAB_PANEL),this._parent&&(this._setInitialAttributes(this._parent,this._getChildren()),EventHandler.on(this._element,EVENT_KEYDOWN,(e=>this._keydown(e))))}static get NAME(){return"tab"}show(){const e=this._element;if(this._elemIsActive(e))return;const t=this._getActiveElem(),n=t?EventHandler.trigger(t,EVENT_HIDE$1,{relatedTarget:e}):null;EventHandler.trigger(e,EVENT_SHOW$1,{relatedTarget:t}).defaultPrevented||n&&n.defaultPrevented||(this._deactivate(t,e),this._activate(e,t))}_activate(e,t){if(!e)return;e.classList.add("active"),this._activate(SelectorEngine.getElementFromSelector(e));this._queueCallback((()=>{"tab"===e.getAttribute("role")?(e.removeAttribute("tabindex"),e.setAttribute("aria-selected",!0),this._toggleDropDown(e,!0),EventHandler.trigger(e,EVENT_SHOWN$1,{relatedTarget:t})):e.classList.add("show")}),e,e.classList.contains("fade"))}_deactivate(e,t){if(!e)return;e.classList.remove("active"),e.blur(),this._deactivate(SelectorEngine.getElementFromSelector(e));this._queueCallback((()=>{"tab"===e.getAttribute("role")?(e.setAttribute("aria-selected",!1),e.setAttribute("tabindex","-1"),this._toggleDropDown(e,!1),EventHandler.trigger(e,EVENT_HIDDEN$1,{relatedTarget:t})):e.classList.remove("show")}),e,e.classList.contains("fade"))}_keydown(e){if(![ARROW_LEFT_KEY,ARROW_RIGHT_KEY,ARROW_UP_KEY,ARROW_DOWN_KEY,HOME_KEY,END_KEY].includes(e.key))return;e.stopPropagation(),e.preventDefault();const t=this._getChildren().filter((e=>!isDisabled(e)));let n;if([HOME_KEY,END_KEY].includes(e.key))n=t[e.key===HOME_KEY?0:t.length-1];else{const i=[ARROW_RIGHT_KEY,ARROW_DOWN_KEY].includes(e.key);n=getNextActiveElement(t,e.target,i,!0)}n&&(n.focus({preventScroll:!0}),Tab.getOrCreateInstance(n).show())}_getChildren(){return SelectorEngine.find(SELECTOR_INNER_ELEM,this._parent)}_getActiveElem(){return this._getChildren().find((e=>this._elemIsActive(e)))||null}_setInitialAttributes(e,t){this._setAttributeIfNotExists(e,"role","tablist");for(const e of t)this._setInitialAttributesOnChild(e)}_setInitialAttributesOnChild(e){e=this._getInnerElement(e);const t=this._elemIsActive(e),n=this._getOuterElement(e);e.setAttribute("aria-selected",t),n!==e&&this._setAttributeIfNotExists(n,"role","presentation"),t||e.setAttribute("tabindex","-1"),this._setAttributeIfNotExists(e,"role","tab"),this._setInitialAttributesOnTargetPanel(e)}_setInitialAttributesOnTargetPanel(e){const t=SelectorEngine.getElementFromSelector(e);t&&(this._setAttributeIfNotExists(t,"role","tabpanel"),e.id&&this._setAttributeIfNotExists(t,"aria-labelledby",`${e.id}`))}_toggleDropDown(e,t){const n=this._getOuterElement(e);if(!n.classList.contains("dropdown"))return;const i=(e,i)=>{const s=SelectorEngine.findOne(e,n);s&&s.classList.toggle(i,t)};i(".dropdown-toggle","active"),i(".dropdown-menu","show"),n.setAttribute("aria-expanded",t)}_setAttributeIfNotExists(e,t,n){e.hasAttribute(t)||e.setAttribute(t,n)}_elemIsActive(e){return e.classList.contains("active")}_getInnerElement(e){return e.matches(SELECTOR_INNER_ELEM)?e:SelectorEngine.findOne(SELECTOR_INNER_ELEM,e)}_getOuterElement(e){return e.closest(SELECTOR_OUTER)||e}static jQueryInterface(e){return this.each((function(){const t=Tab.getOrCreateInstance(this);if("string"==typeof e){if(void 0===t[e]||e.startsWith("_")||"constructor"===e)throw new TypeError(`No method named "${e}"`);t[e]()}}))}}EventHandler.on(document,"click.bs.tab",SELECTOR_DATA_TOGGLE,(function(e){["A","AREA"].includes(this.tagName)&&e.preventDefault(),isDisabled(this)||Tab.getOrCreateInstance(this).show()})),EventHandler.on(window,"load.bs.tab",(()=>{for(const e of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE))Tab.getOrCreateInstance(e)})),defineJQueryPlugin(Tab);const NAME="toast",DATA_KEY="bs.toast",EVENT_KEY=`.${DATA_KEY}`,EVENT_MOUSEOVER=`mouseover${EVENT_KEY}`,EVENT_MOUSEOUT=`mouseout${EVENT_KEY}`,EVENT_FOCUSIN=`focusin${EVENT_KEY}`,EVENT_FOCUSOUT=`focusout${EVENT_KEY}`,EVENT_HIDE=`hide${EVENT_KEY}`,EVENT_HIDDEN=`hidden${EVENT_KEY}`,EVENT_SHOW=`show${EVENT_KEY}`,EVENT_SHOWN=`shown${EVENT_KEY}`,CLASS_NAME_FADE="fade",CLASS_NAME_HIDE="hide",CLASS_NAME_SHOW="show",CLASS_NAME_SHOWING="showing",DefaultType={animation:"boolean",autohide:"boolean",delay:"number"},Default={animation:!0,autohide:!0,delay:5e3};class Toast extends BaseComponent{constructor(e,t){super(e,t),this._timeout=null,this._hasMouseInteraction=!1,this._hasKeyboardInteraction=!1,this._setListeners()}static get Default(){return Default}static get DefaultType(){return DefaultType}static get NAME(){return NAME}show(){if(EventHandler.trigger(this._element,EVENT_SHOW).defaultPrevented)return;this._clearTimeout(),this._config.animation&&this._element.classList.add("fade");this._element.classList.remove("hide"),reflow(this._element),this._element.classList.add("show","showing"),this._queueCallback((()=>{this._element.classList.remove("showing"),EventHandler.trigger(this._element,EVENT_SHOWN),this._maybeScheduleHide()}),this._element,this._config.animation)}hide(){if(!this.isShown())return;if(EventHandler.trigger(this._element,EVENT_HIDE).defaultPrevented)return;this._element.classList.add("showing"),this._queueCallback((()=>{this._element.classList.add("hide"),this._element.classList.remove("showing","show"),EventHandler.trigger(this._element,EVENT_HIDDEN)}),this._element,this._config.animation)}dispose(){this._clearTimeout(),this.isShown()&&this._element.classList.remove("show"),super.dispose()}isShown(){return this._element.classList.contains("show")}_maybeScheduleHide(){this._config.autohide&&(this._hasMouseInteraction||this._hasKeyboardInteraction||(this._timeout=setTimeout((()=>{this.hide()}),this._config.delay)))}_onInteraction(e,t){switch(e.type){case"mouseover":case"mouseout":this._hasMouseInteraction=t;break;case"focusin":case"focusout":this._hasKeyboardInteraction=t}if(t)return void this._clearTimeout();const n=e.relatedTarget;this._element===n||this._element.contains(n)||this._maybeScheduleHide()}_setListeners(){EventHandler.on(this._element,EVENT_MOUSEOVER,(e=>this._onInteraction(e,!0))),EventHandler.on(this._element,EVENT_MOUSEOUT,(e=>this._onInteraction(e,!1))),EventHandler.on(this._element,EVENT_FOCUSIN,(e=>this._onInteraction(e,!0))),EventHandler.on(this._element,EVENT_FOCUSOUT,(e=>this._onInteraction(e,!1)))}_clearTimeout(){clearTimeout(this._timeout),this._timeout=null}static jQueryInterface(e){return this.each((function(){const t=Toast.getOrCreateInstance(this,e);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "${e}"`);t[e](this)}}))}}enableDismissTrigger(Toast),defineJQueryPlugin(Toast);export{Alert,Button,Carousel,Collapse,Dropdown,Modal,Offcanvas,Popover,ScrollSpy,Tab,Toast,Tooltip}; diff --git a/typo3/sysext/dashboard/Resources/Public/JavaScript/Contrib/chartjs.js b/typo3/sysext/dashboard/Resources/Public/JavaScript/Contrib/chartjs.js index a9e3126128bfd8ef4ce4d2cc153e429056d5e9b9..6876b62239b5addb3aad601d4dc2d85ceca88ff0 100644 --- a/typo3/sysext/dashboard/Resources/Public/JavaScript/Contrib/chartjs.js +++ b/typo3/sysext/dashboard/Resources/Public/JavaScript/Contrib/chartjs.js @@ -10,10 +10,10 @@ function round(t){return t+.5|0}const lim=(t,e,i)=>Math.max(Math.min(t,i),e);fun * https://www.chartjs.org * (c) 2023 Chart.js Contributors * Released under the MIT License - */function noop(){}const uid=(()=>{let t=0;return()=>t++})();function isNullOrUndef(t){return null==t}function isArray(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.slice(0,7)&&"Array]"===e.slice(-6)}function isObject(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}function isNumberFinite(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)}function finiteOrDefault(t,e){return isNumberFinite(t)?t:e}function valueOrDefault(t,e){return void 0===t?e:t}const toPercentage=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:+t/e,toDimension=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function callback(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function each(t,e,i,s){let n,o,a;if(isArray(t))if(o=t.length,s)for(n=o-1;n>=0;n--)e.call(i,t[n],n);else for(n=0;n<o;n++)e.call(i,t[n],n);else if(isObject(t))for(a=Object.keys(t),o=a.length,n=0;n<o;n++)e.call(i,t[a[n]],a[n])}function _elementsEqual(t,e){let i,s,n,o;if(!t||!e||t.length!==e.length)return!1;for(i=0,s=t.length;i<s;++i)if(n=t[i],o=e[i],n.datasetIndex!==o.datasetIndex||n.index!==o.index)return!1;return!0}function clone(t){if(isArray(t))return t.map(clone);if(isObject(t)){const e=Object.create(null),i=Object.keys(t),s=i.length;let n=0;for(;n<s;++n)e[i[n]]=clone(t[i[n]]);return e}return t}function isValidKey(t){return-1===["__proto__","prototype","constructor"].indexOf(t)}function _merger(t,e,i,s){if(!isValidKey(t))return;const n=e[t],o=i[t];isObject(n)&&isObject(o)?merge(n,o,s):e[t]=clone(o)}function merge(t,e,i){const s=isArray(e)?e:[e],n=s.length;if(!isObject(t))return t;const o=(i=i||{}).merger||_merger;let a;for(let e=0;e<n;++e){if(a=s[e],!isObject(a))continue;const n=Object.keys(a);for(let e=0,s=n.length;e<s;++e)o(n[e],t,a,i)}return t}function mergeIf(t,e){return merge(t,e,{merger:_mergerIf})}function _mergerIf(t,e,i){if(!isValidKey(t))return;const s=e[t],n=i[t];isObject(s)&&isObject(n)?mergeIf(s,n):Object.prototype.hasOwnProperty.call(e,t)||(e[t]=clone(n))}const keyResolvers={"":t=>t,x:t=>t.x,y:t=>t.y};function _splitKey(t){const e=t.split("."),i=[];let s="";for(const t of e)s+=t,s.endsWith("\\")?s=s.slice(0,-1)+".":(i.push(s),s="");return i}function _getKeyResolver(t){const e=_splitKey(t);return t=>{for(const i of e){if(""===i)break;t=t&&t[i]}return t}}function resolveObjectKey(t,e){return(keyResolvers[e]||(keyResolvers[e]=_getKeyResolver(e)))(t)}function _capitalize(t){return t.charAt(0).toUpperCase()+t.slice(1)}const defined=t=>void 0!==t,isFunction=t=>"function"==typeof t,setsEqual=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0};function _isClickEvent(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}const PI=Math.PI,TAU=2*PI,PITAU=TAU+PI,INFINITY=Number.POSITIVE_INFINITY,RAD_PER_DEG=PI/180,HALF_PI=PI/2,QUARTER_PI=PI/4,TWO_THIRDS_PI=2*PI/3,log10=Math.log10,sign=Math.sign;function almostEquals(t,e,i){return Math.abs(t-e)<i}function niceNum(t){const e=Math.round(t);t=almostEquals(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(log10(t))),s=t/i;return(s<=1?1:s<=2?2:s<=5?5:10)*i}function _factorize(t){const e=[],i=Math.sqrt(t);let s;for(s=1;s<i;s++)t%s==0&&(e.push(s),e.push(t/s));return i===(0|i)&&e.push(i),e.sort(((t,e)=>t-e)).pop(),e}function isNumber(t){return!isNaN(parseFloat(t))&&isFinite(t)}function almostWhole(t,e){const i=Math.round(t);return i-e<=t&&i+e>=t}function _setMinAndMaxByKey(t,e,i){let s,n,o;for(s=0,n=t.length;s<n;s++)o=t[s][i],isNaN(o)||(e.min=Math.min(e.min,o),e.max=Math.max(e.max,o))}function toRadians(t){return t*(PI/180)}function toDegrees(t){return t*(180/PI)}function _decimalPlaces(t){if(!isNumberFinite(t))return;let e=1,i=0;for(;Math.round(t*e)/e!==t;)e*=10,i++;return i}function getAngleFromPoint(t,e){const i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s);let o=Math.atan2(s,i);return o<-.5*PI&&(o+=TAU),{angle:o,distance:n}}function distanceBetweenPoints(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function _angleDiff(t,e){return(t-e+PITAU)%TAU-PI}function _normalizeAngle(t){return(t%TAU+TAU)%TAU}function _angleBetween(t,e,i,s){const n=_normalizeAngle(t),o=_normalizeAngle(e),a=_normalizeAngle(i),r=_normalizeAngle(o-n),l=_normalizeAngle(a-n),h=_normalizeAngle(n-o),c=_normalizeAngle(n-a);return n===o||n===a||s&&o===a||r>l&&h<c}function _limitValue(t,e,i){return Math.max(e,Math.min(i,t))}function _int16Range(t){return _limitValue(t,-32768,32767)}function _isBetween(t,e,i,s=1e-6){return t>=Math.min(e,i)-s&&t<=Math.max(e,i)+s}function _lookup(t,e,i){i=i||(i=>t[i]<e);let s,n=t.length-1,o=0;for(;n-o>1;)s=o+n>>1,i(s)?o=s:n=s;return{lo:o,hi:n}}const _lookupByKey=(t,e,i,s)=>_lookup(t,i,s?s=>{const n=t[s][e];return n<i||n===i&&t[s+1][e]===i}:s=>t[s][e]<i),_rlookupByKey=(t,e,i)=>_lookup(t,i,(s=>t[s][e]>=i));function _filterBetween(t,e,i){let s=0,n=t.length;for(;s<n&&t[s]<e;)s++;for(;n>s&&t[n-1]>i;)n--;return s>0||n<t.length?t.slice(s,n):t}const arrayEvents=["push","pop","shift","splice","unshift"];function listenArrayEvents(t,e){t._chartjs?t._chartjs.listeners.push(e):(Object.defineProperty(t,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[e]}}),arrayEvents.forEach((e=>{const i="_onData"+_capitalize(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const n=s.apply(this,e);return t._chartjs.listeners.forEach((t=>{"function"==typeof t[i]&&t[i](...e)})),n}})})))}function unlistenArrayEvents(t,e){const i=t._chartjs;if(!i)return;const s=i.listeners,n=s.indexOf(e);-1!==n&&s.splice(n,1),s.length>0||(arrayEvents.forEach((e=>{delete t[e]})),delete t._chartjs)}function _arrayUnique(t){const e=new Set;let i,s;for(i=0,s=t.length;i<s;++i)e.add(t[i]);return e.size===s?t:Array.from(e)}const requestAnimFrame="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function throttled(t,e){let i=[],s=!1;return function(...n){i=n,s||(s=!0,requestAnimFrame.call(window,(()=>{s=!1,t.apply(e,i)})))}}function debounce(t,e){let i;return function(...s){return e?(clearTimeout(i),i=setTimeout(t,e,s)):t.apply(this,s),e}}const _toLeftRightCenter=t=>"start"===t?"left":"end"===t?"right":"center",_alignStartEnd=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2,_textX=(t,e,i,s)=>t===(s?"left":"right")?i:"center"===t?(e+i)/2:e;function _getStartAndCountOfVisiblePoints(t,e,i){const s=e.length;let n=0,o=s;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:h,max:c,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(n=_limitValue(Math.min(_lookupByKey(r,a.axis,h).lo,i?s:_lookupByKey(e,l,a.getPixelForValue(h)).lo),0,s-1)),o=u?_limitValue(Math.max(_lookupByKey(r,a.axis,c,!0).hi+1,i?0:_lookupByKey(e,l,a.getPixelForValue(c),!0).hi+1),n,s)-n:s-n}return{start:n,count:o}}function _scaleRangesChanged(t){const{xScale:e,yScale:i,_scaleRanges:s}=t,n={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!s)return t._scaleRanges=n,!0;const o=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==i.min||s.ymax!==i.max;return Object.assign(s,n),o}const atEdge=t=>0===t||1===t,elasticIn=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*TAU/i),elasticOut=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*TAU/i)+1,effects={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*HALF_PI),easeOutSine:t=>Math.sin(t*HALF_PI),easeInOutSine:t=>-.5*(Math.cos(PI*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>atEdge(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>atEdge(t)?t:elasticIn(t,.075,.3),easeOutElastic:t=>atEdge(t)?t:elasticOut(t,.075,.3),easeInOutElastic(t){const e=.1125;return atEdge(t)?t:t<.5?.5*elasticIn(2*t,e,.45):.5+.5*elasticOut(2*t-1,e,.45)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-effects.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*effects.easeInBounce(2*t):.5*effects.easeOutBounce(2*t-1)+.5};function isPatternOrGradient(t){if(t&&"object"==typeof t){const e=t.toString();return"[object CanvasPattern]"===e||"[object CanvasGradient]"===e}return!1}function color(t){return isPatternOrGradient(t)?t:new Color(t)}function getHoverColor(t){return isPatternOrGradient(t)?t:new Color(t).saturate(.5).darken(.1).hexString()}const numbers=["x","y","borderWidth","radius","tension"],colors=["color","borderColor","backgroundColor"];function applyAnimationsDefaults(t){t.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),t.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),t.set("animations",{colors:{type:"color",properties:colors},numbers:{type:"number",properties:numbers}}),t.describe("animations",{_fallback:"animation"}),t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}})}function applyLayoutsDefaults(t){t.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const intlCache=new Map;function getNumberFormat(t,e){e=e||{};const i=t+JSON.stringify(e);let s=intlCache.get(i);return s||(s=new Intl.NumberFormat(t,e),intlCache.set(i,s)),s}function formatNumber(t,e,i){return getNumberFormat(e,i).format(t)}const formatters={values:t=>isArray(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const s=this.chart.options.locale;let n,o=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(n="scientific"),o=calculateDelta(t,i)}const a=log10(Math.abs(o)),r=Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),formatNumber(t,s,l)},logarithmic(t,e,i){if(0===t)return"0";const s=i[e].significand||t/Math.pow(10,Math.floor(log10(t)));return[1,2,3,5,10,15].includes(s)||e>.8*i.length?formatters.numeric.call(this,t,e,i):""}};function calculateDelta(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;return Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t)),i}var Ticks={formatters};function applyScaleDefaults(t){t.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Ticks.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),t.route("scale.ticks","color","","color"),t.route("scale.grid","color","","borderColor"),t.route("scale.border","color","","borderColor"),t.route("scale.title","color","","color"),t.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t&&"dash"!==t}),t.describe("scales",{_fallback:"scale"}),t.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t})}const overrides=Object.create(null),descriptors=Object.create(null);function getScope$1(t,e){if(!e)return t;const i=e.split(".");for(let e=0,s=i.length;e<s;++e){const s=i[e];t=t[s]||(t[s]=Object.create(null))}return t}function set(t,e,i){return"string"==typeof e?merge(getScope$1(t,e),i):merge(getScope$1(t,""),e)}class Defaults{constructor(t,e){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=t=>t.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(t,e)=>getHoverColor(e.backgroundColor),this.hoverBorderColor=(t,e)=>getHoverColor(e.borderColor),this.hoverColor=(t,e)=>getHoverColor(e.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return set(this,t,e)}get(t){return getScope$1(this,t)}describe(t,e){return set(descriptors,t,e)}override(t,e){return set(overrides,t,e)}route(t,e,i,s){const n=getScope$1(this,t),o=getScope$1(this,i),a="_"+e;Object.defineProperties(n,{[a]:{value:n[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=o[s];return isObject(t)?Object.assign({},e,t):valueOrDefault(t,e)},set(t){this[a]=t}}})}apply(t){t.forEach((t=>t(this)))}}var defaults=new Defaults({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[applyAnimationsDefaults,applyLayoutsDefaults,applyScaleDefaults]);function toFontString(t){return!t||isNullOrUndef(t.size)||isNullOrUndef(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}function _measureText(t,e,i,s,n){let o=e[n];return o||(o=e[n]=t.measureText(n).width,i.push(n)),o>s&&(s=o),s}function _longestText(t,e,i,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==e&&(n=s.data={},o=s.garbageCollect=[],s.font=e),t.save(),t.font=e;let a=0;const r=i.length;let l,h,c,d,u;for(l=0;l<r;l++)if(d=i[l],null!=d&&!0!==isArray(d))a=_measureText(t,n,o,a,d);else if(isArray(d))for(h=0,c=d.length;h<c;h++)u=d[h],null==u||isArray(u)||(a=_measureText(t,n,o,a,u));t.restore();const g=o.length/2;if(g>i.length){for(l=0;l<g;l++)delete n[o[l]];o.splice(0,g)}return a}function _alignPixel(t,e,i){const s=t.currentDevicePixelRatio,n=0!==i?Math.max(i/2,.5):0;return Math.round((e-n)*s)/s+n}function clearCanvas(t,e){(e=e||t.getContext("2d")).save(),e.resetTransform(),e.clearRect(0,0,t.width,t.height),e.restore()}function drawPoint(t,e,i,s){drawPointLegend(t,e,i,s,null)}function drawPointLegend(t,e,i,s,n){let o,a,r,l,h,c,d,u;const g=e.pointStyle,f=e.rotation,p=e.radius;let m=(f||0)*RAD_PER_DEG;if(g&&"object"==typeof g&&(o=g.toString(),"[object HTMLImageElement]"===o||"[object HTMLCanvasElement]"===o))return t.save(),t.translate(i,s),t.rotate(m),t.drawImage(g,-g.width/2,-g.height/2,g.width,g.height),void t.restore();if(!(isNaN(p)||p<=0)){switch(t.beginPath(),g){default:n?t.ellipse(i,s,n/2,p,0,0,TAU):t.arc(i,s,p,0,TAU),t.closePath();break;case"triangle":c=n?n/2:p,t.moveTo(i+Math.sin(m)*c,s-Math.cos(m)*p),m+=TWO_THIRDS_PI,t.lineTo(i+Math.sin(m)*c,s-Math.cos(m)*p),m+=TWO_THIRDS_PI,t.lineTo(i+Math.sin(m)*c,s-Math.cos(m)*p),t.closePath();break;case"rectRounded":h=.516*p,l=p-h,a=Math.cos(m+QUARTER_PI)*l,d=Math.cos(m+QUARTER_PI)*(n?n/2-h:l),r=Math.sin(m+QUARTER_PI)*l,u=Math.sin(m+QUARTER_PI)*(n?n/2-h:l),t.arc(i-d,s-r,h,m-PI,m-HALF_PI),t.arc(i+u,s-a,h,m-HALF_PI,m),t.arc(i+d,s+r,h,m,m+HALF_PI),t.arc(i-u,s+a,h,m+HALF_PI,m+PI),t.closePath();break;case"rect":if(!f){l=Math.SQRT1_2*p,c=n?n/2:l,t.rect(i-c,s-l,2*c,2*l);break}m+=QUARTER_PI;case"rectRot":d=Math.cos(m)*(n?n/2:p),a=Math.cos(m)*p,r=Math.sin(m)*p,u=Math.sin(m)*(n?n/2:p),t.moveTo(i-d,s-r),t.lineTo(i+u,s-a),t.lineTo(i+d,s+r),t.lineTo(i-u,s+a),t.closePath();break;case"crossRot":m+=QUARTER_PI;case"cross":d=Math.cos(m)*(n?n/2:p),a=Math.cos(m)*p,r=Math.sin(m)*p,u=Math.sin(m)*(n?n/2:p),t.moveTo(i-d,s-r),t.lineTo(i+d,s+r),t.moveTo(i+u,s-a),t.lineTo(i-u,s+a);break;case"star":d=Math.cos(m)*(n?n/2:p),a=Math.cos(m)*p,r=Math.sin(m)*p,u=Math.sin(m)*(n?n/2:p),t.moveTo(i-d,s-r),t.lineTo(i+d,s+r),t.moveTo(i+u,s-a),t.lineTo(i-u,s+a),m+=QUARTER_PI,d=Math.cos(m)*(n?n/2:p),a=Math.cos(m)*p,r=Math.sin(m)*p,u=Math.sin(m)*(n?n/2:p),t.moveTo(i-d,s-r),t.lineTo(i+d,s+r),t.moveTo(i+u,s-a),t.lineTo(i-u,s+a);break;case"line":a=n?n/2:Math.cos(m)*p,r=Math.sin(m)*p,t.moveTo(i-a,s-r),t.lineTo(i+a,s+r);break;case"dash":t.moveTo(i,s),t.lineTo(i+Math.cos(m)*(n?n/2:p),s+Math.sin(m)*p);break;case!1:t.closePath()}t.fill(),e.borderWidth>0&&t.stroke()}}function _isPointInArea(t,e,i){return i=i||.5,!e||t&&t.x>e.left-i&&t.x<e.right+i&&t.y>e.top-i&&t.y<e.bottom+i}function clipArea(t,e){t.save(),t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.clip()}function unclipArea(t){t.restore()}function _steppedLineTo(t,e,i,s,n){if(!e)return t.lineTo(i.x,i.y);if("middle"===n){const s=(e.x+i.x)/2;t.lineTo(s,e.y),t.lineTo(s,i.y)}else"after"===n!=!!s?t.lineTo(e.x,i.y):t.lineTo(i.x,e.y);t.lineTo(i.x,i.y)}function _bezierCurveTo(t,e,i,s){if(!e)return t.lineTo(i.x,i.y);t.bezierCurveTo(s?e.cp1x:e.cp2x,s?e.cp1y:e.cp2y,s?i.cp2x:i.cp1x,s?i.cp2y:i.cp1y,i.x,i.y)}function renderText(t,e,i,s,n,o={}){const a=isArray(e)?e:[e],r=o.strokeWidth>0&&""!==o.strokeColor;let l,h;for(t.save(),t.font=n.string,setRenderOpts(t,o),l=0;l<a.length;++l)h=a[l],o.backdrop&&drawBackdrop(t,o.backdrop),r&&(o.strokeColor&&(t.strokeStyle=o.strokeColor),isNullOrUndef(o.strokeWidth)||(t.lineWidth=o.strokeWidth),t.strokeText(h,i,s,o.maxWidth)),t.fillText(h,i,s,o.maxWidth),decorateText(t,i,s,h,o),s+=n.lineHeight;t.restore()}function setRenderOpts(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]),isNullOrUndef(e.rotation)||t.rotate(e.rotation),e.color&&(t.fillStyle=e.color),e.textAlign&&(t.textAlign=e.textAlign),e.textBaseline&&(t.textBaseline=e.textBaseline)}function decorateText(t,e,i,s,n){if(n.strikethrough||n.underline){const o=t.measureText(s),a=e-o.actualBoundingBoxLeft,r=e+o.actualBoundingBoxRight,l=i-o.actualBoundingBoxAscent,h=i+o.actualBoundingBoxDescent,c=n.strikethrough?(l+h)/2:h;t.strokeStyle=t.fillStyle,t.beginPath(),t.lineWidth=n.decorationWidth||2,t.moveTo(a,c),t.lineTo(r,c),t.stroke()}}function drawBackdrop(t,e){const i=t.fillStyle;t.fillStyle=e.color,t.fillRect(e.left,e.top,e.width,e.height),t.fillStyle=i}function addRoundedRectPath(t,e){const{x:i,y:s,w:n,h:o,radius:a}=e;t.arc(i+a.topLeft,s+a.topLeft,a.topLeft,-HALF_PI,PI,!0),t.lineTo(i,s+o-a.bottomLeft),t.arc(i+a.bottomLeft,s+o-a.bottomLeft,a.bottomLeft,PI,HALF_PI,!0),t.lineTo(i+n-a.bottomRight,s+o),t.arc(i+n-a.bottomRight,s+o-a.bottomRight,a.bottomRight,HALF_PI,0,!0),t.lineTo(i+n,s+a.topRight),t.arc(i+n-a.topRight,s+a.topRight,a.topRight,0,-HALF_PI,!0),t.lineTo(i+a.topLeft,s)}const LINE_HEIGHT=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,FONT_STYLE=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function toLineHeight(t,e){const i=(""+t).match(LINE_HEIGHT);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}const numberOrZero=t=>+t||0;function _readValueToProps(t,e){const i={},s=isObject(e),n=s?Object.keys(e):e,o=isObject(t)?s?i=>valueOrDefault(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of n)i[t]=numberOrZero(o(t));return i}function toTRBL(t){return _readValueToProps(t,{top:"y",right:"x",bottom:"y",left:"x"})}function toTRBLCorners(t){return _readValueToProps(t,["topLeft","topRight","bottomLeft","bottomRight"])}function toPadding(t){const e=toTRBL(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function toFont(t,e){t=t||{},e=e||defaults.font;let i=valueOrDefault(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let s=valueOrDefault(t.style,e.style);s&&!(""+s).match(FONT_STYLE)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);const n={family:valueOrDefault(t.family,e.family),lineHeight:toLineHeight(valueOrDefault(t.lineHeight,e.lineHeight),i),size:i,style:s,weight:valueOrDefault(t.weight,e.weight),string:""};return n.string=toFontString(n),n}function resolve(t,e,i,s){let n,o,a,r=!0;for(n=0,o=t.length;n<o;++n)if(a=t[n],void 0!==a&&(void 0!==e&&"function"==typeof a&&(a=a(e),r=!1),void 0!==i&&isArray(a)&&(a=a[i%a.length],r=!1),void 0!==a))return s&&!r&&(s.cacheable=!1),a}function _addGrace(t,e,i){const{min:s,max:n}=t,o=toDimension(e,(n-s)/2),a=(t,e)=>i&&0===t?0:t+e;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function createContext(t,e){return Object.assign(Object.create(t),e)}function _createResolver(t,e=[""],i=t,s,n=(()=>t[0])){defined(s)||(s=_resolve("_fallback",t));const o={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:s,_getTarget:n,override:n=>_createResolver([n,...t],e,i,s)};return new Proxy(o,{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,s)=>_cached(i,s,(()=>_resolveWithPrefixes(s,e,t,i))),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>getKeysFromAllScopes(t).includes(e),ownKeys:t=>getKeysFromAllScopes(t),set(t,e,i){const s=t._storage||(t._storage=n());return t[e]=s[e]=i,delete t._keys,!0}})}function _attachContext(t,e,i,s){const n={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:_descriptors(t,s),setContext:e=>_attachContext(t,e,i,s),override:n=>_attachContext(t.override(n),e,i,s)};return new Proxy(n,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>_cached(t,e,(()=>_resolveWithContext(t,e,i))),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,s)=>(t[i]=s,delete e[i],!0)})}function _descriptors(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:s=e.indexable,_allKeys:n=e.allKeys}=t;return{allKeys:n,scriptable:i,indexable:s,isScriptable:isFunction(i)?i:()=>i,isIndexable:isFunction(s)?s:()=>s}}const readKey=(t,e)=>t?t+_capitalize(e):e,needsSubResolver=(t,e)=>isObject(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function _cached(t,e,i){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const s=i();return t[e]=s,s}function _resolveWithContext(t,e,i){const{_proxy:s,_context:n,_subProxy:o,_descriptors:a}=t;let r=s[e];return isFunction(r)&&a.isScriptable(e)&&(r=_resolveScriptable(e,r,t,i)),isArray(r)&&r.length&&(r=_resolveArray(e,r,t,a.isIndexable)),needsSubResolver(e,r)&&(r=_attachContext(r,n,o&&o[e],a)),r}function _resolveScriptable(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_stack:r}=i;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);return r.add(t),e=e(o,a||s),r.delete(t),needsSubResolver(t,e)&&(e=createSubResolver(n._scopes,n,t,e)),e}function _resolveArray(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_descriptors:r}=i;if(defined(o.index)&&s(t))e=e[o.index%e.length];else if(isObject(e[0])){const i=e,s=n._scopes.filter((t=>t!==i));e=[];for(const l of i){const i=createSubResolver(s,n,t,l);e.push(_attachContext(i,o,a&&a[t],r))}}return e}function resolveFallback(t,e,i){return isFunction(t)?t(e,i):t}const getScope=(t,e)=>!0===t?e:"string"==typeof t?resolveObjectKey(e,t):void 0;function addScopes(t,e,i,s,n){for(const o of e){const e=getScope(i,o);if(e){t.add(e);const o=resolveFallback(e._fallback,i,n);if(defined(o)&&o!==i&&o!==s)return o}else if(!1===e&&defined(s)&&i!==s)return null}return!1}function createSubResolver(t,e,i,s){const n=e._rootScopes,o=resolveFallback(e._fallback,i,s),a=[...t,...n],r=new Set;r.add(s);let l=addScopesFromKey(r,a,i,o||i,s);return null!==l&&((!defined(o)||o===i||(l=addScopesFromKey(r,a,o,l,s),null!==l))&&_createResolver(Array.from(r),[""],n,o,(()=>subGetTarget(e,i,s))))}function addScopesFromKey(t,e,i,s,n){for(;i;)i=addScopes(t,e,i,s,n);return i}function subGetTarget(t,e,i){const s=t._getTarget();e in s||(s[e]={});const n=s[e];return isArray(n)&&isObject(i)?i:n||{}}function _resolveWithPrefixes(t,e,i,s){let n;for(const o of e)if(n=_resolve(readKey(o,t),i),defined(n))return needsSubResolver(t,n)?createSubResolver(i,s,t,n):n}function _resolve(t,e){for(const i of e){if(!i)continue;const e=i[t];if(defined(e))return e}}function getKeysFromAllScopes(t){let e=t._keys;return e||(e=t._keys=resolveKeysFromAllScopes(t._scopes)),e}function resolveKeysFromAllScopes(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter((t=>!t.startsWith("_"))))e.add(t);return Array.from(e)}function _parseObjectDataRadialScale(t,e,i,s){const{iScale:n}=t,{key:o="r"}=this._parsing,a=new Array(s);let r,l,h,c;for(r=0,l=s;r<l;++r)h=r+i,c=e[h],a[r]={r:n.parse(resolveObjectKey(c,o),h)};return a}const EPSILON=Number.EPSILON||1e-14,getPoint=(t,e)=>e<t.length&&!t[e].skip&&t[e],getValueAxis=t=>"x"===t?"y":"x";function splineCurve(t,e,i,s){const n=t.skip?e:t,o=e,a=i.skip?e:i,r=distanceBetweenPoints(o,n),l=distanceBetweenPoints(a,o);let h=r/(r+l),c=l/(r+l);h=isNaN(h)?0:h,c=isNaN(c)?0:c;const d=s*h,u=s*c;return{previous:{x:o.x-d*(a.x-n.x),y:o.y-d*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function monotoneAdjust(t,e,i){const s=t.length;let n,o,a,r,l,h=getPoint(t,0);for(let c=0;c<s-1;++c)l=h,h=getPoint(t,c+1),l&&h&&(almostEquals(e[c],0,EPSILON)?i[c]=i[c+1]=0:(n=i[c]/e[c],o=i[c+1]/e[c],r=Math.pow(n,2)+Math.pow(o,2),r<=9||(a=3/Math.sqrt(r),i[c]=n*a*e[c],i[c+1]=o*a*e[c])))}function monotoneCompute(t,e,i="x"){const s=getValueAxis(i),n=t.length;let o,a,r,l=getPoint(t,0);for(let h=0;h<n;++h){if(a=r,r=l,l=getPoint(t,h+1),!r)continue;const n=r[i],c=r[s];a&&(o=(n-a[i])/3,r[`cp1${i}`]=n-o,r[`cp1${s}`]=c-o*e[h]),l&&(o=(l[i]-n)/3,r[`cp2${i}`]=n+o,r[`cp2${s}`]=c+o*e[h])}}function splineCurveMonotone(t,e="x"){const i=getValueAxis(e),s=t.length,n=Array(s).fill(0),o=Array(s);let a,r,l,h=getPoint(t,0);for(a=0;a<s;++a)if(r=l,l=h,h=getPoint(t,a+1),l){if(h){const t=h[e]-l[e];n[a]=0!==t?(h[i]-l[i])/t:0}o[a]=r?h?sign(n[a-1])!==sign(n[a])?0:(n[a-1]+n[a])/2:n[a-1]:n[a]}monotoneAdjust(t,n,o),monotoneCompute(t,o,e)}function capControlPoint(t,e,i){return Math.max(Math.min(t,i),e)}function capBezierPoints(t,e){let i,s,n,o,a,r=_isPointInArea(t[0],e);for(i=0,s=t.length;i<s;++i)a=o,o=r,r=i<s-1&&_isPointInArea(t[i+1],e),o&&(n=t[i],a&&(n.cp1x=capControlPoint(n.cp1x,e.left,e.right),n.cp1y=capControlPoint(n.cp1y,e.top,e.bottom)),r&&(n.cp2x=capControlPoint(n.cp2x,e.left,e.right),n.cp2y=capControlPoint(n.cp2y,e.top,e.bottom)))}function _updateBezierControlPoints(t,e,i,s,n){let o,a,r,l;if(e.spanGaps&&(t=t.filter((t=>!t.skip))),"monotone"===e.cubicInterpolationMode)splineCurveMonotone(t,n);else{let i=s?t[t.length-1]:t[0];for(o=0,a=t.length;o<a;++o)r=t[o],l=splineCurve(i,r,t[Math.min(o+1,a-(s?0:1))%a],e.tension),r.cp1x=l.previous.x,r.cp1y=l.previous.y,r.cp2x=l.next.x,r.cp2y=l.next.y,i=r}e.capBezierPoints&&capBezierPoints(t,i)}function _isDomSupported(){return"undefined"!=typeof window&&"undefined"!=typeof document}function _getParentNode(t){let e=t.parentNode;return e&&"[object ShadowRoot]"===e.toString()&&(e=e.host),e}function parseMaxStyle(t,e,i){let s;return"string"==typeof t?(s=parseInt(t,10),-1!==t.indexOf("%")&&(s=s/100*e.parentNode[i])):s=t,s}const getComputedStyle=t=>t.ownerDocument.defaultView.getComputedStyle(t,null);function getStyle(t,e){return getComputedStyle(t).getPropertyValue(e)}const positions=["top","right","bottom","left"];function getPositionedStyle(t,e,i){const s={};i=i?"-"+i:"";for(let n=0;n<4;n++){const o=positions[n];s[o]=parseFloat(t[e+"-"+o+i])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}const useOffsetPos=(t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot);function getCanvasPosition(t,e){const i=t.touches,s=i&&i.length?i[0]:t,{offsetX:n,offsetY:o}=s;let a,r,l=!1;if(useOffsetPos(n,o,t.target))a=n,r=o;else{const t=e.getBoundingClientRect();a=s.clientX-t.left,r=s.clientY-t.top,l=!0}return{x:a,y:r,box:l}}function getRelativePosition(t,e){if("native"in t)return t;const{canvas:i,currentDevicePixelRatio:s}=e,n=getComputedStyle(i),o="border-box"===n.boxSizing,a=getPositionedStyle(n,"padding"),r=getPositionedStyle(n,"border","width"),{x:l,y:h,box:c}=getCanvasPosition(t,i),d=a.left+(c&&r.left),u=a.top+(c&&r.top);let{width:g,height:f}=e;return o&&(g-=a.width+r.width,f-=a.height+r.height),{x:Math.round((l-d)/g*i.width/s),y:Math.round((h-u)/f*i.height/s)}}function getContainerSize(t,e,i){let s,n;if(void 0===e||void 0===i){const o=_getParentNode(t);if(o){const t=o.getBoundingClientRect(),a=getComputedStyle(o),r=getPositionedStyle(a,"border","width"),l=getPositionedStyle(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,s=parseMaxStyle(a.maxWidth,o,"clientWidth"),n=parseMaxStyle(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:s||INFINITY,maxHeight:n||INFINITY}}const round1=t=>Math.round(10*t)/10;function getMaximumSize(t,e,i,s){const n=getComputedStyle(t),o=getPositionedStyle(n,"margin"),a=parseMaxStyle(n.maxWidth,t,"clientWidth")||INFINITY,r=parseMaxStyle(n.maxHeight,t,"clientHeight")||INFINITY,l=getContainerSize(t,e,i);let{width:h,height:c}=l;if("content-box"===n.boxSizing){const t=getPositionedStyle(n,"border","width"),e=getPositionedStyle(n,"padding");h-=e.width+t.width,c-=e.height+t.height}h=Math.max(0,h-o.width),c=Math.max(0,s?h/s:c-o.height),h=round1(Math.min(h,a,l.maxWidth)),c=round1(Math.min(c,r,l.maxHeight)),h&&!c&&(c=round1(h/2));return(void 0!==e||void 0!==i)&&s&&l.height&&c>l.height&&(c=l.height,h=round1(Math.floor(c*s))),{width:h,height:c}}function retinaScale(t,e,i){const s=e||1,n=Math.floor(t.height*s),o=Math.floor(t.width*s);t.height=Math.floor(t.height),t.width=Math.floor(t.width);const a=t.canvas;return a.style&&(i||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(t.currentDevicePixelRatio=s,a.height=n,a.width=o,t.ctx.setTransform(s,0,0,s,0,0),!0)}const supportsEventListenerOptions=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function readUsedSize(t,e){const i=getStyle(t,e),s=i&&i.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function _pointInLine(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function _steppedInterpolation(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:"middle"===s?i<.5?t.y:e.y:"after"===s?i<1?t.y:e.y:i>0?e.y:t.y}}function _bezierInterpolation(t,e,i,s){const n={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=_pointInLine(t,n,i),r=_pointInLine(n,o,i),l=_pointInLine(o,e,i),h=_pointInLine(a,r,i),c=_pointInLine(r,l,i);return _pointInLine(h,c,i)}const getRightToLeftAdapter=function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}},getLeftToRightAdapter=function(){return{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}};function getRtlAdapter(t,e,i){return t?getRightToLeftAdapter(e,i):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function overrideTextDirection(t,e){let i,s;"ltr"!==e&&"rtl"!==e||(i=t.canvas.style,s=[i.getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=s)}function restoreTextDirection(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function propertyFn(t){return"angle"===t?{between:_angleBetween,compare:_angleDiff,normalize:_normalizeAngle}:{between:_isBetween,compare:(t,e)=>t-e,normalize:t=>t}}function normalizeSegment({start:t,end:e,count:i,loop:s,style:n}){return{start:t%i,end:e%i,loop:s&&(e-t+1)%i==0,style:n}}function getSegment(t,e,i){const{property:s,start:n,end:o}=i,{between:a,normalize:r}=propertyFn(s),l=e.length;let h,c,{start:d,end:u,loop:g}=t;if(g){for(d+=l,u+=l,h=0,c=l;h<c&&a(r(e[d%l][s]),n,o);++h)d--,u--;d%=l,u%=l}return u<d&&(u+=l),{start:d,end:u,loop:g,style:t.style}}function _boundSegment(t,e,i){if(!i)return[t];const{property:s,start:n,end:o}=i,a=e.length,{compare:r,between:l,normalize:h}=propertyFn(s),{start:c,end:d,loop:u,style:g}=getSegment(t,e,i),f=[];let p,m,b,x=!1,_=null;const y=()=>x||l(n,b,p)&&0!==r(n,b),v=()=>!x||0===r(o,p)||l(o,b,p);for(let t=c,i=c;t<=d;++t)m=e[t%a],m.skip||(p=h(m[s]),p!==b&&(x=l(p,n,o),null===_&&y()&&(_=0===r(p,n)?t:i),null!==_&&v()&&(f.push(normalizeSegment({start:_,end:t,loop:u,count:a,style:g})),_=null),i=t,b=p));return null!==_&&f.push(normalizeSegment({start:_,end:d,loop:u,count:a,style:g})),f}function _boundSegments(t,e){const i=[],s=t.segments;for(let n=0;n<s.length;n++){const o=_boundSegment(s[n],t.points,e);o.length&&i.push(...o)}return i}function findStartAndEnd(t,e,i,s){let n=0,o=e-1;if(i&&!s)for(;n<e&&!t[n].skip;)n++;for(;n<e&&t[n].skip;)n++;for(n%=e,i&&(o+=n);o>n&&t[o%e].skip;)o--;return o%=e,{start:n,end:o}}function solidSegments(t,e,i,s){const n=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%n];i.skip||i.stop?l.skip||(s=!1,o.push({start:e%n,end:(a-1)%n,loop:s}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&o.push({start:e%n,end:r%n,loop:s}),o}function _computeSegments(t,e){const i=t.points,s=t.options.spanGaps,n=i.length;if(!n)return[];const o=!!t._loop,{start:a,end:r}=findStartAndEnd(i,n,o,s);if(!0===s)return splitByStyles(t,[{start:a,end:r,loop:o}],i,e);return splitByStyles(t,solidSegments(i,a,r<a?r+n:r,!!t._fullLoop&&0===a&&r===n-1),i,e)}function splitByStyles(t,e,i,s){return s&&s.setContext&&i?doSplitByStyles(t,e,i,s):e}function doSplitByStyles(t,e,i,s){const n=t._chart.getContext(),o=readStyle(t.options),{_datasetIndex:a,options:{spanGaps:r}}=t,l=i.length,h=[];let c=o,d=e[0].start,u=d;function g(t,e,s,n){const o=r?-1:1;if(t!==e){for(t+=l;i[t%l].skip;)t-=o;for(;i[e%l].skip;)e+=o;t%l!=e%l&&(h.push({start:t%l,end:e%l,loop:s,style:n}),c=n,d=e%l)}}for(const t of e){d=r?d:t.start;let e,o=i[d%l];for(u=d+1;u<=t.end;u++){const r=i[u%l];e=readStyle(s.setContext(createContext(n,{type:"segment",p0:o,p1:r,p0DataIndex:(u-1)%l,p1DataIndex:u%l,datasetIndex:a}))),styleChanged(e,c)&&g(d,u-1,t.loop,c),o=r,c=e}d<u-1&&g(d,u-1,t.loop,c)}return h}function readStyle(t){return{backgroundColor:t.backgroundColor,borderCapStyle:t.borderCapStyle,borderDash:t.borderDash,borderDashOffset:t.borderDashOffset,borderJoinStyle:t.borderJoinStyle,borderWidth:t.borderWidth,borderColor:t.borderColor}}function styleChanged(t,e){return e&&JSON.stringify(t)!==JSON.stringify(e)} + */function noop(){}const uid=(()=>{let t=0;return()=>t++})();function isNullOrUndef(t){return null==t}function isArray(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.slice(0,7)&&"Array]"===e.slice(-6)}function isObject(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}function isNumberFinite(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)}function finiteOrDefault(t,e){return isNumberFinite(t)?t:e}function valueOrDefault(t,e){return void 0===t?e:t}const toPercentage=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:+t/e,toDimension=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function callback(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function each(t,e,i,s){let n,o,a;if(isArray(t))if(o=t.length,s)for(n=o-1;n>=0;n--)e.call(i,t[n],n);else for(n=0;n<o;n++)e.call(i,t[n],n);else if(isObject(t))for(a=Object.keys(t),o=a.length,n=0;n<o;n++)e.call(i,t[a[n]],a[n])}function _elementsEqual(t,e){let i,s,n,o;if(!t||!e||t.length!==e.length)return!1;for(i=0,s=t.length;i<s;++i)if(n=t[i],o=e[i],n.datasetIndex!==o.datasetIndex||n.index!==o.index)return!1;return!0}function clone(t){if(isArray(t))return t.map(clone);if(isObject(t)){const e=Object.create(null),i=Object.keys(t),s=i.length;let n=0;for(;n<s;++n)e[i[n]]=clone(t[i[n]]);return e}return t}function isValidKey(t){return-1===["__proto__","prototype","constructor"].indexOf(t)}function _merger(t,e,i,s){if(!isValidKey(t))return;const n=e[t],o=i[t];isObject(n)&&isObject(o)?merge(n,o,s):e[t]=clone(o)}function merge(t,e,i){const s=isArray(e)?e:[e],n=s.length;if(!isObject(t))return t;const o=(i=i||{}).merger||_merger;let a;for(let e=0;e<n;++e){if(a=s[e],!isObject(a))continue;const n=Object.keys(a);for(let e=0,s=n.length;e<s;++e)o(n[e],t,a,i)}return t}function mergeIf(t,e){return merge(t,e,{merger:_mergerIf})}function _mergerIf(t,e,i){if(!isValidKey(t))return;const s=e[t],n=i[t];isObject(s)&&isObject(n)?mergeIf(s,n):Object.prototype.hasOwnProperty.call(e,t)||(e[t]=clone(n))}const keyResolvers={"":t=>t,x:t=>t.x,y:t=>t.y};function _splitKey(t){const e=t.split("."),i=[];let s="";for(const t of e)s+=t,s.endsWith("\\")?s=s.slice(0,-1)+".":(i.push(s),s="");return i}function _getKeyResolver(t){const e=_splitKey(t);return t=>{for(const i of e){if(""===i)break;t=t&&t[i]}return t}}function resolveObjectKey(t,e){return(keyResolvers[e]||(keyResolvers[e]=_getKeyResolver(e)))(t)}function _capitalize(t){return t.charAt(0).toUpperCase()+t.slice(1)}const defined=t=>void 0!==t,isFunction=t=>"function"==typeof t,setsEqual=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0};function _isClickEvent(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}const PI=Math.PI,TAU=2*PI,PITAU=TAU+PI,INFINITY=Number.POSITIVE_INFINITY,RAD_PER_DEG=PI/180,HALF_PI=PI/2,QUARTER_PI=PI/4,TWO_THIRDS_PI=2*PI/3,log10=Math.log10,sign=Math.sign;function almostEquals(t,e,i){return Math.abs(t-e)<i}function niceNum(t){const e=Math.round(t);t=almostEquals(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(log10(t))),s=t/i;return(s<=1?1:s<=2?2:s<=5?5:10)*i}function _factorize(t){const e=[],i=Math.sqrt(t);let s;for(s=1;s<i;s++)t%s==0&&(e.push(s),e.push(t/s));return i===(0|i)&&e.push(i),e.sort(((t,e)=>t-e)).pop(),e}function isNumber(t){return!isNaN(parseFloat(t))&&isFinite(t)}function almostWhole(t,e){const i=Math.round(t);return i-e<=t&&i+e>=t}function _setMinAndMaxByKey(t,e,i){let s,n,o;for(s=0,n=t.length;s<n;s++)o=t[s][i],isNaN(o)||(e.min=Math.min(e.min,o),e.max=Math.max(e.max,o))}function toRadians(t){return t*(PI/180)}function toDegrees(t){return t*(180/PI)}function _decimalPlaces(t){if(!isNumberFinite(t))return;let e=1,i=0;for(;Math.round(t*e)/e!==t;)e*=10,i++;return i}function getAngleFromPoint(t,e){const i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s);let o=Math.atan2(s,i);return o<-.5*PI&&(o+=TAU),{angle:o,distance:n}}function distanceBetweenPoints(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function _angleDiff(t,e){return(t-e+PITAU)%TAU-PI}function _normalizeAngle(t){return(t%TAU+TAU)%TAU}function _angleBetween(t,e,i,s){const n=_normalizeAngle(t),o=_normalizeAngle(e),a=_normalizeAngle(i),r=_normalizeAngle(o-n),l=_normalizeAngle(a-n),h=_normalizeAngle(n-o),c=_normalizeAngle(n-a);return n===o||n===a||s&&o===a||r>l&&h<c}function _limitValue(t,e,i){return Math.max(e,Math.min(i,t))}function _int16Range(t){return _limitValue(t,-32768,32767)}function _isBetween(t,e,i,s=1e-6){return t>=Math.min(e,i)-s&&t<=Math.max(e,i)+s}function _lookup(t,e,i){i=i||(i=>t[i]<e);let s,n=t.length-1,o=0;for(;n-o>1;)s=o+n>>1,i(s)?o=s:n=s;return{lo:o,hi:n}}const _lookupByKey=(t,e,i,s)=>_lookup(t,i,s?s=>{const n=t[s][e];return n<i||n===i&&t[s+1][e]===i}:s=>t[s][e]<i),_rlookupByKey=(t,e,i)=>_lookup(t,i,(s=>t[s][e]>=i));function _filterBetween(t,e,i){let s=0,n=t.length;for(;s<n&&t[s]<e;)s++;for(;n>s&&t[n-1]>i;)n--;return s>0||n<t.length?t.slice(s,n):t}const arrayEvents=["push","pop","shift","splice","unshift"];function listenArrayEvents(t,e){t._chartjs?t._chartjs.listeners.push(e):(Object.defineProperty(t,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[e]}}),arrayEvents.forEach((e=>{const i="_onData"+_capitalize(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const n=s.apply(this,e);return t._chartjs.listeners.forEach((t=>{"function"==typeof t[i]&&t[i](...e)})),n}})})))}function unlistenArrayEvents(t,e){const i=t._chartjs;if(!i)return;const s=i.listeners,n=s.indexOf(e);-1!==n&&s.splice(n,1),s.length>0||(arrayEvents.forEach((e=>{delete t[e]})),delete t._chartjs)}function _arrayUnique(t){const e=new Set;let i,s;for(i=0,s=t.length;i<s;++i)e.add(t[i]);return e.size===s?t:Array.from(e)}const requestAnimFrame="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function throttled(t,e){let i=[],s=!1;return function(...n){i=n,s||(s=!0,requestAnimFrame.call(window,(()=>{s=!1,t.apply(e,i)})))}}function debounce(t,e){let i;return function(...s){return e?(clearTimeout(i),i=setTimeout(t,e,s)):t.apply(this,s),e}}const _toLeftRightCenter=t=>"start"===t?"left":"end"===t?"right":"center",_alignStartEnd=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2,_textX=(t,e,i,s)=>t===(s?"left":"right")?i:"center"===t?(e+i)/2:e;function _getStartAndCountOfVisiblePoints(t,e,i){const s=e.length;let n=0,o=s;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:h,max:c,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(n=_limitValue(Math.min(_lookupByKey(r,a.axis,h).lo,i?s:_lookupByKey(e,l,a.getPixelForValue(h)).lo),0,s-1)),o=u?_limitValue(Math.max(_lookupByKey(r,a.axis,c,!0).hi+1,i?0:_lookupByKey(e,l,a.getPixelForValue(c),!0).hi+1),n,s)-n:s-n}return{start:n,count:o}}function _scaleRangesChanged(t){const{xScale:e,yScale:i,_scaleRanges:s}=t,n={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!s)return t._scaleRanges=n,!0;const o=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==i.min||s.ymax!==i.max;return Object.assign(s,n),o}const atEdge=t=>0===t||1===t,elasticIn=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*TAU/i),elasticOut=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*TAU/i)+1,effects={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*HALF_PI),easeOutSine:t=>Math.sin(t*HALF_PI),easeInOutSine:t=>-.5*(Math.cos(PI*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>atEdge(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>atEdge(t)?t:elasticIn(t,.075,.3),easeOutElastic:t=>atEdge(t)?t:elasticOut(t,.075,.3),easeInOutElastic(t){const e=.1125;return atEdge(t)?t:t<.5?.5*elasticIn(2*t,e,.45):.5+.5*elasticOut(2*t-1,e,.45)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-effects.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*effects.easeInBounce(2*t):.5*effects.easeOutBounce(2*t-1)+.5};function isPatternOrGradient(t){if(t&&"object"==typeof t){const e=t.toString();return"[object CanvasPattern]"===e||"[object CanvasGradient]"===e}return!1}function color(t){return isPatternOrGradient(t)?t:new Color(t)}function getHoverColor(t){return isPatternOrGradient(t)?t:new Color(t).saturate(.5).darken(.1).hexString()}const numbers=["x","y","borderWidth","radius","tension"],colors=["color","borderColor","backgroundColor"];function applyAnimationsDefaults(t){t.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),t.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),t.set("animations",{colors:{type:"color",properties:colors},numbers:{type:"number",properties:numbers}}),t.describe("animations",{_fallback:"animation"}),t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}})}function applyLayoutsDefaults(t){t.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const intlCache=new Map;function getNumberFormat(t,e){e=e||{};const i=t+JSON.stringify(e);let s=intlCache.get(i);return s||(s=new Intl.NumberFormat(t,e),intlCache.set(i,s)),s}function formatNumber(t,e,i){return getNumberFormat(e,i).format(t)}const formatters={values:t=>isArray(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const s=this.chart.options.locale;let n,o=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(n="scientific"),o=calculateDelta(t,i)}const a=log10(Math.abs(o)),r=Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),formatNumber(t,s,l)},logarithmic(t,e,i){if(0===t)return"0";const s=i[e].significand||t/Math.pow(10,Math.floor(log10(t)));return[1,2,3,5,10,15].includes(s)||e>.8*i.length?formatters.numeric.call(this,t,e,i):""}};function calculateDelta(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;return Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t)),i}var Ticks={formatters};function applyScaleDefaults(t){t.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Ticks.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),t.route("scale.ticks","color","","color"),t.route("scale.grid","color","","borderColor"),t.route("scale.border","color","","borderColor"),t.route("scale.title","color","","color"),t.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t&&"dash"!==t}),t.describe("scales",{_fallback:"scale"}),t.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t})}const overrides=Object.create(null),descriptors=Object.create(null);function getScope$1(t,e){if(!e)return t;const i=e.split(".");for(let e=0,s=i.length;e<s;++e){const s=i[e];t=t[s]||(t[s]=Object.create(null))}return t}function set(t,e,i){return"string"==typeof e?merge(getScope$1(t,e),i):merge(getScope$1(t,""),e)}class Defaults{constructor(t,e){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=t=>t.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(t,e)=>getHoverColor(e.backgroundColor),this.hoverBorderColor=(t,e)=>getHoverColor(e.borderColor),this.hoverColor=(t,e)=>getHoverColor(e.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return set(this,t,e)}get(t){return getScope$1(this,t)}describe(t,e){return set(descriptors,t,e)}override(t,e){return set(overrides,t,e)}route(t,e,i,s){const n=getScope$1(this,t),o=getScope$1(this,i),a="_"+e;Object.defineProperties(n,{[a]:{value:n[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=o[s];return isObject(t)?Object.assign({},e,t):valueOrDefault(t,e)},set(t){this[a]=t}}})}apply(t){t.forEach((t=>t(this)))}}var defaults=new Defaults({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[applyAnimationsDefaults,applyLayoutsDefaults,applyScaleDefaults]);function toFontString(t){return!t||isNullOrUndef(t.size)||isNullOrUndef(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}function _measureText(t,e,i,s,n){let o=e[n];return o||(o=e[n]=t.measureText(n).width,i.push(n)),o>s&&(s=o),s}function _longestText(t,e,i,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==e&&(n=s.data={},o=s.garbageCollect=[],s.font=e),t.save(),t.font=e;let a=0;const r=i.length;let l,h,c,d,u;for(l=0;l<r;l++)if(d=i[l],null!=d&&!0!==isArray(d))a=_measureText(t,n,o,a,d);else if(isArray(d))for(h=0,c=d.length;h<c;h++)u=d[h],null==u||isArray(u)||(a=_measureText(t,n,o,a,u));t.restore();const g=o.length/2;if(g>i.length){for(l=0;l<g;l++)delete n[o[l]];o.splice(0,g)}return a}function _alignPixel(t,e,i){const s=t.currentDevicePixelRatio,n=0!==i?Math.max(i/2,.5):0;return Math.round((e-n)*s)/s+n}function clearCanvas(t,e){(e=e||t.getContext("2d")).save(),e.resetTransform(),e.clearRect(0,0,t.width,t.height),e.restore()}function drawPoint(t,e,i,s){drawPointLegend(t,e,i,s,null)}function drawPointLegend(t,e,i,s,n){let o,a,r,l,h,c,d,u;const g=e.pointStyle,f=e.rotation,p=e.radius;let m=(f||0)*RAD_PER_DEG;if(g&&"object"==typeof g&&(o=g.toString(),"[object HTMLImageElement]"===o||"[object HTMLCanvasElement]"===o))return t.save(),t.translate(i,s),t.rotate(m),t.drawImage(g,-g.width/2,-g.height/2,g.width,g.height),void t.restore();if(!(isNaN(p)||p<=0)){switch(t.beginPath(),g){default:n?t.ellipse(i,s,n/2,p,0,0,TAU):t.arc(i,s,p,0,TAU),t.closePath();break;case"triangle":c=n?n/2:p,t.moveTo(i+Math.sin(m)*c,s-Math.cos(m)*p),m+=TWO_THIRDS_PI,t.lineTo(i+Math.sin(m)*c,s-Math.cos(m)*p),m+=TWO_THIRDS_PI,t.lineTo(i+Math.sin(m)*c,s-Math.cos(m)*p),t.closePath();break;case"rectRounded":h=.516*p,l=p-h,a=Math.cos(m+QUARTER_PI)*l,d=Math.cos(m+QUARTER_PI)*(n?n/2-h:l),r=Math.sin(m+QUARTER_PI)*l,u=Math.sin(m+QUARTER_PI)*(n?n/2-h:l),t.arc(i-d,s-r,h,m-PI,m-HALF_PI),t.arc(i+u,s-a,h,m-HALF_PI,m),t.arc(i+d,s+r,h,m,m+HALF_PI),t.arc(i-u,s+a,h,m+HALF_PI,m+PI),t.closePath();break;case"rect":if(!f){l=Math.SQRT1_2*p,c=n?n/2:l,t.rect(i-c,s-l,2*c,2*l);break}m+=QUARTER_PI;case"rectRot":d=Math.cos(m)*(n?n/2:p),a=Math.cos(m)*p,r=Math.sin(m)*p,u=Math.sin(m)*(n?n/2:p),t.moveTo(i-d,s-r),t.lineTo(i+u,s-a),t.lineTo(i+d,s+r),t.lineTo(i-u,s+a),t.closePath();break;case"crossRot":m+=QUARTER_PI;case"cross":d=Math.cos(m)*(n?n/2:p),a=Math.cos(m)*p,r=Math.sin(m)*p,u=Math.sin(m)*(n?n/2:p),t.moveTo(i-d,s-r),t.lineTo(i+d,s+r),t.moveTo(i+u,s-a),t.lineTo(i-u,s+a);break;case"star":d=Math.cos(m)*(n?n/2:p),a=Math.cos(m)*p,r=Math.sin(m)*p,u=Math.sin(m)*(n?n/2:p),t.moveTo(i-d,s-r),t.lineTo(i+d,s+r),t.moveTo(i+u,s-a),t.lineTo(i-u,s+a),m+=QUARTER_PI,d=Math.cos(m)*(n?n/2:p),a=Math.cos(m)*p,r=Math.sin(m)*p,u=Math.sin(m)*(n?n/2:p),t.moveTo(i-d,s-r),t.lineTo(i+d,s+r),t.moveTo(i+u,s-a),t.lineTo(i-u,s+a);break;case"line":a=n?n/2:Math.cos(m)*p,r=Math.sin(m)*p,t.moveTo(i-a,s-r),t.lineTo(i+a,s+r);break;case"dash":t.moveTo(i,s),t.lineTo(i+Math.cos(m)*(n?n/2:p),s+Math.sin(m)*p);break;case!1:t.closePath()}t.fill(),e.borderWidth>0&&t.stroke()}}function _isPointInArea(t,e,i){return i=i||.5,!e||t&&t.x>e.left-i&&t.x<e.right+i&&t.y>e.top-i&&t.y<e.bottom+i}function clipArea(t,e){t.save(),t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.clip()}function unclipArea(t){t.restore()}function _steppedLineTo(t,e,i,s,n){if(!e)return t.lineTo(i.x,i.y);if("middle"===n){const s=(e.x+i.x)/2;t.lineTo(s,e.y),t.lineTo(s,i.y)}else"after"===n!=!!s?t.lineTo(e.x,i.y):t.lineTo(i.x,e.y);t.lineTo(i.x,i.y)}function _bezierCurveTo(t,e,i,s){if(!e)return t.lineTo(i.x,i.y);t.bezierCurveTo(s?e.cp1x:e.cp2x,s?e.cp1y:e.cp2y,s?i.cp2x:i.cp1x,s?i.cp2y:i.cp1y,i.x,i.y)}function renderText(t,e,i,s,n,o={}){const a=isArray(e)?e:[e],r=o.strokeWidth>0&&""!==o.strokeColor;let l,h;for(t.save(),t.font=n.string,setRenderOpts(t,o),l=0;l<a.length;++l)h=a[l],o.backdrop&&drawBackdrop(t,o.backdrop),r&&(o.strokeColor&&(t.strokeStyle=o.strokeColor),isNullOrUndef(o.strokeWidth)||(t.lineWidth=o.strokeWidth),t.strokeText(h,i,s,o.maxWidth)),t.fillText(h,i,s,o.maxWidth),decorateText(t,i,s,h,o),s+=n.lineHeight;t.restore()}function setRenderOpts(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]),isNullOrUndef(e.rotation)||t.rotate(e.rotation),e.color&&(t.fillStyle=e.color),e.textAlign&&(t.textAlign=e.textAlign),e.textBaseline&&(t.textBaseline=e.textBaseline)}function decorateText(t,e,i,s,n){if(n.strikethrough||n.underline){const o=t.measureText(s),a=e-o.actualBoundingBoxLeft,r=e+o.actualBoundingBoxRight,l=i-o.actualBoundingBoxAscent,h=i+o.actualBoundingBoxDescent,c=n.strikethrough?(l+h)/2:h;t.strokeStyle=t.fillStyle,t.beginPath(),t.lineWidth=n.decorationWidth||2,t.moveTo(a,c),t.lineTo(r,c),t.stroke()}}function drawBackdrop(t,e){const i=t.fillStyle;t.fillStyle=e.color,t.fillRect(e.left,e.top,e.width,e.height),t.fillStyle=i}function addRoundedRectPath(t,e){const{x:i,y:s,w:n,h:o,radius:a}=e;t.arc(i+a.topLeft,s+a.topLeft,a.topLeft,-HALF_PI,PI,!0),t.lineTo(i,s+o-a.bottomLeft),t.arc(i+a.bottomLeft,s+o-a.bottomLeft,a.bottomLeft,PI,HALF_PI,!0),t.lineTo(i+n-a.bottomRight,s+o),t.arc(i+n-a.bottomRight,s+o-a.bottomRight,a.bottomRight,HALF_PI,0,!0),t.lineTo(i+n,s+a.topRight),t.arc(i+n-a.topRight,s+a.topRight,a.topRight,0,-HALF_PI,!0),t.lineTo(i+a.topLeft,s)}const LINE_HEIGHT=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,FONT_STYLE=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function toLineHeight(t,e){const i=(""+t).match(LINE_HEIGHT);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}const numberOrZero=t=>+t||0;function _readValueToProps(t,e){const i={},s=isObject(e),n=s?Object.keys(e):e,o=isObject(t)?s?i=>valueOrDefault(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of n)i[t]=numberOrZero(o(t));return i}function toTRBL(t){return _readValueToProps(t,{top:"y",right:"x",bottom:"y",left:"x"})}function toTRBLCorners(t){return _readValueToProps(t,["topLeft","topRight","bottomLeft","bottomRight"])}function toPadding(t){const e=toTRBL(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function toFont(t,e){t=t||{},e=e||defaults.font;let i=valueOrDefault(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let s=valueOrDefault(t.style,e.style);s&&!(""+s).match(FONT_STYLE)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);const n={family:valueOrDefault(t.family,e.family),lineHeight:toLineHeight(valueOrDefault(t.lineHeight,e.lineHeight),i),size:i,style:s,weight:valueOrDefault(t.weight,e.weight),string:""};return n.string=toFontString(n),n}function resolve(t,e,i,s){let n,o,a,r=!0;for(n=0,o=t.length;n<o;++n)if(a=t[n],void 0!==a&&(void 0!==e&&"function"==typeof a&&(a=a(e),r=!1),void 0!==i&&isArray(a)&&(a=a[i%a.length],r=!1),void 0!==a))return s&&!r&&(s.cacheable=!1),a}function _addGrace(t,e,i){const{min:s,max:n}=t,o=toDimension(e,(n-s)/2),a=(t,e)=>i&&0===t?0:t+e;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function createContext(t,e){return Object.assign(Object.create(t),e)}function _createResolver(t,e=[""],i=t,s,n=(()=>t[0])){defined(s)||(s=_resolve("_fallback",t));const o={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:s,_getTarget:n,override:n=>_createResolver([n,...t],e,i,s)};return new Proxy(o,{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,s)=>_cached(i,s,(()=>_resolveWithPrefixes(s,e,t,i))),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>getKeysFromAllScopes(t).includes(e),ownKeys:t=>getKeysFromAllScopes(t),set(t,e,i){const s=t._storage||(t._storage=n());return t[e]=s[e]=i,delete t._keys,!0}})}function _attachContext(t,e,i,s){const n={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:_descriptors(t,s),setContext:e=>_attachContext(t,e,i,s),override:n=>_attachContext(t.override(n),e,i,s)};return new Proxy(n,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>_cached(t,e,(()=>_resolveWithContext(t,e,i))),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,s)=>(t[i]=s,delete e[i],!0)})}function _descriptors(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:s=e.indexable,_allKeys:n=e.allKeys}=t;return{allKeys:n,scriptable:i,indexable:s,isScriptable:isFunction(i)?i:()=>i,isIndexable:isFunction(s)?s:()=>s}}const readKey=(t,e)=>t?t+_capitalize(e):e,needsSubResolver=(t,e)=>isObject(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function _cached(t,e,i){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const s=i();return t[e]=s,s}function _resolveWithContext(t,e,i){const{_proxy:s,_context:n,_subProxy:o,_descriptors:a}=t;let r=s[e];return isFunction(r)&&a.isScriptable(e)&&(r=_resolveScriptable(e,r,t,i)),isArray(r)&&r.length&&(r=_resolveArray(e,r,t,a.isIndexable)),needsSubResolver(e,r)&&(r=_attachContext(r,n,o&&o[e],a)),r}function _resolveScriptable(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_stack:r}=i;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);return r.add(t),e=e(o,a||s),r.delete(t),needsSubResolver(t,e)&&(e=createSubResolver(n._scopes,n,t,e)),e}function _resolveArray(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_descriptors:r}=i;if(defined(o.index)&&s(t))e=e[o.index%e.length];else if(isObject(e[0])){const i=e,s=n._scopes.filter((t=>t!==i));e=[];for(const l of i){const i=createSubResolver(s,n,t,l);e.push(_attachContext(i,o,a&&a[t],r))}}return e}function resolveFallback(t,e,i){return isFunction(t)?t(e,i):t}const getScope=(t,e)=>!0===t?e:"string"==typeof t?resolveObjectKey(e,t):void 0;function addScopes(t,e,i,s,n){for(const o of e){const e=getScope(i,o);if(e){t.add(e);const o=resolveFallback(e._fallback,i,n);if(defined(o)&&o!==i&&o!==s)return o}else if(!1===e&&defined(s)&&i!==s)return null}return!1}function createSubResolver(t,e,i,s){const n=e._rootScopes,o=resolveFallback(e._fallback,i,s),a=[...t,...n],r=new Set;r.add(s);let l=addScopesFromKey(r,a,i,o||i,s);return null!==l&&((!defined(o)||o===i||(l=addScopesFromKey(r,a,o,l,s),null!==l))&&_createResolver(Array.from(r),[""],n,o,(()=>subGetTarget(e,i,s))))}function addScopesFromKey(t,e,i,s,n){for(;i;)i=addScopes(t,e,i,s,n);return i}function subGetTarget(t,e,i){const s=t._getTarget();e in s||(s[e]={});const n=s[e];return isArray(n)&&isObject(i)?i:n||{}}function _resolveWithPrefixes(t,e,i,s){let n;for(const o of e)if(n=_resolve(readKey(o,t),i),defined(n))return needsSubResolver(t,n)?createSubResolver(i,s,t,n):n}function _resolve(t,e){for(const i of e){if(!i)continue;const e=i[t];if(defined(e))return e}}function getKeysFromAllScopes(t){let e=t._keys;return e||(e=t._keys=resolveKeysFromAllScopes(t._scopes)),e}function resolveKeysFromAllScopes(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter((t=>!t.startsWith("_"))))e.add(t);return Array.from(e)}function _parseObjectDataRadialScale(t,e,i,s){const{iScale:n}=t,{key:o="r"}=this._parsing,a=new Array(s);let r,l,h,c;for(r=0,l=s;r<l;++r)h=r+i,c=e[h],a[r]={r:n.parse(resolveObjectKey(c,o),h)};return a}const EPSILON=Number.EPSILON||1e-14,getPoint=(t,e)=>e<t.length&&!t[e].skip&&t[e],getValueAxis=t=>"x"===t?"y":"x";function splineCurve(t,e,i,s){const n=t.skip?e:t,o=e,a=i.skip?e:i,r=distanceBetweenPoints(o,n),l=distanceBetweenPoints(a,o);let h=r/(r+l),c=l/(r+l);h=isNaN(h)?0:h,c=isNaN(c)?0:c;const d=s*h,u=s*c;return{previous:{x:o.x-d*(a.x-n.x),y:o.y-d*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function monotoneAdjust(t,e,i){const s=t.length;let n,o,a,r,l,h=getPoint(t,0);for(let c=0;c<s-1;++c)l=h,h=getPoint(t,c+1),l&&h&&(almostEquals(e[c],0,EPSILON)?i[c]=i[c+1]=0:(n=i[c]/e[c],o=i[c+1]/e[c],r=Math.pow(n,2)+Math.pow(o,2),r<=9||(a=3/Math.sqrt(r),i[c]=n*a*e[c],i[c+1]=o*a*e[c])))}function monotoneCompute(t,e,i="x"){const s=getValueAxis(i),n=t.length;let o,a,r,l=getPoint(t,0);for(let h=0;h<n;++h){if(a=r,r=l,l=getPoint(t,h+1),!r)continue;const n=r[i],c=r[s];a&&(o=(n-a[i])/3,r[`cp1${i}`]=n-o,r[`cp1${s}`]=c-o*e[h]),l&&(o=(l[i]-n)/3,r[`cp2${i}`]=n+o,r[`cp2${s}`]=c+o*e[h])}}function splineCurveMonotone(t,e="x"){const i=getValueAxis(e),s=t.length,n=Array(s).fill(0),o=Array(s);let a,r,l,h=getPoint(t,0);for(a=0;a<s;++a)if(r=l,l=h,h=getPoint(t,a+1),l){if(h){const t=h[e]-l[e];n[a]=0!==t?(h[i]-l[i])/t:0}o[a]=r?h?sign(n[a-1])!==sign(n[a])?0:(n[a-1]+n[a])/2:n[a-1]:n[a]}monotoneAdjust(t,n,o),monotoneCompute(t,o,e)}function capControlPoint(t,e,i){return Math.max(Math.min(t,i),e)}function capBezierPoints(t,e){let i,s,n,o,a,r=_isPointInArea(t[0],e);for(i=0,s=t.length;i<s;++i)a=o,o=r,r=i<s-1&&_isPointInArea(t[i+1],e),o&&(n=t[i],a&&(n.cp1x=capControlPoint(n.cp1x,e.left,e.right),n.cp1y=capControlPoint(n.cp1y,e.top,e.bottom)),r&&(n.cp2x=capControlPoint(n.cp2x,e.left,e.right),n.cp2y=capControlPoint(n.cp2y,e.top,e.bottom)))}function _updateBezierControlPoints(t,e,i,s,n){let o,a,r,l;if(e.spanGaps&&(t=t.filter((t=>!t.skip))),"monotone"===e.cubicInterpolationMode)splineCurveMonotone(t,n);else{let i=s?t[t.length-1]:t[0];for(o=0,a=t.length;o<a;++o)r=t[o],l=splineCurve(i,r,t[Math.min(o+1,a-(s?0:1))%a],e.tension),r.cp1x=l.previous.x,r.cp1y=l.previous.y,r.cp2x=l.next.x,r.cp2y=l.next.y,i=r}e.capBezierPoints&&capBezierPoints(t,i)}function _isDomSupported(){return"undefined"!=typeof window&&"undefined"!=typeof document}function _getParentNode(t){let e=t.parentNode;return e&&"[object ShadowRoot]"===e.toString()&&(e=e.host),e}function parseMaxStyle(t,e,i){let s;return"string"==typeof t?(s=parseInt(t,10),-1!==t.indexOf("%")&&(s=s/100*e.parentNode[i])):s=t,s}const getComputedStyle=t=>t.ownerDocument.defaultView.getComputedStyle(t,null);function getStyle(t,e){return getComputedStyle(t).getPropertyValue(e)}const positions=["top","right","bottom","left"];function getPositionedStyle(t,e,i){const s={};i=i?"-"+i:"";for(let n=0;n<4;n++){const o=positions[n];s[o]=parseFloat(t[e+"-"+o+i])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}const useOffsetPos=(t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot);function getCanvasPosition(t,e){const i=t.touches,s=i&&i.length?i[0]:t,{offsetX:n,offsetY:o}=s;let a,r,l=!1;if(useOffsetPos(n,o,t.target))a=n,r=o;else{const t=e.getBoundingClientRect();a=s.clientX-t.left,r=s.clientY-t.top,l=!0}return{x:a,y:r,box:l}}function getRelativePosition(t,e){if("native"in t)return t;const{canvas:i,currentDevicePixelRatio:s}=e,n=getComputedStyle(i),o="border-box"===n.boxSizing,a=getPositionedStyle(n,"padding"),r=getPositionedStyle(n,"border","width"),{x:l,y:h,box:c}=getCanvasPosition(t,i),d=a.left+(c&&r.left),u=a.top+(c&&r.top);let{width:g,height:f}=e;return o&&(g-=a.width+r.width,f-=a.height+r.height),{x:Math.round((l-d)/g*i.width/s),y:Math.round((h-u)/f*i.height/s)}}function getContainerSize(t,e,i){let s,n;if(void 0===e||void 0===i){const o=_getParentNode(t);if(o){const t=o.getBoundingClientRect(),a=getComputedStyle(o),r=getPositionedStyle(a,"border","width"),l=getPositionedStyle(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,s=parseMaxStyle(a.maxWidth,o,"clientWidth"),n=parseMaxStyle(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:s||INFINITY,maxHeight:n||INFINITY}}const round1=t=>Math.round(10*t)/10;function getMaximumSize(t,e,i,s){const n=getComputedStyle(t),o=getPositionedStyle(n,"margin"),a=parseMaxStyle(n.maxWidth,t,"clientWidth")||INFINITY,r=parseMaxStyle(n.maxHeight,t,"clientHeight")||INFINITY,l=getContainerSize(t,e,i);let{width:h,height:c}=l;if("content-box"===n.boxSizing){const t=getPositionedStyle(n,"border","width"),e=getPositionedStyle(n,"padding");h-=e.width+t.width,c-=e.height+t.height}h=Math.max(0,h-o.width),c=Math.max(0,s?h/s:c-o.height),h=round1(Math.min(h,a,l.maxWidth)),c=round1(Math.min(c,r,l.maxHeight)),h&&!c&&(c=round1(h/2));return(void 0!==e||void 0!==i)&&s&&l.height&&c>l.height&&(c=l.height,h=round1(Math.floor(c*s))),{width:h,height:c}}function retinaScale(t,e,i){const s=e||1,n=Math.floor(t.height*s),o=Math.floor(t.width*s);t.height=Math.floor(t.height),t.width=Math.floor(t.width);const a=t.canvas;return a.style&&(i||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(t.currentDevicePixelRatio=s,a.height=n,a.width=o,t.ctx.setTransform(s,0,0,s,0,0),!0)}const supportsEventListenerOptions=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function readUsedSize(t,e){const i=getStyle(t,e),s=i&&i.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function _pointInLine(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function _steppedInterpolation(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:"middle"===s?i<.5?t.y:e.y:"after"===s?i<1?t.y:e.y:i>0?e.y:t.y}}function _bezierInterpolation(t,e,i,s){const n={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=_pointInLine(t,n,i),r=_pointInLine(n,o,i),l=_pointInLine(o,e,i),h=_pointInLine(a,r,i),c=_pointInLine(r,l,i);return _pointInLine(h,c,i)}const getRightToLeftAdapter=function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}},getLeftToRightAdapter=function(){return{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}};function getRtlAdapter(t,e,i){return t?getRightToLeftAdapter(e,i):getLeftToRightAdapter()}function overrideTextDirection(t,e){let i,s;"ltr"!==e&&"rtl"!==e||(i=t.canvas.style,s=[i.getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=s)}function restoreTextDirection(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function propertyFn(t){return"angle"===t?{between:_angleBetween,compare:_angleDiff,normalize:_normalizeAngle}:{between:_isBetween,compare:(t,e)=>t-e,normalize:t=>t}}function normalizeSegment({start:t,end:e,count:i,loop:s,style:n}){return{start:t%i,end:e%i,loop:s&&(e-t+1)%i==0,style:n}}function getSegment(t,e,i){const{property:s,start:n,end:o}=i,{between:a,normalize:r}=propertyFn(s),l=e.length;let h,c,{start:d,end:u,loop:g}=t;if(g){for(d+=l,u+=l,h=0,c=l;h<c&&a(r(e[d%l][s]),n,o);++h)d--,u--;d%=l,u%=l}return u<d&&(u+=l),{start:d,end:u,loop:g,style:t.style}}function _boundSegment(t,e,i){if(!i)return[t];const{property:s,start:n,end:o}=i,a=e.length,{compare:r,between:l,normalize:h}=propertyFn(s),{start:c,end:d,loop:u,style:g}=getSegment(t,e,i),f=[];let p,m,b,x=!1,_=null;const y=()=>x||l(n,b,p)&&0!==r(n,b),v=()=>!x||0===r(o,p)||l(o,b,p);for(let t=c,i=c;t<=d;++t)m=e[t%a],m.skip||(p=h(m[s]),p!==b&&(x=l(p,n,o),null===_&&y()&&(_=0===r(p,n)?t:i),null!==_&&v()&&(f.push(normalizeSegment({start:_,end:t,loop:u,count:a,style:g})),_=null),i=t,b=p));return null!==_&&f.push(normalizeSegment({start:_,end:d,loop:u,count:a,style:g})),f}function _boundSegments(t,e){const i=[],s=t.segments;for(let n=0;n<s.length;n++){const o=_boundSegment(s[n],t.points,e);o.length&&i.push(...o)}return i}function findStartAndEnd(t,e,i,s){let n=0,o=e-1;if(i&&!s)for(;n<e&&!t[n].skip;)n++;for(;n<e&&t[n].skip;)n++;for(n%=e,i&&(o+=n);o>n&&t[o%e].skip;)o--;return o%=e,{start:n,end:o}}function solidSegments(t,e,i,s){const n=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%n];i.skip||i.stop?l.skip||(s=!1,o.push({start:e%n,end:(a-1)%n,loop:s}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&o.push({start:e%n,end:r%n,loop:s}),o}function _computeSegments(t,e){const i=t.points,s=t.options.spanGaps,n=i.length;if(!n)return[];const o=!!t._loop,{start:a,end:r}=findStartAndEnd(i,n,o,s);if(!0===s)return splitByStyles(t,[{start:a,end:r,loop:o}],i,e);return splitByStyles(t,solidSegments(i,a,r<a?r+n:r,!!t._fullLoop&&0===a&&r===n-1),i,e)}function splitByStyles(t,e,i,s){return s&&s.setContext&&i?doSplitByStyles(t,e,i,s):e}function doSplitByStyles(t,e,i,s){const n=t._chart.getContext(),o=readStyle(t.options),{_datasetIndex:a,options:{spanGaps:r}}=t,l=i.length,h=[];let c=o,d=e[0].start,u=d;function g(t,e,s,n){const o=r?-1:1;if(t!==e){for(t+=l;i[t%l].skip;)t-=o;for(;i[e%l].skip;)e+=o;t%l!=e%l&&(h.push({start:t%l,end:e%l,loop:s,style:n}),c=n,d=e%l)}}for(const t of e){d=r?d:t.start;let e,o=i[d%l];for(u=d+1;u<=t.end;u++){const r=i[u%l];e=readStyle(s.setContext(createContext(n,{type:"segment",p0:o,p1:r,p0DataIndex:(u-1)%l,p1DataIndex:u%l,datasetIndex:a}))),styleChanged(e,c)&&g(d,u-1,t.loop,c),o=r,c=e}d<u-1&&g(d,u-1,t.loop,c)}return h}function readStyle(t){return{backgroundColor:t.backgroundColor,borderCapStyle:t.borderCapStyle,borderDash:t.borderDash,borderDashOffset:t.borderDashOffset,borderJoinStyle:t.borderJoinStyle,borderWidth:t.borderWidth,borderColor:t.borderColor}}function styleChanged(t,e){return e&&JSON.stringify(t)!==JSON.stringify(e)} /*! * Chart.js v4.2.1 * https://www.chartjs.org * (c) 2023 Chart.js Contributors * Released under the MIT License - */class Animator{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,s){const n=e.listeners[s],o=e.duration;n.forEach((s=>s({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(i-e.start,o)})))}_refresh(){this._request||(this._running=!0,this._request=requestAnimFrame.call(window,(()=>{this._update(),this._request=null,this._running&&this._refresh()})))}_update(t=Date.now()){let e=0;this._charts.forEach(((i,s)=>{if(!i.running||!i.items.length)return;const n=i.items;let o,a=n.length-1,r=!1;for(;a>=0;--a)o=n[a],o._active?(o._total>i.duration&&(i.duration=o._total),o.tick(t),r=!0):(n[a]=n[n.length-1],n.pop());r&&(s.draw(),this._notify(s,i,t,"progress")),n.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),e+=n.length})),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce(((t,e)=>Math.max(t,e._duration)),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var animator=new Animator;const transparent="transparent",interpolators={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const s=color(t||transparent),n=s.valid&&color(e||transparent);return n&&n.valid?n.mix(s,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class Animation{constructor(t,e,i,s){const n=e[i];s=resolve([t.to,s,n,t.from]);const o=resolve([t.from,n,s]);this._active=!0,this._fn=t.fn||interpolators[t.type||typeof o],this._easing=effects[t.easing]||effects.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=o,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],n=i-this._start,o=this._duration-n;this._start=i,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=resolve([t.to,e,s,t.from]),this._from=resolve([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,n=this._from,o=this._loop,a=this._to;let r;if(this._active=n!==a&&(o||e<i),!this._active)return this._target[s]=a,void this._notify(!0);e<0?this._target[s]=n:(r=e/i%2,r=o&&r>1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[s]=this._fn(n,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,i)=>{t.push({res:e,rej:i})}))}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t<i.length;t++)i[t][e]()}}class Animations{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!isObject(t))return;const e=Object.keys(defaults.animation),i=this._properties;Object.getOwnPropertyNames(t).forEach((s=>{const n=t[s];if(!isObject(n))return;const o={};for(const t of e)o[t]=n[t];(isArray(n.properties)&&n.properties||[s]).forEach((t=>{t!==s&&i.has(t)||i.set(t,o)}))}))}_animateOptions(t,e){const i=e.options,s=resolveTargetOptions(t,i);if(!s)return[];const n=this._createAnimations(s,i);return i.$shared&&awaitAll(t.options.$animations,i).then((()=>{t.options=i}),(()=>{})),n}_createAnimations(t,e){const i=this._properties,s=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),a=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if("$"===l.charAt(0))continue;if("options"===l){s.push(...this._animateOptions(t,e));continue}const h=e[l];let c=n[l];const d=i.get(l);if(c){if(d&&c.active()){c.update(d,h,a);continue}c.cancel()}d&&d.duration?(n[l]=c=new Animation(d,t,l,h),s.push(c)):t[l]=h}return s}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(animator.add(this._chart,i),!0):void 0}}function awaitAll(t,e){const i=[],s=Object.keys(e);for(let e=0;e<s.length;e++){const n=t[s[e]];n&&n.active()&&i.push(n.wait())}return Promise.all(i)}function resolveTargetOptions(t,e){if(!e)return;let i=t.options;if(i)return i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}})),i;t.options=e}function scaleClip(t,e){const i=t&&t.options||{},s=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:s?o:n,end:s?n:o}}function defaultClip(t,e,i){if(!1===i)return!1;const s=scaleClip(t,i),n=scaleClip(e,i);return{top:n.end,right:s.end,bottom:n.start,left:s.start}}function toClip(t){let e,i,s,n;return isObject(t)?(e=t.top,i=t.right,s=t.bottom,n=t.left):e=i=s=n=t,{top:e,right:i,bottom:s,left:n,disabled:!1===t}}function getSortedDatasetIndices(t,e){const i=[],s=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=s.length;n<o;++n)i.push(s[n].index);return i}function applyStack(t,e,i,s={}){const n=t.keys,o="single"===s.mode;let a,r,l,h;if(null!==e){for(a=0,r=n.length;a<r;++a){if(l=+n[a],l===i){if(s.all)continue;break}h=t.values[l],isNumberFinite(h)&&(o||0===e||sign(e)===sign(h))&&(e+=h)}return e}}function convertObjectDataToArray(t){const e=Object.keys(t),i=new Array(e.length);let s,n,o;for(s=0,n=e.length;s<n;++s)o=e[s],i[s]={x:o,y:t[o]};return i}function isStacked(t,e){const i=t&&t.options.stacked;return i||void 0===i&&void 0!==e.stack}function getStackKey(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}function getUserBounds(t){const{min:e,max:i,minDefined:s,maxDefined:n}=t.getUserBounds();return{min:s?e:Number.NEGATIVE_INFINITY,max:n?i:Number.POSITIVE_INFINITY}}function getOrCreateStack(t,e,i){const s=t[e]||(t[e]={});return s[i]||(s[i]={})}function getLastIndexInStack(t,e,i,s){for(const n of e.getMatchingVisibleMetas(s).reverse()){const e=t[n.index];if(i&&e>0||!i&&e<0)return n.index}return null}function updateStacks(t,e){const{chart:i,_cachedMeta:s}=t,n=i._stacks||(i._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,c=getStackKey(o,a,s),d=e.length;let u;for(let t=0;t<d;++t){const i=e[t],{[l]:o,[h]:d}=i;u=(i._stacks||(i._stacks={}))[h]=getOrCreateStack(n,c,o),u[r]=d,u._top=getLastIndexInStack(u,a,!0,s.type),u._bottom=getLastIndexInStack(u,a,!1,s.type);(u._visualValues||(u._visualValues={}))[r]=d}}function getFirstScaleId(t,e){const i=t.scales;return Object.keys(i).filter((t=>i[t].axis===e)).shift()}function createDatasetContext(t,e){return createContext(t,{active:!1,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}function createDataContext(t,e,i){return createContext(t,{active:!1,dataIndex:e,parsed:void 0,raw:void 0,element:i,index:e,mode:"default",type:"data"})}function clearStacks(t,e){const i=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[s]||void 0===e[s][i])return;delete e[s][i],void 0!==e[s]._visualValues&&void 0!==e[s]._visualValues[i]&&delete e[s]._visualValues[i]}}}const isDirectUpdateMode=t=>"reset"===t||"none"===t,cloneIfNotShared=(t,e)=>e?t:Object.assign({},t),createStack=(t,e,i)=>t&&!e.hidden&&e._stacked&&{keys:getSortedDatasetIndices(i,!0),values:null};class DatasetController{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=isStacked(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&clearStacks(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(t,e,i,s)=>"x"===t?e:"r"===t?s:i,n=e.xAxisID=valueOrDefault(i.xAxisID,getFirstScaleId(t,"x")),o=e.yAxisID=valueOrDefault(i.yAxisID,getFirstScaleId(t,"y")),a=e.rAxisID=valueOrDefault(i.rAxisID,getFirstScaleId(t,"r")),r=e.indexAxis,l=e.iAxisID=s(r,n,o,a),h=e.vAxisID=s(r,o,n,a);e.xScale=this.getScaleForId(n),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(l),e.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&unlistenArrayEvents(this._data,this),t._stacked&&clearStacks(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(isObject(e))this._data=convertObjectDataToArray(e);else if(i!==e){if(i){unlistenArrayEvents(i,this);const t=this._cachedMeta;clearStacks(t),t._parsed=[]}e&&Object.isExtensible(e)&&listenArrayEvents(e,this),this._syncList=[],this._data=e}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,i=this.getDataset();let s=!1;this._dataCheck();const n=e._stacked;e._stacked=isStacked(e.vScale,e),e.stack!==i.stack&&(s=!0,clearStacks(e),e.stack=i.stack),this._resyncElements(t),(s||n!==e._stacked)&&updateStacks(this,e._parsed)}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),i=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(i,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:i,_data:s}=this,{iScale:n,_stacked:o}=i,a=n.axis;let r,l,h,c=0===t&&e===s.length||i._sorted,d=t>0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=s,i._sorted=!0,h=s;else{h=isArray(s[t])?this.parseArrayData(i,s,t,e):isObject(s[t])?this.parseObjectData(i,s,t,e):this.parsePrimitiveData(i,s,t,e);const n=()=>null===l[a]||d&&l[a]<d[a];for(r=0;r<e;++r)i._parsed[r+t]=l=h[r],c&&(n()&&(c=!1),d=l);i._sorted=c}o&&updateStacks(this,h)}parsePrimitiveData(t,e,i,s){const{iScale:n,vScale:o}=t,a=n.axis,r=o.axis,l=n.getLabels(),h=n===o,c=new Array(s);let d,u,g;for(d=0,u=s;d<u;++d)g=d+i,c[d]={[a]:h||n.parse(l[g],g),[r]:o.parse(e[g],g)};return c}parseArrayData(t,e,i,s){const{xScale:n,yScale:o}=t,a=new Array(s);let r,l,h,c;for(r=0,l=s;r<l;++r)h=r+i,c=e[h],a[r]={x:n.parse(c[0],h),y:o.parse(c[1],h)};return a}parseObjectData(t,e,i,s){const{xScale:n,yScale:o}=t,{xAxisKey:a="x",yAxisKey:r="y"}=this._parsing,l=new Array(s);let h,c,d,u;for(h=0,c=s;h<c;++h)d=h+i,u=e[d],l[h]={x:n.parse(resolveObjectKey(u,a),d),y:o.parse(resolveObjectKey(u,r),d)};return l}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,e,i){const s=this.chart,n=this._cachedMeta,o=e[t.axis];return applyStack({keys:getSortedDatasetIndices(s,!0),values:e._stacks[t.axis]._visualValues},o,n.index,{mode:i})}updateRangeFromParsed(t,e,i,s){const n=i[e.axis];let o=null===n?NaN:n;const a=s&&i._stacks[e.axis];s&&a&&(s.values=a,o=applyStack(s,n,this._cachedMeta.index)),t.min=Math.min(t.min,o),t.max=Math.max(t.max,o)}getMinMax(t,e){const i=this._cachedMeta,s=i._parsed,n=i._sorted&&t===i.iScale,o=s.length,a=this._getOtherScale(t),r=createStack(e,i,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:h,max:c}=getUserBounds(a);let d,u;function g(){u=s[d];const e=u[a.axis];return!isNumberFinite(u[t.axis])||h>e||c<e}for(d=0;d<o&&(g()||(this.updateRangeFromParsed(l,t,u,r),!n));++d);if(n)for(d=o-1;d>=0;--d)if(!g()){this.updateRangeFromParsed(l,t,u,r);break}return l}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,n,o;for(s=0,n=e.length;s<n;++s)o=e[s][t.axis],isNumberFinite(o)&&i.push(o);return i}getMaxOverflow(){return!1}getLabelAndValue(t){const e=this._cachedMeta,i=e.iScale,s=e.vScale,n=this.getParsed(t);return{label:i?""+i.getLabelForValue(n[i.axis]):"",value:s?""+s.getLabelForValue(n[s.axis]):""}}_update(t){const e=this._cachedMeta;this.update(t||"default"),e._clip=toClip(valueOrDefault(this.options.clip,defaultClip(e.xScale,e.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,e=this.chart,i=this._cachedMeta,s=i.data||[],n=e.chartArea,o=[],a=this._drawStart||0,r=this._drawCount||s.length-a,l=this.options.drawActiveElementsOnTop;let h;for(i.dataset&&i.dataset.draw(t,n,a,r),h=a;h<a+r;++h){const e=s[h];e.hidden||(e.active&&l?o.push(e):e.draw(t,n))}for(h=0;h<o.length;++h)o[h].draw(t,n)}getStyle(t,e){const i=e?"active":"default";return void 0===t&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(i):this.resolveDataElementOptions(t||0,i)}getContext(t,e,i){const s=this.getDataset();let n;if(t>=0&&t<this._cachedMeta.data.length){const e=this._cachedMeta.data[t];n=e.$context||(e.$context=createDataContext(this.getContext(),t,e)),n.parsed=this.getParsed(t),n.raw=s.data[t],n.index=n.dataIndex=t}else n=this.$context||(this.$context=createDatasetContext(this.chart.getContext(),this.index)),n.dataset=s,n.index=n.datasetIndex=this.index;return n.active=!!e,n.mode=i,n}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,e){return this._resolveElementOptions(this.dataElementType.id,e,t)}_resolveElementOptions(t,e="default",i){const s="active"===e,n=this._cachedDataOpts,o=t+"-"+e,a=n[o],r=this.enableOptionSharing&&defined(i);if(a)return cloneIfNotShared(a,r);const l=this.chart.config,h=l.datasetElementScopeKeys(this._type,t),c=s?[`${t}Hover`,"hover",t,""]:[t,""],d=l.getOptionScopes(this.getDataset(),h),u=Object.keys(defaults.elements[t]),g=l.resolveNamedOptions(d,u,(()=>this.getContext(i,s,e)),c);return g.$shared&&(g.$shared=r,n[o]=Object.freeze(cloneIfNotShared(g,r))),g}_resolveAnimations(t,e,i){const s=this.chart,n=this._cachedDataOpts,o=`animation-${e}`,a=n[o];if(a)return a;let r;if(!1!==s.options.animation){const s=this.chart.config,n=s.datasetAnimationScopeKeys(this._type,e),o=s.getOptionScopes(this.getDataset(),n);r=s.createResolver(o,this.getContext(t,i,e))}const l=new Animations(s,r&&r.animations);return r&&r._cacheable&&(n[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||isDirectUpdateMode(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const i=this.resolveDataElementOptions(t,e),s=this._sharedOptions,n=this.getSharedOptions(i),o=this.includeOptions(e,n)||n!==s;return this.updateSharedOptions(n,e,i),{sharedOptions:n,includeOptions:o}}updateElement(t,e,i,s){isDirectUpdateMode(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!isDirectUpdateMode(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const n=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[t,e,i]of this._syncList)this[t](e,i);this._syncList=[];const s=i.length,n=e.length,o=Math.min(n,s);o&&this.parse(0,o),n>s?this._insertElements(s,n-s,t):n<s&&this._removeElements(n,s-n)}_insertElements(t,e,i=!0){const s=this._cachedMeta,n=s.data,o=t+e;let a;const r=t=>{for(t.length+=e,a=t.length-1;a>=o;a--)t[a]=t[a-e]};for(r(n),a=t;a<o;++a)n[a]=new this.dataElementType;this._parsing&&r(s._parsed),this.parse(t,e),i&&this.updateElements(n,t,e,"reset")}updateElements(t,e,i,s){}_removeElements(t,e){const i=this._cachedMeta;if(this._parsing){const s=i._parsed.splice(t,e);i._stacked&&clearStacks(i,s)}i.data.splice(t,e)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[e,i,s]=t;this[e](i,s)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,e){e&&this._sync(["_removeElements",t,e]);const i=arguments.length-2;i&&this._sync(["_insertElements",t,i])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}function getAllScaleValues(t,e){if(!t._cache.$bar){const i=t.getMatchingVisibleMetas(e);let s=[];for(let e=0,n=i.length;e<n;e++)s=s.concat(i[e].controller.getAllParsedValues(t));t._cache.$bar=_arrayUnique(s.sort(((t,e)=>t-e)))}return t._cache.$bar}function computeMinSampleSize(t){const e=t.iScale,i=getAllScaleValues(e,t.type);let s,n,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(defined(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=i.length;s<n;++s)o=e.getPixelForValue(i[s]),l();for(a=void 0,s=0,n=e.ticks.length;s<n;++s)o=e.getPixelForTick(s),l();return r}function computeFitCategoryTraits(t,e,i,s){const n=i.barThickness;let o,a;return isNullOrUndef(n)?(o=e.min*i.categoryPercentage,a=i.barPercentage):(o=n*s,a=1),{chunk:o/s,ratio:a,start:e.pixels[t]-o/2}}function computeFlexCategoryTraits(t,e,i,s){const n=e.pixels,o=n[t];let a=t>0?n[t-1]:null,r=t<n.length-1?n[t+1]:null;const l=i.categoryPercentage;null===a&&(a=o-(null===r?e.end-e.start:r-o)),null===r&&(r=o+o-a);const h=o-(o-Math.min(a,r))/2*l;return{chunk:Math.abs(r-a)/2*l/s,ratio:i.barPercentage,start:h}}function parseFloatBar(t,e,i,s){const n=i.parse(t[0],s),o=i.parse(t[1],s),a=Math.min(n,o),r=Math.max(n,o);let l=a,h=r;Math.abs(a)>Math.abs(r)&&(l=r,h=a),e[i.axis]=h,e._custom={barStart:l,barEnd:h,start:n,end:o,min:a,max:r}}function parseValue(t,e,i,s){return isArray(t)?parseFloatBar(t,e,i,s):e[i.axis]=i.parse(t,s),e}function parseArrayOrPrimitive(t,e,i,s){const n=t.iScale,o=t.vScale,a=n.getLabels(),r=n===o,l=[];let h,c,d,u;for(h=i,c=i+s;h<c;++h)u=e[h],d={},d[n.axis]=r||n.parse(a[h],h),l.push(parseValue(u,d,o,h));return l}function isFloatBar(t){return t&&void 0!==t.barStart&&void 0!==t.barEnd}function barSign(t,e,i){return 0!==t?sign(t):(e.isHorizontal()?1:-1)*(e.min>=i?1:-1)}function borderProps(t){let e,i,s,n,o;return t.horizontal?(e=t.base>t.x,i="left",s="right"):(e=t.base<t.y,i="bottom",s="top"),e?(n="end",o="start"):(n="start",o="end"),{start:i,end:s,reverse:e,top:n,bottom:o}}function setBorderSkipped(t,e,i,s){let n=e.borderSkipped;const o={};if(!n)return void(t.borderSkipped=o);if(!0===n)return void(t.borderSkipped={top:!0,right:!0,bottom:!0,left:!0});const{start:a,end:r,reverse:l,top:h,bottom:c}=borderProps(t);"middle"===n&&i&&(t.enableBorderRadius=!0,(i._top||0)===s?n=h:(i._bottom||0)===s?n=c:(o[parseEdge(c,a,r,l)]=!0,n=h)),o[parseEdge(n,a,r,l)]=!0,t.borderSkipped=o}function parseEdge(t,e,i,s){return t=s?startEnd(t=swap(t,e,i),i,e):startEnd(t,e,i)}function swap(t,e,i){return t===e?i:t===i?e:t}function startEnd(t,e,i){return"start"===t?e:"end"===t?i:t}function setInflateAmount(t,{inflateAmount:e},i){t.inflateAmount="auto"===e?1===i?.33:0:e}class BarController extends DatasetController{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(t,e,i,s){return parseArrayOrPrimitive(t,e,i,s)}parseArrayData(t,e,i,s){return parseArrayOrPrimitive(t,e,i,s)}parseObjectData(t,e,i,s){const{iScale:n,vScale:o}=t,{xAxisKey:a="x",yAxisKey:r="y"}=this._parsing,l="x"===n.axis?a:r,h="x"===o.axis?a:r,c=[];let d,u,g,f;for(d=i,u=i+s;d<u;++d)f=e[d],g={},g[n.axis]=n.parse(resolveObjectKey(f,l),d),c.push(parseValue(resolveObjectKey(f,h),g,o,d));return c}updateRangeFromParsed(t,e,i,s){super.updateRangeFromParsed(t,e,i,s);const n=i._custom;n&&e===this._cachedMeta.vScale&&(t.min=Math.min(t.min,n.min),t.max=Math.max(t.max,n.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const e=this._cachedMeta,{iScale:i,vScale:s}=e,n=this.getParsed(t),o=n._custom,a=isFloatBar(o)?"["+o.start+", "+o.end+"]":""+s.getLabelForValue(n[s.axis]);return{label:""+i.getLabelForValue(n[i.axis]),value:a}}initialize(){this.enableOptionSharing=!0,super.initialize();this._cachedMeta.stack=this.getDataset().stack}update(t){const e=this._cachedMeta;this.updateElements(e.data,0,e.data.length,t)}updateElements(t,e,i,s){const n="reset"===s,{index:o,_cachedMeta:{vScale:a}}=this,r=a.getBasePixel(),l=a.isHorizontal(),h=this._getRuler(),{sharedOptions:c,includeOptions:d}=this._getSharedOptions(e,s);for(let u=e;u<e+i;u++){const e=this.getParsed(u),i=n||isNullOrUndef(e[a.axis])?{base:r,head:r}:this._calculateBarValuePixels(u),g=this._calculateBarIndexPixels(u,h),f=(e._stacks||{})[a.axis],p={horizontal:l,base:i.base,enableBorderRadius:!f||isFloatBar(e._custom)||o===f._top||o===f._bottom,x:l?i.head:g.center,y:l?g.center:i.head,height:l?g.size:Math.abs(i.size),width:l?Math.abs(i.size):g.size};d&&(p.options=c||this.resolveDataElementOptions(u,t[u].active?"active":s));const m=p.options||t[u].options;setBorderSkipped(p,m,f,o),setInflateAmount(p,m,h.ratio),this.updateElement(t[u],u,p,s)}}_getStacks(t,e){const{iScale:i}=this._cachedMeta,s=i.getMatchingVisibleMetas(this._type).filter((t=>t.controller.options.grouped)),n=i.options.stacked,o=[],a=t=>{const i=t.controller.getParsed(e),s=i&&i[t.vScale.axis];if(isNullOrUndef(s)||isNaN(s))return!0};for(const i of s)if((void 0===e||!a(i))&&((!1===n||-1===o.indexOf(i.stack)||void 0===n&&void 0===i.stack)&&o.push(i.stack),i.index===t))break;return o.length||o.push(void 0),o}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,i){const s=this._getStacks(t,i),n=void 0!==e?s.indexOf(e):-1;return-1===n?s.length-1:n}_getRuler(){const t=this.options,e=this._cachedMeta,i=e.iScale,s=[];let n,o;for(n=0,o=e.data.length;n<o;++n)s.push(i.getPixelForValue(this.getParsed(n)[i.axis],n));const a=t.barThickness;return{min:a||computeMinSampleSize(e),pixels:s,start:i._startPixel,end:i._endPixel,stackCount:this._getStackCount(),scale:i,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:e,_stacked:i,index:s},options:{base:n,minBarLength:o}}=this,a=n||0,r=this.getParsed(t),l=r._custom,h=isFloatBar(l);let c,d,u=r[e.axis],g=0,f=i?this.applyStack(e,r,i):u;f!==u&&(g=f-u,f=u),h&&(u=l.barStart,f=l.barEnd-l.barStart,0!==u&&sign(u)!==sign(l.barEnd)&&(g=0),g+=u);const p=isNullOrUndef(n)||h?g:n;let m=e.getPixelForValue(p);if(c=this.chart.getDataVisibility(t)?e.getPixelForValue(g+f):m,d=c-m,Math.abs(d)<o){d=barSign(d,e,a)*o,u===a&&(m-=d/2);const t=e.getPixelForDecimal(0),n=e.getPixelForDecimal(1),l=Math.min(t,n),g=Math.max(t,n);m=Math.max(Math.min(m,g),l),c=m+d,i&&!h&&(r._stacks[e.axis]._visualValues[s]=e.getValueForPixel(c)-e.getValueForPixel(m))}if(m===e.getPixelForValue(a)){const t=sign(d)*e.getLineWidthForValue(a)/2;m+=t,d-=t}return{size:d,base:m,head:c,center:c+d/2}}_calculateBarIndexPixels(t,e){const i=e.scale,s=this.options,n=s.skipNull,o=valueOrDefault(s.maxBarThickness,1/0);let a,r;if(e.grouped){const i=n?this._getStackCount(t):e.stackCount,l="flex"===s.barThickness?computeFlexCategoryTraits(t,e,s,i):computeFitCategoryTraits(t,e,s,i),h=this._getStackIndex(this.index,this._cachedMeta.stack,n?t:void 0);a=l.start+l.chunk*h+l.chunk/2,r=Math.min(o,l.chunk*l.ratio)}else a=i.getPixelForValue(this.getParsed(t)[i.axis],t),r=Math.min(o,e.min*e.ratio);return{base:a-r/2,head:a+r/2,center:a,size:r}}draw(){const t=this._cachedMeta,e=t.vScale,i=t.data,s=i.length;let n=0;for(;n<s;++n)null!==this.getParsed(n)[e.axis]&&i[n].draw(this._ctx)}}class BubbleController extends DatasetController{static id="bubble";static defaults={datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}};static overrides={scales:{x:{type:"linear"},y:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,e,i,s){const n=super.parsePrimitiveData(t,e,i,s);for(let t=0;t<n.length;t++)n[t]._custom=this.resolveDataElementOptions(t+i).radius;return n}parseArrayData(t,e,i,s){const n=super.parseArrayData(t,e,i,s);for(let t=0;t<n.length;t++){const s=e[i+t];n[t]._custom=valueOrDefault(s[2],this.resolveDataElementOptions(t+i).radius)}return n}parseObjectData(t,e,i,s){const n=super.parseObjectData(t,e,i,s);for(let t=0;t<n.length;t++){const s=e[i+t];n[t]._custom=valueOrDefault(s&&s.r&&+s.r,this.resolveDataElementOptions(t+i).radius)}return n}getMaxOverflow(){const t=this._cachedMeta.data;let e=0;for(let i=t.length-1;i>=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart.data.labels||[],{xScale:s,yScale:n}=e,o=this.getParsed(t),a=s.getLabelForValue(o.x),r=n.getLabelForValue(o.y),l=o._custom;return{label:i[t]||"",value:"("+a+", "+r+(l?", "+l:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a}=this._cachedMeta,{sharedOptions:r,includeOptions:l}=this._getSharedOptions(e,s),h=o.axis,c=a.axis;for(let d=e;d<e+i;d++){const e=t[d],i=!n&&this.getParsed(d),u={},g=u[h]=n?o.getPixelForDecimal(.5):o.getPixelForValue(i[h]),f=u[c]=n?a.getBasePixel():a.getPixelForValue(i[c]);u.skip=isNaN(g)||isNaN(f),l&&(u.options=r||this.resolveDataElementOptions(d,e.active?"active":s),n&&(u.options.radius=0)),this.updateElement(e,d,u,s)}}resolveDataElementOptions(t,e){const i=this.getParsed(t);let s=super.resolveDataElementOptions(t,e);s.$shared&&(s=Object.assign({},s,{$shared:!1}));const n=s.radius;return"active"!==e&&(s.radius=0),s.radius+=valueOrDefault(i&&i._custom,n),s}}function getRatioAndOffset(t,e,i){let s=1,n=1,o=0,a=0;if(e<TAU){const r=t,l=r+e,h=Math.cos(r),c=Math.sin(r),d=Math.cos(l),u=Math.sin(l),g=(t,e,s)=>_angleBetween(t,r,l,!0)?1:Math.max(e,e*i,s,s*i),f=(t,e,s)=>_angleBetween(t,r,l,!0)?-1:Math.min(e,e*i,s,s*i),p=g(0,h,d),m=g(HALF_PI,c,u),b=f(PI,h,d),x=f(PI+HALF_PI,c,u);s=(p-b)/2,n=(m-x)/2,o=-(p+b)/2,a=-(m+x)/2}return{ratioX:s,ratioY:n,offsetX:o,offsetY:a}}class DoughnutController extends DatasetController{static id="doughnut";static defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:t=>"spacing"!==t,_indexable:t=>"spacing"!==t};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i,color:s}}=t.legend.options;return e.labels.map(((e,n)=>{const o=t.getDatasetMeta(0).controller.getStyle(n);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,fontColor:s,lineWidth:o.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}}}};constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=i;else{let n,o,a=t=>+i[t];if(isObject(i[t])){const{key:t="value"}=this._parsing;a=e=>+resolveObjectKey(i[e],t)}for(n=t,o=t+e;n<o;++n)s._parsed[n]=a(n)}}_getRotation(){return toRadians(this.options.rotation-90)}_getCircumference(){return toRadians(this.options.circumference)}_getRotationExtents(){let t=TAU,e=-TAU;for(let i=0;i<this.chart.data.datasets.length;++i)if(this.chart.isDatasetVisible(i)&&this.chart.getDatasetMeta(i).type===this._type){const s=this.chart.getDatasetMeta(i).controller,n=s._getRotation(),o=s._getCircumference();t=Math.min(t,n),e=Math.max(e,n+o)}return{rotation:t,circumference:e-t}}update(t){const e=this.chart,{chartArea:i}=e,s=this._cachedMeta,n=s.data,o=this.getMaxBorderWidth()+this.getMaxOffset(n)+this.options.spacing,a=Math.max((Math.min(i.width,i.height)-o)/2,0),r=Math.min((l=this.options.cutout,h=a,"string"==typeof l&&l.endsWith("%")?parseFloat(l)/100:+l/h),1);var l,h;const c=this._getRingWeight(this.index),{circumference:d,rotation:u}=this._getRotationExtents(),{ratioX:g,ratioY:f,offsetX:p,offsetY:m}=getRatioAndOffset(u,d,r),b=(i.width-o)/g,x=(i.height-o)/f,_=Math.max(Math.min(b,x)/2,0),y=toDimension(this.options.radius,_),v=(y-Math.max(y*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=p*y,this.offsetY=m*y,s.total=this.calculateTotal(),this.outerRadius=y-v*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-v*c,0),this.updateElements(n,0,n.length,t)}_circumference(t,e){const i=this.options,s=this._cachedMeta,n=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===s._parsed[t]||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*n/TAU)}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,h=(a.top+a.bottom)/2,c=n&&r.animateScale,d=c?0:this.innerRadius,u=c?0:this.outerRadius,{sharedOptions:g,includeOptions:f}=this._getSharedOptions(e,s);let p,m=this._getRotation();for(p=0;p<e;++p)m+=this._circumference(p,n);for(p=e;p<e+i;++p){const e=this._circumference(p,n),i=t[p],o={x:l+this.offsetX,y:h+this.offsetY,startAngle:m,endAngle:m+e,circumference:e,outerRadius:u,innerRadius:d};f&&(o.options=g||this.resolveDataElementOptions(p,i.active?"active":s)),m+=e,this.updateElement(i,p,o,s)}}calculateTotal(){const t=this._cachedMeta,e=t.data;let i,s=0;for(i=0;i<e.length;i++){const n=t._parsed[i];null===n||isNaN(n)||!this.chart.getDataVisibility(i)||e[i].hidden||(s+=Math.abs(n))}return s}calculateCircumference(t){const e=this._cachedMeta.total;return e>0&&!isNaN(t)?TAU*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=formatNumber(e._parsed[t],i.options.locale);return{label:s[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,n,o,a,r;if(!t)for(s=0,n=i.data.datasets.length;s<n;++s)if(i.isDatasetVisible(s)){o=i.getDatasetMeta(s),t=o.data,a=o.controller;break}if(!t)return 0;for(s=0,n=t.length;s<n;++s)r=a.resolveDataElementOptions(s),"inner"!==r.borderAlign&&(e=Math.max(e,r.borderWidth||0,r.hoverBorderWidth||0));return e}getMaxOffset(t){let e=0;for(let i=0,s=t.length;i<s;++i){const t=this.resolveDataElementOptions(i);e=Math.max(e,t.offset||0,t.hoverOffset||0)}return e}_getRingWeightOffset(t){let e=0;for(let i=0;i<t;++i)this.chart.isDatasetVisible(i)&&(e+=this._getRingWeight(i));return e}_getRingWeight(t){return Math.max(valueOrDefault(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}class LineController extends DatasetController{static id="line";static defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:n}=e,o=this.chart._animationsDisabled;let{start:a,count:r}=_getStartAndCountOfVisiblePoints(e,s,o);this._drawStart=a,this._drawCount=r,_scaleRangesChanged(e)&&(a=0,r=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!n._decimated,i.points=s;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!o,options:l},t),this.updateElements(s,a,r,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,{sharedOptions:h,includeOptions:c}=this._getSharedOptions(e,s),d=o.axis,u=a.axis,{spanGaps:g,segment:f}=this.options,p=isNumber(g)?g:Number.POSITIVE_INFINITY,m=this.chart._animationsDisabled||n||"none"===s,b=e+i,x=t.length;let _=e>0&&this.getParsed(e-1);for(let i=0;i<x;++i){const g=t[i],x=m?g:{};if(i<e||i>=b){x.skip=!0;continue}const y=this.getParsed(i),v=isNullOrUndef(y[u]),S=x[d]=o.getPixelForValue(y[d],i),k=x[u]=n||v?a.getBasePixel():a.getPixelForValue(r?this.applyStack(a,y,r):y[u],i);x.skip=isNaN(S)||isNaN(k)||v,x.stop=i>0&&Math.abs(y[d]-_[d])>p,f&&(x.parsed=y,x.raw=l.data[i]),c&&(x.options=h||this.resolveDataElementOptions(i,g.active?"active":s)),m||this.updateElement(g,i,x,s),_=y}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}class PolarAreaController extends DatasetController{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i,color:s}}=t.legend.options;return e.labels.map(((e,n)=>{const o=t.getDatasetMeta(0).controller.getStyle(n);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,fontColor:s,lineWidth:o.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=formatNumber(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:n}}parseObjectData(t,e,i,s){return _parseObjectDataRadialScale.bind(this)(t,e,i,s)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach(((t,i)=>{const s=this.getParsed(i).r;!isNaN(s)&&this.chart.getDataVisibility(i)&&(s<e.min&&(e.min=s),s>e.max&&(e.max=s))})),e}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),n=Math.max(s/2,0),o=(n-Math.max(i.cutoutPercentage?n/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.options.animation,r=this._cachedMeta.rScale,l=r.xCenter,h=r.yCenter,c=r.getIndexAngle(0)-.5*PI;let d,u=c;const g=360/this.countVisibleElements();for(d=0;d<e;++d)u+=this._computeAngle(d,s,g);for(d=e;d<e+i;d++){const e=t[d];let i=u,f=u+this._computeAngle(d,s,g),p=o.getDataVisibility(d)?r.getDistanceFromCenterForValue(this.getParsed(d).r):0;u=f,n&&(a.animateScale&&(p=0),a.animateRotate&&(i=f=c));const m={x:l,y:h,innerRadius:0,outerRadius:p,startAngle:i,endAngle:f,options:this.resolveDataElementOptions(d,e.active?"active":s)};this.updateElement(e,d,m,s)}}countVisibleElements(){const t=this._cachedMeta;let e=0;return t.data.forEach(((t,i)=>{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&e++})),e}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?toRadians(this.resolveDataElementOptions(t,e).angle||i):0}}class PieController extends DoughnutController{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}}class RadarController extends DatasetController{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}parseObjectData(t,e,i,s){return _parseObjectDataRadialScale.bind(this)(t,e,i,s)}update(t){const e=this._cachedMeta,i=e.dataset,s=e.data||[],n=e.iScale.getLabels();if(i.points=s,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:n.length===s.length,options:e};this.updateElement(i,void 0,o,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const n=this._cachedMeta.rScale,o="reset"===s;for(let a=e;a<e+i;a++){const e=t[a],i=this.resolveDataElementOptions(a,e.active?"active":s),r=n.getPointPositionForValue(a,this.getParsed(a).r),l=o?n.xCenter:r.x,h=o?n.yCenter:r.y,c={x:l,y:h,angle:r.angle,skip:isNaN(l)||isNaN(h),options:i};this.updateElement(e,a,c,s)}}}class ScatterController extends DatasetController{static id="scatter";static defaults={datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1};static overrides={interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}};getLabelAndValue(t){const e=this._cachedMeta,i=this.chart.data.labels||[],{xScale:s,yScale:n}=e,o=this.getParsed(t),a=s.getLabelForValue(o.x),r=n.getLabelForValue(o.y);return{label:i[t]||"",value:"("+a+", "+r+")"}}update(t){const e=this._cachedMeta,{data:i=[]}=e,s=this.chart._animationsDisabled;let{start:n,count:o}=_getStartAndCountOfVisiblePoints(e,i,s);if(this._drawStart=n,this._drawCount=o,_scaleRangesChanged(e)&&(n=0,o=i.length),this.options.showLine){const{dataset:n,_dataset:o}=e;n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!o._decimated,n.points=i;const a=this.resolveDatasetElementOptions(t);a.segment=this.options.segment,this.updateElement(n,void 0,{animated:!s,options:a},t)}this.updateElements(i,n,o,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,h=this.resolveDataElementOptions(e,s),c=this.getSharedOptions(h),d=this.includeOptions(s,c),u=o.axis,g=a.axis,{spanGaps:f,segment:p}=this.options,m=isNumber(f)?f:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||n||"none"===s;let x=e>0&&this.getParsed(e-1);for(let h=e;h<e+i;++h){const e=t[h],i=this.getParsed(h),f=b?e:{},_=isNullOrUndef(i[g]),y=f[u]=o.getPixelForValue(i[u],h),v=f[g]=n||_?a.getBasePixel():a.getPixelForValue(r?this.applyStack(a,i,r):i[g],h);f.skip=isNaN(y)||isNaN(v)||_,f.stop=h>0&&Math.abs(i[u]-x[u])>m,p&&(f.parsed=i,f.raw=l.data[h]),d&&(f.options=c||this.resolveDataElementOptions(h,e.active?"active":s)),b||this.updateElement(e,h,f,s),x=i}this.updateSharedOptions(c,s,h)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let t=0;for(let i=e.length-1;i>=0;--i)t=Math.max(t,e[i].size(this.resolveDataElementOptions(i))/2);return t>0&&t}const i=t.dataset,s=i.options&&i.options.borderWidth||0;if(!e.length)return s;const n=e[0].size(this.resolveDataElementOptions(0)),o=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(s,n,o)/2}}var controllers=Object.freeze({__proto__:null,BarController,BubbleController,DoughnutController,LineController,PolarAreaController,PieController,RadarController,ScatterController});function abstract(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class DateAdapterBase{static override(t){Object.assign(DateAdapterBase.prototype,t)}constructor(t){this.options=t||{}}init(){}formats(){return abstract()}parse(){return abstract()}format(){return abstract()}add(){return abstract()}diff(){return abstract()}startOf(){return abstract()}endOf(){return abstract()}}var adapters={_date:DateAdapterBase};function binarySearch(t,e,i,s){const{controller:n,data:o,_sorted:a}=t,r=n._cachedMeta.iScale;if(r&&e===r.axis&&"r"!==e&&a&&o.length){const t=r._reversePixels?_rlookupByKey:_lookupByKey;if(!s)return t(o,e,i);if(n._sharedOptions){const s=o[0],n="function"==typeof s.getRange&&s.getRange(e);if(n){const s=t(o,e,i-n),a=t(o,e,i+n);return{lo:s.lo,hi:a.hi}}}}return{lo:0,hi:o.length-1}}function evaluateInteractionItems(t,e,i,s,n){const o=t.getSortedVisibleDatasetMetas(),a=i[e];for(let t=0,i=o.length;t<i;++t){const{index:i,data:r}=o[t],{lo:l,hi:h}=binarySearch(o[t],e,a,n);for(let t=l;t<=h;++t){const e=r[t];e.skip||s(e,i,t)}}}function getDistanceMetricForAxis(t){const e=-1!==t.indexOf("x"),i=-1!==t.indexOf("y");return function(t,s){const n=e?Math.abs(t.x-s.x):0,o=i?Math.abs(t.y-s.y):0;return Math.sqrt(Math.pow(n,2)+Math.pow(o,2))}}function getIntersectItems(t,e,i,s,n){const o=[];if(!n&&!t.isPointInArea(e))return o;return evaluateInteractionItems(t,i,e,(function(i,a,r){(n||_isPointInArea(i,t.chartArea,0))&&i.inRange(e.x,e.y,s)&&o.push({element:i,datasetIndex:a,index:r})}),!0),o}function getNearestRadialItems(t,e,i,s){let n=[];return evaluateInteractionItems(t,i,e,(function(t,i,o){const{startAngle:a,endAngle:r}=t.getProps(["startAngle","endAngle"],s),{angle:l}=getAngleFromPoint(t,{x:e.x,y:e.y});_angleBetween(l,a,r)&&n.push({element:t,datasetIndex:i,index:o})})),n}function getNearestCartesianItems(t,e,i,s,n,o){let a=[];const r=getDistanceMetricForAxis(i);let l=Number.POSITIVE_INFINITY;return evaluateInteractionItems(t,i,e,(function(i,h,c){const d=i.inRange(e.x,e.y,n);if(s&&!d)return;const u=i.getCenterPoint(n);if(!(!!o||t.isPointInArea(u))&&!d)return;const g=r(e,u);g<l?(a=[{element:i,datasetIndex:h,index:c}],l=g):g===l&&a.push({element:i,datasetIndex:h,index:c})})),a}function getNearestItems(t,e,i,s,n,o){return o||t.isPointInArea(e)?"r"!==i||s?getNearestCartesianItems(t,e,i,s,n,o):getNearestRadialItems(t,e,i,n):[]}function getAxisItems(t,e,i,s,n){const o=[],a="x"===i?"inXRange":"inYRange";let r=!1;return evaluateInteractionItems(t,i,e,((t,s,l)=>{t[a](e[i],n)&&(o.push({element:t,datasetIndex:s,index:l}),r=r||t.inRange(e.x,e.y,n))})),s&&!r?[]:o}var Interaction={evaluateInteractionItems,modes:{index(t,e,i,s){const n=getRelativePosition(e,t),o=i.axis||"x",a=i.includeInvisible||!1,r=i.intersect?getIntersectItems(t,n,o,s,a):getNearestItems(t,n,o,!1,s,a),l=[];return r.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=r[0].index,i=t.data[e];i&&!i.skip&&l.push({element:i,datasetIndex:t.index,index:e})})),l):[]},dataset(t,e,i,s){const n=getRelativePosition(e,t),o=i.axis||"xy",a=i.includeInvisible||!1;let r=i.intersect?getIntersectItems(t,n,o,s,a):getNearestItems(t,n,o,!1,s,a);if(r.length>0){const e=r[0].datasetIndex,i=t.getDatasetMeta(e).data;r=[];for(let t=0;t<i.length;++t)r.push({element:i[t],datasetIndex:e,index:t})}return r},point:(t,e,i,s)=>getIntersectItems(t,getRelativePosition(e,t),i.axis||"xy",s,i.includeInvisible||!1),nearest(t,e,i,s){const n=getRelativePosition(e,t),o=i.axis||"xy",a=i.includeInvisible||!1;return getNearestItems(t,n,o,i.intersect,s,a)},x:(t,e,i,s)=>getAxisItems(t,getRelativePosition(e,t),"x",i.intersect,s),y:(t,e,i,s)=>getAxisItems(t,getRelativePosition(e,t),"y",i.intersect,s)}};const STATIC_POSITIONS=["left","top","right","bottom"];function filterByPosition(t,e){return t.filter((t=>t.pos===e))}function filterDynamicPositionByAxis(t,e){return t.filter((t=>-1===STATIC_POSITIONS.indexOf(t.pos)&&t.box.axis===e))}function sortByWeight(t,e){return t.sort(((t,i)=>{const s=e?i:t,n=e?t:i;return s.weight===n.weight?s.index-n.index:s.weight-n.weight}))}function wrapBoxes(t){const e=[];let i,s,n,o,a,r;for(i=0,s=(t||[]).length;i<s;++i)n=t[i],({position:o,options:{stack:a,stackWeight:r=1}}=n),e.push({index:i,box:n,pos:o,horizontal:n.isHorizontal(),weight:n.weight,stack:a&&o+a,stackWeight:r});return e}function buildStacks(t){const e={};for(const i of t){const{stack:t,pos:s,stackWeight:n}=i;if(!t||!STATIC_POSITIONS.includes(s))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=n}return e}function setLayoutDims(t,e){const i=buildStacks(t),{vBoxMaxWidth:s,hBoxMaxHeight:n}=e;let o,a,r;for(o=0,a=t.length;o<a;++o){r=t[o];const{fullSize:a}=r.box,l=i[r.stack],h=l&&r.stackWeight/l.weight;r.horizontal?(r.width=h?h*s:a&&e.availableWidth,r.height=n):(r.width=s,r.height=h?h*n:a&&e.availableHeight)}return i}function buildLayoutBoxes(t){const e=wrapBoxes(t),i=sortByWeight(e.filter((t=>t.box.fullSize)),!0),s=sortByWeight(filterByPosition(e,"left"),!0),n=sortByWeight(filterByPosition(e,"right")),o=sortByWeight(filterByPosition(e,"top"),!0),a=sortByWeight(filterByPosition(e,"bottom")),r=filterDynamicPositionByAxis(e,"x"),l=filterDynamicPositionByAxis(e,"y");return{fullSize:i,leftAndTop:s.concat(o),rightAndBottom:n.concat(l).concat(a).concat(r),chartArea:filterByPosition(e,"chartArea"),vertical:s.concat(n).concat(l),horizontal:o.concat(a).concat(r)}}function getCombinedMax(t,e,i,s){return Math.max(t[i],e[i])+Math.max(t[s],e[s])}function updateMaxPadding(t,e){t.top=Math.max(t.top,e.top),t.left=Math.max(t.left,e.left),t.bottom=Math.max(t.bottom,e.bottom),t.right=Math.max(t.right,e.right)}function updateDims(t,e,i,s){const{pos:n,box:o}=i,a=t.maxPadding;if(!isObject(n)){i.size&&(t[n]-=i.size);const e=s[i.stack]||{size:0,count:1};e.size=Math.max(e.size,i.horizontal?o.height:o.width),i.size=e.size/e.count,t[n]+=i.size}o.getPadding&&updateMaxPadding(a,o.getPadding());const r=Math.max(0,e.outerWidth-getCombinedMax(a,t,"left","right")),l=Math.max(0,e.outerHeight-getCombinedMax(a,t,"top","bottom")),h=r!==t.w,c=l!==t.h;return t.w=r,t.h=l,i.horizontal?{same:h,other:c}:{same:c,other:h}}function handleMaxPadding(t){const e=t.maxPadding;function i(i){const s=Math.max(e[i]-t[i],0);return t[i]+=s,s}t.y+=i("top"),t.x+=i("left"),i("right"),i("bottom")}function getMargins(t,e){const i=e.maxPadding;function s(t){const s={left:0,top:0,right:0,bottom:0};return t.forEach((t=>{s[t]=Math.max(e[t],i[t])})),s}return s(t?["left","right"]:["top","bottom"])}function fitBoxes(t,e,i,s){const n=[];let o,a,r,l,h,c;for(o=0,a=t.length,h=0;o<a;++o){r=t[o],l=r.box,l.update(r.width||e.w,r.height||e.h,getMargins(r.horizontal,e));const{same:a,other:d}=updateDims(e,i,r,s);h|=a&&n.length,c=c||d,l.fullSize||n.push(r)}return h&&fitBoxes(n,e,i,s)||c}function setBoxDims(t,e,i,s,n){t.top=i,t.left=e,t.right=e+s,t.bottom=i+n,t.width=s,t.height=n}function placeBoxes(t,e,i,s){const n=i.padding;let{x:o,y:a}=e;for(const r of t){const t=r.box,l=s[r.stack]||{count:1,placed:0,weight:1},h=r.stackWeight/l.weight||1;if(r.horizontal){const s=e.w*h,o=l.size||t.height;defined(l.start)&&(a=l.start),t.fullSize?setBoxDims(t,n.left,a,i.outerWidth-n.right-n.left,o):setBoxDims(t,e.left+l.placed,a,s,o),l.start=a,l.placed+=s,a=t.bottom}else{const s=e.h*h,a=l.size||t.width;defined(l.start)&&(o=l.start),t.fullSize?setBoxDims(t,o,n.top,a,i.outerHeight-n.bottom-n.top):setBoxDims(t,o,e.top+l.placed,a,s),l.start=o,l.placed+=s,o=t.right}}e.x=o,e.y=a}var layouts={addBox(t,e){t.boxes||(t.boxes=[]),e.fullSize=e.fullSize||!1,e.position=e.position||"top",e.weight=e.weight||0,e._layers=e._layers||function(){return[{z:0,draw(t){e.draw(t)}}]},t.boxes.push(e)},removeBox(t,e){const i=t.boxes?t.boxes.indexOf(e):-1;-1!==i&&t.boxes.splice(i,1)},configure(t,e,i){e.fullSize=i.fullSize,e.position=i.position,e.weight=i.weight},update(t,e,i,s){if(!t)return;const n=toPadding(t.options.layout.padding),o=Math.max(e-n.width,0),a=Math.max(i-n.height,0),r=buildLayoutBoxes(t.boxes),l=r.vertical,h=r.horizontal;each(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const c=l.reduce(((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1),0)||1,d=Object.freeze({outerWidth:e,outerHeight:i,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/c,hBoxMaxHeight:a/2}),u=Object.assign({},n);updateMaxPadding(u,toPadding(s));const g=Object.assign({maxPadding:u,w:o,h:a,x:n.left,y:n.top},n),f=setLayoutDims(l.concat(h),d);fitBoxes(r.fullSize,g,d,f),fitBoxes(l,g,d,f),fitBoxes(h,g,d,f)&&fitBoxes(l,g,d,f),handleMaxPadding(g),placeBoxes(r.leftAndTop,g,d,f),g.x+=g.w,g.y+=g.h,placeBoxes(r.rightAndBottom,g,d,f),t.chartArea={left:g.left,top:g.top,right:g.left+g.w,bottom:g.top+g.h,height:g.h,width:g.w},each(r.chartArea,(e=>{const i=e.box;Object.assign(i,t.chartArea),i.update(g.w,g.h,{left:0,top:0,right:0,bottom:0})}))}};class BasePlatform{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,s){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,s?Math.floor(e/s):i)}}isAttached(t){return!0}updateConfig(t){}}class BasicPlatform extends BasePlatform{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const EXPANDO_KEY="$chartjs",EVENT_TYPES={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},isNullOrEmpty=t=>null===t||""===t;function initCanvas(t,e){const i=t.style,s=t.getAttribute("height"),n=t.getAttribute("width");if(t[EXPANDO_KEY]={initial:{height:s,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",isNullOrEmpty(n)){const e=readUsedSize(t,"width");void 0!==e&&(t.width=e)}if(isNullOrEmpty(s))if(""===t.style.height)t.height=t.width/(e||2);else{const e=readUsedSize(t,"height");void 0!==e&&(t.height=e)}return t}const eventListenerOptions=!!supportsEventListenerOptions&&{passive:!0};function addListener(t,e,i){t.addEventListener(e,i,eventListenerOptions)}function removeListener(t,e,i){t.canvas.removeEventListener(e,i,eventListenerOptions)}function fromNativeEvent(t,e){const i=EVENT_TYPES[t.type]||t.type,{x:s,y:n}=getRelativePosition(t,e);return{type:i,chart:e,native:t,x:void 0!==s?s:null,y:void 0!==n?n:null}}function nodeListContains(t,e){for(const i of t)if(i===e||i.contains(e))return!0}function createAttachObserver(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||nodeListContains(i.addedNodes,s),e=e&&!nodeListContains(i.removedNodes,s);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}function createDetachObserver(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||nodeListContains(i.removedNodes,s),e=e&&!nodeListContains(i.addedNodes,s);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}const drpListeningCharts=new Map;let oldDevicePixelRatio=0;function onWindowResize(){const t=window.devicePixelRatio;t!==oldDevicePixelRatio&&(oldDevicePixelRatio=t,drpListeningCharts.forEach(((e,i)=>{i.currentDevicePixelRatio!==t&&e()})))}function listenDevicePixelRatioChanges(t,e){drpListeningCharts.size||window.addEventListener("resize",onWindowResize),drpListeningCharts.set(t,e)}function unlistenDevicePixelRatioChanges(t){drpListeningCharts.delete(t),drpListeningCharts.size||window.removeEventListener("resize",onWindowResize)}function createResizeObserver(t,e,i){const s=t.canvas,n=s&&_getParentNode(s);if(!n)return;const o=throttled(((t,e)=>{const s=n.clientWidth;i(t,e),s<n.clientWidth&&i()}),window),a=new ResizeObserver((t=>{const e=t[0],i=e.contentRect.width,s=e.contentRect.height;0===i&&0===s||o(i,s)}));return a.observe(n),listenDevicePixelRatioChanges(t,o),a}function releaseObserver(t,e,i){i&&i.disconnect(),"resize"===e&&unlistenDevicePixelRatioChanges(t)}function createProxyAndListen(t,e,i){const s=t.canvas,n=throttled((e=>{null!==t.ctx&&i(fromNativeEvent(e,t))}),t);return addListener(s,e,n),n}class DomPlatform extends BasePlatform{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(initCanvas(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e[EXPANDO_KEY])return!1;const i=e[EXPANDO_KEY].initial;["height","width"].forEach((t=>{const s=i[t];isNullOrUndef(s)?e.removeAttribute(t):e.setAttribute(t,s)}));const s=i.style||{};return Object.keys(s).forEach((t=>{e.style[t]=s[t]})),e.width=e.width,delete e[EXPANDO_KEY],!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),n={attach:createAttachObserver,detach:createDetachObserver,resize:createResizeObserver}[e]||createProxyAndListen;s[e]=n(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];if(!s)return;({attach:releaseObserver,detach:releaseObserver,resize:releaseObserver}[e]||removeListener)(t,e,s),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return getMaximumSize(t,e,i,s)}isAttached(t){const e=_getParentNode(t);return!(!e||!e.isConnected)}}function _detectPlatform(t){return!_isDomSupported()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?BasicPlatform:DomPlatform}class Element{static defaults={};static defaultRoutes=void 0;active=!1;tooltipPosition(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}hasValue(){return isNumber(this.x)&&isNumber(this.y)}getProps(t,e){const i=this.$animations;if(!e||!i)return this;const s={};return t.forEach((t=>{s[t]=i[t]&&i[t].active()?i[t]._to:this[t]})),s}}function autoSkip(t,e){const i=t.options.ticks,s=determineMaxTicks(t),n=Math.min(i.maxTicksLimit||s,s),o=i.major.enabled?getMajorIndices(e):[],a=o.length,r=o[0],l=o[a-1],h=[];if(a>n)return skipMajors(e,h,o,a/n),h;const c=calculateSpacing(o,e,n);if(a>0){let t,i;const s=a>1?Math.round((l-r)/(a-1)):null;for(skip(e,h,c,isNullOrUndef(s)?0:r-s,r),t=0,i=a-1;t<i;t++)skip(e,h,c,o[t],o[t+1]);return skip(e,h,c,l,isNullOrUndef(s)?e.length:l+s),h}return skip(e,h,c),h}function determineMaxTicks(t){const e=t.options.offset,i=t._tickSize(),s=t._length/i+(e?0:1),n=t._maxLength/i;return Math.floor(Math.min(s,n))}function calculateSpacing(t,e,i){const s=getEvenSpacing(t),n=e.length/i;if(!s)return Math.max(n,1);const o=_factorize(s);for(let t=0,e=o.length-1;t<e;t++){const e=o[t];if(e>n)return e}return Math.max(n,1)}function getMajorIndices(t){const e=[];let i,s;for(i=0,s=t.length;i<s;i++)t[i].major&&e.push(i);return e}function skipMajors(t,e,i,s){let n,o=0,a=i[0];for(s=Math.ceil(s),n=0;n<t.length;n++)n===a&&(e.push(t[n]),o++,a=i[o*s])}function skip(t,e,i,s,n){const o=valueOrDefault(s,0),a=Math.min(valueOrDefault(n,t.length),t.length);let r,l,h,c=0;for(i=Math.ceil(i),n&&(r=n-s,i=r/Math.floor(r/i)),h=o;h<0;)c++,h=Math.round(o+c*i);for(l=Math.max(o,0);l<a;l++)l===h&&(e.push(t[l]),c++,h=Math.round(o+c*i))}function getEvenSpacing(t){const e=t.length;let i,s;if(e<2)return!1;for(s=t[0],i=1;i<e;++i)if(t[i]-t[i-1]!==s)return!1;return s}const reverseAlign=t=>"left"===t?"right":"right"===t?"left":t,offsetFromEdge=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i,getTicksLimit=(t,e)=>Math.min(e||t,t);function sample(t,e){const i=[],s=t.length/e,n=t.length;let o=0;for(;o<n;o+=s)i.push(t[Math.floor(o)]);return i}function getPixelForGridLine(t,e,i){const s=t.ticks.length,n=Math.min(e,s-1),o=t._startPixel,a=t._endPixel,r=1e-6;let l,h=t.getPixelForTick(n);if(!(i&&(l=1===s?Math.max(h-o,a-h):0===e?(t.getPixelForTick(1)-h)/2:(h-t.getPixelForTick(n-1))/2,h+=n<e?l:-l,h<o-r||h>a+r)))return h}function garbageCollect(t,e){each(t,(t=>{const i=t.gc,s=i.length/2;let n;if(s>e){for(n=0;n<s;++n)delete t.data[i[n]];i.splice(0,s)}}))}function getTickMarkLength(t){return t.drawTicks?t.tickLength:0}function getTitleHeight(t,e){if(!t.display)return 0;const i=toFont(t.font,e),s=toPadding(t.padding);return(isArray(t.text)?t.text.length:1)*i.lineHeight+s.height}function createScaleContext(t,e){return createContext(t,{scale:e,type:"scale"})}function createTickContext(t,e,i){return createContext(t,{tick:i,index:e,type:"tick"})}function titleAlign(t,e,i){let s=_toLeftRightCenter(t);return(i&&"right"!==e||!i&&"right"===e)&&(s=reverseAlign(s)),s}function titleArgs(t,e,i,s){const{top:n,left:o,bottom:a,right:r,chart:l}=t,{chartArea:h,scales:c}=l;let d,u,g,f=0;const p=a-n,m=r-o;if(t.isHorizontal()){if(u=_alignStartEnd(s,o,r),isObject(i)){const t=Object.keys(i)[0],s=i[t];g=c[t].getPixelForValue(s)+p-e}else g="center"===i?(h.bottom+h.top)/2+p-e:offsetFromEdge(t,i,e);d=r-o}else{if(isObject(i)){const t=Object.keys(i)[0],s=i[t];u=c[t].getPixelForValue(s)-m+e}else u="center"===i?(h.left+h.right)/2-m+e:offsetFromEdge(t,i,e);g=_alignStartEnd(s,a,n),f="left"===i?-HALF_PI:HALF_PI}return{titleX:u,titleY:g,maxWidth:d,rotation:f}}class Scale extends Element{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:s}=this;return t=finiteOrDefault(t,Number.POSITIVE_INFINITY),e=finiteOrDefault(e,Number.NEGATIVE_INFINITY),i=finiteOrDefault(i,Number.POSITIVE_INFINITY),s=finiteOrDefault(s,Number.NEGATIVE_INFINITY),{min:finiteOrDefault(t,i),max:finiteOrDefault(e,s),minDefined:isNumberFinite(t),maxDefined:isNumberFinite(e)}}getMinMax(t){let e,{min:i,max:s,minDefined:n,maxDefined:o}=this.getUserBounds();if(n&&o)return{min:i,max:s};const a=this.getMatchingVisibleMetas();for(let r=0,l=a.length;r<l;++r)e=a[r].controller.getMinMax(this,t),n||(i=Math.min(i,e.min)),o||(s=Math.max(s,e.max));return i=o&&i>s?s:i,s=n&&i>s?i:s,{min:finiteOrDefault(i,finiteOrDefault(s,i)),max:finiteOrDefault(s,finiteOrDefault(i,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){callback(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:n,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=_addGrace(this,n,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a<this.ticks.length;this._convertTicksToLabels(r?sample(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),o.display&&(o.autoSkip||"auto"===o.source)&&(this.ticks=autoSkip(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),r&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t,e,i=this.options.reverse;this.isHorizontal()?(t=this.left,e=this.right):(t=this.top,e=this.bottom,i=!i),this._startPixel=t,this._endPixel=e,this._reversePixels=i,this._length=e-t,this._alignToPixels=this.options.alignToPixels}afterUpdate(){callback(this.options.afterUpdate,[this])}beforeSetDimensions(){callback(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){callback(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),callback(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){callback(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const e=this.options.ticks;let i,s,n;for(i=0,s=t.length;i<s;i++)n=t[i],n.label=callback(e.callback,[n.value,i,t],this)}afterTickToLabelConversion(){callback(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){callback(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,e=t.ticks,i=getTicksLimit(this.ticks.length,t.ticks.maxTicksLimit),s=e.minRotation||0,n=e.maxRotation;let o,a,r,l=s;if(!this._isVisible()||!e.display||s>=n||i<=1||!this.isHorizontal())return void(this.labelRotation=s);const h=this._getLabelSizes(),c=h.widest.width,d=h.highest.height,u=_limitValue(this.chart.width-c,0,this.maxWidth);o=t.offset?this.maxWidth/i:u/(i-1),c+6>o&&(o=u/(i-(t.offset?.5:1)),a=this.maxHeight-getTickMarkLength(t.grid)-e.padding-getTitleHeight(t.title,this.chart.options.font),r=Math.sqrt(c*c+d*d),l=toDegrees(Math.min(Math.asin(_limitValue((h.highest.height+6)/o,-1,1)),Math.asin(_limitValue(a/r,-1,1))-Math.asin(_limitValue(d/r,-1,1)))),l=Math.max(s,Math.min(n,l))),this.labelRotation=l}afterCalculateLabelRotation(){callback(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){callback(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:n}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=getTitleHeight(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=getTickMarkLength(n)+o):(t.height=this.maxHeight,t.width=getTickMarkLength(n)+o),i.display&&this.ticks.length){const{first:e,last:s,widest:n,highest:o}=this._getLabelSizes(),r=2*i.padding,l=toRadians(this.labelRotation),h=Math.cos(l),c=Math.sin(l);if(a){const e=i.mirror?0:c*n.width+h*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=i.mirror?0:h*n.width+c*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,s,c,h)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:n,padding:o},position:a}=this.options,r=0!==this.labelRotation,l="top"!==a&&"x"===this.axis;if(this.isHorizontal()){const a=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let c=0,d=0;r?l?(c=s*t.width,d=i*e.height):(c=i*t.height,d=s*e.width):"start"===n?d=e.width:"end"===n?c=t.width:"inner"!==n&&(c=t.width/2,d=e.width/2),this.paddingLeft=Math.max((c-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((d-h+o)*this.width/(this.width-h),0)}else{let i=e.height/2,s=t.height/2;"start"===n?(i=0,s=t.height):"end"===n&&(i=e.height,s=0),this.paddingTop=i+o,this.paddingBottom=s+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){callback(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,i;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,i=t.length;e<i;e++)isNullOrUndef(t[e].label)&&(t.splice(e,1),i--,e--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const e=this.options.ticks.sampleSize;let i=this.ticks;e<i.length&&(i=sample(i,e)),this._labelSizes=t=this._computeLabelSizes(i,i.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,e,i){const{ctx:s,_longestTextCache:n}=this,o=[],a=[],r=Math.floor(e/getTicksLimit(e,i));let l,h,c,d,u,g,f,p,m,b,x,_=0,y=0;for(l=0;l<e;l+=r){if(d=t[l].label,u=this._resolveTickFontOptions(l),s.font=g=u.string,f=n[g]=n[g]||{data:{},gc:[]},p=u.lineHeight,m=b=0,isNullOrUndef(d)||isArray(d)){if(isArray(d))for(h=0,c=d.length;h<c;++h)x=d[h],isNullOrUndef(x)||isArray(x)||(m=_measureText(s,f.data,f.gc,m,x),b+=p)}else m=_measureText(s,f.data,f.gc,m,d),b=p;o.push(m),a.push(b),_=Math.max(m,_),y=Math.max(b,y)}garbageCollect(n,e);const v=o.indexOf(_),S=a.indexOf(y),k=t=>({width:o[t]||0,height:a[t]||0});return{first:k(0),last:k(e-1),widest:k(v),highest:k(S),widths:o,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return _int16Range(this._alignToPixels?_alignPixel(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&t<e.length){const i=e[t];return i.$context||(i.$context=createTickContext(this.getContext(),t,i))}return this.$context||(this.$context=createScaleContext(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,e=toRadians(this.labelRotation),i=Math.abs(Math.cos(e)),s=Math.abs(Math.sin(e)),n=this._getLabelSizes(),o=t.autoSkipPadding||0,a=n?n.widest.width+o:0,r=n?n.highest.height+o:0;return this.isHorizontal()?r*i>a*s?a/i:r/s:r*s<a*i?r/i:a/s}_isVisible(){const t=this.options.display;return"auto"!==t?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:n,position:o,border:a}=s,r=n.offset,l=this.isHorizontal(),h=this.ticks.length+(r?1:0),c=getTickMarkLength(n),d=[],u=a.setContext(this.getContext()),g=u.display?u.width:0,f=g/2,p=function(t){return _alignPixel(i,t,g)};let m,b,x,_,y,v,S,k,P,M,w,A;if("top"===o)m=p(this.bottom),v=this.bottom-c,k=m-f,M=p(t.top)+f,A=t.bottom;else if("bottom"===o)m=p(this.top),M=t.top,A=p(t.bottom)-f,v=m+f,k=this.top+c;else if("left"===o)m=p(this.right),y=this.right-c,S=m-f,P=p(t.left)+f,w=t.right;else if("right"===o)m=p(this.left),P=t.left,w=p(t.right)-f,y=m+f,S=this.left+c;else if("x"===e){if("center"===o)m=p((t.top+t.bottom)/2+.5);else if(isObject(o)){const t=Object.keys(o)[0],e=o[t];m=p(this.chart.scales[t].getPixelForValue(e))}M=t.top,A=t.bottom,v=m+f,k=v+c}else if("y"===e){if("center"===o)m=p((t.left+t.right)/2);else if(isObject(o)){const t=Object.keys(o)[0],e=o[t];m=p(this.chart.scales[t].getPixelForValue(e))}y=m-f,S=y-c,P=t.left,w=t.right}const C=valueOrDefault(s.ticks.maxTicksLimit,h),O=Math.max(1,Math.ceil(h/C));for(b=0;b<h;b+=O){const t=this.getContext(b),e=n.setContext(t),s=a.setContext(t),o=e.lineWidth,h=e.color,c=s.dash||[],u=s.dashOffset,g=e.tickWidth,f=e.tickColor,p=e.tickBorderDash||[],m=e.tickBorderDashOffset;x=getPixelForGridLine(this,b,r),void 0!==x&&(_=_alignPixel(i,x,o),l?y=S=P=w=_:v=k=M=A=_,d.push({tx1:y,ty1:v,tx2:S,ty2:k,x1:P,y1:M,x2:w,y2:A,width:o,color:h,borderDash:c,borderDashOffset:u,tickWidth:g,tickColor:f,tickBorderDash:p,tickBorderDashOffset:m}))}return this._ticksLength=h,this._borderValue=m,d}_computeLabelItems(t){const e=this.axis,i=this.options,{position:s,ticks:n}=i,o=this.isHorizontal(),a=this.ticks,{align:r,crossAlign:l,padding:h,mirror:c}=n,d=getTickMarkLength(i.grid),u=d+h,g=c?-h:u,f=-toRadians(this.labelRotation),p=[];let m,b,x,_,y,v,S,k,P,M,w,A,C="middle";if("top"===s)v=this.bottom-g,S=this._getXAxisLabelAlignment();else if("bottom"===s)v=this.top+g,S=this._getXAxisLabelAlignment();else if("left"===s){const t=this._getYAxisLabelAlignment(d);S=t.textAlign,y=t.x}else if("right"===s){const t=this._getYAxisLabelAlignment(d);S=t.textAlign,y=t.x}else if("x"===e){if("center"===s)v=(t.top+t.bottom)/2+u;else if(isObject(s)){const t=Object.keys(s)[0],e=s[t];v=this.chart.scales[t].getPixelForValue(e)+u}S=this._getXAxisLabelAlignment()}else if("y"===e){if("center"===s)y=(t.left+t.right)/2-u;else if(isObject(s)){const t=Object.keys(s)[0],e=s[t];y=this.chart.scales[t].getPixelForValue(e)}S=this._getYAxisLabelAlignment(d).textAlign}"y"===e&&("start"===r?C="top":"end"===r&&(C="bottom"));const O=this._getLabelSizes();for(m=0,b=a.length;m<b;++m){x=a[m],_=x.label;const t=n.setContext(this.getContext(m));k=this.getPixelForTick(m)+n.labelOffset,P=this._resolveTickFontOptions(m),M=P.lineHeight,w=isArray(_)?_.length:1;const e=w/2,i=t.color,r=t.textStrokeColor,h=t.textStrokeWidth;let d,u=S;if(o?(y=k,"inner"===S&&(u=m===b-1?this.options.reverse?"left":"right":0===m?this.options.reverse?"right":"left":"center"),A="top"===s?"near"===l||0!==f?-w*M+M/2:"center"===l?-O.highest.height/2-e*M+M:-O.highest.height+M/2:"near"===l||0!==f?M/2:"center"===l?O.highest.height/2-e*M:O.highest.height-w*M,c&&(A*=-1),0===f||t.showLabelBackdrop||(y+=M/2*Math.sin(f))):(v=k,A=(1-w)*M/2),t.showLabelBackdrop){const e=toPadding(t.backdropPadding),i=O.heights[m],s=O.widths[m];let n=A-e.top,o=0-e.left;switch(C){case"middle":n-=i/2;break;case"bottom":n-=i}switch(S){case"center":o-=s/2;break;case"right":o-=s}d={left:o,top:n,width:s+e.width,height:i+e.height,color:t.backdropColor}}p.push({label:_,font:P,textOffset:A,options:{rotation:f,color:i,strokeColor:r,strokeWidth:h,textAlign:u,textBaseline:C,translation:[y,v],backdrop:d}})}return p}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-toRadians(this.labelRotation))return"top"===t?"left":"right";let i="center";return"start"===e.align?i="left":"end"===e.align?i="right":"inner"===e.align&&(i="inner"),i}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:i,mirror:s,padding:n}}=this.options,o=t+n,a=this._getLabelSizes().widest.width;let r,l;return"left"===e?s?(l=this.right+n,"near"===i?r="left":"center"===i?(r="center",l+=a/2):(r="right",l+=a)):(l=this.right-o,"near"===i?r="right":"center"===i?(r="center",l-=a/2):(r="left",l=this.left)):"right"===e?s?(l=this.left+n,"near"===i?r="right":"center"===i?(r="center",l-=a/2):(r="left",l-=a)):(l=this.left+o,"near"===i?r="left":"center"===i?(r="center",l+=a/2):(r="right",l=this.right)):r="right",{textAlign:r,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,e=this.options.position;return"left"===e||"right"===e?{top:0,left:this.left,bottom:t.height,right:this.right}:"top"===e||"bottom"===e?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:i,top:s,width:n,height:o}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(i,s,n,o),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const i=this.ticks.findIndex((e=>e.value===t));if(i>=0){return e.setContext(this.getContext(i)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const a=(t,e,s)=>{s.width&&s.color&&(i.save(),i.lineWidth=s.width,i.strokeStyle=s.color,i.setLineDash(s.borderDash||[]),i.lineDashOffset=s.borderDashOffset,i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke(),i.restore())};if(e.display)for(n=0,o=s.length;n<o;++n){const t=s[n];e.drawOnChartArea&&a({x:t.x1,y:t.y1},{x:t.x2,y:t.y2},t),e.drawTicks&&a({x:t.tx1,y:t.ty1},{x:t.tx2,y:t.ty2},{color:t.tickColor,width:t.tickWidth,borderDash:t.tickBorderDash,borderDashOffset:t.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:e,options:{border:i,grid:s}}=this,n=i.setContext(this.getContext()),o=i.display?n.width:0;if(!o)return;const a=s.setContext(this.getContext(0)).lineWidth,r=this._borderValue;let l,h,c,d;this.isHorizontal()?(l=_alignPixel(t,this.left,o)-o/2,h=_alignPixel(t,this.right,a)+a/2,c=d=r):(c=_alignPixel(t,this.top,o)-o/2,d=_alignPixel(t,this.bottom,a)+a/2,l=h=r),e.save(),e.lineWidth=n.width,e.strokeStyle=n.color,e.beginPath(),e.moveTo(l,c),e.lineTo(h,d),e.stroke(),e.restore()}drawLabels(t){if(!this.options.ticks.display)return;const e=this.ctx,i=this._computeLabelArea();i&&clipArea(e,i);const s=this.getLabelItems(t);for(const t of s){const i=t.options,s=t.font;renderText(e,t.label,0,t.textOffset,s,i)}i&&unclipArea(e)}drawTitle(){const{ctx:t,options:{position:e,title:i,reverse:s}}=this;if(!i.display)return;const n=toFont(i.font),o=toPadding(i.padding),a=i.align;let r=n.lineHeight/2;"bottom"===e||"center"===e||isObject(e)?(r+=o.bottom,isArray(i.text)&&(r+=n.lineHeight*(i.text.length-1))):r+=o.top;const{titleX:l,titleY:h,maxWidth:c,rotation:d}=titleArgs(this,r,e,a);renderText(t,i.text,0,0,n,{color:i.color,maxWidth:c,rotation:d,textAlign:titleAlign(a,e,s),textBaseline:"middle",translation:[l,h]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,e=t.ticks&&t.ticks.z||0,i=valueOrDefault(t.grid&&t.grid.z,-1),s=valueOrDefault(t.border&&t.border.z,0);return this._isVisible()&&this.draw===Scale.prototype.draw?[{z:i,draw:t=>{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let n,o;for(n=0,o=e.length;n<o;++n){const o=e[n];o[i]!==this.id||t&&o.type!==t||s.push(o)}return s}_resolveTickFontOptions(t){return toFont(this.options.ticks.setContext(this.getContext(t)).font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class TypedRegistry{constructor(t,e,i){this.type=t,this.scope=e,this.override=i,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const e=Object.getPrototypeOf(t);let i;isIChartComponent(e)&&(i=this.register(e));const s=this.items,n=t.id,o=this.scope+"."+n;if(!n)throw new Error("class does not have id: "+t);return n in s||(s[n]=t,registerDefaults(t,o,i),this.override&&defaults.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,s=this.scope;i in e&&delete e[i],s&&i in defaults[s]&&(delete defaults[s][i],this.override&&delete overrides[i])}}function registerDefaults(t,e,i){const s=merge(Object.create(null),[i?defaults.get(i):{},defaults.get(e),t.defaults]);defaults.set(e,s),t.defaultRoutes&&routeDefaults(e,t.defaultRoutes),t.descriptors&&defaults.describe(e,t.descriptors)}function routeDefaults(t,e){Object.keys(e).forEach((i=>{const s=i.split("."),n=s.pop(),o=[t].concat(s).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");defaults.route(o,n,l,r)}))}function isIChartComponent(t){return"id"in t&&"defaults"in t}class Registry{constructor(){this.controllers=new TypedRegistry(DatasetController,"datasets",!0),this.elements=new TypedRegistry(Element,"elements"),this.plugins=new TypedRegistry(Object,"plugins"),this.scales=new TypedRegistry(Scale,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach((e=>{const s=i||this._getRegistryForType(e);i||s.isForType(e)||s===this.plugins&&e.id?this._exec(t,s,e):each(e,(e=>{const s=i||this._getRegistryForType(e);this._exec(t,s,e)}))}))}_exec(t,e,i){const s=_capitalize(t);callback(i["before"+s],[],i),e[t](i),callback(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;e<this._typedRegistries.length;e++){const i=this._typedRegistries[e];if(i.isForType(t))return i}return this.plugins}_get(t,e,i){const s=e.get(t);if(void 0===s)throw new Error('"'+t+'" is not a registered '+i+".");return s}}var registry=new Registry;class PluginService{constructor(){this._init=[]}notify(t,e,i,s){"beforeInit"===e&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install"));const n=s?this._descriptors(t).filter(s):this._descriptors(t),o=this._notify(n,t,e,i);return"afterDestroy"===e&&(this._notify(n,t,"stop"),this._notify(this._init,t,"uninstall")),o}_notify(t,e,i,s){s=s||{};for(const n of t){const t=n.plugin;if(!1===callback(t[i],[e,s,n.options],t)&&s.cancelable)return!1}return!0}invalidate(){isNullOrUndef(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const e=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),e}_createDescriptors(t,e){const i=t&&t.config,s=valueOrDefault(i.options&&i.options.plugins,{}),n=allPlugins(i);return!1!==s||e?createDescriptors(t,n,s,e):[]}_notifyStateChanges(t){const e=this._oldCache||[],i=this._cache,s=(t,e)=>t.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function allPlugins(t){const e={},i=[],s=Object.keys(registry.plugins.items);for(let t=0;t<s.length;t++)i.push(registry.getPlugin(s[t]));const n=t.plugins||[];for(let t=0;t<n.length;t++){const s=n[t];-1===i.indexOf(s)&&(i.push(s),e[s.id]=!0)}return{plugins:i,localIds:e}}function getOpts(t,e){return e||!1!==t?!0===t?{}:t:null}function createDescriptors(t,{plugins:e,localIds:i},s,n){const o=[],a=t.getContext();for(const r of e){const e=r.id,l=getOpts(s[e],n);null!==l&&o.push({plugin:r,options:pluginOpts(t.config,{plugin:r,local:i[e]},l,a)})}return o}function pluginOpts(t,{plugin:e,local:i},s,n){const o=t.pluginScopeKeys(e),a=t.getOptionScopes(s,o);return i&&e.defaults&&a.push(e.defaults),t.createResolver(a,n,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function getIndexAxis(t,e){const i=defaults.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function getAxisFromDefaultScaleID(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}function getDefaultScaleIDFromAxis(t,e){return t===e?"_index_":"_value_"}function axisFromPosition(t){return"top"===t||"bottom"===t?"x":"left"===t||"right"===t?"y":void 0}function determineAxis(t,e){if("x"===t||"y"===t||"r"===t)return t;if(t=e.axis||axisFromPosition(e.position)||t.length>1&&determineAxis(t[0].toLowerCase(),e))return t;throw new Error(`Cannot determine type of '${name}' axis. Please provide 'axis' or 'position' option.`)}function mergeScaleConfig(t,e){const i=overrides[t.type]||{scales:{}},s=e.scales||{},n=getIndexAxis(t.type,e),o=Object.create(null);return Object.keys(s).forEach((t=>{const e=s[t];if(!isObject(e))return console.error(`Invalid scale configuration for scale: ${t}`);if(e._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);const a=determineAxis(t,e),r=getDefaultScaleIDFromAxis(a,n),l=i.scales||{};o[t]=mergeIf(Object.create(null),[{axis:a},e,l[a],l[r]])})),t.data.datasets.forEach((i=>{const n=i.type||t.type,a=i.indexAxis||getIndexAxis(n,e),r=(overrides[n]||{}).scales||{};Object.keys(r).forEach((t=>{const e=getAxisFromDefaultScaleID(t,a),n=i[e+"AxisID"]||e;o[n]=o[n]||Object.create(null),mergeIf(o[n],[{axis:e},s[n],r[t]])}))})),Object.keys(o).forEach((t=>{const e=o[t];mergeIf(e,[defaults.scales[e.type],defaults.scale])})),o}function initOptions(t){const e=t.options||(t.options={});e.plugins=valueOrDefault(e.plugins,{}),e.scales=mergeScaleConfig(t,e)}function initData(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}function initConfig(t){return(t=t||{}).data=initData(t.data),initOptions(t),t}const keyCache=new Map,keysCached=new Set;function cachedKeys(t,e){let i=keyCache.get(t);return i||(i=e(),keyCache.set(t,i),keysCached.add(i)),i}const addIfFound=(t,e,i)=>{const s=resolveObjectKey(e,i);void 0!==s&&t.add(s)};class Config{constructor(t){this._config=initConfig(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=initData(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),initOptions(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return cachedKeys(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return cachedKeys(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return cachedKeys(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;return cachedKeys(`${this.type}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return s&&!e||(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:n}=this,o=this._cachedScopes(t,i),a=o.get(e);if(a)return a;const r=new Set;e.forEach((e=>{t&&(r.add(t),e.forEach((e=>addIfFound(r,t,e)))),e.forEach((t=>addIfFound(r,s,t))),e.forEach((t=>addIfFound(r,overrides[n]||{},t))),e.forEach((t=>addIfFound(r,defaults,t))),e.forEach((t=>addIfFound(r,descriptors,t)))}));const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),keysCached.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,overrides[e]||{},defaults.datasets[e]||{},{type:e},defaults,descriptors]}resolveNamedOptions(t,e,i,s=[""]){const n={$shared:!0},{resolver:o,subPrefixes:a}=getResolver(this._resolverCache,t,s);let r=o;if(needContext(o,e)){n.$shared=!1;r=_attachContext(o,i=isFunction(i)?i():i,this.createResolver(t,i,a))}for(const t of e)n[t]=r[t];return n}createResolver(t,e,i=[""],s){const{resolver:n}=getResolver(this._resolverCache,t,i);return isObject(e)?_attachContext(n,e,void 0,s):n}}function getResolver(t,e,i){let s=t.get(e);s||(s=new Map,t.set(e,s));const n=i.join();let o=s.get(n);if(!o){o={resolver:_createResolver(e,i),subPrefixes:i.filter((t=>!t.toLowerCase().includes("hover")))},s.set(n,o)}return o}const hasFunction=t=>isObject(t)&&Object.getOwnPropertyNames(t).reduce(((e,i)=>e||isFunction(t[i])),!1);function needContext(t,e){const{isScriptable:i,isIndexable:s}=_descriptors(t);for(const n of e){const e=i(n),o=s(n),a=(o||e)&&t[n];if(e&&(isFunction(a)||hasFunction(a))||o&&isArray(a))return!0}return!1}var version="4.2.1";const KNOWN_POSITIONS=["top","bottom","left","right","chartArea"];function positionIsHorizontal(t,e){return"top"===t||"bottom"===t||-1===KNOWN_POSITIONS.indexOf(t)&&"x"===e}function compare2Level(t,e){return function(i,s){return i[t]===s[t]?i[e]-s[e]:i[t]-s[t]}}function onAnimationsComplete(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),callback(i&&i.onComplete,[t],e)}function onAnimationProgress(t){const e=t.chart,i=e.options.animation;callback(i&&i.onProgress,[t],e)}function getCanvas(t){return _isDomSupported()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const instances={},getChart=t=>{const e=getCanvas(t);return Object.values(instances).filter((t=>t.canvas===e)).pop()};function moveNumericKeys(t,e,i){const s=Object.keys(t);for(const n of s){const s=+n;if(s>=e){const o=t[n];delete t[n],(i>0||s>e)&&(t[s+i]=o)}}}function determineLastEvent(t,e,i,s){return i&&"mouseout"!==t.type?s?e:t:null}function getDatasetArea(t){const{xScale:e,yScale:i}=t;if(e&&i)return{left:e.left,right:e.right,top:i.top,bottom:i.bottom}}class Chart{static defaults=defaults;static instances=instances;static overrides=overrides;static registry=registry;static version=version;static getChart=getChart;static register(...t){registry.add(...t),invalidatePlugins()}static unregister(...t){registry.remove(...t),invalidatePlugins()}constructor(t,e){const i=this.config=new Config(e),s=getCanvas(t),n=getChart(s);if(n)throw new Error("Canvas is already in use. Chart with ID '"+n.id+"' must be destroyed before the canvas with ID '"+n.canvas.id+"' can be reused.");const o=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||_detectPlatform(s)),this.platform.updateConfig(i);const a=this.platform.acquireContext(s,o.aspectRatio),r=a&&a.canvas,l=r&&r.height,h=r&&r.width;this.id=uid(),this.ctx=a,this.canvas=r,this.width=h,this.height=l,this._options=o,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new PluginService,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=debounce((t=>this.update(t)),o.resizeDelay||0),this._dataChanges=[],instances[this.id]=this,a&&r?(animator.listen(this,"complete",onAnimationsComplete),animator.listen(this,"progress",onAnimationProgress),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:n}=this;return isNullOrUndef(t)?e&&n?n:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return registry}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():retinaScale(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return clearCanvas(this.canvas,this.ctx),this}stop(){return animator.stop(this),this}resize(t,e){animator.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,n=i.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(s,t,e,n),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,retinaScale(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),callback(i.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){each(this.options.scales||{},((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce(((t,e)=>(t[e]=!1,t)),{});let n=[];e&&(n=n.concat(Object.keys(e).map((t=>{const i=e[t],s=determineAxis(t,i),n="r"===s,o="x"===s;return{options:i,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}})))),each(n,(e=>{const n=e.options,o=n.id,a=determineAxis(o,n),r=valueOrDefault(n.type,e.dtype);void 0!==n.position&&positionIsHorizontal(n.position,a)===positionIsHorizontal(e.dposition)||(n.position=e.dposition),s[o]=!0;let l=null;if(o in i&&i[o].type===r)l=i[o];else{l=new(registry.getScale(r))({id:o,type:r,ctx:this.ctx,chart:this}),i[l.id]=l}l.init(n,t)})),each(s,((t,e)=>{t||delete i[e]})),each(i,(t=>{layouts.configure(this,t,t.options),layouts.addBox(this,t)}))}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort(((t,e)=>t.index-e.index)),i>e){for(let t=e;t<i;++t)this._destroyDatasetMeta(t);t.splice(e,i-e)}this._sortedMetasets=t.slice(0).sort(compare2Level("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:e}}=this;t.length>e.length&&delete this._stacks,t.forEach(((t,i)=>{0===e.filter((e=>e===t._dataset)).length&&this._destroyDatasetMeta(i)}))}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i<s;i++){const s=e[i];let n=this.getDatasetMeta(i);const o=s.type||this.config.type;if(n.type&&n.type!==o&&(this._destroyDatasetMeta(i),n=this.getDatasetMeta(i)),n.type=o,n.indexAxis=s.indexAxis||getIndexAxis(o,this.options),n.order=s.order||0,n.index=i,n.label=""+s.label,n.visible=this.isDatasetVisible(i),n.controller)n.controller.updateIndex(i),n.controller.linkScales();else{const e=registry.getController(o),{datasetElementType:s,dataElementType:a}=defaults.datasets[o];Object.assign(e,{dataElementType:registry.getElement(a),datasetElementType:s&®istry.getElement(s)}),n.controller=new e(this,i),t.push(n.controller)}}return this._updateMetasets(),t}_resetElements(){each(this.data.datasets,((t,e)=>{this.getDatasetMeta(e).controller.reset()}),this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const n=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let t=0,e=this.data.datasets.length;t<e;t++){const{controller:e}=this.getDatasetMeta(t),i=!s&&-1===n.indexOf(e);e.buildOrUpdateElements(i),o=Math.max(+e.getMaxOverflow(),o)}o=this._minPadding=i.layout.autoPadding?o:0,this._updateLayout(o),s||each(n,(t=>{t.reset()})),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(compare2Level("z","_idx"));const{_active:a,_lastEvent:r}=this;r?this._eventHandler(r,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){each(this.scales,(t=>{layouts.removeBox(this,t)})),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);setsEqual(e,i)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:n}of e){moveNumericKeys(t,s,"_removeElements"===i?-n:n)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=e=>new Set(t.filter((t=>t[0]===e)).map(((t,e)=>e+","+t.splice(1).join(",")))),s=i(0);for(let t=1;t<e;t++)if(!setsEqual(s,i(t)))return;return Array.from(s).map((t=>t.split(","))).map((t=>({method:t[1],start:+t[2],count:+t[3]})))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;layouts.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],each(this.boxes,(t=>{i&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))}),this),this._layers.forEach(((t,e)=>{t._idx=e})),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let t=0,e=this.data.datasets.length;t<e;++t)this.getDatasetMeta(t).controller.configure();for(let e=0,i=this.data.datasets.length;e<i;++e)this._updateDataset(e,isFunction(t)?t({datasetIndex:e}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,e){const i=this.getDatasetMeta(t),s={meta:i,index:t,mode:e,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetUpdate",s)&&(i.controller._update(e),s.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",s))}render(){!1!==this.notifyPlugins("beforeRender",{cancelable:!0})&&(animator.has(this)?this.attached&&!animator.running(this)&&animator.start(this):(this.draw(),onAnimationsComplete({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:t,height:e}=this._resizeBeforeDraw;this._resize(t,e),this._resizeBeforeDraw=null}if(this.clear(),this.width<=0||this.height<=0)return;if(!1===this.notifyPlugins("beforeDraw",{cancelable:!0}))return;const e=this._layers;for(t=0;t<e.length&&e[t].z<=0;++t)e[t].draw(this.chartArea);for(this._drawDatasets();t<e.length;++t)e[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const e=this._sortedMetasets,i=[];let s,n;for(s=0,n=e.length;s<n;++s){const n=e[s];t&&!n.visible||i.push(n)}return i}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(!1===this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0}))return;const t=this.getSortedVisibleDatasetMetas();for(let e=t.length-1;e>=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,n=getDatasetArea(t)||this.chartArea,o={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",o)&&(s&&clipArea(e,{left:!1===i.left?0:n.left-i.left,right:!1===i.right?this.width:n.right+i.right,top:!1===i.top?0:n.top-i.top,bottom:!1===i.bottom?this.height:n.bottom+i.bottom}),t.controller.draw(),s&&unclipArea(e),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}isPointInArea(t){return _isPointInArea(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,i,s){const n=Interaction.modes[e];return"function"==typeof n?n(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter((t=>t&&t._dataset===e)).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=createContext(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",n=this.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,s);defined(e)?(n.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),o.update(n,{visible:i}),this.update((e=>e.datasetIndex===t?s:void 0)))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),animator.remove(this),t=0,e=this.data.datasets.length;t<e;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:e}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),clearCanvas(t,e),this.platform.releaseContext(e),this.canvas=null,this.ctx=null),delete instances[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};each(this.options.events,(t=>i(t,s)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(i,s)=>{t[i]&&(e.removeEventListener(this,i,s),delete t[i])},n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",n),i("detach",o)};o=()=>{this.attached=!1,s("resize",n),this._stop(),this._resize(0,0),i("attach",a)},e.isAttached(this.canvas)?a():o()}unbindEvents(){each(this._listeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._listeners={},each(this._responsiveListeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let n,o,a,r;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex),n.controller["_"+s+"DatasetHoverStyle"]()),a=0,r=t.length;a<r;++a){o=t[a];const e=o&&this.getDatasetMeta(o.datasetIndex).controller;e&&e[s+"HoverStyle"](o.element,o.datasetIndex,o.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const e=this._active||[],i=t.map((({datasetIndex:t,index:e})=>{const i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}}));!_elementsEqual(i,e)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}isPluginEnabled(t){return 1===this._plugins._cache.filter((e=>e.plugin.id===t)).length}_updateHoverStyles(t,e,i){const s=this.options.hover,n=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),o=n(e,t),a=i?t:n(t,e);o.length&&this.updateHoverStyle(o,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},s=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,s))return;const n=this._handleEvent(t,e,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(n||i.changed)&&this.render(),this}_handleEvent(t,e,i){const{_active:s=[],options:n}=this,o=e,a=this._getActiveElements(t,s,i,o),r=_isClickEvent(t),l=determineLastEvent(t,this._lastEvent,i,r);i&&(this._lastEvent=null,callback(n.onHover,[t,a,this],this),r&&callback(n.onClick,[t,a,this],this));const h=!_elementsEqual(a,s);return(h||e)&&(this._active=a,this._updateHoverStyles(a,s,e)),this._lastEvent=l,h}_getActiveElements(t,e,i,s){if("mouseout"===t.type)return[];if(!i)return e;const n=this.options.hover;return this.getElementsAtEventForMode(t,n.mode,n,s)}}function invalidatePlugins(){return each(Chart.instances,(t=>t._plugins.invalidate()))}function clipArc(t,e,i){const{startAngle:s,pixelMargin:n,x:o,y:a,outerRadius:r,innerRadius:l}=e;let h=n/r;t.beginPath(),t.arc(o,a,r,s-h,i+h),l>n?(h=n/l,t.arc(o,a,l,i+h,s-h,!0)):t.arc(o,a,n,i+HALF_PI,s-HALF_PI),t.closePath(),t.clip()}function toRadiusCorners(t){return _readValueToProps(t,["outerStart","outerEnd","innerStart","innerEnd"])}function parseBorderRadius$1(t,e,i,s){const n=toRadiusCorners(t.options.borderRadius),o=(i-e)/2,a=Math.min(o,s*e/2),r=t=>{const e=(i-Math.min(o,t))*s/2;return _limitValue(t,0,Math.min(o,e))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:_limitValue(n.innerStart,0,a),innerEnd:_limitValue(n.innerEnd,0,a)}}function rThetaToXY(t,e,i,s){return{x:i+t*Math.cos(e),y:s+t*Math.sin(e)}}function pathArc(t,e,i,s,n,o){const{x:a,y:r,startAngle:l,pixelMargin:h,innerRadius:c}=e,d=Math.max(e.outerRadius+s+i-h,0),u=c>0?c+s+i+h:0;let g=0;const f=n-l;if(s){const t=((c>0?c-s:0)+(d>0?d-s:0))/2;g=(f-(0!==t?f*t/(t+s):f))/2}const p=(f-Math.max(.001,f*d-i/PI)/d)/2,m=l+p+g,b=n-p-g,{outerStart:x,outerEnd:_,innerStart:y,innerEnd:v}=parseBorderRadius$1(e,u,d,b-m),S=d-x,k=d-_,P=m+x/S,M=b-_/k,w=u+y,A=u+v,C=m+y/w,O=b-v/A;if(t.beginPath(),o){const e=(P+M)/2;if(t.arc(a,r,d,P,e),t.arc(a,r,d,e,M),_>0){const e=rThetaToXY(k,M,a,r);t.arc(e.x,e.y,_,M,b+HALF_PI)}const i=rThetaToXY(A,b,a,r);if(t.lineTo(i.x,i.y),v>0){const e=rThetaToXY(A,O,a,r);t.arc(e.x,e.y,v,b+HALF_PI,O+Math.PI)}const s=(b-v/u+(m+y/u))/2;if(t.arc(a,r,u,b-v/u,s,!0),t.arc(a,r,u,s,m+y/u,!0),y>0){const e=rThetaToXY(w,C,a,r);t.arc(e.x,e.y,y,C+Math.PI,m-HALF_PI)}const n=rThetaToXY(S,m,a,r);if(t.lineTo(n.x,n.y),x>0){const e=rThetaToXY(S,P,a,r);t.arc(e.x,e.y,x,m-HALF_PI,P)}}else{t.moveTo(a,r);const e=Math.cos(P)*d+a,i=Math.sin(P)*d+r;t.lineTo(e,i);const s=Math.cos(M)*d+a,n=Math.sin(M)*d+r;t.lineTo(s,n)}t.closePath()}function drawArc(t,e,i,s,n){const{fullCircles:o,startAngle:a,circumference:r}=e;let l=e.endAngle;if(o){pathArc(t,e,i,s,l,n);for(let e=0;e<o;++e)t.fill();isNaN(r)||(l=a+(r%TAU||TAU))}return pathArc(t,e,i,s,l,n),t.fill(),l}function drawBorder(t,e,i,s,n){const{fullCircles:o,startAngle:a,circumference:r,options:l}=e,{borderWidth:h,borderJoinStyle:c}=l,d="inner"===l.borderAlign;if(!h)return;d?(t.lineWidth=2*h,t.lineJoin=c||"round"):(t.lineWidth=h,t.lineJoin=c||"bevel");let u=e.endAngle;if(o){pathArc(t,e,i,s,u,n);for(let e=0;e<o;++e)t.stroke();isNaN(r)||(u=a+(r%TAU||TAU))}d&&clipArc(t,e,u),o||(pathArc(t,e,i,s,u,n),t.stroke())}class ArcElement extends Element{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0};static defaultRoutes={backgroundColor:"backgroundColor"};constructor(t){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,t&&Object.assign(this,t)}inRange(t,e,i){const s=this.getProps(["x","y"],i),{angle:n,distance:o}=getAngleFromPoint(s,{x:t,y:e}),{startAngle:a,endAngle:r,innerRadius:l,outerRadius:h,circumference:c}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),d=this.options.spacing/2,u=valueOrDefault(c,r-a)>=TAU||_angleBetween(n,a,r),g=_isBetween(o,l+d,h+d);return u&&g}getCenterPoint(t){const{x:e,y:i,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:r,spacing:l}=this.options,h=(s+n)/2,c=(o+a+l+r)/2;return{x:e+Math.cos(h)*c,y:i+Math.sin(h)*c}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,s=(e.offset||0)/4,n=(e.spacing||0)/2,o=e.circular;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>TAU?Math.floor(i/TAU):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();const a=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(a)*s,Math.sin(a)*s);const r=s*(1-Math.sin(Math.min(PI,i||0)));t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,drawArc(t,this,r,n,o),drawBorder(t,this,r,n,o),t.restore()}}function setStyle(t,e,i=e){t.lineCap=valueOrDefault(i.borderCapStyle,e.borderCapStyle),t.setLineDash(valueOrDefault(i.borderDash,e.borderDash)),t.lineDashOffset=valueOrDefault(i.borderDashOffset,e.borderDashOffset),t.lineJoin=valueOrDefault(i.borderJoinStyle,e.borderJoinStyle),t.lineWidth=valueOrDefault(i.borderWidth,e.borderWidth),t.strokeStyle=valueOrDefault(i.borderColor,e.borderColor)}function lineTo(t,e,i){t.lineTo(i.x,i.y)}function getLineMethod(t){return t.stepped?_steppedLineTo:t.tension||"monotone"===t.cubicInterpolationMode?_bezierCurveTo:lineTo}function pathVars(t,e,i={}){const s=t.length,{start:n=0,end:o=s-1}=i,{start:a,end:r}=e,l=Math.max(n,a),h=Math.min(o,r),c=n<a&&o<a||n>r&&o>r;return{count:s,start:l,loop:e.loop,ilen:h<l&&!c?s+h-l:h-l}}function pathSegment(t,e,i,s){const{points:n,options:o}=e,{count:a,start:r,loop:l,ilen:h}=pathVars(n,i,s),c=getLineMethod(o);let d,u,g,{move:f=!0,reverse:p}=s||{};for(d=0;d<=h;++d)u=n[(r+(p?h-d:d))%a],u.skip||(f?(t.moveTo(u.x,u.y),f=!1):c(t,g,u,p,o.stepped),g=u);return l&&(u=n[(r+(p?h:0))%a],c(t,g,u,p,o.stepped)),!!l}function fastPathSegment(t,e,i,s){const n=e.points,{count:o,start:a,ilen:r}=pathVars(n,i,s),{move:l=!0,reverse:h}=s||{};let c,d,u,g,f,p,m=0,b=0;const x=t=>(a+(h?r-t:t))%o,_=()=>{g!==f&&(t.lineTo(m,f),t.lineTo(m,g),t.lineTo(m,p))};for(l&&(d=n[x(0)],t.moveTo(d.x,d.y)),c=0;c<=r;++c){if(d=n[x(c)],d.skip)continue;const e=d.x,i=d.y,s=0|e;s===u?(i<g?g=i:i>f&&(f=i),m=(b*m+e)/++b):(_(),t.lineTo(e,i),u=s,b=0,g=f=i),p=i}_()}function _getSegmentMethod(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?fastPathSegment:pathSegment}function _getInterpolationMethod(t){return t.stepped?_steppedInterpolation:t.tension||"monotone"===t.cubicInterpolationMode?_bezierInterpolation:_pointInLine}function strokePathWithCache(t,e,i,s){let n=e._path;n||(n=e._path=new Path2D,e.path(n,i,s)&&n.closePath()),setStyle(t,e.options),t.stroke(n)}function strokePathDirect(t,e,i,s){const{segments:n,options:o}=e,a=_getSegmentMethod(e);for(const r of n)setStyle(t,o,r.style),t.beginPath(),a(t,e,r,{start:i,end:i+s-1})&&t.closePath(),t.stroke()}const usePath2D="function"==typeof Path2D;function draw(t,e,i,s){usePath2D&&!e.options.segment?strokePathWithCache(t,e,i,s):strokePathDirect(t,e,i,s)}class LineElement extends Element{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>"borderDash"!==t&&"fill"!==t};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||"monotone"===i.cubicInterpolationMode)&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;_updateBezierControlPoints(this._points,i,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=_computeSegments(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],n=this.points,o=_boundSegments(this,{property:e,start:s,end:s});if(!o.length)return;const a=[],r=_getInterpolationMethod(i);let l,h;for(l=0,h=o.length;l<h;++l){const{start:h,end:c}=o[l],d=n[h],u=n[c];if(d===u){a.push(d);continue}const g=r(d,u,Math.abs((s-d[e])/(u[e]-d[e])),i.stepped);g[e]=t[e],a.push(g)}return 1===a.length?a[0]:a}pathSegment(t,e,i){return _getSegmentMethod(this)(t,this,e,i)}path(t,e,i){const s=this.segments,n=_getSegmentMethod(this);let o=this._loop;e=e||0,i=i||this.points.length-e;for(const a of s)o&=n(t,this,a,{start:e,end:e+i-1});return!!o}draw(t,e,i,s){const n=this.options||{};(this.points||[]).length&&n.borderWidth&&(t.save(),draw(t,this,i,s),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function inRange$1(t,e,i,s){const n=t.options,{[i]:o}=t.getProps([i],s);return Math.abs(e-o)<n.radius+n.hitRadius}class PointElement extends Element{static id="point";static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,i){const s=this.options,{x:n,y:o}=this.getProps(["x","y"],i);return Math.pow(t-n,2)+Math.pow(e-o,2)<Math.pow(s.hitRadius+s.radius,2)}inXRange(t,e){return inRange$1(this,t,"x",e)}inYRange(t,e){return inRange$1(this,t,"y",e)}getCenterPoint(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}size(t){let e=(t=t||this.options||{}).radius||0;e=Math.max(e,e&&t.hoverRadius||0);return 2*(e+(e&&t.borderWidth||0))}draw(t,e){const i=this.options;this.skip||i.radius<.1||!_isPointInArea(this,e,this.size(i)/2)||(t.strokeStyle=i.borderColor,t.lineWidth=i.borderWidth,t.fillStyle=i.backgroundColor,drawPoint(t,i,this.x,this.y))}getRange(){const t=this.options||{};return t.radius+t.hitRadius}}function getBarBounds(t,e){const{x:i,y:s,base:n,width:o,height:a}=t.getProps(["x","y","base","width","height"],e);let r,l,h,c,d;return t.horizontal?(d=a/2,r=Math.min(i,n),l=Math.max(i,n),h=s-d,c=s+d):(d=o/2,r=i-d,l=i+d,h=Math.min(s,n),c=Math.max(s,n)),{left:r,top:h,right:l,bottom:c}}function skipOrLimit(t,e,i,s){return t?0:_limitValue(e,i,s)}function parseBorderWidth(t,e,i){const s=t.options.borderWidth,n=t.borderSkipped,o=toTRBL(s);return{t:skipOrLimit(n.top,o.top,0,i),r:skipOrLimit(n.right,o.right,0,e),b:skipOrLimit(n.bottom,o.bottom,0,i),l:skipOrLimit(n.left,o.left,0,e)}}function parseBorderRadius(t,e,i){const{enableBorderRadius:s}=t.getProps(["enableBorderRadius"]),n=t.options.borderRadius,o=toTRBLCorners(n),a=Math.min(e,i),r=t.borderSkipped,l=s||isObject(n);return{topLeft:skipOrLimit(!l||r.top||r.left,o.topLeft,0,a),topRight:skipOrLimit(!l||r.top||r.right,o.topRight,0,a),bottomLeft:skipOrLimit(!l||r.bottom||r.left,o.bottomLeft,0,a),bottomRight:skipOrLimit(!l||r.bottom||r.right,o.bottomRight,0,a)}}function boundingRects(t){const e=getBarBounds(t),i=e.right-e.left,s=e.bottom-e.top,n=parseBorderWidth(t,i/2,s/2),o=parseBorderRadius(t,i/2,s/2);return{outer:{x:e.left,y:e.top,w:i,h:s,radius:o},inner:{x:e.left+n.l,y:e.top+n.t,w:i-n.l-n.r,h:s-n.t-n.b,radius:{topLeft:Math.max(0,o.topLeft-Math.max(n.t,n.l)),topRight:Math.max(0,o.topRight-Math.max(n.t,n.r)),bottomLeft:Math.max(0,o.bottomLeft-Math.max(n.b,n.l)),bottomRight:Math.max(0,o.bottomRight-Math.max(n.b,n.r))}}}}function inRange(t,e,i,s){const n=null===e,o=null===i,a=t&&!(n&&o)&&getBarBounds(t,s);return a&&(n||_isBetween(e,a.left,a.right))&&(o||_isBetween(i,a.top,a.bottom))}function hasRadius(t){return t.topLeft||t.topRight||t.bottomLeft||t.bottomRight}function addNormalRectPath(t,e){t.rect(e.x,e.y,e.w,e.h)}function inflateRect(t,e,i={}){const s=t.x!==i.x?-e:0,n=t.y!==i.y?-e:0,o=(t.x+t.w!==i.x+i.w?e:0)-s,a=(t.y+t.h!==i.y+i.h?e:0)-n;return{x:t.x+s,y:t.y+n,w:t.w+o,h:t.h+a,radius:t.radius}}class BarElement extends Element{static id="bar";static defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:e,options:{borderColor:i,backgroundColor:s}}=this,{inner:n,outer:o}=boundingRects(this),a=hasRadius(o.radius)?addRoundedRectPath:addNormalRectPath;t.save(),o.w===n.w&&o.h===n.h||(t.beginPath(),a(t,inflateRect(o,e,n)),t.clip(),a(t,inflateRect(n,-e,o)),t.fillStyle=i,t.fill("evenodd")),t.beginPath(),a(t,inflateRect(n,e)),t.fillStyle=s,t.fill(),t.restore()}inRange(t,e,i){return inRange(this,t,e,i)}inXRange(t,e){return inRange(this,t,null,e)}inYRange(t,e){return inRange(this,null,t,e)}getCenterPoint(t){const{x:e,y:i,base:s,horizontal:n}=this.getProps(["x","y","base","horizontal"],t);return{x:n?(e+s)/2:e,y:n?i:(i+s)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}var elements=Object.freeze({__proto__:null,ArcElement,LineElement,PointElement,BarElement});const BORDER_COLORS=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],BACKGROUND_COLORS=BORDER_COLORS.map((t=>t.replace("rgb(","rgba(").replace(")",", 0.5)")));function getBorderColor(t){return BORDER_COLORS[t%BORDER_COLORS.length]}function getBackgroundColor(t){return BACKGROUND_COLORS[t%BACKGROUND_COLORS.length]}function colorizeDefaultDataset(t,e){return t.borderColor=getBorderColor(e),t.backgroundColor=getBackgroundColor(e),++e}function colorizeDoughnutDataset(t,e){return t.backgroundColor=t.data.map((()=>getBorderColor(e++))),e}function colorizePolarAreaDataset(t,e){return t.backgroundColor=t.data.map((()=>getBackgroundColor(e++))),e}function getColorizer(t){let e=0;return(i,s)=>{const n=t.getDatasetMeta(s).controller;n instanceof DoughnutController?e=colorizeDoughnutDataset(i,e):n instanceof PolarAreaController?e=colorizePolarAreaDataset(i,e):n&&(e=colorizeDefaultDataset(i,e))}}function containsColorsDefinitions(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}function containsColorsDefinition(t){return t&&(t.borderColor||t.backgroundColor)}var plugin_colors={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,i){if(!i.enabled)return;const{data:{datasets:s},options:n}=t.config,{elements:o}=n;if(!i.forceOverride&&(containsColorsDefinitions(s)||containsColorsDefinition(n)||o&&containsColorsDefinitions(o)))return;const a=getColorizer(t);s.forEach(a)}};function lttbDecimation(t,e,i,s,n){const o=n.samples||s;if(o>=i)return t.slice(e,e+i);const a=[],r=(i-2)/(o-2);let l=0;const h=e+i-1;let c,d,u,g,f,p=e;for(a[l++]=t[p],c=0;c<o-2;c++){let s,n=0,o=0;const h=Math.floor((c+1)*r)+1+e,m=Math.min(Math.floor((c+2)*r)+1,i)+e,b=m-h;for(s=h;s<m;s++)n+=t[s].x,o+=t[s].y;n/=b,o/=b;const x=Math.floor(c*r)+1+e,_=Math.min(Math.floor((c+1)*r)+1,i)+e,{x:y,y:v}=t[p];for(u=g=-1,s=x;s<_;s++)g=.5*Math.abs((y-n)*(t[s].y-v)-(y-t[s].x)*(o-v)),g>u&&(u=g,d=t[s],f=s);a[l++]=d,p=f}return a[l++]=t[h],a}function minMaxDecimation(t,e,i,s){let n,o,a,r,l,h,c,d,u,g,f=0,p=0;const m=[],b=e+i-1,x=t[e].x,_=t[b].x-x;for(n=e;n<e+i;++n){o=t[n],a=(o.x-x)/_*s,r=o.y;const e=0|a;if(e===l)r<u?(u=r,h=n):r>g&&(g=r,c=n),f=(p*f+o.x)/++p;else{const i=n-1;if(!isNullOrUndef(h)&&!isNullOrUndef(c)){const e=Math.min(h,c),s=Math.max(h,c);e!==d&&e!==i&&m.push({...t[e],x:f}),s!==d&&s!==i&&m.push({...t[s],x:f})}n>0&&i!==d&&m.push(t[i]),m.push(o),l=e,p=0,u=g=r,h=c=d=n}}return m}function cleanDecimatedDataset(t){if(t._decimated){const e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,writable:!0,value:e})}}function cleanDecimatedData(t){t.data.datasets.forEach((t=>{cleanDecimatedDataset(t)}))}function getStartAndCountOfVisiblePointsSimplified(t,e){const i=e.length;let s,n=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:h}=o.getUserBounds();return l&&(n=_limitValue(_lookupByKey(e,o.axis,a).lo,0,i-1)),s=h?_limitValue(_lookupByKey(e,o.axis,r).hi+1,n,i)-n:i-n,{start:n,count:s}}var plugin_decimation={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return void cleanDecimatedData(t);const s=t.width;t.data.datasets.forEach(((e,n)=>{const{_data:o,indexAxis:a}=e,r=t.getDatasetMeta(n),l=o||e.data;if("y"===resolve([a,t.options.indexAxis]))return;if(!r.controller.supportsDecimation)return;const h=t.scales[r.xAxisID];if("linear"!==h.type&&"time"!==h.type)return;if(t.options.parsing)return;let{start:c,count:d}=getStartAndCountOfVisiblePointsSimplified(r,l);if(d<=(i.threshold||4*s))return void cleanDecimatedDataset(e);let u;switch(isNullOrUndef(o)&&(e._data=l,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"lttb":u=lttbDecimation(l,c,d,s,i);break;case"min-max":u=minMaxDecimation(l,c,d,s);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=u}))},destroy(t){cleanDecimatedData(t)}};function _segments(t,e,i){const s=t.segments,n=t.points,o=e.points,a=[];for(const t of s){let{start:s,end:r}=t;r=_findSegmentEnd(s,r,n);const l=_getBounds(i,n[s],n[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:n[s],end:n[r]});continue}const h=_boundSegments(e,l);for(const e of h){const s=_getBounds(i,o[e.start],o[e.end],e.loop),r=_boundSegment(t,n,s);for(const t of r)a.push({source:t,target:e,start:{[i]:_getEdge(l,s,"start",Math.max)},end:{[i]:_getEdge(l,s,"end",Math.min)}})}}return a}function _getBounds(t,e,i,s){if(s)return;let n=e[t],o=i[t];return"angle"===t&&(n=_normalizeAngle(n),o=_normalizeAngle(o)),{property:t,start:n,end:o}}function _pointsFromSegments(t,e){const{x:i=null,y:s=null}=t||{},n=e.points,o=[];return e.segments.forEach((({start:t,end:e})=>{e=_findSegmentEnd(t,e,n);const a=n[t],r=n[e];null!==s?(o.push({x:a.x,y:s}),o.push({x:r.x,y:s})):null!==i&&(o.push({x:i,y:a.y}),o.push({x:i,y:r.y}))})),o}function _findSegmentEnd(t,e,i){for(;e>t;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function _getEdge(t,e,i,s){return t&&e?s(t[i],e[i]):t?t[i]:e?e[i]:0}function _createBoundaryLine(t,e){let i=[],s=!1;return isArray(t)?(s=!0,i=t):i=_pointsFromSegments(t,e),i.length?new LineElement({points:i,options:{tension:0},_loop:s,_fullLoop:s}):null}function _shouldApplyFill(t){return t&&!1!==t.fill}function _resolveTarget(t,e,i){let s=t[e].fill;const n=[e];let o;if(!i)return s;for(;!1!==s&&-1===n.indexOf(s);){if(!isNumberFinite(s))return s;if(o=t[s],!o)return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function _decodeFill(t,e,i){const s=parseFillOption(t);if(isObject(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return isNumberFinite(n)&&Math.floor(n)===n?decodeTargetIndex(s[0],e,n,i):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function decodeTargetIndex(t,e,i,s){return"-"!==t&&"+"!==t||(i=e+i),!(i===e||i<0||i>=s)&&i}function _getTargetPixel(t,e){let i=null;return"start"===t?i=e.bottom:"end"===t?i=e.top:isObject(t)?i=e.getPixelForValue(t.value):e.getBasePixel&&(i=e.getBasePixel()),i}function _getTargetValue(t,e,i){let s;return s="start"===t?i:"end"===t?e.options.reverse?e.min:e.max:isObject(t)?t.value:e.getBaseValue(),s}function parseFillOption(t){const e=t.options,i=e.fill;let s=valueOrDefault(i&&i.target,i);return void 0===s&&(s=!!e.backgroundColor),!1!==s&&null!==s&&(!0===s?"origin":s)}function _buildStackLine(t){const{scale:e,index:i,line:s}=t,n=[],o=s.segments,a=s.points,r=getLinesBelow(e,i);r.push(_createBoundaryLine({x:null,y:e.bottom},s));for(let t=0;t<o.length;t++){const e=o[t];for(let t=e.start;t<=e.end;t++)addPointsBelow(n,a[t],r)}return new LineElement({points:n,options:{}})}function getLinesBelow(t,e){const i=[],s=t.getMatchingVisibleMetas("line");for(let t=0;t<s.length;t++){const n=s[t];if(n.index===e)break;n.hidden||i.unshift(n.dataset)}return i}function addPointsBelow(t,e,i){const s=[];for(let n=0;n<i.length;n++){const o=i[n],{first:a,last:r,point:l}=findPoint(o,e,"x");if(!(!l||a&&r))if(a)s.unshift(l);else if(t.push(l),!r)break}t.push(...s)}function findPoint(t,e,i){const s=t.interpolate(e,i);if(!s)return{};const n=s[i],o=t.segments,a=t.points;let r=!1,l=!1;for(let t=0;t<o.length;t++){const e=o[t],s=a[e.start][i],h=a[e.end][i];if(_isBetween(n,s,h)){r=n===s,l=n===h;break}}return{first:r,last:l,point:s}}class simpleArc{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:s,y:n,radius:o}=this;return e=e||{start:0,end:TAU},t.arc(s,n,o,e.end,e.start,!0),!i.bounds}interpolate(t){const{x:e,y:i,radius:s}=this,n=t.angle;return{x:e+Math.cos(n)*s,y:i+Math.sin(n)*s,angle:n}}}function _getTarget(t){const{chart:e,fill:i,line:s}=t;if(isNumberFinite(i))return getLineByIndex(e,i);if("stack"===i)return _buildStackLine(t);if("shape"===i)return!0;const n=computeBoundary(t);return n instanceof simpleArc?n:_createBoundaryLine(n,s)}function getLineByIndex(t,e){const i=t.getDatasetMeta(e);return i&&t.isDatasetVisible(e)?i.dataset:null}function computeBoundary(t){return(t.scale||{}).getPointPositionForValue?computeCircularBoundary(t):computeLinearBoundary(t)}function computeLinearBoundary(t){const{scale:e={},fill:i}=t,s=_getTargetPixel(i,e);if(isNumberFinite(s)){const t=e.isHorizontal();return{x:t?s:null,y:t?null:s}}return null}function computeCircularBoundary(t){const{scale:e,fill:i}=t,s=e.options,n=e.getLabels().length,o=s.reverse?e.max:e.min,a=_getTargetValue(i,e,o),r=[];if(s.grid.circular){const t=e.getPointPositionForValue(0,o);return new simpleArc({x:t.x,y:t.y,radius:e.getDistanceFromCenterForValue(a)})}for(let t=0;t<n;++t)r.push(e.getPointPositionForValue(t,a));return r}function _drawfill(t,e,i){const s=_getTarget(e),{line:n,scale:o,axis:a}=e,r=n.options,l=r.fill,h=r.backgroundColor,{above:c=h,below:d=h}=l||{};s&&n.points.length&&(clipArea(t,i),doFill(t,{line:n,target:s,above:c,below:d,area:i,scale:o,axis:a}),unclipArea(t))}function doFill(t,e){const{line:i,target:s,above:n,below:o,area:a,scale:r}=e,l=i._loop?"angle":e.axis;t.save(),"x"===l&&o!==n&&(clipVertical(t,s,a.top),fill(t,{line:i,target:s,color:n,scale:r,property:l}),t.restore(),t.save(),clipVertical(t,s,a.bottom)),fill(t,{line:i,target:s,color:o,scale:r,property:l}),t.restore()}function clipVertical(t,e,i){const{segments:s,points:n}=e;let o=!0,a=!1;t.beginPath();for(const r of s){const{start:s,end:l}=r,h=n[s],c=n[_findSegmentEnd(s,l,n)];o?(t.moveTo(h.x,h.y),o=!1):(t.lineTo(h.x,i),t.lineTo(h.x,h.y)),a=!!e.pathSegment(t,r,{move:a}),a?t.closePath():t.lineTo(c.x,i)}t.lineTo(e.first().x,i),t.closePath(),t.clip()}function fill(t,e){const{line:i,target:s,property:n,color:o,scale:a}=e,r=_segments(i,s,n);for(const{source:e,target:l,start:h,end:c}of r){const{style:{backgroundColor:r=o}={}}=e,d=!0!==s;t.save(),t.fillStyle=r,clipBounds(t,a,d&&_getBounds(n,h,c)),t.beginPath();const u=!!i.pathSegment(t,e);let g;if(d){u?t.closePath():interpolatedLineTo(t,s,c,n);const e=!!s.pathSegment(t,l,{move:u,reverse:!0});g=u&&e,g||interpolatedLineTo(t,s,h,n)}t.closePath(),t.fill(g?"evenodd":"nonzero"),t.restore()}}function clipBounds(t,e,i){const{top:s,bottom:n}=e.chart.chartArea,{property:o,start:a,end:r}=i||{};"x"===o&&(t.beginPath(),t.rect(a,s,r-a,n-s),t.clip())}function interpolatedLineTo(t,e,i,s){const n=e.interpolate(i,s);n&&t.lineTo(n.x,n.y)}var index={id:"filler",afterDatasetsUpdate(t,e,i){const s=(t.data.datasets||[]).length,n=[];let o,a,r,l;for(a=0;a<s;++a)o=t.getDatasetMeta(a),r=o.dataset,l=null,r&&r.options&&r instanceof LineElement&&(l={visible:t.isDatasetVisible(a),index:a,fill:_decodeFill(r,a,s),chart:t,axis:o.controller.options.indexAxis,scale:o.vScale,line:r}),o.$filler=l,n.push(l);for(a=0;a<s;++a)l=n[a],l&&!1!==l.fill&&(l.fill=_resolveTarget(n,a,i.propagate))},beforeDraw(t,e,i){const s="beforeDraw"===i.drawTime,n=t.getSortedVisibleDatasetMetas(),o=t.chartArea;for(let e=n.length-1;e>=0;--e){const i=n[e].$filler;i&&(i.line.updateControlPoints(o,i.axis),s&&i.fill&&_drawfill(t.ctx,i,o))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const s=t.getSortedVisibleDatasetMetas();for(let e=s.length-1;e>=0;--e){const i=s[e].$filler;_shouldApplyFill(i)&&_drawfill(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const s=e.meta.$filler;_shouldApplyFill(s)&&"beforeDatasetDraw"===i.drawTime&&_drawfill(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const getBoxSize=(t,e)=>{let{boxHeight:i=e,boxWidth:s=e}=t;return t.usePointStyle&&(i=Math.min(i,e),s=t.pointStyleWidth||Math.min(s,e)),{boxWidth:s,boxHeight:i,itemHeight:Math.max(e,i)}},itemsEqual=(t,e)=>null!==t&&null!==e&&t.datasetIndex===e.datasetIndex&&t.index===e.index;class Legend extends Element{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=callback(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter((e=>t.filter(e,this.chart.data)))),t.sort&&(e=e.sort(((e,i)=>t.sort(e,i,this.chart.data)))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,s=toFont(i.font),n=s.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=getBoxSize(i,n);let l,h;e.font=s.string,this.isHorizontal()?(l=this.maxWidth,h=this._fitRows(o,n,a,r)+10):(h=this.maxHeight,l=this._fitCols(o,s,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:n,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],h=s+a;let c=t;n.textAlign="left",n.textBaseline="middle";let d=-1,u=-h;return this.legendItems.forEach(((t,g)=>{const f=i+e/2+n.measureText(t.text).width;(0===g||l[l.length-1]+f+2*a>o)&&(c+=h,l[l.length-(g>0?0:1)]=0,u+=h,d++),r[g]={left:0,top:u,row:d,width:f,height:s},l[l.length-1]+=f+a})),c}_fitCols(t,e,i,s){const{ctx:n,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],h=o-t;let c=a,d=0,u=0,g=0,f=0;return this.legendItems.forEach(((t,o)=>{const{itemWidth:p,itemHeight:m}=calculateItemSize(i,e,n,t,s);o>0&&u+m+2*a>h&&(c+=d+a,l.push({width:d,height:u}),g+=d+a,f++,d=u=0),r[o]={left:g,top:u,col:f,width:p,height:m},d=Math.max(d,p),u+=m+a})),c+=d,l.push({width:d,height:u}),c}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:n}}=this,o=getRtlAdapter(n,this.left,this.width);if(this.isHorizontal()){let n=0,a=_alignStartEnd(i,this.left+s,this.right-this.lineWidths[n]);for(const r of e)n!==r.row&&(n=r.row,a=_alignStartEnd(i,this.left+s,this.right-this.lineWidths[n])),r.top+=this.top+t+s,r.left=o.leftForLtr(o.x(a),r.width),a+=r.width+s}else{let n=0,a=_alignStartEnd(i,this.top+t+s,this.bottom-this.columnSizes[n].height);for(const r of e)r.col!==n&&(n=r.col,a=_alignStartEnd(i,this.top+t+s,this.bottom-this.columnSizes[n].height)),r.top=a,r.left+=this.left+s,r.left=o.leftForLtr(o.x(r.left),r.width),a+=r.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;clipArea(t,this),this._draw(),unclipArea(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:n,labels:o}=t,a=defaults.color,r=getRtlAdapter(t.rtl,this.left,this.width),l=toFont(o.font),{padding:h}=o,c=l.size,d=c/2;let u;this.drawTitle(),s.textAlign=r.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=l.string;const{boxWidth:g,boxHeight:f,itemHeight:p}=getBoxSize(o,c),m=this.isHorizontal(),b=this._computeTitleHeight();u=m?{x:_alignStartEnd(n,this.left+h,this.right-i[0]),y:this.top+h+b,line:0}:{x:this.left+h,y:_alignStartEnd(n,this.top+b+h,this.bottom-e[0].height),line:0},overrideTextDirection(this.ctx,t.textDirection);const x=p+h;this.legendItems.forEach(((_,y)=>{s.strokeStyle=_.fontColor,s.fillStyle=_.fontColor;const v=s.measureText(_.text).width,S=r.textAlign(_.textAlign||(_.textAlign=o.textAlign)),k=g+d+v;let P=u.x,M=u.y;r.setWidth(this.width),m?y>0&&P+k+h>this.right&&(M=u.y+=x,u.line++,P=u.x=_alignStartEnd(n,this.left+h,this.right-i[u.line])):y>0&&M+x>this.bottom&&(P=u.x=P+e[u.line].width+h,u.line++,M=u.y=_alignStartEnd(n,this.top+b+h,this.bottom-e[u.line].height));if(function(t,e,i){if(isNaN(g)||g<=0||isNaN(f)||f<0)return;s.save();const n=valueOrDefault(i.lineWidth,1);if(s.fillStyle=valueOrDefault(i.fillStyle,a),s.lineCap=valueOrDefault(i.lineCap,"butt"),s.lineDashOffset=valueOrDefault(i.lineDashOffset,0),s.lineJoin=valueOrDefault(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=valueOrDefault(i.strokeStyle,a),s.setLineDash(valueOrDefault(i.lineDash,[])),o.usePointStyle){const a={radius:f*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},l=r.xPlus(t,g/2);drawPointLegend(s,a,l,e+d,o.pointStyleWidth&&g)}else{const o=e+Math.max((c-f)/2,0),a=r.leftForLtr(t,g),l=toTRBLCorners(i.borderRadius);s.beginPath(),Object.values(l).some((t=>0!==t))?addRoundedRectPath(s,{x:a,y:o,w:g,h:f,radius:l}):s.rect(a,o,g,f),s.fill(),0!==n&&s.stroke()}s.restore()}(r.x(P),M,_),P=_textX(S,P+g+d,m?P+k:this.right,t.rtl),function(t,e,i){renderText(s,i.text,t,e+p/2,l,{strikethrough:i.hidden,textAlign:r.textAlign(i.textAlign)})}(r.x(P),M,_),m)u.x+=k+h;else if("string"!=typeof _.text){const t=l.lineHeight;u.y+=calculateLegendItemHeight(_,t)}else u.y+=x})),restoreTextDirection(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=toFont(e.font),s=toPadding(e.padding);if(!e.display)return;const n=getRtlAdapter(t.rtl,this.left,this.width),o=this.ctx,a=e.position,r=i.size/2,l=s.top+r;let h,c=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),h=this.top+l,c=_alignStartEnd(t.align,c,this.right-d);else{const e=this.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);h=l+_alignStartEnd(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const u=_alignStartEnd(a,c,c+d);o.textAlign=n.textAlign(_toLeftRightCenter(a)),o.textBaseline="middle",o.strokeStyle=e.color,o.fillStyle=e.color,o.font=i.string,renderText(o,e.text,u,h,i)}_computeTitleHeight(){const t=this.options.title,e=toFont(t.font),i=toPadding(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,n;if(_isBetween(t,this.left,this.right)&&_isBetween(e,this.top,this.bottom))for(n=this.legendHitBoxes,i=0;i<n.length;++i)if(s=n[i],_isBetween(t,s.left,s.left+s.width)&&_isBetween(e,s.top,s.top+s.height))return this.legendItems[i];return null}handleEvent(t){const e=this.options;if(!isListened(t.type,e))return;const i=this._getLegendItemAt(t.x,t.y);if("mousemove"===t.type||"mouseout"===t.type){const o=this._hoveredItem,a=(n=i,null!==(s=o)&&null!==n&&s.datasetIndex===n.datasetIndex&&s.index===n.index);o&&!a&&callback(e.onLeave,[t,o,this],this),this._hoveredItem=i,i&&!a&&callback(e.onHover,[t,i,this],this)}else i&&callback(e.onClick,[t,i,this],this);var s,n}}function calculateItemSize(t,e,i,s,n){return{itemWidth:calculateItemWidth(s,t,e,i),itemHeight:calculateItemHeight(n,s,e.lineHeight)}}function calculateItemWidth(t,e,i,s){let n=t.text;return n&&"string"!=typeof n&&(n=n.reduce(((t,e)=>t.length>e.length?t:e))),e+i.size/2+s.measureText(n).width}function calculateItemHeight(t,e,i){let s=t;return"string"!=typeof e.text&&(s=calculateLegendItemHeight(e,i)),s}function calculateLegendItemHeight(t,e){return e*(t.text?t.text.length+.5:0)}function isListened(t,e){return!("mousemove"!==t&&"mouseout"!==t||!e.onHover&&!e.onLeave)||!(!e.onClick||"click"!==t&&"mouseup"!==t)}var plugin_legend={id:"legend",_element:Legend,start(t,e,i){const s=t.legend=new Legend({ctx:t.ctx,options:i,chart:t});layouts.configure(t,s,i),layouts.addBox(t,s)},stop(t){layouts.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,i){const s=t.legend;layouts.configure(t,s,i),s.options=i},afterUpdate(t){const e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,i){const s=e.datasetIndex,n=i.chart;n.isDatasetVisible(s)?(n.hide(s),e.hidden=!0):(n.show(s),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:s,textAlign:n,color:o,useBorderRadius:a,borderRadius:r}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const l=t.controller.getStyle(i?0:void 0),h=toPadding(l.borderWidth);return{text:e[t.index].label,fillStyle:l.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:l.borderCapStyle,lineDash:l.borderDash,lineDashOffset:l.borderDashOffset,lineJoin:l.borderJoinStyle,lineWidth:(h.width+h.height)/4,strokeStyle:l.borderColor,pointStyle:s||l.pointStyle,rotation:l.rotation,textAlign:n||l.textAlign,borderRadius:a&&(r||l.borderRadius),datasetIndex:t.index}}),this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class Title extends Element{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const s=isArray(i.text)?i.text.length:1;this._padding=toPadding(i.padding);const n=s*toFont(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=n:this.width=n}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:s,right:n,options:o}=this,a=o.align;let r,l,h,c=0;return this.isHorizontal()?(l=_alignStartEnd(a,i,n),h=e+t,r=n-i):("left"===o.position?(l=i+t,h=_alignStartEnd(a,s,e),c=-.5*PI):(l=n-t,h=_alignStartEnd(a,e,s),c=.5*PI),r=s-e),{titleX:l,titleY:h,maxWidth:r,rotation:c}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=toFont(e.font),s=i.lineHeight/2+this._padding.top,{titleX:n,titleY:o,maxWidth:a,rotation:r}=this._drawArgs(s);renderText(t,e.text,0,0,i,{color:e.color,maxWidth:a,rotation:r,textAlign:_toLeftRightCenter(e.align),textBaseline:"middle",translation:[n,o]})}}function createTitle(t,e){const i=new Title({ctx:t.ctx,options:e,chart:t});layouts.configure(t,i,e),layouts.addBox(t,i),t.titleBlock=i}var plugin_title={id:"title",_element:Title,start(t,e,i){createTitle(t,i)},stop(t){const e=t.titleBlock;layouts.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const s=t.titleBlock;layouts.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const map=new WeakMap;var plugin_subtitle={id:"subtitle",start(t,e,i){const s=new Title({ctx:t.ctx,options:i,chart:t});layouts.configure(t,s,i),layouts.addBox(t,s),map.set(t,s)},stop(t){layouts.removeBox(t,map.get(t)),map.delete(t)},beforeUpdate(t,e,i){const s=map.get(t);layouts.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const positioners={average(t){if(!t.length)return!1;let e,i,s=0,n=0,o=0;for(e=0,i=t.length;e<i;++e){const i=t[e].element;if(i&&i.hasValue()){const t=i.tooltipPosition();s+=t.x,n+=t.y,++o}}return{x:s/o,y:n/o}},nearest(t,e){if(!t.length)return!1;let i,s,n,o=e.x,a=e.y,r=Number.POSITIVE_INFINITY;for(i=0,s=t.length;i<s;++i){const s=t[i].element;if(s&&s.hasValue()){const t=distanceBetweenPoints(e,s.getCenterPoint());t<r&&(r=t,n=s)}}if(n){const t=n.tooltipPosition();o=t.x,a=t.y}return{x:o,y:a}}};function pushOrConcat(t,e){return e&&(isArray(e)?Array.prototype.push.apply(t,e):t.push(e)),t}function splitNewlines(t){return("string"==typeof t||t instanceof String)&&t.indexOf("\n")>-1?t.split("\n"):t}function createTooltipItem(t,e){const{element:i,datasetIndex:s,index:n}=e,o=t.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:t,label:a,parsed:o.getParsed(n),raw:t.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:i}}function getTooltipSize(t,e){const i=t.chart.ctx,{body:s,footer:n,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=toFont(e.bodyFont),h=toFont(e.titleFont),c=toFont(e.footerFont),d=o.length,u=n.length,g=s.length,f=toPadding(e.padding);let p=f.height,m=0,b=s.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);if(b+=t.beforeBody.length+t.afterBody.length,d&&(p+=d*h.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),b){p+=g*(e.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(b-g)*l.lineHeight+(b-1)*e.bodySpacing}u&&(p+=e.footerMarginTop+u*c.lineHeight+(u-1)*e.footerSpacing);let x=0;const _=function(t){m=Math.max(m,i.measureText(t).width+x)};return i.save(),i.font=h.string,each(t.title,_),i.font=l.string,each(t.beforeBody.concat(t.afterBody),_),x=e.displayColors?a+2+e.boxPadding:0,each(s,(t=>{each(t.before,_),each(t.lines,_),each(t.after,_)})),x=0,i.font=c.string,each(t.footer,_),i.restore(),m+=f.width,{width:m,height:p}}function determineYAlign(t,e){const{y:i,height:s}=e;return i<s/2?"top":i>t.height-s/2?"bottom":"center"}function doesNotFitWithAlign(t,e,i,s){const{x:n,width:o}=s,a=i.caretSize+i.caretPadding;return"left"===t&&n+o+a>e.width||("right"===t&&n-o-a<0||void 0)}function determineXAlign(t,e,i,s){const{x:n,width:o}=i,{width:a,chartArea:{left:r,right:l}}=t;let h="center";return"center"===s?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),doesNotFitWithAlign(h,t,e,i)&&(h="center"),h}function determineAlignment(t,e,i){const s=i.yAlign||e.yAlign||determineYAlign(t,i);return{xAlign:i.xAlign||e.xAlign||determineXAlign(t,e,i,s),yAlign:s}}function alignX(t,e){let{x:i,width:s}=t;return"right"===e?i-=s:"center"===e&&(i-=s/2),i}function alignY(t,e,i){let{y:s,height:n}=t;return"top"===e?s+=i:s-="bottom"===e?n+i:n/2,s}function getBackgroundPoint(t,e,i,s){const{caretSize:n,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,h=n+o,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:g}=toTRBLCorners(a);let f=alignX(e,r);const p=alignY(e,l,h);return"center"===l?"left"===r?f+=h:"right"===r&&(f-=h):"left"===r?f-=Math.max(c,u)+n:"right"===r&&(f+=Math.max(d,g)+n),{x:_limitValue(f,0,s.width-e.width),y:_limitValue(p,0,s.height-e.height)}}function getAlignedX(t,e,i){const s=toPadding(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-s.right:t.x+s.left}function getBeforeAfterBodyLines(t){return pushOrConcat([],splitNewlines(t))}function createTooltipContext(t,e,i){return createContext(t,{tooltip:e,tooltipItems:i,type:"tooltip"})}function overrideCallbacks(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}const defaultCallbacks={beforeTitle:noop,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,s=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex<s)return i[e.dataIndex]}return""},afterTitle:noop,beforeBody:noop,beforeLabel:noop,label(t){if(this&&this.options&&"dataset"===this.options.mode)return t.label+": "+t.formattedValue||t.formattedValue;let e=t.dataset.label||"";e&&(e+=": ");const i=t.formattedValue;return isNullOrUndef(i)||(e+=i),e},labelColor(t){const e=t.chart.getDatasetMeta(t.datasetIndex).controller.getStyle(t.dataIndex);return{borderColor:e.borderColor,backgroundColor:e.backgroundColor,borderWidth:e.borderWidth,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(t){const e=t.chart.getDatasetMeta(t.datasetIndex).controller.getStyle(t.dataIndex);return{pointStyle:e.pointStyle,rotation:e.rotation}},afterLabel:noop,afterBody:noop,beforeFooter:noop,footer:noop,afterFooter:noop};function invokeCallbackWithFallback(t,e,i,s){const n=t[e].call(i,s);return void 0===n?defaultCallbacks[e].call(i,s):n}class Tooltip extends Element{static positioners=positioners;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,n=new Animations(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(n)),n}getContext(){return this.$context||(this.$context=createTooltipContext(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:i}=e,s=invokeCallbackWithFallback(i,"beforeTitle",this,t),n=invokeCallbackWithFallback(i,"title",this,t),o=invokeCallbackWithFallback(i,"afterTitle",this,t);let a=[];return a=pushOrConcat(a,splitNewlines(s)),a=pushOrConcat(a,splitNewlines(n)),a=pushOrConcat(a,splitNewlines(o)),a}getBeforeBody(t,e){return getBeforeAfterBodyLines(invokeCallbackWithFallback(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:i}=e,s=[];return each(t,(t=>{const e={before:[],lines:[],after:[]},n=overrideCallbacks(i,t);pushOrConcat(e.before,splitNewlines(invokeCallbackWithFallback(n,"beforeLabel",this,t))),pushOrConcat(e.lines,invokeCallbackWithFallback(n,"label",this,t)),pushOrConcat(e.after,splitNewlines(invokeCallbackWithFallback(n,"afterLabel",this,t))),s.push(e)})),s}getAfterBody(t,e){return getBeforeAfterBodyLines(invokeCallbackWithFallback(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:i}=e,s=invokeCallbackWithFallback(i,"beforeFooter",this,t),n=invokeCallbackWithFallback(i,"footer",this,t),o=invokeCallbackWithFallback(i,"afterFooter",this,t);let a=[];return a=pushOrConcat(a,splitNewlines(s)),a=pushOrConcat(a,splitNewlines(n)),a=pushOrConcat(a,splitNewlines(o)),a}_createItems(t){const e=this._active,i=this.chart.data,s=[],n=[],o=[];let a,r,l=[];for(a=0,r=e.length;a<r;++a)l.push(createTooltipItem(this.chart,e[a]));return t.filter&&(l=l.filter(((e,s,n)=>t.filter(e,s,n,i)))),t.itemSort&&(l=l.sort(((e,s)=>t.itemSort(e,s,i)))),each(l,(e=>{const i=overrideCallbacks(t.callbacks,e);s.push(invokeCallbackWithFallback(i,"labelColor",this,e)),n.push(invokeCallbackWithFallback(i,"labelPointStyle",this,e)),o.push(invokeCallbackWithFallback(i,"labelTextColor",this,e))})),this.labelColors=s,this.labelPointStyles=n,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let n,o=[];if(s.length){const t=positioners[i.position].call(this,s,this._eventPosition);o=this._createItems(i),this.title=this.getTitle(o,i),this.beforeBody=this.getBeforeBody(o,i),this.body=this.getBody(o,i),this.afterBody=this.getAfterBody(o,i),this.footer=this.getFooter(o,i);const e=this._size=getTooltipSize(this,i),a=Object.assign({},t,e),r=determineAlignment(this.chart,i,a),l=getBackgroundPoint(i,a,r,this.chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=o,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const n=this.getCaretPosition(t,i,s);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:n}=this,{caretSize:o,cornerRadius:a}=i,{topLeft:r,topRight:l,bottomLeft:h,bottomRight:c}=toTRBLCorners(a),{x:d,y:u}=t,{width:g,height:f}=e;let p,m,b,x,_,y;return"center"===n?(_=u+f/2,"left"===s?(p=d,m=p-o,x=_+o,y=_-o):(p=d+g,m=p+o,x=_-o,y=_+o),b=p):(m="left"===s?d+Math.max(r,h)+o:"right"===s?d+g-Math.max(l,c)-o:this.caretX,"top"===n?(x=u,_=x-o,p=m-o,b=m+o):(x=u+f,_=x+o,p=m+o,b=m-o),y=x),{x1:p,x2:m,x3:b,y1:x,y2:_,y3:y}}drawTitle(t,e,i){const s=this.title,n=s.length;let o,a,r;if(n){const l=getRtlAdapter(i.rtl,this.x,this.width);for(t.x=getAlignedX(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",o=toFont(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=o.string,r=0;r<n;++r)e.fillText(s[r],l.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+a,r+1===n&&(t.y+=i.titleMarginBottom-a)}}_drawColorBox(t,e,i,s,n){const o=this.labelColors[i],a=this.labelPointStyles[i],{boxHeight:r,boxWidth:l,boxPadding:h}=n,c=toFont(n.bodyFont),d=getAlignedX(this,"left",n),u=s.x(d),g=r<c.lineHeight?(c.lineHeight-r)/2:0,f=e.y+g;if(n.usePointStyle){const e={radius:Math.min(l,r)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},i=s.leftForLtr(u,l)+l/2,h=f+r/2;t.strokeStyle=n.multiKeyBackground,t.fillStyle=n.multiKeyBackground,drawPoint(t,e,i,h),t.strokeStyle=o.borderColor,t.fillStyle=o.backgroundColor,drawPoint(t,e,i,h)}else{t.lineWidth=isObject(o.borderWidth)?Math.max(...Object.values(o.borderWidth)):o.borderWidth||1,t.strokeStyle=o.borderColor,t.setLineDash(o.borderDash||[]),t.lineDashOffset=o.borderDashOffset||0;const e=s.leftForLtr(u,l-h),i=s.leftForLtr(s.xPlus(u,1),l-h-2),a=toTRBLCorners(o.borderRadius);Object.values(a).some((t=>0!==t))?(t.beginPath(),t.fillStyle=n.multiKeyBackground,addRoundedRectPath(t,{x:e,y:f,w:l,h:r,radius:a}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),addRoundedRectPath(t,{x:i,y:f+1,w:l-2,h:r-2,radius:a}),t.fill()):(t.fillStyle=n.multiKeyBackground,t.fillRect(e,f,l,r),t.strokeRect(e,f,l,r),t.fillStyle=o.backgroundColor,t.fillRect(i,f+1,l-2,r-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:n,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:h}=i,c=toFont(i.bodyFont);let d=c.lineHeight,u=0;const g=getRtlAdapter(i.rtl,this.x,this.width),f=function(i){e.fillText(i,g.x(t.x+u),t.y+d/2),t.y+=d+n},p=g.textAlign(o);let m,b,x,_,y,v,S;for(e.textAlign=o,e.textBaseline="middle",e.font=c.string,t.x=getAlignedX(this,p,i),e.fillStyle=i.bodyColor,each(this.beforeBody,f),u=a&&"right"!==p?"center"===o?l/2+h:l+2+h:0,_=0,v=s.length;_<v;++_){for(m=s[_],b=this.labelTextColors[_],e.fillStyle=b,each(m.before,f),x=m.lines,a&&x.length&&(this._drawColorBox(e,t,_,g,i),d=Math.max(c.lineHeight,r)),y=0,S=x.length;y<S;++y)f(x[y]),d=c.lineHeight;each(m.after,f)}u=0,d=c.lineHeight,each(this.afterBody,f),t.y-=n}drawFooter(t,e,i){const s=this.footer,n=s.length;let o,a;if(n){const r=getRtlAdapter(i.rtl,this.x,this.width);for(t.x=getAlignedX(this,i.footerAlign,i),t.y+=i.footerMarginTop,e.textAlign=r.textAlign(i.footerAlign),e.textBaseline="middle",o=toFont(i.footerFont),e.fillStyle=i.footerColor,e.font=o.string,a=0;a<n;++a)e.fillText(s[a],r.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+i.footerSpacing}}drawBackground(t,e,i,s){const{xAlign:n,yAlign:o}=this,{x:a,y:r}=t,{width:l,height:h}=i,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:g}=toTRBLCorners(s.cornerRadius);e.fillStyle=s.backgroundColor,e.strokeStyle=s.borderColor,e.lineWidth=s.borderWidth,e.beginPath(),e.moveTo(a+c,r),"top"===o&&this.drawCaret(t,e,i,s),e.lineTo(a+l-d,r),e.quadraticCurveTo(a+l,r,a+l,r+d),"center"===o&&"right"===n&&this.drawCaret(t,e,i,s),e.lineTo(a+l,r+h-g),e.quadraticCurveTo(a+l,r+h,a+l-g,r+h),"bottom"===o&&this.drawCaret(t,e,i,s),e.lineTo(a+u,r+h),e.quadraticCurveTo(a,r+h,a,r+h-u),"center"===o&&"left"===n&&this.drawCaret(t,e,i,s),e.lineTo(a,r+c),e.quadraticCurveTo(a,r,a+c,r),e.closePath(),e.fill(),s.borderWidth>0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,s=i&&i.x,n=i&&i.y;if(s||n){const i=positioners[t.position].call(this,this._active,this._eventPosition);if(!i)return;const o=this._size=getTooltipSize(this,t),a=Object.assign({},i,this._size),r=determineAlignment(e,t,a),l=getBackgroundPoint(t,a,r,e);s._to===l.x&&n._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,l))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const o=toPadding(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,s,e),overrideTextDirection(t,e.textDirection),n.y+=o.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),restoreTextDirection(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map((({datasetIndex:t,index:e})=>{const i=this.chart.getDatasetMeta(t);if(!i)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:i.data[e],index:e}})),n=!_elementsEqual(i,s),o=this._positionChanged(s,e);(n||o)&&(this._active=s,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,i=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,n=this._active||[],o=this._getActiveElements(t,n,e,i),a=this._positionChanged(o,t),r=e||!_elementsEqual(o,n)||a;return r&&(this._active=o,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),r}_getActiveElements(t,e,i,s){const n=this.options;if("mouseout"===t.type)return[];if(!s)return e;const o=this.chart.getElementsAtEventForMode(t,n.mode,n,i);return n.reverse&&o.reverse(),o}_positionChanged(t,e){const{caretX:i,caretY:s,options:n}=this,o=positioners[n.position].call(this,t,e);return!1!==o&&(i!==o.x||s!==o.y)}}var plugin_tooltip={id:"tooltip",_element:Tooltip,positioners,afterInit(t,e,i){i&&(t.tooltip=new Tooltip({chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const i={tooltip:e};if(!1===t.notifyPlugins("beforeTooltipDraw",{...i,cancelable:!0}))return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i)}},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i,e.inChartArea)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:defaultCallbacks},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:t=>"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},plugins=Object.freeze({__proto__:null,Colors:plugin_colors,Decimation:plugin_decimation,Filler:index,Legend:plugin_legend,SubTitle:plugin_subtitle,Title:plugin_title,Tooltip:plugin_tooltip});const addIfString=(t,e,i,s)=>("string"==typeof e?(i=t.push(e)-1,s.unshift({index:i,label:e})):isNaN(e)&&(i=null),i);function findOrAddLabel(t,e,i,s){const n=t.indexOf(e);if(-1===n)return addIfString(t,e,i,s);return n!==t.lastIndexOf(e)?i:n}const validIndex=(t,e)=>null===t?null:_limitValue(Math.round(t),0,e);function _getLabelForValue(t){const e=this.getLabels();return t>=0&&t<e.length?e[t]:t}class CategoryScale extends Scale{static id="category";static defaults={ticks:{callback:_getLabelForValue}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const e=this._addedLabels;if(e.length){const t=this.getLabels();for(const{index:i,label:s}of e)t[i]===s&&t.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(isNullOrUndef(t))return null;const i=this.getLabels();return e=isFinite(e)&&i[e]===t?e:findOrAddLabel(i,t,valueOrDefault(e,t),this._addedLabels),validIndex(e,i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,e=this.max,i=this.options.offset,s=[];let n=this.getLabels();n=0===t&&e===n.length-1?n:n.slice(t,e+1),this._valueRange=Math.max(n.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let i=t;i<=e;i++)s.push({value:i});return s}getLabelForValue(t){return _getLabelForValue.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return"number"!=typeof t&&(t=this.parse(t)),null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function generateTicks$1(t,e){const i=[],{bounds:s,step:n,min:o,max:a,precision:r,count:l,maxTicks:h,maxDigits:c,includeBounds:d}=t,u=n||1,g=h-1,{min:f,max:p}=e,m=!isNullOrUndef(o),b=!isNullOrUndef(a),x=!isNullOrUndef(l),_=(p-f)/(c+1);let y,v,S,k,P=niceNum((p-f)/g/u)*u;if(P<1e-14&&!m&&!b)return[{value:f},{value:p}];k=Math.ceil(p/P)-Math.floor(f/P),k>g&&(P=niceNum(k*P/g/u)*u),isNullOrUndef(r)||(y=Math.pow(10,r),P=Math.ceil(P*y)/y),"ticks"===s?(v=Math.floor(f/P)*P,S=Math.ceil(p/P)*P):(v=f,S=p),m&&b&&n&&almostWhole((a-o)/n,P/1e3)?(k=Math.round(Math.min((a-o)/P,h)),P=(a-o)/k,v=o,S=a):x?(v=m?o:v,S=b?a:S,k=l-1,P=(S-v)/k):(k=(S-v)/P,k=almostEquals(k,Math.round(k),P/1e3)?Math.round(k):Math.ceil(k));const M=Math.max(_decimalPlaces(P),_decimalPlaces(v));y=Math.pow(10,isNullOrUndef(r)?M:r),v=Math.round(v*y)/y,S=Math.round(S*y)/y;let w=0;for(m&&(d&&v!==o?(i.push({value:o}),v<o&&w++,almostEquals(Math.round((v+w*P)*y)/y,o,relativeLabelSize(o,_,t))&&w++):v<o&&w++);w<k;++w)i.push({value:Math.round((v+w*P)*y)/y});return b&&d&&S!==a?i.length&&almostEquals(i[i.length-1].value,a,relativeLabelSize(a,_,t))?i[i.length-1].value=a:i.push({value:a}):b&&S!==a||i.push({value:S}),i}function relativeLabelSize(t,e,{horizontal:i,minRotation:s}){const n=toRadians(s),o=(i?Math.sin(n):Math.cos(n))||.001,a=.75*e*(""+t).length;return Math.min(e/o,a)}class LinearScaleBase extends Scale{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return isNullOrUndef(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:n}=this;const o=t=>s=e?s:t,a=t=>n=i?n:t;if(t){const t=sign(s),e=sign(n);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(s===n){let e=0===n?1:Math.abs(.05*n);a(n+e),t||o(s-e)}this.min=s,this.max=n}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:i,stepSize:s}=t;return s?(e=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),i=i||11),i&&(e=Math.min(i,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const s=generateTicks$1({maxTicks:i,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:!1!==e.includeBounds},this._range||this);return"ticks"===t.bounds&&_setMinAndMaxByKey(s,this,"value"),t.reverse?(s.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),s}configure(){const t=this.ticks;let e=this.min,i=this.max;if(super.configure(),this.options.offset&&t.length){const s=(i-e)/Math.max(t.length-1,1)/2;e-=s,i+=s}this._startValue=e,this._endValue=i,this._valueRange=i-e}getLabelForValue(t){return formatNumber(t,this.chart.options.locale,this.options.ticks.format)}}class LinearScale extends LinearScaleBase{static id="linear";static defaults={ticks:{callback:Ticks.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=isNumberFinite(t)?t:0,this.max=isNumberFinite(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,i=toRadians(this.options.ticks.minRotation),s=(t?Math.sin(i):Math.cos(i))||.001,n=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,n.lineHeight/s))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const log10Floor=t=>Math.floor(log10(t)),changeExponent=(t,e)=>Math.pow(10,log10Floor(t)+e);function isMajor(t){return 1===t/Math.pow(10,log10Floor(t))}function steps(t,e,i){const s=Math.pow(10,i),n=Math.floor(t/s);return Math.ceil(e/s)-n}function startExp(t,e){let i=log10Floor(e-t);for(;steps(t,e,i)>10;)i++;for(;steps(t,e,i)<10;)i--;return Math.min(i,log10Floor(t))}function generateTicks(t,{min:e,max:i}){e=finiteOrDefault(t.min,e);const s=[],n=log10Floor(e);let o=startExp(e,i),a=o<0?Math.pow(10,Math.abs(o)):1;const r=Math.pow(10,o),l=n>o?Math.pow(10,n):0,h=Math.round((e-l)*a)/a,c=Math.floor((e-l)/r/10)*r*10;let d=Math.floor((h-c)/Math.pow(10,o)),u=finiteOrDefault(t.min,Math.round((l+c+d*Math.pow(10,o))*a)/a);for(;u<i;)s.push({value:u,major:isMajor(u),significand:d}),d>=10?d=d<15?15:20:d++,d>=20&&(o++,d=2,a=o>=0?1:a),u=Math.round((l+c+d*Math.pow(10,o))*a)/a;const g=finiteOrDefault(t.max,u);return s.push({value:g,major:isMajor(g),significand:d}),s}class LogarithmicScale extends Scale{static id="logarithmic";static defaults={ticks:{callback:Ticks.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const i=LinearScaleBase.prototype.parse.apply(this,[t,e]);if(0!==i)return isNumberFinite(i)&&i>0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=isNumberFinite(t)?Math.max(0,t):null,this.max=isNumberFinite(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!isNumberFinite(this._userMin)&&(this.min=t===changeExponent(this.min,0)?changeExponent(this.min,-1):changeExponent(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const n=e=>i=t?i:e,o=t=>s=e?s:t;i===s&&(i<=0?(n(1),o(10)):(n(changeExponent(i,-1)),o(changeExponent(s,1)))),i<=0&&n(changeExponent(s,-1)),s<=0&&o(changeExponent(i,1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e=generateTicks({min:this._userMin,max:this._userMax},this);return"ticks"===t.bounds&&_setMinAndMaxByKey(e,this,"value"),t.reverse?(e.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),e}getLabelForValue(t){return void 0===t?"0":formatNumber(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=log10(t),this._valueRange=log10(this.max)-log10(t)}getPixelForValue(t){return void 0!==t&&0!==t||(t=this.min),null===t||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(log10(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function getTickBackdropHeight(t){const e=t.ticks;if(e.display&&t.display){const t=toPadding(e.backdropPadding);return valueOrDefault(e.font&&e.font.size,defaults.font.size)+t.height}return 0}function measureLabelSize(t,e,i){return i=isArray(i)?i:[i],{w:_longestText(t,e.string,i),h:i.length*e.lineHeight}}function determineLimits(t,e,i,s,n){return t===s||t===n?{start:e-i/2,end:e+i/2}:t<s||t>n?{start:e-i,end:e}:{start:e,end:e+i}}function fitWithPointLabels(t){const e={l:t.left+t._padding.left,r:t.right-t._padding.right,t:t.top+t._padding.top,b:t.bottom-t._padding.bottom},i=Object.assign({},e),s=[],n=[],o=t._pointLabels.length,a=t.options.pointLabels,r=a.centerPointLabels?PI/o:0;for(let l=0;l<o;l++){const o=a.setContext(t.getPointLabelContext(l));n[l]=o.padding;const h=t.getPointPosition(l,t.drawingArea+n[l],r),c=toFont(o.font),d=measureLabelSize(t.ctx,c,t._pointLabels[l]);s[l]=d;const u=_normalizeAngle(t.getIndexAngle(l)+r),g=Math.round(toDegrees(u));updateLimits(i,e,u,determineLimits(g,h.x,d.w,0,180),determineLimits(g,h.y,d.h,90,270))}t.setCenterPoint(e.l-i.l,i.r-e.r,e.t-i.t,i.b-e.b),t._pointLabelItems=buildPointLabelItems(t,s,n)}function updateLimits(t,e,i,s,n){const o=Math.abs(Math.sin(i)),a=Math.abs(Math.cos(i));let r=0,l=0;s.start<e.l?(r=(e.l-s.start)/o,t.l=Math.min(t.l,e.l-r)):s.end>e.r&&(r=(s.end-e.r)/o,t.r=Math.max(t.r,e.r+r)),n.start<e.t?(l=(e.t-n.start)/a,t.t=Math.min(t.t,e.t-l)):n.end>e.b&&(l=(n.end-e.b)/a,t.b=Math.max(t.b,e.b+l))}function buildPointLabelItems(t,e,i){const s=[],n=t._pointLabels.length,o=t.options,a=getTickBackdropHeight(o)/2,r=t.drawingArea,l=o.pointLabels.centerPointLabels?PI/n:0;for(let o=0;o<n;o++){const n=t.getPointPosition(o,r+a+i[o],l),h=Math.round(toDegrees(_normalizeAngle(n.angle+HALF_PI))),c=e[o],d=yForAngle(n.y,c.h,h),u=getTextAlignForAngle(h),g=leftForTextAlign(n.x,c.w,u);s.push({x:n.x,y:d,textAlign:u,left:g,top:d,right:g+c.w,bottom:d+c.h})}return s}function getTextAlignForAngle(t){return 0===t||180===t?"center":t<180?"left":"right"}function leftForTextAlign(t,e,i){return"right"===i?t-=e:"center"===i&&(t-=e/2),t}function yForAngle(t,e,i){return 90===i||270===i?t-=e/2:(i>270||i<90)&&(t-=e),t}function drawPointLabels(t,e){const{ctx:i,options:{pointLabels:s}}=t;for(let n=e-1;n>=0;n--){const e=s.setContext(t.getPointLabelContext(n)),o=toFont(e.font),{x:a,y:r,textAlign:l,left:h,top:c,right:d,bottom:u}=t._pointLabelItems[n],{backdropColor:g}=e;if(!isNullOrUndef(g)){const t=toTRBLCorners(e.borderRadius),s=toPadding(e.backdropPadding);i.fillStyle=g;const n=h-s.left,o=c-s.top,a=d-h+s.width,r=u-c+s.height;Object.values(t).some((t=>0!==t))?(i.beginPath(),addRoundedRectPath(i,{x:n,y:o,w:a,h:r,radius:t}),i.fill()):i.fillRect(n,o,a,r)}renderText(i,t._pointLabels[n],a,r+o.lineHeight/2,o,{color:e.color,textAlign:l,textBaseline:"middle"})}}function pathRadiusLine(t,e,i,s){const{ctx:n}=t;if(i)n.arc(t.xCenter,t.yCenter,e,0,TAU);else{let i=t.getPointPosition(0,e);n.moveTo(i.x,i.y);for(let o=1;o<s;o++)i=t.getPointPosition(o,e),n.lineTo(i.x,i.y)}}function drawRadiusLine(t,e,i,s,n){const o=t.ctx,a=e.circular,{color:r,lineWidth:l}=e;!a&&!s||!r||!l||i<0||(o.save(),o.strokeStyle=r,o.lineWidth=l,o.setLineDash(n.dash),o.lineDashOffset=n.dashOffset,o.beginPath(),pathRadiusLine(t,i,a,s),o.closePath(),o.stroke(),o.restore())}function createPointLabelContext(t,e,i){return createContext(t,{label:i,index:e,type:"pointLabel"})}class RadialLinearScale extends LinearScaleBase{static id="radialLinear";static defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ticks.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:t=>t,padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=toPadding(getTickBackdropHeight(this.options)/2),e=this.width=this.maxWidth-t.width,i=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+i/2+t.top),this.drawingArea=Math.floor(Math.min(e,i)/2)}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!1);this.min=isNumberFinite(t)&&!isNaN(t)?t:0,this.max=isNumberFinite(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/getTickBackdropHeight(this.options))}generateTickLabels(t){LinearScaleBase.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map(((t,e)=>{const i=callback(this.options.pointLabels.callback,[t,e],this);return i||0===i?i:""})).filter(((t,e)=>this.chart.getDataVisibility(e)))}fit(){const t=this.options;t.display&&t.pointLabels.display?fitWithPointLabels(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,i,s){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((i-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,i,s))}getIndexAngle(t){return _normalizeAngle(t*(TAU/(this._pointLabels.length||1))+toRadians(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(isNullOrUndef(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(isNullOrUndef(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t<e.length){const i=e[t];return createPointLabelContext(this.getContext(),t,i)}}getPointPosition(t,e,i=0){const s=this.getIndexAngle(t)-HALF_PI+i;return{x:Math.cos(s)*e+this.xCenter,y:Math.sin(s)*e+this.yCenter,angle:s}}getPointPositionForValue(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){const{left:e,top:i,right:s,bottom:n}=this._pointLabelItems[t];return{left:e,top:i,right:s,bottom:n}}drawBackground(){const{backgroundColor:t,grid:{circular:e}}=this.options;if(t){const i=this.ctx;i.save(),i.beginPath(),pathRadiusLine(this,this.getDistanceFromCenterForValue(this._endValue),e,this._pointLabels.length),i.closePath(),i.fillStyle=t,i.fill(),i.restore()}}drawGrid(){const t=this.ctx,e=this.options,{angleLines:i,grid:s,border:n}=e,o=this._pointLabels.length;let a,r,l;if(e.pointLabels.display&&drawPointLabels(this,o),s.display&&this.ticks.forEach(((t,e)=>{if(0!==e){r=this.getDistanceFromCenterForValue(t.value);const i=this.getContext(e),a=s.setContext(i),l=n.setContext(i);drawRadiusLine(this,a,r,o,l)}})),i.display){for(t.save(),a=o-1;a>=0;a--){const s=i.setContext(this.getPointLabelContext(a)),{color:n,lineWidth:o}=s;o&&n&&(t.lineWidth=o,t.strokeStyle=n,t.setLineDash(s.borderDash),t.lineDashOffset=s.borderDashOffset,r=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),l=this.getPointPosition(a,r),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(l.x,l.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let n,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach(((s,a)=>{if(0===a&&!e.reverse)return;const r=i.setContext(this.getContext(a)),l=toFont(r.font);if(n=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(s.label).width,t.fillStyle=r.backdropColor;const e=toPadding(r.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}renderText(t,s.label,0,-n,l,{color:r.color})})),t.restore()}drawTitle(){}}const INTERVALS={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},UNITS=Object.keys(INTERVALS);function sorter(t,e){return t-e}function parse(t,e){if(isNullOrUndef(e))return null;const i=t._adapter,{parser:s,round:n,isoWeekday:o}=t._parseOpts;let a=e;return"function"==typeof s&&(a=s(a)),isNumberFinite(a)||(a="string"==typeof s?i.parse(a,s):i.parse(a)),null===a?null:(n&&(a="week"!==n||!isNumber(o)&&!0!==o?i.startOf(a,n):i.startOf(a,"isoWeek",o)),+a)}function determineUnitForAutoTicks(t,e,i,s){const n=UNITS.length;for(let o=UNITS.indexOf(t);o<n-1;++o){const t=INTERVALS[UNITS[o]],n=t.steps?t.steps:Number.MAX_SAFE_INTEGER;if(t.common&&Math.ceil((i-e)/(n*t.size))<=s)return UNITS[o]}return UNITS[n-1]}function determineUnitForFormatting(t,e,i,s,n){for(let o=UNITS.length-1;o>=UNITS.indexOf(i);o--){const i=UNITS[o];if(INTERVALS[i].common&&t._adapter.diff(n,s,i)>=e-1)return i}return UNITS[i?UNITS.indexOf(i):0]}function determineMajorUnit(t){for(let e=UNITS.indexOf(t)+1,i=UNITS.length;e<i;++e)if(INTERVALS[UNITS[e]].common)return UNITS[e]}function addTick(t,e,i){if(i){if(i.length){const{lo:s,hi:n}=_lookup(i,e);t[i[s]>=e?i[s]:i[n]]=!0}}else t[e]=!0}function setMajorTicks(t,e,i,s){const n=t._adapter,o=+n.startOf(e[0].value,s),a=e[e.length-1].value;let r,l;for(r=o;r<=a;r=+n.add(r,1,s))l=i[r],l>=0&&(e[l].major=!0);return e}function ticksFromTimestamps(t,e,i){const s=[],n={},o=e.length;let a,r;for(a=0;a<o;++a)r=e[a],n[r]=a,s.push({value:r,major:!1});return 0!==o&&i?setMajorTicks(t,s,n,i):s}class TimeScale extends Scale{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e={}){const i=t.time||(t.time={}),s=this._adapter=new adapters._date(t.adapters.date);s.init(e),mergeIf(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:parse(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,i=t.time.unit||"day";let{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();function r(t){o||isNaN(t.min)||(s=Math.min(s,t.min)),a||isNaN(t.max)||(n=Math.max(n,t.max))}o&&a||(r(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||r(this.getMinMax(!1))),s=isNumberFinite(s)&&!isNaN(s)?s:+e.startOf(Date.now(),i),n=isNumberFinite(n)&&!isNaN(n)?n:+e.endOf(Date.now(),i)+1,this.min=Math.min(s,n-1),this.max=Math.max(s+1,n)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this.options,e=t.time,i=t.ticks,s="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const n=this.min,o=_filterBetween(s,n,this.max);return this._unit=e.unit||(i.autoSkip?determineUnitForAutoTicks(e.minUnit,this.min,this.max,this._getLabelCapacity(n)):determineUnitForFormatting(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?determineMajorUnit(this._unit):void 0,this.initOffsets(s),t.reverse&&o.reverse(),ticksFromTimestamps(this,o,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map((t=>+t.value)))}initOffsets(t=[]){let e,i,s=0,n=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),s=1===t.length?1-e:(this.getDecimalForValue(t[1])-e)/2,i=this.getDecimalForValue(t[t.length-1]),n=1===t.length?i:(i-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;s=_limitValue(s,0,o),n=_limitValue(n,0,o),this._offsets={start:s,end:n,factor:1/(s+1+n)}}_generate(){const t=this._adapter,e=this.min,i=this.max,s=this.options,n=s.time,o=n.unit||determineUnitForAutoTicks(n.minUnit,e,i,this._getLabelCapacity(e)),a=valueOrDefault(s.ticks.stepSize,1),r="week"===o&&n.isoWeekday,l=isNumber(r)||!0===r,h={};let c,d,u=e;if(l&&(u=+t.startOf(u,"isoWeek",r)),u=+t.startOf(u,l?"day":o),t.diff(i,e,o)>1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+o);const g="data"===s.ticks.source&&this.getDataTimestamps();for(c=u,d=0;c<i;c=+t.add(c,a,o),d++)addTick(h,c,g);return c!==i&&"ticks"!==s.bounds&&1!==d||addTick(h,c,g),Object.keys(h).sort(((t,e)=>t-e)).map((t=>+t))}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}format(t,e){const i=this.options.time.displayFormats,s=this._unit,n=e||i[s];return this._adapter.format(t,n)}_tickFormatFunction(t,e,i,s){const n=this.options,o=n.ticks.callback;if(o)return callback(o,[t,e,i],this);const a=n.time.displayFormats,r=this._unit,l=this._majorUnit,h=r&&a[r],c=l&&a[l],d=i[e],u=l&&c&&d&&d.major;return this._adapter.format(t,s||(u?c:h))}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e<i;++e)s=t[e],s.label=this._tickFormatFunction(s.value,e,t)}getDecimalForValue(t){return null===t?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const e=this._offsets,i=this.getDecimalForValue(t);return this.getPixelForDecimal((e.start+i)*e.factor)}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return this.min+i*(this.max-this.min)}_getLabelSize(t){const e=this.options.ticks,i=this.ctx.measureText(t).width,s=toRadians(this.isHorizontal()?e.maxRotation:e.minRotation),n=Math.cos(s),o=Math.sin(s),a=this._resolveTickFontOptions(0).size;return{w:i*n+a*o,h:i*o+a*n}}_getLabelCapacity(t){const e=this.options.time,i=e.displayFormats,s=i[e.unit]||i.millisecond,n=this._tickFormatFunction(t,0,ticksFromTimestamps(this,[t],this._majorUnit),s),o=this._getLabelSize(n),a=Math.floor(this.isHorizontal()?this.width/o.w:this.height/o.h)-1;return a>0?a:1}getDataTimestamps(){let t,e,i=this._cache.data||[];if(i.length)return i;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(t=0,e=s.length;t<e;++t)i=i.concat(s[t].controller.getAllParsedValues(this));return this._cache.data=this.normalize(i)}getLabelTimestamps(){const t=this._cache.labels||[];let e,i;if(t.length)return t;const s=this.getLabels();for(e=0,i=s.length;e<i;++e)t.push(parse(this,s[e]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return _arrayUnique(t.sort(sorter))}}function interpolate(t,e,i){let s,n,o,a,r=0,l=t.length-1;i?(e>=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=_lookupByKey(t,"pos",e)),({pos:s,time:o}=t[r]),({pos:n,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=_lookupByKey(t,"time",e)),({time:s,pos:o}=t[r]),({time:n,pos:a}=t[l]));const h=n-s;return h?o+(a-o)*(e-s)/h:o}class TimeSeriesScale extends TimeScale{static id="timeseries";static defaults=TimeScale.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=interpolate(e,this.min),this._tableRange=interpolate(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],n=[];let o,a,r,l,h;for(o=0,a=t.length;o<a;++o)l=t[o],l>=e&&l<=i&&s.push(l);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(o=0,a=s.length;o<a;++o)h=s[o+1],r=s[o-1],l=s[o],Math.round((h+r)/2)!==l&&n.push({time:l,pos:o/(a-1)});return n}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),i=this.getLabelTimestamps();return t=e.length&&i.length?this.normalize(e.concat(i)):e.length?e:i,t=this._cache.all=t,t}getDecimalForValue(t){return(interpolate(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return interpolate(this._table,i*this._tableRange+this._minPos,!0)}}var scales=Object.freeze({__proto__:null,CategoryScale,LinearScale,LogarithmicScale,RadialLinearScale,TimeScale,TimeSeriesScale});const registerables=[controllers,elements,plugins,scales];export{Animation,Animations,ArcElement,BarController,BarElement,BasePlatform,BasicPlatform,BubbleController,CategoryScale,Chart,plugin_colors as Colors,DatasetController,plugin_decimation as Decimation,DomPlatform,DoughnutController,Element,index as Filler,Interaction,plugin_legend as Legend,LineController,LineElement,LinearScale,LogarithmicScale,PieController,PointElement,PolarAreaController,RadarController,RadialLinearScale,Scale,ScatterController,plugin_subtitle as SubTitle,Ticks,TimeScale,TimeSeriesScale,plugin_title as Title,plugin_tooltip as Tooltip,adapters as _adapters,_detectPlatform,animator,controllers,defaults,elements,layouts,plugins,registerables,registry,scales}; + */class Animator{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,s){const n=e.listeners[s],o=e.duration;n.forEach((s=>s({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(i-e.start,o)})))}_refresh(){this._request||(this._running=!0,this._request=requestAnimFrame.call(window,(()=>{this._update(),this._request=null,this._running&&this._refresh()})))}_update(t=Date.now()){let e=0;this._charts.forEach(((i,s)=>{if(!i.running||!i.items.length)return;const n=i.items;let o,a=n.length-1,r=!1;for(;a>=0;--a)o=n[a],o._active?(o._total>i.duration&&(i.duration=o._total),o.tick(t),r=!0):(n[a]=n[n.length-1],n.pop());r&&(s.draw(),this._notify(s,i,t,"progress")),n.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),e+=n.length})),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce(((t,e)=>Math.max(t,e._duration)),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var animator=new Animator;const transparent="transparent",interpolators={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const s=color(t||transparent),n=s.valid&&color(e||transparent);return n&&n.valid?n.mix(s,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class Animation{constructor(t,e,i,s){const n=e[i];s=resolve([t.to,s,n,t.from]);const o=resolve([t.from,n,s]);this._active=!0,this._fn=t.fn||interpolators[t.type||typeof o],this._easing=effects[t.easing]||effects.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=o,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],n=i-this._start,o=this._duration-n;this._start=i,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=resolve([t.to,e,s,t.from]),this._from=resolve([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,n=this._from,o=this._loop,a=this._to;let r;if(this._active=n!==a&&(o||e<i),!this._active)return this._target[s]=a,void this._notify(!0);e<0?this._target[s]=n:(r=e/i%2,r=o&&r>1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[s]=this._fn(n,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,i)=>{t.push({res:e,rej:i})}))}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t<i.length;t++)i[t][e]()}}class Animations{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!isObject(t))return;const e=Object.keys(defaults.animation),i=this._properties;Object.getOwnPropertyNames(t).forEach((s=>{const n=t[s];if(!isObject(n))return;const o={};for(const t of e)o[t]=n[t];(isArray(n.properties)&&n.properties||[s]).forEach((t=>{t!==s&&i.has(t)||i.set(t,o)}))}))}_animateOptions(t,e){const i=e.options,s=resolveTargetOptions(t,i);if(!s)return[];const n=this._createAnimations(s,i);return i.$shared&&awaitAll(t.options.$animations,i).then((()=>{t.options=i}),(()=>{})),n}_createAnimations(t,e){const i=this._properties,s=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),a=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if("$"===l.charAt(0))continue;if("options"===l){s.push(...this._animateOptions(t,e));continue}const h=e[l];let c=n[l];const d=i.get(l);if(c){if(d&&c.active()){c.update(d,h,a);continue}c.cancel()}d&&d.duration?(n[l]=c=new Animation(d,t,l,h),s.push(c)):t[l]=h}return s}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(animator.add(this._chart,i),!0):void 0}}function awaitAll(t,e){const i=[],s=Object.keys(e);for(let e=0;e<s.length;e++){const n=t[s[e]];n&&n.active()&&i.push(n.wait())}return Promise.all(i)}function resolveTargetOptions(t,e){if(!e)return;let i=t.options;if(i)return i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}})),i;t.options=e}function scaleClip(t,e){const i=t&&t.options||{},s=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:s?o:n,end:s?n:o}}function defaultClip(t,e,i){if(!1===i)return!1;const s=scaleClip(t,i),n=scaleClip(e,i);return{top:n.end,right:s.end,bottom:n.start,left:s.start}}function toClip(t){let e,i,s,n;return isObject(t)?(e=t.top,i=t.right,s=t.bottom,n=t.left):e=i=s=n=t,{top:e,right:i,bottom:s,left:n,disabled:!1===t}}function getSortedDatasetIndices(t,e){const i=[],s=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=s.length;n<o;++n)i.push(s[n].index);return i}function applyStack(t,e,i,s={}){const n=t.keys,o="single"===s.mode;let a,r,l,h;if(null!==e){for(a=0,r=n.length;a<r;++a){if(l=+n[a],l===i){if(s.all)continue;break}h=t.values[l],isNumberFinite(h)&&(o||0===e||sign(e)===sign(h))&&(e+=h)}return e}}function convertObjectDataToArray(t){const e=Object.keys(t),i=new Array(e.length);let s,n,o;for(s=0,n=e.length;s<n;++s)o=e[s],i[s]={x:o,y:t[o]};return i}function isStacked(t,e){const i=t&&t.options.stacked;return i||void 0===i&&void 0!==e.stack}function getStackKey(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}function getUserBounds(t){const{min:e,max:i,minDefined:s,maxDefined:n}=t.getUserBounds();return{min:s?e:Number.NEGATIVE_INFINITY,max:n?i:Number.POSITIVE_INFINITY}}function getOrCreateStack(t,e,i){const s=t[e]||(t[e]={});return s[i]||(s[i]={})}function getLastIndexInStack(t,e,i,s){for(const n of e.getMatchingVisibleMetas(s).reverse()){const e=t[n.index];if(i&&e>0||!i&&e<0)return n.index}return null}function updateStacks(t,e){const{chart:i,_cachedMeta:s}=t,n=i._stacks||(i._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,c=getStackKey(o,a,s),d=e.length;let u;for(let t=0;t<d;++t){const i=e[t],{[l]:o,[h]:d}=i;u=(i._stacks||(i._stacks={}))[h]=getOrCreateStack(n,c,o),u[r]=d,u._top=getLastIndexInStack(u,a,!0,s.type),u._bottom=getLastIndexInStack(u,a,!1,s.type);(u._visualValues||(u._visualValues={}))[r]=d}}function getFirstScaleId(t,e){const i=t.scales;return Object.keys(i).filter((t=>i[t].axis===e)).shift()}function createDatasetContext(t,e){return createContext(t,{active:!1,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}function createDataContext(t,e,i){return createContext(t,{active:!1,dataIndex:e,parsed:void 0,raw:void 0,element:i,index:e,mode:"default",type:"data"})}function clearStacks(t,e){const i=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[s]||void 0===e[s][i])return;delete e[s][i],void 0!==e[s]._visualValues&&void 0!==e[s]._visualValues[i]&&delete e[s]._visualValues[i]}}}const isDirectUpdateMode=t=>"reset"===t||"none"===t,cloneIfNotShared=(t,e)=>e?t:Object.assign({},t),createStack=(t,e,i)=>t&&!e.hidden&&e._stacked&&{keys:getSortedDatasetIndices(i,!0),values:null};class DatasetController{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=isStacked(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&clearStacks(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(t,e,i,s)=>"x"===t?e:"r"===t?s:i,n=e.xAxisID=valueOrDefault(i.xAxisID,getFirstScaleId(t,"x")),o=e.yAxisID=valueOrDefault(i.yAxisID,getFirstScaleId(t,"y")),a=e.rAxisID=valueOrDefault(i.rAxisID,getFirstScaleId(t,"r")),r=e.indexAxis,l=e.iAxisID=s(r,n,o,a),h=e.vAxisID=s(r,o,n,a);e.xScale=this.getScaleForId(n),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(l),e.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&unlistenArrayEvents(this._data,this),t._stacked&&clearStacks(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(isObject(e))this._data=convertObjectDataToArray(e);else if(i!==e){if(i){unlistenArrayEvents(i,this);const t=this._cachedMeta;clearStacks(t),t._parsed=[]}e&&Object.isExtensible(e)&&listenArrayEvents(e,this),this._syncList=[],this._data=e}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,i=this.getDataset();let s=!1;this._dataCheck();const n=e._stacked;e._stacked=isStacked(e.vScale,e),e.stack!==i.stack&&(s=!0,clearStacks(e),e.stack=i.stack),this._resyncElements(t),(s||n!==e._stacked)&&updateStacks(this,e._parsed)}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),i=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(i,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:i,_data:s}=this,{iScale:n,_stacked:o}=i,a=n.axis;let r,l,h,c=0===t&&e===s.length||i._sorted,d=t>0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=s,i._sorted=!0,h=s;else{h=isArray(s[t])?this.parseArrayData(i,s,t,e):isObject(s[t])?this.parseObjectData(i,s,t,e):this.parsePrimitiveData(i,s,t,e);const n=()=>null===l[a]||d&&l[a]<d[a];for(r=0;r<e;++r)i._parsed[r+t]=l=h[r],c&&(n()&&(c=!1),d=l);i._sorted=c}o&&updateStacks(this,h)}parsePrimitiveData(t,e,i,s){const{iScale:n,vScale:o}=t,a=n.axis,r=o.axis,l=n.getLabels(),h=n===o,c=new Array(s);let d,u,g;for(d=0,u=s;d<u;++d)g=d+i,c[d]={[a]:h||n.parse(l[g],g),[r]:o.parse(e[g],g)};return c}parseArrayData(t,e,i,s){const{xScale:n,yScale:o}=t,a=new Array(s);let r,l,h,c;for(r=0,l=s;r<l;++r)h=r+i,c=e[h],a[r]={x:n.parse(c[0],h),y:o.parse(c[1],h)};return a}parseObjectData(t,e,i,s){const{xScale:n,yScale:o}=t,{xAxisKey:a="x",yAxisKey:r="y"}=this._parsing,l=new Array(s);let h,c,d,u;for(h=0,c=s;h<c;++h)d=h+i,u=e[d],l[h]={x:n.parse(resolveObjectKey(u,a),d),y:o.parse(resolveObjectKey(u,r),d)};return l}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,e,i){const s=this.chart,n=this._cachedMeta,o=e[t.axis];return applyStack({keys:getSortedDatasetIndices(s,!0),values:e._stacks[t.axis]._visualValues},o,n.index,{mode:i})}updateRangeFromParsed(t,e,i,s){const n=i[e.axis];let o=null===n?NaN:n;const a=s&&i._stacks[e.axis];s&&a&&(s.values=a,o=applyStack(s,n,this._cachedMeta.index)),t.min=Math.min(t.min,o),t.max=Math.max(t.max,o)}getMinMax(t,e){const i=this._cachedMeta,s=i._parsed,n=i._sorted&&t===i.iScale,o=s.length,a=this._getOtherScale(t),r=createStack(e,i,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:h,max:c}=getUserBounds(a);let d,u;function g(){u=s[d];const e=u[a.axis];return!isNumberFinite(u[t.axis])||h>e||c<e}for(d=0;d<o&&(g()||(this.updateRangeFromParsed(l,t,u,r),!n));++d);if(n)for(d=o-1;d>=0;--d)if(!g()){this.updateRangeFromParsed(l,t,u,r);break}return l}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,n,o;for(s=0,n=e.length;s<n;++s)o=e[s][t.axis],isNumberFinite(o)&&i.push(o);return i}getMaxOverflow(){return!1}getLabelAndValue(t){const e=this._cachedMeta,i=e.iScale,s=e.vScale,n=this.getParsed(t);return{label:i?""+i.getLabelForValue(n[i.axis]):"",value:s?""+s.getLabelForValue(n[s.axis]):""}}_update(t){const e=this._cachedMeta;this.update(t||"default"),e._clip=toClip(valueOrDefault(this.options.clip,defaultClip(e.xScale,e.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,e=this.chart,i=this._cachedMeta,s=i.data||[],n=e.chartArea,o=[],a=this._drawStart||0,r=this._drawCount||s.length-a,l=this.options.drawActiveElementsOnTop;let h;for(i.dataset&&i.dataset.draw(t,n,a,r),h=a;h<a+r;++h){const e=s[h];e.hidden||(e.active&&l?o.push(e):e.draw(t,n))}for(h=0;h<o.length;++h)o[h].draw(t,n)}getStyle(t,e){const i=e?"active":"default";return void 0===t&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(i):this.resolveDataElementOptions(t||0,i)}getContext(t,e,i){const s=this.getDataset();let n;if(t>=0&&t<this._cachedMeta.data.length){const e=this._cachedMeta.data[t];n=e.$context||(e.$context=createDataContext(this.getContext(),t,e)),n.parsed=this.getParsed(t),n.raw=s.data[t],n.index=n.dataIndex=t}else n=this.$context||(this.$context=createDatasetContext(this.chart.getContext(),this.index)),n.dataset=s,n.index=n.datasetIndex=this.index;return n.active=!!e,n.mode=i,n}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,e){return this._resolveElementOptions(this.dataElementType.id,e,t)}_resolveElementOptions(t,e="default",i){const s="active"===e,n=this._cachedDataOpts,o=t+"-"+e,a=n[o],r=this.enableOptionSharing&&defined(i);if(a)return cloneIfNotShared(a,r);const l=this.chart.config,h=l.datasetElementScopeKeys(this._type,t),c=s?[`${t}Hover`,"hover",t,""]:[t,""],d=l.getOptionScopes(this.getDataset(),h),u=Object.keys(defaults.elements[t]),g=l.resolveNamedOptions(d,u,(()=>this.getContext(i,s,e)),c);return g.$shared&&(g.$shared=r,n[o]=Object.freeze(cloneIfNotShared(g,r))),g}_resolveAnimations(t,e,i){const s=this.chart,n=this._cachedDataOpts,o=`animation-${e}`,a=n[o];if(a)return a;let r;if(!1!==s.options.animation){const s=this.chart.config,n=s.datasetAnimationScopeKeys(this._type,e),o=s.getOptionScopes(this.getDataset(),n);r=s.createResolver(o,this.getContext(t,i,e))}const l=new Animations(s,r&&r.animations);return r&&r._cacheable&&(n[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||isDirectUpdateMode(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const i=this.resolveDataElementOptions(t,e),s=this._sharedOptions,n=this.getSharedOptions(i),o=this.includeOptions(e,n)||n!==s;return this.updateSharedOptions(n,e,i),{sharedOptions:n,includeOptions:o}}updateElement(t,e,i,s){isDirectUpdateMode(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!isDirectUpdateMode(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const n=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[t,e,i]of this._syncList)this[t](e,i);this._syncList=[];const s=i.length,n=e.length,o=Math.min(n,s);o&&this.parse(0,o),n>s?this._insertElements(s,n-s,t):n<s&&this._removeElements(n,s-n)}_insertElements(t,e,i=!0){const s=this._cachedMeta,n=s.data,o=t+e;let a;const r=t=>{for(t.length+=e,a=t.length-1;a>=o;a--)t[a]=t[a-e]};for(r(n),a=t;a<o;++a)n[a]=new this.dataElementType;this._parsing&&r(s._parsed),this.parse(t,e),i&&this.updateElements(n,t,e,"reset")}updateElements(t,e,i,s){}_removeElements(t,e){const i=this._cachedMeta;if(this._parsing){const s=i._parsed.splice(t,e);i._stacked&&clearStacks(i,s)}i.data.splice(t,e)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[e,i,s]=t;this[e](i,s)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,e){e&&this._sync(["_removeElements",t,e]);const i=arguments.length-2;i&&this._sync(["_insertElements",t,i])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}function getAllScaleValues(t,e){if(!t._cache.$bar){const i=t.getMatchingVisibleMetas(e);let s=[];for(let e=0,n=i.length;e<n;e++)s=s.concat(i[e].controller.getAllParsedValues(t));t._cache.$bar=_arrayUnique(s.sort(((t,e)=>t-e)))}return t._cache.$bar}function computeMinSampleSize(t){const e=t.iScale,i=getAllScaleValues(e,t.type);let s,n,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(defined(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=i.length;s<n;++s)o=e.getPixelForValue(i[s]),l();for(a=void 0,s=0,n=e.ticks.length;s<n;++s)o=e.getPixelForTick(s),l();return r}function computeFitCategoryTraits(t,e,i,s){const n=i.barThickness;let o,a;return isNullOrUndef(n)?(o=e.min*i.categoryPercentage,a=i.barPercentage):(o=n*s,a=1),{chunk:o/s,ratio:a,start:e.pixels[t]-o/2}}function computeFlexCategoryTraits(t,e,i,s){const n=e.pixels,o=n[t];let a=t>0?n[t-1]:null,r=t<n.length-1?n[t+1]:null;const l=i.categoryPercentage;null===a&&(a=o-(null===r?e.end-e.start:r-o)),null===r&&(r=o+o-a);const h=o-(o-Math.min(a,r))/2*l;return{chunk:Math.abs(r-a)/2*l/s,ratio:i.barPercentage,start:h}}function parseFloatBar(t,e,i,s){const n=i.parse(t[0],s),o=i.parse(t[1],s),a=Math.min(n,o),r=Math.max(n,o);let l=a,h=r;Math.abs(a)>Math.abs(r)&&(l=r,h=a),e[i.axis]=h,e._custom={barStart:l,barEnd:h,start:n,end:o,min:a,max:r}}function parseValue(t,e,i,s){return isArray(t)?parseFloatBar(t,e,i,s):e[i.axis]=i.parse(t,s),e}function parseArrayOrPrimitive(t,e,i,s){const n=t.iScale,o=t.vScale,a=n.getLabels(),r=n===o,l=[];let h,c,d,u;for(h=i,c=i+s;h<c;++h)u=e[h],d={},d[n.axis]=r||n.parse(a[h],h),l.push(parseValue(u,d,o,h));return l}function isFloatBar(t){return t&&void 0!==t.barStart&&void 0!==t.barEnd}function barSign(t,e,i){return 0!==t?sign(t):(e.isHorizontal()?1:-1)*(e.min>=i?1:-1)}function borderProps(t){let e,i,s,n,o;return t.horizontal?(e=t.base>t.x,i="left",s="right"):(e=t.base<t.y,i="bottom",s="top"),e?(n="end",o="start"):(n="start",o="end"),{start:i,end:s,reverse:e,top:n,bottom:o}}function setBorderSkipped(t,e,i,s){let n=e.borderSkipped;const o={};if(!n)return void(t.borderSkipped=o);if(!0===n)return void(t.borderSkipped={top:!0,right:!0,bottom:!0,left:!0});const{start:a,end:r,reverse:l,top:h,bottom:c}=borderProps(t);"middle"===n&&i&&(t.enableBorderRadius=!0,(i._top||0)===s?n=h:(i._bottom||0)===s?n=c:(o[parseEdge(c,a,r,l)]=!0,n=h)),o[parseEdge(n,a,r,l)]=!0,t.borderSkipped=o}function parseEdge(t,e,i,s){return t=s?startEnd(t=swap(t,e,i),i,e):startEnd(t,e,i)}function swap(t,e,i){return t===e?i:t===i?e:t}function startEnd(t,e,i){return"start"===t?e:"end"===t?i:t}function setInflateAmount(t,{inflateAmount:e},i){t.inflateAmount="auto"===e?1===i?.33:0:e}class BarController extends DatasetController{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(t,e,i,s){return parseArrayOrPrimitive(t,e,i,s)}parseArrayData(t,e,i,s){return parseArrayOrPrimitive(t,e,i,s)}parseObjectData(t,e,i,s){const{iScale:n,vScale:o}=t,{xAxisKey:a="x",yAxisKey:r="y"}=this._parsing,l="x"===n.axis?a:r,h="x"===o.axis?a:r,c=[];let d,u,g,f;for(d=i,u=i+s;d<u;++d)f=e[d],g={},g[n.axis]=n.parse(resolveObjectKey(f,l),d),c.push(parseValue(resolveObjectKey(f,h),g,o,d));return c}updateRangeFromParsed(t,e,i,s){super.updateRangeFromParsed(t,e,i,s);const n=i._custom;n&&e===this._cachedMeta.vScale&&(t.min=Math.min(t.min,n.min),t.max=Math.max(t.max,n.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const e=this._cachedMeta,{iScale:i,vScale:s}=e,n=this.getParsed(t),o=n._custom,a=isFloatBar(o)?"["+o.start+", "+o.end+"]":""+s.getLabelForValue(n[s.axis]);return{label:""+i.getLabelForValue(n[i.axis]),value:a}}initialize(){this.enableOptionSharing=!0,super.initialize();this._cachedMeta.stack=this.getDataset().stack}update(t){const e=this._cachedMeta;this.updateElements(e.data,0,e.data.length,t)}updateElements(t,e,i,s){const n="reset"===s,{index:o,_cachedMeta:{vScale:a}}=this,r=a.getBasePixel(),l=a.isHorizontal(),h=this._getRuler(),{sharedOptions:c,includeOptions:d}=this._getSharedOptions(e,s);for(let u=e;u<e+i;u++){const e=this.getParsed(u),i=n||isNullOrUndef(e[a.axis])?{base:r,head:r}:this._calculateBarValuePixels(u),g=this._calculateBarIndexPixels(u,h),f=(e._stacks||{})[a.axis],p={horizontal:l,base:i.base,enableBorderRadius:!f||isFloatBar(e._custom)||o===f._top||o===f._bottom,x:l?i.head:g.center,y:l?g.center:i.head,height:l?g.size:Math.abs(i.size),width:l?Math.abs(i.size):g.size};d&&(p.options=c||this.resolveDataElementOptions(u,t[u].active?"active":s));const m=p.options||t[u].options;setBorderSkipped(p,m,f,o),setInflateAmount(p,m,h.ratio),this.updateElement(t[u],u,p,s)}}_getStacks(t,e){const{iScale:i}=this._cachedMeta,s=i.getMatchingVisibleMetas(this._type).filter((t=>t.controller.options.grouped)),n=i.options.stacked,o=[],a=t=>{const i=t.controller.getParsed(e),s=i&&i[t.vScale.axis];if(isNullOrUndef(s)||isNaN(s))return!0};for(const i of s)if((void 0===e||!a(i))&&((!1===n||-1===o.indexOf(i.stack)||void 0===n&&void 0===i.stack)&&o.push(i.stack),i.index===t))break;return o.length||o.push(void 0),o}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,i){const s=this._getStacks(t,i),n=void 0!==e?s.indexOf(e):-1;return-1===n?s.length-1:n}_getRuler(){const t=this.options,e=this._cachedMeta,i=e.iScale,s=[];let n,o;for(n=0,o=e.data.length;n<o;++n)s.push(i.getPixelForValue(this.getParsed(n)[i.axis],n));const a=t.barThickness;return{min:a||computeMinSampleSize(e),pixels:s,start:i._startPixel,end:i._endPixel,stackCount:this._getStackCount(),scale:i,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:e,_stacked:i,index:s},options:{base:n,minBarLength:o}}=this,a=n||0,r=this.getParsed(t),l=r._custom,h=isFloatBar(l);let c,d,u=r[e.axis],g=0,f=i?this.applyStack(e,r,i):u;f!==u&&(g=f-u,f=u),h&&(u=l.barStart,f=l.barEnd-l.barStart,0!==u&&sign(u)!==sign(l.barEnd)&&(g=0),g+=u);const p=isNullOrUndef(n)||h?g:n;let m=e.getPixelForValue(p);if(c=this.chart.getDataVisibility(t)?e.getPixelForValue(g+f):m,d=c-m,Math.abs(d)<o){d=barSign(d,e,a)*o,u===a&&(m-=d/2);const t=e.getPixelForDecimal(0),n=e.getPixelForDecimal(1),l=Math.min(t,n),g=Math.max(t,n);m=Math.max(Math.min(m,g),l),c=m+d,i&&!h&&(r._stacks[e.axis]._visualValues[s]=e.getValueForPixel(c)-e.getValueForPixel(m))}if(m===e.getPixelForValue(a)){const t=sign(d)*e.getLineWidthForValue(a)/2;m+=t,d-=t}return{size:d,base:m,head:c,center:c+d/2}}_calculateBarIndexPixels(t,e){const i=e.scale,s=this.options,n=s.skipNull,o=valueOrDefault(s.maxBarThickness,1/0);let a,r;if(e.grouped){const i=n?this._getStackCount(t):e.stackCount,l="flex"===s.barThickness?computeFlexCategoryTraits(t,e,s,i):computeFitCategoryTraits(t,e,s,i),h=this._getStackIndex(this.index,this._cachedMeta.stack,n?t:void 0);a=l.start+l.chunk*h+l.chunk/2,r=Math.min(o,l.chunk*l.ratio)}else a=i.getPixelForValue(this.getParsed(t)[i.axis],t),r=Math.min(o,e.min*e.ratio);return{base:a-r/2,head:a+r/2,center:a,size:r}}draw(){const t=this._cachedMeta,e=t.vScale,i=t.data,s=i.length;let n=0;for(;n<s;++n)null!==this.getParsed(n)[e.axis]&&i[n].draw(this._ctx)}}class BubbleController extends DatasetController{static id="bubble";static defaults={datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}};static overrides={scales:{x:{type:"linear"},y:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,e,i,s){const n=super.parsePrimitiveData(t,e,i,s);for(let t=0;t<n.length;t++)n[t]._custom=this.resolveDataElementOptions(t+i).radius;return n}parseArrayData(t,e,i,s){const n=super.parseArrayData(t,e,i,s);for(let t=0;t<n.length;t++){const s=e[i+t];n[t]._custom=valueOrDefault(s[2],this.resolveDataElementOptions(t+i).radius)}return n}parseObjectData(t,e,i,s){const n=super.parseObjectData(t,e,i,s);for(let t=0;t<n.length;t++){const s=e[i+t];n[t]._custom=valueOrDefault(s&&s.r&&+s.r,this.resolveDataElementOptions(t+i).radius)}return n}getMaxOverflow(){const t=this._cachedMeta.data;let e=0;for(let i=t.length-1;i>=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart.data.labels||[],{xScale:s,yScale:n}=e,o=this.getParsed(t),a=s.getLabelForValue(o.x),r=n.getLabelForValue(o.y),l=o._custom;return{label:i[t]||"",value:"("+a+", "+r+(l?", "+l:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a}=this._cachedMeta,{sharedOptions:r,includeOptions:l}=this._getSharedOptions(e,s),h=o.axis,c=a.axis;for(let d=e;d<e+i;d++){const e=t[d],i=!n&&this.getParsed(d),u={},g=u[h]=n?o.getPixelForDecimal(.5):o.getPixelForValue(i[h]),f=u[c]=n?a.getBasePixel():a.getPixelForValue(i[c]);u.skip=isNaN(g)||isNaN(f),l&&(u.options=r||this.resolveDataElementOptions(d,e.active?"active":s),n&&(u.options.radius=0)),this.updateElement(e,d,u,s)}}resolveDataElementOptions(t,e){const i=this.getParsed(t);let s=super.resolveDataElementOptions(t,e);s.$shared&&(s=Object.assign({},s,{$shared:!1}));const n=s.radius;return"active"!==e&&(s.radius=0),s.radius+=valueOrDefault(i&&i._custom,n),s}}function getRatioAndOffset(t,e,i){let s=1,n=1,o=0,a=0;if(e<TAU){const r=t,l=r+e,h=Math.cos(r),c=Math.sin(r),d=Math.cos(l),u=Math.sin(l),g=(t,e,s)=>_angleBetween(t,r,l,!0)?1:Math.max(e,e*i,s,s*i),f=(t,e,s)=>_angleBetween(t,r,l,!0)?-1:Math.min(e,e*i,s,s*i),p=g(0,h,d),m=g(HALF_PI,c,u),b=f(PI,h,d),x=f(PI+HALF_PI,c,u);s=(p-b)/2,n=(m-x)/2,o=-(p+b)/2,a=-(m+x)/2}return{ratioX:s,ratioY:n,offsetX:o,offsetY:a}}class DoughnutController extends DatasetController{static id="doughnut";static defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:t=>"spacing"!==t,_indexable:t=>"spacing"!==t};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i,color:s}}=t.legend.options;return e.labels.map(((e,n)=>{const o=t.getDatasetMeta(0).controller.getStyle(n);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,fontColor:s,lineWidth:o.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}}}};constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=i;else{let n,o,a=t=>+i[t];if(isObject(i[t])){const{key:t="value"}=this._parsing;a=e=>+resolveObjectKey(i[e],t)}for(n=t,o=t+e;n<o;++n)s._parsed[n]=a(n)}}_getRotation(){return toRadians(this.options.rotation-90)}_getCircumference(){return toRadians(this.options.circumference)}_getRotationExtents(){let t=TAU,e=-TAU;for(let i=0;i<this.chart.data.datasets.length;++i)if(this.chart.isDatasetVisible(i)&&this.chart.getDatasetMeta(i).type===this._type){const s=this.chart.getDatasetMeta(i).controller,n=s._getRotation(),o=s._getCircumference();t=Math.min(t,n),e=Math.max(e,n+o)}return{rotation:t,circumference:e-t}}update(t){const e=this.chart,{chartArea:i}=e,s=this._cachedMeta,n=s.data,o=this.getMaxBorderWidth()+this.getMaxOffset(n)+this.options.spacing,a=Math.max((Math.min(i.width,i.height)-o)/2,0),r=Math.min(toPercentage(this.options.cutout,a),1),l=this._getRingWeight(this.index),{circumference:h,rotation:c}=this._getRotationExtents(),{ratioX:d,ratioY:u,offsetX:g,offsetY:f}=getRatioAndOffset(c,h,r),p=(i.width-o)/d,m=(i.height-o)/u,b=Math.max(Math.min(p,m)/2,0),x=toDimension(this.options.radius,b),_=(x-Math.max(x*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=g*x,this.offsetY=f*x,s.total=this.calculateTotal(),this.outerRadius=x-_*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-_*l,0),this.updateElements(n,0,n.length,t)}_circumference(t,e){const i=this.options,s=this._cachedMeta,n=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===s._parsed[t]||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*n/TAU)}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,h=(a.top+a.bottom)/2,c=n&&r.animateScale,d=c?0:this.innerRadius,u=c?0:this.outerRadius,{sharedOptions:g,includeOptions:f}=this._getSharedOptions(e,s);let p,m=this._getRotation();for(p=0;p<e;++p)m+=this._circumference(p,n);for(p=e;p<e+i;++p){const e=this._circumference(p,n),i=t[p],o={x:l+this.offsetX,y:h+this.offsetY,startAngle:m,endAngle:m+e,circumference:e,outerRadius:u,innerRadius:d};f&&(o.options=g||this.resolveDataElementOptions(p,i.active?"active":s)),m+=e,this.updateElement(i,p,o,s)}}calculateTotal(){const t=this._cachedMeta,e=t.data;let i,s=0;for(i=0;i<e.length;i++){const n=t._parsed[i];null===n||isNaN(n)||!this.chart.getDataVisibility(i)||e[i].hidden||(s+=Math.abs(n))}return s}calculateCircumference(t){const e=this._cachedMeta.total;return e>0&&!isNaN(t)?TAU*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=formatNumber(e._parsed[t],i.options.locale);return{label:s[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,n,o,a,r;if(!t)for(s=0,n=i.data.datasets.length;s<n;++s)if(i.isDatasetVisible(s)){o=i.getDatasetMeta(s),t=o.data,a=o.controller;break}if(!t)return 0;for(s=0,n=t.length;s<n;++s)r=a.resolveDataElementOptions(s),"inner"!==r.borderAlign&&(e=Math.max(e,r.borderWidth||0,r.hoverBorderWidth||0));return e}getMaxOffset(t){let e=0;for(let i=0,s=t.length;i<s;++i){const t=this.resolveDataElementOptions(i);e=Math.max(e,t.offset||0,t.hoverOffset||0)}return e}_getRingWeightOffset(t){let e=0;for(let i=0;i<t;++i)this.chart.isDatasetVisible(i)&&(e+=this._getRingWeight(i));return e}_getRingWeight(t){return Math.max(valueOrDefault(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}class LineController extends DatasetController{static id="line";static defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:n}=e,o=this.chart._animationsDisabled;let{start:a,count:r}=_getStartAndCountOfVisiblePoints(e,s,o);this._drawStart=a,this._drawCount=r,_scaleRangesChanged(e)&&(a=0,r=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!n._decimated,i.points=s;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!o,options:l},t),this.updateElements(s,a,r,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,{sharedOptions:h,includeOptions:c}=this._getSharedOptions(e,s),d=o.axis,u=a.axis,{spanGaps:g,segment:f}=this.options,p=isNumber(g)?g:Number.POSITIVE_INFINITY,m=this.chart._animationsDisabled||n||"none"===s,b=e+i,x=t.length;let _=e>0&&this.getParsed(e-1);for(let i=0;i<x;++i){const g=t[i],x=m?g:{};if(i<e||i>=b){x.skip=!0;continue}const y=this.getParsed(i),v=isNullOrUndef(y[u]),S=x[d]=o.getPixelForValue(y[d],i),k=x[u]=n||v?a.getBasePixel():a.getPixelForValue(r?this.applyStack(a,y,r):y[u],i);x.skip=isNaN(S)||isNaN(k)||v,x.stop=i>0&&Math.abs(y[d]-_[d])>p,f&&(x.parsed=y,x.raw=l.data[i]),c&&(x.options=h||this.resolveDataElementOptions(i,g.active?"active":s)),m||this.updateElement(g,i,x,s),_=y}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}class PolarAreaController extends DatasetController{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i,color:s}}=t.legend.options;return e.labels.map(((e,n)=>{const o=t.getDatasetMeta(0).controller.getStyle(n);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,fontColor:s,lineWidth:o.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=formatNumber(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:n}}parseObjectData(t,e,i,s){return _parseObjectDataRadialScale.bind(this)(t,e,i,s)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach(((t,i)=>{const s=this.getParsed(i).r;!isNaN(s)&&this.chart.getDataVisibility(i)&&(s<e.min&&(e.min=s),s>e.max&&(e.max=s))})),e}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),n=Math.max(s/2,0),o=(n-Math.max(i.cutoutPercentage?n/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.options.animation,r=this._cachedMeta.rScale,l=r.xCenter,h=r.yCenter,c=r.getIndexAngle(0)-.5*PI;let d,u=c;const g=360/this.countVisibleElements();for(d=0;d<e;++d)u+=this._computeAngle(d,s,g);for(d=e;d<e+i;d++){const e=t[d];let i=u,f=u+this._computeAngle(d,s,g),p=o.getDataVisibility(d)?r.getDistanceFromCenterForValue(this.getParsed(d).r):0;u=f,n&&(a.animateScale&&(p=0),a.animateRotate&&(i=f=c));const m={x:l,y:h,innerRadius:0,outerRadius:p,startAngle:i,endAngle:f,options:this.resolveDataElementOptions(d,e.active?"active":s)};this.updateElement(e,d,m,s)}}countVisibleElements(){const t=this._cachedMeta;let e=0;return t.data.forEach(((t,i)=>{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&e++})),e}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?toRadians(this.resolveDataElementOptions(t,e).angle||i):0}}class PieController extends DoughnutController{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}}class RadarController extends DatasetController{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}parseObjectData(t,e,i,s){return _parseObjectDataRadialScale.bind(this)(t,e,i,s)}update(t){const e=this._cachedMeta,i=e.dataset,s=e.data||[],n=e.iScale.getLabels();if(i.points=s,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:n.length===s.length,options:e};this.updateElement(i,void 0,o,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const n=this._cachedMeta.rScale,o="reset"===s;for(let a=e;a<e+i;a++){const e=t[a],i=this.resolveDataElementOptions(a,e.active?"active":s),r=n.getPointPositionForValue(a,this.getParsed(a).r),l=o?n.xCenter:r.x,h=o?n.yCenter:r.y,c={x:l,y:h,angle:r.angle,skip:isNaN(l)||isNaN(h),options:i};this.updateElement(e,a,c,s)}}}class ScatterController extends DatasetController{static id="scatter";static defaults={datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1};static overrides={interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}};getLabelAndValue(t){const e=this._cachedMeta,i=this.chart.data.labels||[],{xScale:s,yScale:n}=e,o=this.getParsed(t),a=s.getLabelForValue(o.x),r=n.getLabelForValue(o.y);return{label:i[t]||"",value:"("+a+", "+r+")"}}update(t){const e=this._cachedMeta,{data:i=[]}=e,s=this.chart._animationsDisabled;let{start:n,count:o}=_getStartAndCountOfVisiblePoints(e,i,s);if(this._drawStart=n,this._drawCount=o,_scaleRangesChanged(e)&&(n=0,o=i.length),this.options.showLine){const{dataset:n,_dataset:o}=e;n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!o._decimated,n.points=i;const a=this.resolveDatasetElementOptions(t);a.segment=this.options.segment,this.updateElement(n,void 0,{animated:!s,options:a},t)}this.updateElements(i,n,o,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,h=this.resolveDataElementOptions(e,s),c=this.getSharedOptions(h),d=this.includeOptions(s,c),u=o.axis,g=a.axis,{spanGaps:f,segment:p}=this.options,m=isNumber(f)?f:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||n||"none"===s;let x=e>0&&this.getParsed(e-1);for(let h=e;h<e+i;++h){const e=t[h],i=this.getParsed(h),f=b?e:{},_=isNullOrUndef(i[g]),y=f[u]=o.getPixelForValue(i[u],h),v=f[g]=n||_?a.getBasePixel():a.getPixelForValue(r?this.applyStack(a,i,r):i[g],h);f.skip=isNaN(y)||isNaN(v)||_,f.stop=h>0&&Math.abs(i[u]-x[u])>m,p&&(f.parsed=i,f.raw=l.data[h]),d&&(f.options=c||this.resolveDataElementOptions(h,e.active?"active":s)),b||this.updateElement(e,h,f,s),x=i}this.updateSharedOptions(c,s,h)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let t=0;for(let i=e.length-1;i>=0;--i)t=Math.max(t,e[i].size(this.resolveDataElementOptions(i))/2);return t>0&&t}const i=t.dataset,s=i.options&&i.options.borderWidth||0;if(!e.length)return s;const n=e[0].size(this.resolveDataElementOptions(0)),o=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(s,n,o)/2}}var controllers=Object.freeze({__proto__:null,BarController,BubbleController,DoughnutController,LineController,PolarAreaController,PieController,RadarController,ScatterController});function abstract(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class DateAdapterBase{static override(t){Object.assign(DateAdapterBase.prototype,t)}constructor(t){this.options=t||{}}init(){}formats(){return abstract()}parse(){return abstract()}format(){return abstract()}add(){return abstract()}diff(){return abstract()}startOf(){return abstract()}endOf(){return abstract()}}var adapters={_date:DateAdapterBase};function binarySearch(t,e,i,s){const{controller:n,data:o,_sorted:a}=t,r=n._cachedMeta.iScale;if(r&&e===r.axis&&"r"!==e&&a&&o.length){const t=r._reversePixels?_rlookupByKey:_lookupByKey;if(!s)return t(o,e,i);if(n._sharedOptions){const s=o[0],n="function"==typeof s.getRange&&s.getRange(e);if(n){const s=t(o,e,i-n),a=t(o,e,i+n);return{lo:s.lo,hi:a.hi}}}}return{lo:0,hi:o.length-1}}function evaluateInteractionItems(t,e,i,s,n){const o=t.getSortedVisibleDatasetMetas(),a=i[e];for(let t=0,i=o.length;t<i;++t){const{index:i,data:r}=o[t],{lo:l,hi:h}=binarySearch(o[t],e,a,n);for(let t=l;t<=h;++t){const e=r[t];e.skip||s(e,i,t)}}}function getDistanceMetricForAxis(t){const e=-1!==t.indexOf("x"),i=-1!==t.indexOf("y");return function(t,s){const n=e?Math.abs(t.x-s.x):0,o=i?Math.abs(t.y-s.y):0;return Math.sqrt(Math.pow(n,2)+Math.pow(o,2))}}function getIntersectItems(t,e,i,s,n){const o=[];if(!n&&!t.isPointInArea(e))return o;return evaluateInteractionItems(t,i,e,(function(i,a,r){(n||_isPointInArea(i,t.chartArea,0))&&i.inRange(e.x,e.y,s)&&o.push({element:i,datasetIndex:a,index:r})}),!0),o}function getNearestRadialItems(t,e,i,s){let n=[];return evaluateInteractionItems(t,i,e,(function(t,i,o){const{startAngle:a,endAngle:r}=t.getProps(["startAngle","endAngle"],s),{angle:l}=getAngleFromPoint(t,{x:e.x,y:e.y});_angleBetween(l,a,r)&&n.push({element:t,datasetIndex:i,index:o})})),n}function getNearestCartesianItems(t,e,i,s,n,o){let a=[];const r=getDistanceMetricForAxis(i);let l=Number.POSITIVE_INFINITY;return evaluateInteractionItems(t,i,e,(function(i,h,c){const d=i.inRange(e.x,e.y,n);if(s&&!d)return;const u=i.getCenterPoint(n);if(!(!!o||t.isPointInArea(u))&&!d)return;const g=r(e,u);g<l?(a=[{element:i,datasetIndex:h,index:c}],l=g):g===l&&a.push({element:i,datasetIndex:h,index:c})})),a}function getNearestItems(t,e,i,s,n,o){return o||t.isPointInArea(e)?"r"!==i||s?getNearestCartesianItems(t,e,i,s,n,o):getNearestRadialItems(t,e,i,n):[]}function getAxisItems(t,e,i,s,n){const o=[],a="x"===i?"inXRange":"inYRange";let r=!1;return evaluateInteractionItems(t,i,e,((t,s,l)=>{t[a](e[i],n)&&(o.push({element:t,datasetIndex:s,index:l}),r=r||t.inRange(e.x,e.y,n))})),s&&!r?[]:o}var Interaction={evaluateInteractionItems,modes:{index(t,e,i,s){const n=getRelativePosition(e,t),o=i.axis||"x",a=i.includeInvisible||!1,r=i.intersect?getIntersectItems(t,n,o,s,a):getNearestItems(t,n,o,!1,s,a),l=[];return r.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=r[0].index,i=t.data[e];i&&!i.skip&&l.push({element:i,datasetIndex:t.index,index:e})})),l):[]},dataset(t,e,i,s){const n=getRelativePosition(e,t),o=i.axis||"xy",a=i.includeInvisible||!1;let r=i.intersect?getIntersectItems(t,n,o,s,a):getNearestItems(t,n,o,!1,s,a);if(r.length>0){const e=r[0].datasetIndex,i=t.getDatasetMeta(e).data;r=[];for(let t=0;t<i.length;++t)r.push({element:i[t],datasetIndex:e,index:t})}return r},point:(t,e,i,s)=>getIntersectItems(t,getRelativePosition(e,t),i.axis||"xy",s,i.includeInvisible||!1),nearest(t,e,i,s){const n=getRelativePosition(e,t),o=i.axis||"xy",a=i.includeInvisible||!1;return getNearestItems(t,n,o,i.intersect,s,a)},x:(t,e,i,s)=>getAxisItems(t,getRelativePosition(e,t),"x",i.intersect,s),y:(t,e,i,s)=>getAxisItems(t,getRelativePosition(e,t),"y",i.intersect,s)}};const STATIC_POSITIONS=["left","top","right","bottom"];function filterByPosition(t,e){return t.filter((t=>t.pos===e))}function filterDynamicPositionByAxis(t,e){return t.filter((t=>-1===STATIC_POSITIONS.indexOf(t.pos)&&t.box.axis===e))}function sortByWeight(t,e){return t.sort(((t,i)=>{const s=e?i:t,n=e?t:i;return s.weight===n.weight?s.index-n.index:s.weight-n.weight}))}function wrapBoxes(t){const e=[];let i,s,n,o,a,r;for(i=0,s=(t||[]).length;i<s;++i)n=t[i],({position:o,options:{stack:a,stackWeight:r=1}}=n),e.push({index:i,box:n,pos:o,horizontal:n.isHorizontal(),weight:n.weight,stack:a&&o+a,stackWeight:r});return e}function buildStacks(t){const e={};for(const i of t){const{stack:t,pos:s,stackWeight:n}=i;if(!t||!STATIC_POSITIONS.includes(s))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=n}return e}function setLayoutDims(t,e){const i=buildStacks(t),{vBoxMaxWidth:s,hBoxMaxHeight:n}=e;let o,a,r;for(o=0,a=t.length;o<a;++o){r=t[o];const{fullSize:a}=r.box,l=i[r.stack],h=l&&r.stackWeight/l.weight;r.horizontal?(r.width=h?h*s:a&&e.availableWidth,r.height=n):(r.width=s,r.height=h?h*n:a&&e.availableHeight)}return i}function buildLayoutBoxes(t){const e=wrapBoxes(t),i=sortByWeight(e.filter((t=>t.box.fullSize)),!0),s=sortByWeight(filterByPosition(e,"left"),!0),n=sortByWeight(filterByPosition(e,"right")),o=sortByWeight(filterByPosition(e,"top"),!0),a=sortByWeight(filterByPosition(e,"bottom")),r=filterDynamicPositionByAxis(e,"x"),l=filterDynamicPositionByAxis(e,"y");return{fullSize:i,leftAndTop:s.concat(o),rightAndBottom:n.concat(l).concat(a).concat(r),chartArea:filterByPosition(e,"chartArea"),vertical:s.concat(n).concat(l),horizontal:o.concat(a).concat(r)}}function getCombinedMax(t,e,i,s){return Math.max(t[i],e[i])+Math.max(t[s],e[s])}function updateMaxPadding(t,e){t.top=Math.max(t.top,e.top),t.left=Math.max(t.left,e.left),t.bottom=Math.max(t.bottom,e.bottom),t.right=Math.max(t.right,e.right)}function updateDims(t,e,i,s){const{pos:n,box:o}=i,a=t.maxPadding;if(!isObject(n)){i.size&&(t[n]-=i.size);const e=s[i.stack]||{size:0,count:1};e.size=Math.max(e.size,i.horizontal?o.height:o.width),i.size=e.size/e.count,t[n]+=i.size}o.getPadding&&updateMaxPadding(a,o.getPadding());const r=Math.max(0,e.outerWidth-getCombinedMax(a,t,"left","right")),l=Math.max(0,e.outerHeight-getCombinedMax(a,t,"top","bottom")),h=r!==t.w,c=l!==t.h;return t.w=r,t.h=l,i.horizontal?{same:h,other:c}:{same:c,other:h}}function handleMaxPadding(t){const e=t.maxPadding;function i(i){const s=Math.max(e[i]-t[i],0);return t[i]+=s,s}t.y+=i("top"),t.x+=i("left"),i("right"),i("bottom")}function getMargins(t,e){const i=e.maxPadding;function s(t){const s={left:0,top:0,right:0,bottom:0};return t.forEach((t=>{s[t]=Math.max(e[t],i[t])})),s}return s(t?["left","right"]:["top","bottom"])}function fitBoxes(t,e,i,s){const n=[];let o,a,r,l,h,c;for(o=0,a=t.length,h=0;o<a;++o){r=t[o],l=r.box,l.update(r.width||e.w,r.height||e.h,getMargins(r.horizontal,e));const{same:a,other:d}=updateDims(e,i,r,s);h|=a&&n.length,c=c||d,l.fullSize||n.push(r)}return h&&fitBoxes(n,e,i,s)||c}function setBoxDims(t,e,i,s,n){t.top=i,t.left=e,t.right=e+s,t.bottom=i+n,t.width=s,t.height=n}function placeBoxes(t,e,i,s){const n=i.padding;let{x:o,y:a}=e;for(const r of t){const t=r.box,l=s[r.stack]||{count:1,placed:0,weight:1},h=r.stackWeight/l.weight||1;if(r.horizontal){const s=e.w*h,o=l.size||t.height;defined(l.start)&&(a=l.start),t.fullSize?setBoxDims(t,n.left,a,i.outerWidth-n.right-n.left,o):setBoxDims(t,e.left+l.placed,a,s,o),l.start=a,l.placed+=s,a=t.bottom}else{const s=e.h*h,a=l.size||t.width;defined(l.start)&&(o=l.start),t.fullSize?setBoxDims(t,o,n.top,a,i.outerHeight-n.bottom-n.top):setBoxDims(t,o,e.top+l.placed,a,s),l.start=o,l.placed+=s,o=t.right}}e.x=o,e.y=a}var layouts={addBox(t,e){t.boxes||(t.boxes=[]),e.fullSize=e.fullSize||!1,e.position=e.position||"top",e.weight=e.weight||0,e._layers=e._layers||function(){return[{z:0,draw(t){e.draw(t)}}]},t.boxes.push(e)},removeBox(t,e){const i=t.boxes?t.boxes.indexOf(e):-1;-1!==i&&t.boxes.splice(i,1)},configure(t,e,i){e.fullSize=i.fullSize,e.position=i.position,e.weight=i.weight},update(t,e,i,s){if(!t)return;const n=toPadding(t.options.layout.padding),o=Math.max(e-n.width,0),a=Math.max(i-n.height,0),r=buildLayoutBoxes(t.boxes),l=r.vertical,h=r.horizontal;each(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const c=l.reduce(((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1),0)||1,d=Object.freeze({outerWidth:e,outerHeight:i,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/c,hBoxMaxHeight:a/2}),u=Object.assign({},n);updateMaxPadding(u,toPadding(s));const g=Object.assign({maxPadding:u,w:o,h:a,x:n.left,y:n.top},n),f=setLayoutDims(l.concat(h),d);fitBoxes(r.fullSize,g,d,f),fitBoxes(l,g,d,f),fitBoxes(h,g,d,f)&&fitBoxes(l,g,d,f),handleMaxPadding(g),placeBoxes(r.leftAndTop,g,d,f),g.x+=g.w,g.y+=g.h,placeBoxes(r.rightAndBottom,g,d,f),t.chartArea={left:g.left,top:g.top,right:g.left+g.w,bottom:g.top+g.h,height:g.h,width:g.w},each(r.chartArea,(e=>{const i=e.box;Object.assign(i,t.chartArea),i.update(g.w,g.h,{left:0,top:0,right:0,bottom:0})}))}};class BasePlatform{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,s){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,s?Math.floor(e/s):i)}}isAttached(t){return!0}updateConfig(t){}}class BasicPlatform extends BasePlatform{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const EXPANDO_KEY="$chartjs",EVENT_TYPES={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},isNullOrEmpty=t=>null===t||""===t;function initCanvas(t,e){const i=t.style,s=t.getAttribute("height"),n=t.getAttribute("width");if(t.$chartjs={initial:{height:s,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",isNullOrEmpty(n)){const e=readUsedSize(t,"width");void 0!==e&&(t.width=e)}if(isNullOrEmpty(s))if(""===t.style.height)t.height=t.width/(e||2);else{const e=readUsedSize(t,"height");void 0!==e&&(t.height=e)}return t}const eventListenerOptions=!!supportsEventListenerOptions&&{passive:!0};function addListener(t,e,i){t.addEventListener(e,i,eventListenerOptions)}function removeListener(t,e,i){t.canvas.removeEventListener(e,i,eventListenerOptions)}function fromNativeEvent(t,e){const i=EVENT_TYPES[t.type]||t.type,{x:s,y:n}=getRelativePosition(t,e);return{type:i,chart:e,native:t,x:void 0!==s?s:null,y:void 0!==n?n:null}}function nodeListContains(t,e){for(const i of t)if(i===e||i.contains(e))return!0}function createAttachObserver(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||nodeListContains(i.addedNodes,s),e=e&&!nodeListContains(i.removedNodes,s);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}function createDetachObserver(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||nodeListContains(i.removedNodes,s),e=e&&!nodeListContains(i.addedNodes,s);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}const drpListeningCharts=new Map;let oldDevicePixelRatio=0;function onWindowResize(){const t=window.devicePixelRatio;t!==oldDevicePixelRatio&&(oldDevicePixelRatio=t,drpListeningCharts.forEach(((e,i)=>{i.currentDevicePixelRatio!==t&&e()})))}function listenDevicePixelRatioChanges(t,e){drpListeningCharts.size||window.addEventListener("resize",onWindowResize),drpListeningCharts.set(t,e)}function unlistenDevicePixelRatioChanges(t){drpListeningCharts.delete(t),drpListeningCharts.size||window.removeEventListener("resize",onWindowResize)}function createResizeObserver(t,e,i){const s=t.canvas,n=s&&_getParentNode(s);if(!n)return;const o=throttled(((t,e)=>{const s=n.clientWidth;i(t,e),s<n.clientWidth&&i()}),window),a=new ResizeObserver((t=>{const e=t[0],i=e.contentRect.width,s=e.contentRect.height;0===i&&0===s||o(i,s)}));return a.observe(n),listenDevicePixelRatioChanges(t,o),a}function releaseObserver(t,e,i){i&&i.disconnect(),"resize"===e&&unlistenDevicePixelRatioChanges(t)}function createProxyAndListen(t,e,i){const s=t.canvas,n=throttled((e=>{null!==t.ctx&&i(fromNativeEvent(e,t))}),t);return addListener(s,e,n),n}class DomPlatform extends BasePlatform{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(initCanvas(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e.$chartjs)return!1;const i=e.$chartjs.initial;["height","width"].forEach((t=>{const s=i[t];isNullOrUndef(s)?e.removeAttribute(t):e.setAttribute(t,s)}));const s=i.style||{};return Object.keys(s).forEach((t=>{e.style[t]=s[t]})),e.width=e.width,delete e.$chartjs,!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),n={attach:createAttachObserver,detach:createDetachObserver,resize:createResizeObserver}[e]||createProxyAndListen;s[e]=n(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];if(!s)return;({attach:releaseObserver,detach:releaseObserver,resize:releaseObserver}[e]||removeListener)(t,e,s),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return getMaximumSize(t,e,i,s)}isAttached(t){const e=_getParentNode(t);return!(!e||!e.isConnected)}}function _detectPlatform(t){return!_isDomSupported()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?BasicPlatform:DomPlatform}class Element{static defaults={};static defaultRoutes=void 0;active=!1;tooltipPosition(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}hasValue(){return isNumber(this.x)&&isNumber(this.y)}getProps(t,e){const i=this.$animations;if(!e||!i)return this;const s={};return t.forEach((t=>{s[t]=i[t]&&i[t].active()?i[t]._to:this[t]})),s}}function autoSkip(t,e){const i=t.options.ticks,s=determineMaxTicks(t),n=Math.min(i.maxTicksLimit||s,s),o=i.major.enabled?getMajorIndices(e):[],a=o.length,r=o[0],l=o[a-1],h=[];if(a>n)return skipMajors(e,h,o,a/n),h;const c=calculateSpacing(o,e,n);if(a>0){let t,i;const s=a>1?Math.round((l-r)/(a-1)):null;for(skip(e,h,c,isNullOrUndef(s)?0:r-s,r),t=0,i=a-1;t<i;t++)skip(e,h,c,o[t],o[t+1]);return skip(e,h,c,l,isNullOrUndef(s)?e.length:l+s),h}return skip(e,h,c),h}function determineMaxTicks(t){const e=t.options.offset,i=t._tickSize(),s=t._length/i+(e?0:1),n=t._maxLength/i;return Math.floor(Math.min(s,n))}function calculateSpacing(t,e,i){const s=getEvenSpacing(t),n=e.length/i;if(!s)return Math.max(n,1);const o=_factorize(s);for(let t=0,e=o.length-1;t<e;t++){const e=o[t];if(e>n)return e}return Math.max(n,1)}function getMajorIndices(t){const e=[];let i,s;for(i=0,s=t.length;i<s;i++)t[i].major&&e.push(i);return e}function skipMajors(t,e,i,s){let n,o=0,a=i[0];for(s=Math.ceil(s),n=0;n<t.length;n++)n===a&&(e.push(t[n]),o++,a=i[o*s])}function skip(t,e,i,s,n){const o=valueOrDefault(s,0),a=Math.min(valueOrDefault(n,t.length),t.length);let r,l,h,c=0;for(i=Math.ceil(i),n&&(r=n-s,i=r/Math.floor(r/i)),h=o;h<0;)c++,h=Math.round(o+c*i);for(l=Math.max(o,0);l<a;l++)l===h&&(e.push(t[l]),c++,h=Math.round(o+c*i))}function getEvenSpacing(t){const e=t.length;let i,s;if(e<2)return!1;for(s=t[0],i=1;i<e;++i)if(t[i]-t[i-1]!==s)return!1;return s}const reverseAlign=t=>"left"===t?"right":"right"===t?"left":t,offsetFromEdge=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i,getTicksLimit=(t,e)=>Math.min(e||t,t);function sample(t,e){const i=[],s=t.length/e,n=t.length;let o=0;for(;o<n;o+=s)i.push(t[Math.floor(o)]);return i}function getPixelForGridLine(t,e,i){const s=t.ticks.length,n=Math.min(e,s-1),o=t._startPixel,a=t._endPixel,r=1e-6;let l,h=t.getPixelForTick(n);if(!(i&&(l=1===s?Math.max(h-o,a-h):0===e?(t.getPixelForTick(1)-h)/2:(h-t.getPixelForTick(n-1))/2,h+=n<e?l:-l,h<o-r||h>a+r)))return h}function garbageCollect(t,e){each(t,(t=>{const i=t.gc,s=i.length/2;let n;if(s>e){for(n=0;n<s;++n)delete t.data[i[n]];i.splice(0,s)}}))}function getTickMarkLength(t){return t.drawTicks?t.tickLength:0}function getTitleHeight(t,e){if(!t.display)return 0;const i=toFont(t.font,e),s=toPadding(t.padding);return(isArray(t.text)?t.text.length:1)*i.lineHeight+s.height}function createScaleContext(t,e){return createContext(t,{scale:e,type:"scale"})}function createTickContext(t,e,i){return createContext(t,{tick:i,index:e,type:"tick"})}function titleAlign(t,e,i){let s=_toLeftRightCenter(t);return(i&&"right"!==e||!i&&"right"===e)&&(s=reverseAlign(s)),s}function titleArgs(t,e,i,s){const{top:n,left:o,bottom:a,right:r,chart:l}=t,{chartArea:h,scales:c}=l;let d,u,g,f=0;const p=a-n,m=r-o;if(t.isHorizontal()){if(u=_alignStartEnd(s,o,r),isObject(i)){const t=Object.keys(i)[0],s=i[t];g=c[t].getPixelForValue(s)+p-e}else g="center"===i?(h.bottom+h.top)/2+p-e:offsetFromEdge(t,i,e);d=r-o}else{if(isObject(i)){const t=Object.keys(i)[0],s=i[t];u=c[t].getPixelForValue(s)-m+e}else u="center"===i?(h.left+h.right)/2-m+e:offsetFromEdge(t,i,e);g=_alignStartEnd(s,a,n),f="left"===i?-HALF_PI:HALF_PI}return{titleX:u,titleY:g,maxWidth:d,rotation:f}}class Scale extends Element{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:s}=this;return t=finiteOrDefault(t,Number.POSITIVE_INFINITY),e=finiteOrDefault(e,Number.NEGATIVE_INFINITY),i=finiteOrDefault(i,Number.POSITIVE_INFINITY),s=finiteOrDefault(s,Number.NEGATIVE_INFINITY),{min:finiteOrDefault(t,i),max:finiteOrDefault(e,s),minDefined:isNumberFinite(t),maxDefined:isNumberFinite(e)}}getMinMax(t){let e,{min:i,max:s,minDefined:n,maxDefined:o}=this.getUserBounds();if(n&&o)return{min:i,max:s};const a=this.getMatchingVisibleMetas();for(let r=0,l=a.length;r<l;++r)e=a[r].controller.getMinMax(this,t),n||(i=Math.min(i,e.min)),o||(s=Math.max(s,e.max));return i=o&&i>s?s:i,s=n&&i>s?i:s,{min:finiteOrDefault(i,finiteOrDefault(s,i)),max:finiteOrDefault(s,finiteOrDefault(i,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){callback(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:n,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=_addGrace(this,n,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a<this.ticks.length;this._convertTicksToLabels(r?sample(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),o.display&&(o.autoSkip||"auto"===o.source)&&(this.ticks=autoSkip(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),r&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t,e,i=this.options.reverse;this.isHorizontal()?(t=this.left,e=this.right):(t=this.top,e=this.bottom,i=!i),this._startPixel=t,this._endPixel=e,this._reversePixels=i,this._length=e-t,this._alignToPixels=this.options.alignToPixels}afterUpdate(){callback(this.options.afterUpdate,[this])}beforeSetDimensions(){callback(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){callback(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),callback(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){callback(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const e=this.options.ticks;let i,s,n;for(i=0,s=t.length;i<s;i++)n=t[i],n.label=callback(e.callback,[n.value,i,t],this)}afterTickToLabelConversion(){callback(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){callback(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,e=t.ticks,i=getTicksLimit(this.ticks.length,t.ticks.maxTicksLimit),s=e.minRotation||0,n=e.maxRotation;let o,a,r,l=s;if(!this._isVisible()||!e.display||s>=n||i<=1||!this.isHorizontal())return void(this.labelRotation=s);const h=this._getLabelSizes(),c=h.widest.width,d=h.highest.height,u=_limitValue(this.chart.width-c,0,this.maxWidth);o=t.offset?this.maxWidth/i:u/(i-1),c+6>o&&(o=u/(i-(t.offset?.5:1)),a=this.maxHeight-getTickMarkLength(t.grid)-e.padding-getTitleHeight(t.title,this.chart.options.font),r=Math.sqrt(c*c+d*d),l=toDegrees(Math.min(Math.asin(_limitValue((h.highest.height+6)/o,-1,1)),Math.asin(_limitValue(a/r,-1,1))-Math.asin(_limitValue(d/r,-1,1)))),l=Math.max(s,Math.min(n,l))),this.labelRotation=l}afterCalculateLabelRotation(){callback(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){callback(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:n}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=getTitleHeight(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=getTickMarkLength(n)+o):(t.height=this.maxHeight,t.width=getTickMarkLength(n)+o),i.display&&this.ticks.length){const{first:e,last:s,widest:n,highest:o}=this._getLabelSizes(),r=2*i.padding,l=toRadians(this.labelRotation),h=Math.cos(l),c=Math.sin(l);if(a){const e=i.mirror?0:c*n.width+h*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=i.mirror?0:h*n.width+c*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,s,c,h)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:n,padding:o},position:a}=this.options,r=0!==this.labelRotation,l="top"!==a&&"x"===this.axis;if(this.isHorizontal()){const a=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let c=0,d=0;r?l?(c=s*t.width,d=i*e.height):(c=i*t.height,d=s*e.width):"start"===n?d=e.width:"end"===n?c=t.width:"inner"!==n&&(c=t.width/2,d=e.width/2),this.paddingLeft=Math.max((c-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((d-h+o)*this.width/(this.width-h),0)}else{let i=e.height/2,s=t.height/2;"start"===n?(i=0,s=t.height):"end"===n&&(i=e.height,s=0),this.paddingTop=i+o,this.paddingBottom=s+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){callback(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,i;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,i=t.length;e<i;e++)isNullOrUndef(t[e].label)&&(t.splice(e,1),i--,e--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const e=this.options.ticks.sampleSize;let i=this.ticks;e<i.length&&(i=sample(i,e)),this._labelSizes=t=this._computeLabelSizes(i,i.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,e,i){const{ctx:s,_longestTextCache:n}=this,o=[],a=[],r=Math.floor(e/getTicksLimit(e,i));let l,h,c,d,u,g,f,p,m,b,x,_=0,y=0;for(l=0;l<e;l+=r){if(d=t[l].label,u=this._resolveTickFontOptions(l),s.font=g=u.string,f=n[g]=n[g]||{data:{},gc:[]},p=u.lineHeight,m=b=0,isNullOrUndef(d)||isArray(d)){if(isArray(d))for(h=0,c=d.length;h<c;++h)x=d[h],isNullOrUndef(x)||isArray(x)||(m=_measureText(s,f.data,f.gc,m,x),b+=p)}else m=_measureText(s,f.data,f.gc,m,d),b=p;o.push(m),a.push(b),_=Math.max(m,_),y=Math.max(b,y)}garbageCollect(n,e);const v=o.indexOf(_),S=a.indexOf(y),k=t=>({width:o[t]||0,height:a[t]||0});return{first:k(0),last:k(e-1),widest:k(v),highest:k(S),widths:o,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return _int16Range(this._alignToPixels?_alignPixel(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&t<e.length){const i=e[t];return i.$context||(i.$context=createTickContext(this.getContext(),t,i))}return this.$context||(this.$context=createScaleContext(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,e=toRadians(this.labelRotation),i=Math.abs(Math.cos(e)),s=Math.abs(Math.sin(e)),n=this._getLabelSizes(),o=t.autoSkipPadding||0,a=n?n.widest.width+o:0,r=n?n.highest.height+o:0;return this.isHorizontal()?r*i>a*s?a/i:r/s:r*s<a*i?r/i:a/s}_isVisible(){const t=this.options.display;return"auto"!==t?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:n,position:o,border:a}=s,r=n.offset,l=this.isHorizontal(),h=this.ticks.length+(r?1:0),c=getTickMarkLength(n),d=[],u=a.setContext(this.getContext()),g=u.display?u.width:0,f=g/2,p=function(t){return _alignPixel(i,t,g)};let m,b,x,_,y,v,S,k,P,M,w,A;if("top"===o)m=p(this.bottom),v=this.bottom-c,k=m-f,M=p(t.top)+f,A=t.bottom;else if("bottom"===o)m=p(this.top),M=t.top,A=p(t.bottom)-f,v=m+f,k=this.top+c;else if("left"===o)m=p(this.right),y=this.right-c,S=m-f,P=p(t.left)+f,w=t.right;else if("right"===o)m=p(this.left),P=t.left,w=p(t.right)-f,y=m+f,S=this.left+c;else if("x"===e){if("center"===o)m=p((t.top+t.bottom)/2+.5);else if(isObject(o)){const t=Object.keys(o)[0],e=o[t];m=p(this.chart.scales[t].getPixelForValue(e))}M=t.top,A=t.bottom,v=m+f,k=v+c}else if("y"===e){if("center"===o)m=p((t.left+t.right)/2);else if(isObject(o)){const t=Object.keys(o)[0],e=o[t];m=p(this.chart.scales[t].getPixelForValue(e))}y=m-f,S=y-c,P=t.left,w=t.right}const C=valueOrDefault(s.ticks.maxTicksLimit,h),O=Math.max(1,Math.ceil(h/C));for(b=0;b<h;b+=O){const t=this.getContext(b),e=n.setContext(t),s=a.setContext(t),o=e.lineWidth,h=e.color,c=s.dash||[],u=s.dashOffset,g=e.tickWidth,f=e.tickColor,p=e.tickBorderDash||[],m=e.tickBorderDashOffset;x=getPixelForGridLine(this,b,r),void 0!==x&&(_=_alignPixel(i,x,o),l?y=S=P=w=_:v=k=M=A=_,d.push({tx1:y,ty1:v,tx2:S,ty2:k,x1:P,y1:M,x2:w,y2:A,width:o,color:h,borderDash:c,borderDashOffset:u,tickWidth:g,tickColor:f,tickBorderDash:p,tickBorderDashOffset:m}))}return this._ticksLength=h,this._borderValue=m,d}_computeLabelItems(t){const e=this.axis,i=this.options,{position:s,ticks:n}=i,o=this.isHorizontal(),a=this.ticks,{align:r,crossAlign:l,padding:h,mirror:c}=n,d=getTickMarkLength(i.grid),u=d+h,g=c?-h:u,f=-toRadians(this.labelRotation),p=[];let m,b,x,_,y,v,S,k,P,M,w,A,C="middle";if("top"===s)v=this.bottom-g,S=this._getXAxisLabelAlignment();else if("bottom"===s)v=this.top+g,S=this._getXAxisLabelAlignment();else if("left"===s){const t=this._getYAxisLabelAlignment(d);S=t.textAlign,y=t.x}else if("right"===s){const t=this._getYAxisLabelAlignment(d);S=t.textAlign,y=t.x}else if("x"===e){if("center"===s)v=(t.top+t.bottom)/2+u;else if(isObject(s)){const t=Object.keys(s)[0],e=s[t];v=this.chart.scales[t].getPixelForValue(e)+u}S=this._getXAxisLabelAlignment()}else if("y"===e){if("center"===s)y=(t.left+t.right)/2-u;else if(isObject(s)){const t=Object.keys(s)[0],e=s[t];y=this.chart.scales[t].getPixelForValue(e)}S=this._getYAxisLabelAlignment(d).textAlign}"y"===e&&("start"===r?C="top":"end"===r&&(C="bottom"));const O=this._getLabelSizes();for(m=0,b=a.length;m<b;++m){x=a[m],_=x.label;const t=n.setContext(this.getContext(m));k=this.getPixelForTick(m)+n.labelOffset,P=this._resolveTickFontOptions(m),M=P.lineHeight,w=isArray(_)?_.length:1;const e=w/2,i=t.color,r=t.textStrokeColor,h=t.textStrokeWidth;let d,u=S;if(o?(y=k,"inner"===S&&(u=m===b-1?this.options.reverse?"left":"right":0===m?this.options.reverse?"right":"left":"center"),A="top"===s?"near"===l||0!==f?-w*M+M/2:"center"===l?-O.highest.height/2-e*M+M:-O.highest.height+M/2:"near"===l||0!==f?M/2:"center"===l?O.highest.height/2-e*M:O.highest.height-w*M,c&&(A*=-1),0===f||t.showLabelBackdrop||(y+=M/2*Math.sin(f))):(v=k,A=(1-w)*M/2),t.showLabelBackdrop){const e=toPadding(t.backdropPadding),i=O.heights[m],s=O.widths[m];let n=A-e.top,o=0-e.left;switch(C){case"middle":n-=i/2;break;case"bottom":n-=i}switch(S){case"center":o-=s/2;break;case"right":o-=s}d={left:o,top:n,width:s+e.width,height:i+e.height,color:t.backdropColor}}p.push({label:_,font:P,textOffset:A,options:{rotation:f,color:i,strokeColor:r,strokeWidth:h,textAlign:u,textBaseline:C,translation:[y,v],backdrop:d}})}return p}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-toRadians(this.labelRotation))return"top"===t?"left":"right";let i="center";return"start"===e.align?i="left":"end"===e.align?i="right":"inner"===e.align&&(i="inner"),i}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:i,mirror:s,padding:n}}=this.options,o=t+n,a=this._getLabelSizes().widest.width;let r,l;return"left"===e?s?(l=this.right+n,"near"===i?r="left":"center"===i?(r="center",l+=a/2):(r="right",l+=a)):(l=this.right-o,"near"===i?r="right":"center"===i?(r="center",l-=a/2):(r="left",l=this.left)):"right"===e?s?(l=this.left+n,"near"===i?r="right":"center"===i?(r="center",l-=a/2):(r="left",l-=a)):(l=this.left+o,"near"===i?r="left":"center"===i?(r="center",l+=a/2):(r="right",l=this.right)):r="right",{textAlign:r,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,e=this.options.position;return"left"===e||"right"===e?{top:0,left:this.left,bottom:t.height,right:this.right}:"top"===e||"bottom"===e?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:i,top:s,width:n,height:o}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(i,s,n,o),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const i=this.ticks.findIndex((e=>e.value===t));if(i>=0){return e.setContext(this.getContext(i)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const a=(t,e,s)=>{s.width&&s.color&&(i.save(),i.lineWidth=s.width,i.strokeStyle=s.color,i.setLineDash(s.borderDash||[]),i.lineDashOffset=s.borderDashOffset,i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke(),i.restore())};if(e.display)for(n=0,o=s.length;n<o;++n){const t=s[n];e.drawOnChartArea&&a({x:t.x1,y:t.y1},{x:t.x2,y:t.y2},t),e.drawTicks&&a({x:t.tx1,y:t.ty1},{x:t.tx2,y:t.ty2},{color:t.tickColor,width:t.tickWidth,borderDash:t.tickBorderDash,borderDashOffset:t.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:e,options:{border:i,grid:s}}=this,n=i.setContext(this.getContext()),o=i.display?n.width:0;if(!o)return;const a=s.setContext(this.getContext(0)).lineWidth,r=this._borderValue;let l,h,c,d;this.isHorizontal()?(l=_alignPixel(t,this.left,o)-o/2,h=_alignPixel(t,this.right,a)+a/2,c=d=r):(c=_alignPixel(t,this.top,o)-o/2,d=_alignPixel(t,this.bottom,a)+a/2,l=h=r),e.save(),e.lineWidth=n.width,e.strokeStyle=n.color,e.beginPath(),e.moveTo(l,c),e.lineTo(h,d),e.stroke(),e.restore()}drawLabels(t){if(!this.options.ticks.display)return;const e=this.ctx,i=this._computeLabelArea();i&&clipArea(e,i);const s=this.getLabelItems(t);for(const t of s){const i=t.options,s=t.font;renderText(e,t.label,0,t.textOffset,s,i)}i&&unclipArea(e)}drawTitle(){const{ctx:t,options:{position:e,title:i,reverse:s}}=this;if(!i.display)return;const n=toFont(i.font),o=toPadding(i.padding),a=i.align;let r=n.lineHeight/2;"bottom"===e||"center"===e||isObject(e)?(r+=o.bottom,isArray(i.text)&&(r+=n.lineHeight*(i.text.length-1))):r+=o.top;const{titleX:l,titleY:h,maxWidth:c,rotation:d}=titleArgs(this,r,e,a);renderText(t,i.text,0,0,n,{color:i.color,maxWidth:c,rotation:d,textAlign:titleAlign(a,e,s),textBaseline:"middle",translation:[l,h]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,e=t.ticks&&t.ticks.z||0,i=valueOrDefault(t.grid&&t.grid.z,-1),s=valueOrDefault(t.border&&t.border.z,0);return this._isVisible()&&this.draw===Scale.prototype.draw?[{z:i,draw:t=>{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let n,o;for(n=0,o=e.length;n<o;++n){const o=e[n];o[i]!==this.id||t&&o.type!==t||s.push(o)}return s}_resolveTickFontOptions(t){return toFont(this.options.ticks.setContext(this.getContext(t)).font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class TypedRegistry{constructor(t,e,i){this.type=t,this.scope=e,this.override=i,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const e=Object.getPrototypeOf(t);let i;isIChartComponent(e)&&(i=this.register(e));const s=this.items,n=t.id,o=this.scope+"."+n;if(!n)throw new Error("class does not have id: "+t);return n in s||(s[n]=t,registerDefaults(t,o,i),this.override&&defaults.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,s=this.scope;i in e&&delete e[i],s&&i in defaults[s]&&(delete defaults[s][i],this.override&&delete overrides[i])}}function registerDefaults(t,e,i){const s=merge(Object.create(null),[i?defaults.get(i):{},defaults.get(e),t.defaults]);defaults.set(e,s),t.defaultRoutes&&routeDefaults(e,t.defaultRoutes),t.descriptors&&defaults.describe(e,t.descriptors)}function routeDefaults(t,e){Object.keys(e).forEach((i=>{const s=i.split("."),n=s.pop(),o=[t].concat(s).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");defaults.route(o,n,l,r)}))}function isIChartComponent(t){return"id"in t&&"defaults"in t}class Registry{constructor(){this.controllers=new TypedRegistry(DatasetController,"datasets",!0),this.elements=new TypedRegistry(Element,"elements"),this.plugins=new TypedRegistry(Object,"plugins"),this.scales=new TypedRegistry(Scale,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach((e=>{const s=i||this._getRegistryForType(e);i||s.isForType(e)||s===this.plugins&&e.id?this._exec(t,s,e):each(e,(e=>{const s=i||this._getRegistryForType(e);this._exec(t,s,e)}))}))}_exec(t,e,i){const s=_capitalize(t);callback(i["before"+s],[],i),e[t](i),callback(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;e<this._typedRegistries.length;e++){const i=this._typedRegistries[e];if(i.isForType(t))return i}return this.plugins}_get(t,e,i){const s=e.get(t);if(void 0===s)throw new Error('"'+t+'" is not a registered '+i+".");return s}}var registry=new Registry;class PluginService{constructor(){this._init=[]}notify(t,e,i,s){"beforeInit"===e&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install"));const n=s?this._descriptors(t).filter(s):this._descriptors(t),o=this._notify(n,t,e,i);return"afterDestroy"===e&&(this._notify(n,t,"stop"),this._notify(this._init,t,"uninstall")),o}_notify(t,e,i,s){s=s||{};for(const n of t){const t=n.plugin;if(!1===callback(t[i],[e,s,n.options],t)&&s.cancelable)return!1}return!0}invalidate(){isNullOrUndef(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const e=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),e}_createDescriptors(t,e){const i=t&&t.config,s=valueOrDefault(i.options&&i.options.plugins,{}),n=allPlugins(i);return!1!==s||e?createDescriptors(t,n,s,e):[]}_notifyStateChanges(t){const e=this._oldCache||[],i=this._cache,s=(t,e)=>t.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function allPlugins(t){const e={},i=[],s=Object.keys(registry.plugins.items);for(let t=0;t<s.length;t++)i.push(registry.getPlugin(s[t]));const n=t.plugins||[];for(let t=0;t<n.length;t++){const s=n[t];-1===i.indexOf(s)&&(i.push(s),e[s.id]=!0)}return{plugins:i,localIds:e}}function getOpts(t,e){return e||!1!==t?!0===t?{}:t:null}function createDescriptors(t,{plugins:e,localIds:i},s,n){const o=[],a=t.getContext();for(const r of e){const e=r.id,l=getOpts(s[e],n);null!==l&&o.push({plugin:r,options:pluginOpts(t.config,{plugin:r,local:i[e]},l,a)})}return o}function pluginOpts(t,{plugin:e,local:i},s,n){const o=t.pluginScopeKeys(e),a=t.getOptionScopes(s,o);return i&&e.defaults&&a.push(e.defaults),t.createResolver(a,n,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function getIndexAxis(t,e){const i=defaults.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function getAxisFromDefaultScaleID(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}function getDefaultScaleIDFromAxis(t,e){return t===e?"_index_":"_value_"}function axisFromPosition(t){return"top"===t||"bottom"===t?"x":"left"===t||"right"===t?"y":void 0}function determineAxis(t,e){if("x"===t||"y"===t||"r"===t)return t;if(t=e.axis||axisFromPosition(e.position)||t.length>1&&determineAxis(t[0].toLowerCase(),e))return t;throw new Error(`Cannot determine type of '${name}' axis. Please provide 'axis' or 'position' option.`)}function mergeScaleConfig(t,e){const i=overrides[t.type]||{scales:{}},s=e.scales||{},n=getIndexAxis(t.type,e),o=Object.create(null);return Object.keys(s).forEach((t=>{const e=s[t];if(!isObject(e))return console.error(`Invalid scale configuration for scale: ${t}`);if(e._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);const a=determineAxis(t,e),r=getDefaultScaleIDFromAxis(a,n),l=i.scales||{};o[t]=mergeIf(Object.create(null),[{axis:a},e,l[a],l[r]])})),t.data.datasets.forEach((i=>{const n=i.type||t.type,a=i.indexAxis||getIndexAxis(n,e),r=(overrides[n]||{}).scales||{};Object.keys(r).forEach((t=>{const e=getAxisFromDefaultScaleID(t,a),n=i[e+"AxisID"]||e;o[n]=o[n]||Object.create(null),mergeIf(o[n],[{axis:e},s[n],r[t]])}))})),Object.keys(o).forEach((t=>{const e=o[t];mergeIf(e,[defaults.scales[e.type],defaults.scale])})),o}function initOptions(t){const e=t.options||(t.options={});e.plugins=valueOrDefault(e.plugins,{}),e.scales=mergeScaleConfig(t,e)}function initData(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}function initConfig(t){return(t=t||{}).data=initData(t.data),initOptions(t),t}const keyCache=new Map,keysCached=new Set;function cachedKeys(t,e){let i=keyCache.get(t);return i||(i=e(),keyCache.set(t,i),keysCached.add(i)),i}const addIfFound=(t,e,i)=>{const s=resolveObjectKey(e,i);void 0!==s&&t.add(s)};class Config{constructor(t){this._config=initConfig(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=initData(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),initOptions(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return cachedKeys(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return cachedKeys(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return cachedKeys(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;return cachedKeys(`${this.type}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return s&&!e||(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:n}=this,o=this._cachedScopes(t,i),a=o.get(e);if(a)return a;const r=new Set;e.forEach((e=>{t&&(r.add(t),e.forEach((e=>addIfFound(r,t,e)))),e.forEach((t=>addIfFound(r,s,t))),e.forEach((t=>addIfFound(r,overrides[n]||{},t))),e.forEach((t=>addIfFound(r,defaults,t))),e.forEach((t=>addIfFound(r,descriptors,t)))}));const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),keysCached.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,overrides[e]||{},defaults.datasets[e]||{},{type:e},defaults,descriptors]}resolveNamedOptions(t,e,i,s=[""]){const n={$shared:!0},{resolver:o,subPrefixes:a}=getResolver(this._resolverCache,t,s);let r=o;if(needContext(o,e)){n.$shared=!1;r=_attachContext(o,i=isFunction(i)?i():i,this.createResolver(t,i,a))}for(const t of e)n[t]=r[t];return n}createResolver(t,e,i=[""],s){const{resolver:n}=getResolver(this._resolverCache,t,i);return isObject(e)?_attachContext(n,e,void 0,s):n}}function getResolver(t,e,i){let s=t.get(e);s||(s=new Map,t.set(e,s));const n=i.join();let o=s.get(n);if(!o){o={resolver:_createResolver(e,i),subPrefixes:i.filter((t=>!t.toLowerCase().includes("hover")))},s.set(n,o)}return o}const hasFunction=t=>isObject(t)&&Object.getOwnPropertyNames(t).reduce(((e,i)=>e||isFunction(t[i])),!1);function needContext(t,e){const{isScriptable:i,isIndexable:s}=_descriptors(t);for(const n of e){const e=i(n),o=s(n),a=(o||e)&&t[n];if(e&&(isFunction(a)||hasFunction(a))||o&&isArray(a))return!0}return!1}var version="4.2.1";const KNOWN_POSITIONS=["top","bottom","left","right","chartArea"];function positionIsHorizontal(t,e){return"top"===t||"bottom"===t||-1===KNOWN_POSITIONS.indexOf(t)&&"x"===e}function compare2Level(t,e){return function(i,s){return i[t]===s[t]?i[e]-s[e]:i[t]-s[t]}}function onAnimationsComplete(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),callback(i&&i.onComplete,[t],e)}function onAnimationProgress(t){const e=t.chart,i=e.options.animation;callback(i&&i.onProgress,[t],e)}function getCanvas(t){return _isDomSupported()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const instances={},getChart=t=>{const e=getCanvas(t);return Object.values(instances).filter((t=>t.canvas===e)).pop()};function moveNumericKeys(t,e,i){const s=Object.keys(t);for(const n of s){const s=+n;if(s>=e){const o=t[n];delete t[n],(i>0||s>e)&&(t[s+i]=o)}}}function determineLastEvent(t,e,i,s){return i&&"mouseout"!==t.type?s?e:t:null}function getDatasetArea(t){const{xScale:e,yScale:i}=t;if(e&&i)return{left:e.left,right:e.right,top:i.top,bottom:i.bottom}}class Chart{static defaults=defaults;static instances=instances;static overrides=overrides;static registry=registry;static version=version;static getChart=getChart;static register(...t){registry.add(...t),invalidatePlugins()}static unregister(...t){registry.remove(...t),invalidatePlugins()}constructor(t,e){const i=this.config=new Config(e),s=getCanvas(t),n=getChart(s);if(n)throw new Error("Canvas is already in use. Chart with ID '"+n.id+"' must be destroyed before the canvas with ID '"+n.canvas.id+"' can be reused.");const o=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||_detectPlatform(s)),this.platform.updateConfig(i);const a=this.platform.acquireContext(s,o.aspectRatio),r=a&&a.canvas,l=r&&r.height,h=r&&r.width;this.id=uid(),this.ctx=a,this.canvas=r,this.width=h,this.height=l,this._options=o,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new PluginService,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=debounce((t=>this.update(t)),o.resizeDelay||0),this._dataChanges=[],instances[this.id]=this,a&&r?(animator.listen(this,"complete",onAnimationsComplete),animator.listen(this,"progress",onAnimationProgress),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:n}=this;return isNullOrUndef(t)?e&&n?n:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return registry}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():retinaScale(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return clearCanvas(this.canvas,this.ctx),this}stop(){return animator.stop(this),this}resize(t,e){animator.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,n=i.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(s,t,e,n),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,retinaScale(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),callback(i.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){each(this.options.scales||{},((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce(((t,e)=>(t[e]=!1,t)),{});let n=[];e&&(n=n.concat(Object.keys(e).map((t=>{const i=e[t],s=determineAxis(t,i),n="r"===s,o="x"===s;return{options:i,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}})))),each(n,(e=>{const n=e.options,o=n.id,a=determineAxis(o,n),r=valueOrDefault(n.type,e.dtype);void 0!==n.position&&positionIsHorizontal(n.position,a)===positionIsHorizontal(e.dposition)||(n.position=e.dposition),s[o]=!0;let l=null;if(o in i&&i[o].type===r)l=i[o];else{l=new(registry.getScale(r))({id:o,type:r,ctx:this.ctx,chart:this}),i[l.id]=l}l.init(n,t)})),each(s,((t,e)=>{t||delete i[e]})),each(i,(t=>{layouts.configure(this,t,t.options),layouts.addBox(this,t)}))}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort(((t,e)=>t.index-e.index)),i>e){for(let t=e;t<i;++t)this._destroyDatasetMeta(t);t.splice(e,i-e)}this._sortedMetasets=t.slice(0).sort(compare2Level("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:e}}=this;t.length>e.length&&delete this._stacks,t.forEach(((t,i)=>{0===e.filter((e=>e===t._dataset)).length&&this._destroyDatasetMeta(i)}))}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i<s;i++){const s=e[i];let n=this.getDatasetMeta(i);const o=s.type||this.config.type;if(n.type&&n.type!==o&&(this._destroyDatasetMeta(i),n=this.getDatasetMeta(i)),n.type=o,n.indexAxis=s.indexAxis||getIndexAxis(o,this.options),n.order=s.order||0,n.index=i,n.label=""+s.label,n.visible=this.isDatasetVisible(i),n.controller)n.controller.updateIndex(i),n.controller.linkScales();else{const e=registry.getController(o),{datasetElementType:s,dataElementType:a}=defaults.datasets[o];Object.assign(e,{dataElementType:registry.getElement(a),datasetElementType:s&®istry.getElement(s)}),n.controller=new e(this,i),t.push(n.controller)}}return this._updateMetasets(),t}_resetElements(){each(this.data.datasets,((t,e)=>{this.getDatasetMeta(e).controller.reset()}),this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const n=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let t=0,e=this.data.datasets.length;t<e;t++){const{controller:e}=this.getDatasetMeta(t),i=!s&&-1===n.indexOf(e);e.buildOrUpdateElements(i),o=Math.max(+e.getMaxOverflow(),o)}o=this._minPadding=i.layout.autoPadding?o:0,this._updateLayout(o),s||each(n,(t=>{t.reset()})),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(compare2Level("z","_idx"));const{_active:a,_lastEvent:r}=this;r?this._eventHandler(r,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){each(this.scales,(t=>{layouts.removeBox(this,t)})),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);setsEqual(e,i)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:n}of e){moveNumericKeys(t,s,"_removeElements"===i?-n:n)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=e=>new Set(t.filter((t=>t[0]===e)).map(((t,e)=>e+","+t.splice(1).join(",")))),s=i(0);for(let t=1;t<e;t++)if(!setsEqual(s,i(t)))return;return Array.from(s).map((t=>t.split(","))).map((t=>({method:t[1],start:+t[2],count:+t[3]})))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;layouts.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],each(this.boxes,(t=>{i&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))}),this),this._layers.forEach(((t,e)=>{t._idx=e})),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let t=0,e=this.data.datasets.length;t<e;++t)this.getDatasetMeta(t).controller.configure();for(let e=0,i=this.data.datasets.length;e<i;++e)this._updateDataset(e,isFunction(t)?t({datasetIndex:e}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,e){const i=this.getDatasetMeta(t),s={meta:i,index:t,mode:e,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetUpdate",s)&&(i.controller._update(e),s.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",s))}render(){!1!==this.notifyPlugins("beforeRender",{cancelable:!0})&&(animator.has(this)?this.attached&&!animator.running(this)&&animator.start(this):(this.draw(),onAnimationsComplete({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:t,height:e}=this._resizeBeforeDraw;this._resize(t,e),this._resizeBeforeDraw=null}if(this.clear(),this.width<=0||this.height<=0)return;if(!1===this.notifyPlugins("beforeDraw",{cancelable:!0}))return;const e=this._layers;for(t=0;t<e.length&&e[t].z<=0;++t)e[t].draw(this.chartArea);for(this._drawDatasets();t<e.length;++t)e[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const e=this._sortedMetasets,i=[];let s,n;for(s=0,n=e.length;s<n;++s){const n=e[s];t&&!n.visible||i.push(n)}return i}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(!1===this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0}))return;const t=this.getSortedVisibleDatasetMetas();for(let e=t.length-1;e>=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,n=getDatasetArea(t)||this.chartArea,o={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",o)&&(s&&clipArea(e,{left:!1===i.left?0:n.left-i.left,right:!1===i.right?this.width:n.right+i.right,top:!1===i.top?0:n.top-i.top,bottom:!1===i.bottom?this.height:n.bottom+i.bottom}),t.controller.draw(),s&&unclipArea(e),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}isPointInArea(t){return _isPointInArea(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,i,s){const n=Interaction.modes[e];return"function"==typeof n?n(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter((t=>t&&t._dataset===e)).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=createContext(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",n=this.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,s);defined(e)?(n.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),o.update(n,{visible:i}),this.update((e=>e.datasetIndex===t?s:void 0)))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),animator.remove(this),t=0,e=this.data.datasets.length;t<e;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:e}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),clearCanvas(t,e),this.platform.releaseContext(e),this.canvas=null,this.ctx=null),delete instances[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};each(this.options.events,(t=>i(t,s)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(i,s)=>{t[i]&&(e.removeEventListener(this,i,s),delete t[i])},n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",n),i("detach",o)};o=()=>{this.attached=!1,s("resize",n),this._stop(),this._resize(0,0),i("attach",a)},e.isAttached(this.canvas)?a():o()}unbindEvents(){each(this._listeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._listeners={},each(this._responsiveListeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let n,o,a,r;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex),n.controller["_"+s+"DatasetHoverStyle"]()),a=0,r=t.length;a<r;++a){o=t[a];const e=o&&this.getDatasetMeta(o.datasetIndex).controller;e&&e[s+"HoverStyle"](o.element,o.datasetIndex,o.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const e=this._active||[],i=t.map((({datasetIndex:t,index:e})=>{const i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}}));!_elementsEqual(i,e)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}isPluginEnabled(t){return 1===this._plugins._cache.filter((e=>e.plugin.id===t)).length}_updateHoverStyles(t,e,i){const s=this.options.hover,n=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),o=n(e,t),a=i?t:n(t,e);o.length&&this.updateHoverStyle(o,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},s=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,s))return;const n=this._handleEvent(t,e,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(n||i.changed)&&this.render(),this}_handleEvent(t,e,i){const{_active:s=[],options:n}=this,o=e,a=this._getActiveElements(t,s,i,o),r=_isClickEvent(t),l=determineLastEvent(t,this._lastEvent,i,r);i&&(this._lastEvent=null,callback(n.onHover,[t,a,this],this),r&&callback(n.onClick,[t,a,this],this));const h=!_elementsEqual(a,s);return(h||e)&&(this._active=a,this._updateHoverStyles(a,s,e)),this._lastEvent=l,h}_getActiveElements(t,e,i,s){if("mouseout"===t.type)return[];if(!i)return e;const n=this.options.hover;return this.getElementsAtEventForMode(t,n.mode,n,s)}}function invalidatePlugins(){return each(Chart.instances,(t=>t._plugins.invalidate()))}function clipArc(t,e,i){const{startAngle:s,pixelMargin:n,x:o,y:a,outerRadius:r,innerRadius:l}=e;let h=n/r;t.beginPath(),t.arc(o,a,r,s-h,i+h),l>n?(h=n/l,t.arc(o,a,l,i+h,s-h,!0)):t.arc(o,a,n,i+HALF_PI,s-HALF_PI),t.closePath(),t.clip()}function toRadiusCorners(t){return _readValueToProps(t,["outerStart","outerEnd","innerStart","innerEnd"])}function parseBorderRadius$1(t,e,i,s){const n=toRadiusCorners(t.options.borderRadius),o=(i-e)/2,a=Math.min(o,s*e/2),r=t=>{const e=(i-Math.min(o,t))*s/2;return _limitValue(t,0,Math.min(o,e))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:_limitValue(n.innerStart,0,a),innerEnd:_limitValue(n.innerEnd,0,a)}}function rThetaToXY(t,e,i,s){return{x:i+t*Math.cos(e),y:s+t*Math.sin(e)}}function pathArc(t,e,i,s,n,o){const{x:a,y:r,startAngle:l,pixelMargin:h,innerRadius:c}=e,d=Math.max(e.outerRadius+s+i-h,0),u=c>0?c+s+i+h:0;let g=0;const f=n-l;if(s){const t=((c>0?c-s:0)+(d>0?d-s:0))/2;g=(f-(0!==t?f*t/(t+s):f))/2}const p=(f-Math.max(.001,f*d-i/PI)/d)/2,m=l+p+g,b=n-p-g,{outerStart:x,outerEnd:_,innerStart:y,innerEnd:v}=parseBorderRadius$1(e,u,d,b-m),S=d-x,k=d-_,P=m+x/S,M=b-_/k,w=u+y,A=u+v,C=m+y/w,O=b-v/A;if(t.beginPath(),o){const e=(P+M)/2;if(t.arc(a,r,d,P,e),t.arc(a,r,d,e,M),_>0){const e=rThetaToXY(k,M,a,r);t.arc(e.x,e.y,_,M,b+HALF_PI)}const i=rThetaToXY(A,b,a,r);if(t.lineTo(i.x,i.y),v>0){const e=rThetaToXY(A,O,a,r);t.arc(e.x,e.y,v,b+HALF_PI,O+Math.PI)}const s=(b-v/u+(m+y/u))/2;if(t.arc(a,r,u,b-v/u,s,!0),t.arc(a,r,u,s,m+y/u,!0),y>0){const e=rThetaToXY(w,C,a,r);t.arc(e.x,e.y,y,C+Math.PI,m-HALF_PI)}const n=rThetaToXY(S,m,a,r);if(t.lineTo(n.x,n.y),x>0){const e=rThetaToXY(S,P,a,r);t.arc(e.x,e.y,x,m-HALF_PI,P)}}else{t.moveTo(a,r);const e=Math.cos(P)*d+a,i=Math.sin(P)*d+r;t.lineTo(e,i);const s=Math.cos(M)*d+a,n=Math.sin(M)*d+r;t.lineTo(s,n)}t.closePath()}function drawArc(t,e,i,s,n){const{fullCircles:o,startAngle:a,circumference:r}=e;let l=e.endAngle;if(o){pathArc(t,e,i,s,l,n);for(let e=0;e<o;++e)t.fill();isNaN(r)||(l=a+(r%TAU||TAU))}return pathArc(t,e,i,s,l,n),t.fill(),l}function drawBorder(t,e,i,s,n){const{fullCircles:o,startAngle:a,circumference:r,options:l}=e,{borderWidth:h,borderJoinStyle:c}=l,d="inner"===l.borderAlign;if(!h)return;d?(t.lineWidth=2*h,t.lineJoin=c||"round"):(t.lineWidth=h,t.lineJoin=c||"bevel");let u=e.endAngle;if(o){pathArc(t,e,i,s,u,n);for(let e=0;e<o;++e)t.stroke();isNaN(r)||(u=a+(r%TAU||TAU))}d&&clipArc(t,e,u),o||(pathArc(t,e,i,s,u,n),t.stroke())}class ArcElement extends Element{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0};static defaultRoutes={backgroundColor:"backgroundColor"};constructor(t){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,t&&Object.assign(this,t)}inRange(t,e,i){const s=this.getProps(["x","y"],i),{angle:n,distance:o}=getAngleFromPoint(s,{x:t,y:e}),{startAngle:a,endAngle:r,innerRadius:l,outerRadius:h,circumference:c}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),d=this.options.spacing/2,u=valueOrDefault(c,r-a)>=TAU||_angleBetween(n,a,r),g=_isBetween(o,l+d,h+d);return u&&g}getCenterPoint(t){const{x:e,y:i,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:r,spacing:l}=this.options,h=(s+n)/2,c=(o+a+l+r)/2;return{x:e+Math.cos(h)*c,y:i+Math.sin(h)*c}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,s=(e.offset||0)/4,n=(e.spacing||0)/2,o=e.circular;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>TAU?Math.floor(i/TAU):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();const a=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(a)*s,Math.sin(a)*s);const r=s*(1-Math.sin(Math.min(PI,i||0)));t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,drawArc(t,this,r,n,o),drawBorder(t,this,r,n,o),t.restore()}}function setStyle(t,e,i=e){t.lineCap=valueOrDefault(i.borderCapStyle,e.borderCapStyle),t.setLineDash(valueOrDefault(i.borderDash,e.borderDash)),t.lineDashOffset=valueOrDefault(i.borderDashOffset,e.borderDashOffset),t.lineJoin=valueOrDefault(i.borderJoinStyle,e.borderJoinStyle),t.lineWidth=valueOrDefault(i.borderWidth,e.borderWidth),t.strokeStyle=valueOrDefault(i.borderColor,e.borderColor)}function lineTo(t,e,i){t.lineTo(i.x,i.y)}function getLineMethod(t){return t.stepped?_steppedLineTo:t.tension||"monotone"===t.cubicInterpolationMode?_bezierCurveTo:lineTo}function pathVars(t,e,i={}){const s=t.length,{start:n=0,end:o=s-1}=i,{start:a,end:r}=e,l=Math.max(n,a),h=Math.min(o,r),c=n<a&&o<a||n>r&&o>r;return{count:s,start:l,loop:e.loop,ilen:h<l&&!c?s+h-l:h-l}}function pathSegment(t,e,i,s){const{points:n,options:o}=e,{count:a,start:r,loop:l,ilen:h}=pathVars(n,i,s),c=getLineMethod(o);let d,u,g,{move:f=!0,reverse:p}=s||{};for(d=0;d<=h;++d)u=n[(r+(p?h-d:d))%a],u.skip||(f?(t.moveTo(u.x,u.y),f=!1):c(t,g,u,p,o.stepped),g=u);return l&&(u=n[(r+(p?h:0))%a],c(t,g,u,p,o.stepped)),!!l}function fastPathSegment(t,e,i,s){const n=e.points,{count:o,start:a,ilen:r}=pathVars(n,i,s),{move:l=!0,reverse:h}=s||{};let c,d,u,g,f,p,m=0,b=0;const x=t=>(a+(h?r-t:t))%o,_=()=>{g!==f&&(t.lineTo(m,f),t.lineTo(m,g),t.lineTo(m,p))};for(l&&(d=n[x(0)],t.moveTo(d.x,d.y)),c=0;c<=r;++c){if(d=n[x(c)],d.skip)continue;const e=d.x,i=d.y,s=0|e;s===u?(i<g?g=i:i>f&&(f=i),m=(b*m+e)/++b):(_(),t.lineTo(e,i),u=s,b=0,g=f=i),p=i}_()}function _getSegmentMethod(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?fastPathSegment:pathSegment}function _getInterpolationMethod(t){return t.stepped?_steppedInterpolation:t.tension||"monotone"===t.cubicInterpolationMode?_bezierInterpolation:_pointInLine}function strokePathWithCache(t,e,i,s){let n=e._path;n||(n=e._path=new Path2D,e.path(n,i,s)&&n.closePath()),setStyle(t,e.options),t.stroke(n)}function strokePathDirect(t,e,i,s){const{segments:n,options:o}=e,a=_getSegmentMethod(e);for(const r of n)setStyle(t,o,r.style),t.beginPath(),a(t,e,r,{start:i,end:i+s-1})&&t.closePath(),t.stroke()}const usePath2D="function"==typeof Path2D;function draw(t,e,i,s){usePath2D&&!e.options.segment?strokePathWithCache(t,e,i,s):strokePathDirect(t,e,i,s)}class LineElement extends Element{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>"borderDash"!==t&&"fill"!==t};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||"monotone"===i.cubicInterpolationMode)&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;_updateBezierControlPoints(this._points,i,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=_computeSegments(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],n=this.points,o=_boundSegments(this,{property:e,start:s,end:s});if(!o.length)return;const a=[],r=_getInterpolationMethod(i);let l,h;for(l=0,h=o.length;l<h;++l){const{start:h,end:c}=o[l],d=n[h],u=n[c];if(d===u){a.push(d);continue}const g=r(d,u,Math.abs((s-d[e])/(u[e]-d[e])),i.stepped);g[e]=t[e],a.push(g)}return 1===a.length?a[0]:a}pathSegment(t,e,i){return _getSegmentMethod(this)(t,this,e,i)}path(t,e,i){const s=this.segments,n=_getSegmentMethod(this);let o=this._loop;e=e||0,i=i||this.points.length-e;for(const a of s)o&=n(t,this,a,{start:e,end:e+i-1});return!!o}draw(t,e,i,s){const n=this.options||{};(this.points||[]).length&&n.borderWidth&&(t.save(),draw(t,this,i,s),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function inRange$1(t,e,i,s){const n=t.options,{[i]:o}=t.getProps([i],s);return Math.abs(e-o)<n.radius+n.hitRadius}class PointElement extends Element{static id="point";static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,i){const s=this.options,{x:n,y:o}=this.getProps(["x","y"],i);return Math.pow(t-n,2)+Math.pow(e-o,2)<Math.pow(s.hitRadius+s.radius,2)}inXRange(t,e){return inRange$1(this,t,"x",e)}inYRange(t,e){return inRange$1(this,t,"y",e)}getCenterPoint(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}size(t){let e=(t=t||this.options||{}).radius||0;e=Math.max(e,e&&t.hoverRadius||0);return 2*(e+(e&&t.borderWidth||0))}draw(t,e){const i=this.options;this.skip||i.radius<.1||!_isPointInArea(this,e,this.size(i)/2)||(t.strokeStyle=i.borderColor,t.lineWidth=i.borderWidth,t.fillStyle=i.backgroundColor,drawPoint(t,i,this.x,this.y))}getRange(){const t=this.options||{};return t.radius+t.hitRadius}}function getBarBounds(t,e){const{x:i,y:s,base:n,width:o,height:a}=t.getProps(["x","y","base","width","height"],e);let r,l,h,c,d;return t.horizontal?(d=a/2,r=Math.min(i,n),l=Math.max(i,n),h=s-d,c=s+d):(d=o/2,r=i-d,l=i+d,h=Math.min(s,n),c=Math.max(s,n)),{left:r,top:h,right:l,bottom:c}}function skipOrLimit(t,e,i,s){return t?0:_limitValue(e,i,s)}function parseBorderWidth(t,e,i){const s=t.options.borderWidth,n=t.borderSkipped,o=toTRBL(s);return{t:skipOrLimit(n.top,o.top,0,i),r:skipOrLimit(n.right,o.right,0,e),b:skipOrLimit(n.bottom,o.bottom,0,i),l:skipOrLimit(n.left,o.left,0,e)}}function parseBorderRadius(t,e,i){const{enableBorderRadius:s}=t.getProps(["enableBorderRadius"]),n=t.options.borderRadius,o=toTRBLCorners(n),a=Math.min(e,i),r=t.borderSkipped,l=s||isObject(n);return{topLeft:skipOrLimit(!l||r.top||r.left,o.topLeft,0,a),topRight:skipOrLimit(!l||r.top||r.right,o.topRight,0,a),bottomLeft:skipOrLimit(!l||r.bottom||r.left,o.bottomLeft,0,a),bottomRight:skipOrLimit(!l||r.bottom||r.right,o.bottomRight,0,a)}}function boundingRects(t){const e=getBarBounds(t),i=e.right-e.left,s=e.bottom-e.top,n=parseBorderWidth(t,i/2,s/2),o=parseBorderRadius(t,i/2,s/2);return{outer:{x:e.left,y:e.top,w:i,h:s,radius:o},inner:{x:e.left+n.l,y:e.top+n.t,w:i-n.l-n.r,h:s-n.t-n.b,radius:{topLeft:Math.max(0,o.topLeft-Math.max(n.t,n.l)),topRight:Math.max(0,o.topRight-Math.max(n.t,n.r)),bottomLeft:Math.max(0,o.bottomLeft-Math.max(n.b,n.l)),bottomRight:Math.max(0,o.bottomRight-Math.max(n.b,n.r))}}}}function inRange(t,e,i,s){const n=null===e,o=null===i,a=t&&!(n&&o)&&getBarBounds(t,s);return a&&(n||_isBetween(e,a.left,a.right))&&(o||_isBetween(i,a.top,a.bottom))}function hasRadius(t){return t.topLeft||t.topRight||t.bottomLeft||t.bottomRight}function addNormalRectPath(t,e){t.rect(e.x,e.y,e.w,e.h)}function inflateRect(t,e,i={}){const s=t.x!==i.x?-e:0,n=t.y!==i.y?-e:0,o=(t.x+t.w!==i.x+i.w?e:0)-s,a=(t.y+t.h!==i.y+i.h?e:0)-n;return{x:t.x+s,y:t.y+n,w:t.w+o,h:t.h+a,radius:t.radius}}class BarElement extends Element{static id="bar";static defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:e,options:{borderColor:i,backgroundColor:s}}=this,{inner:n,outer:o}=boundingRects(this),a=hasRadius(o.radius)?addRoundedRectPath:addNormalRectPath;t.save(),o.w===n.w&&o.h===n.h||(t.beginPath(),a(t,inflateRect(o,e,n)),t.clip(),a(t,inflateRect(n,-e,o)),t.fillStyle=i,t.fill("evenodd")),t.beginPath(),a(t,inflateRect(n,e)),t.fillStyle=s,t.fill(),t.restore()}inRange(t,e,i){return inRange(this,t,e,i)}inXRange(t,e){return inRange(this,t,null,e)}inYRange(t,e){return inRange(this,null,t,e)}getCenterPoint(t){const{x:e,y:i,base:s,horizontal:n}=this.getProps(["x","y","base","horizontal"],t);return{x:n?(e+s)/2:e,y:n?i:(i+s)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}var elements=Object.freeze({__proto__:null,ArcElement,LineElement,PointElement,BarElement});const BORDER_COLORS=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],BACKGROUND_COLORS=BORDER_COLORS.map((t=>t.replace("rgb(","rgba(").replace(")",", 0.5)")));function getBorderColor(t){return BORDER_COLORS[t%BORDER_COLORS.length]}function getBackgroundColor(t){return BACKGROUND_COLORS[t%BACKGROUND_COLORS.length]}function colorizeDefaultDataset(t,e){return t.borderColor=getBorderColor(e),t.backgroundColor=getBackgroundColor(e),++e}function colorizeDoughnutDataset(t,e){return t.backgroundColor=t.data.map((()=>getBorderColor(e++))),e}function colorizePolarAreaDataset(t,e){return t.backgroundColor=t.data.map((()=>getBackgroundColor(e++))),e}function getColorizer(t){let e=0;return(i,s)=>{const n=t.getDatasetMeta(s).controller;n instanceof DoughnutController?e=colorizeDoughnutDataset(i,e):n instanceof PolarAreaController?e=colorizePolarAreaDataset(i,e):n&&(e=colorizeDefaultDataset(i,e))}}function containsColorsDefinitions(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}function containsColorsDefinition(t){return t&&(t.borderColor||t.backgroundColor)}var plugin_colors={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,i){if(!i.enabled)return;const{data:{datasets:s},options:n}=t.config,{elements:o}=n;if(!i.forceOverride&&(containsColorsDefinitions(s)||containsColorsDefinition(n)||o&&containsColorsDefinitions(o)))return;const a=getColorizer(t);s.forEach(a)}};function lttbDecimation(t,e,i,s,n){const o=n.samples||s;if(o>=i)return t.slice(e,e+i);const a=[],r=(i-2)/(o-2);let l=0;const h=e+i-1;let c,d,u,g,f,p=e;for(a[l++]=t[p],c=0;c<o-2;c++){let s,n=0,o=0;const h=Math.floor((c+1)*r)+1+e,m=Math.min(Math.floor((c+2)*r)+1,i)+e,b=m-h;for(s=h;s<m;s++)n+=t[s].x,o+=t[s].y;n/=b,o/=b;const x=Math.floor(c*r)+1+e,_=Math.min(Math.floor((c+1)*r)+1,i)+e,{x:y,y:v}=t[p];for(u=g=-1,s=x;s<_;s++)g=.5*Math.abs((y-n)*(t[s].y-v)-(y-t[s].x)*(o-v)),g>u&&(u=g,d=t[s],f=s);a[l++]=d,p=f}return a[l++]=t[h],a}function minMaxDecimation(t,e,i,s){let n,o,a,r,l,h,c,d,u,g,f=0,p=0;const m=[],b=e+i-1,x=t[e].x,_=t[b].x-x;for(n=e;n<e+i;++n){o=t[n],a=(o.x-x)/_*s,r=o.y;const e=0|a;if(e===l)r<u?(u=r,h=n):r>g&&(g=r,c=n),f=(p*f+o.x)/++p;else{const i=n-1;if(!isNullOrUndef(h)&&!isNullOrUndef(c)){const e=Math.min(h,c),s=Math.max(h,c);e!==d&&e!==i&&m.push({...t[e],x:f}),s!==d&&s!==i&&m.push({...t[s],x:f})}n>0&&i!==d&&m.push(t[i]),m.push(o),l=e,p=0,u=g=r,h=c=d=n}}return m}function cleanDecimatedDataset(t){if(t._decimated){const e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,writable:!0,value:e})}}function cleanDecimatedData(t){t.data.datasets.forEach((t=>{cleanDecimatedDataset(t)}))}function getStartAndCountOfVisiblePointsSimplified(t,e){const i=e.length;let s,n=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:h}=o.getUserBounds();return l&&(n=_limitValue(_lookupByKey(e,o.axis,a).lo,0,i-1)),s=h?_limitValue(_lookupByKey(e,o.axis,r).hi+1,n,i)-n:i-n,{start:n,count:s}}var plugin_decimation={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return void cleanDecimatedData(t);const s=t.width;t.data.datasets.forEach(((e,n)=>{const{_data:o,indexAxis:a}=e,r=t.getDatasetMeta(n),l=o||e.data;if("y"===resolve([a,t.options.indexAxis]))return;if(!r.controller.supportsDecimation)return;const h=t.scales[r.xAxisID];if("linear"!==h.type&&"time"!==h.type)return;if(t.options.parsing)return;let{start:c,count:d}=getStartAndCountOfVisiblePointsSimplified(r,l);if(d<=(i.threshold||4*s))return void cleanDecimatedDataset(e);let u;switch(isNullOrUndef(o)&&(e._data=l,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"lttb":u=lttbDecimation(l,c,d,s,i);break;case"min-max":u=minMaxDecimation(l,c,d,s);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=u}))},destroy(t){cleanDecimatedData(t)}};function _segments(t,e,i){const s=t.segments,n=t.points,o=e.points,a=[];for(const t of s){let{start:s,end:r}=t;r=_findSegmentEnd(s,r,n);const l=_getBounds(i,n[s],n[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:n[s],end:n[r]});continue}const h=_boundSegments(e,l);for(const e of h){const s=_getBounds(i,o[e.start],o[e.end],e.loop),r=_boundSegment(t,n,s);for(const t of r)a.push({source:t,target:e,start:{[i]:_getEdge(l,s,"start",Math.max)},end:{[i]:_getEdge(l,s,"end",Math.min)}})}}return a}function _getBounds(t,e,i,s){if(s)return;let n=e[t],o=i[t];return"angle"===t&&(n=_normalizeAngle(n),o=_normalizeAngle(o)),{property:t,start:n,end:o}}function _pointsFromSegments(t,e){const{x:i=null,y:s=null}=t||{},n=e.points,o=[];return e.segments.forEach((({start:t,end:e})=>{e=_findSegmentEnd(t,e,n);const a=n[t],r=n[e];null!==s?(o.push({x:a.x,y:s}),o.push({x:r.x,y:s})):null!==i&&(o.push({x:i,y:a.y}),o.push({x:i,y:r.y}))})),o}function _findSegmentEnd(t,e,i){for(;e>t;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function _getEdge(t,e,i,s){return t&&e?s(t[i],e[i]):t?t[i]:e?e[i]:0}function _createBoundaryLine(t,e){let i=[],s=!1;return isArray(t)?(s=!0,i=t):i=_pointsFromSegments(t,e),i.length?new LineElement({points:i,options:{tension:0},_loop:s,_fullLoop:s}):null}function _shouldApplyFill(t){return t&&!1!==t.fill}function _resolveTarget(t,e,i){let s=t[e].fill;const n=[e];let o;if(!i)return s;for(;!1!==s&&-1===n.indexOf(s);){if(!isNumberFinite(s))return s;if(o=t[s],!o)return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function _decodeFill(t,e,i){const s=parseFillOption(t);if(isObject(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return isNumberFinite(n)&&Math.floor(n)===n?decodeTargetIndex(s[0],e,n,i):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function decodeTargetIndex(t,e,i,s){return"-"!==t&&"+"!==t||(i=e+i),!(i===e||i<0||i>=s)&&i}function _getTargetPixel(t,e){let i=null;return"start"===t?i=e.bottom:"end"===t?i=e.top:isObject(t)?i=e.getPixelForValue(t.value):e.getBasePixel&&(i=e.getBasePixel()),i}function _getTargetValue(t,e,i){let s;return s="start"===t?i:"end"===t?e.options.reverse?e.min:e.max:isObject(t)?t.value:e.getBaseValue(),s}function parseFillOption(t){const e=t.options,i=e.fill;let s=valueOrDefault(i&&i.target,i);return void 0===s&&(s=!!e.backgroundColor),!1!==s&&null!==s&&(!0===s?"origin":s)}function _buildStackLine(t){const{scale:e,index:i,line:s}=t,n=[],o=s.segments,a=s.points,r=getLinesBelow(e,i);r.push(_createBoundaryLine({x:null,y:e.bottom},s));for(let t=0;t<o.length;t++){const e=o[t];for(let t=e.start;t<=e.end;t++)addPointsBelow(n,a[t],r)}return new LineElement({points:n,options:{}})}function getLinesBelow(t,e){const i=[],s=t.getMatchingVisibleMetas("line");for(let t=0;t<s.length;t++){const n=s[t];if(n.index===e)break;n.hidden||i.unshift(n.dataset)}return i}function addPointsBelow(t,e,i){const s=[];for(let n=0;n<i.length;n++){const o=i[n],{first:a,last:r,point:l}=findPoint(o,e,"x");if(!(!l||a&&r))if(a)s.unshift(l);else if(t.push(l),!r)break}t.push(...s)}function findPoint(t,e,i){const s=t.interpolate(e,i);if(!s)return{};const n=s[i],o=t.segments,a=t.points;let r=!1,l=!1;for(let t=0;t<o.length;t++){const e=o[t],s=a[e.start][i],h=a[e.end][i];if(_isBetween(n,s,h)){r=n===s,l=n===h;break}}return{first:r,last:l,point:s}}class simpleArc{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:s,y:n,radius:o}=this;return e=e||{start:0,end:TAU},t.arc(s,n,o,e.end,e.start,!0),!i.bounds}interpolate(t){const{x:e,y:i,radius:s}=this,n=t.angle;return{x:e+Math.cos(n)*s,y:i+Math.sin(n)*s,angle:n}}}function _getTarget(t){const{chart:e,fill:i,line:s}=t;if(isNumberFinite(i))return getLineByIndex(e,i);if("stack"===i)return _buildStackLine(t);if("shape"===i)return!0;const n=computeBoundary(t);return n instanceof simpleArc?n:_createBoundaryLine(n,s)}function getLineByIndex(t,e){const i=t.getDatasetMeta(e);return i&&t.isDatasetVisible(e)?i.dataset:null}function computeBoundary(t){return(t.scale||{}).getPointPositionForValue?computeCircularBoundary(t):computeLinearBoundary(t)}function computeLinearBoundary(t){const{scale:e={},fill:i}=t,s=_getTargetPixel(i,e);if(isNumberFinite(s)){const t=e.isHorizontal();return{x:t?s:null,y:t?null:s}}return null}function computeCircularBoundary(t){const{scale:e,fill:i}=t,s=e.options,n=e.getLabels().length,o=s.reverse?e.max:e.min,a=_getTargetValue(i,e,o),r=[];if(s.grid.circular){const t=e.getPointPositionForValue(0,o);return new simpleArc({x:t.x,y:t.y,radius:e.getDistanceFromCenterForValue(a)})}for(let t=0;t<n;++t)r.push(e.getPointPositionForValue(t,a));return r}function _drawfill(t,e,i){const s=_getTarget(e),{line:n,scale:o,axis:a}=e,r=n.options,l=r.fill,h=r.backgroundColor,{above:c=h,below:d=h}=l||{};s&&n.points.length&&(clipArea(t,i),doFill(t,{line:n,target:s,above:c,below:d,area:i,scale:o,axis:a}),unclipArea(t))}function doFill(t,e){const{line:i,target:s,above:n,below:o,area:a,scale:r}=e,l=i._loop?"angle":e.axis;t.save(),"x"===l&&o!==n&&(clipVertical(t,s,a.top),fill(t,{line:i,target:s,color:n,scale:r,property:l}),t.restore(),t.save(),clipVertical(t,s,a.bottom)),fill(t,{line:i,target:s,color:o,scale:r,property:l}),t.restore()}function clipVertical(t,e,i){const{segments:s,points:n}=e;let o=!0,a=!1;t.beginPath();for(const r of s){const{start:s,end:l}=r,h=n[s],c=n[_findSegmentEnd(s,l,n)];o?(t.moveTo(h.x,h.y),o=!1):(t.lineTo(h.x,i),t.lineTo(h.x,h.y)),a=!!e.pathSegment(t,r,{move:a}),a?t.closePath():t.lineTo(c.x,i)}t.lineTo(e.first().x,i),t.closePath(),t.clip()}function fill(t,e){const{line:i,target:s,property:n,color:o,scale:a}=e,r=_segments(i,s,n);for(const{source:e,target:l,start:h,end:c}of r){const{style:{backgroundColor:r=o}={}}=e,d=!0!==s;t.save(),t.fillStyle=r,clipBounds(t,a,d&&_getBounds(n,h,c)),t.beginPath();const u=!!i.pathSegment(t,e);let g;if(d){u?t.closePath():interpolatedLineTo(t,s,c,n);const e=!!s.pathSegment(t,l,{move:u,reverse:!0});g=u&&e,g||interpolatedLineTo(t,s,h,n)}t.closePath(),t.fill(g?"evenodd":"nonzero"),t.restore()}}function clipBounds(t,e,i){const{top:s,bottom:n}=e.chart.chartArea,{property:o,start:a,end:r}=i||{};"x"===o&&(t.beginPath(),t.rect(a,s,r-a,n-s),t.clip())}function interpolatedLineTo(t,e,i,s){const n=e.interpolate(i,s);n&&t.lineTo(n.x,n.y)}var index={id:"filler",afterDatasetsUpdate(t,e,i){const s=(t.data.datasets||[]).length,n=[];let o,a,r,l;for(a=0;a<s;++a)o=t.getDatasetMeta(a),r=o.dataset,l=null,r&&r.options&&r instanceof LineElement&&(l={visible:t.isDatasetVisible(a),index:a,fill:_decodeFill(r,a,s),chart:t,axis:o.controller.options.indexAxis,scale:o.vScale,line:r}),o.$filler=l,n.push(l);for(a=0;a<s;++a)l=n[a],l&&!1!==l.fill&&(l.fill=_resolveTarget(n,a,i.propagate))},beforeDraw(t,e,i){const s="beforeDraw"===i.drawTime,n=t.getSortedVisibleDatasetMetas(),o=t.chartArea;for(let e=n.length-1;e>=0;--e){const i=n[e].$filler;i&&(i.line.updateControlPoints(o,i.axis),s&&i.fill&&_drawfill(t.ctx,i,o))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const s=t.getSortedVisibleDatasetMetas();for(let e=s.length-1;e>=0;--e){const i=s[e].$filler;_shouldApplyFill(i)&&_drawfill(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const s=e.meta.$filler;_shouldApplyFill(s)&&"beforeDatasetDraw"===i.drawTime&&_drawfill(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const getBoxSize=(t,e)=>{let{boxHeight:i=e,boxWidth:s=e}=t;return t.usePointStyle&&(i=Math.min(i,e),s=t.pointStyleWidth||Math.min(s,e)),{boxWidth:s,boxHeight:i,itemHeight:Math.max(e,i)}},itemsEqual=(t,e)=>null!==t&&null!==e&&t.datasetIndex===e.datasetIndex&&t.index===e.index;class Legend extends Element{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=callback(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter((e=>t.filter(e,this.chart.data)))),t.sort&&(e=e.sort(((e,i)=>t.sort(e,i,this.chart.data)))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,s=toFont(i.font),n=s.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=getBoxSize(i,n);let l,h;e.font=s.string,this.isHorizontal()?(l=this.maxWidth,h=this._fitRows(o,n,a,r)+10):(h=this.maxHeight,l=this._fitCols(o,s,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:n,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],h=s+a;let c=t;n.textAlign="left",n.textBaseline="middle";let d=-1,u=-h;return this.legendItems.forEach(((t,g)=>{const f=i+e/2+n.measureText(t.text).width;(0===g||l[l.length-1]+f+2*a>o)&&(c+=h,l[l.length-(g>0?0:1)]=0,u+=h,d++),r[g]={left:0,top:u,row:d,width:f,height:s},l[l.length-1]+=f+a})),c}_fitCols(t,e,i,s){const{ctx:n,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],h=o-t;let c=a,d=0,u=0,g=0,f=0;return this.legendItems.forEach(((t,o)=>{const{itemWidth:p,itemHeight:m}=calculateItemSize(i,e,n,t,s);o>0&&u+m+2*a>h&&(c+=d+a,l.push({width:d,height:u}),g+=d+a,f++,d=u=0),r[o]={left:g,top:u,col:f,width:p,height:m},d=Math.max(d,p),u+=m+a})),c+=d,l.push({width:d,height:u}),c}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:n}}=this,o=getRtlAdapter(n,this.left,this.width);if(this.isHorizontal()){let n=0,a=_alignStartEnd(i,this.left+s,this.right-this.lineWidths[n]);for(const r of e)n!==r.row&&(n=r.row,a=_alignStartEnd(i,this.left+s,this.right-this.lineWidths[n])),r.top+=this.top+t+s,r.left=o.leftForLtr(o.x(a),r.width),a+=r.width+s}else{let n=0,a=_alignStartEnd(i,this.top+t+s,this.bottom-this.columnSizes[n].height);for(const r of e)r.col!==n&&(n=r.col,a=_alignStartEnd(i,this.top+t+s,this.bottom-this.columnSizes[n].height)),r.top=a,r.left+=this.left+s,r.left=o.leftForLtr(o.x(r.left),r.width),a+=r.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;clipArea(t,this),this._draw(),unclipArea(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:n,labels:o}=t,a=defaults.color,r=getRtlAdapter(t.rtl,this.left,this.width),l=toFont(o.font),{padding:h}=o,c=l.size,d=c/2;let u;this.drawTitle(),s.textAlign=r.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=l.string;const{boxWidth:g,boxHeight:f,itemHeight:p}=getBoxSize(o,c),m=this.isHorizontal(),b=this._computeTitleHeight();u=m?{x:_alignStartEnd(n,this.left+h,this.right-i[0]),y:this.top+h+b,line:0}:{x:this.left+h,y:_alignStartEnd(n,this.top+b+h,this.bottom-e[0].height),line:0},overrideTextDirection(this.ctx,t.textDirection);const x=p+h;this.legendItems.forEach(((_,y)=>{s.strokeStyle=_.fontColor,s.fillStyle=_.fontColor;const v=s.measureText(_.text).width,S=r.textAlign(_.textAlign||(_.textAlign=o.textAlign)),k=g+d+v;let P=u.x,M=u.y;r.setWidth(this.width),m?y>0&&P+k+h>this.right&&(M=u.y+=x,u.line++,P=u.x=_alignStartEnd(n,this.left+h,this.right-i[u.line])):y>0&&M+x>this.bottom&&(P=u.x=P+e[u.line].width+h,u.line++,M=u.y=_alignStartEnd(n,this.top+b+h,this.bottom-e[u.line].height));if(function(t,e,i){if(isNaN(g)||g<=0||isNaN(f)||f<0)return;s.save();const n=valueOrDefault(i.lineWidth,1);if(s.fillStyle=valueOrDefault(i.fillStyle,a),s.lineCap=valueOrDefault(i.lineCap,"butt"),s.lineDashOffset=valueOrDefault(i.lineDashOffset,0),s.lineJoin=valueOrDefault(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=valueOrDefault(i.strokeStyle,a),s.setLineDash(valueOrDefault(i.lineDash,[])),o.usePointStyle){const a={radius:f*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},l=r.xPlus(t,g/2);drawPointLegend(s,a,l,e+d,o.pointStyleWidth&&g)}else{const o=e+Math.max((c-f)/2,0),a=r.leftForLtr(t,g),l=toTRBLCorners(i.borderRadius);s.beginPath(),Object.values(l).some((t=>0!==t))?addRoundedRectPath(s,{x:a,y:o,w:g,h:f,radius:l}):s.rect(a,o,g,f),s.fill(),0!==n&&s.stroke()}s.restore()}(r.x(P),M,_),P=_textX(S,P+g+d,m?P+k:this.right,t.rtl),function(t,e,i){renderText(s,i.text,t,e+p/2,l,{strikethrough:i.hidden,textAlign:r.textAlign(i.textAlign)})}(r.x(P),M,_),m)u.x+=k+h;else if("string"!=typeof _.text){const t=l.lineHeight;u.y+=calculateLegendItemHeight(_,t)}else u.y+=x})),restoreTextDirection(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=toFont(e.font),s=toPadding(e.padding);if(!e.display)return;const n=getRtlAdapter(t.rtl,this.left,this.width),o=this.ctx,a=e.position,r=i.size/2,l=s.top+r;let h,c=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),h=this.top+l,c=_alignStartEnd(t.align,c,this.right-d);else{const e=this.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);h=l+_alignStartEnd(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const u=_alignStartEnd(a,c,c+d);o.textAlign=n.textAlign(_toLeftRightCenter(a)),o.textBaseline="middle",o.strokeStyle=e.color,o.fillStyle=e.color,o.font=i.string,renderText(o,e.text,u,h,i)}_computeTitleHeight(){const t=this.options.title,e=toFont(t.font),i=toPadding(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,n;if(_isBetween(t,this.left,this.right)&&_isBetween(e,this.top,this.bottom))for(n=this.legendHitBoxes,i=0;i<n.length;++i)if(s=n[i],_isBetween(t,s.left,s.left+s.width)&&_isBetween(e,s.top,s.top+s.height))return this.legendItems[i];return null}handleEvent(t){const e=this.options;if(!isListened(t.type,e))return;const i=this._getLegendItemAt(t.x,t.y);if("mousemove"===t.type||"mouseout"===t.type){const s=this._hoveredItem,n=itemsEqual(s,i);s&&!n&&callback(e.onLeave,[t,s,this],this),this._hoveredItem=i,i&&!n&&callback(e.onHover,[t,i,this],this)}else i&&callback(e.onClick,[t,i,this],this)}}function calculateItemSize(t,e,i,s,n){return{itemWidth:calculateItemWidth(s,t,e,i),itemHeight:calculateItemHeight(n,s,e.lineHeight)}}function calculateItemWidth(t,e,i,s){let n=t.text;return n&&"string"!=typeof n&&(n=n.reduce(((t,e)=>t.length>e.length?t:e))),e+i.size/2+s.measureText(n).width}function calculateItemHeight(t,e,i){let s=t;return"string"!=typeof e.text&&(s=calculateLegendItemHeight(e,i)),s}function calculateLegendItemHeight(t,e){return e*(t.text?t.text.length+.5:0)}function isListened(t,e){return!("mousemove"!==t&&"mouseout"!==t||!e.onHover&&!e.onLeave)||!(!e.onClick||"click"!==t&&"mouseup"!==t)}var plugin_legend={id:"legend",_element:Legend,start(t,e,i){const s=t.legend=new Legend({ctx:t.ctx,options:i,chart:t});layouts.configure(t,s,i),layouts.addBox(t,s)},stop(t){layouts.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,i){const s=t.legend;layouts.configure(t,s,i),s.options=i},afterUpdate(t){const e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,i){const s=e.datasetIndex,n=i.chart;n.isDatasetVisible(s)?(n.hide(s),e.hidden=!0):(n.show(s),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:s,textAlign:n,color:o,useBorderRadius:a,borderRadius:r}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const l=t.controller.getStyle(i?0:void 0),h=toPadding(l.borderWidth);return{text:e[t.index].label,fillStyle:l.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:l.borderCapStyle,lineDash:l.borderDash,lineDashOffset:l.borderDashOffset,lineJoin:l.borderJoinStyle,lineWidth:(h.width+h.height)/4,strokeStyle:l.borderColor,pointStyle:s||l.pointStyle,rotation:l.rotation,textAlign:n||l.textAlign,borderRadius:a&&(r||l.borderRadius),datasetIndex:t.index}}),this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class Title extends Element{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const s=isArray(i.text)?i.text.length:1;this._padding=toPadding(i.padding);const n=s*toFont(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=n:this.width=n}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:s,right:n,options:o}=this,a=o.align;let r,l,h,c=0;return this.isHorizontal()?(l=_alignStartEnd(a,i,n),h=e+t,r=n-i):("left"===o.position?(l=i+t,h=_alignStartEnd(a,s,e),c=-.5*PI):(l=n-t,h=_alignStartEnd(a,e,s),c=.5*PI),r=s-e),{titleX:l,titleY:h,maxWidth:r,rotation:c}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=toFont(e.font),s=i.lineHeight/2+this._padding.top,{titleX:n,titleY:o,maxWidth:a,rotation:r}=this._drawArgs(s);renderText(t,e.text,0,0,i,{color:e.color,maxWidth:a,rotation:r,textAlign:_toLeftRightCenter(e.align),textBaseline:"middle",translation:[n,o]})}}function createTitle(t,e){const i=new Title({ctx:t.ctx,options:e,chart:t});layouts.configure(t,i,e),layouts.addBox(t,i),t.titleBlock=i}var plugin_title={id:"title",_element:Title,start(t,e,i){createTitle(t,i)},stop(t){const e=t.titleBlock;layouts.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const s=t.titleBlock;layouts.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const map=new WeakMap;var plugin_subtitle={id:"subtitle",start(t,e,i){const s=new Title({ctx:t.ctx,options:i,chart:t});layouts.configure(t,s,i),layouts.addBox(t,s),map.set(t,s)},stop(t){layouts.removeBox(t,map.get(t)),map.delete(t)},beforeUpdate(t,e,i){const s=map.get(t);layouts.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const positioners={average(t){if(!t.length)return!1;let e,i,s=0,n=0,o=0;for(e=0,i=t.length;e<i;++e){const i=t[e].element;if(i&&i.hasValue()){const t=i.tooltipPosition();s+=t.x,n+=t.y,++o}}return{x:s/o,y:n/o}},nearest(t,e){if(!t.length)return!1;let i,s,n,o=e.x,a=e.y,r=Number.POSITIVE_INFINITY;for(i=0,s=t.length;i<s;++i){const s=t[i].element;if(s&&s.hasValue()){const t=distanceBetweenPoints(e,s.getCenterPoint());t<r&&(r=t,n=s)}}if(n){const t=n.tooltipPosition();o=t.x,a=t.y}return{x:o,y:a}}};function pushOrConcat(t,e){return e&&(isArray(e)?Array.prototype.push.apply(t,e):t.push(e)),t}function splitNewlines(t){return("string"==typeof t||t instanceof String)&&t.indexOf("\n")>-1?t.split("\n"):t}function createTooltipItem(t,e){const{element:i,datasetIndex:s,index:n}=e,o=t.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:t,label:a,parsed:o.getParsed(n),raw:t.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:i}}function getTooltipSize(t,e){const i=t.chart.ctx,{body:s,footer:n,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=toFont(e.bodyFont),h=toFont(e.titleFont),c=toFont(e.footerFont),d=o.length,u=n.length,g=s.length,f=toPadding(e.padding);let p=f.height,m=0,b=s.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);if(b+=t.beforeBody.length+t.afterBody.length,d&&(p+=d*h.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),b){p+=g*(e.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(b-g)*l.lineHeight+(b-1)*e.bodySpacing}u&&(p+=e.footerMarginTop+u*c.lineHeight+(u-1)*e.footerSpacing);let x=0;const _=function(t){m=Math.max(m,i.measureText(t).width+x)};return i.save(),i.font=h.string,each(t.title,_),i.font=l.string,each(t.beforeBody.concat(t.afterBody),_),x=e.displayColors?a+2+e.boxPadding:0,each(s,(t=>{each(t.before,_),each(t.lines,_),each(t.after,_)})),x=0,i.font=c.string,each(t.footer,_),i.restore(),m+=f.width,{width:m,height:p}}function determineYAlign(t,e){const{y:i,height:s}=e;return i<s/2?"top":i>t.height-s/2?"bottom":"center"}function doesNotFitWithAlign(t,e,i,s){const{x:n,width:o}=s,a=i.caretSize+i.caretPadding;return"left"===t&&n+o+a>e.width||("right"===t&&n-o-a<0||void 0)}function determineXAlign(t,e,i,s){const{x:n,width:o}=i,{width:a,chartArea:{left:r,right:l}}=t;let h="center";return"center"===s?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),doesNotFitWithAlign(h,t,e,i)&&(h="center"),h}function determineAlignment(t,e,i){const s=i.yAlign||e.yAlign||determineYAlign(t,i);return{xAlign:i.xAlign||e.xAlign||determineXAlign(t,e,i,s),yAlign:s}}function alignX(t,e){let{x:i,width:s}=t;return"right"===e?i-=s:"center"===e&&(i-=s/2),i}function alignY(t,e,i){let{y:s,height:n}=t;return"top"===e?s+=i:s-="bottom"===e?n+i:n/2,s}function getBackgroundPoint(t,e,i,s){const{caretSize:n,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,h=n+o,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:g}=toTRBLCorners(a);let f=alignX(e,r);const p=alignY(e,l,h);return"center"===l?"left"===r?f+=h:"right"===r&&(f-=h):"left"===r?f-=Math.max(c,u)+n:"right"===r&&(f+=Math.max(d,g)+n),{x:_limitValue(f,0,s.width-e.width),y:_limitValue(p,0,s.height-e.height)}}function getAlignedX(t,e,i){const s=toPadding(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-s.right:t.x+s.left}function getBeforeAfterBodyLines(t){return pushOrConcat([],splitNewlines(t))}function createTooltipContext(t,e,i){return createContext(t,{tooltip:e,tooltipItems:i,type:"tooltip"})}function overrideCallbacks(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}const defaultCallbacks={beforeTitle:noop,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,s=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex<s)return i[e.dataIndex]}return""},afterTitle:noop,beforeBody:noop,beforeLabel:noop,label(t){if(this&&this.options&&"dataset"===this.options.mode)return t.label+": "+t.formattedValue||t.formattedValue;let e=t.dataset.label||"";e&&(e+=": ");const i=t.formattedValue;return isNullOrUndef(i)||(e+=i),e},labelColor(t){const e=t.chart.getDatasetMeta(t.datasetIndex).controller.getStyle(t.dataIndex);return{borderColor:e.borderColor,backgroundColor:e.backgroundColor,borderWidth:e.borderWidth,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(t){const e=t.chart.getDatasetMeta(t.datasetIndex).controller.getStyle(t.dataIndex);return{pointStyle:e.pointStyle,rotation:e.rotation}},afterLabel:noop,afterBody:noop,beforeFooter:noop,footer:noop,afterFooter:noop};function invokeCallbackWithFallback(t,e,i,s){const n=t[e].call(i,s);return void 0===n?defaultCallbacks[e].call(i,s):n}class Tooltip extends Element{static positioners=positioners;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,n=new Animations(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(n)),n}getContext(){return this.$context||(this.$context=createTooltipContext(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:i}=e,s=invokeCallbackWithFallback(i,"beforeTitle",this,t),n=invokeCallbackWithFallback(i,"title",this,t),o=invokeCallbackWithFallback(i,"afterTitle",this,t);let a=[];return a=pushOrConcat(a,splitNewlines(s)),a=pushOrConcat(a,splitNewlines(n)),a=pushOrConcat(a,splitNewlines(o)),a}getBeforeBody(t,e){return getBeforeAfterBodyLines(invokeCallbackWithFallback(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:i}=e,s=[];return each(t,(t=>{const e={before:[],lines:[],after:[]},n=overrideCallbacks(i,t);pushOrConcat(e.before,splitNewlines(invokeCallbackWithFallback(n,"beforeLabel",this,t))),pushOrConcat(e.lines,invokeCallbackWithFallback(n,"label",this,t)),pushOrConcat(e.after,splitNewlines(invokeCallbackWithFallback(n,"afterLabel",this,t))),s.push(e)})),s}getAfterBody(t,e){return getBeforeAfterBodyLines(invokeCallbackWithFallback(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:i}=e,s=invokeCallbackWithFallback(i,"beforeFooter",this,t),n=invokeCallbackWithFallback(i,"footer",this,t),o=invokeCallbackWithFallback(i,"afterFooter",this,t);let a=[];return a=pushOrConcat(a,splitNewlines(s)),a=pushOrConcat(a,splitNewlines(n)),a=pushOrConcat(a,splitNewlines(o)),a}_createItems(t){const e=this._active,i=this.chart.data,s=[],n=[],o=[];let a,r,l=[];for(a=0,r=e.length;a<r;++a)l.push(createTooltipItem(this.chart,e[a]));return t.filter&&(l=l.filter(((e,s,n)=>t.filter(e,s,n,i)))),t.itemSort&&(l=l.sort(((e,s)=>t.itemSort(e,s,i)))),each(l,(e=>{const i=overrideCallbacks(t.callbacks,e);s.push(invokeCallbackWithFallback(i,"labelColor",this,e)),n.push(invokeCallbackWithFallback(i,"labelPointStyle",this,e)),o.push(invokeCallbackWithFallback(i,"labelTextColor",this,e))})),this.labelColors=s,this.labelPointStyles=n,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let n,o=[];if(s.length){const t=positioners[i.position].call(this,s,this._eventPosition);o=this._createItems(i),this.title=this.getTitle(o,i),this.beforeBody=this.getBeforeBody(o,i),this.body=this.getBody(o,i),this.afterBody=this.getAfterBody(o,i),this.footer=this.getFooter(o,i);const e=this._size=getTooltipSize(this,i),a=Object.assign({},t,e),r=determineAlignment(this.chart,i,a),l=getBackgroundPoint(i,a,r,this.chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=o,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const n=this.getCaretPosition(t,i,s);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:n}=this,{caretSize:o,cornerRadius:a}=i,{topLeft:r,topRight:l,bottomLeft:h,bottomRight:c}=toTRBLCorners(a),{x:d,y:u}=t,{width:g,height:f}=e;let p,m,b,x,_,y;return"center"===n?(_=u+f/2,"left"===s?(p=d,m=p-o,x=_+o,y=_-o):(p=d+g,m=p+o,x=_-o,y=_+o),b=p):(m="left"===s?d+Math.max(r,h)+o:"right"===s?d+g-Math.max(l,c)-o:this.caretX,"top"===n?(x=u,_=x-o,p=m-o,b=m+o):(x=u+f,_=x+o,p=m+o,b=m-o),y=x),{x1:p,x2:m,x3:b,y1:x,y2:_,y3:y}}drawTitle(t,e,i){const s=this.title,n=s.length;let o,a,r;if(n){const l=getRtlAdapter(i.rtl,this.x,this.width);for(t.x=getAlignedX(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",o=toFont(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=o.string,r=0;r<n;++r)e.fillText(s[r],l.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+a,r+1===n&&(t.y+=i.titleMarginBottom-a)}}_drawColorBox(t,e,i,s,n){const o=this.labelColors[i],a=this.labelPointStyles[i],{boxHeight:r,boxWidth:l,boxPadding:h}=n,c=toFont(n.bodyFont),d=getAlignedX(this,"left",n),u=s.x(d),g=r<c.lineHeight?(c.lineHeight-r)/2:0,f=e.y+g;if(n.usePointStyle){const e={radius:Math.min(l,r)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},i=s.leftForLtr(u,l)+l/2,h=f+r/2;t.strokeStyle=n.multiKeyBackground,t.fillStyle=n.multiKeyBackground,drawPoint(t,e,i,h),t.strokeStyle=o.borderColor,t.fillStyle=o.backgroundColor,drawPoint(t,e,i,h)}else{t.lineWidth=isObject(o.borderWidth)?Math.max(...Object.values(o.borderWidth)):o.borderWidth||1,t.strokeStyle=o.borderColor,t.setLineDash(o.borderDash||[]),t.lineDashOffset=o.borderDashOffset||0;const e=s.leftForLtr(u,l-h),i=s.leftForLtr(s.xPlus(u,1),l-h-2),a=toTRBLCorners(o.borderRadius);Object.values(a).some((t=>0!==t))?(t.beginPath(),t.fillStyle=n.multiKeyBackground,addRoundedRectPath(t,{x:e,y:f,w:l,h:r,radius:a}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),addRoundedRectPath(t,{x:i,y:f+1,w:l-2,h:r-2,radius:a}),t.fill()):(t.fillStyle=n.multiKeyBackground,t.fillRect(e,f,l,r),t.strokeRect(e,f,l,r),t.fillStyle=o.backgroundColor,t.fillRect(i,f+1,l-2,r-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:n,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:h}=i,c=toFont(i.bodyFont);let d=c.lineHeight,u=0;const g=getRtlAdapter(i.rtl,this.x,this.width),f=function(i){e.fillText(i,g.x(t.x+u),t.y+d/2),t.y+=d+n},p=g.textAlign(o);let m,b,x,_,y,v,S;for(e.textAlign=o,e.textBaseline="middle",e.font=c.string,t.x=getAlignedX(this,p,i),e.fillStyle=i.bodyColor,each(this.beforeBody,f),u=a&&"right"!==p?"center"===o?l/2+h:l+2+h:0,_=0,v=s.length;_<v;++_){for(m=s[_],b=this.labelTextColors[_],e.fillStyle=b,each(m.before,f),x=m.lines,a&&x.length&&(this._drawColorBox(e,t,_,g,i),d=Math.max(c.lineHeight,r)),y=0,S=x.length;y<S;++y)f(x[y]),d=c.lineHeight;each(m.after,f)}u=0,d=c.lineHeight,each(this.afterBody,f),t.y-=n}drawFooter(t,e,i){const s=this.footer,n=s.length;let o,a;if(n){const r=getRtlAdapter(i.rtl,this.x,this.width);for(t.x=getAlignedX(this,i.footerAlign,i),t.y+=i.footerMarginTop,e.textAlign=r.textAlign(i.footerAlign),e.textBaseline="middle",o=toFont(i.footerFont),e.fillStyle=i.footerColor,e.font=o.string,a=0;a<n;++a)e.fillText(s[a],r.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+i.footerSpacing}}drawBackground(t,e,i,s){const{xAlign:n,yAlign:o}=this,{x:a,y:r}=t,{width:l,height:h}=i,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:g}=toTRBLCorners(s.cornerRadius);e.fillStyle=s.backgroundColor,e.strokeStyle=s.borderColor,e.lineWidth=s.borderWidth,e.beginPath(),e.moveTo(a+c,r),"top"===o&&this.drawCaret(t,e,i,s),e.lineTo(a+l-d,r),e.quadraticCurveTo(a+l,r,a+l,r+d),"center"===o&&"right"===n&&this.drawCaret(t,e,i,s),e.lineTo(a+l,r+h-g),e.quadraticCurveTo(a+l,r+h,a+l-g,r+h),"bottom"===o&&this.drawCaret(t,e,i,s),e.lineTo(a+u,r+h),e.quadraticCurveTo(a,r+h,a,r+h-u),"center"===o&&"left"===n&&this.drawCaret(t,e,i,s),e.lineTo(a,r+c),e.quadraticCurveTo(a,r,a+c,r),e.closePath(),e.fill(),s.borderWidth>0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,s=i&&i.x,n=i&&i.y;if(s||n){const i=positioners[t.position].call(this,this._active,this._eventPosition);if(!i)return;const o=this._size=getTooltipSize(this,t),a=Object.assign({},i,this._size),r=determineAlignment(e,t,a),l=getBackgroundPoint(t,a,r,e);s._to===l.x&&n._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,l))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const o=toPadding(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,s,e),overrideTextDirection(t,e.textDirection),n.y+=o.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),restoreTextDirection(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map((({datasetIndex:t,index:e})=>{const i=this.chart.getDatasetMeta(t);if(!i)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:i.data[e],index:e}})),n=!_elementsEqual(i,s),o=this._positionChanged(s,e);(n||o)&&(this._active=s,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,i=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,n=this._active||[],o=this._getActiveElements(t,n,e,i),a=this._positionChanged(o,t),r=e||!_elementsEqual(o,n)||a;return r&&(this._active=o,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),r}_getActiveElements(t,e,i,s){const n=this.options;if("mouseout"===t.type)return[];if(!s)return e;const o=this.chart.getElementsAtEventForMode(t,n.mode,n,i);return n.reverse&&o.reverse(),o}_positionChanged(t,e){const{caretX:i,caretY:s,options:n}=this,o=positioners[n.position].call(this,t,e);return!1!==o&&(i!==o.x||s!==o.y)}}var plugin_tooltip={id:"tooltip",_element:Tooltip,positioners,afterInit(t,e,i){i&&(t.tooltip=new Tooltip({chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const i={tooltip:e};if(!1===t.notifyPlugins("beforeTooltipDraw",{...i,cancelable:!0}))return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i)}},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i,e.inChartArea)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:defaultCallbacks},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:t=>"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},plugins=Object.freeze({__proto__:null,Colors:plugin_colors,Decimation:plugin_decimation,Filler:index,Legend:plugin_legend,SubTitle:plugin_subtitle,Title:plugin_title,Tooltip:plugin_tooltip});const addIfString=(t,e,i,s)=>("string"==typeof e?(i=t.push(e)-1,s.unshift({index:i,label:e})):isNaN(e)&&(i=null),i);function findOrAddLabel(t,e,i,s){const n=t.indexOf(e);if(-1===n)return addIfString(t,e,i,s);return n!==t.lastIndexOf(e)?i:n}const validIndex=(t,e)=>null===t?null:_limitValue(Math.round(t),0,e);function _getLabelForValue(t){const e=this.getLabels();return t>=0&&t<e.length?e[t]:t}class CategoryScale extends Scale{static id="category";static defaults={ticks:{callback:_getLabelForValue}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const e=this._addedLabels;if(e.length){const t=this.getLabels();for(const{index:i,label:s}of e)t[i]===s&&t.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(isNullOrUndef(t))return null;const i=this.getLabels();return e=isFinite(e)&&i[e]===t?e:findOrAddLabel(i,t,valueOrDefault(e,t),this._addedLabels),validIndex(e,i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,e=this.max,i=this.options.offset,s=[];let n=this.getLabels();n=0===t&&e===n.length-1?n:n.slice(t,e+1),this._valueRange=Math.max(n.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let i=t;i<=e;i++)s.push({value:i});return s}getLabelForValue(t){return _getLabelForValue.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return"number"!=typeof t&&(t=this.parse(t)),null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function generateTicks$1(t,e){const i=[],{bounds:s,step:n,min:o,max:a,precision:r,count:l,maxTicks:h,maxDigits:c,includeBounds:d}=t,u=n||1,g=h-1,{min:f,max:p}=e,m=!isNullOrUndef(o),b=!isNullOrUndef(a),x=!isNullOrUndef(l),_=(p-f)/(c+1);let y,v,S,k,P=niceNum((p-f)/g/u)*u;if(P<1e-14&&!m&&!b)return[{value:f},{value:p}];k=Math.ceil(p/P)-Math.floor(f/P),k>g&&(P=niceNum(k*P/g/u)*u),isNullOrUndef(r)||(y=Math.pow(10,r),P=Math.ceil(P*y)/y),"ticks"===s?(v=Math.floor(f/P)*P,S=Math.ceil(p/P)*P):(v=f,S=p),m&&b&&n&&almostWhole((a-o)/n,P/1e3)?(k=Math.round(Math.min((a-o)/P,h)),P=(a-o)/k,v=o,S=a):x?(v=m?o:v,S=b?a:S,k=l-1,P=(S-v)/k):(k=(S-v)/P,k=almostEquals(k,Math.round(k),P/1e3)?Math.round(k):Math.ceil(k));const M=Math.max(_decimalPlaces(P),_decimalPlaces(v));y=Math.pow(10,isNullOrUndef(r)?M:r),v=Math.round(v*y)/y,S=Math.round(S*y)/y;let w=0;for(m&&(d&&v!==o?(i.push({value:o}),v<o&&w++,almostEquals(Math.round((v+w*P)*y)/y,o,relativeLabelSize(o,_,t))&&w++):v<o&&w++);w<k;++w)i.push({value:Math.round((v+w*P)*y)/y});return b&&d&&S!==a?i.length&&almostEquals(i[i.length-1].value,a,relativeLabelSize(a,_,t))?i[i.length-1].value=a:i.push({value:a}):b&&S!==a||i.push({value:S}),i}function relativeLabelSize(t,e,{horizontal:i,minRotation:s}){const n=toRadians(s),o=(i?Math.sin(n):Math.cos(n))||.001,a=.75*e*(""+t).length;return Math.min(e/o,a)}class LinearScaleBase extends Scale{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return isNullOrUndef(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:n}=this;const o=t=>s=e?s:t,a=t=>n=i?n:t;if(t){const t=sign(s),e=sign(n);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(s===n){let e=0===n?1:Math.abs(.05*n);a(n+e),t||o(s-e)}this.min=s,this.max=n}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:i,stepSize:s}=t;return s?(e=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),i=i||11),i&&(e=Math.min(i,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const s=generateTicks$1({maxTicks:i,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:!1!==e.includeBounds},this._range||this);return"ticks"===t.bounds&&_setMinAndMaxByKey(s,this,"value"),t.reverse?(s.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),s}configure(){const t=this.ticks;let e=this.min,i=this.max;if(super.configure(),this.options.offset&&t.length){const s=(i-e)/Math.max(t.length-1,1)/2;e-=s,i+=s}this._startValue=e,this._endValue=i,this._valueRange=i-e}getLabelForValue(t){return formatNumber(t,this.chart.options.locale,this.options.ticks.format)}}class LinearScale extends LinearScaleBase{static id="linear";static defaults={ticks:{callback:Ticks.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=isNumberFinite(t)?t:0,this.max=isNumberFinite(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,i=toRadians(this.options.ticks.minRotation),s=(t?Math.sin(i):Math.cos(i))||.001,n=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,n.lineHeight/s))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const log10Floor=t=>Math.floor(log10(t)),changeExponent=(t,e)=>Math.pow(10,log10Floor(t)+e);function isMajor(t){return 1===t/Math.pow(10,log10Floor(t))}function steps(t,e,i){const s=Math.pow(10,i),n=Math.floor(t/s);return Math.ceil(e/s)-n}function startExp(t,e){let i=log10Floor(e-t);for(;steps(t,e,i)>10;)i++;for(;steps(t,e,i)<10;)i--;return Math.min(i,log10Floor(t))}function generateTicks(t,{min:e,max:i}){e=finiteOrDefault(t.min,e);const s=[],n=log10Floor(e);let o=startExp(e,i),a=o<0?Math.pow(10,Math.abs(o)):1;const r=Math.pow(10,o),l=n>o?Math.pow(10,n):0,h=Math.round((e-l)*a)/a,c=Math.floor((e-l)/r/10)*r*10;let d=Math.floor((h-c)/Math.pow(10,o)),u=finiteOrDefault(t.min,Math.round((l+c+d*Math.pow(10,o))*a)/a);for(;u<i;)s.push({value:u,major:isMajor(u),significand:d}),d>=10?d=d<15?15:20:d++,d>=20&&(o++,d=2,a=o>=0?1:a),u=Math.round((l+c+d*Math.pow(10,o))*a)/a;const g=finiteOrDefault(t.max,u);return s.push({value:g,major:isMajor(g),significand:d}),s}class LogarithmicScale extends Scale{static id="logarithmic";static defaults={ticks:{callback:Ticks.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const i=LinearScaleBase.prototype.parse.apply(this,[t,e]);if(0!==i)return isNumberFinite(i)&&i>0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=isNumberFinite(t)?Math.max(0,t):null,this.max=isNumberFinite(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!isNumberFinite(this._userMin)&&(this.min=t===changeExponent(this.min,0)?changeExponent(this.min,-1):changeExponent(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const n=e=>i=t?i:e,o=t=>s=e?s:t;i===s&&(i<=0?(n(1),o(10)):(n(changeExponent(i,-1)),o(changeExponent(s,1)))),i<=0&&n(changeExponent(s,-1)),s<=0&&o(changeExponent(i,1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e=generateTicks({min:this._userMin,max:this._userMax},this);return"ticks"===t.bounds&&_setMinAndMaxByKey(e,this,"value"),t.reverse?(e.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),e}getLabelForValue(t){return void 0===t?"0":formatNumber(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=log10(t),this._valueRange=log10(this.max)-log10(t)}getPixelForValue(t){return void 0!==t&&0!==t||(t=this.min),null===t||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(log10(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function getTickBackdropHeight(t){const e=t.ticks;if(e.display&&t.display){const t=toPadding(e.backdropPadding);return valueOrDefault(e.font&&e.font.size,defaults.font.size)+t.height}return 0}function measureLabelSize(t,e,i){return i=isArray(i)?i:[i],{w:_longestText(t,e.string,i),h:i.length*e.lineHeight}}function determineLimits(t,e,i,s,n){return t===s||t===n?{start:e-i/2,end:e+i/2}:t<s||t>n?{start:e-i,end:e}:{start:e,end:e+i}}function fitWithPointLabels(t){const e={l:t.left+t._padding.left,r:t.right-t._padding.right,t:t.top+t._padding.top,b:t.bottom-t._padding.bottom},i=Object.assign({},e),s=[],n=[],o=t._pointLabels.length,a=t.options.pointLabels,r=a.centerPointLabels?PI/o:0;for(let l=0;l<o;l++){const o=a.setContext(t.getPointLabelContext(l));n[l]=o.padding;const h=t.getPointPosition(l,t.drawingArea+n[l],r),c=toFont(o.font),d=measureLabelSize(t.ctx,c,t._pointLabels[l]);s[l]=d;const u=_normalizeAngle(t.getIndexAngle(l)+r),g=Math.round(toDegrees(u));updateLimits(i,e,u,determineLimits(g,h.x,d.w,0,180),determineLimits(g,h.y,d.h,90,270))}t.setCenterPoint(e.l-i.l,i.r-e.r,e.t-i.t,i.b-e.b),t._pointLabelItems=buildPointLabelItems(t,s,n)}function updateLimits(t,e,i,s,n){const o=Math.abs(Math.sin(i)),a=Math.abs(Math.cos(i));let r=0,l=0;s.start<e.l?(r=(e.l-s.start)/o,t.l=Math.min(t.l,e.l-r)):s.end>e.r&&(r=(s.end-e.r)/o,t.r=Math.max(t.r,e.r+r)),n.start<e.t?(l=(e.t-n.start)/a,t.t=Math.min(t.t,e.t-l)):n.end>e.b&&(l=(n.end-e.b)/a,t.b=Math.max(t.b,e.b+l))}function buildPointLabelItems(t,e,i){const s=[],n=t._pointLabels.length,o=t.options,a=getTickBackdropHeight(o)/2,r=t.drawingArea,l=o.pointLabels.centerPointLabels?PI/n:0;for(let o=0;o<n;o++){const n=t.getPointPosition(o,r+a+i[o],l),h=Math.round(toDegrees(_normalizeAngle(n.angle+HALF_PI))),c=e[o],d=yForAngle(n.y,c.h,h),u=getTextAlignForAngle(h),g=leftForTextAlign(n.x,c.w,u);s.push({x:n.x,y:d,textAlign:u,left:g,top:d,right:g+c.w,bottom:d+c.h})}return s}function getTextAlignForAngle(t){return 0===t||180===t?"center":t<180?"left":"right"}function leftForTextAlign(t,e,i){return"right"===i?t-=e:"center"===i&&(t-=e/2),t}function yForAngle(t,e,i){return 90===i||270===i?t-=e/2:(i>270||i<90)&&(t-=e),t}function drawPointLabels(t,e){const{ctx:i,options:{pointLabels:s}}=t;for(let n=e-1;n>=0;n--){const e=s.setContext(t.getPointLabelContext(n)),o=toFont(e.font),{x:a,y:r,textAlign:l,left:h,top:c,right:d,bottom:u}=t._pointLabelItems[n],{backdropColor:g}=e;if(!isNullOrUndef(g)){const t=toTRBLCorners(e.borderRadius),s=toPadding(e.backdropPadding);i.fillStyle=g;const n=h-s.left,o=c-s.top,a=d-h+s.width,r=u-c+s.height;Object.values(t).some((t=>0!==t))?(i.beginPath(),addRoundedRectPath(i,{x:n,y:o,w:a,h:r,radius:t}),i.fill()):i.fillRect(n,o,a,r)}renderText(i,t._pointLabels[n],a,r+o.lineHeight/2,o,{color:e.color,textAlign:l,textBaseline:"middle"})}}function pathRadiusLine(t,e,i,s){const{ctx:n}=t;if(i)n.arc(t.xCenter,t.yCenter,e,0,TAU);else{let i=t.getPointPosition(0,e);n.moveTo(i.x,i.y);for(let o=1;o<s;o++)i=t.getPointPosition(o,e),n.lineTo(i.x,i.y)}}function drawRadiusLine(t,e,i,s,n){const o=t.ctx,a=e.circular,{color:r,lineWidth:l}=e;!a&&!s||!r||!l||i<0||(o.save(),o.strokeStyle=r,o.lineWidth=l,o.setLineDash(n.dash),o.lineDashOffset=n.dashOffset,o.beginPath(),pathRadiusLine(t,i,a,s),o.closePath(),o.stroke(),o.restore())}function createPointLabelContext(t,e,i){return createContext(t,{label:i,index:e,type:"pointLabel"})}class RadialLinearScale extends LinearScaleBase{static id="radialLinear";static defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ticks.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:t=>t,padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=toPadding(getTickBackdropHeight(this.options)/2),e=this.width=this.maxWidth-t.width,i=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+i/2+t.top),this.drawingArea=Math.floor(Math.min(e,i)/2)}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!1);this.min=isNumberFinite(t)&&!isNaN(t)?t:0,this.max=isNumberFinite(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/getTickBackdropHeight(this.options))}generateTickLabels(t){LinearScaleBase.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map(((t,e)=>{const i=callback(this.options.pointLabels.callback,[t,e],this);return i||0===i?i:""})).filter(((t,e)=>this.chart.getDataVisibility(e)))}fit(){const t=this.options;t.display&&t.pointLabels.display?fitWithPointLabels(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,i,s){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((i-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,i,s))}getIndexAngle(t){return _normalizeAngle(t*(TAU/(this._pointLabels.length||1))+toRadians(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(isNullOrUndef(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(isNullOrUndef(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t<e.length){const i=e[t];return createPointLabelContext(this.getContext(),t,i)}}getPointPosition(t,e,i=0){const s=this.getIndexAngle(t)-HALF_PI+i;return{x:Math.cos(s)*e+this.xCenter,y:Math.sin(s)*e+this.yCenter,angle:s}}getPointPositionForValue(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){const{left:e,top:i,right:s,bottom:n}=this._pointLabelItems[t];return{left:e,top:i,right:s,bottom:n}}drawBackground(){const{backgroundColor:t,grid:{circular:e}}=this.options;if(t){const i=this.ctx;i.save(),i.beginPath(),pathRadiusLine(this,this.getDistanceFromCenterForValue(this._endValue),e,this._pointLabels.length),i.closePath(),i.fillStyle=t,i.fill(),i.restore()}}drawGrid(){const t=this.ctx,e=this.options,{angleLines:i,grid:s,border:n}=e,o=this._pointLabels.length;let a,r,l;if(e.pointLabels.display&&drawPointLabels(this,o),s.display&&this.ticks.forEach(((t,e)=>{if(0!==e){r=this.getDistanceFromCenterForValue(t.value);const i=this.getContext(e),a=s.setContext(i),l=n.setContext(i);drawRadiusLine(this,a,r,o,l)}})),i.display){for(t.save(),a=o-1;a>=0;a--){const s=i.setContext(this.getPointLabelContext(a)),{color:n,lineWidth:o}=s;o&&n&&(t.lineWidth=o,t.strokeStyle=n,t.setLineDash(s.borderDash),t.lineDashOffset=s.borderDashOffset,r=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),l=this.getPointPosition(a,r),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(l.x,l.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let n,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach(((s,a)=>{if(0===a&&!e.reverse)return;const r=i.setContext(this.getContext(a)),l=toFont(r.font);if(n=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(s.label).width,t.fillStyle=r.backdropColor;const e=toPadding(r.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}renderText(t,s.label,0,-n,l,{color:r.color})})),t.restore()}drawTitle(){}}const INTERVALS={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},UNITS=Object.keys(INTERVALS);function sorter(t,e){return t-e}function parse(t,e){if(isNullOrUndef(e))return null;const i=t._adapter,{parser:s,round:n,isoWeekday:o}=t._parseOpts;let a=e;return"function"==typeof s&&(a=s(a)),isNumberFinite(a)||(a="string"==typeof s?i.parse(a,s):i.parse(a)),null===a?null:(n&&(a="week"!==n||!isNumber(o)&&!0!==o?i.startOf(a,n):i.startOf(a,"isoWeek",o)),+a)}function determineUnitForAutoTicks(t,e,i,s){const n=UNITS.length;for(let o=UNITS.indexOf(t);o<n-1;++o){const t=INTERVALS[UNITS[o]],n=t.steps?t.steps:Number.MAX_SAFE_INTEGER;if(t.common&&Math.ceil((i-e)/(n*t.size))<=s)return UNITS[o]}return UNITS[n-1]}function determineUnitForFormatting(t,e,i,s,n){for(let o=UNITS.length-1;o>=UNITS.indexOf(i);o--){const i=UNITS[o];if(INTERVALS[i].common&&t._adapter.diff(n,s,i)>=e-1)return i}return UNITS[i?UNITS.indexOf(i):0]}function determineMajorUnit(t){for(let e=UNITS.indexOf(t)+1,i=UNITS.length;e<i;++e)if(INTERVALS[UNITS[e]].common)return UNITS[e]}function addTick(t,e,i){if(i){if(i.length){const{lo:s,hi:n}=_lookup(i,e);t[i[s]>=e?i[s]:i[n]]=!0}}else t[e]=!0}function setMajorTicks(t,e,i,s){const n=t._adapter,o=+n.startOf(e[0].value,s),a=e[e.length-1].value;let r,l;for(r=o;r<=a;r=+n.add(r,1,s))l=i[r],l>=0&&(e[l].major=!0);return e}function ticksFromTimestamps(t,e,i){const s=[],n={},o=e.length;let a,r;for(a=0;a<o;++a)r=e[a],n[r]=a,s.push({value:r,major:!1});return 0!==o&&i?setMajorTicks(t,s,n,i):s}class TimeScale extends Scale{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e={}){const i=t.time||(t.time={}),s=this._adapter=new adapters._date(t.adapters.date);s.init(e),mergeIf(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:parse(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,i=t.time.unit||"day";let{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();function r(t){o||isNaN(t.min)||(s=Math.min(s,t.min)),a||isNaN(t.max)||(n=Math.max(n,t.max))}o&&a||(r(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||r(this.getMinMax(!1))),s=isNumberFinite(s)&&!isNaN(s)?s:+e.startOf(Date.now(),i),n=isNumberFinite(n)&&!isNaN(n)?n:+e.endOf(Date.now(),i)+1,this.min=Math.min(s,n-1),this.max=Math.max(s+1,n)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this.options,e=t.time,i=t.ticks,s="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const n=this.min,o=_filterBetween(s,n,this.max);return this._unit=e.unit||(i.autoSkip?determineUnitForAutoTicks(e.minUnit,this.min,this.max,this._getLabelCapacity(n)):determineUnitForFormatting(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?determineMajorUnit(this._unit):void 0,this.initOffsets(s),t.reverse&&o.reverse(),ticksFromTimestamps(this,o,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map((t=>+t.value)))}initOffsets(t=[]){let e,i,s=0,n=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),s=1===t.length?1-e:(this.getDecimalForValue(t[1])-e)/2,i=this.getDecimalForValue(t[t.length-1]),n=1===t.length?i:(i-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;s=_limitValue(s,0,o),n=_limitValue(n,0,o),this._offsets={start:s,end:n,factor:1/(s+1+n)}}_generate(){const t=this._adapter,e=this.min,i=this.max,s=this.options,n=s.time,o=n.unit||determineUnitForAutoTicks(n.minUnit,e,i,this._getLabelCapacity(e)),a=valueOrDefault(s.ticks.stepSize,1),r="week"===o&&n.isoWeekday,l=isNumber(r)||!0===r,h={};let c,d,u=e;if(l&&(u=+t.startOf(u,"isoWeek",r)),u=+t.startOf(u,l?"day":o),t.diff(i,e,o)>1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+o);const g="data"===s.ticks.source&&this.getDataTimestamps();for(c=u,d=0;c<i;c=+t.add(c,a,o),d++)addTick(h,c,g);return c!==i&&"ticks"!==s.bounds&&1!==d||addTick(h,c,g),Object.keys(h).sort(((t,e)=>t-e)).map((t=>+t))}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}format(t,e){const i=this.options.time.displayFormats,s=this._unit,n=e||i[s];return this._adapter.format(t,n)}_tickFormatFunction(t,e,i,s){const n=this.options,o=n.ticks.callback;if(o)return callback(o,[t,e,i],this);const a=n.time.displayFormats,r=this._unit,l=this._majorUnit,h=r&&a[r],c=l&&a[l],d=i[e],u=l&&c&&d&&d.major;return this._adapter.format(t,s||(u?c:h))}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e<i;++e)s=t[e],s.label=this._tickFormatFunction(s.value,e,t)}getDecimalForValue(t){return null===t?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const e=this._offsets,i=this.getDecimalForValue(t);return this.getPixelForDecimal((e.start+i)*e.factor)}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return this.min+i*(this.max-this.min)}_getLabelSize(t){const e=this.options.ticks,i=this.ctx.measureText(t).width,s=toRadians(this.isHorizontal()?e.maxRotation:e.minRotation),n=Math.cos(s),o=Math.sin(s),a=this._resolveTickFontOptions(0).size;return{w:i*n+a*o,h:i*o+a*n}}_getLabelCapacity(t){const e=this.options.time,i=e.displayFormats,s=i[e.unit]||i.millisecond,n=this._tickFormatFunction(t,0,ticksFromTimestamps(this,[t],this._majorUnit),s),o=this._getLabelSize(n),a=Math.floor(this.isHorizontal()?this.width/o.w:this.height/o.h)-1;return a>0?a:1}getDataTimestamps(){let t,e,i=this._cache.data||[];if(i.length)return i;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(t=0,e=s.length;t<e;++t)i=i.concat(s[t].controller.getAllParsedValues(this));return this._cache.data=this.normalize(i)}getLabelTimestamps(){const t=this._cache.labels||[];let e,i;if(t.length)return t;const s=this.getLabels();for(e=0,i=s.length;e<i;++e)t.push(parse(this,s[e]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return _arrayUnique(t.sort(sorter))}}function interpolate(t,e,i){let s,n,o,a,r=0,l=t.length-1;i?(e>=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=_lookupByKey(t,"pos",e)),({pos:s,time:o}=t[r]),({pos:n,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=_lookupByKey(t,"time",e)),({time:s,pos:o}=t[r]),({time:n,pos:a}=t[l]));const h=n-s;return h?o+(a-o)*(e-s)/h:o}class TimeSeriesScale extends TimeScale{static id="timeseries";static defaults=TimeScale.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=interpolate(e,this.min),this._tableRange=interpolate(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],n=[];let o,a,r,l,h;for(o=0,a=t.length;o<a;++o)l=t[o],l>=e&&l<=i&&s.push(l);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(o=0,a=s.length;o<a;++o)h=s[o+1],r=s[o-1],l=s[o],Math.round((h+r)/2)!==l&&n.push({time:l,pos:o/(a-1)});return n}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),i=this.getLabelTimestamps();return t=e.length&&i.length?this.normalize(e.concat(i)):e.length?e:i,t=this._cache.all=t,t}getDecimalForValue(t){return(interpolate(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return interpolate(this._table,i*this._tableRange+this._minPos,!0)}}var scales=Object.freeze({__proto__:null,CategoryScale,LinearScale,LogarithmicScale,RadialLinearScale,TimeScale,TimeSeriesScale});const registerables=[controllers,elements,plugins,scales];export{Animation,Animations,ArcElement,BarController,BarElement,BasePlatform,BasicPlatform,BubbleController,CategoryScale,Chart,plugin_colors as Colors,DatasetController,plugin_decimation as Decimation,DomPlatform,DoughnutController,Element,index as Filler,Interaction,plugin_legend as Legend,LineController,LineElement,LinearScale,LogarithmicScale,PieController,PointElement,PolarAreaController,RadarController,RadialLinearScale,Scale,ScatterController,plugin_subtitle as SubTitle,Ticks,TimeScale,TimeSeriesScale,plugin_title as Title,plugin_tooltip as Tooltip,adapters as _adapters,_detectPlatform,animator,controllers,defaults,elements,layouts,plugins,registerables,registry,scales}; diff --git a/typo3/sysext/rte_ckeditor/Resources/Public/Contrib/@ckeditor/ckeditor5-engine.js b/typo3/sysext/rte_ckeditor/Resources/Public/Contrib/@ckeditor/ckeditor5-engine.js index 85513bb3eee91fac19ce259ebea8ef5deb6aa1e0..0c958dc5fa2696f43216e57e9a81a52e6f1b47ad 100644 --- a/typo3/sysext/rte_ckeditor/Resources/Public/Contrib/@ckeditor/ckeditor5-engine.js +++ b/typo3/sysext/rte_ckeditor/Resources/Public/Contrib/@ckeditor/ckeditor5-engine.js @@ -253,7 +253,7 @@ class ln extends(e()){constructor(){super(),this._modelToViewMapping=new WeakMap /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */(this._model,e)}))}get isCollapsed(){return 0===this._ranges.length?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let t=0;t<this._ranges.length;t++)this._ranges[t].detach();this.stopListening()}*getRanges(){this._ranges.length?yield*super.getRanges():yield this._document._getDefaultRange()}getFirstRange(){return super.getFirstRange()||this._document._getDefaultRange()}getLastRange(){return super.getLastRange()||this._document._getDefaultRange()}setTo(...t){super.setTo(...t),this._updateAttributes(!0),this.updateMarkers()}setFocus(t,e){super.setFocus(t,e),this._updateAttributes(!0),this.updateMarkers()}setAttribute(t,e){if(this._setAttribute(t,e)){const e=[t];this.fire("change:attribute",{attributeKeys:e,directChange:!0})}}removeAttribute(t){if(this._removeAttribute(t)){const e=[t];this.fire("change:attribute",{attributeKeys:e,directChange:!0})}}overrideGravity(){const t=T();return this._overriddenGravityRegister.add(t),1===this._overriddenGravityRegister.size&&this._updateAttributes(!0),t}restoreGravity(t){if(!this._overriddenGravityRegister.has(t))throw new n("document-selection-gravity-wrong-restore",this,{uid:t});this._overriddenGravityRegister.delete(t),this.isGravityOverridden||this._updateAttributes(!0)}observeMarkers(t){this._observedMarkers.add(t),this.updateMarkers()}_replaceAllRanges(t){this._validateSelectionRanges(t),super._replaceAllRanges(t)}_popRange(){this._ranges.pop().detach()}_pushRange(t){const e=this._prepareRange(t);e&&this._ranges.push(e)}_validateSelectionRanges(t){for(const e of t)if(!this._document._validateSelectionRange(e))throw new n("document-selection-wrong-position",this,{range:e})}_prepareRange(t){if(this._checkRange(t),t.root==this._document.graveyard)return;const e=vn.fromRange(t);return e.on("change:range",((t,n,s)=>{if(this._hasChangedRange=!0,e.root==this._document.graveyard){this._selectionRestorePosition=s.deletionPosition;const t=this._ranges.indexOf(e);this._ranges.splice(t,1),e.detach()}})),e}updateMarkers(){if(!this._observedMarkers.size)return;const t=[];let e=!1;for(const e of this._model.markers){const n=e.name.split(":",1)[0];if(!this._observedMarkers.has(n))continue;const s=e.getRange();for(const n of this.getRanges())s.containsRange(n,!n.isCollapsed)&&t.push(e)}const n=Array.from(this.markers);for(const n of t)this.markers.has(n)||(this.markers.add(n),e=!0);for(const n of Array.from(this.markers))t.includes(n)||(this.markers.remove(n),e=!0);e&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateMarker(t,e){const n=t.name.split(":",1)[0];if(!this._observedMarkers.has(n))return;let s=!1;const i=Array.from(this.markers),r=this.markers.has(t);if(e){let n=!1;for(const t of this.getRanges())if(e.containsRange(t,!t.isCollapsed)){n=!0;break}n&&!r?(this.markers.add(t),s=!0):!n&&r&&(this.markers.remove(t),s=!0)}else r&&(this.markers.remove(t),s=!0);s&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateAttributes(t){const e=r(this._getSurroundingAttributes()),n=r(this.getAttributes());if(t)this._attributePriority=new Map,this._attrs=new Map;else for(const[t,e]of this._attributePriority)"low"==e&&(this._attrs.delete(t),this._attributePriority.delete(t));this._setAttributesTo(e);const s=[];for(const[t,e]of this.getAttributes())n.has(t)&&n.get(t)===e||s.push(t);for(const[t]of n)this.hasAttribute(t)||s.push(t);s.length>0&&this.fire("change:attribute",{attributeKeys:s,directChange:!1})}_setAttribute(t,e,n=!0){const s=n?"normal":"low";if("low"==s&&"normal"==this._attributePriority.get(t))return!1;return super.getAttribute(t)!==e&&(this._attrs.set(t,e),this._attributePriority.set(t,s),!0)}_removeAttribute(t,e=!0){const n=e?"normal":"low";return("low"!=n||"normal"!=this._attributePriority.get(t))&&(this._attributePriority.set(t,n),!!super.hasAttribute(t)&&(this._attrs.delete(t),!0))}_setAttributesTo(t){const e=new Set;for(const[e,n]of this.getAttributes())t.get(e)!==n&&this._removeAttribute(e,!1);for(const[n,s]of t){this._setAttribute(n,s,!1)&&e.add(n)}return e}*getStoredAttributes(){const t=this.getFirstPosition().parent;if(this.isCollapsed&&t.isEmpty)for(const e of t.getAttributeKeys())if(e.startsWith(Cn)){const n=e.substr(Cn.length);yield[n,t.getAttribute(e)]}}_getSurroundingAttributes(){const t=this.getFirstPosition(),e=this._model.schema;if("$graveyard"==t.root.rootName)return null;let n=null;if(this.isCollapsed){const s=t.textNode?t.textNode:t.nodeBefore,i=t.textNode?t.textNode:t.nodeAfter;if(this.isGravityOverridden||(n=Rn(s,e)),n||(n=Rn(i,e)),!this.isGravityOverridden&&!n){let t=s;for(;t&&!n;)t=t.previousSibling,n=Rn(t,e)}if(!n){let t=i;for(;t&&!n;)t=t.nextSibling,n=Rn(t,e)}n||(n=this.getStoredAttributes())}else{const t=this.getFirstRange();for(const s of t){if(s.item.is("element")&&e.isObject(s.item)){n=Rn(s.item,e);break}if("text"==s.type){n=s.item.getAttributes();break}}}return n}_fixGraveyardSelection(t){const e=this._model.schema.getNearestSelectionRange(t);e&&this._pushRange(e)}}function Rn(t,e){if(!t)return null;if(t instanceof Ye||t instanceof He)return t.getAttributes();if(!e.isInline(t))return null;if(!e.isObject(t))return[];const n=[];for(const[s,i]of t.getAttributes())e.checkAttribute("$text",s)&&!1!==e.getAttributeProperties(s).copyFromObject&&n.push([s,i]);return n}class En{constructor(t){this._dispatchers=t}add(t){for(const e of this._dispatchers)t(e);return this}} + */(this._model,e)}))}get isCollapsed(){return 0===this._ranges.length?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let t=0;t<this._ranges.length;t++)this._ranges[t].detach();this.stopListening()}*getRanges(){this._ranges.length?yield*super.getRanges():yield this._document._getDefaultRange()}getFirstRange(){return super.getFirstRange()||this._document._getDefaultRange()}getLastRange(){return super.getLastRange()||this._document._getDefaultRange()}setTo(...t){super.setTo(...t),this._updateAttributes(!0),this.updateMarkers()}setFocus(t,e){super.setFocus(t,e),this._updateAttributes(!0),this.updateMarkers()}setAttribute(t,e){if(this._setAttribute(t,e)){const e=[t];this.fire("change:attribute",{attributeKeys:e,directChange:!0})}}removeAttribute(t){if(this._removeAttribute(t)){const e=[t];this.fire("change:attribute",{attributeKeys:e,directChange:!0})}}overrideGravity(){const t=T();return this._overriddenGravityRegister.add(t),1===this._overriddenGravityRegister.size&&this._updateAttributes(!0),t}restoreGravity(t){if(!this._overriddenGravityRegister.has(t))throw new n("document-selection-gravity-wrong-restore",this,{uid:t});this._overriddenGravityRegister.delete(t),this.isGravityOverridden||this._updateAttributes(!0)}observeMarkers(t){this._observedMarkers.add(t),this.updateMarkers()}_replaceAllRanges(t){this._validateSelectionRanges(t),super._replaceAllRanges(t)}_popRange(){this._ranges.pop().detach()}_pushRange(t){const e=this._prepareRange(t);e&&this._ranges.push(e)}_validateSelectionRanges(t){for(const e of t)if(!this._document._validateSelectionRange(e))throw new n("document-selection-wrong-position",this,{range:e})}_prepareRange(t){if(this._checkRange(t),t.root==this._document.graveyard)return;const e=vn.fromRange(t);return e.on("change:range",((t,n,s)=>{if(this._hasChangedRange=!0,e.root==this._document.graveyard){this._selectionRestorePosition=s.deletionPosition;const t=this._ranges.indexOf(e);this._ranges.splice(t,1),e.detach()}})),e}updateMarkers(){if(!this._observedMarkers.size)return;const t=[];let e=!1;for(const e of this._model.markers){const n=e.name.split(":",1)[0];if(!this._observedMarkers.has(n))continue;const s=e.getRange();for(const n of this.getRanges())s.containsRange(n,!n.isCollapsed)&&t.push(e)}const n=Array.from(this.markers);for(const n of t)this.markers.has(n)||(this.markers.add(n),e=!0);for(const n of Array.from(this.markers))t.includes(n)||(this.markers.remove(n),e=!0);e&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateMarker(t,e){const n=t.name.split(":",1)[0];if(!this._observedMarkers.has(n))return;let s=!1;const i=Array.from(this.markers),r=this.markers.has(t);if(e){let n=!1;for(const t of this.getRanges())if(e.containsRange(t,!t.isCollapsed)){n=!0;break}n&&!r?(this.markers.add(t),s=!0):!n&&r&&(this.markers.remove(t),s=!0)}else r&&(this.markers.remove(t),s=!0);s&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateAttributes(t){const e=r(this._getSurroundingAttributes()),n=r(this.getAttributes());if(t)this._attributePriority=new Map,this._attrs=new Map;else for(const[t,e]of this._attributePriority)"low"==e&&(this._attrs.delete(t),this._attributePriority.delete(t));this._setAttributesTo(e);const s=[];for(const[t,e]of this.getAttributes())n.has(t)&&n.get(t)===e||s.push(t);for(const[t]of n)this.hasAttribute(t)||s.push(t);s.length>0&&this.fire("change:attribute",{attributeKeys:s,directChange:!1})}_setAttribute(t,e,n=!0){const s=n?"normal":"low";if("low"==s&&"normal"==this._attributePriority.get(t))return!1;return super.getAttribute(t)!==e&&(this._attrs.set(t,e),this._attributePriority.set(t,s),!0)}_removeAttribute(t,e=!0){const n=e?"normal":"low";return("low"!=n||"normal"!=this._attributePriority.get(t))&&(this._attributePriority.set(t,n),!!super.hasAttribute(t)&&(this._attrs.delete(t),!0))}_setAttributesTo(t){const e=new Set;for(const[e,n]of this.getAttributes())t.get(e)!==n&&this._removeAttribute(e,!1);for(const[n,s]of t){this._setAttribute(n,s,!1)&&e.add(n)}return e}*getStoredAttributes(){const t=this.getFirstPosition().parent;if(this.isCollapsed&&t.isEmpty)for(const e of t.getAttributeKeys())if(e.startsWith(Cn)){const n=e.substr(10);yield[n,t.getAttribute(e)]}}_getSurroundingAttributes(){const t=this.getFirstPosition(),e=this._model.schema;if("$graveyard"==t.root.rootName)return null;let n=null;if(this.isCollapsed){const s=t.textNode?t.textNode:t.nodeBefore,i=t.textNode?t.textNode:t.nodeAfter;if(this.isGravityOverridden||(n=Rn(s,e)),n||(n=Rn(i,e)),!this.isGravityOverridden&&!n){let t=s;for(;t&&!n;)t=t.previousSibling,n=Rn(t,e)}if(!n){let t=i;for(;t&&!n;)t=t.nextSibling,n=Rn(t,e)}n||(n=this.getStoredAttributes())}else{const t=this.getFirstRange();for(const s of t){if(s.item.is("element")&&e.isObject(s.item)){n=Rn(s.item,e);break}if("text"==s.type){n=s.item.getAttributes();break}}}return n}_fixGraveyardSelection(t){const e=this._model.schema.getNearestSelectionRange(t);e&&this._pushRange(e)}}function Rn(t,e){if(!t)return null;if(t instanceof Ye||t instanceof He)return t.getAttributes();if(!e.isInline(t))return null;if(!e.isObject(t))return[];const n=[];for(const[s,i]of t.getAttributes())e.checkAttribute("$text",s)&&!1!==e.getAttributeProperties(s).copyFromObject&&n.push([s,i]);return n}class En{constructor(t){this._dispatchers=t}add(t){for(const e of this._dispatchers)t(e);return this}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license diff --git a/typo3/sysext/rte_ckeditor/Resources/Public/Contrib/@ckeditor/ckeditor5-table.js b/typo3/sysext/rte_ckeditor/Resources/Public/Contrib/@ckeditor/ckeditor5-table.js index 9198d06118d785a32b7e210954d4720721e3855d..2893e6261c962598a416f117278c37d6d67fd5f6 100644 --- a/typo3/sysext/rte_ckeditor/Resources/Public/Contrib/@ckeditor/ckeditor5-table.js +++ b/typo3/sysext/rte_ckeditor/Resources/Public/Contrib/@ckeditor/ckeditor5-table.js @@ -63,274 +63,274 @@ class we extends e{refresh(){const e=this.editor.model,t=e.document.selection,o= /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */const He=5,De=40,Me=2;function Oe(e,t){return 100*De/Ue(e,t)}function Ue(e,t){const o=$e(e,"tbody",t)||$e(e,"thead",t);return je(t.editing.view.domConverter.mapViewToDom(o))}function $e(e,t,o){return[...[...o.editing.mapper.toViewElement(e).getChildren()].find((e=>e.is("element","table"))).getChildren()].find((e=>e.is("element",t)))}function je(e){const t=c.window.getComputedStyle(e);return"border-box"===t.boxSizing?parseFloat(t.width)-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth):parseFloat(t.width)}function qe(e){const t=Math.pow(10,Me),o="number"==typeof e?e:parseFloat(e);return Math.round(o*t)/t}function Ge(e){return e.map((e=>"number"==typeof e?e:parseFloat(e))).filter((e=>!Number.isNaN(e))).reduce(((e,t)=>e+t),0)}function Ke(e){let t=function(e){const t=e.filter((e=>"auto"===e)).length;if(0===t)return e.map((e=>qe(e)));const o=Ge(e),n=Math.max((100-o)/t,He);return e.map((e=>"auto"===e?n:e)).map((e=>qe(e)))}(e.map((e=>"auto"===e?e:parseFloat(e.replace("%","")))));const o=Ge(t);return 100!==o&&(t=t.map((e=>qe(100*e/o))).map(((e,t,o)=>{if(!(t===o.length-1))return e;return qe(e+100-Ge(o))}))),t.map((e=>e+"%"))}function Je(e){const t=c.window.getComputedStyle(e);return"border-box"===t.boxSizing?parseInt(t.width):parseFloat(t.width)+parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)+parseFloat(t.borderWidth)}function Xe(e,t,o,n){for(let i=0;i<Math.max(o.length,e.length);i++){const r=e[i],l=o[i];l?r?n.setAttribute("columnWidth",l,r):n.appendElement("tableColumn",{columnWidth:l},t):n.remove(r)}}function Ye(e){if(e.is("element","tableColumnGroup"))return e;const t=e.getChildren();return Array.from(t).find((e=>e.is("element","tableColumnGroup")))}function Qe(e){const t=Ye(e);return t?Array.from(t.getChildren()):[]} + */const He=5,De=2;function Me(e,t){return 4e3/Oe(e,t)}function Oe(e,t){const o=Ue(e,"tbody",t)||Ue(e,"thead",t);return $e(t.editing.view.domConverter.mapViewToDom(o))}function Ue(e,t,o){return[...[...o.editing.mapper.toViewElement(e).getChildren()].find((e=>e.is("element","table"))).getChildren()].find((e=>e.is("element",t)))}function $e(e){const t=c.window.getComputedStyle(e);return"border-box"===t.boxSizing?parseFloat(t.width)-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth):parseFloat(t.width)}function je(e){const t=Math.pow(10,De),o="number"==typeof e?e:parseFloat(e);return Math.round(o*t)/t}function qe(e){return e.map((e=>"number"==typeof e?e:parseFloat(e))).filter((e=>!Number.isNaN(e))).reduce(((e,t)=>e+t),0)}function Ge(e){let t=function(e){const t=e.filter((e=>"auto"===e)).length;if(0===t)return e.map((e=>je(e)));const o=qe(e),n=Math.max((100-o)/t,He);return e.map((e=>"auto"===e?n:e)).map((e=>je(e)))}(e.map((e=>"auto"===e?e:parseFloat(e.replace("%","")))));const o=qe(t);return 100!==o&&(t=t.map((e=>je(100*e/o))).map(((e,t,o)=>{if(!(t===o.length-1))return e;return je(e+100-qe(o))}))),t.map((e=>e+"%"))}function Ke(e){const t=c.window.getComputedStyle(e);return"border-box"===t.boxSizing?parseInt(t.width):parseFloat(t.width)+parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)+parseFloat(t.borderWidth)}function Je(e,t,o,n){for(let i=0;i<Math.max(o.length,e.length);i++){const r=e[i],l=o[i];l?r?n.setAttribute("columnWidth",l,r):n.appendElement("tableColumn",{columnWidth:l},t):n.remove(r)}}function Xe(e){if(e.is("element","tableColumnGroup"))return e;const t=e.getChildren();return Array.from(t).find((e=>e.is("element","tableColumnGroup")))}function Ye(e){const t=Xe(e);return t?Array.from(t.getChildren()):[]} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -class Ze extends t{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,o=t.parent,n=o.getChildIndex(t),i=new he(o,{row:n});for(const{cell:t,row:o,column:n}of i)if(t===e)return{row:o,column:n}; -/* istanbul ignore next -- @preserve */}createTable(e,t){const o=e.createElement("table"),n=t.rows||2,i=t.columns||2;return et(e,o,0,n,i),t.headingRows&&re("headingRows",Math.min(t.headingRows,n),o,e,0),t.headingColumns&&re("headingColumns",Math.min(t.headingColumns,i),o,e,0),o}insertRows(e,t={}){const o=this.editor.model,n=t.at||0,i=t.rows||1,r=void 0!==t.copyStructureFromAbove,l=t.copyStructureFromAbove?n-1:n,s=this.getRows(e),a=this.getColumns(e);if(n>s)throw new d("tableutils-insertrows-insert-out-of-range",this,{options:t});o.change((t=>{const o=e.getAttribute("headingRows")||0;if(o>n&&re("headingRows",o+i,e,t,0),!r&&(0===n||n===s))return void et(t,e,n,i,a);const c=r?Math.max(n,l):n,d=new he(e,{endRow:c}),u=new Array(a).fill(1);for(const{row:e,column:o,cellHeight:s,cellWidth:a,cell:c}of d){const d=e+s-1,h=e<=l&&l<=d;e<n&&n<=d?(t.setAttribute("rowspan",s+i,c),u[o]=-a):r&&h&&(u[o]=a)}for(let o=0;o<i;o++){const o=t.createElement("tableRow");t.insert(o,e,n);for(let e=0;e<u.length;e++){const n=u[e],i=t.createPositionAt(o,"end");n>0&&le(t,i,n>1?{colspan:n}:void 0),e+=Math.abs(n)-1}}}))}insertColumns(e,t={}){const o=this.editor.model,n=t.at||0,i=t.columns||1;o.change((t=>{const o=e.getAttribute("headingColumns");n<o&&t.setAttribute("headingColumns",o+i,e);const r=this.getColumns(e);if(0===n||r===n){for(const o of e.getChildren())o.is("element","tableRow")&&tt(i,t,t.createPositionAt(o,n?"end":0));return}const l=new he(e,{column:n,includeAllSlots:!0});for(const e of l){const{row:o,cell:r,cellAnchorColumn:s,cellAnchorRow:a,cellWidth:c,cellHeight:d}=e;if(s<n){t.setAttribute("colspan",c+i,r);const e=a+d-1;for(let t=o;t<=e;t++)l.skipRow(t)}else tt(i,t,e.getPositionBefore())}}))}removeRows(e,t){const o=this.editor.model,n=t.rows||1,i=this.getRows(e),r=t.at,l=r+n-1;if(l>i-1)throw new d("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});o.change((t=>{const o={first:r,last:l},{cellsToMove:n,cellsToTrim:i}=function(e,{first:t,last:o}){const n=new Map,i=[];for(const{row:r,column:l,cellHeight:s,cell:a}of new he(e,{endRow:o})){const e=r+s-1;if(r>=t&&r<=o&&e>o){const e=s-(o-r+1);n.set(l,{cell:a,rowspan:e})}if(r<t&&e>=t){let n;n=e>=o?o-t+1:e-t+1,i.push({cell:a,rowspan:s-n})}}return{cellsToMove:n,cellsToTrim:i}}(e,o);if(n.size){!function(e,t,o,n){const i=new he(e,{includeAllSlots:!0,row:t}),r=[...i],l=e.getChild(t);let s;for(const{column:e,cell:t,isAnchor:i}of r)if(o.has(e)){const{cell:t,rowspan:i}=o.get(e),r=s?n.createPositionAfter(s):n.createPositionAt(l,0);n.move(n.createRangeOn(t),r),re("rowspan",i,t,n),s=t}else i&&(s=t)}(e,l+1,n,t)}for(let o=l;o>=r;o--)t.remove(e.getChild(o));for(const{rowspan:e,cell:o}of i)re("rowspan",e,o,t);!function(e,{first:t,last:o},n){const i=e.getAttribute("headingRows")||0;if(t<i){re("headingRows",o<i?i-(o-t+1):t,e,n,0)}}(e,o,t),Ve(e,this)||Re(e,this)}))}removeColumns(e,t){const o=this.editor.model,n=t.at,i=t.columns||1,r=t.at+i-1;o.change((t=>{!function(e,t,o){const n=e.getAttribute("headingColumns")||0;if(n&&t.first<n){const i=Math.min(n-1,t.last)-t.first+1;o.setAttribute("headingColumns",n-i,e)}}(e,{first:n,last:r},t);const o=Qe(e);for(let i=r;i>=n;i--){for(const{cell:o,column:n,cellWidth:r}of[...new he(e)])n<=i&&r>1&&n+r>i?re("colspan",r-1,o,t):n===i&&t.remove(o);if(o[i]){const e=0===i?o[1]:o[i-1],n=parseFloat(o[i].getAttribute("columnWidth")),r=parseFloat(e.getAttribute("columnWidth"));t.remove(o[i]),t.setAttribute("columnWidth",n+r+"%",e)}}Re(e,this)||Ve(e,this)}))}splitCellVertically(e,t=2){const o=this.editor.model,n=e.parent.parent,i=parseInt(e.getAttribute("rowspan")||"1"),r=parseInt(e.getAttribute("colspan")||"1");o.change((o=>{if(r>1){const{newCellsSpan:n,updatedSpan:l}=ot(r,t);re("colspan",l,e,o);const s={};n>1&&(s.colspan=n),i>1&&(s.rowspan=i);tt(r>t?t-1:r-1,o,o.createPositionAfter(e),s)}if(r<t){const l=t-r,s=[...new he(n)],{column:a}=s.find((({cell:t})=>t===e)),c=s.filter((({cell:t,cellWidth:o,column:n})=>t!==e&&n===a||n<a&&n+o>a));for(const{cell:e,cellWidth:t}of c)o.setAttribute("colspan",t+l,e);const d={};i>1&&(d.rowspan=i),tt(l,o,o.createPositionAfter(e),d);const u=n.getAttribute("headingColumns")||0;u>a&&re("headingColumns",u+l,n,o)}}))}splitCellHorizontally(e,t=2){const o=this.editor.model,n=e.parent,i=n.parent,r=i.getChildIndex(n),l=parseInt(e.getAttribute("rowspan")||"1"),s=parseInt(e.getAttribute("colspan")||"1");o.change((o=>{if(l>1){const n=[...new he(i,{startRow:r,endRow:r+l-1,includeAllSlots:!0})],{newCellsSpan:a,updatedSpan:c}=ot(l,t);re("rowspan",c,e,o);const{column:d}=n.find((({cell:t})=>t===e)),u={};a>1&&(u.rowspan=a),s>1&&(u.colspan=s);for(const e of n){const{column:t,row:n}=e;n>=r+c&&t===d&&(n+r+c)%a==0&&tt(1,o,e.getPositionBefore(),u)}}if(l<t){const n=t-l,a=[...new he(i,{startRow:0,endRow:r})];for(const{cell:t,cellHeight:i,row:l}of a)if(t!==e&&l+i>r){const e=i+n;o.setAttribute("rowspan",e,t)}const c={};s>1&&(c.colspan=s),et(o,i,r+1,n,1,c);const d=i.getAttribute("headingRows")||0;d>r&&re("headingRows",d+n,i,o)}}))}getColumns(e){return[...e.getChild(0).getChildren()].reduce(((e,t)=>e+parseInt(t.getAttribute("colspan")||"1")),0)}getRows(e){return Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0)}createTableWalker(e,t={}){return new he(e,t)}getSelectedTableCells(e){const t=[];for(const o of this.sortRanges(e.getRanges())){const e=o.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}getTableCellsContainingSelection(e){const t=[];for(const o of e.getRanges()){const e=o.start.findAncestor("tableCell");e&&t.push(e)}return t}getSelectionAffectedTableCells(e){const t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){const t=e.map((e=>e.parent.index));return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),o=[...new he(t)].filter((t=>e.includes(t.cell))).map((e=>e.column));return this._getFirstLastIndexesObject(o)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,o=new Set;let n=0;for(const i of e){const{row:e,column:r}=this.getCellLocation(i),l=parseInt(i.getAttribute("rowspan"))||1,s=parseInt(i.getAttribute("colspan"))||1;t.add(e),o.add(r),l>1&&t.add(e+l-1),s>1&&o.add(r+s-1),n+=l*s}const i=function(e,t){const o=Array.from(e.values()),n=Array.from(t.values()),i=Math.max(...o),r=Math.min(...o),l=Math.max(...n),s=Math.min(...n);return(i-r+1)*(l-s+1)} +class Qe extends t{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,o=t.parent,n=o.getChildIndex(t),i=new he(o,{row:n});for(const{cell:t,row:o,column:n}of i)if(t===e)return{row:o,column:n}; +/* istanbul ignore next -- @preserve */}createTable(e,t){const o=e.createElement("table"),n=t.rows||2,i=t.columns||2;return Ze(e,o,0,n,i),t.headingRows&&re("headingRows",Math.min(t.headingRows,n),o,e,0),t.headingColumns&&re("headingColumns",Math.min(t.headingColumns,i),o,e,0),o}insertRows(e,t={}){const o=this.editor.model,n=t.at||0,i=t.rows||1,r=void 0!==t.copyStructureFromAbove,l=t.copyStructureFromAbove?n-1:n,s=this.getRows(e),a=this.getColumns(e);if(n>s)throw new d("tableutils-insertrows-insert-out-of-range",this,{options:t});o.change((t=>{const o=e.getAttribute("headingRows")||0;if(o>n&&re("headingRows",o+i,e,t,0),!r&&(0===n||n===s))return void Ze(t,e,n,i,a);const c=r?Math.max(n,l):n,d=new he(e,{endRow:c}),u=new Array(a).fill(1);for(const{row:e,column:o,cellHeight:s,cellWidth:a,cell:c}of d){const d=e+s-1,h=e<=l&&l<=d;e<n&&n<=d?(t.setAttribute("rowspan",s+i,c),u[o]=-a):r&&h&&(u[o]=a)}for(let o=0;o<i;o++){const o=t.createElement("tableRow");t.insert(o,e,n);for(let e=0;e<u.length;e++){const n=u[e],i=t.createPositionAt(o,"end");n>0&&le(t,i,n>1?{colspan:n}:void 0),e+=Math.abs(n)-1}}}))}insertColumns(e,t={}){const o=this.editor.model,n=t.at||0,i=t.columns||1;o.change((t=>{const o=e.getAttribute("headingColumns");n<o&&t.setAttribute("headingColumns",o+i,e);const r=this.getColumns(e);if(0===n||r===n){for(const o of e.getChildren())o.is("element","tableRow")&&et(i,t,t.createPositionAt(o,n?"end":0));return}const l=new he(e,{column:n,includeAllSlots:!0});for(const e of l){const{row:o,cell:r,cellAnchorColumn:s,cellAnchorRow:a,cellWidth:c,cellHeight:d}=e;if(s<n){t.setAttribute("colspan",c+i,r);const e=a+d-1;for(let t=o;t<=e;t++)l.skipRow(t)}else et(i,t,e.getPositionBefore())}}))}removeRows(e,t){const o=this.editor.model,n=t.rows||1,i=this.getRows(e),r=t.at,l=r+n-1;if(l>i-1)throw new d("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});o.change((t=>{const o={first:r,last:l},{cellsToMove:n,cellsToTrim:i}=function(e,{first:t,last:o}){const n=new Map,i=[];for(const{row:r,column:l,cellHeight:s,cell:a}of new he(e,{endRow:o})){const e=r+s-1;if(r>=t&&r<=o&&e>o){const e=s-(o-r+1);n.set(l,{cell:a,rowspan:e})}if(r<t&&e>=t){let n;n=e>=o?o-t+1:e-t+1,i.push({cell:a,rowspan:s-n})}}return{cellsToMove:n,cellsToTrim:i}}(e,o);if(n.size){!function(e,t,o,n){const i=new he(e,{includeAllSlots:!0,row:t}),r=[...i],l=e.getChild(t);let s;for(const{column:e,cell:t,isAnchor:i}of r)if(o.has(e)){const{cell:t,rowspan:i}=o.get(e),r=s?n.createPositionAfter(s):n.createPositionAt(l,0);n.move(n.createRangeOn(t),r),re("rowspan",i,t,n),s=t}else i&&(s=t)}(e,l+1,n,t)}for(let o=l;o>=r;o--)t.remove(e.getChild(o));for(const{rowspan:e,cell:o}of i)re("rowspan",e,o,t);!function(e,{first:t,last:o},n){const i=e.getAttribute("headingRows")||0;if(t<i){re("headingRows",o<i?i-(o-t+1):t,e,n,0)}}(e,o,t),Ve(e,this)||Re(e,this)}))}removeColumns(e,t){const o=this.editor.model,n=t.at,i=t.columns||1,r=t.at+i-1;o.change((t=>{!function(e,t,o){const n=e.getAttribute("headingColumns")||0;if(n&&t.first<n){const i=Math.min(n-1,t.last)-t.first+1;o.setAttribute("headingColumns",n-i,e)}}(e,{first:n,last:r},t);const o=Ye(e);for(let i=r;i>=n;i--){for(const{cell:o,column:n,cellWidth:r}of[...new he(e)])n<=i&&r>1&&n+r>i?re("colspan",r-1,o,t):n===i&&t.remove(o);if(o[i]){const e=0===i?o[1]:o[i-1],n=parseFloat(o[i].getAttribute("columnWidth")),r=parseFloat(e.getAttribute("columnWidth"));t.remove(o[i]),t.setAttribute("columnWidth",n+r+"%",e)}}Re(e,this)||Ve(e,this)}))}splitCellVertically(e,t=2){const o=this.editor.model,n=e.parent.parent,i=parseInt(e.getAttribute("rowspan")||"1"),r=parseInt(e.getAttribute("colspan")||"1");o.change((o=>{if(r>1){const{newCellsSpan:n,updatedSpan:l}=tt(r,t);re("colspan",l,e,o);const s={};n>1&&(s.colspan=n),i>1&&(s.rowspan=i);et(r>t?t-1:r-1,o,o.createPositionAfter(e),s)}if(r<t){const l=t-r,s=[...new he(n)],{column:a}=s.find((({cell:t})=>t===e)),c=s.filter((({cell:t,cellWidth:o,column:n})=>t!==e&&n===a||n<a&&n+o>a));for(const{cell:e,cellWidth:t}of c)o.setAttribute("colspan",t+l,e);const d={};i>1&&(d.rowspan=i),et(l,o,o.createPositionAfter(e),d);const u=n.getAttribute("headingColumns")||0;u>a&&re("headingColumns",u+l,n,o)}}))}splitCellHorizontally(e,t=2){const o=this.editor.model,n=e.parent,i=n.parent,r=i.getChildIndex(n),l=parseInt(e.getAttribute("rowspan")||"1"),s=parseInt(e.getAttribute("colspan")||"1");o.change((o=>{if(l>1){const n=[...new he(i,{startRow:r,endRow:r+l-1,includeAllSlots:!0})],{newCellsSpan:a,updatedSpan:c}=tt(l,t);re("rowspan",c,e,o);const{column:d}=n.find((({cell:t})=>t===e)),u={};a>1&&(u.rowspan=a),s>1&&(u.colspan=s);for(const e of n){const{column:t,row:n}=e;n>=r+c&&t===d&&(n+r+c)%a==0&&et(1,o,e.getPositionBefore(),u)}}if(l<t){const n=t-l,a=[...new he(i,{startRow:0,endRow:r})];for(const{cell:t,cellHeight:i,row:l}of a)if(t!==e&&l+i>r){const e=i+n;o.setAttribute("rowspan",e,t)}const c={};s>1&&(c.colspan=s),Ze(o,i,r+1,n,1,c);const d=i.getAttribute("headingRows")||0;d>r&&re("headingRows",d+n,i,o)}}))}getColumns(e){return[...e.getChild(0).getChildren()].reduce(((e,t)=>e+parseInt(t.getAttribute("colspan")||"1")),0)}getRows(e){return Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0)}createTableWalker(e,t={}){return new he(e,t)}getSelectedTableCells(e){const t=[];for(const o of this.sortRanges(e.getRanges())){const e=o.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}getTableCellsContainingSelection(e){const t=[];for(const o of e.getRanges()){const e=o.start.findAncestor("tableCell");e&&t.push(e)}return t}getSelectionAffectedTableCells(e){const t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){const t=e.map((e=>e.parent.index));return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),o=[...new he(t)].filter((t=>e.includes(t.cell))).map((e=>e.column));return this._getFirstLastIndexesObject(o)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,o=new Set;let n=0;for(const i of e){const{row:e,column:r}=this.getCellLocation(i),l=parseInt(i.getAttribute("rowspan"))||1,s=parseInt(i.getAttribute("colspan"))||1;t.add(e),o.add(r),l>1&&t.add(e+l-1),s>1&&o.add(r+s-1),n+=l*s}const i=function(e,t){const o=Array.from(e.values()),n=Array.from(t.values()),i=Math.max(...o),r=Math.min(...o),l=Math.max(...n),s=Math.min(...n);return(i-r+1)*(l-s+1)} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */(t,o);return i==n}sortRanges(e){return Array.from(e).sort(nt)}_getFirstLastIndexesObject(e){const t=e.sort(((e,t)=>e-t));return{first:t[0],last:t[t.length-1]}}_areCellInTheSameTableSection(e){const t=e[0].findAncestor("table"),o=this.getRowIndexes(e),n=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(o,n))return!1;const i=this.getColumnIndexes(e),r=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(i,r)}_areIndexesInSameSection({first:e,last:t},o){return e<o===t<o}}function et(e,t,o,n,i,r={}){for(let l=0;l<n;l++){const n=e.createElement("tableRow");e.insert(n,t,o),tt(i,e,e.createPositionAt(n,"end"),r)}}function tt(e,t,o,n={}){for(let i=0;i<e;i++)le(t,o,n)}function ot(e,t){if(e<t)return{newCellsSpan:1,updatedSpan:1};const o=Math.floor(e/t);return{newCellsSpan:o,updatedSpan:e-o*t+o}}function nt(e,t){const o=e.start,n=t.start;return o.isBefore(n)?-1:1}class it extends e{refresh(){const e=this.editor.plugins.get(Ze),t=e.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=e.isSelectionRectangular(t)}execute(){const e=this.editor.model,t=this.editor.plugins.get(Ze);e.change((o=>{const n=t.getSelectedTableCells(e.document.selection),i=n.shift(),{mergeWidth:r,mergeHeight:l}=function(e,t,o){let n=0,i=0;for(const e of t){const{row:t,column:r}=o.getCellLocation(e);n=st(e,r,n,"colspan"),i=st(e,t,i,"rowspan")}const{row:r,column:l}=o.getCellLocation(e),s=n-l,a=i-r;return{mergeWidth:s,mergeHeight:a}}(i,n,t);re("colspan",r,i,o),re("rowspan",l,i,o);for(const e of n)rt(e,i,o);Ie(i.findAncestor("table"),t),o.setSelection(i,"in")}))}}function rt(e,t,o){lt(e)||(lt(t)&&o.remove(o.createRangeIn(t)),o.move(o.createRangeIn(e),o.createPositionAt(t,"end"))),o.remove(e)}function lt(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}function st(e,t,o,n){const i=parseInt(e.getAttribute(n)||"1");return Math.max(o,t+i)} + */(t,o);return i==n}sortRanges(e){return Array.from(e).sort(ot)}_getFirstLastIndexesObject(e){const t=e.sort(((e,t)=>e-t));return{first:t[0],last:t[t.length-1]}}_areCellInTheSameTableSection(e){const t=e[0].findAncestor("table"),o=this.getRowIndexes(e),n=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(o,n))return!1;const i=this.getColumnIndexes(e),r=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(i,r)}_areIndexesInSameSection({first:e,last:t},o){return e<o===t<o}}function Ze(e,t,o,n,i,r={}){for(let l=0;l<n;l++){const n=e.createElement("tableRow");e.insert(n,t,o),et(i,e,e.createPositionAt(n,"end"),r)}}function et(e,t,o,n={}){for(let i=0;i<e;i++)le(t,o,n)}function tt(e,t){if(e<t)return{newCellsSpan:1,updatedSpan:1};const o=Math.floor(e/t);return{newCellsSpan:o,updatedSpan:e-o*t+o}}function ot(e,t){const o=e.start,n=t.start;return o.isBefore(n)?-1:1}class nt extends e{refresh(){const e=this.editor.plugins.get(Qe),t=e.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=e.isSelectionRectangular(t)}execute(){const e=this.editor.model,t=this.editor.plugins.get(Qe);e.change((o=>{const n=t.getSelectedTableCells(e.document.selection),i=n.shift(),{mergeWidth:r,mergeHeight:l}=function(e,t,o){let n=0,i=0;for(const e of t){const{row:t,column:r}=o.getCellLocation(e);n=lt(e,r,n,"colspan"),i=lt(e,t,i,"rowspan")}const{row:r,column:l}=o.getCellLocation(e),s=n-l,a=i-r;return{mergeWidth:s,mergeHeight:a}}(i,n,t);re("colspan",r,i,o),re("rowspan",l,i,o);for(const e of n)it(e,i,o);Ie(i.findAncestor("table"),t),o.setSelection(i,"in")}))}}function it(e,t,o){rt(e)||(rt(t)&&o.remove(o.createRangeIn(t)),o.move(o.createRangeIn(e),o.createPositionAt(t,"end"))),o.remove(e)}function rt(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}function lt(e,t,o,n){const i=parseInt(e.getAttribute(n)||"1");return Math.max(o,t+i)} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class at extends e{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),o=t.getSelectionAffectedTableCells(e.document.selection),n=t.getRowIndexes(o),i=o[0].findAncestor("table"),r=[];for(let t=n.first;t<=n.last;t++)for(const o of i.getChild(t).getChildren())r.push(e.createRangeOn(o));e.change((e=>{e.setSelection(r)}))}} + */class st extends e{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),o=t.getSelectionAffectedTableCells(e.document.selection),n=t.getRowIndexes(o),i=o[0].findAncestor("table"),r=[];for(let t=n.first;t<=n.last;t++)for(const o of i.getChild(t).getChildren())r.push(e.createRangeOn(o));e.change((e=>{e.setSelection(r)}))}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class ct extends e{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,o=e.getSelectionAffectedTableCells(t.document.selection),n=o[0],i=o.pop(),r=n.findAncestor("table"),l=e.getCellLocation(n),s=e.getCellLocation(i),a=Math.min(l.column,s.column),c=Math.max(l.column,s.column),d=[];for(const e of new he(r,{startColumn:a,endColumn:c}))d.push(t.createRangeOn(e.cell));t.change((e=>{e.setSelection(d)}))}} + */class at extends e{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,o=e.getSelectionAffectedTableCells(t.document.selection),n=o[0],i=o.pop(),r=n.findAncestor("table"),l=e.getCellLocation(n),s=e.getCellLocation(i),a=Math.min(l.column,s.column),c=Math.max(l.column,s.column),d=[];for(const e of new he(r,{startColumn:a,endColumn:c}))d.push(t.createRangeOn(e.cell));t.change((e=>{e.setSelection(d)}))}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */function dt(e){e.document.registerPostFixer((t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;const i=new Set;for(const t of o){let o=null;"insert"==t.type&&"table"==t.name&&(o=t.position.nodeAfter),"insert"!=t.type&&"remove"!=t.type||"tableRow"!=t.name&&"tableCell"!=t.name||(o=t.position.findAncestor("table")),bt(t)&&(o=t.range.start.findAncestor("table")),o&&!i.has(o)&&(n=ut(o,e)||n,n=ht(o,e)||n,i.add(o))}return n}(t,e)))}function ut(e,t){let o=!1;const n=function(e){const t=parseInt(e.getAttribute("headingRows")||"0"),o=Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0),n=[];for(const{row:i,cell:r,cellHeight:l}of new he(e)){if(l<2)continue;const e=i<t?t:o;if(i+l>e){const t=e-i;n.push({cell:r,rowspan:t})}}return n}(e);if(n.length){o=!0;for(const e of n)re("rowspan",e.rowspan,e.cell,t,1)}return o}function ht(e,t){let o=!1;const n=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:o}of new he(e,{includeAllSlots:!0}))t[o]++;return t}(e),i=[];for(const[t,o]of n.entries())!o&&e.getChild(t).is("element","tableRow")&&i.push(t);if(i.length){o=!0;for(const o of i.reverse())t.remove(e.getChild(o)),n.splice(o,1)}const r=n.filter(((t,o)=>e.getChild(o).is("element","tableRow"))),l=r[0];if(!r.every((e=>e===l))){const n=r.reduce(((e,t)=>t>e?t:e),0);for(const[i,l]of r.entries()){const r=n-l;if(r){for(let o=0;o<r;o++)le(t,t.createPositionAt(e.getChild(i),"end"));o=!0}}}return o}function bt(e){if("attribute"!==e.type)return!1;const t=e.attributeKey;return"headingRows"===t||"colspan"===t||"rowspan"===t} + */function ct(e){e.document.registerPostFixer((t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;const i=new Set;for(const t of o){let o=null;"insert"==t.type&&"table"==t.name&&(o=t.position.nodeAfter),"insert"!=t.type&&"remove"!=t.type||"tableRow"!=t.name&&"tableCell"!=t.name||(o=t.position.findAncestor("table")),ht(t)&&(o=t.range.start.findAncestor("table")),o&&!i.has(o)&&(n=dt(o,e)||n,n=ut(o,e)||n,i.add(o))}return n}(t,e)))}function dt(e,t){let o=!1;const n=function(e){const t=parseInt(e.getAttribute("headingRows")||"0"),o=Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0),n=[];for(const{row:i,cell:r,cellHeight:l}of new he(e)){if(l<2)continue;const e=i<t?t:o;if(i+l>e){const t=e-i;n.push({cell:r,rowspan:t})}}return n}(e);if(n.length){o=!0;for(const e of n)re("rowspan",e.rowspan,e.cell,t,1)}return o}function ut(e,t){let o=!1;const n=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:o}of new he(e,{includeAllSlots:!0}))t[o]++;return t}(e),i=[];for(const[t,o]of n.entries())!o&&e.getChild(t).is("element","tableRow")&&i.push(t);if(i.length){o=!0;for(const o of i.reverse())t.remove(e.getChild(o)),n.splice(o,1)}const r=n.filter(((t,o)=>e.getChild(o).is("element","tableRow"))),l=r[0];if(!r.every((e=>e===l))){const n=r.reduce(((e,t)=>t>e?t:e),0);for(const[i,l]of r.entries()){const r=n-l;if(r){for(let o=0;o<r;o++)le(t,t.createPositionAt(e.getChild(i),"end"));o=!0}}}return o}function ht(e){if("attribute"!==e.type)return!1;const t=e.attributeKey;return"headingRows"===t||"colspan"===t||"rowspan"===t} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */function mt(e){e.document.registerPostFixer((t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;for(const t of o)"insert"==t.type&&"table"==t.name&&(n=gt(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableRow"==t.name&&(n=pt(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableCell"==t.name&&(n=ft(t.position.nodeAfter,e)||n),"remove"!=t.type&&"insert"!=t.type||!wt(t)||(n=ft(t.position.parent,e)||n);return n}(t,e)))}function gt(e,t){let o=!1;for(const n of e.getChildren())n.is("element","tableRow")&&(o=pt(n,t)||o);return o}function pt(e,t){let o=!1;for(const n of e.getChildren())o=ft(n,t)||o;return o}function ft(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;const o=Array.from(e.getChildren()).filter((e=>e.is("$text")));for(const e of o)t.wrap(t.createRangeOn(e),"paragraph");return!!o.length}function wt(e){return!!e.position.parent.is("element","tableCell")&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)} + */function bt(e){e.document.registerPostFixer((t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;for(const t of o)"insert"==t.type&&"table"==t.name&&(n=mt(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableRow"==t.name&&(n=gt(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableCell"==t.name&&(n=pt(t.position.nodeAfter,e)||n),"remove"!=t.type&&"insert"!=t.type||!ft(t)||(n=pt(t.position.parent,e)||n);return n}(t,e)))}function mt(e,t){let o=!1;for(const n of e.getChildren())n.is("element","tableRow")&&(o=gt(n,t)||o);return o}function gt(e,t){let o=!1;for(const n of e.getChildren())o=pt(n,t)||o;return o}function pt(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;const o=Array.from(e.getChildren()).filter((e=>e.is("$text")));for(const e of o)t.wrap(t.createRangeOn(e),"paragraph");return!!o.length}function ft(e){return!!e.position.parent.is("element","tableCell")&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */function kt(e,t){if(!e.is("element","paragraph"))return!1;const o=t.toViewElement(e);return!!o&&fe(e)!==o.is("element","span")}function _t(e,{insertAt:t}={}){if(!e||"undefined"==typeof document)return;const o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",window.litNonce&&n.setAttribute("nonce",window.litNonce),"top"===t&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}_t(":root{--ck-color-selector-focused-cell-background:rgba(158,201,250,.3)}.ck-widget.table td.ck-editor__nested-editable.ck-editor__nested-editable_focused,.ck-widget.table td.ck-editor__nested-editable:focus,.ck-widget.table th.ck-editor__nested-editable.ck-editor__nested-editable_focused,.ck-widget.table th.ck-editor__nested-editable:focus{background:var(--ck-color-selector-focused-cell-background);border-style:none;outline:1px solid var(--ck-color-focus-border);outline-offset:-1px}"); + */function wt(e,t){if(!e.is("element","paragraph"))return!1;const o=t.toViewElement(e);return!!o&&fe(e)!==o.is("element","span")}function kt(e,{insertAt:t}={}){if(!e||"undefined"==typeof document)return;const o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",window.litNonce&&n.setAttribute("nonce",window.litNonce),"top"===t&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}kt(":root{--ck-color-selector-focused-cell-background:rgba(158,201,250,.3)}.ck-widget.table td.ck-editor__nested-editable.ck-editor__nested-editable_focused,.ck-widget.table td.ck-editor__nested-editable:focus,.ck-widget.table th.ck-editor__nested-editable.ck-editor__nested-editable_focused,.ck-widget.table th.ck-editor__nested-editable:focus{background:var(--ck-color-selector-focused-cell-background);border-style:none;outline:1px solid var(--ck-color-focus-border);outline-offset:-1px}"); /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -class Ct extends t{static get pluginName(){return"TableEditing"}static get requires(){return[Ze]}constructor(e){super(e),this._additionalSlots=[]}init(){const e=this.editor,t=e.model,o=t.schema,n=e.conversion,i=e.plugins.get(Ze);o.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),o.register("tableRow",{allowIn:"table",isLimit:!0}),o.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),n.for("upcast").add((e=>{e.on("element:figure",((e,t,o)=>{if(!o.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const n=function(e){for(const t of e.getChildren())if(t.is("element","table"))return t}(t.viewItem);if(!n||!o.consumable.test(n,{name:!0}))return;o.consumable.consume(t.viewItem,{name:!0,classes:"table"});const i=o.convertItem(n,t.modelCursor),r=a(i.modelRange.getItems());r?(o.convertChildren(t.viewItem,o.writer.createPositionAt(r,"end")),o.updateConversionResult(r,t)):o.consumable.revert(t.viewItem,{name:!0,classes:"table"})}))})),n.for("upcast").add(ce()),n.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:me(i,{asWidget:!0,additionalSlots:this._additionalSlots})}),n.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:me(i,{additionalSlots:this._additionalSlots})}),n.for("upcast").elementToElement({model:"tableRow",view:"tr"}),n.for("upcast").add((e=>{e.on("element:tr",((e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()}),{priority:"high"})})),n.for("downcast").elementToElement({model:"tableRow",view:(e,{writer:t})=>e.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}),n.for("upcast").elementToElement({model:"tableCell",view:"td"}),n.for("upcast").elementToElement({model:"tableCell",view:"th"}),n.for("upcast").add(de("td")),n.for("upcast").add(de("th")),n.for("editingDowncast").elementToElement({model:"tableCell",view:ge({asWidget:!0})}),n.for("dataDowncast").elementToElement({model:"tableCell",view:ge()}),n.for("editingDowncast").elementToElement({model:"paragraph",view:pe({asWidget:!0}),converterPriority:"high"}),n.for("dataDowncast").elementToElement({model:"paragraph",view:pe(),converterPriority:"high"}),n.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),n.for("upcast").attributeToAttribute({model:{key:"colspan",value:vt("colspan")},view:"colspan"}),n.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),n.for("upcast").attributeToAttribute({model:{key:"rowspan",value:vt("rowspan")},view:"rowspan"}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new we(e)),e.commands.add("insertTableRowAbove",new ke(e,{order:"above"})),e.commands.add("insertTableRowBelow",new ke(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new _e(e,{order:"left"})),e.commands.add("insertTableColumnRight",new _e(e,{order:"right"})),e.commands.add("removeTableRow",new We(e)),e.commands.add("removeTableColumn",new Ne(e)),e.commands.add("splitTableCellVertically",new Ce(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new Ce(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new it(e)),e.commands.add("mergeTableCellRight",new ze(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new ze(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new ze(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new ze(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new Fe(e)),e.commands.add("setTableRowHeader",new Le(e)),e.commands.add("selectTableRow",new at(e)),e.commands.add("selectTableColumn",new ct(e)),dt(t),mt(t),this.listenTo(t.document,"change:data",(()=>{!function(e,t){const o=e.document.differ;for(const e of o.getChanges()){let o,n=!1;if("attribute"==e.type){const t=e.range.start.nodeAfter;if(!t||!t.is("element","table"))continue;if("headingRows"!=e.attributeKey&&"headingColumns"!=e.attributeKey)continue;o=t,n="headingRows"==e.attributeKey}else"tableRow"!=e.name&&"tableCell"!=e.name||(o=e.position.findAncestor("table"),n="tableRow"==e.name);if(!o)continue;const i=o.getAttribute("headingRows")||0,r=o.getAttribute("headingColumns")||0,l=new he(o);for(const e of l){const o=e.row<i||e.column<r?"th":"td",l=t.mapper.toViewElement(e.cell);l&&l.is("element")&&l.name!=o&&t.reconvertItem(n?e.cell.parent:e.cell)}}} +class _t extends t{static get pluginName(){return"TableEditing"}static get requires(){return[Qe]}constructor(e){super(e),this._additionalSlots=[]}init(){const e=this.editor,t=e.model,o=t.schema,n=e.conversion,i=e.plugins.get(Qe);o.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),o.register("tableRow",{allowIn:"table",isLimit:!0}),o.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),n.for("upcast").add((e=>{e.on("element:figure",((e,t,o)=>{if(!o.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const n=function(e){for(const t of e.getChildren())if(t.is("element","table"))return t}(t.viewItem);if(!n||!o.consumable.test(n,{name:!0}))return;o.consumable.consume(t.viewItem,{name:!0,classes:"table"});const i=o.convertItem(n,t.modelCursor),r=a(i.modelRange.getItems());r?(o.convertChildren(t.viewItem,o.writer.createPositionAt(r,"end")),o.updateConversionResult(r,t)):o.consumable.revert(t.viewItem,{name:!0,classes:"table"})}))})),n.for("upcast").add(ce()),n.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:me(i,{asWidget:!0,additionalSlots:this._additionalSlots})}),n.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:me(i,{additionalSlots:this._additionalSlots})}),n.for("upcast").elementToElement({model:"tableRow",view:"tr"}),n.for("upcast").add((e=>{e.on("element:tr",((e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()}),{priority:"high"})})),n.for("downcast").elementToElement({model:"tableRow",view:(e,{writer:t})=>e.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}),n.for("upcast").elementToElement({model:"tableCell",view:"td"}),n.for("upcast").elementToElement({model:"tableCell",view:"th"}),n.for("upcast").add(de("td")),n.for("upcast").add(de("th")),n.for("editingDowncast").elementToElement({model:"tableCell",view:ge({asWidget:!0})}),n.for("dataDowncast").elementToElement({model:"tableCell",view:ge()}),n.for("editingDowncast").elementToElement({model:"paragraph",view:pe({asWidget:!0}),converterPriority:"high"}),n.for("dataDowncast").elementToElement({model:"paragraph",view:pe(),converterPriority:"high"}),n.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),n.for("upcast").attributeToAttribute({model:{key:"colspan",value:Ct("colspan")},view:"colspan"}),n.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),n.for("upcast").attributeToAttribute({model:{key:"rowspan",value:Ct("rowspan")},view:"rowspan"}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new we(e)),e.commands.add("insertTableRowAbove",new ke(e,{order:"above"})),e.commands.add("insertTableRowBelow",new ke(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new _e(e,{order:"left"})),e.commands.add("insertTableColumnRight",new _e(e,{order:"right"})),e.commands.add("removeTableRow",new We(e)),e.commands.add("removeTableColumn",new Ne(e)),e.commands.add("splitTableCellVertically",new Ce(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new Ce(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new nt(e)),e.commands.add("mergeTableCellRight",new ze(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new ze(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new ze(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new ze(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new Fe(e)),e.commands.add("setTableRowHeader",new Le(e)),e.commands.add("selectTableRow",new st(e)),e.commands.add("selectTableColumn",new at(e)),ct(t),bt(t),this.listenTo(t.document,"change:data",(()=>{!function(e,t){const o=e.document.differ;for(const e of o.getChanges()){let o,n=!1;if("attribute"==e.type){const t=e.range.start.nodeAfter;if(!t||!t.is("element","table"))continue;if("headingRows"!=e.attributeKey&&"headingColumns"!=e.attributeKey)continue;o=t,n="headingRows"==e.attributeKey}else"tableRow"!=e.name&&"tableCell"!=e.name||(o=e.position.findAncestor("table"),n="tableRow"==e.name);if(!o)continue;const i=o.getAttribute("headingRows")||0,r=o.getAttribute("headingColumns")||0,l=new he(o);for(const e of l){const o=e.row<i||e.column<r?"th":"td",l=t.mapper.toViewElement(e.cell);l&&l.is("element")&&l.name!=o&&t.reconvertItem(n?e.cell.parent:e.cell)}}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */(t,e.editing),function(e,t){const o=e.document.differ,n=new Set;for(const e of o.getChanges()){const t="attribute"==e.type?e.range.start.parent:e.position.parent;t.is("element","tableCell")&&n.add(t)}for(const e of n.values()){const o=Array.from(e.getChildren()).filter((e=>kt(e,t.mapper)));for(const e of o)t.reconvertItem(e)}}(t,e.editing)}))}registerAdditionalSlot(e){this._additionalSlots.push(e)}}function vt(e){return t=>{const o=parseInt(t.getAttribute(e));return Number.isNaN(o)||o<=0?null:o}}_t(".ck .ck-insert-table-dropdown__grid{display:flex;flex-direction:row;flex-wrap:wrap}:root{--ck-insert-table-dropdown-padding:10px;--ck-insert-table-dropdown-box-height:11px;--ck-insert-table-dropdown-box-width:12px;--ck-insert-table-dropdown-box-margin:1px}.ck .ck-insert-table-dropdown__grid{padding:var(--ck-insert-table-dropdown-padding) var(--ck-insert-table-dropdown-padding) 0;width:calc(var(--ck-insert-table-dropdown-box-width)*10 + var(--ck-insert-table-dropdown-box-margin)*20 + var(--ck-insert-table-dropdown-padding)*2)}.ck .ck-insert-table-dropdown__label,.ck[dir=rtl] .ck-insert-table-dropdown__label{text-align:center}.ck .ck-insert-table-dropdown-grid-box{border:1px solid var(--ck-color-base-border);border-radius:1px;margin:var(--ck-insert-table-dropdown-box-margin);min-height:var(--ck-insert-table-dropdown-box-height);min-width:var(--ck-insert-table-dropdown-box-width);outline:none;transition:none}.ck .ck-insert-table-dropdown-grid-box:focus{box-shadow:none}.ck .ck-insert-table-dropdown-grid-box.ck-on{background:var(--ck-color-focus-outer-shadow);border-color:var(--ck-color-focus-border)}"); + */(t,e.editing),function(e,t){const o=e.document.differ,n=new Set;for(const e of o.getChanges()){const t="attribute"==e.type?e.range.start.parent:e.position.parent;t.is("element","tableCell")&&n.add(t)}for(const e of n.values()){const o=Array.from(e.getChildren()).filter((e=>wt(e,t.mapper)));for(const e of o)t.reconvertItem(e)}}(t,e.editing)}))}registerAdditionalSlot(e){this._additionalSlots.push(e)}}function Ct(e){return t=>{const o=parseInt(t.getAttribute(e));return Number.isNaN(o)||o<=0?null:o}}kt(".ck .ck-insert-table-dropdown__grid{display:flex;flex-direction:row;flex-wrap:wrap}:root{--ck-insert-table-dropdown-padding:10px;--ck-insert-table-dropdown-box-height:11px;--ck-insert-table-dropdown-box-width:12px;--ck-insert-table-dropdown-box-margin:1px}.ck .ck-insert-table-dropdown__grid{padding:var(--ck-insert-table-dropdown-padding) var(--ck-insert-table-dropdown-padding) 0;width:calc(var(--ck-insert-table-dropdown-box-width)*10 + var(--ck-insert-table-dropdown-box-margin)*20 + var(--ck-insert-table-dropdown-padding)*2)}.ck .ck-insert-table-dropdown__label,.ck[dir=rtl] .ck-insert-table-dropdown__label{text-align:center}.ck .ck-insert-table-dropdown-grid-box{border:1px solid var(--ck-color-base-border);border-radius:1px;margin:var(--ck-insert-table-dropdown-box-margin);min-height:var(--ck-insert-table-dropdown-box-height);min-width:var(--ck-insert-table-dropdown-box-width);outline:none;transition:none}.ck .ck-insert-table-dropdown-grid-box:focus{box-shadow:none}.ck .ck-insert-table-dropdown-grid-box.ck-on{background:var(--ck-color-focus-outer-shadow);border-color:var(--ck-color-focus-border)}"); /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -class yt extends f{constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new u,this.focusTracker=new h,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",((e,t)=>`${t} × ${e}`)),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:t.to("label")}]}],on:{mousedown:t.to((e=>{e.preventDefault()})),click:t.to((()=>{this.fire("execute")}))}}),this.on("boxover",((e,t)=>{const{row:o,column:n}=t.target.dataset;this.items.get(10*(parseInt(o,10)-1)+(parseInt(n,10)-1)).focus()})),this.focusTracker.on("change:focusedElement",((e,t,o)=>{if(!o)return;const{row:n,column:i}=o.dataset;this.set({rows:parseInt(n),columns:parseInt(i)})})),this.on("change:columns",(()=>this._highlightGridBoxes())),this.on("change:rows",(()=>this._highlightGridBoxes()))}render(){super.render(),w({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection});for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map(((o,n)=>{const i=Math.floor(n/10)<e&&n%10<t;o.set("isOn",i)}))}_createGridButton(e,t,o,n){const i=new k(e);return i.set({label:n,class:"ck-insert-table-dropdown-grid-box"}),i.extendTemplate({attributes:{"data-row":t,"data-column":o}}),i}_createGridCollection(){const e=[];for(let t=0;t<100;t++){const o=Math.floor(t/10),n=t%10,i=`${o+1} × ${n+1}`;e.push(this._createGridButton(this.locale,o+1,n+1,i))}return this.createCollection(e)}} +class vt extends f{constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new u,this.focusTracker=new h,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",((e,t)=>`${t} × ${e}`)),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:t.to("label")}]}],on:{mousedown:t.to((e=>{e.preventDefault()})),click:t.to((()=>{this.fire("execute")}))}}),this.on("boxover",((e,t)=>{const{row:o,column:n}=t.target.dataset;this.items.get(10*(parseInt(o,10)-1)+(parseInt(n,10)-1)).focus()})),this.focusTracker.on("change:focusedElement",((e,t,o)=>{if(!o)return;const{row:n,column:i}=o.dataset;this.set({rows:parseInt(n),columns:parseInt(i)})})),this.on("change:columns",(()=>this._highlightGridBoxes())),this.on("change:rows",(()=>this._highlightGridBoxes()))}render(){super.render(),w({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection});for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map(((o,n)=>{const i=Math.floor(n/10)<e&&n%10<t;o.set("isOn",i)}))}_createGridButton(e,t,o,n){const i=new k(e);return i.set({label:n,class:"ck-insert-table-dropdown-grid-box"}),i.extendTemplate({attributes:{"data-row":t,"data-column":o}}),i}_createGridCollection(){const e=[];for(let t=0;t<100;t++){const o=Math.floor(t/10),n=t%10,i=`${o+1} × ${n+1}`;e.push(this._createGridButton(this.locale,o+1,n+1,i))}return this.createCollection(e)}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -class At extends t{static get pluginName(){return"TableUI"}init(){const e=this.editor,t=this.editor.t,o="ltr"===e.locale.contentLanguageDirection;e.ui.componentFactory.add("insertTable",(o=>{const n=e.commands.get("insertTable"),i=_(o);let r;return i.bind("isEnabled").to(n),i.buttonView.set({icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 6v3h4V6H3zm0 4v3h4v-3H3zm0 4v3h4v-3H3zm5 3h4v-3H8v3zm5 0h4v-3h-4v3zm4-4v-3h-4v3h4zm0-4V6h-4v3h4zm1.5 8a1.5 1.5 0 0 1-1.5 1.5H3A1.5 1.5 0 0 1 1.5 17V4c.222-.863 1.068-1.5 2-1.5h13c.932 0 1.778.637 2 1.5v13zM12 13v-3H8v3h4zm0-4V6H8v3h4z"/></svg>',label:t("Insert table"),tooltip:!0}),i.on("change:isOpen",(()=>{r||(r=new yt(o),i.panelView.children.add(r),r.delegate("execute").to(i),i.on("execute",(()=>{e.execute("insertTable",{rows:r.rows,columns:r.columns}),e.editing.view.focus()})))})),i})),e.ui.componentFactory.add("tableColumn",(e=>{const n=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:o?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:o?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M18 7v1H2V7h16zm0 5v1H2v-1h16z" opacity=".6"/><path d="M14 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1zm-2 1H8v4h4V2zm0 6H8v4h4V8zm0 6H8v4h4v-4z"/></svg>',n,e)})),e.ui.componentFactory.add("tableRow",(e=>{const o=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v16h-1V2z" opacity=".6"/><path d="M1 6h18a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1 2v4h4V8H2zm6 0v4h4V8H8zm6 0v4h4V8h-4z"/></svg>',o,e)})),e.ui.componentFactory.add("mergeTableCells",(e=>{const n=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:o?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:o?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v7h-1V2zm6 5v1H2V7h16zM8 12v1H2v-1h6z" opacity=".6"/><path d="M7 7h12a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1zm1 2v9h10V9H8z"/></svg>',n,e)}))}_prepareDropdown(e,t,o,n){const i=this.editor,r=_(n),l=this._fillDropdownWithListOptions(r,o);return r.buttonView.set({label:e,icon:t,tooltip:!0}),r.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(r,"execute",(e=>{i.execute(e.source.commandName),e.source instanceof C||i.editing.view.focus()})),r}_prepareMergeSplitButtonDropdown(e,t,o,n){const i=this.editor,r=_(n,v),l="mergeTableCells",s=i.commands.get(l),a=this._fillDropdownWithListOptions(r,o);return r.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([s,...a],"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(r.buttonView,"execute",(()=>{i.execute(l),i.editing.view.focus()})),this.listenTo(r,"execute",(e=>{i.execute(e.source.commandName),i.editing.view.focus()})),r}_fillDropdownWithListOptions(e,t){const o=this.editor,n=[],i=new b;for(const e of t)Tt(e,o,n,i);return y(e,i),n}}function Tt(e,t,o,n){if("button"===e.type||"switchbutton"===e.type){const n=e.model=new A(e.model),{commandName:i,bindIsOn:r}=e.model,l=t.commands.get(i);o.push(l),n.set({commandName:i}),n.bind("isEnabled").to(l),r&&n.bind("isOn").to(l,"value"),n.set({withText:!0})}n.add(e)}_t(':root{--ck-table-selected-cell-background:rgba(158,207,250,.3)}.ck.ck-editor__editable .table table td.ck-editor__editable_selected,.ck.ck-editor__editable .table table th.ck-editor__editable_selected{box-shadow:unset;caret-color:transparent;outline:unset;position:relative}.ck.ck-editor__editable .table table td.ck-editor__editable_selected:after,.ck.ck-editor__editable .table table th.ck-editor__editable_selected:after{background-color:var(--ck-table-selected-cell-background);bottom:0;content:"";left:0;pointer-events:none;position:absolute;right:0;top:0}.ck.ck-editor__editable .table table td.ck-editor__editable_selected ::selection,.ck.ck-editor__editable .table table td.ck-editor__editable_selected:focus,.ck.ck-editor__editable .table table th.ck-editor__editable_selected ::selection,.ck.ck-editor__editable .table table th.ck-editor__editable_selected:focus{background-color:transparent}.ck.ck-editor__editable .table table td.ck-editor__editable_selected .ck-widget,.ck.ck-editor__editable .table table th.ck-editor__editable_selected .ck-widget{outline:unset}.ck.ck-editor__editable .table table td.ck-editor__editable_selected .ck-widget>.ck-widget__selection-handle,.ck.ck-editor__editable .table table th.ck-editor__editable_selected .ck-widget>.ck-widget__selection-handle{display:none}'); +class yt extends t{static get pluginName(){return"TableUI"}init(){const e=this.editor,t=this.editor.t,o="ltr"===e.locale.contentLanguageDirection;e.ui.componentFactory.add("insertTable",(o=>{const n=e.commands.get("insertTable"),i=_(o);let r;return i.bind("isEnabled").to(n),i.buttonView.set({icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 6v3h4V6H3zm0 4v3h4v-3H3zm0 4v3h4v-3H3zm5 3h4v-3H8v3zm5 0h4v-3h-4v3zm4-4v-3h-4v3h4zm0-4V6h-4v3h4zm1.5 8a1.5 1.5 0 0 1-1.5 1.5H3A1.5 1.5 0 0 1 1.5 17V4c.222-.863 1.068-1.5 2-1.5h13c.932 0 1.778.637 2 1.5v13zM12 13v-3H8v3h4zm0-4V6H8v3h4z"/></svg>',label:t("Insert table"),tooltip:!0}),i.on("change:isOpen",(()=>{r||(r=new vt(o),i.panelView.children.add(r),r.delegate("execute").to(i),i.on("execute",(()=>{e.execute("insertTable",{rows:r.rows,columns:r.columns}),e.editing.view.focus()})))})),i})),e.ui.componentFactory.add("tableColumn",(e=>{const n=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:o?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:o?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M18 7v1H2V7h16zm0 5v1H2v-1h16z" opacity=".6"/><path d="M14 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1zm-2 1H8v4h4V2zm0 6H8v4h4V8zm0 6H8v4h4v-4z"/></svg>',n,e)})),e.ui.componentFactory.add("tableRow",(e=>{const o=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v16h-1V2z" opacity=".6"/><path d="M1 6h18a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1 2v4h4V8H2zm6 0v4h4V8H8zm6 0v4h4V8h-4z"/></svg>',o,e)})),e.ui.componentFactory.add("mergeTableCells",(e=>{const n=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:o?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:o?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v7h-1V2zm6 5v1H2V7h16zM8 12v1H2v-1h6z" opacity=".6"/><path d="M7 7h12a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1zm1 2v9h10V9H8z"/></svg>',n,e)}))}_prepareDropdown(e,t,o,n){const i=this.editor,r=_(n),l=this._fillDropdownWithListOptions(r,o);return r.buttonView.set({label:e,icon:t,tooltip:!0}),r.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(r,"execute",(e=>{i.execute(e.source.commandName),e.source instanceof C||i.editing.view.focus()})),r}_prepareMergeSplitButtonDropdown(e,t,o,n){const i=this.editor,r=_(n,v),l="mergeTableCells",s=i.commands.get(l),a=this._fillDropdownWithListOptions(r,o);return r.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([s,...a],"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(r.buttonView,"execute",(()=>{i.execute(l),i.editing.view.focus()})),this.listenTo(r,"execute",(e=>{i.execute(e.source.commandName),i.editing.view.focus()})),r}_fillDropdownWithListOptions(e,t){const o=this.editor,n=[],i=new b;for(const e of t)At(e,o,n,i);return y(e,i),n}}function At(e,t,o,n){if("button"===e.type||"switchbutton"===e.type){const n=e.model=new A(e.model),{commandName:i,bindIsOn:r}=e.model,l=t.commands.get(i);o.push(l),n.set({commandName:i}),n.bind("isEnabled").to(l),r&&n.bind("isOn").to(l,"value"),n.set({withText:!0})}n.add(e)}kt(':root{--ck-table-selected-cell-background:rgba(158,207,250,.3)}.ck.ck-editor__editable .table table td.ck-editor__editable_selected,.ck.ck-editor__editable .table table th.ck-editor__editable_selected{box-shadow:unset;caret-color:transparent;outline:unset;position:relative}.ck.ck-editor__editable .table table td.ck-editor__editable_selected:after,.ck.ck-editor__editable .table table th.ck-editor__editable_selected:after{background-color:var(--ck-table-selected-cell-background);bottom:0;content:"";left:0;pointer-events:none;position:absolute;right:0;top:0}.ck.ck-editor__editable .table table td.ck-editor__editable_selected ::selection,.ck.ck-editor__editable .table table td.ck-editor__editable_selected:focus,.ck.ck-editor__editable .table table th.ck-editor__editable_selected ::selection,.ck.ck-editor__editable .table table th.ck-editor__editable_selected:focus{background-color:transparent}.ck.ck-editor__editable .table table td.ck-editor__editable_selected .ck-widget,.ck.ck-editor__editable .table table th.ck-editor__editable_selected .ck-widget{outline:unset}.ck.ck-editor__editable .table table td.ck-editor__editable_selected .ck-widget>.ck-widget__selection-handle,.ck.ck-editor__editable .table table th.ck-editor__editable_selected .ck-widget>.ck-widget__selection-handle{display:none}'); /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -class xt extends t{static get pluginName(){return"TableSelection"}static get requires(){return[Ze,Ze]}init(){const e=this.editor,t=e.model,o=e.editing.view;this.listenTo(t,"deleteContent",((e,t)=>this._handleDeleteContent(e,t)),{priority:"high"}),this.listenTo(o.document,"insertText",((e,t)=>this._handleInsertTextEvent(e,t)),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(Ze),t=this.editor.model.document.selection,o=e.getSelectedTableCells(t);return 0==o.length?null:o}getSelectionAsFragment(){const e=this.editor.plugins.get(Ze),t=this.getSelectedTableCells();return t?this.editor.model.change((o=>{const n=o.createDocumentFragment(),{first:i,last:r}=e.getColumnIndexes(t),{first:l,last:s}=e.getRowIndexes(t),a=t[0].findAncestor("table");let c=s,d=r;if(e.isSelectionRectangular(t)){const e={firstColumn:i,lastColumn:r,firstRow:l,lastRow:s};c=Ee(a,e),d=Pe(a,e)}const u=ve(a,{startRow:l,startColumn:i,endRow:c,endColumn:d},o);return o.insert(u,n,0),n})):null}setCellSelection(e,t){const o=this._getCellsToSelect(e,t);this.editor.model.change((e=>{e.setSelection(o.cells.map((t=>e.createRangeOn(t))),{backward:o.backward})}))}getFocusCell(){const e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){const e=this.editor.model.document.selection,t=a(e.getRanges()).getContainedElement();return t&&t.is("element","tableCell")?t:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add((e=>e.on("selection",((e,o,n)=>{const i=n.writer;!function(e){for(const o of t)e.removeClass("ck-editor__editable_selected",o);t.clear()}(i);const r=this.getSelectedTableCells();if(!r)return;for(const e of r){const o=n.mapper.toViewElement(e);i.addClass("ck-editor__editable_selected",o),t.add(o)}const l=n.mapper.toViewElement(r[r.length-1]);i.setSelection(l,0)}),{priority:"lowest"})))}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",(()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change((o=>{const n=o.createPositionAt(t[0],0),i=e.model.schema.getNearestSelectionRange(n);o.setSelection(i)}))}}))}_handleDeleteContent(e,t){const o=this.editor.plugins.get(Ze),n=t[0],i=t[1],r=this.editor.model,l=!i||"backward"==i.direction,s=o.getSelectedTableCells(n);s.length&&(e.stop(),r.change((e=>{const t=s[l?s.length-1:0];r.change((e=>{for(const t of s)r.deleteContent(e.createSelection(t,"in"))}));const o=r.schema.getNearestSelectionRange(e.createPositionAt(t,0));n.is("documentSelection")?e.setSelection(o):n.setTo(o)})))}_handleInsertTextEvent(e,t){const o=this.editor,n=this.getSelectedTableCells();if(!n)return;const i=o.editing.view,r=o.editing.mapper,l=n.map((e=>i.createRangeOn(r.toViewElement(e))));t.selection=i.createSelection(l)}_getCellsToSelect(e,t){const o=this.editor.plugins.get("TableUtils"),n=o.getCellLocation(e),i=o.getCellLocation(t),r=Math.min(n.row,i.row),l=Math.max(n.row,i.row),s=Math.min(n.column,i.column),a=Math.max(n.column,i.column),c=new Array(l-r+1).fill(null).map((()=>[])),d={startRow:r,endRow:l,startColumn:s,endColumn:a};for(const{row:t,cell:o}of new he(e.findAncestor("table"),d))c[t-r].push(o);const u=i.row<n.row,h=i.column<n.column;return u&&c.reverse(),h&&c.forEach((e=>e.reverse())),{cells:c.flat(),backward:u||h}}} +class Tt extends t{static get pluginName(){return"TableSelection"}static get requires(){return[Qe,Qe]}init(){const e=this.editor,t=e.model,o=e.editing.view;this.listenTo(t,"deleteContent",((e,t)=>this._handleDeleteContent(e,t)),{priority:"high"}),this.listenTo(o.document,"insertText",((e,t)=>this._handleInsertTextEvent(e,t)),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(Qe),t=this.editor.model.document.selection,o=e.getSelectedTableCells(t);return 0==o.length?null:o}getSelectionAsFragment(){const e=this.editor.plugins.get(Qe),t=this.getSelectedTableCells();return t?this.editor.model.change((o=>{const n=o.createDocumentFragment(),{first:i,last:r}=e.getColumnIndexes(t),{first:l,last:s}=e.getRowIndexes(t),a=t[0].findAncestor("table");let c=s,d=r;if(e.isSelectionRectangular(t)){const e={firstColumn:i,lastColumn:r,firstRow:l,lastRow:s};c=Ee(a,e),d=Pe(a,e)}const u=ve(a,{startRow:l,startColumn:i,endRow:c,endColumn:d},o);return o.insert(u,n,0),n})):null}setCellSelection(e,t){const o=this._getCellsToSelect(e,t);this.editor.model.change((e=>{e.setSelection(o.cells.map((t=>e.createRangeOn(t))),{backward:o.backward})}))}getFocusCell(){const e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){const e=this.editor.model.document.selection,t=a(e.getRanges()).getContainedElement();return t&&t.is("element","tableCell")?t:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add((e=>e.on("selection",((e,o,n)=>{const i=n.writer;!function(e){for(const o of t)e.removeClass("ck-editor__editable_selected",o);t.clear()}(i);const r=this.getSelectedTableCells();if(!r)return;for(const e of r){const o=n.mapper.toViewElement(e);i.addClass("ck-editor__editable_selected",o),t.add(o)}const l=n.mapper.toViewElement(r[r.length-1]);i.setSelection(l,0)}),{priority:"lowest"})))}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",(()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change((o=>{const n=o.createPositionAt(t[0],0),i=e.model.schema.getNearestSelectionRange(n);o.setSelection(i)}))}}))}_handleDeleteContent(e,t){const o=this.editor.plugins.get(Qe),n=t[0],i=t[1],r=this.editor.model,l=!i||"backward"==i.direction,s=o.getSelectedTableCells(n);s.length&&(e.stop(),r.change((e=>{const t=s[l?s.length-1:0];r.change((e=>{for(const t of s)r.deleteContent(e.createSelection(t,"in"))}));const o=r.schema.getNearestSelectionRange(e.createPositionAt(t,0));n.is("documentSelection")?e.setSelection(o):n.setTo(o)})))}_handleInsertTextEvent(e,t){const o=this.editor,n=this.getSelectedTableCells();if(!n)return;const i=o.editing.view,r=o.editing.mapper,l=n.map((e=>i.createRangeOn(r.toViewElement(e))));t.selection=i.createSelection(l)}_getCellsToSelect(e,t){const o=this.editor.plugins.get("TableUtils"),n=o.getCellLocation(e),i=o.getCellLocation(t),r=Math.min(n.row,i.row),l=Math.max(n.row,i.row),s=Math.min(n.column,i.column),a=Math.max(n.column,i.column),c=new Array(l-r+1).fill(null).map((()=>[])),d={startRow:r,endRow:l,startColumn:s,endColumn:a};for(const{row:t,cell:o}of new he(e.findAncestor("table"),d))c[t-r].push(o);const u=i.row<n.row,h=i.column<n.column;return u&&c.reverse(),h&&c.forEach((e=>e.reverse())),{cells:c.flat(),backward:u||h}}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class St extends t{static get pluginName(){return"TableClipboard"}static get requires(){return[xt,Ze]}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"copy",((e,t)=>this._onCopyCut(e,t))),this.listenTo(t,"cut",((e,t)=>this._onCopyCut(e,t))),this.listenTo(e.model,"insertContent",((e,[t,o])=>this._onInsertContent(e,t,o)),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const o=this.editor.plugins.get(xt);if(!o.getSelectedTableCells())return;if("cut"==e.name&&!this.editor.model.canEditAt(this.editor.model.document.selection))return;t.preventDefault(),e.stop();const n=this.editor.data,i=this.editor.editing.view.document,r=n.toView(o.getSelectionAsFragment());i.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:r,method:e.name})}_onInsertContent(e,t,o){if(o&&!o.is("documentSelection"))return;const n=this.editor.model,i=this.editor.plugins.get(Ze);let r=this.getTableIfOnlyTableInContent(t,n);if(!r)return;const l=i.getSelectionAffectedTableCells(n.document.selection);l.length?(e.stop(),n.change((e=>{const t={width:i.getColumns(r),height:i.getRows(r)},o=function(e,t,o,n){const i=e[0].findAncestor("table"),r=n.getColumnIndexes(e),l=n.getRowIndexes(e),s={firstColumn:r.first,lastColumn:r.last,firstRow:l.first,lastRow:l.last},a=1===e.length;a&&(s.lastRow+=t.height-1,s.lastColumn+=t.width-1,function(e,t,o,n){const i=n.getColumns(e),r=n.getRows(e);o>i&&n.insertColumns(e,{at:i,columns:o-i});t>r&&n.insertRows(e,{at:r,rows:t-r})}(i,s.lastRow+1,s.lastColumn+1,n));a||!n.isSelectionRectangular(e)?function(e,t,o){const{firstRow:n,lastRow:i,firstColumn:r,lastColumn:l}=t,s={first:n,last:i},a={first:r,last:l};Rt(e,r,s,o),Rt(e,l+1,s,o),Vt(e,n,a,o),Vt(e,i+1,a,o,n)}(i,s,o):(s.lastRow=Ee(i,s),s.lastColumn=Pe(i,s));return s}(l,t,e,i),n=o.lastRow-o.firstRow+1,s=o.lastColumn-o.firstColumn+1,a={startRow:0,startColumn:0,endRow:Math.min(n,t.height)-1,endColumn:Math.min(s,t.width)-1};r=ve(r,a,e);const c=l[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(r,t,c,o,e);if(this.editor.plugins.get("TableSelection").isEnabled){const t=i.sortRanges(d.map((t=>e.createRangeOn(t))));e.setSelection(t)}else e.setSelection(d[0],0)}))):Ie(r,i)}_replaceSelectedCellsWithPasted(e,t,o,n,i){const{width:r,height:l}=t,s=function(e,t,o){const n=new Array(o).fill(null).map((()=>new Array(t).fill(null)));for(const{column:t,row:o,cell:i}of new he(e))n[o][t]=i;return n}(e,r,l),a=[...new he(o,{startRow:n.firstRow,endRow:n.lastRow,startColumn:n.firstColumn,endColumn:n.lastColumn,includeAllSlots:!0})],c=[];let d;for(const e of a){const{row:t,column:o}=e;o===n.firstColumn&&(d=e.getPositionBefore());const a=t-n.firstRow,u=o-n.firstColumn,h=s[a%l][u%r],b=h?i.cloneElement(h):null,m=this._replaceTableSlotCell(e,b,d,i);m&&(Se(m,t,o,n.lastRow,n.lastColumn,i),c.push(m),d=i.createPositionAfter(m))}const u=parseInt(o.getAttribute("headingRows")||"0"),h=parseInt(o.getAttribute("headingColumns")||"0"),b=n.firstRow<u&&u<=n.lastRow,m=n.firstColumn<h&&h<=n.lastColumn;if(b){const e=Vt(o,u,{first:n.firstColumn,last:n.lastColumn},i,n.firstRow);c.push(...e)}if(m){const e=Rt(o,h,{first:n.firstRow,last:n.lastRow},i);c.push(...e)}return c}_replaceTableSlotCell(e,t,o,n){const{cell:i,isAnchor:r}=e;return r&&n.remove(i),t?(n.insert(t,o),t):null}getTableIfOnlyTableInContent(e,t){if(!e.is("documentFragment")&&!e.is("element"))return null;if(e.is("element","table"))return e;if(1==e.childCount&&e.getChild(0).is("element","table"))return e.getChild(0);const o=t.createRangeIn(e);for(const e of o.getItems())if(e.is("element","table")){const n=t.createRange(o.start,t.createPositionBefore(e));if(t.hasContent(n,{ignoreWhitespaces:!0}))return null;const i=t.createRange(t.createPositionAfter(e),o.end);return t.hasContent(i,{ignoreWhitespaces:!0})?null:e}return null}}function Vt(e,t,o,n,i=0){if(t<1)return;return ye(e,t,i).filter((({column:e,cellWidth:t})=>It(e,t,o))).map((({cell:e})=>Ae(e,t,n)))}function Rt(e,t,o,n){if(t<1)return;return Te(e,t).filter((({row:e,cellHeight:t})=>It(e,t,o))).map((({cell:e,column:o})=>xe(e,o,t,n)))}function It(e,t,o){const n=e+t-1,{first:i,last:r}=o;return e>=i&&e<=r||e<i&&n>=i} + */class xt extends t{static get pluginName(){return"TableClipboard"}static get requires(){return[Tt,Qe]}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"copy",((e,t)=>this._onCopyCut(e,t))),this.listenTo(t,"cut",((e,t)=>this._onCopyCut(e,t))),this.listenTo(e.model,"insertContent",((e,[t,o])=>this._onInsertContent(e,t,o)),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const o=this.editor.plugins.get(Tt);if(!o.getSelectedTableCells())return;if("cut"==e.name&&!this.editor.model.canEditAt(this.editor.model.document.selection))return;t.preventDefault(),e.stop();const n=this.editor.data,i=this.editor.editing.view.document,r=n.toView(o.getSelectionAsFragment());i.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:r,method:e.name})}_onInsertContent(e,t,o){if(o&&!o.is("documentSelection"))return;const n=this.editor.model,i=this.editor.plugins.get(Qe);let r=this.getTableIfOnlyTableInContent(t,n);if(!r)return;const l=i.getSelectionAffectedTableCells(n.document.selection);l.length?(e.stop(),n.change((e=>{const t={width:i.getColumns(r),height:i.getRows(r)},o=function(e,t,o,n){const i=e[0].findAncestor("table"),r=n.getColumnIndexes(e),l=n.getRowIndexes(e),s={firstColumn:r.first,lastColumn:r.last,firstRow:l.first,lastRow:l.last},a=1===e.length;a&&(s.lastRow+=t.height-1,s.lastColumn+=t.width-1,function(e,t,o,n){const i=n.getColumns(e),r=n.getRows(e);o>i&&n.insertColumns(e,{at:i,columns:o-i});t>r&&n.insertRows(e,{at:r,rows:t-r})}(i,s.lastRow+1,s.lastColumn+1,n));a||!n.isSelectionRectangular(e)?function(e,t,o){const{firstRow:n,lastRow:i,firstColumn:r,lastColumn:l}=t,s={first:n,last:i},a={first:r,last:l};Vt(e,r,s,o),Vt(e,l+1,s,o),St(e,n,a,o),St(e,i+1,a,o,n)}(i,s,o):(s.lastRow=Ee(i,s),s.lastColumn=Pe(i,s));return s}(l,t,e,i),n=o.lastRow-o.firstRow+1,s=o.lastColumn-o.firstColumn+1,a={startRow:0,startColumn:0,endRow:Math.min(n,t.height)-1,endColumn:Math.min(s,t.width)-1};r=ve(r,a,e);const c=l[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(r,t,c,o,e);if(this.editor.plugins.get("TableSelection").isEnabled){const t=i.sortRanges(d.map((t=>e.createRangeOn(t))));e.setSelection(t)}else e.setSelection(d[0],0)}))):Ie(r,i)}_replaceSelectedCellsWithPasted(e,t,o,n,i){const{width:r,height:l}=t,s=function(e,t,o){const n=new Array(o).fill(null).map((()=>new Array(t).fill(null)));for(const{column:t,row:o,cell:i}of new he(e))n[o][t]=i;return n}(e,r,l),a=[...new he(o,{startRow:n.firstRow,endRow:n.lastRow,startColumn:n.firstColumn,endColumn:n.lastColumn,includeAllSlots:!0})],c=[];let d;for(const e of a){const{row:t,column:o}=e;o===n.firstColumn&&(d=e.getPositionBefore());const a=t-n.firstRow,u=o-n.firstColumn,h=s[a%l][u%r],b=h?i.cloneElement(h):null,m=this._replaceTableSlotCell(e,b,d,i);m&&(Se(m,t,o,n.lastRow,n.lastColumn,i),c.push(m),d=i.createPositionAfter(m))}const u=parseInt(o.getAttribute("headingRows")||"0"),h=parseInt(o.getAttribute("headingColumns")||"0"),b=n.firstRow<u&&u<=n.lastRow,m=n.firstColumn<h&&h<=n.lastColumn;if(b){const e=St(o,u,{first:n.firstColumn,last:n.lastColumn},i,n.firstRow);c.push(...e)}if(m){const e=Vt(o,h,{first:n.firstRow,last:n.lastRow},i);c.push(...e)}return c}_replaceTableSlotCell(e,t,o,n){const{cell:i,isAnchor:r}=e;return r&&n.remove(i),t?(n.insert(t,o),t):null}getTableIfOnlyTableInContent(e,t){if(!e.is("documentFragment")&&!e.is("element"))return null;if(e.is("element","table"))return e;if(1==e.childCount&&e.getChild(0).is("element","table"))return e.getChild(0);const o=t.createRangeIn(e);for(const e of o.getItems())if(e.is("element","table")){const n=t.createRange(o.start,t.createPositionBefore(e));if(t.hasContent(n,{ignoreWhitespaces:!0}))return null;const i=t.createRange(t.createPositionAfter(e),o.end);return t.hasContent(i,{ignoreWhitespaces:!0})?null:e}return null}}function St(e,t,o,n,i=0){if(t<1)return;return ye(e,t,i).filter((({column:e,cellWidth:t})=>Rt(e,t,o))).map((({cell:e})=>Ae(e,t,n)))}function Vt(e,t,o,n){if(t<1)return;return Te(e,t).filter((({row:e,cellHeight:t})=>Rt(e,t,o))).map((({cell:e,column:o})=>xe(e,o,t,n)))}function Rt(e,t,o){const n=e+t-1,{first:i,last:r}=o;return e>=i&&e<=r||e<i&&n>=i} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Et extends t{static get pluginName(){return"TableKeyboard"}static get requires(){return[xt,Ze]}init(){const e=this.editor.editing.view.document;this.listenTo(e,"arrowKey",((...e)=>this._onArrowKey(...e)),{context:"table"}),this.listenTo(e,"tab",((...e)=>this._handleTabOnSelectedTable(...e)),{context:"figure"}),this.listenTo(e,"tab",((...e)=>this._handleTab(...e)),{context:["th","td"]})}_handleTabOnSelectedTable(e,t){const o=this.editor,n=o.model.document.selection.getSelectedElement();n&&n.is("element","table")&&(t.preventDefault(),t.stopPropagation(),e.stop(),o.model.change((e=>{e.setSelection(e.createRangeIn(n.getChild(0).getChild(0)))})))}_handleTab(e,t){const o=this.editor,n=this.editor.plugins.get(Ze),i=this.editor.plugins.get("TableSelection"),r=o.model.document.selection,l=!t.shiftKey;let s=n.getTableCellsContainingSelection(r)[0];if(s||(s=i.getFocusCell()),!s)return;t.preventDefault(),t.stopPropagation(),e.stop();const a=s.parent,c=a.parent,d=c.getChildIndex(a),u=a.getChildIndex(s),h=0===u;if(!l&&h&&0===d)return void o.model.change((e=>{e.setSelection(e.createRangeOn(c))}));const b=u===a.childCount-1,m=d===n.getRows(c)-1;if(l&&m&&b&&(o.execute("insertTableRowBelow"),d===n.getRows(c)-1))return void o.model.change((e=>{e.setSelection(e.createRangeOn(c))}));let g;if(l&&b){const e=c.getChild(d+1);g=e.getChild(0)}else if(!l&&h){const e=c.getChild(d-1);g=e.getChild(e.childCount-1)}else g=a.getChild(u+(l?1:-1));o.model.change((e=>{e.setSelection(e.createRangeIn(g))}))}_onArrowKey(e,t){const o=this.editor,n=t.keyCode,i=m(n,o.locale.contentLanguageDirection);this._handleArrowKeys(i,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const o=this.editor.plugins.get(Ze),n=this.editor.plugins.get("TableSelection"),i=this.editor.model,r=i.document.selection,l=["right","down"].includes(e),s=o.getSelectedTableCells(r);if(s.length){let o;return o=t?n.getFocusCell():l?s[s.length-1]:s[0],this._navigateFromCellInDirection(o,e,t),!0}const a=r.focus.findAncestor("tableCell"); + */class It extends t{static get pluginName(){return"TableKeyboard"}static get requires(){return[Tt,Qe]}init(){const e=this.editor.editing.view.document;this.listenTo(e,"arrowKey",((...e)=>this._onArrowKey(...e)),{context:"table"}),this.listenTo(e,"tab",((...e)=>this._handleTabOnSelectedTable(...e)),{context:"figure"}),this.listenTo(e,"tab",((...e)=>this._handleTab(...e)),{context:["th","td"]})}_handleTabOnSelectedTable(e,t){const o=this.editor,n=o.model.document.selection.getSelectedElement();n&&n.is("element","table")&&(t.preventDefault(),t.stopPropagation(),e.stop(),o.model.change((e=>{e.setSelection(e.createRangeIn(n.getChild(0).getChild(0)))})))}_handleTab(e,t){const o=this.editor,n=this.editor.plugins.get(Qe),i=this.editor.plugins.get("TableSelection"),r=o.model.document.selection,l=!t.shiftKey;let s=n.getTableCellsContainingSelection(r)[0];if(s||(s=i.getFocusCell()),!s)return;t.preventDefault(),t.stopPropagation(),e.stop();const a=s.parent,c=a.parent,d=c.getChildIndex(a),u=a.getChildIndex(s),h=0===u;if(!l&&h&&0===d)return void o.model.change((e=>{e.setSelection(e.createRangeOn(c))}));const b=u===a.childCount-1,m=d===n.getRows(c)-1;if(l&&m&&b&&(o.execute("insertTableRowBelow"),d===n.getRows(c)-1))return void o.model.change((e=>{e.setSelection(e.createRangeOn(c))}));let g;if(l&&b){const e=c.getChild(d+1);g=e.getChild(0)}else if(!l&&h){const e=c.getChild(d-1);g=e.getChild(e.childCount-1)}else g=a.getChild(u+(l?1:-1));o.model.change((e=>{e.setSelection(e.createRangeIn(g))}))}_onArrowKey(e,t){const o=this.editor,n=t.keyCode,i=m(n,o.locale.contentLanguageDirection);this._handleArrowKeys(i,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const o=this.editor.plugins.get(Qe),n=this.editor.plugins.get("TableSelection"),i=this.editor.model,r=i.document.selection,l=["right","down"].includes(e),s=o.getSelectedTableCells(r);if(s.length){let o;return o=t?n.getFocusCell():l?s[s.length-1]:s[0],this._navigateFromCellInDirection(o,e,t),!0}const a=r.focus.findAncestor("tableCell"); /* istanbul ignore if: paranoid check -- @preserve */if(!a)return!1;if(!r.isCollapsed)if(t){if(r.isBackward==l&&!r.containsEntireContent(a))return!1}else{const e=r.getSelectedElement();if(!e||!i.schema.isObject(e))return!1}return!!this._isSelectionAtCellEdge(r,a,l)&&(this._navigateFromCellInDirection(a,e,t),!0)}_isSelectionAtCellEdge(e,t,o){const n=this.editor.model,i=this.editor.model.schema,r=o?e.getLastPosition():e.getFirstPosition();if(!i.getLimitElement(r).is("element","tableCell")){return n.createPositionAt(t,o?"end":0).isTouching(r)}const l=n.createSelection(r);return n.modifySelection(l,{direction:o?"forward":"backward"}),r.isEqual(l.focus)}_navigateFromCellInDirection(e,t,o=!1){const n=this.editor.model,i=e.findAncestor("table"),r=[...new he(i,{includeAllSlots:!0})],{row:l,column:s}=r[r.length-1],a=r.find((({cell:t})=>t==e));let{row:c,column:d}=a;switch(t){case"left":d--;break;case"up":c--;break;case"right":d+=a.cellWidth;break;case"down":c+=a.cellHeight}if(c<0||c>l||d<0&&c<=0||d>s&&c>=l)return void n.change((e=>{e.setSelection(e.createRangeOn(i))}));d<0?(d=o?0:s,c--):d>s&&(d=o?s:0,c++);const u=r.find((e=>e.row==c&&e.column==d)).cell,h=["right","down"].includes(t),b=this.editor.plugins.get("TableSelection");if(o&&b.isEnabled){const t=b.getAnchorCell()||e;b.setCellSelection(t,u)}else{const e=n.createPositionAt(u,h?0:"end");n.change((t=>{t.setSelection(e)}))}}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Pt extends M{constructor(){super(...arguments),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}} + */class Et extends M{constructor(){super(...arguments),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class zt extends t{static get pluginName(){return"TableMouse"}static get requires(){return[xt,Ze]}init(){this.editor.editing.view.addObserver(Pt),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(Ze);let o=!1;const n=e.plugins.get(xt);this.listenTo(e.editing.view.document,"mousedown",((i,r)=>{const l=e.model.document.selection;if(!this.isEnabled||!n.isEnabled)return;if(!r.domEvent.shiftKey)return;const s=n.getAnchorCell()||t.getTableCellsContainingSelection(l)[0];if(!s)return;const a=this._getModelTableCellFromDomEvent(r);a&&Bt(s,a)&&(o=!0,n.setCellSelection(s,a),r.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{o=!1})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{o&&e.stop()}),{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,o,n=!1,i=!1;const r=e.plugins.get(xt);this.listenTo(e.editing.view.document,"mousedown",((e,o)=>{this.isEnabled&&r.isEnabled&&(o.domEvent.shiftKey||o.domEvent.ctrlKey||o.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(o)))})),this.listenTo(e.editing.view.document,"mousemove",((e,l)=>{if(!l.domEvent.buttons)return;if(!t)return;const s=this._getModelTableCellFromDomEvent(l);s&&Bt(t,s)&&(o=s,n||o==t||(n=!0)),n&&(i=!0,r.setCellSelection(t,o),l.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{n=!1,i=!1,t=null,o=null})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{i&&e.stop()}),{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,o=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(o).parent.findAncestor("tableCell",{includeSelf:!0})}}function Bt(e,t){return e.parent.parent==t.parent.parent}_t(".ck-content .table{display:table;margin:.9em auto}.ck-content .table table{border:1px double #b3b3b3;border-collapse:collapse;border-spacing:0;height:100%;width:100%}.ck-content .table table td,.ck-content .table table th{border:1px solid #bfbfbf;min-width:2em;padding:.4em}.ck-content .table table th{background:rgba(0,0,0,.05);font-weight:700}.ck-content[dir=rtl] .table th{text-align:right}.ck-content[dir=ltr] .table th{text-align:left}.ck-editor__editable .ck-table-bogus-paragraph{display:inline-block;width:100%}"); + */class Pt extends t{static get pluginName(){return"TableMouse"}static get requires(){return[Tt,Qe]}init(){this.editor.editing.view.addObserver(Et),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(Qe);let o=!1;const n=e.plugins.get(Tt);this.listenTo(e.editing.view.document,"mousedown",((i,r)=>{const l=e.model.document.selection;if(!this.isEnabled||!n.isEnabled)return;if(!r.domEvent.shiftKey)return;const s=n.getAnchorCell()||t.getTableCellsContainingSelection(l)[0];if(!s)return;const a=this._getModelTableCellFromDomEvent(r);a&&zt(s,a)&&(o=!0,n.setCellSelection(s,a),r.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{o=!1})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{o&&e.stop()}),{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,o,n=!1,i=!1;const r=e.plugins.get(Tt);this.listenTo(e.editing.view.document,"mousedown",((e,o)=>{this.isEnabled&&r.isEnabled&&(o.domEvent.shiftKey||o.domEvent.ctrlKey||o.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(o)))})),this.listenTo(e.editing.view.document,"mousemove",((e,l)=>{if(!l.domEvent.buttons)return;if(!t)return;const s=this._getModelTableCellFromDomEvent(l);s&&zt(t,s)&&(o=s,n||o==t||(n=!0)),n&&(i=!0,r.setCellSelection(t,o),l.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{n=!1,i=!1,t=null,o=null})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{i&&e.stop()}),{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,o=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(o).parent.findAncestor("tableCell",{includeSelf:!0})}}function zt(e,t){return e.parent.parent==t.parent.parent}kt(".ck-content .table{display:table;margin:.9em auto}.ck-content .table table{border:1px double #b3b3b3;border-collapse:collapse;border-spacing:0;height:100%;width:100%}.ck-content .table table td,.ck-content .table table th{border:1px solid #bfbfbf;min-width:2em;padding:.4em}.ck-content .table table th{background:rgba(0,0,0,.05);font-weight:700}.ck-content[dir=rtl] .table th{text-align:right}.ck-content[dir=ltr] .table th{text-align:left}.ck-editor__editable .ck-table-bogus-paragraph{display:inline-block;width:100%}"); /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -class Wt extends t{static get requires(){return[Ct,At,xt,zt,Et,St,r]}static get pluginName(){return"Table"}} +class Bt extends t{static get requires(){return[_t,yt,Tt,Pt,It,xt,r]}static get pluginName(){return"Table"}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Nt extends t{static get pluginName(){return"PlainTableOutput"}static get requires(){return[Wt]}init(){const e=this.editor;e.conversion.for("dataDowncast").elementToStructure({model:"table",view:Lt,converterPriority:"high"}),e.plugins.has("TableCaption")&&e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>{if("table"===e.parent.name)return t.createContainerElement("caption")},converterPriority:"high"}),e.plugins.has("TableProperties")&&function(e){const t={"border-width":"tableBorderWidth","border-color":"tableBorderColor","border-style":"tableBorderStyle","background-color":"tableBackgroundColor"};for(const[o,n]of Object.entries(t))e.conversion.for("dataDowncast").add((e=>e.on(`attribute:${n}:table`,((e,t,n)=>{const{item:i,attributeNewValue:r}=t,{mapper:l,writer:s}=n;if(!n.consumable.consume(i,e.name))return;const a=l.toViewElement(i);r?s.setStyle(o,r,a):s.removeStyle(o,a)}),{priority:"high"})))} + */class Wt extends t{static get pluginName(){return"PlainTableOutput"}static get requires(){return[Bt]}init(){const e=this.editor;e.conversion.for("dataDowncast").elementToStructure({model:"table",view:Nt,converterPriority:"high"}),e.plugins.has("TableCaption")&&e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>{if("table"===e.parent.name)return t.createContainerElement("caption")},converterPriority:"high"}),e.plugins.has("TableProperties")&&function(e){const t={"border-width":"tableBorderWidth","border-color":"tableBorderColor","border-style":"tableBorderStyle","background-color":"tableBackgroundColor"};for(const[o,n]of Object.entries(t))e.conversion.for("dataDowncast").add((e=>e.on(`attribute:${n}:table`,((e,t,n)=>{const{item:i,attributeNewValue:r}=t,{mapper:l,writer:s}=n;if(!n.consumable.consume(i,e.name))return;const a=l.toViewElement(i);r?s.setStyle(o,r,a):s.removeStyle(o,a)}),{priority:"high"})))} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */(e)}}function Lt(e,{writer:t}){const o=e.getAttribute("headingRows")||0,n=t.createSlot((e=>e.is("element","tableRow")&&e.index<o)),i=t.createSlot((e=>e.is("element","tableRow")&&e.index>=o)),r=t.createSlot((e=>!e.is("element","tableRow"))),l=t.createContainerElement("thead",null,n),s=t.createContainerElement("tbody",null,i),a=[];return o&&a.push(l),o<e.childCount&&a.push(s),t.createContainerElement("table",null,[r,...a])}function Ft(e){const t=e.getSelectedElement();return t&&Dt(t)?t:null}function Ht(e){const t=e.getFirstPosition();if(!t)return null;let o=t.parent;for(;o;){if(o.is("element")&&Dt(o))return o;o=o.parent}return null}function Dt(e){return!!e.getCustomProperty("table")&&l(e)} + */(e)}}function Nt(e,{writer:t}){const o=e.getAttribute("headingRows")||0,n=t.createSlot((e=>e.is("element","tableRow")&&e.index<o)),i=t.createSlot((e=>e.is("element","tableRow")&&e.index>=o)),r=t.createSlot((e=>!e.is("element","tableRow"))),l=t.createContainerElement("thead",null,n),s=t.createContainerElement("tbody",null,i),a=[];return o&&a.push(l),o<e.childCount&&a.push(s),t.createContainerElement("table",null,[r,...a])}function Lt(e){const t=e.getSelectedElement();return t&&Ht(t)?t:null}function Ft(e){const t=e.getFirstPosition();if(!t)return null;let o=t.parent;for(;o;){if(o.is("element")&&Ht(o))return o;o=o.parent}return null}function Ht(e){return!!e.getCustomProperty("table")&&l(e)} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Mt extends t{static get requires(){return[s]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,o=e.plugins.get(s),n=e.config.get("table.contentToolbar"),i=e.config.get("table.tableToolbar");n&&o.register("tableContent",{ariaLabel:t("Table toolbar"),items:n,getRelatedElement:Ht}),i&&o.register("table",{ariaLabel:t("Table toolbar"),items:i,getRelatedElement:Ft})}}_t(".ck.ck-input-color{display:flex;flex-direction:row-reverse;width:100%}.ck.ck-input-color>input.ck.ck-input-text{flex-grow:1;min-width:auto}.ck.ck-input-color>div.ck.ck-dropdown{min-width:auto}.ck.ck-input-color>div.ck.ck-dropdown>.ck-input-color__button .ck-dropdown__arrow{display:none}.ck.ck-input-color .ck.ck-input-color__button{display:flex}.ck.ck-input-color .ck.ck-input-color__button .ck.ck-input-color__button__preview{overflow:hidden;position:relative}.ck.ck-input-color .ck.ck-input-color__button .ck.ck-input-color__button__preview>.ck.ck-input-color__button__preview__no-color-indicator{display:block;position:absolute}[dir=ltr] .ck.ck-input-color>.ck.ck-input-text{border-bottom-right-radius:0;border-top-right-radius:0}[dir=rtl] .ck.ck-input-color>.ck.ck-input-text{border-bottom-left-radius:0;border-top-left-radius:0}.ck.ck-input-color>.ck.ck-input-text:focus{z-index:0}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{padding:0}[dir=ltr] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{border-bottom-left-radius:0;border-top-left-radius:0}[dir=ltr] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button:not(:focus){border-left:1px solid transparent}[dir=rtl] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{border-bottom-right-radius:0;border-top-right-radius:0}[dir=rtl] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button:not(:focus){border-right:1px solid transparent}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button.ck-disabled{background:var(--ck-color-input-disabled-background)}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview{border-radius:0}.ck-rounded-corners .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview,.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview.ck-rounded-corners{border-radius:var(--ck-border-radius)}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview{border:1px solid var(--ck-color-input-border);height:20px;width:20px}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview>.ck.ck-input-color__button__preview__no-color-indicator{background:red;border-radius:2px;height:150%;left:50%;top:-30%;transform:rotate(45deg);transform-origin:50%;width:8%}.ck.ck-input-color .ck.ck-input-color__remove-color{border-bottom-left-radius:0;border-bottom-right-radius:0;padding:calc(var(--ck-spacing-standard)/2) var(--ck-spacing-standard);width:100%}.ck.ck-input-color .ck.ck-input-color__remove-color:not(:focus){border-bottom:1px solid var(--ck-color-input-border)}[dir=ltr] .ck.ck-input-color .ck.ck-input-color__remove-color{border-top-right-radius:0}[dir=rtl] .ck.ck-input-color .ck.ck-input-color__remove-color{border-top-left-radius:0}.ck.ck-input-color .ck.ck-input-color__remove-color .ck.ck-icon{margin-right:var(--ck-spacing-standard)}[dir=rtl] .ck.ck-input-color .ck.ck-input-color__remove-color .ck.ck-icon{margin-left:var(--ck-spacing-standard);margin-right:0}"); + */class Dt extends t{static get requires(){return[s]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,o=e.plugins.get(s),n=e.config.get("table.contentToolbar"),i=e.config.get("table.tableToolbar");n&&o.register("tableContent",{ariaLabel:t("Table toolbar"),items:n,getRelatedElement:Ft}),i&&o.register("table",{ariaLabel:t("Table toolbar"),items:i,getRelatedElement:Lt})}}kt(".ck.ck-input-color{display:flex;flex-direction:row-reverse;width:100%}.ck.ck-input-color>input.ck.ck-input-text{flex-grow:1;min-width:auto}.ck.ck-input-color>div.ck.ck-dropdown{min-width:auto}.ck.ck-input-color>div.ck.ck-dropdown>.ck-input-color__button .ck-dropdown__arrow{display:none}.ck.ck-input-color .ck.ck-input-color__button{display:flex}.ck.ck-input-color .ck.ck-input-color__button .ck.ck-input-color__button__preview{overflow:hidden;position:relative}.ck.ck-input-color .ck.ck-input-color__button .ck.ck-input-color__button__preview>.ck.ck-input-color__button__preview__no-color-indicator{display:block;position:absolute}[dir=ltr] .ck.ck-input-color>.ck.ck-input-text{border-bottom-right-radius:0;border-top-right-radius:0}[dir=rtl] .ck.ck-input-color>.ck.ck-input-text{border-bottom-left-radius:0;border-top-left-radius:0}.ck.ck-input-color>.ck.ck-input-text:focus{z-index:0}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{padding:0}[dir=ltr] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{border-bottom-left-radius:0;border-top-left-radius:0}[dir=ltr] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button:not(:focus){border-left:1px solid transparent}[dir=rtl] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{border-bottom-right-radius:0;border-top-right-radius:0}[dir=rtl] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button:not(:focus){border-right:1px solid transparent}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button.ck-disabled{background:var(--ck-color-input-disabled-background)}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview{border-radius:0}.ck-rounded-corners .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview,.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview.ck-rounded-corners{border-radius:var(--ck-border-radius)}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview{border:1px solid var(--ck-color-input-border);height:20px;width:20px}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview>.ck.ck-input-color__button__preview__no-color-indicator{background:red;border-radius:2px;height:150%;left:50%;top:-30%;transform:rotate(45deg);transform-origin:50%;width:8%}.ck.ck-input-color .ck.ck-input-color__remove-color{border-bottom-left-radius:0;border-bottom-right-radius:0;padding:calc(var(--ck-spacing-standard)/2) var(--ck-spacing-standard);width:100%}.ck.ck-input-color .ck.ck-input-color__remove-color:not(:focus){border-bottom:1px solid var(--ck-color-input-border)}[dir=ltr] .ck.ck-input-color .ck.ck-input-color__remove-color{border-top-right-radius:0}[dir=rtl] .ck.ck-input-color .ck.ck-input-color__remove-color{border-top-left-radius:0}.ck.ck-input-color .ck.ck-input-color__remove-color .ck.ck-icon{margin-right:var(--ck-spacing-standard)}[dir=rtl] .ck.ck-input-color .ck.ck-input-color__remove-color .ck.ck-icon{margin-left:var(--ck-spacing-standard);margin-right:0}"); /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -class Ot extends f{constructor(e,t){super(e),this.set("value",""),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.options=t,this.focusTracker=new h,this._focusables=new T,this.dropdownView=this._createDropdownView(),this.inputView=this._createInputTextView(),this.keystrokes=new u,this._stillTyping=!1,this.focusCycler=new x({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color"]},children:[this.dropdownView,this.inputView]}),this.on("change:value",((e,t,o)=>this._setInputValue(o)))}render(){super.render(),[this.inputView,this.dropdownView.buttonView].forEach((e=>{this.focusTracker.add(e.element),this._focusables.add(e)})),this.keystrokes.listenTo(this.element)}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createDropdownView(){const e=this.locale,t=e.t,o=this.bindTemplate,n=this._createColorSelector(e),i=_(e),r=new f;return r.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:o.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",o.if("value","ck-hidden",(e=>""!=e))]}}]}),i.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),i.buttonView.children.add(r),i.buttonView.label=t("Color picker"),i.buttonView.tooltip=!0,i.panelPosition="rtl"===e.uiLanguageDirection?"se":"sw",i.panelView.children.add(n),i.bind("isEnabled").to(this,"isReadOnly",(e=>!e)),i.on("change:isOpen",((e,t,o)=>{o&&(n.updateSelectedColors(),n.showColorGridsFragment())})),i}_createInputTextView(){const e=this.locale,t=new S(e);return t.extendTemplate({on:{blur:t.bindTemplate.to("blur")}}),t.value=this.value,t.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(t),t.on("input",(()=>{const e=t.element.value,o=this.options.colorDefinitions.find((t=>e===t.label));this._stillTyping=!0,this.value=o&&o.color||e})),t.on("blur",(()=>{this._stillTyping=!1,this._setInputValue(t.element.value)})),t.delegate("input").to(this),t}_createColorSelector(e){const t=e.t,o=this.options.defaultColorValue||"",n=t(o?"Restore default":"Remove color"),i=new V(e,{colors:this.options.colorDefinitions,columns:this.options.columns,removeButtonLabel:n,colorPickerLabel:t("Color picker"),colorPickerViewConfig:!1!==this.options.colorPickerConfig&&{...this.options.colorPickerConfig,hideInput:!0}});i.appendUI(),i.on("execute",((e,t)=>{"colorPickerSaveButton"!==t.source?(this.value=t.value||o,this.fire("input"),"colorPicker"!==t.source&&(this.dropdownView.isOpen=!1)):this.dropdownView.isOpen=!1}));let r=this.value;return i.on("colorPicker:cancel",(()=>{this.value=r,this.fire("input"),this.dropdownView.isOpen=!1})),i.colorGridsFragmentView.colorPickerButtonView.on("execute",(()=>{r=this.value})),i.bind("selectedColor").to(this,"value"),i}_setInputValue(e){if(!this._stillTyping){const t=Ut(e),o=this.options.colorDefinitions.find((e=>t===Ut(e.color)));this.inputView.value=o?o.label:e||""}}}function Ut(e){return e.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")} +class Mt extends f{constructor(e,t){super(e),this.set("value",""),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.options=t,this.focusTracker=new h,this._focusables=new T,this.dropdownView=this._createDropdownView(),this.inputView=this._createInputTextView(),this.keystrokes=new u,this._stillTyping=!1,this.focusCycler=new x({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color"]},children:[this.dropdownView,this.inputView]}),this.on("change:value",((e,t,o)=>this._setInputValue(o)))}render(){super.render(),[this.inputView,this.dropdownView.buttonView].forEach((e=>{this.focusTracker.add(e.element),this._focusables.add(e)})),this.keystrokes.listenTo(this.element)}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createDropdownView(){const e=this.locale,t=e.t,o=this.bindTemplate,n=this._createColorSelector(e),i=_(e),r=new f;return r.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:o.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",o.if("value","ck-hidden",(e=>""!=e))]}}]}),i.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),i.buttonView.children.add(r),i.buttonView.label=t("Color picker"),i.buttonView.tooltip=!0,i.panelPosition="rtl"===e.uiLanguageDirection?"se":"sw",i.panelView.children.add(n),i.bind("isEnabled").to(this,"isReadOnly",(e=>!e)),i.on("change:isOpen",((e,t,o)=>{o&&(n.updateSelectedColors(),n.showColorGridsFragment())})),i}_createInputTextView(){const e=this.locale,t=new S(e);return t.extendTemplate({on:{blur:t.bindTemplate.to("blur")}}),t.value=this.value,t.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(t),t.on("input",(()=>{const e=t.element.value,o=this.options.colorDefinitions.find((t=>e===t.label));this._stillTyping=!0,this.value=o&&o.color||e})),t.on("blur",(()=>{this._stillTyping=!1,this._setInputValue(t.element.value)})),t.delegate("input").to(this),t}_createColorSelector(e){const t=e.t,o=this.options.defaultColorValue||"",n=t(o?"Restore default":"Remove color"),i=new V(e,{colors:this.options.colorDefinitions,columns:this.options.columns,removeButtonLabel:n,colorPickerLabel:t("Color picker"),colorPickerViewConfig:!1!==this.options.colorPickerConfig&&{...this.options.colorPickerConfig,hideInput:!0}});i.appendUI(),i.on("execute",((e,t)=>{"colorPickerSaveButton"!==t.source?(this.value=t.value||o,this.fire("input"),"colorPicker"!==t.source&&(this.dropdownView.isOpen=!1)):this.dropdownView.isOpen=!1}));let r=this.value;return i.on("colorPicker:cancel",(()=>{this.value=r,this.fire("input"),this.dropdownView.isOpen=!1})),i.colorGridsFragmentView.colorPickerButtonView.on("execute",(()=>{r=this.value})),i.bind("selectedColor").to(this,"value"),i}_setInputValue(e){if(!this._stillTyping){const t=Ot(e),o=this.options.colorDefinitions.find((e=>t===Ot(e.color)));this.inputView.value=o?o.label:e||""}}}function Ot(e){return e.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */const $t=e=>""===e;function jt(e){return{none:e("None"),solid:e("Solid"),dotted:e("Dotted"),dashed:e("Dashed"),double:e("Double"),groove:e("Groove"),ridge:e("Ridge"),inset:e("Inset"),outset:e("Outset")}}function qt(e){return e('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function Gt(e){return e('The value is invalid. Try "10px" or "2em" or simply "2".')}function Kt(e){return e=e.trim().toLowerCase(),$t(e)||O(e)}function Jt(e){return e=e.trim(),$t(e)||to(e)||U(e)||$(e)}function Xt(e){return e=e.trim(),$t(e)||to(e)||U(e)}function Yt(e,t){const o=new b,n=jt(e.t);for(const i in n){const r={type:"button",model:new A({_borderStyleValue:i,label:n[i],role:"menuitemradio",withText:!0})};"none"===i?r.model.bind("isOn").to(e,"borderStyle",(e=>"none"===t?!e:e===i)):r.model.bind("isOn").to(e,"borderStyle",(e=>e===i)),o.add(r)}return o}function Qt(e){const{view:t,icons:o,toolbar:n,labels:i,propertyName:r,nameToValue:l,defaultValue:s}=e;for(const e in i){const a=new k(t.locale);a.set({label:i[e],icon:o[e],tooltip:i[e]});const c=l?l(e):e;a.bind("isOn").to(t,r,(e=>{let t=e;return""===e&&s&&(t=s),c===t})),a.on("execute",(()=>{t[r]=c})),n.items.add(a)}}const Zt=[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}];function eo(e){return(t,o,n)=>{const i=new Ot(t.locale,{colorDefinitions:(r=e.colorConfig,r.map((e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}})))),columns:e.columns,defaultColorValue:e.defaultColorValue,colorPickerConfig:e.colorPickerConfig});var r;return i.inputView.set({id:o,ariaDescribedById:n}),i.bind("isReadOnly").to(t,"isEnabled",(e=>!e)),i.bind("hasError").to(t,"errorText",(e=>!!e)),i.on("input",(()=>{t.errorText=null})),t.bind("isEmpty","isFocused").to(i),i}}function to(e){const t=parseFloat(e);return!Number.isNaN(t)&&e===String(t)}_t(".ck.ck-form__row{display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between}.ck.ck-form__row>:not(.ck-label){flex-grow:1}.ck.ck-form__row.ck-table-form__action-row .ck-button-cancel,.ck.ck-form__row.ck-table-form__action-row .ck-button-save{justify-content:center}.ck.ck-form__row{padding:var(--ck-spacing-standard) var(--ck-spacing-large) 0}[dir=ltr] .ck.ck-form__row>:not(.ck-label)+*{margin-left:var(--ck-spacing-large)}[dir=rtl] .ck.ck-form__row>:not(.ck-label)+*{margin-right:var(--ck-spacing-large)}.ck.ck-form__row>.ck-label{min-width:100%;width:100%}.ck.ck-form__row.ck-table-form__action-row{margin-top:var(--ck-spacing-large)}.ck.ck-form__row.ck-table-form__action-row .ck-button .ck-button__label{color:var(--ck-color-text)}"); + */const Ut=e=>""===e;function $t(e){return{none:e("None"),solid:e("Solid"),dotted:e("Dotted"),dashed:e("Dashed"),double:e("Double"),groove:e("Groove"),ridge:e("Ridge"),inset:e("Inset"),outset:e("Outset")}}function jt(e){return e('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function qt(e){return e('The value is invalid. Try "10px" or "2em" or simply "2".')}function Gt(e){return e=e.trim().toLowerCase(),Ut(e)||O(e)}function Kt(e){return e=e.trim(),Ut(e)||eo(e)||U(e)||$(e)}function Jt(e){return e=e.trim(),Ut(e)||eo(e)||U(e)}function Xt(e,t){const o=new b,n=$t(e.t);for(const i in n){const r={type:"button",model:new A({_borderStyleValue:i,label:n[i],role:"menuitemradio",withText:!0})};"none"===i?r.model.bind("isOn").to(e,"borderStyle",(e=>"none"===t?!e:e===i)):r.model.bind("isOn").to(e,"borderStyle",(e=>e===i)),o.add(r)}return o}function Yt(e){const{view:t,icons:o,toolbar:n,labels:i,propertyName:r,nameToValue:l,defaultValue:s}=e;for(const e in i){const a=new k(t.locale);a.set({label:i[e],icon:o[e],tooltip:i[e]});const c=l?l(e):e;a.bind("isOn").to(t,r,(e=>{let t=e;return""===e&&s&&(t=s),c===t})),a.on("execute",(()=>{t[r]=c})),n.items.add(a)}}const Qt=[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}];function Zt(e){return(t,o,n)=>{const i=new Mt(t.locale,{colorDefinitions:(r=e.colorConfig,r.map((e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}})))),columns:e.columns,defaultColorValue:e.defaultColorValue,colorPickerConfig:e.colorPickerConfig});var r;return i.inputView.set({id:o,ariaDescribedById:n}),i.bind("isReadOnly").to(t,"isEnabled",(e=>!e)),i.bind("hasError").to(t,"errorText",(e=>!!e)),i.on("input",(()=>{t.errorText=null})),t.bind("isEmpty","isFocused").to(i),i}}function eo(e){const t=parseFloat(e);return!Number.isNaN(t)&&e===String(t)}kt(".ck.ck-form__row{display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between}.ck.ck-form__row>:not(.ck-label){flex-grow:1}.ck.ck-form__row.ck-table-form__action-row .ck-button-cancel,.ck.ck-form__row.ck-table-form__action-row .ck-button-save{justify-content:center}.ck.ck-form__row{padding:var(--ck-spacing-standard) var(--ck-spacing-large) 0}[dir=ltr] .ck.ck-form__row>:not(.ck-label)+*{margin-left:var(--ck-spacing-large)}[dir=rtl] .ck.ck-form__row>:not(.ck-label)+*{margin-right:var(--ck-spacing-large)}.ck.ck-form__row>.ck-label{min-width:100%;width:100%}.ck.ck-form__row.ck-table-form__action-row{margin-top:var(--ck-spacing-large)}.ck.ck-form__row.ck-table-form__action-row .ck-button .ck-button__label{color:var(--ck-color-text)}"); /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -class oo extends f{constructor(e,t={}){super(e);const o=this.bindTemplate;this.set("class",t.class||null),this.children=this.createCollection(),t.children&&t.children.forEach((e=>this.children.add(e))),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",o.to("class")],role:o.to("_role"),"aria-labelledby":o.to("_ariaLabelledBy")},children:this.children})}}_t(".ck.ck-form{padding:0 0 var(--ck-spacing-large)}.ck.ck-form:focus{outline:none}.ck.ck-form .ck.ck-input-text{min-width:100%;width:0}.ck.ck-form .ck.ck-dropdown{min-width:100%}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button:not(:focus){border:1px solid var(--ck-color-base-border)}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button .ck-button__label{width:100%}");_t('.ck.ck-table-form .ck-form__row.ck-table-form__background-row,.ck.ck-table-form .ck-form__row.ck-table-form__border-row{flex-wrap:wrap}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row{align-items:center;flex-wrap:wrap}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-labeled-field-view{align-items:center;display:flex;flex-direction:column-reverse}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-labeled-field-view .ck.ck-dropdown,.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimension-operator{flex-grow:0}.ck.ck-table-form .ck.ck-labeled-field-view{position:relative}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{bottom:calc(var(--ck-table-properties-error-arrow-size)*-1);left:50%;position:absolute;transform:translate(-50%,100%);z-index:1}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status:after{content:"";left:50%;position:absolute;top:calc(var(--ck-table-properties-error-arrow-size)*-1);transform:translateX(-50%)}:root{--ck-table-properties-error-arrow-size:6px;--ck-table-properties-min-error-width:150px}.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-labeled-field-view>.ck-label{font-size:var(--ck-font-size-tiny);text-align:center}.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-table-form__border-style,.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-table-form__border-width{max-width:80px;min-width:80px;width:80px}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row{padding:0}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimensions-row__height,.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimensions-row__width{margin:0}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimension-operator{align-self:flex-end;display:inline-block;height:var(--ck-ui-component-min-height);line-height:var(--ck-ui-component-min-height);margin:0 var(--ck-spacing-small)}.ck.ck-table-form .ck.ck-labeled-field-view{padding-top:var(--ck-spacing-standard)}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{border-radius:0}.ck-rounded-corners .ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status,.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status.ck-rounded-corners{border-radius:var(--ck-border-radius)}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{background:var(--ck-color-base-error);color:var(--ck-color-base-background);min-width:var(--ck-table-properties-min-error-width);padding:var(--ck-spacing-small) var(--ck-spacing-medium);text-align:center}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status:after{border-color:transparent transparent var(--ck-color-base-error) transparent;border-style:solid;border-width:0 var(--ck-table-properties-error-arrow-size) var(--ck-table-properties-error-arrow-size) var(--ck-table-properties-error-arrow-size)}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{animation:ck-table-form-labeled-view-status-appear .15s ease both}.ck.ck-table-form .ck.ck-labeled-field-view .ck-input.ck-error:not(:focus)+.ck.ck-labeled-field-view__status{display:none}@keyframes ck-table-form-labeled-view-status-appear{0%{opacity:0}to{opacity:1}}');_t(".ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row{flex-wrap:wrap}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar:first-of-type{flex-grow:0.57}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar:last-of-type{flex-grow:0.43}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar .ck-button{flex-grow:1}.ck.ck-table-cell-properties-form{width:320px}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__padding-row{align-self:flex-end;padding:0;width:25%}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar{background:none;margin-top:var(--ck-spacing-standard)}"); +class to extends f{constructor(e,t={}){super(e);const o=this.bindTemplate;this.set("class",t.class||null),this.children=this.createCollection(),t.children&&t.children.forEach((e=>this.children.add(e))),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",o.to("class")],role:o.to("_role"),"aria-labelledby":o.to("_ariaLabelledBy")},children:this.children})}}kt(".ck.ck-form{padding:0 0 var(--ck-spacing-large)}.ck.ck-form:focus{outline:none}.ck.ck-form .ck.ck-input-text{min-width:100%;width:0}.ck.ck-form .ck.ck-dropdown{min-width:100%}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button:not(:focus){border:1px solid var(--ck-color-base-border)}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button .ck-button__label{width:100%}");kt('.ck.ck-table-form .ck-form__row.ck-table-form__background-row,.ck.ck-table-form .ck-form__row.ck-table-form__border-row{flex-wrap:wrap}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row{align-items:center;flex-wrap:wrap}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-labeled-field-view{align-items:center;display:flex;flex-direction:column-reverse}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-labeled-field-view .ck.ck-dropdown,.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimension-operator{flex-grow:0}.ck.ck-table-form .ck.ck-labeled-field-view{position:relative}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{bottom:calc(var(--ck-table-properties-error-arrow-size)*-1);left:50%;position:absolute;transform:translate(-50%,100%);z-index:1}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status:after{content:"";left:50%;position:absolute;top:calc(var(--ck-table-properties-error-arrow-size)*-1);transform:translateX(-50%)}:root{--ck-table-properties-error-arrow-size:6px;--ck-table-properties-min-error-width:150px}.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-labeled-field-view>.ck-label{font-size:var(--ck-font-size-tiny);text-align:center}.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-table-form__border-style,.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-table-form__border-width{max-width:80px;min-width:80px;width:80px}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row{padding:0}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimensions-row__height,.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimensions-row__width{margin:0}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimension-operator{align-self:flex-end;display:inline-block;height:var(--ck-ui-component-min-height);line-height:var(--ck-ui-component-min-height);margin:0 var(--ck-spacing-small)}.ck.ck-table-form .ck.ck-labeled-field-view{padding-top:var(--ck-spacing-standard)}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{border-radius:0}.ck-rounded-corners .ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status,.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status.ck-rounded-corners{border-radius:var(--ck-border-radius)}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{background:var(--ck-color-base-error);color:var(--ck-color-base-background);min-width:var(--ck-table-properties-min-error-width);padding:var(--ck-spacing-small) var(--ck-spacing-medium);text-align:center}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status:after{border-color:transparent transparent var(--ck-color-base-error) transparent;border-style:solid;border-width:0 var(--ck-table-properties-error-arrow-size) var(--ck-table-properties-error-arrow-size) var(--ck-table-properties-error-arrow-size)}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{animation:ck-table-form-labeled-view-status-appear .15s ease both}.ck.ck-table-form .ck.ck-labeled-field-view .ck-input.ck-error:not(:focus)+.ck.ck-labeled-field-view__status{display:none}@keyframes ck-table-form-labeled-view-status-appear{0%{opacity:0}to{opacity:1}}');kt(".ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row{flex-wrap:wrap}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar:first-of-type{flex-grow:0.57}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar:last-of-type{flex-grow:0.43}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar .ck-button{flex-grow:1}.ck.ck-table-cell-properties-form{width:320px}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__padding-row{align-self:flex-end;padding:0;width:25%}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar{background:none;margin-top:var(--ck-spacing-standard)}"); /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -const no={left:o.alignLeft,center:o.alignCenter,right:o.alignRight,justify:o.alignJustify,top:o.alignTop,middle:o.alignMiddle,bottom:o.alignBottom};class io extends f{constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=t;const{borderStyleDropdown:o,borderWidthInput:n,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:l,backgroundInput:s}=this._createBackgroundFields(),{widthInput:a,operatorLabel:c,heightInput:d,dimensionsLabel:b}=this._createDimensionFields(),{horizontalAlignmentToolbar:m,verticalAlignmentToolbar:g,alignmentLabel:p}=this._createAlignmentFields();this.focusTracker=new h,this.keystrokes=new u,this.children=this.createCollection(),this.borderStyleDropdown=o,this.borderWidthInput=n,this.borderColorInput=i,this.backgroundInput=s,this.paddingInput=this._createPaddingField(),this.widthInput=a,this.heightInput=d,this.horizontalAlignmentToolbar=m,this.verticalAlignmentToolbar=g;const{saveButtonView:f,cancelButtonView:w}=this._createActionButtons();this.saveButtonView=f,this.cancelButtonView=w,this._focusables=new T,this._focusCycler=new x({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new R(e,{label:this.t("Cell properties")})),this.children.add(new oo(e,{labelView:r,children:[r,o,i,n],class:"ck-table-form__border-row"})),this.children.add(new oo(e,{labelView:l,children:[l,s],class:"ck-table-form__background-row"})),this.children.add(new oo(e,{children:[new oo(e,{labelView:b,children:[b,a,c,d],class:"ck-table-form__dimensions-row"}),new oo(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new oo(e,{labelView:p,children:[p,m,g],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new oo(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),I({view:this}),[this.borderColorInput,this.backgroundInput].forEach((e=>{e.fieldView.focusCycler.on("forwardCycle",(e=>{this._focusCycler.focusNext(),e.stop()})),e.fieldView.focusCycler.on("backwardCycle",(e=>{this._focusCycler.focusPrevious(),e.stop()}))})),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableCellProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},o=eo({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,i=this.t,r=i("Style"),l=new E(n);l.text=i("Border");const s=jt(i),a=new P(n,z);a.set({label:r,class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",(e=>s[e||"none"])),a.fieldView.on("execute",(e=>{this.borderStyle=e.source._borderStyleValue})),a.bind("isEmpty").to(this,"borderStyle",(e=>!e)),y(a.fieldView,Yt(this,t.style),{role:"menu",ariaLabel:r});const c=new P(n,B);c.set({label:i("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",ro),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const d=new P(n,o);return d.set({label:i("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",ro),d.fieldView.on("input",(()=>{this.borderColor=d.fieldView.value})),this.on("change:borderStyle",((e,o,n,i)=>{ro(n)||(this.borderColor="",this.borderWidth=""),ro(i)||(this.borderColor=t.color,this.borderWidth=t.width)})),{borderRowLabel:l,borderStyleDropdown:a,borderColorInput:d,borderWidthInput:c}}_createBackgroundFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Background");const n=eo({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),i=new P(e,n);return i.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",(()=>{this.backgroundColor=i.fieldView.value})),{backgroundRowLabel:o,backgroundInput:i}}_createDimensionFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Dimensions");const n=new P(e,B);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",(()=>{this.width=n.fieldView.element.value}));const i=new f(e);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new P(e,B);return r.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",(()=>{this.height=r.fieldView.element.value})),{dimensionsLabel:o,widthInput:n,operatorLabel:i,heightInput:r}}_createPaddingField(){const e=this.locale,t=this.t,o=new P(e,B);return o.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),o.fieldView.bind("value").to(this,"padding"),o.fieldView.on("input",(()=>{this.padding=o.fieldView.element.value})),o}_createAlignmentFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Table cell text alignment");const n=new W(e),i="rtl"===e.contentLanguageDirection;n.set({isCompact:!0,ariaLabel:t("Horizontal text alignment toolbar")}),Qt({view:this,icons:no,toolbar:n,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:e=>{if(i){if("left"===e)return"right";if("right"===e)return"left"}return e},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const r=new W(e);return r.set({isCompact:!0,ariaLabel:t("Vertical text alignment toolbar")}),Qt({view:this,icons:no,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:n,verticalAlignmentToolbar:r,alignmentLabel:o}}_createActionButtons(){const e=this.locale,t=this.t,n=new k(e),i=new k(e),r=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return n.set({label:t("Save"),icon:o.check,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(r,"errorText",((...e)=>e.every((e=>!e)))),i.set({label:t("Cancel"),icon:o.cancel,class:"ck-button-cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:i}}get _horizontalAlignmentLabels(){const e=this.locale,t=this.t,o=t("Align cell text to the left"),n=t("Align cell text to the center"),i=t("Align cell text to the right"),r=t("Justify cell text");return"rtl"===e.uiLanguageDirection?{right:i,center:n,left:o,justify:r}:{left:o,center:n,right:i,justify:r}}get _verticalAlignmentLabels(){const e=this.t;return{top:e("Align cell text to the top"),middle:e("Align cell text to the middle"),bottom:e("Align cell text to the bottom")}}}function ro(e){return"none"!==e} +const oo={left:o.alignLeft,center:o.alignCenter,right:o.alignRight,justify:o.alignJustify,top:o.alignTop,middle:o.alignMiddle,bottom:o.alignBottom};class no extends f{constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=t;const{borderStyleDropdown:o,borderWidthInput:n,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:l,backgroundInput:s}=this._createBackgroundFields(),{widthInput:a,operatorLabel:c,heightInput:d,dimensionsLabel:b}=this._createDimensionFields(),{horizontalAlignmentToolbar:m,verticalAlignmentToolbar:g,alignmentLabel:p}=this._createAlignmentFields();this.focusTracker=new h,this.keystrokes=new u,this.children=this.createCollection(),this.borderStyleDropdown=o,this.borderWidthInput=n,this.borderColorInput=i,this.backgroundInput=s,this.paddingInput=this._createPaddingField(),this.widthInput=a,this.heightInput=d,this.horizontalAlignmentToolbar=m,this.verticalAlignmentToolbar=g;const{saveButtonView:f,cancelButtonView:w}=this._createActionButtons();this.saveButtonView=f,this.cancelButtonView=w,this._focusables=new T,this._focusCycler=new x({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new R(e,{label:this.t("Cell properties")})),this.children.add(new to(e,{labelView:r,children:[r,o,i,n],class:"ck-table-form__border-row"})),this.children.add(new to(e,{labelView:l,children:[l,s],class:"ck-table-form__background-row"})),this.children.add(new to(e,{children:[new to(e,{labelView:b,children:[b,a,c,d],class:"ck-table-form__dimensions-row"}),new to(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new to(e,{labelView:p,children:[p,m,g],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new to(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),I({view:this}),[this.borderColorInput,this.backgroundInput].forEach((e=>{e.fieldView.focusCycler.on("forwardCycle",(e=>{this._focusCycler.focusNext(),e.stop()})),e.fieldView.focusCycler.on("backwardCycle",(e=>{this._focusCycler.focusPrevious(),e.stop()}))})),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableCellProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},o=Zt({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,i=this.t,r=i("Style"),l=new E(n);l.text=i("Border");const s=$t(i),a=new P(n,z);a.set({label:r,class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",(e=>s[e||"none"])),a.fieldView.on("execute",(e=>{this.borderStyle=e.source._borderStyleValue})),a.bind("isEmpty").to(this,"borderStyle",(e=>!e)),y(a.fieldView,Xt(this,t.style),{role:"menu",ariaLabel:r});const c=new P(n,B);c.set({label:i("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",io),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const d=new P(n,o);return d.set({label:i("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",io),d.fieldView.on("input",(()=>{this.borderColor=d.fieldView.value})),this.on("change:borderStyle",((e,o,n,i)=>{io(n)||(this.borderColor="",this.borderWidth=""),io(i)||(this.borderColor=t.color,this.borderWidth=t.width)})),{borderRowLabel:l,borderStyleDropdown:a,borderColorInput:d,borderWidthInput:c}}_createBackgroundFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Background");const n=Zt({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),i=new P(e,n);return i.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",(()=>{this.backgroundColor=i.fieldView.value})),{backgroundRowLabel:o,backgroundInput:i}}_createDimensionFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Dimensions");const n=new P(e,B);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",(()=>{this.width=n.fieldView.element.value}));const i=new f(e);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new P(e,B);return r.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",(()=>{this.height=r.fieldView.element.value})),{dimensionsLabel:o,widthInput:n,operatorLabel:i,heightInput:r}}_createPaddingField(){const e=this.locale,t=this.t,o=new P(e,B);return o.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),o.fieldView.bind("value").to(this,"padding"),o.fieldView.on("input",(()=>{this.padding=o.fieldView.element.value})),o}_createAlignmentFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Table cell text alignment");const n=new W(e),i="rtl"===e.contentLanguageDirection;n.set({isCompact:!0,ariaLabel:t("Horizontal text alignment toolbar")}),Yt({view:this,icons:oo,toolbar:n,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:e=>{if(i){if("left"===e)return"right";if("right"===e)return"left"}return e},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const r=new W(e);return r.set({isCompact:!0,ariaLabel:t("Vertical text alignment toolbar")}),Yt({view:this,icons:oo,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:n,verticalAlignmentToolbar:r,alignmentLabel:o}}_createActionButtons(){const e=this.locale,t=this.t,n=new k(e),i=new k(e),r=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return n.set({label:t("Save"),icon:o.check,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(r,"errorText",((...e)=>e.every((e=>!e)))),i.set({label:t("Cancel"),icon:o.cancel,class:"ck-button-cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:i}}get _horizontalAlignmentLabels(){const e=this.locale,t=this.t,o=t("Align cell text to the left"),n=t("Align cell text to the center"),i=t("Align cell text to the right"),r=t("Justify cell text");return"rtl"===e.uiLanguageDirection?{right:i,center:n,left:o,justify:r}:{left:o,center:n,right:i,justify:r}}get _verticalAlignmentLabels(){const e=this.t;return{top:e("Align cell text to the top"),middle:e("Align cell text to the middle"),bottom:e("Align cell text to the bottom")}}}function io(e){return"none"!==e} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */const lo=N.defaultPositions,so=[lo.northArrowSouth,lo.northArrowSouthWest,lo.northArrowSouthEast,lo.southArrowNorth,lo.southArrowNorthWest,lo.southArrowNorthEast,lo.viewportStickyNorth];function ao(e,t){const o=e.plugins.get("ContextualBalloon");if(Ht(e.editing.view.document.selection)){let n;n="cell"===t?uo(e):co(e),o.updatePosition(n)}}function co(e){const t=e.model.document.selection.getFirstPosition().findAncestor("table"),o=e.editing.mapper.toViewElement(t);return{target:e.editing.view.domConverter.mapViewToDom(o),positions:so}}function uo(e){const t=e.editing.mapper,o=e.editing.view.domConverter,n=e.model.document.selection;if(n.rangeCount>1)return{target:()=>function(e,t){const o=t.editing.mapper,n=t.editing.view.domConverter,i=Array.from(e).map((e=>{const t=ho(e.start),i=o.toViewElement(t);return new g(n.mapViewToDom(i))}));return g.getBoundingRect(i)}(n.getRanges(),e),positions:so};const i=ho(n.getFirstPosition()),r=t.toViewElement(i);return{target:o.mapViewToDom(r),positions:so}}function ho(e){return e.nodeAfter&&e.nodeAfter.is("element","tableCell")?e.nodeAfter:e.findAncestor("tableCell")} + */const ro=N.defaultPositions,lo=[ro.northArrowSouth,ro.northArrowSouthWest,ro.northArrowSouthEast,ro.southArrowNorth,ro.southArrowNorthWest,ro.southArrowNorthEast,ro.viewportStickyNorth];function so(e,t){const o=e.plugins.get("ContextualBalloon");if(Ft(e.editing.view.document.selection)){let n;n="cell"===t?co(e):ao(e),o.updatePosition(n)}}function ao(e){const t=e.model.document.selection.getFirstPosition().findAncestor("table"),o=e.editing.mapper.toViewElement(t);return{target:e.editing.view.domConverter.mapViewToDom(o),positions:lo}}function co(e){const t=e.editing.mapper,o=e.editing.view.domConverter,n=e.model.document.selection;if(n.rangeCount>1)return{target:()=>function(e,t){const o=t.editing.mapper,n=t.editing.view.domConverter,i=Array.from(e).map((e=>{const t=uo(e.start),i=o.toViewElement(t);return new g(n.mapViewToDom(i))}));return g.getBoundingRect(i)}(n.getRanges(),e),positions:lo};const i=uo(n.getFirstPosition()),r=t.toViewElement(i);return{target:o.mapViewToDom(r),positions:lo}}function uo(e){return e.nodeAfter&&e.nodeAfter.is("element","tableCell")?e.nodeAfter:e.findAncestor("tableCell")} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -function bo(e){if(!e||!X(e))return e;const{top:t,right:o,bottom:n,left:i}=e;return t==o&&o==n&&n==i?t:void 0}function mo(e,t){const o=parseFloat(e);return Number.isNaN(o)||String(o)!==String(e)?e:`${o}${t}`}function go(e,t={}){const o={borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",...e};return t.includeAlignmentProperty&&!o.alignment&&(o.alignment="center"),t.includePaddingProperty&&!o.padding&&(o.padding=""),t.includeVerticalAlignmentProperty&&!o.verticalAlignment&&(o.verticalAlignment="middle"),t.includeHorizontalAlignmentProperty&&!o.horizontalAlignment&&(o.horizontalAlignment=t.isRightToLeftContent?"right":"left"),o} +function ho(e){if(!e||!X(e))return e;const{top:t,right:o,bottom:n,left:i}=e;return t==o&&o==n&&n==i?t:void 0}function bo(e,t){const o=parseFloat(e);return Number.isNaN(o)||String(o)!==String(e)?e:`${o}${t}`}function mo(e,t={}){const o={borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",...e};return t.includeAlignmentProperty&&!o.alignment&&(o.alignment="center"),t.includePaddingProperty&&!o.padding&&(o.padding=""),t.includeVerticalAlignmentProperty&&!o.verticalAlignment&&(o.verticalAlignment="middle"),t.includeHorizontalAlignmentProperty&&!o.horizontalAlignment&&(o.horizontalAlignment=t.isRightToLeftContent?"right":"left"),o} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */const po={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class fo extends t{static get requires(){return[L]}static get pluginName(){return"TableCellPropertiesUI"}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:Zt,backgroundColors:Zt})}init(){const e=this.editor,t=e.t;this._defaultTableCellProperties=go(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._balloon=e.plugins.get(L),this.view=null,this._isReady=!1,e.ui.componentFactory.add("tableCellProperties",(o=>{const n=new k(o);n.set({label:t("Cell properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.105 18-.17 1H2.5A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1h15A1.5 1.5 0 0 1 19 2.5v9.975l-.85-.124-.15-.302V8h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5h3.105zM2 12h5V8H2v4zm10-4H8v4h4V8zM2 2v5h5V2H2zm0 16h5v-5H2v5zM13 7h5V2h-5v5zM8 2v5h4V2H8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM13 6a1 1 0 0 1 1 1v3.172a2.047 2.047 0 0 0-.293.443l-.858 1.736-1.916.28-.151.027A1.976 1.976 0 0 0 9.315 14H7a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h6zm-1 2H8v4h4V8z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",(()=>this._showView()));const i=Object.values(po).map((t=>e.commands.get(t)));return n.bind("isEnabled").toMany(i,"isEnabled",((...e)=>e.some((e=>e)))),n}))}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.config.get("table.tableCellProperties"),o=F(t.borderColors),n=H(e.locale,o),i=F(t.backgroundColors),r=H(e.locale,i),l=!1!==t.colorPicker,s=new io(e.locale,{borderColors:n,backgroundColors:r,defaultTableCellProperties:this._defaultTableCellProperties,colorPickerConfig:!!l&&(t.colorPicker||{})}),a=e.t;s.render(),this.listenTo(s,"submit",(()=>{this._hideView()})),this.listenTo(s,"cancel",(()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()})),s.keystrokes.set("Esc",((e,t)=>{this._hideView(),t()})),D({emitter:s,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const c=qt(a),d=Gt(a);return s.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),s.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:s.borderColorInput,commandName:"tableCellBorderColor",errorText:c,validator:Kt})),s.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:s.borderWidthInput,commandName:"tableCellBorderWidth",errorText:d,validator:Xt})),s.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:s.paddingInput,commandName:"tableCellPadding",errorText:d,validator:Jt})),s.on("change:width",this._getValidatedPropertyChangeCallback({viewField:s.widthInput,commandName:"tableCellWidth",errorText:d,validator:Jt})),s.on("change:height",this._getValidatedPropertyChangeCallback({viewField:s.heightInput,commandName:"tableCellHeight",errorText:d,validator:Jt})),s.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:s.backgroundInput,commandName:"tableCellBackgroundColor",errorText:c,validator:Kt})),s.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),s.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment")),s}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(po).map((([t,o])=>{const n=this._defaultTableCellProperties[t]||"";return[t,e.get(o).value||n]})).forEach((([e,o])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,o)})),this._isReady=!0}_showView(){const e=this.editor;this.view||(this.view=this._createPropertiesView()),this.listenTo(e.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:uo(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;Ht(e.editing.view.document.selection)?this._isViewVisible&&ao(e,"cell"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,o,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:o,validator:n,errorText:i}=e,r=Y((()=>{o.errorText=i}),500);return(e,i,l)=>{r.cancel(),this._isReady&&(n(l)?(this.editor.execute(t,{value:l,batch:this._undoStepBatch}),o.errorText=null):r())}}} + */const go={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class po extends t{static get requires(){return[L]}static get pluginName(){return"TableCellPropertiesUI"}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:Qt,backgroundColors:Qt})}init(){const e=this.editor,t=e.t;this._defaultTableCellProperties=mo(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._balloon=e.plugins.get(L),this.view=null,this._isReady=!1,e.ui.componentFactory.add("tableCellProperties",(o=>{const n=new k(o);n.set({label:t("Cell properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.105 18-.17 1H2.5A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1h15A1.5 1.5 0 0 1 19 2.5v9.975l-.85-.124-.15-.302V8h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5h3.105zM2 12h5V8H2v4zm10-4H8v4h4V8zM2 2v5h5V2H2zm0 16h5v-5H2v5zM13 7h5V2h-5v5zM8 2v5h4V2H8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM13 6a1 1 0 0 1 1 1v3.172a2.047 2.047 0 0 0-.293.443l-.858 1.736-1.916.28-.151.027A1.976 1.976 0 0 0 9.315 14H7a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h6zm-1 2H8v4h4V8z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",(()=>this._showView()));const i=Object.values(go).map((t=>e.commands.get(t)));return n.bind("isEnabled").toMany(i,"isEnabled",((...e)=>e.some((e=>e)))),n}))}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.config.get("table.tableCellProperties"),o=F(t.borderColors),n=H(e.locale,o),i=F(t.backgroundColors),r=H(e.locale,i),l=!1!==t.colorPicker,s=new no(e.locale,{borderColors:n,backgroundColors:r,defaultTableCellProperties:this._defaultTableCellProperties,colorPickerConfig:!!l&&(t.colorPicker||{})}),a=e.t;s.render(),this.listenTo(s,"submit",(()=>{this._hideView()})),this.listenTo(s,"cancel",(()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()})),s.keystrokes.set("Esc",((e,t)=>{this._hideView(),t()})),D({emitter:s,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const c=jt(a),d=qt(a);return s.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),s.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:s.borderColorInput,commandName:"tableCellBorderColor",errorText:c,validator:Gt})),s.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:s.borderWidthInput,commandName:"tableCellBorderWidth",errorText:d,validator:Jt})),s.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:s.paddingInput,commandName:"tableCellPadding",errorText:d,validator:Kt})),s.on("change:width",this._getValidatedPropertyChangeCallback({viewField:s.widthInput,commandName:"tableCellWidth",errorText:d,validator:Kt})),s.on("change:height",this._getValidatedPropertyChangeCallback({viewField:s.heightInput,commandName:"tableCellHeight",errorText:d,validator:Kt})),s.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:s.backgroundInput,commandName:"tableCellBackgroundColor",errorText:c,validator:Gt})),s.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),s.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment")),s}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(go).map((([t,o])=>{const n=this._defaultTableCellProperties[t]||"";return[t,e.get(o).value||n]})).forEach((([e,o])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,o)})),this._isReady=!0}_showView(){const e=this.editor;this.view||(this.view=this._createPropertiesView()),this.listenTo(e.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:co(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;Ft(e.editing.view.document.selection)?this._isViewVisible&&so(e,"cell"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,o,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:o,validator:n,errorText:i}=e,r=Y((()=>{o.errorText=i}),500);return(e,i,l)=>{r.cancel(),this._isReady&&(n(l)?(this.editor.execute(t,{value:l,batch:this._undoStepBatch}),o.errorText=null):r())}}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class wo extends e{constructor(e,t,o){super(e),this.attributeName=t,this._defaultValue=o}refresh(){const e=this.editor,t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e.model.document.selection);this.isEnabled=!!t.length,this.value=this._getSingleValue(t)}execute(e={}){const{value:t,batch:o}=e,n=this.editor.model,i=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(n.document.selection),r=this._getValueToSet(t);n.enqueueChange(o,(e=>{r?i.forEach((t=>e.setAttribute(this.attributeName,r,t))):i.forEach((t=>e.removeAttribute(this.attributeName,t)))}))}_getAttribute(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){const t=this._getAttribute(e[0]);return e.every((e=>this._getAttribute(e)===t))?t:void 0}} + */class fo extends e{constructor(e,t,o){super(e),this.attributeName=t,this._defaultValue=o}refresh(){const e=this.editor,t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e.model.document.selection);this.isEnabled=!!t.length,this.value=this._getSingleValue(t)}execute(e={}){const{value:t,batch:o}=e,n=this.editor.model,i=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(n.document.selection),r=this._getValueToSet(t);n.enqueueChange(o,(e=>{r?i.forEach((t=>e.setAttribute(this.attributeName,r,t))):i.forEach((t=>e.removeAttribute(this.attributeName,t)))}))}_getAttribute(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){const t=this._getAttribute(e[0]);return e.every((e=>this._getAttribute(e)===t))?t:void 0}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class ko extends wo{constructor(e,t){super(e,"tableCellWidth",t)}_getValueToSet(e){if((e=mo(e,"px"))!==this._defaultValue)return e}} + */class wo extends fo{constructor(e,t){super(e,"tableCellWidth",t)}_getValueToSet(e){if((e=bo(e,"px"))!==this._defaultValue)return e}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class _o extends t{static get pluginName(){return"TableCellWidthEditing"}static get requires(){return[Ct]}init(){const e=this.editor,t=go(e.config.get("table.tableCellProperties.defaultProperties"));ae(e.model.schema,e.conversion,{modelAttribute:"tableCellWidth",styleName:"width",defaultValue:t.width}),e.commands.add("tableCellWidth",new ko(e,t.width))}} + */class ko extends t{static get pluginName(){return"TableCellWidthEditing"}static get requires(){return[_t]}init(){const e=this.editor,t=mo(e.config.get("table.tableCellProperties.defaultProperties"));ae(e.model.schema,e.conversion,{modelAttribute:"tableCellWidth",styleName:"width",defaultValue:t.width}),e.commands.add("tableCellWidth",new wo(e,t.width))}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Co extends wo{constructor(e,t){super(e,"tableCellPadding",t)}_getAttribute(e){if(!e)return;const t=bo(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=mo(e,"px");if(t!==this._defaultValue)return t}} + */class _o extends fo{constructor(e,t){super(e,"tableCellPadding",t)}_getAttribute(e){if(!e)return;const t=ho(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=bo(e,"px");if(t!==this._defaultValue)return t}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class vo extends wo{constructor(e,t){super(e,"tableCellHeight",t)}_getValueToSet(e){const t=mo(e,"px");if(t!==this._defaultValue)return t}} + */class Co extends fo{constructor(e,t){super(e,"tableCellHeight",t)}_getValueToSet(e){const t=bo(e,"px");if(t!==this._defaultValue)return t}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class yo extends wo{constructor(e,t){super(e,"tableCellBackgroundColor",t)}} + */class vo extends fo{constructor(e,t){super(e,"tableCellBackgroundColor",t)}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Ao extends wo{constructor(e,t){super(e,"tableCellVerticalAlignment",t)}} + */class yo extends fo{constructor(e,t){super(e,"tableCellVerticalAlignment",t)}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class To extends wo{constructor(e,t){super(e,"tableCellHorizontalAlignment",t)}} + */class Ao extends fo{constructor(e,t){super(e,"tableCellHorizontalAlignment",t)}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class xo extends wo{constructor(e,t){super(e,"tableCellBorderStyle",t)}_getAttribute(e){if(!e)return;const t=bo(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}} + */class To extends fo{constructor(e,t){super(e,"tableCellBorderStyle",t)}_getAttribute(e){if(!e)return;const t=ho(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class So extends wo{constructor(e,t){super(e,"tableCellBorderColor",t)}_getAttribute(e){if(!e)return;const t=bo(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}} + */class xo extends fo{constructor(e,t){super(e,"tableCellBorderColor",t)}_getAttribute(e){if(!e)return;const t=ho(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Vo extends wo{constructor(e,t){super(e,"tableCellBorderWidth",t)}_getAttribute(e){if(!e)return;const t=bo(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=mo(e,"px");if(t!==this._defaultValue)return t}} + */class So extends fo{constructor(e,t){super(e,"tableCellBorderWidth",t)}_getAttribute(e){if(!e)return;const t=ho(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=bo(e,"px");if(t!==this._defaultValue)return t}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */const Ro=/^(top|middle|bottom)$/,Io=/^(left|center|right|justify)$/;class Eo extends t{static get pluginName(){return"TableCellPropertiesEditing"}static get requires(){return[Ct,_o]}init(){const e=this.editor,t=e.model.schema,o=e.conversion;e.config.define("table.tableCellProperties.defaultProperties",{});const n=go(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection});e.data.addStyleProcessorRules(j),function(e,t,o){const n={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};e.extend("tableCell",{allowAttributes:Object.values(n)}),te(t,"td",n,o),te(t,"th",n,o),oe(t,{modelElement:"tableCell",modelAttribute:n.style,styleName:"border-style"}),oe(t,{modelElement:"tableCell",modelAttribute:n.color,styleName:"border-color"}),oe(t,{modelElement:"tableCell",modelAttribute:n.width,styleName:"border-width"})}(t,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableCellBorderStyle",new xo(e,n.borderStyle)),e.commands.add("tableCellBorderColor",new So(e,n.borderColor)),e.commands.add("tableCellBorderWidth",new Vo(e,n.borderWidth)),ae(t,o,{modelAttribute:"tableCellHeight",styleName:"height",defaultValue:n.height}),e.commands.add("tableCellHeight",new vo(e,n.height)),e.data.addStyleProcessorRules(q),ae(t,o,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:n.padding}),e.commands.add("tableCellPadding",new Co(e,n.padding)),e.data.addStyleProcessorRules(G),ae(t,o,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableCellBackgroundColor",new yo(e,n.backgroundColor)),function(e,t,o){e.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:e=>({key:"style",value:{"text-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":Io}},model:{key:"tableCellHorizontalAlignment",value:e=>{const t=e.getStyle("text-align");return t===o?null:t}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:Io}},model:{key:"tableCellHorizontalAlignment",value:e=>{const t=e.getAttribute("align");return t===o?null:t}}})}(t,o,n.horizontalAlignment),e.commands.add("tableCellHorizontalAlignment",new To(e,n.horizontalAlignment)),function(e,t,o){e.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:e=>({key:"style",value:{"vertical-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":Ro}},model:{key:"tableCellVerticalAlignment",value:e=>{const t=e.getStyle("vertical-align");return t===o?null:t}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:Ro}},model:{key:"tableCellVerticalAlignment",value:e=>{const t=e.getAttribute("valign");return t===o?null:t}}})} + */const Vo=/^(top|middle|bottom)$/,Ro=/^(left|center|right|justify)$/;class Io extends t{static get pluginName(){return"TableCellPropertiesEditing"}static get requires(){return[_t,ko]}init(){const e=this.editor,t=e.model.schema,o=e.conversion;e.config.define("table.tableCellProperties.defaultProperties",{});const n=mo(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection});e.data.addStyleProcessorRules(j),function(e,t,o){const n={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};e.extend("tableCell",{allowAttributes:Object.values(n)}),te(t,"td",n,o),te(t,"th",n,o),oe(t,{modelElement:"tableCell",modelAttribute:n.style,styleName:"border-style"}),oe(t,{modelElement:"tableCell",modelAttribute:n.color,styleName:"border-color"}),oe(t,{modelElement:"tableCell",modelAttribute:n.width,styleName:"border-width"})}(t,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableCellBorderStyle",new To(e,n.borderStyle)),e.commands.add("tableCellBorderColor",new xo(e,n.borderColor)),e.commands.add("tableCellBorderWidth",new So(e,n.borderWidth)),ae(t,o,{modelAttribute:"tableCellHeight",styleName:"height",defaultValue:n.height}),e.commands.add("tableCellHeight",new Co(e,n.height)),e.data.addStyleProcessorRules(q),ae(t,o,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:n.padding}),e.commands.add("tableCellPadding",new _o(e,n.padding)),e.data.addStyleProcessorRules(G),ae(t,o,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableCellBackgroundColor",new vo(e,n.backgroundColor)),function(e,t,o){e.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:e=>({key:"style",value:{"text-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":Ro}},model:{key:"tableCellHorizontalAlignment",value:e=>{const t=e.getStyle("text-align");return t===o?null:t}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:Ro}},model:{key:"tableCellHorizontalAlignment",value:e=>{const t=e.getAttribute("align");return t===o?null:t}}})}(t,o,n.horizontalAlignment),e.commands.add("tableCellHorizontalAlignment",new Ao(e,n.horizontalAlignment)),function(e,t,o){e.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:e=>({key:"style",value:{"vertical-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":Vo}},model:{key:"tableCellVerticalAlignment",value:e=>{const t=e.getStyle("vertical-align");return t===o?null:t}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:Vo}},model:{key:"tableCellVerticalAlignment",value:e=>{const t=e.getAttribute("valign");return t===o?null:t}}})} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */(t,o,n.verticalAlignment),e.commands.add("tableCellVerticalAlignment",new Ao(e,n.verticalAlignment))}}class Po extends t{static get pluginName(){return"TableCellProperties"}static get requires(){return[Eo,fo]}} + */(t,o,n.verticalAlignment),e.commands.add("tableCellVerticalAlignment",new yo(e,n.verticalAlignment))}}class Eo extends t{static get pluginName(){return"TableCellProperties"}static get requires(){return[Io,po]}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class zo extends e{constructor(e,t,o){super(e),this.attributeName=t,this._defaultValue=o}refresh(){const e=this.editor.model.document.selection.getFirstPosition().findAncestor("table");this.isEnabled=!!e,this.value=this._getValue(e)}execute(e={}){const t=this.editor.model,o=t.document.selection,{value:n,batch:i}=e,r=o.getFirstPosition().findAncestor("table"),l=this._getValueToSet(n);t.enqueueChange(i,(e=>{l?e.setAttribute(this.attributeName,l,r):e.removeAttribute(this.attributeName,r)}))}_getValue(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}} + */class Po extends e{constructor(e,t,o){super(e),this.attributeName=t,this._defaultValue=o}refresh(){const e=this.editor.model.document.selection.getFirstPosition().findAncestor("table");this.isEnabled=!!e,this.value=this._getValue(e)}execute(e={}){const t=this.editor.model,o=t.document.selection,{value:n,batch:i}=e,r=o.getFirstPosition().findAncestor("table"),l=this._getValueToSet(n);t.enqueueChange(i,(e=>{l?e.setAttribute(this.attributeName,l,r):e.removeAttribute(this.attributeName,r)}))}_getValue(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Bo extends zo{constructor(e,t){super(e,"tableBackgroundColor",t)}} + */class zo extends Po{constructor(e,t){super(e,"tableBackgroundColor",t)}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Wo extends zo{constructor(e,t){super(e,"tableBorderColor",t)}_getValue(e){if(!e)return;const t=bo(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}} + */class Bo extends Po{constructor(e,t){super(e,"tableBorderColor",t)}_getValue(e){if(!e)return;const t=ho(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class No extends zo{constructor(e,t){super(e,"tableBorderStyle",t)}_getValue(e){if(!e)return;const t=bo(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}} + */class Wo extends Po{constructor(e,t){super(e,"tableBorderStyle",t)}_getValue(e){if(!e)return;const t=ho(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Lo extends zo{constructor(e,t){super(e,"tableBorderWidth",t)}_getValue(e){if(!e)return;const t=bo(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=mo(e,"px");if(t!==this._defaultValue)return t}} + */class No extends Po{constructor(e,t){super(e,"tableBorderWidth",t)}_getValue(e){if(!e)return;const t=ho(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=bo(e,"px");if(t!==this._defaultValue)return t}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Fo extends zo{constructor(e,t){super(e,"tableWidth",t)}_getValueToSet(e){if((e=mo(e,"px"))!==this._defaultValue)return e}} + */class Lo extends Po{constructor(e,t){super(e,"tableWidth",t)}_getValueToSet(e){if((e=bo(e,"px"))!==this._defaultValue)return e}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Ho extends zo{constructor(e,t){super(e,"tableHeight",t)}_getValueToSet(e){if((e=mo(e,"px"))!==this._defaultValue)return e}} + */class Fo extends Po{constructor(e,t){super(e,"tableHeight",t)}_getValueToSet(e){if((e=bo(e,"px"))!==this._defaultValue)return e}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Do extends zo{constructor(e,t){super(e,"tableAlignment",t)}} + */class Ho extends Po{constructor(e,t){super(e,"tableAlignment",t)}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */const Mo=/^(left|center|right)$/,Oo=/^(left|none|right)$/;class Uo extends t{static get pluginName(){return"TablePropertiesEditing"}static get requires(){return[Ct]}init(){const e=this.editor,t=e.model.schema,o=e.conversion;e.config.define("table.tableProperties.defaultProperties",{});const n=go(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0});e.data.addStyleProcessorRules(j),function(e,t,o){const n={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};e.extend("table",{allowAttributes:Object.values(n)}),te(t,"table",n,o),ne(t,{modelAttribute:n.color,styleName:"border-color"}),ne(t,{modelAttribute:n.style,styleName:"border-style"}),ne(t,{modelAttribute:n.width,styleName:"border-width"})}(t,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableBorderColor",new Wo(e,n.borderColor)),e.commands.add("tableBorderStyle",new No(e,n.borderStyle)),e.commands.add("tableBorderWidth",new Lo(e,n.borderWidth)),function(e,t,o){e.extend("table",{allowAttributes:["tableAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment"},view:e=>({key:"style",value:{float:"center"===e?"none":e}}),converterPriority:"high"}),t.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:Oo}},model:{key:"tableAlignment",value:e=>{let t=e.getStyle("float");return"none"===t&&(t="center"),t===o?null:t}}}).attributeToAttribute({view:{attributes:{align:Mo}},model:{name:"table",key:"tableAlignment",value:e=>{const t=e.getAttribute("align");return t===o?null:t}}})}(t,o,n.alignment),e.commands.add("tableAlignment",new Do(e,n.alignment)),$o(t,o,{modelAttribute:"tableWidth",styleName:"width",defaultValue:n.width}),e.commands.add("tableWidth",new Fo(e,n.width)),$o(t,o,{modelAttribute:"tableHeight",styleName:"height",defaultValue:n.height}),e.commands.add("tableHeight",new Ho(e,n.height)),e.data.addStyleProcessorRules(G),function(e,t,o){const{modelAttribute:n}=o;e.extend("table",{allowAttributes:[n]}),ee(t,{viewElement:"table",...o}),ne(t,o)}(t,o,{modelAttribute:"tableBackgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableBackgroundColor",new Bo(e,n.backgroundColor))}}function $o(e,t,o){const{modelAttribute:n}=o;e.extend("table",{allowAttributes:[n]}),ee(t,{viewElement:/^(table|figure)$/,shouldUpcast:e=>!("table"==e.name&&"figure"==e.parent.name),...o}),oe(t,{modelElement:"table",...o})}_t(".ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row{align-content:baseline;flex-basis:0;flex-wrap:wrap}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar .ck-toolbar__items{flex-wrap:nowrap}.ck.ck-table-properties-form{width:320px}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row{align-self:flex-end;padding:0}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar{background:none;margin-top:var(--ck-spacing-standard)}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar .ck-toolbar__items>*{width:40px}"); + */const Do=/^(left|center|right)$/,Mo=/^(left|none|right)$/;class Oo extends t{static get pluginName(){return"TablePropertiesEditing"}static get requires(){return[_t]}init(){const e=this.editor,t=e.model.schema,o=e.conversion;e.config.define("table.tableProperties.defaultProperties",{});const n=mo(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0});e.data.addStyleProcessorRules(j),function(e,t,o){const n={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};e.extend("table",{allowAttributes:Object.values(n)}),te(t,"table",n,o),ne(t,{modelAttribute:n.color,styleName:"border-color"}),ne(t,{modelAttribute:n.style,styleName:"border-style"}),ne(t,{modelAttribute:n.width,styleName:"border-width"})}(t,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableBorderColor",new Bo(e,n.borderColor)),e.commands.add("tableBorderStyle",new Wo(e,n.borderStyle)),e.commands.add("tableBorderWidth",new No(e,n.borderWidth)),function(e,t,o){e.extend("table",{allowAttributes:["tableAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment"},view:e=>({key:"style",value:{float:"center"===e?"none":e}}),converterPriority:"high"}),t.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:Mo}},model:{key:"tableAlignment",value:e=>{let t=e.getStyle("float");return"none"===t&&(t="center"),t===o?null:t}}}).attributeToAttribute({view:{attributes:{align:Do}},model:{name:"table",key:"tableAlignment",value:e=>{const t=e.getAttribute("align");return t===o?null:t}}})}(t,o,n.alignment),e.commands.add("tableAlignment",new Ho(e,n.alignment)),Uo(t,o,{modelAttribute:"tableWidth",styleName:"width",defaultValue:n.width}),e.commands.add("tableWidth",new Lo(e,n.width)),Uo(t,o,{modelAttribute:"tableHeight",styleName:"height",defaultValue:n.height}),e.commands.add("tableHeight",new Fo(e,n.height)),e.data.addStyleProcessorRules(G),function(e,t,o){const{modelAttribute:n}=o;e.extend("table",{allowAttributes:[n]}),ee(t,{viewElement:"table",...o}),ne(t,o)}(t,o,{modelAttribute:"tableBackgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableBackgroundColor",new zo(e,n.backgroundColor))}}function Uo(e,t,o){const{modelAttribute:n}=o;e.extend("table",{allowAttributes:[n]}),ee(t,{viewElement:/^(table|figure)$/,shouldUpcast:e=>!("table"==e.name&&"figure"==e.parent.name),...o}),oe(t,{modelElement:"table",...o})}kt(".ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row{align-content:baseline;flex-basis:0;flex-wrap:wrap}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar .ck-toolbar__items{flex-wrap:nowrap}.ck.ck-table-properties-form{width:320px}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row{align-self:flex-end;padding:0}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar{background:none;margin-top:var(--ck-spacing-standard)}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar .ck-toolbar__items>*{width:40px}"); /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -const jo={left:o.objectLeft,center:o.objectCenter,right:o.objectRight};class qo extends f{constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:o,borderWidthInput:n,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:l,backgroundInput:s}=this._createBackgroundFields(),{widthInput:a,operatorLabel:c,heightInput:d,dimensionsLabel:b}=this._createDimensionFields(),{alignmentToolbar:m,alignmentLabel:g}=this._createAlignmentFields();this.focusTracker=new h,this.keystrokes=new u,this.children=this.createCollection(),this.borderStyleDropdown=o,this.borderWidthInput=n,this.borderColorInput=i,this.backgroundInput=s,this.widthInput=a,this.heightInput=d,this.alignmentToolbar=m;const{saveButtonView:p,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=p,this.cancelButtonView=f,this._focusables=new T,this._focusCycler=new x({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new R(e,{label:this.t("Table properties")})),this.children.add(new oo(e,{labelView:r,children:[r,o,i,n],class:"ck-table-form__border-row"})),this.children.add(new oo(e,{labelView:l,children:[l,s],class:"ck-table-form__background-row"})),this.children.add(new oo(e,{children:[new oo(e,{labelView:b,children:[b,a,c,d],class:"ck-table-form__dimensions-row"}),new oo(e,{labelView:g,children:[g,m],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new oo(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),I({view:this}),[this.borderColorInput,this.backgroundInput].forEach((e=>{e.fieldView.focusCycler.on("forwardCycle",(e=>{this._focusCycler.focusNext(),e.stop()})),e.fieldView.focusCycler.on("backwardCycle",(e=>{this._focusCycler.focusPrevious(),e.stop()}))})),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},o=eo({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,i=this.t,r=i("Style"),l=new E(n);l.text=i("Border");const s=jt(i),a=new P(n,z);a.set({label:r,class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",(e=>s[e||"none"])),a.fieldView.on("execute",(e=>{this.borderStyle=e.source._borderStyleValue})),a.bind("isEmpty").to(this,"borderStyle",(e=>!e)),y(a.fieldView,Yt(this,t.style),{role:"menu",ariaLabel:r});const c=new P(n,B);c.set({label:i("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",Go),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const d=new P(n,o);return d.set({label:i("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",Go),d.fieldView.on("input",(()=>{this.borderColor=d.fieldView.value})),this.on("change:borderStyle",((e,o,n,i)=>{Go(n)||(this.borderColor="",this.borderWidth=""),Go(i)||(this.borderColor=t.color,this.borderWidth=t.width)})),{borderRowLabel:l,borderStyleDropdown:a,borderColorInput:d,borderWidthInput:c}}_createBackgroundFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Background");const n=eo({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),i=new P(e,n);return i.set({label:t("Color"),class:"ck-table-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",(()=>{this.backgroundColor=i.fieldView.value})),{backgroundRowLabel:o,backgroundInput:i}}_createDimensionFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Dimensions");const n=new P(e,B);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",(()=>{this.width=n.fieldView.element.value}));const i=new f(e);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new P(e,B);return r.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",(()=>{this.height=r.fieldView.element.value})),{dimensionsLabel:o,widthInput:n,operatorLabel:i,heightInput:r}}_createAlignmentFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Alignment");const n=new W(e);return n.set({isCompact:!0,ariaLabel:t("Table alignment toolbar")}),Qt({view:this,icons:jo,toolbar:n,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:o,alignmentToolbar:n}}_createActionButtons(){const e=this.locale,t=this.t,n=new k(e),i=new k(e),r=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return n.set({label:t("Save"),icon:o.check,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(r,"errorText",((...e)=>e.every((e=>!e)))),i.set({label:t("Cancel"),icon:o.cancel,class:"ck-button-cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:i}}get _alignmentLabels(){const e=this.locale,t=this.t,o=t("Align table to the left"),n=t("Center table"),i=t("Align table to the right");return"rtl"===e.uiLanguageDirection?{right:i,center:n,left:o}:{left:o,center:n,right:i}}}function Go(e){return"none"!==e} +const $o={left:o.objectLeft,center:o.objectCenter,right:o.objectRight};class jo extends f{constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:o,borderWidthInput:n,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:l,backgroundInput:s}=this._createBackgroundFields(),{widthInput:a,operatorLabel:c,heightInput:d,dimensionsLabel:b}=this._createDimensionFields(),{alignmentToolbar:m,alignmentLabel:g}=this._createAlignmentFields();this.focusTracker=new h,this.keystrokes=new u,this.children=this.createCollection(),this.borderStyleDropdown=o,this.borderWidthInput=n,this.borderColorInput=i,this.backgroundInput=s,this.widthInput=a,this.heightInput=d,this.alignmentToolbar=m;const{saveButtonView:p,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=p,this.cancelButtonView=f,this._focusables=new T,this._focusCycler=new x({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new R(e,{label:this.t("Table properties")})),this.children.add(new to(e,{labelView:r,children:[r,o,i,n],class:"ck-table-form__border-row"})),this.children.add(new to(e,{labelView:l,children:[l,s],class:"ck-table-form__background-row"})),this.children.add(new to(e,{children:[new to(e,{labelView:b,children:[b,a,c,d],class:"ck-table-form__dimensions-row"}),new to(e,{labelView:g,children:[g,m],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new to(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),I({view:this}),[this.borderColorInput,this.backgroundInput].forEach((e=>{e.fieldView.focusCycler.on("forwardCycle",(e=>{this._focusCycler.focusNext(),e.stop()})),e.fieldView.focusCycler.on("backwardCycle",(e=>{this._focusCycler.focusPrevious(),e.stop()}))})),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},o=Zt({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,i=this.t,r=i("Style"),l=new E(n);l.text=i("Border");const s=$t(i),a=new P(n,z);a.set({label:r,class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",(e=>s[e||"none"])),a.fieldView.on("execute",(e=>{this.borderStyle=e.source._borderStyleValue})),a.bind("isEmpty").to(this,"borderStyle",(e=>!e)),y(a.fieldView,Xt(this,t.style),{role:"menu",ariaLabel:r});const c=new P(n,B);c.set({label:i("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",qo),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const d=new P(n,o);return d.set({label:i("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",qo),d.fieldView.on("input",(()=>{this.borderColor=d.fieldView.value})),this.on("change:borderStyle",((e,o,n,i)=>{qo(n)||(this.borderColor="",this.borderWidth=""),qo(i)||(this.borderColor=t.color,this.borderWidth=t.width)})),{borderRowLabel:l,borderStyleDropdown:a,borderColorInput:d,borderWidthInput:c}}_createBackgroundFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Background");const n=Zt({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),i=new P(e,n);return i.set({label:t("Color"),class:"ck-table-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",(()=>{this.backgroundColor=i.fieldView.value})),{backgroundRowLabel:o,backgroundInput:i}}_createDimensionFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Dimensions");const n=new P(e,B);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",(()=>{this.width=n.fieldView.element.value}));const i=new f(e);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new P(e,B);return r.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",(()=>{this.height=r.fieldView.element.value})),{dimensionsLabel:o,widthInput:n,operatorLabel:i,heightInput:r}}_createAlignmentFields(){const e=this.locale,t=this.t,o=new E(e);o.text=t("Alignment");const n=new W(e);return n.set({isCompact:!0,ariaLabel:t("Table alignment toolbar")}),Yt({view:this,icons:$o,toolbar:n,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:o,alignmentToolbar:n}}_createActionButtons(){const e=this.locale,t=this.t,n=new k(e),i=new k(e),r=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return n.set({label:t("Save"),icon:o.check,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(r,"errorText",((...e)=>e.every((e=>!e)))),i.set({label:t("Cancel"),icon:o.cancel,class:"ck-button-cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:i}}get _alignmentLabels(){const e=this.locale,t=this.t,o=t("Align table to the left"),n=t("Center table"),i=t("Align table to the right");return"rtl"===e.uiLanguageDirection?{right:i,center:n,left:o}:{left:o,center:n,right:i}}}function qo(e){return"none"!==e} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -const Ko={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class Jo extends t{static get requires(){return[L]}static get pluginName(){return"TablePropertiesUI"}constructor(e){super(e),this.view=null,e.config.define("table.tableProperties",{borderColors:Zt,backgroundColors:Zt})}init(){const e=this.editor,t=e.t;this._defaultTableProperties=go(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._balloon=e.plugins.get(L),e.ui.componentFactory.add("tableProperties",(o=>{const n=new k(o);n.set({label:t("Table properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8 2v5h4V2h1v5h5v1h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5H7v-5H2v-1h5V8H2V7h5V2h1zm4 6H8v4h4V8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM17 1a2 2 0 0 1 2 2v9.475l-.85-.124-.857-1.736a2.048 2.048 0 0 0-.292-.44L17 3H3v14h7.808l.402.392L10.935 19H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h14z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",(()=>this._showView()));const i=Object.values(Ko).map((t=>e.commands.get(t)));return n.bind("isEnabled").toMany(i,"isEnabled",((...e)=>e.some((e=>e)))),n}))}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.config.get("table.tableProperties"),o=F(t.borderColors),n=H(e.locale,o),i=F(t.backgroundColors),r=H(e.locale,i),l=!1!==t.colorPicker,s=new qo(e.locale,{borderColors:n,backgroundColors:r,defaultTableProperties:this._defaultTableProperties,colorPickerConfig:!!l&&(t.colorPicker||{})}),a=e.t;s.render(),this.listenTo(s,"submit",(()=>{this._hideView()})),this.listenTo(s,"cancel",(()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()})),s.keystrokes.set("Esc",((e,t)=>{this._hideView(),t()})),D({emitter:s,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const c=qt(a),d=Gt(a);return s.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),s.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:s.borderColorInput,commandName:"tableBorderColor",errorText:c,validator:Kt})),s.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:s.borderWidthInput,commandName:"tableBorderWidth",errorText:d,validator:Xt})),s.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:s.backgroundInput,commandName:"tableBackgroundColor",errorText:c,validator:Kt})),s.on("change:width",this._getValidatedPropertyChangeCallback({viewField:s.widthInput,commandName:"tableWidth",errorText:d,validator:Jt})),s.on("change:height",this._getValidatedPropertyChangeCallback({viewField:s.heightInput,commandName:"tableHeight",errorText:d,validator:Jt})),s.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),s}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(Ko).map((([t,o])=>{const n=t,i=this._defaultTableProperties[n]||"";return[n,e.get(o).value||i]})).forEach((([e,o])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,o)})),this._isReady=!0}_showView(){const e=this.editor;this.view||(this.view=this._createPropertiesView()),this.listenTo(e.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:co(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;Ht(e.editing.view.document.selection)?this._isViewVisible&&ao(e,"table"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,o,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:o,validator:n,errorText:i}=e,r=Y((()=>{o.errorText=i}),500);return(e,i,l)=>{r.cancel(),this._isReady&&(n(l)?(this.editor.execute(t,{value:l,batch:this._undoStepBatch}),o.errorText=null):r())}}} +const Go={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class Ko extends t{static get requires(){return[L]}static get pluginName(){return"TablePropertiesUI"}constructor(e){super(e),this.view=null,e.config.define("table.tableProperties",{borderColors:Qt,backgroundColors:Qt})}init(){const e=this.editor,t=e.t;this._defaultTableProperties=mo(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._balloon=e.plugins.get(L),e.ui.componentFactory.add("tableProperties",(o=>{const n=new k(o);n.set({label:t("Table properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8 2v5h4V2h1v5h5v1h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5H7v-5H2v-1h5V8H2V7h5V2h1zm4 6H8v4h4V8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM17 1a2 2 0 0 1 2 2v9.475l-.85-.124-.857-1.736a2.048 2.048 0 0 0-.292-.44L17 3H3v14h7.808l.402.392L10.935 19H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h14z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",(()=>this._showView()));const i=Object.values(Go).map((t=>e.commands.get(t)));return n.bind("isEnabled").toMany(i,"isEnabled",((...e)=>e.some((e=>e)))),n}))}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.config.get("table.tableProperties"),o=F(t.borderColors),n=H(e.locale,o),i=F(t.backgroundColors),r=H(e.locale,i),l=!1!==t.colorPicker,s=new jo(e.locale,{borderColors:n,backgroundColors:r,defaultTableProperties:this._defaultTableProperties,colorPickerConfig:!!l&&(t.colorPicker||{})}),a=e.t;s.render(),this.listenTo(s,"submit",(()=>{this._hideView()})),this.listenTo(s,"cancel",(()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()})),s.keystrokes.set("Esc",((e,t)=>{this._hideView(),t()})),D({emitter:s,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const c=jt(a),d=qt(a);return s.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),s.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:s.borderColorInput,commandName:"tableBorderColor",errorText:c,validator:Gt})),s.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:s.borderWidthInput,commandName:"tableBorderWidth",errorText:d,validator:Jt})),s.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:s.backgroundInput,commandName:"tableBackgroundColor",errorText:c,validator:Gt})),s.on("change:width",this._getValidatedPropertyChangeCallback({viewField:s.widthInput,commandName:"tableWidth",errorText:d,validator:Kt})),s.on("change:height",this._getValidatedPropertyChangeCallback({viewField:s.heightInput,commandName:"tableHeight",errorText:d,validator:Kt})),s.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),s}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(Go).map((([t,o])=>{const n=t,i=this._defaultTableProperties[n]||"";return[n,e.get(o).value||i]})).forEach((([e,o])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,o)})),this._isReady=!0}_showView(){const e=this.editor;this.view||(this.view=this._createPropertiesView()),this.listenTo(e.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:ao(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;Ft(e.editing.view.document.selection)?this._isViewVisible&&so(e,"table"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,o,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:o,validator:n,errorText:i}=e,r=Y((()=>{o.errorText=i}),500);return(e,i,l)=>{r.cancel(),this._isReady&&(n(l)?(this.editor.execute(t,{value:l,batch:this._undoStepBatch}),o.errorText=null):r())}}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class Xo extends t{static get pluginName(){return"TableProperties"}static get requires(){return[Uo,Jo]}} + */class Jo extends t{static get pluginName(){return"TableProperties"}static get requires(){return[Oo,Ko]}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */function Yo(e){e.document.registerPostFixer((t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;for(const t of o){if("insert"!=t.type)continue;const o=t.position.parent;if(o.is("element","table")||"table"==t.name){const i="table"==t.name?t.position.nodeAfter:o,r=Array.from(i.getChildren()).filter((e=>e.is("element","caption"))),l=r.shift();if(!l)continue;for(const t of r)e.move(e.createRangeIn(t),l,"end"),e.remove(t);l.nextSibling&&(e.move(e.createRangeOn(l),i,"end"),n=!0),n=!!r.length||n}}return n} + */function Xo(e){e.document.registerPostFixer((t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;for(const t of o){if("insert"!=t.type)continue;const o=t.position.parent;if(o.is("element","table")||"table"==t.name){const i="table"==t.name?t.position.nodeAfter:o,r=Array.from(i.getChildren()).filter((e=>e.is("element","caption"))),l=r.shift();if(!l)continue;for(const t of r)e.move(e.createRangeIn(t),l,"end"),e.remove(t);l.nextSibling&&(e.move(e.createRangeOn(l),i,"end"),n=!0),n=!!r.length||n}}return n} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */(t,e)))}function Qo(e){return!!e&&e.is("element","table")}function Zo(e){for(const t of e.getChildren())if(t.is("element","caption"))return t;return null}function en(e){const t=e.parent;return"figcaption"==e.name&&t&&t.is("element","figure")&&t.hasClass("table")||"caption"==e.name&&t&&t.is("element","table")?{name:!0}:null}function tn(e){const t=e.getSelectedElement();return t&&t.is("element","table")?t:e.getFirstPosition().findAncestor("table")} + */(t,e)))}function Yo(e){return!!e&&e.is("element","table")}function Qo(e){for(const t of e.getChildren())if(t.is("element","caption"))return t;return null}function Zo(e){const t=e.parent;return"figcaption"==e.name&&t&&t.is("element","figure")&&t.hasClass("table")||"caption"==e.name&&t&&t.is("element","table")?{name:!0}:null}function en(e){const t=e.getSelectedElement();return t&&t.is("element","table")?t:e.getFirstPosition().findAncestor("table")} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class on extends e{refresh(){const e=tn(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?this.value=!!Zo(e):this.value=!1}execute({focusCaptionOnShow:e=!1}={}){this.editor.model.change((t=>{this.value?this._hideTableCaption(t):this._showTableCaption(t,e)}))}_showTableCaption(e,t){const o=this.editor.model,n=tn(o.document.selection),i=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(n)||e.createElement("caption");o.insertContent(i,n,"end"),t&&e.setSelection(i,"in")}_hideTableCaption(e){const t=this.editor.model,o=tn(t.document.selection),n=this.editor.plugins.get("TableCaptionEditing"),i=Zo(o);n._saveCaption(o,i),t.deleteContent(e.createSelection(i,"on"))}} + */class tn extends e{refresh(){const e=en(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?this.value=!!Qo(e):this.value=!1}execute({focusCaptionOnShow:e=!1}={}){this.editor.model.change((t=>{this.value?this._hideTableCaption(t):this._showTableCaption(t,e)}))}_showTableCaption(e,t){const o=this.editor.model,n=en(o.document.selection),i=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(n)||e.createElement("caption");o.insertContent(i,n,"end"),t&&e.setSelection(i,"in")}_hideTableCaption(e){const t=this.editor.model,o=en(t.document.selection),n=this.editor.plugins.get("TableCaptionEditing"),i=Qo(o);n._saveCaption(o,i),t.deleteContent(e.createSelection(i,"on"))}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class nn extends t{static get pluginName(){return"TableCaptionEditing"}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema,o=e.editing.view,i=e.t;t.isRegistered("caption")?t.extend("caption",{allowIn:"table"}):t.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleTableCaption",new on(this.editor)),e.conversion.for("upcast").elementToElement({view:en,model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>Qo(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>{if(!Qo(e.parent))return null;const r=t.createEditableElement("figcaption");return t.setCustomProperty("tableCaption",!0,r),r.placeholder=i("Enter table caption"),K({view:o,element:r,keepOnFocus:!0}),n(r,t)}}),Yo(e.model)}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?J.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}} + */class on extends t{static get pluginName(){return"TableCaptionEditing"}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema,o=e.editing.view,i=e.t;t.isRegistered("caption")?t.extend("caption",{allowIn:"table"}):t.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleTableCaption",new tn(this.editor)),e.conversion.for("upcast").elementToElement({view:Zo,model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>Yo(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>{if(!Yo(e.parent))return null;const r=t.createEditableElement("figcaption");return t.setCustomProperty("tableCaption",!0,r),r.placeholder=i("Enter table caption"),K({view:o,element:r,keepOnFocus:!0}),n(r,t)}}),Xo(e.model)}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?J.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class rn extends t{static get pluginName(){return"TableCaptionUI"}init(){const e=this.editor,t=e.editing.view,n=e.t;e.ui.componentFactory.add("toggleTableCaption",(i=>{const r=e.commands.get("toggleTableCaption"),l=new k(i);return l.set({icon:o.caption,tooltip:!0,isToggleable:!0}),l.bind("isOn","isEnabled").to(r,"value","isEnabled"),l.bind("label").to(r,"value",(e=>n(e?"Toggle caption off":"Toggle caption on"))),this.listenTo(l,"execute",(()=>{if(e.execute("toggleTableCaption",{focusCaptionOnShow:!0}),r.value){const o=function(e){const t=tn(e);return t?Zo(t):null}(e.model.document.selection),n=e.editing.mapper.toViewElement(o);if(!n)return;t.scrollToTheSelection(),t.change((e=>{e.addClass("table__caption_highlighted",n)}))}e.editing.view.focus()})),l}))}}_t(":root{--ck-color-selector-caption-background:#f7f7f7;--ck-color-selector-caption-text:#333;--ck-color-selector-caption-highlighted-background:#fd0}.ck-content .table>figcaption{background-color:var(--ck-color-selector-caption-background);caption-side:top;color:var(--ck-color-selector-caption-text);display:table-caption;font-size:.75em;outline-offset:-1px;padding:.6em;text-align:center;word-break:break-word}.ck.ck-editor__editable .table>figcaption.table__caption_highlighted{animation:ck-table-caption-highlight .6s ease-out}.ck.ck-editor__editable .table>figcaption.ck-placeholder:before{overflow:hidden;padding-left:inherit;padding-right:inherit;text-overflow:ellipsis;white-space:nowrap}@keyframes ck-table-caption-highlight{0%{background-color:var(--ck-color-selector-caption-highlighted-background)}to{background-color:var(--ck-color-selector-caption-background)}}"); + */class nn extends t{static get pluginName(){return"TableCaptionUI"}init(){const e=this.editor,t=e.editing.view,n=e.t;e.ui.componentFactory.add("toggleTableCaption",(i=>{const r=e.commands.get("toggleTableCaption"),l=new k(i);return l.set({icon:o.caption,tooltip:!0,isToggleable:!0}),l.bind("isOn","isEnabled").to(r,"value","isEnabled"),l.bind("label").to(r,"value",(e=>n(e?"Toggle caption off":"Toggle caption on"))),this.listenTo(l,"execute",(()=>{if(e.execute("toggleTableCaption",{focusCaptionOnShow:!0}),r.value){const o=function(e){const t=en(e);return t?Qo(t):null}(e.model.document.selection),n=e.editing.mapper.toViewElement(o);if(!n)return;t.scrollToTheSelection(),t.change((e=>{e.addClass("table__caption_highlighted",n)}))}e.editing.view.focus()})),l}))}}kt(":root{--ck-color-selector-caption-background:#f7f7f7;--ck-color-selector-caption-text:#333;--ck-color-selector-caption-highlighted-background:#fd0}.ck-content .table>figcaption{background-color:var(--ck-color-selector-caption-background);caption-side:top;color:var(--ck-color-selector-caption-text);display:table-caption;font-size:.75em;outline-offset:-1px;padding:.6em;text-align:center;word-break:break-word}.ck.ck-editor__editable .table>figcaption.table__caption_highlighted{animation:ck-table-caption-highlight .6s ease-out}.ck.ck-editor__editable .table>figcaption.ck-placeholder:before{overflow:hidden;padding-left:inherit;padding-right:inherit;text-overflow:ellipsis;white-space:nowrap}@keyframes ck-table-caption-highlight{0%{background-color:var(--ck-color-selector-caption-highlighted-background)}to{background-color:var(--ck-color-selector-caption-background)}}"); /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -class ln extends t{static get pluginName(){return"TableCaption"}static get requires(){return[nn,rn]}} +class rn extends t{static get pluginName(){return"TableCaption"}static get requires(){return[on,nn]}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */class sn extends e{refresh(){this.isEnabled=!0}execute(e={}){const{model:t,plugins:o}=this.editor;let{table:n=t.document.selection.getSelectedElement(),columnWidths:i,tableWidth:r}=e;i&&(i=Array.isArray(i)?i:i.split(",")),t.change((e=>{r?e.setAttribute("tableWidth",r,n):e.removeAttribute("tableWidth",n);const t=o.get("TableColumnResizeEditing").getColumnGroupElement(n);if(!i&&!t)return;if(!i)return e.remove(t);const l=Ke(i);if(t)Array.from(t.getChildren()).forEach(((t,o)=>e.setAttribute("columnWidth",l[o],t)));else{const t=e.createElement("tableColumnGroup");l.forEach((o=>e.appendElement("tableColumn",{columnWidth:o},t))),e.append(t,n)}}))}} + */class ln extends e{refresh(){this.isEnabled=!0}execute(e={}){const{model:t,plugins:o}=this.editor;let{table:n=t.document.selection.getSelectedElement(),columnWidths:i,tableWidth:r}=e;i&&(i=Array.isArray(i)?i:i.split(",")),t.change((e=>{r?e.setAttribute("tableWidth",r,n):e.removeAttribute("tableWidth",n);const t=o.get("TableColumnResizeEditing").getColumnGroupElement(n);if(!i&&!t)return;if(!i)return e.remove(t);const l=Ge(i);if(t)Array.from(t.getChildren()).forEach(((t,o)=>e.setAttribute("columnWidth",l[o],t)));else{const t=e.createElement("tableColumnGroup");l.forEach((o=>e.appendElement("tableColumn",{columnWidth:o},t))),e.append(t,n)}}))}} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license - */function an(e){return t=>t.on("element:colgroup",((t,o,n)=>{const i=o.modelCursor.findAncestor("table"),r=Ye(i);if(!r)return;const l=Qe(r),s=e.getColumns(i);let a=(c=r,d=n.writer,Qe(c).reduce(((e,t)=>{const o=t.getAttribute("columnWidth"),n=t.getAttribute("colSpan");if(!n)return e.push(o),e;for(let t=0;t<n;t++)e.push(o);return d.removeAttribute("colSpan",t),e}),[]));var c,d;a=Array.from({length:s},((e,t)=>a[t]||"auto")),(a.length!=l.length||a.includes("auto"))&&Xe(l,r,Ke(a),n.writer)}),{priority:"low"})} + */function sn(e){return t=>t.on("element:colgroup",((t,o,n)=>{const i=o.modelCursor.findAncestor("table"),r=Xe(i);if(!r)return;const l=Ye(r),s=e.getColumns(i);let a=(c=r,d=n.writer,Ye(c).reduce(((e,t)=>{const o=t.getAttribute("columnWidth"),n=t.getAttribute("colSpan");if(!n)return e.push(o),e;for(let t=0;t<n;t++)e.push(o);return d.removeAttribute("colSpan",t),e}),[]));var c,d;a=Array.from({length:s},((e,t)=>a[t]||"auto")),(a.length!=l.length||a.includes("auto"))&&Je(l,r,Ge(a),n.writer)}),{priority:"low"})} /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -class cn extends t{static get requires(){return[Ct,Ze]}static get pluginName(){return"TableColumnResizeEditing"}constructor(e){super(e),this._isResizingActive=!1,this.set("_isResizingAllowed",!0),this._resizingData=null,this._domEmitter=new(p()),this._tableUtilsPlugin=e.plugins.get("TableUtils"),this.on("change:_isResizingAllowed",((t,o,n)=>{const i=n?"removeClass":"addClass";e.editing.view.change((t=>{for(const o of e.editing.view.document.roots)t[i]("ck-column-resize_disabled",e.editing.view.document.getRoot(o.rootName))}))}))}init(){this._extendSchema(),this._registerPostFixer(),this._registerConverters(),this._registerResizingListeners(),this._registerResizerInserter();const e=this.editor,t=e.plugins.get("TableColumnResize");e.plugins.get("TableEditing").registerAdditionalSlot({filter:e=>e.is("element","tableColumnGroup"),positionOffset:0});const o=new sn(e);e.commands.add("resizeTableWidth",o),e.commands.add("resizeColumnWidths",o),this.bind("_isResizingAllowed").to(e,"isReadOnly",t,"isEnabled",o,"isEnabled",((e,t,o)=>!e&&t&&o))}destroy(){this._domEmitter.stopListening(),super.destroy()}getColumnGroupElement(e){return Ye(e)}getTableColumnElements(e){return Qe(e)}getTableColumnsWidths(e){return function(e){return Qe(e).map((e=>e.getAttribute("columnWidth")))}(e)}_extendSchema(){this.editor.model.schema.extend("table",{allowAttributes:["tableWidth"]}),this.editor.model.schema.register("tableColumnGroup",{allowIn:"table",isLimit:!0}),this.editor.model.schema.register("tableColumn",{allowIn:"tableColumnGroup",allowAttributes:["columnWidth","colSpan"],isLimit:!0})}_registerPostFixer(){const e=this.editor.model;function t(e,t,o){const n=o._tableUtilsPlugin.getColumns(t);if(0===n-e.length)return e;const i=e.map((e=>Number(e.replace("%","")))),r=function(e,t){const o=new Set;for(const n of e.getChanges())if("insert"==n.type&&n.position.nodeAfter&&"tableCell"==n.position.nodeAfter.name&&n.position.nodeAfter.getAncestors().includes(t))o.add(n.position.nodeAfter);else if("remove"==n.type){const e=n.position.nodeBefore||n.position.nodeAfter;"tableCell"==e.name&&e.getAncestors().includes(t)&&o.add(e)}return o}(o.editor.model.document.differ,t);for(const e of r){const r=n-i.length;if(0===r)continue;const s=r>0,a=o._tableUtilsPlugin.getCellLocation(e).column;if(s){const e=Oe(t,o.editor),n=(l=e,Array(r).fill(l));i.splice(a,0,...n)}else{const e=i.splice(a,Math.abs(r));i[a]+=Ge(e)}}var l;return i.map((e=>e+"%"))}e.document.registerPostFixer((o=>{let n=!1;for(const i of +class an extends t{static get requires(){return[_t,Qe]}static get pluginName(){return"TableColumnResizeEditing"}constructor(e){super(e),this._isResizingActive=!1,this.set("_isResizingAllowed",!0),this._resizingData=null,this._domEmitter=new(p()),this._tableUtilsPlugin=e.plugins.get("TableUtils"),this.on("change:_isResizingAllowed",((t,o,n)=>{const i=n?"removeClass":"addClass";e.editing.view.change((t=>{for(const o of e.editing.view.document.roots)t[i]("ck-column-resize_disabled",e.editing.view.document.getRoot(o.rootName))}))}))}init(){this._extendSchema(),this._registerPostFixer(),this._registerConverters(),this._registerResizingListeners(),this._registerResizerInserter();const e=this.editor,t=e.plugins.get("TableColumnResize");e.plugins.get("TableEditing").registerAdditionalSlot({filter:e=>e.is("element","tableColumnGroup"),positionOffset:0});const o=new ln(e);e.commands.add("resizeTableWidth",o),e.commands.add("resizeColumnWidths",o),this.bind("_isResizingAllowed").to(e,"isReadOnly",t,"isEnabled",o,"isEnabled",((e,t,o)=>!e&&t&&o))}destroy(){this._domEmitter.stopListening(),super.destroy()}getColumnGroupElement(e){return Xe(e)}getTableColumnElements(e){return Ye(e)}getTableColumnsWidths(e){return function(e){return Ye(e).map((e=>e.getAttribute("columnWidth")))}(e)}_extendSchema(){this.editor.model.schema.extend("table",{allowAttributes:["tableWidth"]}),this.editor.model.schema.register("tableColumnGroup",{allowIn:"table",isLimit:!0}),this.editor.model.schema.register("tableColumn",{allowIn:"tableColumnGroup",allowAttributes:["columnWidth","colSpan"],isLimit:!0})}_registerPostFixer(){const e=this.editor.model;function t(e,t,o){const n=o._tableUtilsPlugin.getColumns(t);if(0===n-e.length)return e;const i=e.map((e=>Number(e.replace("%","")))),r=function(e,t){const o=new Set;for(const n of e.getChanges())if("insert"==n.type&&n.position.nodeAfter&&"tableCell"==n.position.nodeAfter.name&&n.position.nodeAfter.getAncestors().includes(t))o.add(n.position.nodeAfter);else if("remove"==n.type){const e=n.position.nodeBefore||n.position.nodeAfter;"tableCell"==e.name&&e.getAncestors().includes(t)&&o.add(e)}return o}(o.editor.model.document.differ,t);for(const e of r){const r=n-i.length;if(0===r)continue;const s=r>0,a=o._tableUtilsPlugin.getCellLocation(e).column;if(s){const e=Me(t,o.editor),n=(l=e,Array(r).fill(l));i.splice(a,0,...n)}else{const e=i.splice(a,Math.abs(r));i[a]+=qe(e)}}var l;return i.map((e=>e+"%"))}e.document.registerPostFixer((o=>{let n=!1;for(const i of /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -function(e){const t=new Set;for(const o of e.document.differ.getChanges()){let n=null;switch(o.type){case"insert":n=["table","tableRow","tableCell"].includes(o.name)?o.position:null;break;case"remove":n=["tableRow","tableCell"].includes(o.name)?o.position:null;break;case"attribute":o.range.start.nodeAfter&&(n=["table","tableRow","tableCell"].includes(o.range.start.nodeAfter.name)?o.range.start:null)}if(!n)continue;const i=n.nodeAfter&&n.nodeAfter.is("element","table")?n.nodeAfter:n.findAncestor("table");for(const o of e.createRangeOn(i).getItems())o.is("element","table")&&Ye(o)&&t.add(o)}return t}(e)){const e=this.getColumnGroupElement(i),r=this.getTableColumnElements(e),l=this.getTableColumnsWidths(e);let s=Ke(l);s=t(s,i,this),Q(l,s)||(Xe(r,e,s,o),n=!0)}return n}))}_registerConverters(){const e=this.editor.conversion;e.for("upcast").attributeToAttribute({view:{name:"figure",key:"style",value:{width:/[\s\S]+/}},model:{name:"table",key:"tableWidth",value:e=>e.getStyle("width")}}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableWidth"},view:e=>({name:"figure",key:"style",value:{width:e}})}),e.elementToElement({model:"tableColumnGroup",view:"colgroup"}),e.elementToElement({model:"tableColumn",view:"col"}),e.for("downcast").add((e=>e.on("insert:table",((e,t,o)=>{const n=o.writer,i=t.item,r=o.mapper.toViewElement(i),l=r.is("element","table")?r:Array.from(r.getChildren()).find((e=>e.is("element","table")));Ye(i)?n.addClass("ck-table-resized",l):n.removeClass("ck-table-resized",l)}),{priority:"low"}))),e.for("upcast").add(an(this._tableUtilsPlugin)),e.for("upcast").attributeToAttribute({view:{name:"col",styles:{width:/.*/}},model:{key:"columnWidth",value:e=>{const t=e.getStyle("width");return t&&(t.endsWith("%")||t.endsWith("pt"))?t:"auto"}}}),e.for("upcast").attributeToAttribute({view:{name:"col",key:"span"},model:"colSpan"}),e.for("downcast").attributeToAttribute({model:{name:"tableColumn",key:"columnWidth"},view:e=>({key:"style",value:{width:e}})})}_registerResizingListeners(){const e=this.editor.editing.view;e.addObserver(Pt),e.document.on("mousedown",this._onMouseDownHandler.bind(this),{priority:"high"}),this._domEmitter.listenTo(c.window.document,"mousemove",Z(this._onMouseMoveHandler.bind(this),50)),this._domEmitter.listenTo(c.window.document,"mouseup",this._onMouseUpHandler.bind(this))}_onMouseDownHandler(e,t){const o=t.target;if(!o.hasClass("ck-table-column-resizer"))return;if(!this._isResizingAllowed)return;const n=this.editor,i=n.editing.mapper.toModelElement(o.findAncestor("figure"));if(!n.model.canEditAt(i))return;t.preventDefault(),e.stop();const r=function(e,t,o){const n=Array(t.getColumns(e)),i=new he(e);for(const e of i){const t=o.editing.mapper.toViewElement(e.cell),i=Je(o.editing.view.domConverter.mapViewToDom(t));(!n[e.column]||i<n[e.column])&&(n[e.column]=qe(i))}return n}(i,this._tableUtilsPlugin,n),l=o.findAncestor("table"),s=n.editing.view;Array.from(l.getChildren()).find((e=>e.is("element","colgroup")))||s.change((e=>{!function(e,t,o){const n=e.createContainerElement("colgroup");for(let o=0;o<t.length;o++){const i=e.createEmptyElement("col"),r=`${qe(t[o]/Ge(t)*100)}%`;e.setStyle("width",r,i),e.insert(e.createPositionAt(n,"end"),i)}e.insert(e.createPositionAt(o,0),n)}(e,r,l)})),this._isResizingActive=!0,this._resizingData=this._getResizingData(t,r),s.change((e=>function(e,t,o){const n=o.widths.viewFigureWidth/o.widths.viewFigureParentWidth;e.addClass("ck-table-resized",t),e.addClass("ck-table-column-resizer__active",o.elements.viewResizer),e.setStyle("width",`${qe(100*n)}%`,t.findAncestor("figure"))}(e,l,this._resizingData)))}_onMouseMoveHandler(e,t){if(!this._isResizingActive)return;if(!this._isResizingAllowed)return void this._onMouseUpHandler();const{columnPosition:o,flags:{isRightEdge:n,isTableCentered:i,isLtrContent:r},elements:{viewFigure:l,viewLeftColumn:s,viewRightColumn:a},widths:{viewFigureParentWidth:c,tableWidth:d,leftColumnWidth:u,rightColumnWidth:h}}=this._resizingData,b=-u+De,m=n?c-d:h-De,g=(r?1:-1)*(n&&i?2:1),p=(f=(t.clientX-o)*g,w=Math.min(b,0),k=Math.max(m,0),qe(f<=w?w:f>=k?k:f));var f,w,k;0!==p&&this.editor.editing.view.change((e=>{const t=qe(100*(u+p)/d);if(e.setStyle("width",`${t}%`,s),n){const t=qe(100*(d+p)/c);e.setStyle("width",`${t}%`,l)}else{const t=qe(100*(h-p)/d);e.setStyle("width",`${t}%`,a)}}))}_onMouseUpHandler(){if(!this._isResizingActive)return;const{viewResizer:e,modelTable:t,viewFigure:o,viewColgroup:n}=this._resizingData.elements,i=this.editor,r=i.editing.view,l=this.getColumnGroupElement(t),s=Array.from(n.getChildren()).filter((e=>e.is("view:element"))),a=l?this.getTableColumnsWidths(l):null,c=s.map((e=>e.getStyle("width"))),d=!Q(a,c),u=t.getAttribute("tableWidth"),h=o.getStyle("width"),b=u!==h;(d||b)&&(this._isResizingAllowed?i.execute("resizeTableWidth",{table:t,tableWidth:`${qe(h)}%`,columnWidths:c}):r.change((e=>{if(a)for(const t of s)e.setStyle("width",a.shift(),t);else e.remove(n);b&&(u?e.setStyle("width",u,o):e.removeStyle("width",o)),a||u||e.removeClass("ck-table-resized",[...o.getChildren()].find((e=>"table"===e.name)))}))),r.change((t=>{t.removeClass("ck-table-column-resizer__active",e)})),this._isResizingActive=!1,this._resizingData=null}_getResizingData(e,t){const o=this.editor,n=e.domEvent.clientX,i=e.target,r=i.findAncestor("td")||i.findAncestor("th"),l=o.editing.mapper.toModelElement(r),s=l.findAncestor("table"),a=function(e,t){const o=t.getCellLocation(e).column;return{leftEdge:o,rightEdge:o+(e.getAttribute("colspan")||1)-1}}(l,this._tableUtilsPlugin).rightEdge,c=a===this._tableUtilsPlugin.getColumns(s)-1,d=!s.hasAttribute("tableAlignment"),u="rtl"!==o.locale.contentLanguageDirection,h=r.findAncestor("table"),b=h.findAncestor("figure"),m=[...h.getChildren()].find((e=>e.is("element","colgroup"))),g=m.getChild(a),p=c?void 0:m.getChild(a+1);return{columnPosition:n,flags:{isRightEdge:c,isTableCentered:d,isLtrContent:u},elements:{viewResizer:i,modelTable:s,viewFigure:b,viewColgroup:m,viewLeftColumn:g,viewRightColumn:p},widths:{viewFigureParentWidth:je(o.editing.view.domConverter.mapViewToDom(b.parent)),viewFigureWidth:je(o.editing.view.domConverter.mapViewToDom(b)),tableWidth:Ue(s,o),leftColumnWidth:t[a],rightColumnWidth:c?void 0:t[a+1]}}}_registerResizerInserter(){this.editor.conversion.for("editingDowncast").add((e=>{e.on("insert:tableCell",((e,t,o)=>{const n=t.item,i=o.mapper.toViewElement(n),r=o.writer;r.insert(r.createPositionAt(i,"end"),r.createUIElement("div",{class:"ck-table-column-resizer"}))}),{priority:"lowest"})}))}}_t(":root{--ck-color-selector-column-resizer-hover:var(--ck-color-base-active);--ck-table-column-resizer-width:7px;--ck-table-column-resizer-position-offset:calc(var(--ck-table-column-resizer-width)*-0.5 - 0.5px)}.ck-content .table .ck-table-resized{table-layout:fixed}.ck-content .table table{overflow:hidden}.ck-content .table td,.ck-content .table th{overflow-wrap:break-word;position:relative}.ck.ck-editor__editable .table .ck-table-column-resizer{bottom:0;cursor:col-resize;position:absolute;right:var(--ck-table-column-resizer-position-offset);top:0;user-select:none;width:var(--ck-table-column-resizer-width);z-index:var(--ck-z-default)}.ck.ck-editor__editable .table[draggable] .ck-table-column-resizer,.ck.ck-editor__editable.ck-column-resize_disabled .table .ck-table-column-resizer{display:none}.ck.ck-editor__editable .table .ck-table-column-resizer:hover,.ck.ck-editor__editable .table .ck-table-column-resizer__active{background-color:var(--ck-color-selector-column-resizer-hover);bottom:-999999px;opacity:.25;top:-999999px}.ck.ck-editor__editable[dir=rtl] .table .ck-table-column-resizer{left:var(--ck-table-column-resizer-position-offset);right:unset}"); +function(e){const t=new Set;for(const o of e.document.differ.getChanges()){let n=null;switch(o.type){case"insert":n=["table","tableRow","tableCell"].includes(o.name)?o.position:null;break;case"remove":n=["tableRow","tableCell"].includes(o.name)?o.position:null;break;case"attribute":o.range.start.nodeAfter&&(n=["table","tableRow","tableCell"].includes(o.range.start.nodeAfter.name)?o.range.start:null)}if(!n)continue;const i=n.nodeAfter&&n.nodeAfter.is("element","table")?n.nodeAfter:n.findAncestor("table");for(const o of e.createRangeOn(i).getItems())o.is("element","table")&&Xe(o)&&t.add(o)}return t}(e)){const e=this.getColumnGroupElement(i),r=this.getTableColumnElements(e),l=this.getTableColumnsWidths(e);let s=Ge(l);s=t(s,i,this),Q(l,s)||(Je(r,e,s,o),n=!0)}return n}))}_registerConverters(){const e=this.editor.conversion;e.for("upcast").attributeToAttribute({view:{name:"figure",key:"style",value:{width:/[\s\S]+/}},model:{name:"table",key:"tableWidth",value:e=>e.getStyle("width")}}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableWidth"},view:e=>({name:"figure",key:"style",value:{width:e}})}),e.elementToElement({model:"tableColumnGroup",view:"colgroup"}),e.elementToElement({model:"tableColumn",view:"col"}),e.for("downcast").add((e=>e.on("insert:table",((e,t,o)=>{const n=o.writer,i=t.item,r=o.mapper.toViewElement(i),l=r.is("element","table")?r:Array.from(r.getChildren()).find((e=>e.is("element","table")));Xe(i)?n.addClass("ck-table-resized",l):n.removeClass("ck-table-resized",l)}),{priority:"low"}))),e.for("upcast").add(sn(this._tableUtilsPlugin)),e.for("upcast").attributeToAttribute({view:{name:"col",styles:{width:/.*/}},model:{key:"columnWidth",value:e=>{const t=e.getStyle("width");return t&&(t.endsWith("%")||t.endsWith("pt"))?t:"auto"}}}),e.for("upcast").attributeToAttribute({view:{name:"col",key:"span"},model:"colSpan"}),e.for("downcast").attributeToAttribute({model:{name:"tableColumn",key:"columnWidth"},view:e=>({key:"style",value:{width:e}})})}_registerResizingListeners(){const e=this.editor.editing.view;e.addObserver(Et),e.document.on("mousedown",this._onMouseDownHandler.bind(this),{priority:"high"}),this._domEmitter.listenTo(c.window.document,"mousemove",Z(this._onMouseMoveHandler.bind(this),50)),this._domEmitter.listenTo(c.window.document,"mouseup",this._onMouseUpHandler.bind(this))}_onMouseDownHandler(e,t){const o=t.target;if(!o.hasClass("ck-table-column-resizer"))return;if(!this._isResizingAllowed)return;const n=this.editor,i=n.editing.mapper.toModelElement(o.findAncestor("figure"));if(!n.model.canEditAt(i))return;t.preventDefault(),e.stop();const r=function(e,t,o){const n=Array(t.getColumns(e)),i=new he(e);for(const e of i){const t=o.editing.mapper.toViewElement(e.cell),i=Ke(o.editing.view.domConverter.mapViewToDom(t));(!n[e.column]||i<n[e.column])&&(n[e.column]=je(i))}return n}(i,this._tableUtilsPlugin,n),l=o.findAncestor("table"),s=n.editing.view;Array.from(l.getChildren()).find((e=>e.is("element","colgroup")))||s.change((e=>{!function(e,t,o){const n=e.createContainerElement("colgroup");for(let o=0;o<t.length;o++){const i=e.createEmptyElement("col"),r=`${je(t[o]/qe(t)*100)}%`;e.setStyle("width",r,i),e.insert(e.createPositionAt(n,"end"),i)}e.insert(e.createPositionAt(o,0),n)}(e,r,l)})),this._isResizingActive=!0,this._resizingData=this._getResizingData(t,r),s.change((e=>function(e,t,o){const n=o.widths.viewFigureWidth/o.widths.viewFigureParentWidth;e.addClass("ck-table-resized",t),e.addClass("ck-table-column-resizer__active",o.elements.viewResizer),e.setStyle("width",`${je(100*n)}%`,t.findAncestor("figure"))}(e,l,this._resizingData)))}_onMouseMoveHandler(e,t){if(!this._isResizingActive)return;if(!this._isResizingAllowed)return void this._onMouseUpHandler();const{columnPosition:o,flags:{isRightEdge:n,isTableCentered:i,isLtrContent:r},elements:{viewFigure:l,viewLeftColumn:s,viewRightColumn:a},widths:{viewFigureParentWidth:c,tableWidth:d,leftColumnWidth:u,rightColumnWidth:h}}=this._resizingData,b=40-u,m=n?c-d:h-40,g=(r?1:-1)*(n&&i?2:1),p=(f=(t.clientX-o)*g,w=Math.min(b,0),k=Math.max(m,0),je(f<=w?w:f>=k?k:f));var f,w,k;0!==p&&this.editor.editing.view.change((e=>{const t=je(100*(u+p)/d);if(e.setStyle("width",`${t}%`,s),n){const t=je(100*(d+p)/c);e.setStyle("width",`${t}%`,l)}else{const t=je(100*(h-p)/d);e.setStyle("width",`${t}%`,a)}}))}_onMouseUpHandler(){if(!this._isResizingActive)return;const{viewResizer:e,modelTable:t,viewFigure:o,viewColgroup:n}=this._resizingData.elements,i=this.editor,r=i.editing.view,l=this.getColumnGroupElement(t),s=Array.from(n.getChildren()).filter((e=>e.is("view:element"))),a=l?this.getTableColumnsWidths(l):null,c=s.map((e=>e.getStyle("width"))),d=!Q(a,c),u=t.getAttribute("tableWidth"),h=o.getStyle("width"),b=u!==h;(d||b)&&(this._isResizingAllowed?i.execute("resizeTableWidth",{table:t,tableWidth:`${je(h)}%`,columnWidths:c}):r.change((e=>{if(a)for(const t of s)e.setStyle("width",a.shift(),t);else e.remove(n);b&&(u?e.setStyle("width",u,o):e.removeStyle("width",o)),a||u||e.removeClass("ck-table-resized",[...o.getChildren()].find((e=>"table"===e.name)))}))),r.change((t=>{t.removeClass("ck-table-column-resizer__active",e)})),this._isResizingActive=!1,this._resizingData=null}_getResizingData(e,t){const o=this.editor,n=e.domEvent.clientX,i=e.target,r=i.findAncestor("td")||i.findAncestor("th"),l=o.editing.mapper.toModelElement(r),s=l.findAncestor("table"),a=function(e,t){const o=t.getCellLocation(e).column;return{leftEdge:o,rightEdge:o+(e.getAttribute("colspan")||1)-1}}(l,this._tableUtilsPlugin).rightEdge,c=a===this._tableUtilsPlugin.getColumns(s)-1,d=!s.hasAttribute("tableAlignment"),u="rtl"!==o.locale.contentLanguageDirection,h=r.findAncestor("table"),b=h.findAncestor("figure"),m=[...h.getChildren()].find((e=>e.is("element","colgroup"))),g=m.getChild(a),p=c?void 0:m.getChild(a+1);return{columnPosition:n,flags:{isRightEdge:c,isTableCentered:d,isLtrContent:u},elements:{viewResizer:i,modelTable:s,viewFigure:b,viewColgroup:m,viewLeftColumn:g,viewRightColumn:p},widths:{viewFigureParentWidth:$e(o.editing.view.domConverter.mapViewToDom(b.parent)),viewFigureWidth:$e(o.editing.view.domConverter.mapViewToDom(b)),tableWidth:Oe(s,o),leftColumnWidth:t[a],rightColumnWidth:c?void 0:t[a+1]}}}_registerResizerInserter(){this.editor.conversion.for("editingDowncast").add((e=>{e.on("insert:tableCell",((e,t,o)=>{const n=t.item,i=o.mapper.toViewElement(n),r=o.writer;r.insert(r.createPositionAt(i,"end"),r.createUIElement("div",{class:"ck-table-column-resizer"}))}),{priority:"lowest"})}))}}kt(":root{--ck-color-selector-column-resizer-hover:var(--ck-color-base-active);--ck-table-column-resizer-width:7px;--ck-table-column-resizer-position-offset:calc(var(--ck-table-column-resizer-width)*-0.5 - 0.5px)}.ck-content .table .ck-table-resized{table-layout:fixed}.ck-content .table table{overflow:hidden}.ck-content .table td,.ck-content .table th{overflow-wrap:break-word;position:relative}.ck.ck-editor__editable .table .ck-table-column-resizer{bottom:0;cursor:col-resize;position:absolute;right:var(--ck-table-column-resizer-position-offset);top:0;user-select:none;width:var(--ck-table-column-resizer-width);z-index:var(--ck-z-default)}.ck.ck-editor__editable .table[draggable] .ck-table-column-resizer,.ck.ck-editor__editable.ck-column-resize_disabled .table .ck-table-column-resizer{display:none}.ck.ck-editor__editable .table .ck-table-column-resizer:hover,.ck.ck-editor__editable .table .ck-table-column-resizer__active{background-color:var(--ck-color-selector-column-resizer-hover);bottom:-999999px;opacity:.25;top:-999999px}.ck.ck-editor__editable[dir=rtl] .table .ck-table-column-resizer{left:var(--ck-table-column-resizer-position-offset);right:unset}"); /** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -class dn extends t{static get requires(){return[cn,_o]}static get pluginName(){return"TableColumnResize"}}export{Nt as PlainTableOutput,Wt as Table,ln as TableCaption,nn as TableCaptionEditing,rn as TableCaptionUI,Po as TableCellProperties,Eo as TableCellPropertiesEditing,fo as TableCellPropertiesUI,_o as TableCellWidthEditing,St as TableClipboard,dn as TableColumnResize,cn as TableColumnResizeEditing,Ct as TableEditing,Et as TableKeyboard,zt as TableMouse,Xo as TableProperties,Uo as TablePropertiesEditing,Jo as TablePropertiesUI,xt as TableSelection,Mt as TableToolbar,At as TableUI,Ze as TableUtils}; \ No newline at end of file +class cn extends t{static get requires(){return[an,ko]}static get pluginName(){return"TableColumnResize"}}export{Wt as PlainTableOutput,Bt as Table,rn as TableCaption,on as TableCaptionEditing,nn as TableCaptionUI,Eo as TableCellProperties,Io as TableCellPropertiesEditing,po as TableCellPropertiesUI,ko as TableCellWidthEditing,xt as TableClipboard,cn as TableColumnResize,an as TableColumnResizeEditing,_t as TableEditing,It as TableKeyboard,Pt as TableMouse,Jo as TableProperties,Oo as TablePropertiesEditing,Ko as TablePropertiesUI,Tt as TableSelection,Dt as TableToolbar,yt as TableUI,Qe as TableUtils}; \ No newline at end of file diff --git a/typo3/sysext/t3editor/Resources/Public/JavaScript/Contrib/@codemirror/view.js b/typo3/sysext/t3editor/Resources/Public/JavaScript/Contrib/@codemirror/view.js index 8d32394fbcdd1deb0868aa6ffeefcb06beeb85a3..1825623e92e37b5623c9d161df570f86bd3209c7 100644 --- a/typo3/sysext/t3editor/Resources/Public/JavaScript/Contrib/@codemirror/view.js +++ b/typo3/sysext/t3editor/Resources/Public/JavaScript/Contrib/@codemirror/view.js @@ -1 +1 @@ -import{Text,RangeSet,MapMode,RangeValue,Facet,StateEffect,ChangeSet,findClusterBreak,EditorSelection,EditorState,findColumn,CharCategory,Annotation,Transaction,Prec,codePointAt,codePointSize,combineConfig,StateField,RangeSetBuilder,countColumn}from"@codemirror/state";import{StyleModule}from"style-mod";import{keyName,base,shift}from"w3c-keyname";function getSelection(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function contains(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function deepActiveElement(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function hasSelection(t,e){if(!e.anchorNode)return!1;try{return contains(t,e.anchorNode)}catch(t){return!1}}function clientRectsFor(t){return 3==t.nodeType?textRange(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function isEquivalentPosition(t,e,i,o){return!!i&&(scanFor(t,e,i,o,-1)||scanFor(t,e,i,o,1))}function domIndex(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function scanFor(t,e,i,o,s){for(;;){if(t==i&&e==o)return!0;if(e==(s<0?0:maxOffset(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=domIndex(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?maxOffset(t):0}}}function maxOffset(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}const Rect0={left:0,right:0,top:0,bottom:0};function flattenRect(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function windowRect(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function scrollRectIntoView(t,e,i,o,s,n,r,l){let a=t.ownerDocument,h=a.defaultView||window;for(let c=t;c;)if(1==c.nodeType){let t,d=c==a.body;if(d)t=windowRect(h);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();t={left:e.left,right:e.left+c.clientWidth,top:e.top,bottom:e.top+c.clientHeight}}let u=0,p=0;if("nearest"==s)e.top<t.top?(p=-(t.top-e.top+r),i>0&&e.bottom>t.bottom+p&&(p=e.bottom-t.bottom+p+r)):e.bottom>t.bottom&&(p=e.bottom-t.bottom+r,i<0&&e.top-p<t.top&&(p=-(t.top+p-e.top+r)));else{let o=e.bottom-e.top,n=t.bottom-t.top;p=("center"==s&&o<=n?e.top+o/2-n/2:"start"==s||"center"==s&&i<0?e.top-r:e.bottom-n+r)-t.top}if("nearest"==o)e.left<t.left?(u=-(t.left-e.left+n),i>0&&e.right>t.right+u&&(u=e.right-t.right+u+n)):e.right>t.right&&(u=e.right-t.right+n,i<0&&e.left<t.left+u&&(u=-(t.left+u-e.left+n)));else{u=("center"==o?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==o==l?e.left-n:e.right-(t.right-t.left)+n)-t.left}if(u||p)if(d)h.scrollBy(u,p);else{let t=0,i=0;if(p){let t=c.scrollTop;c.scrollTop+=p,i=c.scrollTop-t}if(u){let e=c.scrollLeft;c.scrollLeft+=u,t=c.scrollLeft-e}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-u)<1&&(o="nearest"),i&&Math.abs(i-p)<1&&(s="nearest")}if(d)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}function scrollableParent(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}class DOMSelectionState{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){this.set(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)}set(t,e,i,o){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=o}}let scratchRange,preventScrollSupported=null;function focusPreventScroll(t){if(t.setActive)return t.setActive();if(preventScrollSupported)return t.focus(preventScrollSupported);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==preventScrollSupported?{get preventScroll(){return preventScrollSupported={preventScroll:!0},!0}}:void 0),!preventScrollSupported){preventScrollSupported=!1;for(let t=0;t<e.length;){let i=e[t++],o=e[t++],s=e[t++];i.scrollTop!=o&&(i.scrollTop=o),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function textRange(t,e,i=e){let o=scratchRange||(scratchRange=document.createRange());return o.setEnd(t,i),o.setStart(t,e),o}function dispatchKey(t,e,i){let o={key:e,code:e,keyCode:i,which:i,cancelable:!0},s=new KeyboardEvent("keydown",o);s.synthetic=!0,t.dispatchEvent(s);let n=new KeyboardEvent("keyup",o);return n.synthetic=!0,t.dispatchEvent(n),s.defaultPrevented||n.defaultPrevented}function getRoot(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function clearAttributes(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function atElementStart(t,e){let i=e.focusNode,o=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=o)return!1;for(;;)if(o){if(1!=i.nodeType)return!1;let t=i.childNodes[o-1];"false"==t.contentEditable?o--:(i=t,o=maxOffset(i))}else{if(i==t)return!0;o=domIndex(i),i=i.parentNode}}class DOMPos{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new DOMPos(t.parentNode,domIndex(t),e)}static after(t,e){return new DOMPos(t.parentNode,domIndex(t)+1,e)}}const noChildren=[];class ContentView{constructor(){this.parent=null,this.dom=null,this.dirty=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}coordsAt(t,e){return null}sync(t,e){if(2&this.dirty){let i,o=this.dom,s=null;for(let n of this.children){if(n.dirty){if(!n.dom&&(i=s?s.nextSibling:o.firstChild)){let t=ContentView.get(i);(!t||!t.parent&&t.canReuseDOM(n))&&n.reuseDOM(i)}n.sync(t,e),n.dirty=0}if(i=s?s.nextSibling:o.firstChild,e&&!e.written&&e.node==o&&i!=n.dom&&(e.written=!0),n.dom.parentNode==o)for(;i&&i!=n.dom;)i=rm$1(i);else o.insertBefore(n.dom,i);s=n.dom}for(i=s?s.nextSibling:o.firstChild,i&&e&&e.node==o&&(e.written=!0);i;)i=rm$1(i)}else if(1&this.dirty)for(let i of this.children)i.dirty&&(i.sync(t,e),i.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let o=0==maxOffset(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==o&&e.firstChild!=e.lastChild&&(o=t==e.firstChild?-1:1),t=e}i=o<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!ContentView.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let o=this.children[t];if(o.dom==i)return e;e+=o.length+o.breakAfter}}domBoundsAround(t,e,i=0){let o=-1,s=-1,n=-1,r=-1;for(let l=0,a=i,h=i;l<this.children.length;l++){let i=this.children[l],c=a+i.length;if(a<t&&c>e)return i.domBoundsAround(t,e,a);if(c>=t&&-1==o&&(o=l,s=a),a>e&&i.dom.parentNode==this.dom){n=l,r=h;break}h=c,a=c+i.breakAfter}return{from:s,to:r<0?i+this.length:r,startDOM:(o?this.children[o-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:n<this.children.length&&n>=0?this.children[n].dom:null}}markDirty(t=!1){this.dirty|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.dirty|=2),1&e.dirty)return;e.dirty|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,this.dirty&&this.markParentsDirty(!0))}setDOM(t){this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=noChildren){this.markDirty();for(let i=t;i<e;i++){let t=this.children[i];t.parent==this&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new ChildCursor(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,o,s,n){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}}function rm$1(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}ContentView.prototype.breakAfter=0;class ChildCursor{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function replaceRange(t,e,i,o,s,n,r,l,a){let{children:h}=t,c=h.length?h[e]:null,d=n.length?n[n.length-1]:null,u=d?d.breakAfter:r;if(!(e==o&&c&&!r&&!u&&n.length<2&&c.merge(i,s,n.length?d:null,0==i,l,a))){if(o<h.length){let t=h[o];t&&s<t.length?(e==o&&(t=t.split(s),s=0),!u&&d&&t.merge(0,s,d,!0,0,a)?n[n.length-1]=t:(s&&t.merge(0,s,null,!1,0,a),n.push(t))):(null==t?void 0:t.breakAfter)&&(d?d.breakAfter=1:r=1),o++}for(c&&(c.breakAfter=r,i>0&&(!r&&n.length&&c.merge(i,c.length,n[0],!1,l,0)?c.breakAfter=n.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,l,0),e++));e<o&&n.length;)if(h[o-1].become(n[n.length-1]))o--,n.pop(),a=n.length?0:l;else{if(!h[e].become(n[0]))break;e++,n.shift(),l=n.length?0:a}!n.length&&e&&o<h.length&&!h[e-1].breakAfter&&h[o].merge(0,0,h[e-1],!1,l,a)&&e--,(e<o||n.length)&&t.replaceChildren(e,o,n)}}function mergeChildrenInto(t,e,i,o,s,n){let r=t.childCursor(),{i:l,off:a}=r.findPos(i,1),{i:h,off:c}=r.findPos(e,-1),d=e-i;for(let t of o)d+=t.length;t.length+=d,replaceRange(t,h,c,l,a,o,0,s,n)}let nav="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},doc="undefined"!=typeof document?document:{documentElement:{style:{}}};const ie_edge=/Edge\/(\d+)/.exec(nav.userAgent),ie_upto10=/MSIE \d/.test(nav.userAgent),ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent),ie=!!(ie_upto10||ie_11up||ie_edge),gecko=!ie&&/gecko\/(\d+)/i.test(nav.userAgent),chrome=!ie&&/Chrome\/(\d+)/.exec(nav.userAgent),webkit="webkitFontSmoothing"in doc.documentElement.style,safari=!ie&&/Apple Computer/.test(nav.vendor),ios=safari&&(/Mobile\/\w+/.test(nav.userAgent)||nav.maxTouchPoints>2);var browser={mac:ios||/Mac/.test(nav.platform),windows:/Win/.test(nav.platform),linux:/Linux|X11/.test(nav.platform),ie,ie_version:ie_upto10?doc.documentMode||6:ie_11up?+ie_11up[1]:ie_edge?+ie_edge[1]:0,gecko,gecko_version:gecko?+(/Firefox\/(\d+)/.exec(nav.userAgent)||[0,0])[1]:0,chrome:!!chrome,chrome_version:chrome?+chrome[1]:0,ios,android:/Android\b/.test(nav.userAgent),webkit,safari,webkit_version:webkit?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=doc.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const MaxJoinLen=256;class TextView extends ContentView{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof TextView&&!(this.length-(e-t)+i.length>256))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new TextView(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new DOMPos(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return textCoords(this.dom,t,e)}}class MarkView extends ContentView{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(clearAttributes(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.dirty|=6)}sync(t,e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,o,s,n){return(!i||!(!(i instanceof MarkView&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&n<=0))&&(mergeChildrenInto(this,t,e,i?i.children:[],s-1,n-1),this.markDirty(),!0)}split(t){let e=[],i=0,o=-1,s=0;for(let n of this.children){let r=i+n.length;r>t&&e.push(i<t?n.split(t-i):n),o<0&&i>=t&&(o=s),i=r,s++}let n=this.length-t;return this.length=t,o>-1&&(this.children.length=o,this.markDirty()),new MarkView(this.mark,e,n)}domAtPos(t){return inlineDOMAtPos(this,t)}coordsAt(t,e){return coordsInChildren(this,t,e)}}function textCoords(t,e,i){let o=t.nodeValue.length;e>o&&(e=o);let s=e,n=e,r=0;0==e&&i<0||e==o&&i>=0?browser.chrome||browser.gecko||(e?(s--,r=1):n<o&&(n++,r=-1)):i<0?s--:n<o&&n++;let l=textRange(t,s,n).getClientRects();if(!l.length)return Rect0;let a=l[(r?r<0:i>=0)?0:l.length-1];return browser.safari&&!r&&0==a.width&&(a=Array.prototype.find.call(l,(t=>t.width))||a),r?flattenRect(a,r<0):a||null}class WidgetView extends ContentView{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}static create(t,e,i){return new(t.customView||WidgetView)(t,e,i)}split(t){let e=WidgetView.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,o,s,n){return!(i&&(!(i instanceof WidgetView&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&n<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t.length==this.length&&t instanceof WidgetView&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return Text.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,o=this.posAtStart;return i?i.slice(o,o+this.length):Text.empty}domAtPos(t){return(this.length?0==t:this.side>0)?DOMPos.before(this.dom):DOMPos.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.dom.getClientRects(),o=null;if(!i.length)return Rect0;for(let e=t>0?i.length-1:0;o=i[e],!(t>0?0==e:e==i.length-1||o.top<o.bottom);e+=t>0?-1:1);return this.length?o:flattenRect(o,this.side>0)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class CompositionView extends WidgetView{domAtPos(t){let{topView:e,text:i}=this.widget;return e?scanCompositionTree(t,0,e,i,this.length-e.length,((t,e)=>t.domAtPos(e)),((t,e)=>new DOMPos(t,Math.min(e,t.nodeValue.length)))):new DOMPos(i,Math.min(t,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(t,e){let{topView:i,text:o}=this.widget;return i?posFromDOMInCompositionTree(t,e,i,o,this.length-i.length):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:o}=this.widget;return i?scanCompositionTree(t,e,i,o,this.length-i.length,((t,e,i)=>t.coordsAt(e,i)),((t,e,i)=>textCoords(t,e,i))):textCoords(o,t,e)}destroy(){var t;super.destroy(),null===(t=this.widget.topView)||void 0===t||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function scanCompositionTree(t,e,i,o,s,n,r){if(i instanceof MarkView){for(let l=i.dom.firstChild;l;l=l.nextSibling){let i=ContentView.get(l);if(i){let a=contains(l,o),h=i.length+(a?s:0);if(t<h||t==h&&i.getSide()<=0)return a?scanCompositionTree(t,e,i,o,s,n,r):n(i,t,e);t-=h}else{let i=scanCompositionNode(t,e,l,r);if("number"!=typeof i)return i;t=i}}return n(i,i.length,-1)}return i.dom==o?r(o,t,e):n(i,t,e)}function scanCompositionNode(t,e,i,o){if(3==i.nodeType){let s=i.nodeValue.length;if(t<=s)return o(i,t,e);t-=s}else if(1==i.nodeType&&"false"!=i.contentEditable)for(let s=i.firstChild;s;s=s.nextSibling){let i=scanCompositionNode(t,e,s,o);if("number"!=typeof i)return i;t=i}return t}function posFromDOMInCompositionTree(t,e,i,o,s){if(i instanceof MarkView){let n=0;for(let r=i.dom.firstChild;r;r=r.nextSibling){let i=ContentView.get(r);if(i){let l=contains(r,o);if(contains(r,t))return n+(l?posFromDOMInCompositionTree(t,e,i,o,s):i.localPosFromDOM(t,e));n+=i.length+(l?s:0)}else{let i=posFromDOMInOpaqueNode(t,e,r);if(null!=i.result)return n+i.result;n+=i.size}}}else if(i.dom==o)return Math.min(e,o.nodeValue.length);return i.localPosFromDOM(t,e)}function posFromDOMInOpaqueNode(t,e,i){if(3==i.nodeType)return t==i?{result:e}:{size:i.nodeValue.length};if(1!=i.nodeType||"false"==i.contentEditable)return i.contains(t)?{result:0}:{size:0};{let o=0;for(let s=i.firstChild,n=0;;s=s.nextSibling,n++){if(t==i&&n==e)return{result:o};if(!s)return{size:o};let r=posFromDOMInOpaqueNode(t,e,s);if(null!=r.result)return{result:e+r.result};o+=r.size}}}class WidgetBufferView extends ContentView{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof WidgetBufferView&&t.side==this.side}split(){return new WidgetBufferView(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?DOMPos.before(this.dom):DOMPos.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){let e=this.dom.getBoundingClientRect(),i=inlineSiblingRect(this,this.side>0?-1:1);return i&&i.top<e.bottom&&i.bottom>e.top?{left:e.left,right:e.right,top:i.top,bottom:i.bottom}:e}get overrideDOMText(){return Text.empty}get isHidden(){return!0}}function inlineSiblingRect(t,e){let i=t.parent,o=i?i.children.indexOf(t):-1;for(;i&&o>=0;)if(e<0?o>0:o<i.children.length){let t=i.children[o+e];if(t instanceof TextView){let i=t.coordsAt(e<0?t.length:0,e);if(i)return i}o+=e}else{if(!(i instanceof MarkView&&i.parent)){let t=i.dom.lastChild;if(t&&"BR"==t.nodeName)return t.getClientRects()[0];break}o=i.parent.children.indexOf(i)+(e<0?0:1),i=i.parent}}function inlineDOMAtPos(t,e){let i=t.dom,{children:o}=t,s=0;for(let t=0;s<o.length;s++){let n=o[s],r=t+n.length;if(!(r==t&&n.getSide()<=0)){if(e>t&&e<r&&n.dom.parentNode==i)return n.domAtPos(e-t);if(e<=t)break;t=r}}for(let t=s;t>0;t--){let e=o[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<o.length;t++){let e=o[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new DOMPos(i,0)}function joinInlineInto(t,e,i){let o,{children:s}=t;i>0&&e instanceof MarkView&&s.length&&(o=s[s.length-1])instanceof MarkView&&o.mark.eq(e.mark)?joinInlineInto(o,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function coordsInChildren(t,e,i){let o=null,s=-1,n=null,r=-1;!function t(e,l){for(let a=0,h=0;a<e.children.length&&h<=l;a++){let c=e.children[a],d=h+c.length;d>=l&&(c.children.length?t(c,l-h):(!n||n instanceof WidgetBufferView&&i>0)&&(d>l||h==d&&c.getSide()>0)?(n=c,r=l-h):(h<l||h==d&&c.getSide()<0)&&(o=c,s=l-h)),h=d}}(t,e);let l=(i<0?o:n)||o||n;return l?l.coordsAt(Math.max(0,l==o?s:r),i):fallbackRect(t)}function fallbackRect(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=clientRectsFor(e);return i[i.length-1]||null}function combineAttrs(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}function attrsEq(t,e){if(t==e)return!0;if(!t||!e)return!1;let i=Object.keys(t),o=Object.keys(e);if(i.length!=o.length)return!1;for(let s of i)if(-1==o.indexOf(s)||t[s]!==e[s])return!1;return!0}function updateAttrs(t,e,i){let o=null;if(e)for(let s in e)i&&s in i||t.removeAttribute(o=s);if(i)for(let s in i)e&&e[s]==i[s]||t.setAttribute(o=s,i[s]);return!!o}TextView.prototype.children=WidgetView.prototype.children=WidgetBufferView.prototype.children=noChildren;class WidgetType{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}ignoreEvent(t){return!0}get customView(){return null}get isHidden(){return!1}destroy(t){}}var BlockType=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(BlockType||(BlockType={}));class Decoration extends RangeValue{constructor(t,e,i,o){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=o}get heightRelevant(){return!1}static mark(t){return new MarkDecoration(t)}static widget(t){let e=t.side||0,i=!!t.block;return e+=i?e>0?3e8:-4e8:e>0?1e8:-1e8,new PointDecoration(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,o=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:n}=getInclusive(t,o);e=(s?o?-3e8:-1:5e8)-1,i=1+(n?o?2e8:1:-6e8)}return new PointDecoration(t,e,i,o,t.widget||null,!0)}static line(t){return new LineDecoration(t)}static set(t,e=!1){return RangeSet.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Decoration.none=RangeSet.empty;class MarkDecoration extends Decoration{constructor(t){let{start:e,end:i}=getInclusive(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){return this==t||t instanceof MarkDecoration&&this.tagName==t.tagName&&this.class==t.class&&attrsEq(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}MarkDecoration.prototype.point=!1;class LineDecoration extends Decoration{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof LineDecoration&&this.spec.class==t.spec.class&&attrsEq(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}LineDecoration.prototype.mapMode=MapMode.TrackBefore,LineDecoration.prototype.point=!0;class PointDecoration extends Decoration{constructor(t,e,i,o,s,n){super(e,i,s,t),this.block=o,this.isReplace=n,this.mapMode=o?e<=0?MapMode.TrackBefore:MapMode.TrackAfter:MapMode.TrackDel}get type(){return this.startSide<this.endSide?BlockType.WidgetRange:this.startSide<=0?BlockType.WidgetBefore:BlockType.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5}eq(t){return t instanceof PointDecoration&&widgetsEq(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function getInclusive(t,e=!1){let{inclusiveStart:i,inclusiveEnd:o}=t;return null==i&&(i=t.inclusive),null==o&&(o=t.inclusive),{start:null!=i?i:e,end:null!=o?o:e}}function widgetsEq(t,e){return t==e||!!(t&&e&&t.compare(e))}function addRange(t,e,i,o=0){let s=i.length-1;s>=0&&i[s]+o>=t?i[s]=Math.max(i[s],e):i.push(t,e)}PointDecoration.prototype.point=!0;class LineView extends ContentView{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,o,s,n){if(i){if(!(i instanceof LineView))return!1;this.dom||i.transferDOM(this)}return o&&this.setDeco(i?i.attrs:null),mergeChildrenInto(this,t,e,i?i.children:[],s,n),!0}split(t){let e=new LineView;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:o}=this.childPos(t);o&&(e.append(this.children[i].split(o),0),this.children[i].merge(o,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){attrsEq(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){joinInlineInto(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=combineAttrs(e,this.attrs||{})),i&&(this.attrs=combineAttrs({class:i},this.attrs||{}))}domAtPos(t){return inlineDOMAtPos(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(clearAttributes(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(updateAttrs(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let o=this.dom.lastChild;for(;o&&ContentView.get(o)instanceof MarkView;)o=o.lastChild;if(!(o&&this.length&&("BR"==o.nodeName||0!=(null===(i=ContentView.get(o))||void 0===i?void 0:i.isEditable)||browser.ios&&this.children.some((t=>t instanceof TextView))))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof TextView)||/[^ -~]/.test(i.text))return null;let o=clientRectsFor(i.dom);if(1!=o.length)return null;e+=o[0].width,t=o[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=coordsInChildren(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let o=(e-t.textHeight)/2;return{top:i.top+o,bottom:i.bottom-o,left:i.left,right:i.left}}}return i}become(t){return!1}get type(){return BlockType.Text}static find(t,e){for(let i=0,o=0;i<t.children.length;i++){let s=t.children[i],n=o+s.length;if(n>=e){if(s instanceof LineView)return s;if(n>e)break}o=n+s.breakAfter}return null}}class BlockWidgetView extends ContentView{constructor(t,e,i){super(),this.widget=t,this.length=e,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,o,s,n){return!(i&&(!(i instanceof BlockWidgetView&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&n<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?DOMPos.before(this.dom):DOMPos.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new BlockWidgetView(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return noChildren}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Text.empty}domBoundsAround(){return null}become(t){return t instanceof BlockWidgetView&&t.type==this.type&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class ContentBuilder{constructor(t,e,i,o){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=o,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof BlockWidgetView&&t.type==BlockType.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new LineView),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(wrapMarks(new WidgetBufferView(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:o}=this.cursor.next(this.skip);if(this.skip=0,o)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let o=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff,this.textOff+o)),e),i),this.atCursorPos=!0,this.textOff+=o,t-=o,i=0}}span(t,e,i,o){this.buildText(e-t,i,o),this.pos=e,this.openStart<0&&(this.openStart=o)}point(t,e,i,o,s,n){if(this.disallowBlockEffectsFor[n]&&i instanceof PointDecoration){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=e-t;if(i instanceof PointDecoration)if(i.block){let{type:t}=i;t!=BlockType.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new BlockWidgetView(i.widget||new NullWidget("div"),r,t))}else{let n=WidgetView.create(i.widget||new NullWidget("span"),r,r?0:i.startSide),l=this.atCursorPos&&!n.isEditable&&s<=o.length&&(t<e||i.startSide>0),a=!n.isEditable&&(t<e||s>o.length||i.startSide<=0),h=this.getLine();2!=this.pendingBuffer||l||n.isEditable||(this.pendingBuffer=0),this.flushBuffer(o),l&&(h.append(wrapMarks(new WidgetBufferView(1),o),s),s=o.length+Math.max(0,s-o.length)),h.append(wrapMarks(n,o),s),this.atCursorPos=a,this.pendingBuffer=a?t<e||s>o.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=o.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,o,s){let n=new ContentBuilder(t,e,i,s);return n.openEnd=RangeSet.spans(o,e,i,n),n.openStart<0&&(n.openStart=n.openEnd),n.finish(n.openEnd),n}}function wrapMarks(t,e){for(let i of e)t=new MarkView(i,[t],t.length);return t}class NullWidget extends WidgetType{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const clickAddsSelectionRange=Facet.define(),dragMovesSelection$1=Facet.define(),mouseSelectionStyle=Facet.define(),exceptionSink=Facet.define(),updateListener=Facet.define(),inputHandler=Facet.define(),focusChangeEffect=Facet.define(),perLineTextDirection=Facet.define({combine:t=>t.some((t=>t))}),nativeSelectionHidden=Facet.define({combine:t=>t.some((t=>t))});class ScrollTarget{constructor(t,e="nearest",i="nearest",o=5,s=5){this.range=t,this.y=e,this.x=i,this.yMargin=o,this.xMargin=s}map(t){return t.empty?this:new ScrollTarget(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const scrollIntoView=StateEffect.define({map:(t,e)=>t.map(e)});function logException(t,e,i){let o=t.facet(exceptionSink);o.length?o[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const editable=Facet.define({combine:t=>!t.length||t[0]});let nextPluginID=0;const viewPlugin=Facet.define();class ViewPlugin{constructor(t,e,i,o){this.id=t,this.create=e,this.domEventHandlers=i,this.extension=o(this)}static define(t,e){const{eventHandlers:i,provide:o,decorations:s}=e||{};return new ViewPlugin(nextPluginID++,t,i,(t=>{let e=[viewPlugin.of(t)];return s&&e.push(decorations.of((e=>{let i=e.plugin(t);return i?s(i):Decoration.none}))),o&&e.push(o(t)),e}))}static fromClass(t,e){return ViewPlugin.define((e=>new t(e)),e)}}class PluginInstance{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(logException(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){logException(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){logException(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const editorAttributes=Facet.define(),contentAttributes=Facet.define(),decorations=Facet.define(),atomicRanges=Facet.define(),scrollMargins=Facet.define(),styleModule=Facet.define();class ChangedRange{constructor(t,e,i,o){this.fromA=t,this.toA=e,this.fromB=i,this.toB=o}join(t){return new ChangedRange(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let o=t[e-1];if(!(o.fromA>i.toA)){if(o.toA<i.fromA)break;i=i.join(o),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let o=0,s=0,n=0,r=0;;o++){let l=o==t.length?null:t[o],a=n-r,h=l?l.fromB:1e9;for(;s<e.length&&e[s]<h;){let t=e[s],o=e[s+1],n=Math.max(r,t),l=Math.min(h,o);if(n<=l&&new ChangedRange(n+a,l+a,n,l).addToSet(i),o>h)break;s+=2}if(!l)return i;new ChangedRange(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),n=l.toA,r=l.toB}}}class ViewUpdate{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=ChangeSet.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let o=[];this.changes.iterChangedRanges(((t,e,i,s)=>o.push(new ChangedRange(t,e,i,s)))),this.changedRanges=o}static create(t,e,i){return new ViewUpdate(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}var Direction=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Direction||(Direction={}));const LTR=Direction.LTR,RTL=Direction.RTL;function dec(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const LowTypes=dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),ArabicTypes=dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Brackets=Object.create(null),BracketStack=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Brackets[e]=i,Brackets[i]=-e}function charType(t){return t<=247?LowTypes[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?ArabicTypes[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8203?256:64336<=t&&t<=65023?4:8204==t?256:1}const BidiRE=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class BidiSpan{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?RTL:LTR}side(t,e){return this.dir==e==t?this.to:this.from}static find(t,e,i,o){let s=-1;for(let n=0;n<t.length;n++){let r=t[n];if(r.from<=e&&r.to>=e){if(r.level==i)return n;(s<0||(0!=o?o<0?r.from<e:r.to>e:t[s].level>r.level))&&(s=n)}}if(s<0)throw new RangeError("Index out of range");return s}}const types=[];function computeOrder(t,e){let i=t.length,o=e==LTR?1:2,s=e==LTR?2:1;if(!t||1==o&&!BidiRE.test(t))return trivialOrder(i);for(let e=0,s=o,n=o;e<i;e++){let i=charType(t.charCodeAt(e));512==i?i=s:8==i&&4==n&&(i=16),types[e]=4==i?2:i,7&i&&(n=i),s=i}for(let t=0,e=o,s=o;t<i;t++){let o=types[t];if(128==o)t<i-1&&e==types[t+1]&&24&e?o=types[t]=e:types[t]=256;else if(64==o){let o=t+1;for(;o<i&&64==types[o];)o++;let n=t&&8==e||o<i&&8==types[o]?1==s?1:8:256;for(let e=t;e<o;e++)types[e]=n;t=o-1}else 8==o&&1==s&&(types[t]=1);e=o,7&o&&(s=o)}for(let e,n,r,l=0,a=0,h=0;l<i;l++)if(n=Brackets[e=t.charCodeAt(l)])if(n<0){for(let t=a-3;t>=0;t-=3)if(BracketStack[t+1]==-n){let e=BracketStack[t+2],i=2&e?o:4&e?1&e?s:o:0;i&&(types[l]=types[BracketStack[t]]=i),a=t;break}}else{if(189==BracketStack.length)break;BracketStack[a++]=l,BracketStack[a++]=e,BracketStack[a++]=h}else if(2==(r=types[l])||1==r){let t=r==o;h=t?0:1;for(let e=a-3;e>=0;e-=3){let i=BracketStack[e+2];if(2&i)break;if(t)BracketStack[e+2]|=2;else{if(4&i)break;BracketStack[e+2]|=4}}}for(let t=0;t<i;t++)if(256==types[t]){let e=t+1;for(;e<i&&256==types[e];)e++;let s=1==(t?types[t-1]:o),n=s==(1==(e<i?types[e]:o))?s?1:2:o;for(let i=t;i<e;i++)types[i]=n;t=e-1}let n=[];if(1==o)for(let t=0;t<i;){let e=t,o=1!=types[t++];for(;t<i&&o==(1!=types[t]);)t++;if(o)for(let i=t;i>e;){let t=i,o=2!=types[--i];for(;i>e&&o==(2!=types[i-1]);)i--;n.push(new BidiSpan(i,t,o?2:1))}else n.push(new BidiSpan(e,t,0))}else for(let t=0;t<i;){let e=t,o=2==types[t++];for(;t<i&&o==(2==types[t]);)t++;n.push(new BidiSpan(e,t,o?1:2))}return n}function trivialOrder(t){return[new BidiSpan(0,t,0)]}let movedOver="";function moveVisually(t,e,i,o,s){var n;let r=o.head-t.from,l=-1;if(0==r){if(!s||!t.length)return null;e[0].level!=i&&(r=e[0].side(!1,i),l=0)}else if(r==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(r=t.side(!0,i),l=e.length-1)}l<0&&(l=BidiSpan.find(e,r,null!==(n=o.bidiLevel)&&void 0!==n?n:-1,o.assoc));let a=e[l];r==a.side(s,i)&&(a=e[l+=s?1:-1],r=a.side(!s,i));let h=s==(a.dir==i),c=findClusterBreak(t.text,r,h);if(movedOver=t.text.slice(Math.min(r,c),Math.max(r,c)),c!=a.side(s,i))return EditorSelection.cursor(c+t.from,h?-1:1,a.level);let d=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return d||a.level==i?d&&d.level<a.level?EditorSelection.cursor(d.side(!s,i)+t.from,s?1:-1,d.level):EditorSelection.cursor(c+t.from,s?-1:1,a.level):EditorSelection.cursor(s?t.to:t.from,s?-1:1,i)}const LineBreakPlaceholder="ï¿¿";class DOMReader{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(EditorState.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=LineBreakPlaceholder}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let o=t;;){this.findPointBefore(i,o),this.readNode(o);let t=o.nextSibling;if(t==e)break;let s=ContentView.get(o),n=ContentView.get(t);(s&&n?s.breakAfter:(s?s.breakAfter:isBlockElement(o))||isBlockElement(t)&&("BR"!=o.nodeName||o.cmIgnore))&&this.lineBreak(),o=t}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let s,n=-1,r=1;if(this.lineSeparator?(n=e.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(s=o.exec(e))&&(n=s.index,r=s[0].length),this.append(e.slice(i,n<0?e.length:n)),n<0)break;if(this.lineBreak(),r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=n+r}}readNode(t){if(t.cmIgnore)return;let e=ContentView.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+Math.min(e,i.offset))}}function isBlockElement(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class DOMPoint{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class DocView extends ContentView{constructor(t){super(),this.view=t,this.compositionDeco=Decoration.none,this.decorations=[],this.dynamicDecorationMap=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new LineView],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ChangedRange(0,0,0,t.state.doc.length)],0)}get length(){return this.view.state.doc.length}update(t){let e=t.changedRanges;this.minWidth>0&&e.length&&(e.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo))?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=Decoration.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=computeCompositionDeco(this.view,t.changes)),(browser.ie||browser.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=findChangedDeco(this.decorations,this.updateDeco(),t.changes);return e=ChangedRange.extendWithRanges(e,i),(0!=this.dirty||0!=e.length)&&(this.updateInner(e,t.startState.doc.length),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e);let{observer:i}=this.view;i.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=browser.chrome||browser.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.dirty=0,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}));let o=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof BlockWidgetView&&t.widget instanceof BlockGapWidget&&o.push(t.dom);i.updateGaps(o)}updateChildren(t,e){let i=this.childCursor(e);for(let e=t.length-1;;e--){let o=e>=0?t[e]:null;if(!o)break;let{fromA:s,toA:n,fromB:r,toB:l}=o,{content:a,breakAtStart:h,openStart:c,openEnd:d}=ContentBuilder.build(this.view.state.doc,r,l,this.decorations,this.dynamicDecorationMap),{i:u,off:p}=i.findPos(n,1),{i:f,off:g}=i.findPos(s,-1);replaceRange(this,f,g,u,p,a,h,c,d)}}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,o=i==this.dom,s=!o&&hasSelection(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(o||e||s))return;let n=this.forceSelection;this.forceSelection=!1;let r=this.view.state.selection.main,l=this.domAtPos(r.anchor),a=r.empty?l:this.domAtPos(r.head);if(browser.gecko&&r.empty&&!this.compositionDeco.size&&betweenUneditable(l)){let t=document.createTextNode("");this.view.observer.ignore((()=>l.node.insertBefore(t,l.node.childNodes[l.offset]||null))),l=a=new DOMPos(t,0),n=!0}let h=this.view.observer.selectionRange;!n&&h.focusNode&&isEquivalentPosition(l.node,l.offset,h.anchorNode,h.anchorOffset)&&isEquivalentPosition(a.node,a.offset,h.focusNode,h.focusOffset)||(this.view.observer.ignore((()=>{browser.android&&browser.chrome&&this.dom.contains(h.focusNode)&&inUneditable(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=getSelection(this.view.root);if(t)if(r.empty){if(browser.gecko){let t=nextToUneditable(l.node,l.offset);if(t&&3!=t){let e=nearbyTextNode(l.node,l.offset,1==t?1:-1);e&&(l=new DOMPos(e,1==t?0:e.nodeValue.length))}}t.collapse(l.node,l.offset),null!=r.bidiLevel&&null!=h.cursorBidiLevel&&(h.cursorBidiLevel=r.bidiLevel)}else if(t.extend){t.collapse(l.node,l.offset);try{t.extend(a.node,a.offset)}catch(t){}}else{let e=document.createRange();r.anchor>r.head&&([l,a]=[a,l]),e.setEnd(a.node,a.offset),e.setStart(l.node,l.offset),t.removeAllRanges(),t.addRange(e)}else;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(l,a)),this.impreciseAnchor=l.precise?null:new DOMPos(h.anchorNode,h.anchorOffset),this.impreciseHead=a.precise?null:new DOMPos(h.focusNode,h.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=getSelection(t.root),{anchorNode:o,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let n=LineView.find(this,e.head);if(!n)return;let r=n.posAtStart;if(e.head==r||e.head==r+n.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(e.head+e.assoc);i.collapse(h.node,h.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(o,s)}nearest(t){for(let e=t;e;){let t=ContentView.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof LineView)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){for(let i=this.length,o=this.children.length-1;;o--){let s=this.children[o],n=i-s.breakAfter-s.length;if(t>n||t==n&&s.type!=BlockType.WidgetBefore&&s.type!=BlockType.WidgetAfter&&(!o||2==e||this.children[o-1].breakAfter||this.children[o-1].type==BlockType.WidgetBefore&&e>-2))return s.coordsAt(t-n,e);i=n}}measureVisibleLineHeights(t){let e=[],{from:i,to:o}=t,s=this.view.contentDOM.clientWidth,n=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,l=this.view.textDirection==Direction.LTR;for(let t=0,a=0;a<this.children.length;a++){let h=this.children[a],c=t+h.length;if(c>o)break;if(t>=i){let i=h.dom.getBoundingClientRect();if(e.push(i.height),n){let e=h.dom.lastChild,o=e?clientRectsFor(e):[];if(o.length){let e=o[o.length-1],n=l?e.right-i.left:i.right-e.left;n>r&&(r=n,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+h.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?Direction.RTL:Direction.LTR}measureTextSize(){for(let t of this.children)if(t instanceof LineView){let e=t.measureTextSize();if(e)return e}let t,e,i,o=document.createElement("div");return o.className="cm-line",o.style.width="99999px",o.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(o);let s=clientRectsFor(o.firstChild)[0];t=o.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,o.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new ChildCursor(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,o=0;;o++){let s=o==e.viewports.length?null:e.viewports[o],n=s?s.from-1:this.length;if(n>i){let o=e.lineBlockAt(n).bottom-e.lineBlockAt(i).top;t.push(Decoration.replace({widget:new BlockGapWidget(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,n))}if(!s)break;i=s.to+1}return Decoration.set(t)}updateDeco(){let t=this.view.state.facet(decorations).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...t,this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){let e,{range:i}=t,o=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!o)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(o={left:Math.min(o.left,e.left),top:Math.min(o.top,e.top),right:Math.max(o.right,e.right),bottom:Math.max(o.bottom,e.bottom)});let s=0,n=0,r=0,l=0;for(let t of this.view.state.facet(scrollMargins).map((t=>t(this.view))))if(t){let{left:e,right:i,top:o,bottom:a}=t;null!=e&&(s=Math.max(s,e)),null!=i&&(n=Math.max(n,i)),null!=o&&(r=Math.max(r,o)),null!=a&&(l=Math.max(l,a))}let a={left:o.left-s,top:o.top-r,right:o.right+n,bottom:o.bottom+l};scrollRectIntoView(this.view.scrollDOM,a,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==Direction.LTR)}}function betweenUneditable(t){return 1==t.node.nodeType&&t.node.firstChild&&(0==t.offset||"false"==t.node.childNodes[t.offset-1].contentEditable)&&(t.offset==t.node.childNodes.length||"false"==t.node.childNodes[t.offset].contentEditable)}class BlockGapWidget extends WidgetType{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}function compositionSurroundingNode(t){let e=t.observer.selectionRange,i=e.focusNode&&nearbyTextNode(e.focusNode,e.focusOffset,0);if(!i)return null;let o=t.docView.nearest(i);if(!o)return null;if(o instanceof LineView){let t=i;for(;t.parentNode!=o.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!ContentView.get(e);)e=e.previousSibling;let s=e?ContentView.get(e).posAtEnd:o.posAtStart;return{from:s,to:s,node:t,text:i}}{for(;;){let{parent:t}=o;if(!t)return null;if(t instanceof LineView)break;o=t}let t=o.posAtStart;return{from:t,to:t+o.length,node:o.dom,text:i}}}function computeCompositionDeco(t,e){let i=compositionSurroundingNode(t);if(!i)return Decoration.none;let{from:o,to:s,node:n,text:r}=i,l=e.mapPos(o,1),a=Math.max(l,e.mapPos(s,-1)),{state:h}=t,c=3==n.nodeType?n.nodeValue:new DOMReader([],h).readRange(n.firstChild,null).text;if(a-l<c.length)if(h.doc.sliceString(l,Math.min(h.doc.length,l+c.length),LineBreakPlaceholder)==c)a=l+c.length;else{if(h.doc.sliceString(Math.max(0,a-c.length),a,LineBreakPlaceholder)!=c)return Decoration.none;l=a-c.length}else if(h.doc.sliceString(l,a,LineBreakPlaceholder)!=c)return Decoration.none;let d=ContentView.get(n);return d instanceof CompositionView?d=d.widget.topView:d&&(d.parent=null),Decoration.set(Decoration.replace({widget:new CompositionWidget(n,r,d),inclusive:!0}).range(l,a))}class CompositionWidget extends WidgetType{constructor(t,e,i){super(),this.top=t,this.text=e,this.topView=i}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return CompositionView}}function nearbyTextNode(t,e,i){if(i<=0)for(let i=t,o=e;;){if(3==i.nodeType)return i;if(!(1==i.nodeType&&o>0))break;i=i.childNodes[o-1],o=maxOffset(i)}if(i>=0)for(let o=t,s=e;;){if(3==o.nodeType)return o;if(!(1==o.nodeType&&s<o.childNodes.length&&i>=0))break;o=o.childNodes[s],s=0}return null}function nextToUneditable(t,e){return 1!=t.nodeType?0:(e&&"false"==t.childNodes[e-1].contentEditable?1:0)|(e<t.childNodes.length&&"false"==t.childNodes[e].contentEditable?2:0)}class DecorationComparator$1{constructor(){this.changes=[]}compareRange(t,e){addRange(t,e,this.changes)}comparePoint(t,e){addRange(t,e,this.changes)}}function findChangedDeco(t,e,i){let o=new DecorationComparator$1;return RangeSet.compare(t,e,i,o),o.changes}function inUneditable(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}function groupAt(t,e,i=1){let o=t.charCategorizer(e),s=t.doc.lineAt(e),n=e-s.from;if(0==s.length)return EditorSelection.cursor(e);0==n?i=1:n==s.length&&(i=-1);let r=n,l=n;i<0?r=findClusterBreak(s.text,n,!1):l=findClusterBreak(s.text,n);let a=o(s.text.slice(r,l));for(;r>0;){let t=findClusterBreak(s.text,r,!1);if(o(s.text.slice(t,r))!=a)break;r=t}for(;l<s.length;){let t=findClusterBreak(s.text,l);if(o(s.text.slice(l,t))!=a)break;l=t}return EditorSelection.range(r+s.from,l+s.from)}function getdx(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function getdy(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function yOverlap(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function upTop(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function upBot(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function domPosAtCoords(t,e,i){let o,s,n,r,l,a,h,c,d=!1;for(let u=t.firstChild;u;u=u.nextSibling){let t=clientRectsFor(u);for(let p=0;p<t.length;p++){let f=t[p];s&&yOverlap(s,f)&&(f=upTop(upBot(f,s.bottom),s.top));let g=getdx(e,f),m=getdy(i,f);if(0==g&&0==m)return 3==u.nodeType?domPosInText(u,e,i):domPosAtCoords(u,e,i);if(!o||r>m||r==m&&n>g){o=u,s=f,n=g,r=m;let l=m?i<f.top?-1:1:g?e<f.left?-1:1:0;d=!l||(l>0?p<t.length-1:p>0)}0==g?i>f.bottom&&(!h||h.bottom<f.bottom)?(l=u,h=f):i<f.top&&(!c||c.top>f.top)&&(a=u,c=f):h&&yOverlap(h,f)?h=upBot(h,f.bottom):c&&yOverlap(c,f)&&(c=upTop(c,f.top))}}if(h&&h.bottom>=i?(o=l,s=h):c&&c.top<=i&&(o=a,s=c),!o)return{node:t,offset:0};let u=Math.max(s.left,Math.min(s.right,e));return 3==o.nodeType?domPosInText(o,u,i):d&&"false"!=o.contentEditable?domPosAtCoords(o,u,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,o)+(e>=(s.left+s.right)/2?1:0)}}function domPosInText(t,e,i){let o=t.nodeValue.length,s=-1,n=1e9,r=0;for(let l=0;l<o;l++){let o=textRange(t,l,l+1).getClientRects();for(let a=0;a<o.length;a++){let h=o[a];if(h.top==h.bottom)continue;r||(r=e-h.left);let c=(h.top>i?h.top-i:i-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c<n){let i=e>=(h.left+h.right)/2,o=i;if(browser.chrome||browser.gecko){textRange(t,l).getBoundingClientRect().left==h.right&&(o=!i)}if(c<=0)return{node:t,offset:l+(o?1:0)};s=l+(o?1:0),n=c}}}return{node:t,offset:s>-1?s:r>0?t.nodeValue.length:0}}function posAtCoords(t,e,i,o=-1){var s,n;let r,l=t.contentDOM.getBoundingClientRect(),a=l.top+t.viewState.paddingTop,{docHeight:h}=t.viewState,{x:c,y:d}=e,u=d-a;if(u<0)return 0;if(u>h)return t.state.doc.length;for(let e=t.defaultLineHeight/2,s=!1;r=t.elementAtHeight(u),r.type!=BlockType.Text;)for(;u=o>0?r.bottom+e:r.top-e,!(u>=0&&u<=h);){if(s)return i?null:0;s=!0,o=-o}d=a+u;let p=r.from;if(p<t.viewport.from)return 0==t.viewport.from?0:i?null:posAtCoordsImprecise(t,l,r,c,d);if(p>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:posAtCoordsImprecise(t,l,r,c,d);let f=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:f,m=g.elementFromPoint(c,d);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(l.left+1,Math.min(l.right-1,c)),m=g.elementFromPoint(c,d),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(f.caretPositionFromPoint){let t=f.caretPositionFromPoint(c,d);t&&({offsetNode:w,offset:v}=t)}else if(f.caretRangeFromPoint){let e=f.caretRangeFromPoint(c,d);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||browser.safari&&isSuspiciousSafariCaretResult(w,v,c)||browser.chrome&&isSuspiciousChromeCaretResult(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=LineView.find(t.docView,p);if(!e)return u>r.top+r.height/2?r.to:r.from;({node:w,offset:v}=domPosAtCoords(e.dom,c,d))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(n=y.dom)||void 0===n?void 0:n.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function posAtCoordsImprecise(t,e,i,o,s){let n=Math.round((o-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){n+=Math.floor((s-i.top)/t.defaultLineHeight)*t.viewState.heightOracle.lineLength}let r=t.state.sliceDoc(i.from,i.to);return i.from+findColumn(r,n,t.state.tabSize)}function isSuspiciousSafariCaretResult(t,e,i){let o;if(3!=t.nodeType||e!=(o=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return textRange(t,o-1,o).getBoundingClientRect().left>i}function isSuspiciousChromeCaretResult(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}return i-(1==t.nodeType?t.getBoundingClientRect():textRange(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}function moveToLineBoundary(t,e,i,o){let s=t.state.doc.lineAt(e.head),n=o&&t.lineWrapping?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(n){let e=t.dom.getBoundingClientRect(),o=t.textDirectionAt(s.from),r=t.posAtCoords({x:i==(o==Direction.LTR)?e.right-1:e.left+1,y:(n.top+n.bottom)/2});if(null!=r)return EditorSelection.cursor(r,i?-1:1)}let r=LineView.find(t.docView,e.head),l=r?i?r.posAtEnd:r.posAtStart:i?s.to:s.from;return EditorSelection.cursor(l,i?-1:1)}function moveByChar(t,e,i,o){let s=t.state.doc.lineAt(e.head),n=t.bidiSpans(s),r=t.textDirectionAt(s.from);for(let l=e,a=null;;){let e=moveVisually(s,n,r,l,i),h=movedOver;if(!e){if(s.number==(i?t.state.doc.lines:1))return l;h="\n",s=t.state.doc.line(s.number+(i?1:-1)),n=t.bidiSpans(s),e=EditorSelection.cursor(i?s.from:s.to)}if(a){if(!a(h))return l}else{if(!o)return e;a=o(h)}l=e}}function byGroup(t,e,i){let o=t.state.charCategorizer(e),s=o(i);return t=>{let e=o(t);return s==CharCategory.Space&&(s=e),s==e}}function moveVertically(t,e,i,o){let s=e.head,n=i?1:-1;if(s==(i?t.state.doc.length:0))return EditorSelection.cursor(s,e.assoc);let r,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s),c=t.documentTop;if(h)null==l&&(l=h.left-a.left),r=n<0?h.top:h.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),r=(n<0?e.top:e.bottom)+c}let d=a.left+l,u=null!=o?o:t.defaultLineHeight>>1;for(let i=0;;i+=10){let o=r+(u+i)*n,h=posAtCoords(t,{x:d,y:o},!1,n);if(o<a.top||o>a.bottom||(n<0?h<s:h>s))return EditorSelection.cursor(h,e.assoc,void 0,l)}}function skipAtoms(t,e,i){let o=t.state.facet(atomicRanges).map((e=>e(t)));for(;;){let t=!1;for(let s of o)s.between(i.from-1,i.from+1,((o,s,n)=>{i.from>o&&i.from<s&&(i=e.head>i.from?EditorSelection.cursor(o,1):EditorSelection.cursor(s,-1),t=!0)}));if(!t)return i}}class InputState{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let e=(e,i)=>{this.ignoreDuringComposition(i)||"keydown"==i.type&&this.keydown(t,i)||(this.mustFlushObserver(i)&&t.observer.forceFlush(),this.runCustomHandlers(i.type,t,i)?i.preventDefault():e(t,i))};for(let i in handlers){let o=handlers[i];t.contentDOM.addEventListener(i,(i=>{eventBelongsToEditor(t,i)&&e(o,i)}),handlerOptions[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",(i=>{if(i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&(e(handlers.mousedown,i),!i.defaultPrevented&&2==i.button)){let e=t.contentDOM.style.minHeight;t.contentDOM.style.minHeight="100%",setTimeout((()=>t.contentDOM.style.minHeight=e),200)}})),browser.chrome&&102==browser.chrome_version&&t.scrollDOM.addEventListener("wheel",(()=>{this.chromeScrollHack<0?t.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout((()=>{this.chromeScrollHack=-1,t.contentDOM.style.pointerEvents=""}),100)}),{passive:!0}),this.notifiedFocused=t.hasFocus,browser.safari&&t.contentDOM.addEventListener("input",(()=>null))}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t,e){var i;let o;this.customHandlers=[];for(let s of e)if(o=null===(i=s.update(t).spec)||void 0===i?void 0:i.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:o});for(let e in o)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),t.contentDOM.addEventListener(e,(i=>{eventBelongsToEditor(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()})))}}runCustomHandlers(t,e,i){for(let o of this.customHandlers){let s=o.handlers[t];if(s)try{if(s.call(o.plugin,i,e)||i.defaultPrevented)return!0}catch(t){logException(e.state,t)}}return!1}runScrollHandlers(t,e){this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft;for(let i of this.customHandlers){let o=i.handlers.scroll;if(o)try{o.call(i.plugin,e,t)}catch(e){logException(t.state,e)}}}keydown(t,e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(browser.android&&browser.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!browser.ios||e.synthetic||e.altKey||e.metaKey||!((i=PendingKeys.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||EmacsyPendingKeys.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey))&&(this.pendingIOSKey=i||e,setTimeout((()=>this.flushIOSKey(t)),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,dispatchKey(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(browser.safari&&!browser.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const PendingKeys=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],EmacsyPendingKeys="dthko",modifierCodes=[16,17,18,20,91,92,224,225],dragScrollMargin=6;function dragScrollSpeed(t){return.7*Math.max(0,t)+8}class MouseSelection{constructor(t,e,i,o){this.view=t,this.style=i,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=scrollableParent(t.contentDOM);let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(EditorState.allowMultipleSelections)&&addsSelectionRange(t,e),this.dragMove=dragMovesSelection(t,e),this.dragging=!(!isInPrimarySelection(t,e)||1!=getClickType(e))&&null}start(t){!1===this.dragging&&(t.preventDefault(),this.select(t))}move(t){var e;if(0==t.buttons)return this.destroy();if(!1!==this.dragging)return;this.select(this.lastEvent=t);let i=0,o=0,s=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight};t.clientX<=s.left+6?i=-dragScrollSpeed(s.left-t.clientX):t.clientX>=s.right-6&&(i=dragScrollSpeed(t.clientX-s.right)),t.clientY<=s.top+6?o=-dragScrollSpeed(s.top-t.clientY):t.clientY>=s.bottom-6&&(o=dragScrollSpeed(t.clientY-s.bottom)),this.setScrollSpeed(i,o)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}select(t){let e=this.style.get(t,this.extend,this.multiple);!this.mustSelect&&e.eq(this.view.state.selection)&&e.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:e,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function addsSelectionRange(t,e){let i=t.state.facet(clickAddsSelectionRange);return i.length?i[0](e):browser.mac?e.metaKey:e.ctrlKey}function dragMovesSelection(t,e){let i=t.state.facet(dragMovesSelection$1);return i.length?i[0](e):browser.mac?!e.altKey:!e.ctrlKey}function isInPrimarySelection(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let o=getSelection(t.root);if(!o||0==o.rangeCount)return!0;let s=o.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}function eventBelongsToEditor(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,o=e.target;o!=t.contentDOM;o=o.parentNode)if(!o||11==o.nodeType||(i=ContentView.get(o))&&i.ignoreEvent(e))return!1;return!0}const handlers=Object.create(null),handlerOptions=Object.create(null),brokenClipboardAPI=browser.ie&&browser.ie_version<15||browser.ios&&browser.webkit_version<604;function capturePaste(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),doPaste(t,i.value)}),50)}function doPaste(t,e){let i,{state:o}=t,s=1,n=o.toText(e),r=n.lines==o.selection.ranges.length;if(null!=lastLinewiseCopy&&o.selection.ranges.every((t=>t.empty))&&lastLinewiseCopy==n.toString()){let t=-1;i=o.changeByRange((i=>{let l=o.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=o.toText((r?n.line(s++).text:e)+o.lineBreak);return{changes:{from:l.from,insert:a},range:EditorSelection.cursor(i.from+a.length)}}))}else i=r?o.changeByRange((t=>{let e=n.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:EditorSelection.cursor(t.from+e.length)}})):o.replaceSelection(n);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function rangeForClick(t,e,i,o){if(1==o)return EditorSelection.cursor(e,i);if(2==o)return groupAt(t.state,e,i);{let i=LineView.find(t.docView,e),o=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:o.from,n=i?i.posAtEnd:o.to;return n<t.state.doc.length&&n==o.to&&n++,EditorSelection.range(s,n)}}handlers.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode?t.inputState.lastEscPress=Date.now():modifierCodes.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0)},handlers.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},handlers.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},handlerOptions.touchstart=handlerOptions.touchmove={passive:!0},handlers.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let i=null;for(let o of t.state.facet(mouseSelectionStyle))if(i=o(t,e),i)break;if(i||0!=e.button||(i=basicMouseSelection(t,e)),i){let o=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new MouseSelection(t,e,i,o)),o&&t.observer.ignore((()=>focusPreventScroll(t.contentDOM))),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let insideY=(t,e)=>t>=e.top&&t<=e.bottom,inside=(t,e,i)=>insideY(e,i)&&t>=i.left&&t<=i.right;function findPositionSide(t,e,i,o){let s=LineView.find(t.docView,e);if(!s)return 1;let n=e-s.posAtStart;if(0==n)return 1;if(n==s.length)return-1;let r=s.coordsAt(n,-1);if(r&&inside(i,o,r))return-1;let l=s.coordsAt(n,1);return l&&inside(i,o,l)?1:r&&insideY(o,r)?-1:1}function queryPos(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:findPositionSide(t,i,e.clientX,e.clientY)}}const BadMouseDetail=browser.ie&&browser.ie_version<=11;let lastMouseDown=null,lastMouseDownCount=0,lastMouseDownTime=0;function getClickType(t){if(!BadMouseDetail)return t.detail;let e=lastMouseDown,i=lastMouseDownTime;return lastMouseDown=t,lastMouseDownTime=Date.now(),lastMouseDownCount=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(lastMouseDownCount+1)%3:1}function basicMouseSelection(t,e){let i=queryPos(t,e),o=getClickType(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,n,r){let l,a=queryPos(t,e),h=rangeForClick(t,a.pos,a.bias,o);if(i.pos!=a.pos&&!n){let e=rangeForClick(t,i.pos,i.bias,o),s=Math.min(e.from,h.from),n=Math.max(e.to,h.to);h=s<h.from?EditorSelection.range(s,n):EditorSelection.range(n,s)}return n?s.replaceRange(s.main.extend(h.from,h.to)):r&&1==o&&s.ranges.length>1&&(l=removeRangeAround(s,a.pos))?l:r?s.addRange(h):EditorSelection.create([h])}}}function removeRangeAround(t,e){for(let i=0;i<t.ranges.length;i++){let{from:o,to:s}=t.ranges[i];if(o<=e&&s>=e)return EditorSelection.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}function dropText(t,e,i,o){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:n}=t.inputState,r=o&&n&&n.dragging&&n.dragMove?{from:n.dragging.from,to:n.dragging.to}:null,l={from:s,insert:i},a=t.state.changes(r?[r,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:r?"move.drop":"input.drop"})}function captureCopy(t,e){let i=t.dom.parentNode;if(!i)return;let o=i.appendChild(document.createElement("textarea"));o.style.cssText="position: fixed; left: -10000px; top: 10px",o.value=e,o.focus(),o.selectionEnd=e.length,o.selectionStart=0,setTimeout((()=>{o.remove(),t.focus()}),50)}function copiedRange(t){let e=[],i=[],o=!1;for(let o of t.selection.ranges)o.empty||(e.push(t.sliceDoc(o.from,o.to)),i.push(o));if(!e.length){let s=-1;for(let{from:o}of t.selection.ranges){let n=t.doc.lineAt(o);n.number>s&&(e.push(n.text),i.push({from:n.from,to:Math.min(t.doc.length,n.to+1)})),s=n.number}o=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:o}}handlers.dragstart=(t,e)=>{let{selection:{main:i}}=t.state,{mouseSelection:o}=t.inputState;o&&(o.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},handlers.drop=(t,e)=>{if(!e.dataTransfer)return;if(t.state.readOnly)return e.preventDefault();let i=e.dataTransfer.files;if(i&&i.length){e.preventDefault();let o=Array(i.length),s=0,n=()=>{++s==i.length&&dropText(t,e,o.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=n,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(o[t]=e.result),n()},e.readAsText(i[t])}}else dropText(t,e,e.dataTransfer.getData("Text"),!0)},handlers.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=brokenClipboardAPI?null:e.clipboardData;i?(doPaste(t,i.getData("text/plain")||i.getData("text/uri-text")),e.preventDefault()):capturePaste(t)};let lastLinewiseCopy=null;handlers.copy=handlers.cut=(t,e)=>{let{text:i,ranges:o,linewise:s}=copiedRange(t.state);if(!i&&!s)return;lastLinewiseCopy=s?i:null;let n=brokenClipboardAPI?null:e.clipboardData;n?(e.preventDefault(),n.clearData(),n.setData("text/plain",i)):captureCopy(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:o,scrollIntoView:!0,userEvent:"delete.cut"})};const isFocusChange=Annotation.define();function focusChangeTransaction(t,e){let i=[];for(let o of t.facet(focusChangeEffect)){let s=o(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:isFocusChange.of(!0)}):null}function updateForFocusChange(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=focusChangeTransaction(t.state,e);i?t.dispatch(i):t.update([])}}),10)}handlers.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),updateForFocusChange(t)},handlers.blur=t=>{t.observer.clearSelectionRange(),updateForFocusChange(t)},handlers.compositionstart=handlers.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},handlers.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,browser.chrome&&browser.android&&t.observer.flushSoon(),setTimeout((()=>{t.inputState.composing<0&&t.docView.compositionDeco.size&&t.update([])}),50)},handlers.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},handlers.beforeinput=(t,e)=>{var i;let o;if(browser.chrome&&browser.android&&(o=PendingKeys.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(o.key,o.keyCode),"Backspace"==o.key||"Delete"==o.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}};const wrappingWhiteSpace=["pre-wrap","normal","pre-line","break-spaces"];class HeightOracle{constructor(t){this.lineWrapping=t,this.doc=Text.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return wrappingWhiteSpace.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let o=t[i];o<0?i++:this.heightSamples[Math.floor(10*o)]||(e=!0,this.heightSamples[Math.floor(10*o)]=!0)}return e}refresh(t,e,i,o,s,n){let r=wrappingWhiteSpace.indexOf(t)>-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=o,this.lineLength=s,l){this.heightSamples={};for(let t=0;t<n.length;t++){let e=n[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return l}}class MeasuredHeights{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class BlockInfo{constructor(t,e,i,o,s){this.from=t,this.length=e,this.top=i,this.height=o,this.type=s}get to(){return this.from+this.length}get bottom(){return this.top+this.height}join(t){let e=(Array.isArray(this.type)?this.type:[this]).concat(Array.isArray(t.type)?t.type:[t]);return new BlockInfo(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var QueryType=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(QueryType||(QueryType={}));const Epsilon=.001;class HeightMap{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>.001&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return HeightMap.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,o){let s=this,n=i.doc;for(let r=o.length-1;r>=0;r--){let{fromA:l,toA:a,fromB:h,toB:c}=o[r],d=s.lineAt(l,QueryType.ByPosNoHeight,i.setDoc(e),0,0),u=d.to>=a?d:s.lineAt(a,QueryType.ByPosNoHeight,i,0,0);for(c+=u.to-a,a=u.to;r>0&&d.from<=o[r-1].toA;)l=o[r-1].fromA,h=o[r-1].fromB,r--,l<d.from&&(d=s.lineAt(l,QueryType.ByPosNoHeight,i,0,0));h+=d.from-l,l=d.from;let p=NodeBuilder.build(i.setDoc(n),t,h,c);s=s.replace(l,a,p)}return s.updateHeight(i,0)}static empty(){return new HeightMapText(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,o=0,s=0;for(;;)if(e==i)if(o>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,o-=s.size}else{if(!(s>2*o))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(o<s){let i=t[e++];i&&(o+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let n=0;return null==t[e-1]?(n=1,e--):null==t[e]&&(n=1,i++),new HeightMapBranch(HeightMap.of(t.slice(0,e)),n,HeightMap.of(t.slice(i)))}}HeightMap.prototype.size=1;class HeightMapBlock extends HeightMap{constructor(t,e,i){super(t,e),this.type=i}blockAt(t,e,i,o){return new BlockInfo(o,this.length,i,this.height,this.type)}lineAt(t,e,i,o,s){return this.blockAt(0,i,o,s)}forEachLine(t,e,i,o,s,n){t<=s+this.length&&e>=s&&n(this.blockAt(0,i,o,s))}updateHeight(t,e=0,i=!1,o){return o&&o.from<=e&&o.more&&this.setHeight(t,o.heights[o.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class HeightMapText extends HeightMapBlock{constructor(t,e){super(t,e,BlockType.Text),this.collapsed=0,this.widgetHeight=0}replace(t,e,i){let o=i[0];return 1==i.length&&(o instanceof HeightMapText||o instanceof HeightMapGap&&4&o.flags)&&Math.abs(this.length-o.length)<10?(o instanceof HeightMapGap?o=new HeightMapText(o.length,this.height):o.height=this.height,this.outdated||(o.outdated=!1),o):HeightMap.of(i)}updateHeight(t,e=0,i=!1,o){return o&&o.from<=e&&o.more?this.setHeight(t,o.heights[o.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class HeightMapGap extends HeightMap{constructor(t){super(t,0)}heightMetrics(t,e){let i,o=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,n=s-o+1,r=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*n);i=e/n,this.length>n+1&&(r=(this.height-e)/(this.length-n-1))}else i=this.height/n;return{firstLine:o,lastLine:s,perLine:i,perChar:r}}blockAt(t,e,i,o){let{firstLine:s,lastLine:n,perLine:r,perChar:l}=this.heightMetrics(e,o);if(e.lineWrapping){let s=o+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),n=e.doc.lineAt(s),a=r+n.length*l,h=Math.max(i,t-a/2);return new BlockInfo(n.from,n.length,h,a,BlockType.Text)}{let o=Math.max(0,Math.min(n-s,Math.floor((t-i)/r))),{from:l,length:a}=e.doc.line(s+o);return new BlockInfo(l,a,i+r*o,r,BlockType.Text)}}lineAt(t,e,i,o,s){if(e==QueryType.ByHeight)return this.blockAt(t,i,o,s);if(e==QueryType.ByPosNoHeight){let{from:e,to:o}=i.doc.lineAt(t);return new BlockInfo(e,o-e,0,0,BlockType.Text)}let{firstLine:n,perLine:r,perChar:l}=this.heightMetrics(i,s),a=i.doc.lineAt(t),h=r+a.length*l,c=a.number-n,d=o+r*c+l*(a.from-s-c);return new BlockInfo(a.from,a.length,Math.max(o,Math.min(d,o+this.height-h)),h,BlockType.Text)}forEachLine(t,e,i,o,s,n){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:r,perLine:l,perChar:a}=this.heightMetrics(i,s);for(let h=t,c=o;h<=e;){let e=i.doc.lineAt(h);if(h==t){let i=e.number-r;c+=l*i+a*(t-s-i)}let o=l+a*e.length;n(new BlockInfo(e.from,e.length,c,o,BlockType.Text)),c+=o,h=e.to+1}}replace(t,e,i){let o=this.length-e;if(o>0){let t=i[i.length-1];t instanceof HeightMapGap?i[i.length-1]=new HeightMapGap(t.length+o):i.push(null,new HeightMapGap(o-1))}if(t>0){let e=i[0];e instanceof HeightMapGap?i[0]=new HeightMapGap(t+e.length):i.unshift(new HeightMapGap(t-1),null)}return HeightMap.of(i)}decomposeLeft(t,e){e.push(new HeightMapGap(t-1),null)}decomposeRight(t,e){e.push(null,new HeightMapGap(this.length-t-1))}updateHeight(t,e=0,i=!1,o){let s=e+this.length;if(o&&o.from<=e+this.length&&o.more){let i=[],n=Math.max(e,o.from),r=-1;for(o.from>e&&i.push(new HeightMapGap(o.from-e-1).updateHeight(t,e));n<=s&&o.more;){let e=t.doc.lineAt(n).length;i.length&&i.push(null);let s=o.heights[o.index++];-1==r?r=s:Math.abs(s-r)>=.001&&(r=-2);let l=new HeightMapText(e,s);l.outdated=!1,i.push(l),n+=e+1}n<=s&&i.push(null,new HeightMapGap(s-n).updateHeight(t,n));let l=HeightMap.of(i);return(r<0||Math.abs(l.height-this.height)>=.001||Math.abs(r-this.heightMetrics(t,e).perLine)>=.001)&&(t.heightChanged=!0),l}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class HeightMapBranch extends HeightMap{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,o){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,o):this.right.blockAt(t,e,s,o+this.left.length+this.break)}lineAt(t,e,i,o,s){let n=o+this.left.height,r=s+this.left.length+this.break,l=e==QueryType.ByHeight?t<n:t<r,a=l?this.left.lineAt(t,e,i,o,s):this.right.lineAt(t,e,i,n,r);if(this.break||(l?a.to<r:a.from>r))return a;let h=e==QueryType.ByPosNoHeight?QueryType.ByPosNoHeight:QueryType.ByPos;return l?a.join(this.right.lineAt(r,h,i,n,r)):this.left.lineAt(r,h,i,o,s).join(a)}forEachLine(t,e,i,o,s,n){let r=o+this.left.height,l=s+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,o,s,n),e>=l&&this.right.forEachLine(t,e,i,r,l,n);else{let a=this.lineAt(l,QueryType.ByPos,i,o,s);t<a.from&&this.left.forEachLine(t,a.from-1,i,o,s,n),a.to>=t&&a.from<=e&&n(a),e>a.to&&this.right.forEachLine(a.to+1,e,i,r,l,n)}}replace(t,e,i){let o=this.left.length+this.break;if(e<o)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-o,e-o,i));let s=[];t>0&&this.decomposeLeft(t,s);let n=s.length;for(let t of i)s.push(t);if(t>0&&mergeGaps(s,n-1),e<this.length){let t=s.length;this.decomposeRight(e,s),mergeGaps(s,t)}return HeightMap.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,o=i+this.break;if(t>=o)return this.right.decomposeRight(t-o,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<o&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?HeightMap.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,o){let{left:s,right:n}=this,r=e+s.length+this.break,l=null;return o&&o.from<=e+s.length&&o.more?l=s=s.updateHeight(t,e,i,o):s.updateHeight(t,e,i),o&&o.from<=r+n.length&&o.more?l=n=n.updateHeight(t,r,i,o):n.updateHeight(t,r,i),l?this.balanced(s,n):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function mergeGaps(t,e){let i,o;null==t[e]&&(i=t[e-1])instanceof HeightMapGap&&(o=t[e+1])instanceof HeightMapGap&&t.splice(e-1,3,new HeightMapGap(i.length+1+o.length))}const relevantWidgetHeight=5;class NodeBuilder{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof HeightMapText?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new HeightMapText(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let o=i.widget?i.widget.estimatedHeight:0;o<0&&(o=this.oracle.lineHeight);let s=e-t;i.block?this.addBlock(new HeightMapBlock(s,o,i.type)):(s||o>=5)&&this.addLineDeco(o,s)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new HeightMapText(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new HeightMapGap(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof HeightMapText)return t;let e=new HeightMapText(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine(),t.type!=BlockType.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=BlockType.WidgetBefore&&(this.covering=t)}addLineDeco(t,e){let i=this.ensureLine();i.length+=e,i.collapsed+=e,i.widgetHeight=Math.max(i.widgetHeight,t),this.writtenTo=this.pos=this.pos+e}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof HeightMapText||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new HeightMapText(0,-1));let i=t;for(let t of this.nodes)t instanceof HeightMapText&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,o){let s=new NodeBuilder(i,t);return RangeSet.spans(e,i,o,s,0),s.finish(i)}}function heightRelevantDecoChanges(t,e,i){let o=new DecorationComparator;return RangeSet.compare(t,e,i,o,0),o.changes}class DecorationComparator{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,o){(t<e||i&&i.heightRelevant||o&&o.heightRelevant)&&addRange(t,e,this.changes,5)}}function visiblePixelRange(t,e){let i=t.getBoundingClientRect(),o=t.ownerDocument,s=o.defaultView||window,n=Math.max(0,i.left),r=Math.min(s.innerWidth,i.right),l=Math.max(0,i.top),a=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=o.body;)if(1==e.nodeType){let i=e,o=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=o.overflow){let o=i.getBoundingClientRect();n=Math.max(n,o.left),r=Math.min(r,o.right),l=Math.max(l,o.top),a=e==t.parentNode?o.bottom:Math.min(a,o.bottom)}e="absolute"==o.position||"fixed"==o.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:n-i.left,right:Math.max(n,r)-i.left,top:l-(i.top+e),bottom:Math.max(l,a)-(i.top+e)}}function fullPixelRange(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class LineGap{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let o=t[i],s=e[i];if(o.from!=s.from||o.to!=s.to||o.size!=s.size)return!1}return!0}draw(t){return Decoration.replace({widget:new LineGapWidget(this.size,t)}).range(this.from,this.to)}}class LineGapWidget extends WidgetType{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class ViewState{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaler=IdScaler,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Direction.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(contentAttributes).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new HeightOracle(e),this.stateDeco=t.facet(decorations).filter((t=>"function"!=typeof t)),this.heightMap=HeightMap.empty().applyChanges(this.stateDeco,Text.empty,this.heightOracle.setDoc(t.doc),[new ChangedRange(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Decoration.set(this.lineGaps.map((t=>t.draw(!1)))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let o=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>o>=t&&o<=e))){let{from:e,to:i}=this.lineBlockAt(o);t.push(new Viewport(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?IdScaler:new BigScaler(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:scaleBlock(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(decorations).filter((t=>"function"!=typeof t));let o=t.changedRanges,s=ChangedRange.extendWithRanges(o,heightRelevantDecoChanges(i,this.stateDeco,t?t.changes:ChangeSet.empty(this.state.doc.length))),n=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=n&&(t.flags|=2);let r=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<r.from||e.range.head>r.to)||!this.viewportIsAppropriate(r))&&(r=this.getViewport(0,e));let l=!t.changes.empty||2&t.flags||r.from!=this.viewport.from||r.to!=this.viewport.to;this.viewport=r,this.updateForViewport(),l&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(nativeSelectionHidden)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),o=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Direction.RTL:Direction.LTR;let n=this.heightOracle.mustRefreshForWrapping(s),r=e.getBoundingClientRect(),l=n||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let a=0,h=0,c=parseInt(i.paddingTop)||0,d=parseInt(i.paddingBottom)||0;this.paddingTop==c&&this.paddingBottom==d||(this.paddingTop=c,this.paddingBottom=d,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(o.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let u=(this.printing?fullPixelRange:visiblePixelRange)(e,this.paddingTop),p=u.top-this.pixelViewport.top,f=u.bottom-this.pixelViewport.bottom;this.pixelViewport=u;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let m=r.width;if(this.contentDOMWidth==m&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=r.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(e)&&(n=!0),n||o.lineWrapping&&Math.abs(m-this.contentDOMWidth)>o.charWidth){let{lineHeight:i,charWidth:r,textHeight:l}=t.docView.measureTextSize();n=i>0&&o.refresh(s,i,r,l,m/r,e),n&&(t.docView.minWidth=0,a|=8)}p>0&&f>0?h=Math.max(p,f):p<0&&f<0&&(h=Math.min(p,f)),o.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(n?HeightMap.empty().applyChanges(this.stateDeco,Text.empty,this.heightOracle,[new ChangedRange(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(o,0,n,new MeasuredHeights(i.from,s))}o.heightChanged&&(a|=2)}let w=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return w&&(this.viewport=this.getViewport(h,this.scrollTarget)),this.updateForViewport(),(2&a||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(n?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),o=this.heightMap,s=this.heightOracle,{visibleTop:n,visibleBottom:r}=this,l=new Viewport(o.lineAt(n-1e3*i,QueryType.ByHeight,s,0,0).from,o.lineAt(r+1e3*(1-i),QueryType.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let i,n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=o.lineAt(t,QueryType.ByPos,s,0,0);i="center"==e.y?(r.top+r.bottom)/2-n/2:"start"==e.y||"nearest"==e.y&&t<l.from?r.top:r.bottom-n,l=new Viewport(o.lineAt(i-500,QueryType.ByHeight,s,0,0).from,o.lineAt(i+n+500,QueryType.ByHeight,s,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),o=e.mapPos(t.to,1);return new Viewport(this.heightMap.lineAt(i,QueryType.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(o,QueryType.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:o}=this.heightMap.lineAt(t,QueryType.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,QueryType.ByPos,this.heightOracle,0,0),{visibleTop:n,visibleBottom:r}=this;return(0==t||o<=n-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=r+Math.max(10,Math.min(i,250)))&&o>n-2e3&&s<r+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let o of t)e.touchesRange(o.from,o.to)||i.push(new LineGap(e.mapPos(o.from),e.mapPos(o.to),o.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,o=i?1e4:2e3,s=o>>1,n=o<<1;if(this.defaultTextDirection!=Direction.LTR&&!i)return[];let r=[],l=(o,n,a,h)=>{if(n-o<s)return;let c=this.state.selection.main,d=[c.from];c.empty||d.push(c.to);for(let t of d)if(t>o&&t<n)return l(o,t-10,a,h),void l(t+10,n,a,h);let u=find(t,(t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-o)<s&&Math.abs(t.to-n)<s&&!d.some((e=>t.from<e&&t.to>e))));if(!u){if(n<a.to&&e&&i&&e.visibleRanges.some((t=>t.from<=n&&t.to>=n))){let t=e.moveToLineBoundary(EditorSelection.cursor(n),!1,!0).head;t>o&&(n=t)}u=new LineGap(o,n,this.gapSize(a,o,n,h))}r.push(u)};for(let t of this.viewportLines){if(t.length<n)continue;let e=lineStructure(t.from,t.to,this.stateDeco);if(e.total<n)continue;let s,r,a=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,n,l=o/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=a){let o=findFraction(e,a),s=((this.visibleBottom-this.visibleTop)/2+l)/t.height;i=o-s,n=o+s}else i=(this.visibleTop-t.top-l)/t.height,n=(this.visibleBottom-t.top+l)/t.height;s=findPosition(e,i),r=findPosition(e,n)}else{let t,i,n=e.total*this.heightOracle.charWidth,l=o*this.heightOracle.charWidth;if(null!=a){let o=findFraction(e,a),s=((this.pixelViewport.right-this.pixelViewport.left)/2+l)/n;t=o-s,i=o+s}else t=(this.pixelViewport.left-l)/n,i=(this.pixelViewport.right+l)/n;s=findPosition(e,t),r=findPosition(e,i)}s>t.from&&l(t.from,s,t,e),r<t.to&&l(r,t.to,t,e)}return r}gapSize(t,e,i,o){let s=findFraction(o,i)-findFraction(o,e);return this.heightOracle.lineWrapping?t.height*s:o.total*this.heightOracle.charWidth*s}updateLineGaps(t){LineGap.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Decoration.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];RangeSet.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||scaleBlock(this.heightMap.lineAt(t,QueryType.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(t),QueryType.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Viewport{constructor(t,e){this.from=t,this.to=e}}function lineStructure(t,e,i){let o=[],s=t,n=0;return RangeSet.spans(i,t,e,{span(){},point(t,e){t>s&&(o.push({from:s,to:t}),n+=t-s),s=e}},20),s<e&&(o.push({from:s,to:e}),n+=e-s),{total:n,ranges:o}}function findPosition({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let o=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],n=s-i;if(o<=n)return i+o;o-=n}}function findFraction(t,e){let i=0;for(let{from:o,to:s}of t.ranges){if(e<=s){i+=e-o;break}i+=s-o}return i/t.total}function find(t,e){for(let i of t)if(e(i))return i}const IdScaler={toDOM:t=>t,fromDOM:t=>t,scale:1};class BigScaler{constructor(t,e,i){let o=0,s=0,n=0;this.viewports=i.map((({from:i,to:s})=>{let n=e.lineAt(i,QueryType.ByPos,t,0,0).top,r=e.lineAt(s,QueryType.ByPos,t,0,0).bottom;return o+=r-n,{from:i,to:s,top:n,bottom:r,domTop:0,domBottom:0}})),this.scale=(7e6-o)/(e.height-o);for(let t of this.viewports)t.domTop=n+(t.top-s)*this.scale,n=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,o=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return o+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,o=s.domBottom}}fromDOM(t){for(let e=0,i=0,o=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-o)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,o=s.domBottom}}}function scaleBlock(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),o=e.toDOM(t.bottom);return new BlockInfo(t.from,t.length,i,o-i,Array.isArray(t.type)?t.type.map((t=>scaleBlock(t,e))):t.type)}const theme=Facet.define({combine:t=>t.join(" ")}),darkTheme=Facet.define({combine:t=>t.indexOf(!0)>-1}),baseThemeID=StyleModule.newName(),baseLightID=StyleModule.newName(),baseDarkID=StyleModule.newName(),lightDarkIDs={"&light":"."+baseLightID,"&dark":"."+baseDarkID};function buildTheme(t,e,i){return new StyleModule(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const baseTheme$1=buildTheme("."+baseThemeID,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},lightDarkIDs);class DOMChange{constructor(t,e,i,o){this.typeOver=o,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:n}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||n?[]:selectionPoints(t),i=new DOMReader(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=selectionFromPoints(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!contains(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),o=n&&n.node==e.anchorNode&&n.offset==e.anchorOffset||!contains(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=EditorSelection.single(o,i)}}}function applyDOMChange(t,e){let i,{newSel:o}=e,s=t.state.selection.main;if(e.bounds){let{from:o,to:n}=e.bounds,r=s.from,l=null;(8===t.inputState.lastKeyCode&&t.inputState.lastKeyTime>Date.now()-100||browser.android&&e.text.length<n-o)&&(r=s.to,l="end");let a=findDiff(t.state.doc.sliceString(o,n,LineBreakPlaceholder),e.text,r-o,l);a&&(browser.chrome&&13==t.inputState.lastKeyCode&&a.toB==a.from+2&&e.text.slice(a.from,a.toB)==LineBreakPlaceholder+LineBreakPlaceholder&&a.toB--,i={from:o+a.from,to:o+a.toA,insert:Text.of(e.text.slice(a.from,a.toB).split(LineBreakPlaceholder))})}else o&&(!t.hasFocus&&t.state.facet(editable)||o.main.eq(s))&&(o=null);if(!i&&!o)return!1;if(!i&&e.typeOver&&!s.empty&&o&&o.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(browser.mac||browser.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(o&&2==i.insert.length&&(o=EditorSelection.single(o.main.anchor-1,o.main.head-1)),i={from:s.from,to:s.to,insert:Text.of([" "])}):browser.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(o&&(o=EditorSelection.single(o.main.anchor-1,o.main.head-1)),i={from:s.from,to:s.to,insert:Text.of([" "])}),i){let e=t.state;if(browser.ios&&t.inputState.flushIOSKey(t))return!0;if(browser.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&dispatchKey(t.contentDOM,"Enter",13)||i.from==s.from-1&&i.to==s.to&&0==i.insert.length&&dispatchKey(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&dispatchKey(t.contentDOM,"Delete",46)))return!0;let n,r=i.insert.toString();if(t.state.facet(inputHandler).some((e=>e(t,i.from,i.to,r))))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=s.from&&i.to<=s.to&&i.to-i.from>=(s.to-s.from)/3&&(!o||o.main.empty&&o.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let o=s.from<i.from?e.sliceDoc(s.from,i.from):"",r=s.to>i.to?e.sliceDoc(i.to,s.to):"";n=e.replaceSelection(t.state.toText(o+i.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=e.changes(i),l=o&&o.main.to<=r.newLength?o.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=s.to&&i.to>=s.to-10){let o=t.state.sliceDoc(i.from,i.to),a=compositionSurroundingNode(t)||t.state.doc.lineAt(s.head),h=s.to-i.to,c=s.to-s.from;n=e.changeByRange((n=>{if(n.from==s.from&&n.to==s.to)return{changes:r,range:l||n.map(r)};let d=n.to-h,u=d-o.length;if(n.to-n.from!=c||t.state.sliceDoc(u,d)!=o||a&&n.to>=a.from&&n.from<=a.to)return{range:n};let p=e.changes({from:u,to:d,insert:i.insert}),f=n.to-s.to;return{changes:p,range:l?EditorSelection.range(Math.max(0,l.anchor+f),Math.max(0,l.head+f)):n.map(p)}}))}else n={changes:r,selection:l&&e.selection.replaceRange(l)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(n,{scrollIntoView:!0,userEvent:l}),!0}if(o&&!o.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:o,scrollIntoView:e,userEvent:i}),!0}return!1}function findDiff(t,e,i,o){let s=Math.min(t.length,e.length),n=0;for(;n<s&&t.charCodeAt(n)==e.charCodeAt(n);)n++;if(n==s&&t.length==e.length)return null;let r=t.length,l=e.length;for(;r>0&&l>0&&t.charCodeAt(r-1)==e.charCodeAt(l-1);)r--,l--;if("end"==o){i-=r+Math.max(0,n-Math.min(r,l))-n}if(r<n&&t.length<e.length){n-=i<=n&&i>=r?n-i:0,l=n+(l-r),r=n}else if(l<n){n-=i<=n&&i>=l?n-i:0,r=n+(r-l),l=n}return{from:n,toA:r,toB:l}}function selectionPoints(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:n}=t.observer.selectionRange;return i&&(e.push(new DOMPoint(i,o)),s==i&&n==o||e.push(new DOMPoint(s,n))),e}function selectionFromPoints(t,e){if(0==t.length)return null;let i=t[0].pos,o=2==t.length?t[1].pos:i;return i>-1&&o>-1?EditorSelection.single(i+e,o+e):null}const observeOptions={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},useCharData=browser.ie&&browser.ie_version<=11;class DOMObserver{constructor(t){this.view=t,this.active=!1,this.selectionRange=new DOMSelectionState,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(browser.ie&&browser.ie_version<=11||browser.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),useCharData&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM),this.resizeContent=new ResizeObserver((()=>this.view.requestMeasure())),this.resizeContent.observe(t.contentDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runScrollHandlers(this.view,t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,o=this.selectionRange;if(i.state.facet(editable)?i.root.activeElement!=this.dom:!hasSelection(i.dom,o))return;let s=o.anchorNode&&i.docView.nearest(o.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(browser.ie&&browser.ie_version<=11||browser.android&&browser.chrome)&&!i.state.selection.main.empty&&o.focusNode&&isEquivalentPosition(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=browser.safari&&11==t.root.nodeType&&deepActiveElement(this.dom.ownerDocument)==this.dom&&safariSelectionRangeHack(this.view)||getSelection(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=hasSelection(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&atElementStart(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,observeOptions),useCharData&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),useCharData&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),!this.flush()&&t.force&&dispatchKey(this.dom,t.key,t.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,o=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(o=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:o}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),o=this.selectionChanged&&hasSelection(this.dom,this.selectionRange);return t<0&&!o?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new DOMChange(this.view,t,e,i))}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return!1;let i=this.view.state,o=applyDOMChange(this.view,e);return this.view.state==i&&this.view.update([]),o}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.dirty|=4),"childList"==t.type){let i=findChild(e,t.previousSibling||t.target.previousSibling,-1),o=findChild(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:o?e.posBefore(o):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i,o;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),null===(o=this.resizeContent)||void 0===o||o.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function findChild(t,e,i){for(;e;){let o=ContentView.get(e);if(o&&o.parent==t)return o;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function safariSelectionRangeHack(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let o=e.startContainer,s=e.startOffset,n=e.endContainer,r=e.endOffset,l=t.docView.domAtPos(t.state.selection.main.anchor);return isEquivalentPosition(l.node,l.offset,n,r)&&([o,s,n,r]=[n,r,o,s]),{anchorNode:o,anchorOffset:s,focusNode:n,focusOffset:r}}class EditorView{constructor(t={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: fixed; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=t.root||getRoot(t.parent)||document,this.viewState=new ViewState(t.state||EditorState.create(t)),this.plugins=this.state.facet(viewPlugin).map((t=>new PluginInstance(t)));for(let t of this.plugins)t.update(this);this.observer=new DOMObserver(this),this.inputState=new InputState(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new DocView(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...t){this._dispatch(1==t.length&&t[0]instanceof Transaction?t[0]:this.state.update(...t))}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,o=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let n=this.hasFocus,r=0,l=null;t.some((t=>t.annotation(isFocusChange)))?(this.inputState.notifiedFocused=n,r=1):n!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=n,l=focusChangeTransaction(s,n),l||(r=1));let a=this.observer.delayedAndroidKey,h=null;if(a?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(EditorState.phrases)!=this.state.facet(EditorState.phrases))return this.setState(s);e=ViewUpdate.create(this,s,t),e.flags|=r;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new ScrollTarget(t.empty?t:EditorSelection.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(scrollIntoView)&&(c=t.value)}this.viewState.update(e,c),this.bidiCache=CachedOrder.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(styleModule)!=this.styleModules&&this.mountStyles(),o=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(theme)!=e.state.facet(theme)&&(this.viewState.mustMeasureContent=!0),(i||o||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(updateListener))t(e);(l||h)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!applyDOMChange(this,h)&&a.force&&dispatchKey(this.contentDOM,a.key,a.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new ViewState(t),this.plugins=t.facet(viewPlugin).map((t=>new PluginInstance(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new DocView(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(viewPlugin),i=t.state.facet(viewPlugin);if(e!=i){let o=[];for(let s of i){let i=e.indexOf(s);if(i<0)o.push(new PluginInstance(s));else{let e=this.plugins[i];e.mustUpdate=t,o.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=o,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this)}measure(t=!0){if(this.destroyed)return;this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,{scrollHeight:i,scrollTop:o,clientHeight:s}=this.scrollDOM,n=o>i-s-4?i:o;try{for(let t=0;;t++){this.updateState=1;let i=this.viewport,o=this.viewState.lineBlockAtHeight(n),s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let r=[];4&s||([this.measureRequests,r]=[r,this.measureRequests]);let l=r.map((t=>{try{return t.read(this)}catch(t){return logException(this.state,t),BadMeasure}})),a=ViewUpdate.create(this,this.state,[]),h=!1,c=!1;a.flags|=s,e?e.flags|=s:e=a,this.updateState=2,a.empty||(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),h=this.docView.update(a));for(let t=0;t<r.length;t++)if(l[t]!=BadMeasure)try{let e=r[t];e.write&&e.write(l[t],this)}catch(t){logException(this.state,t)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,c=!0;else{let t=this.viewState.lineBlockAt(o.from).top-o.top;(t>1||t<-1)&&(this.scrollDOM.scrollTop+=t,c=!0)}if(h&&this.docView.updateSelection(!0),this.viewport.from==i.from&&this.viewport.to==i.to&&!c&&0==this.measureRequests.length)break}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(updateListener))t(e)}get themeClasses(){return baseThemeID+" "+(this.state.facet(darkTheme)?baseDarkID:baseLightID)+" "+this.state.facet(theme)}updateAttrs(){let t=attrsFromFacet(this,editorAttributes,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(editable)?"true":"false",class:"cm-content",style:`${browser.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),attrsFromFacet(this,contentAttributes,e);let i=this.observer.ignore((()=>{let i=updateAttrs(this.contentDOM,this.contentAttrs,e),o=updateAttrs(this.dom,this.editorAttrs,t);return i||o}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(EditorView.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(styleModule),StyleModule.mount(this.root,this.styleModules.concat(baseTheme$1).reverse())}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return skipAtoms(this,t,moveByChar(this,t,e,i))}moveByGroup(t,e){return skipAtoms(this,t,moveByChar(this,t,e,(e=>byGroup(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return moveToLineBoundary(this,t,e,i)}moveVertically(t,e,i){return skipAtoms(this,t,moveVertically(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),posAtCoords(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let o=this.state.doc.lineAt(t),s=this.bidiSpans(o);return flattenRect(i,s[BidiSpan.find(s,t-o.from,-1,e)].dir==Direction.LTR==e>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(perLineTextDirection)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>MaxBidiLine)return trivialOrder(t.length);let e=this.textDirectionAt(t.from);for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e)return i.order;let i=computeOrder(t.text,e);return this.bidiCache.push(new CachedOrder(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||browser.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{focusPreventScroll(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return scrollIntoView.of(new ScrollTarget("number"==typeof t?EditorSelection.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return ViewPlugin.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=StyleModule.newName(),o=[theme.of(i),styleModule.of(buildTheme(`.${i}`,t))];return e&&e.dark&&o.push(darkTheme.of(!0)),o}static baseTheme(t){return Prec.lowest(styleModule.of(buildTheme("."+baseThemeID,t,lightDarkIDs)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),o=i&&ContentView.get(i)||ContentView.get(t);return(null===(e=null==o?void 0:o.rootView)||void 0===e?void 0:e.view)||null}}EditorView.styleModule=styleModule,EditorView.inputHandler=inputHandler,EditorView.focusChangeEffect=focusChangeEffect,EditorView.perLineTextDirection=perLineTextDirection,EditorView.exceptionSink=exceptionSink,EditorView.updateListener=updateListener,EditorView.editable=editable,EditorView.mouseSelectionStyle=mouseSelectionStyle,EditorView.dragMovesSelection=dragMovesSelection$1,EditorView.clickAddsSelectionRange=clickAddsSelectionRange,EditorView.decorations=decorations,EditorView.atomicRanges=atomicRanges,EditorView.scrollMargins=scrollMargins,EditorView.darkTheme=darkTheme,EditorView.contentAttributes=contentAttributes,EditorView.editorAttributes=editorAttributes,EditorView.lineWrapping=EditorView.contentAttributes.of({class:"cm-lineWrapping"}),EditorView.announce=StateEffect.define();const MaxBidiLine=4096,BadMeasure={};class CachedOrder{constructor(t,e,i,o){this.from=t,this.to=e,this.dir=i,this.order=o}static update(t,e){if(e.empty)return t;let i=[],o=t.length?t[t.length-1].dir:Direction.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let n=t[s];n.dir!=o||e.touchesRange(n.from,n.to)||i.push(new CachedOrder(e.mapPos(n.from,1),e.mapPos(n.to,-1),n.dir,n.order))}return i}}function attrsFromFacet(t,e,i){for(let o=t.state.facet(e),s=o.length-1;s>=0;s--){let e=o[s],n="function"==typeof e?e(t):e;n&&combineAttrs(n,i)}return i}const currentPlatform=browser.mac?"mac":browser.windows?"win":browser.linux?"linux":"key";function normalizeKeyName(t,e){const i=t.split(/-(?!$)/);let o,s,n,r,l=i[i.length-1];"Space"==l&&(l=" ");for(let t=0;t<i.length-1;++t){const l=i[t];if(/^(cmd|meta|m)$/i.test(l))r=!0;else if(/^a(lt)?$/i.test(l))o=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))n=!0;else{if(!/^mod$/i.test(l))throw new Error("Unrecognized modifier name: "+l);"mac"==e?r=!0:s=!0}}return o&&(l="Alt-"+l),s&&(l="Ctrl-"+l),r&&(l="Meta-"+l),n&&(l="Shift-"+l),l}function modifiers(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}const handleKeyEvents=Prec.default(EditorView.domEventHandlers({keydown:(t,e)=>runHandlers(getKeymap(e.state),t,e,"editor")})),keymap=Facet.define({enables:handleKeyEvents}),Keymaps=new WeakMap;function getKeymap(t){let e=t.facet(keymap),i=Keymaps.get(e);return i||Keymaps.set(e,i=buildKeymap(e.reduce(((t,e)=>t.concat(e)),[]))),i}function runScopeHandlers(t,e,i){return runHandlers(getKeymap(t.state),e,t,i)}let storedPrefix=null;const PrefixTimeout=4e3;function buildKeymap(t,e=currentPlatform){let i=Object.create(null),o=Object.create(null),s=(t,e)=>{let i=o[t];if(null==i)o[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},n=(t,o,n,r)=>{var l,a;let h=i[t]||(i[t]=Object.create(null)),c=o.split(/ (?!$)/).map((t=>normalizeKeyName(t,e)));for(let e=1;e<c.length;e++){let i=c.slice(0,e).join(" ");s(i,!0),h[i]||(h[i]={preventDefault:!0,run:[e=>{let o=storedPrefix={view:e,prefix:i,scope:t};return setTimeout((()=>{storedPrefix==o&&(storedPrefix=null)}),PrefixTimeout),!0}]})}let d=c.join(" ");s(d,!1);let u=h[d]||(h[d]={preventDefault:!1,run:(null===(a=null===(l=h._any)||void 0===l?void 0:l.run)||void 0===a?void 0:a.slice())||[]});n&&u.run.push(n),r&&(u.preventDefault=!0)};for(let o of t){let t=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,run:[]});for(let e in t)t[e].run.push(o.any)}let s=o[e]||o.key;if(s)for(let e of t)n(e,s,o.run,o.preventDefault),o.shift&&n(e,"Shift-"+s,o.shift,o.preventDefault)}return i}function runHandlers(t,e,i,o){let s=keyName(e),n=codePointAt(s,0),r=codePointSize(n)==s.length&&" "!=s,l="",a=!1;storedPrefix&&storedPrefix.view==i&&storedPrefix.scope==o&&(l=storedPrefix.prefix+" ",(a=modifierCodes.indexOf(e.keyCode)<0)&&(storedPrefix=null));let h,c,d=new Set,u=t=>{if(t){for(let o of t.run)if(!d.has(o)&&(d.add(o),o(i,e)))return!0;t.preventDefault&&(a=!0)}return!1},p=t[o];if(p){if(u(p[l+modifiers(s,e,!r)]))return!0;if(r&&(e.altKey||e.metaKey||e.ctrlKey)&&!(browser.windows&&e.ctrlKey&&e.altKey)&&(h=base[e.keyCode])&&h!=s){if(u(p[l+modifiers(h,e,!0)]))return!0;if(e.shiftKey&&(c=shift[e.keyCode])!=s&&c!=h&&u(p[l+modifiers(c,e,!1)]))return!0}else if(r&&e.shiftKey&&u(p[l+modifiers(s,e,!0)]))return!0;if(u(p._any))return!0}return a}class RectangleMarker{constructor(t,e,i,o,s){this.className=t,this.left=e,this.top=i,this.width=o,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(i.empty){let o=t.coordsAtPos(i.head,i.assoc||1);if(!o)return[];let s=getBase(t);return[new RectangleMarker(e,o.left-s.left,o.top-s.top,null,o.bottom-o.top)]}return rectanglesForRange(t,e,i)}}function getBase(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Direction.LTR?e.left:e.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,top:e.top-t.scrollDOM.scrollTop}}function wrappedLine(t,e,i){let o=EditorSelection.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(o,!1,!0).from),to:Math.min(i.to,t.moveToLineBoundary(o,!0,!0).from),type:BlockType.Text}}function blockAt(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==BlockType.Text))return t;return i}function rectanglesForRange(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let o=Math.max(i.from,t.viewport.from),s=Math.min(i.to,t.viewport.to),n=t.textDirection==Direction.LTR,r=t.contentDOM,l=r.getBoundingClientRect(),a=getBase(t),h=r.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),d=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),p=blockAt(t,o),f=blockAt(t,s),g=p.type==BlockType.Text?p:null,m=f.type==BlockType.Text?f:null;if(t.lineWrapping&&(g&&(g=wrappedLine(t,o,g)),m&&(m=wrappedLine(t,s,m))),g&&m&&g.from==m.from)return v(y(i.from,i.to,g));{let e=g?y(i.from,null,g):b(p,!1),o=m?y(null,i.to,m):b(f,!0),s=[];return(g||p).to<(m||f).from-1?s.push(w(d,e.bottom,u,o.top)):e.bottom<o.top&&t.elementAtHeight((e.bottom+o.top)/2).type==BlockType.Text&&(e.bottom=o.top=(e.bottom+o.top)/2),v(e).concat(s).concat(v(o))}function w(t,i,o,s){return new RectangleMarker(e,t-a.left,i-a.top-.01,o-t,s-i+.01)}function v({top:t,bottom:e,horizontal:i}){let o=[];for(let s=0;s<i.length;s+=2)o.push(w(i[s],t,i[s+1],e));return o}function y(e,i,o){let s=1e9,r=-1e9,l=[];function a(e,i,a,h,c){let p=t.coordsAtPos(e,e==o.to?-2:2),f=t.coordsAtPos(a,a==o.from?2:-2);s=Math.min(p.top,f.top,s),r=Math.max(p.bottom,f.bottom,r),c==Direction.LTR?l.push(n&&i?d:p.left,n&&h?u:f.right):l.push(!n&&h?d:f.left,!n&&i?u:p.right)}let h=null!=e?e:o.from,c=null!=i?i:o.to;for(let o of t.visibleRanges)if(o.to>h&&o.from<c)for(let s=Math.max(o.from,h),n=Math.min(o.to,c);;){let o=t.state.doc.lineAt(s);for(let r of t.bidiSpans(o)){let t=r.from+o.from,l=r.to+o.from;if(t>=n)break;l>s&&a(Math.max(t,s),null==e&&t<=h,Math.min(l,n),null==i&&l>=c,r.dir)}if(s=o.to+1,s>=n)break}return 0==l.length&&a(h,null==e,c,null==i,t.textDirection),{top:s,bottom:r,horizontal:l}}function b(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}function sameMarker(t,e){return t.constructor==e.constructor&&t.eq(e)}class LayerView{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(layerOrder)!=t.state.facet(layerOrder)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&t.view.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(layerOrder);for(;e<i.length&&i[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}draw(t){if(t.length!=this.drawn.length||t.some(((t,e)=>!sameMarker(t,this.drawn[e])))){let e=this.dom.firstChild,i=0;for(let o of t)o.update&&e&&o.constructor&&this.drawn[i].constructor&&o.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(o.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const layerOrder=Facet.define();function layer(t){return[ViewPlugin.define((e=>new LayerView(e,t))),layerOrder.of(t)]}const CanHidePrimary=!browser.ios,selectionConfig=Facet.define({combine:t=>combineConfig(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function drawSelection(t={}){return[selectionConfig.of(t),cursorLayer,selectionLayer,hideNativeSelection,nativeSelectionHidden.of(!0)]}function configChanged(t){return t.startState.facet(selectionConfig)!=t.state.facet(selectionConfig)}const cursorLayer=layer({above:!0,markers(t){let{state:e}=t,i=e.facet(selectionConfig),o=[];for(let s of e.selection.ranges){let n=s==e.selection.main;if(s.empty?!n||CanHidePrimary:i.drawRangeCursor){let e=n?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=s.empty?s:EditorSelection.cursor(s.head,s.head>s.anchor?-1:1);for(let s of RectangleMarker.forRange(t,e,i))o.push(s)}}return o},update(t,e){t.transactions.some((t=>t.selection))&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let i=configChanged(t);return i&&setBlinkRate(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){setBlinkRate(e.state,t)},class:"cm-cursorLayer"});function setBlinkRate(t,e){e.style.animationDuration=t.facet(selectionConfig).cursorBlinkRate+"ms"}const selectionLayer=layer({above:!1,markers:t=>t.state.selection.ranges.map((e=>e.empty?[]:RectangleMarker.forRange(t,"cm-selectionBackground",e))).reduce(((t,e)=>t.concat(e))),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||configChanged(t),class:"cm-selectionLayer"}),themeSpec={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};CanHidePrimary&&(themeSpec[".cm-line"].caretColor="transparent !important");const hideNativeSelection=Prec.highest(EditorView.theme(themeSpec)),setDropCursorPos=StateEffect.define({map:(t,e)=>null==t?null:e.mapPos(t)}),dropCursorPos=StateField.define({create:()=>null,update:(t,e)=>(null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce(((t,e)=>e.is(setDropCursorPos)?e.value:t),t))}),drawDropCursor=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let i=t.state.field(dropCursorPos);null==i?null!=this.cursor&&(null===(e=this.cursor)||void 0===e||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(dropCursorPos)!=i||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let t=this.view.state.field(dropCursorPos),e=null!=t&&this.view.coordsAtPos(t);if(!e)return null;let i=this.view.scrollDOM.getBoundingClientRect();return{left:e.left-i.left+this.view.scrollDOM.scrollLeft,top:e.top-i.top+this.view.scrollDOM.scrollTop,height:e.bottom-e.top}}drawCursor(t){this.cursor&&(t?(this.cursor.style.left=t.left+"px",this.cursor.style.top=t.top+"px",this.cursor.style.height=t.height+"px"):this.cursor.style.left="-100000px")}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(dropCursorPos)!=t&&this.view.dispatch({effects:setDropCursorPos.of(t)})}},{eventHandlers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function dropCursor(){return[dropCursorPos,drawDropCursor]}function iterMatches(t,e,i,o,s){e.lastIndex=0;for(let n,r=t.iterRange(i,o),l=i;!r.next().done;l+=r.value.length)if(!r.lineBreak)for(;n=e.exec(r.value);)s(l+n.index,n)}function matchRanges(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let o=[];for(let{from:s,to:n}of i)s=Math.max(t.state.doc.lineAt(s).from,s-e),n=Math.min(t.state.doc.lineAt(n).to,n+e),o.length&&o[o.length-1].to>=s?o[o.length-1].to=n:o.push({from:s,to:n});return o}class MatchDecorator{constructor(t){const{regexp:e,decoration:i,decorate:o,boundary:s,maxLength:n=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,o)this.addMatch=(t,e,i,s)=>o(s,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,o,s)=>{let n=i(t,e,o);n&&s(o,o+t[0].length,n)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(t,e,o,s)=>s(o,o+t[0].length,i)}this.boundary=s,this.maxLength=n}createDeco(t){let e=new RangeSetBuilder,i=e.add.bind(e);for(let{from:e,to:o}of matchRanges(t,this.maxLength))iterMatches(t.state.doc,this.regexp,e,o,((e,o)=>this.addMatch(o,t,e,i)));return e.finish()}updateDeco(t,e){let i=1e9,o=-1;return t.docChanged&&t.changes.iterChanges(((e,s,n,r)=>{r>t.view.viewport.from&&n<t.view.viewport.to&&(i=Math.min(n,i),o=Math.max(r,o))})),t.viewportChanged||o-i>1e3?this.createDeco(t.view):o>-1?this.updateRange(t.view,e.map(t.changes),i,o):e}updateRange(t,e,i,o){for(let s of t.visibleRanges){let n=Math.max(s.from,i),r=Math.min(s.to,o);if(r>n){let i=t.state.doc.lineAt(n),o=i.to<r?t.state.doc.lineAt(r):i,l=Math.max(s.from,i.from),a=Math.min(s.to,o.to);if(this.boundary){for(;n>i.from;n--)if(this.boundary.test(i.text[n-1-i.from])){l=n;break}for(;r<o.to;r++)if(this.boundary.test(o.text[r-o.from])){a=r;break}}let h,c=[],d=(t,e,i)=>c.push(i.range(t,e));if(i==o)for(this.regexp.lastIndex=l-i.from;(h=this.regexp.exec(i.text))&&h.index<a-i.from;)this.addMatch(h,t,h.index+i.from,d);else iterMatches(t.state.doc,this.regexp,l,a,((e,i)=>this.addMatch(i,t,e,d)));e=e.update({filterFrom:l,filterTo:a,filter:(t,e)=>t<l||e>a,add:c})}}return e}}const UnicodeRegexpSupport=null!=/x/.unicode?"gu":"g",Specials=new RegExp("[\0-\b\n--ÂŸÂØœâ€‹â€Žâ€\u2028\u2029â€â€®â¦â§â©\ufeff-]",UnicodeRegexpSupport),Names={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let _supportsTabSize=null;function supportsTabSize(){var t;if(null==_supportsTabSize&&"undefined"!=typeof document&&document.body){let e=document.body.style;_supportsTabSize=null!=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)}return _supportsTabSize||!1}const specialCharConfig=Facet.define({combine(t){let e=combineConfig(t,{render:null,specialChars:Specials,addSpecialChars:null});return(e.replaceTabs=!supportsTabSize())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,UnicodeRegexpSupport)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,UnicodeRegexpSupport)),e}});function highlightSpecialChars(t={}){return[specialCharConfig.of(t),specialCharPlugin()]}let _plugin=null;function specialCharPlugin(){return _plugin||(_plugin=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.decorations=Decoration.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(specialCharConfig)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new MatchDecorator({regexp:t.specialChars,decoration:(e,i,o)=>{let{doc:s}=i.state,n=codePointAt(e[0],0);if(9==n){let t=s.lineAt(o),e=i.state.tabSize,n=countColumn(t.text,e,o-t.from);return Decoration.replace({widget:new TabWidget((e-n%e)*this.view.defaultCharacterWidth)})}return this.decorationCache[n]||(this.decorationCache[n]=Decoration.replace({widget:new SpecialCharWidget(t,n)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(specialCharConfig);t.startState.facet(specialCharConfig)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const DefaultPlaceholder="•";function placeholder$1(t){return t>=32?"•":10==t?"â¤":String.fromCharCode(9216+t)}class SpecialCharWidget extends WidgetType{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=placeholder$1(this.code),i=t.state.phrase("Control character")+" "+(Names[this.code]||"0x"+this.code.toString(16)),o=this.options.render&&this.options.render(this.code,i,e);if(o)return o;let s=document.createElement("span");return s.textContent=e,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class TabWidget extends WidgetType{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent="\t",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}const plugin=ViewPlugin.fromClass(class{constructor(){this.height=1e3,this.attrs={style:"padding-bottom: 1000px"}}update(t){let{view:e}=t,i=e.viewState.editorHeight-e.defaultLineHeight-e.documentPadding.top-.5;i!=this.height&&(this.height=i,this.attrs={style:`padding-bottom: ${i}px`})}});function scrollPastEnd(){return[plugin,contentAttributes.of((t=>{var e;return(null===(e=t.plugin(plugin))||void 0===e?void 0:e.attrs)||null}))]}function highlightActiveLine(){return activeLineHighlighter}const lineDeco=Decoration.line({class:"cm-activeLine"}),activeLineHighlighter=ViewPlugin.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let o of t.state.selection.ranges){let s=t.lineBlockAt(o.head);s.from>e&&(i.push(lineDeco.range(s.from)),e=s.from)}return Decoration.set(i)}},{decorations:t=>t.decorations});class Placeholder extends WidgetType{constructor(t){super(),this.content=t}toDOM(){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):this.content),"string"==typeof this.content?t.setAttribute("aria-label","placeholder "+this.content):t.setAttribute("aria-hidden","true"),t}ignoreEvent(){return!1}}function placeholder(t){return ViewPlugin.fromClass(class{constructor(e){this.view=e,this.placeholder=Decoration.set([Decoration.widget({widget:new Placeholder(t),side:1}).range(0)])}get decorations(){return this.view.state.doc.length?Decoration.none:this.placeholder}},{decorations:t=>t.decorations})}const MaxOff=2e3;function rectangleFor(t,e,i){let o=Math.min(e.line,i.line),s=Math.max(e.line,i.line),n=[];if(e.off>MaxOff||i.off>MaxOff||e.col<0||i.col<0){let r=Math.min(e.off,i.off),l=Math.max(e.off,i.off);for(let e=o;e<=s;e++){let i=t.doc.line(e);i.length<=l&&n.push(EditorSelection.range(i.from+r,i.to+l))}}else{let r=Math.min(e.col,i.col),l=Math.max(e.col,i.col);for(let e=o;e<=s;e++){let i=t.doc.line(e),o=findColumn(i.text,r,t.tabSize,!0);if(o<0)n.push(EditorSelection.cursor(i.to));else{let e=findColumn(i.text,l,t.tabSize);n.push(EditorSelection.range(i.from+o,i.from+e))}}}return n}function absoluteColumn(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}function getPos(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),o=t.state.doc.lineAt(i),s=i-o.from,n=s>MaxOff?-1:s==o.length?absoluteColumn(t,e.clientX):countColumn(o.text,t.state.tabSize,i-o.from);return{line:o.number,col:n,off:s}}function rectangleSelectionStyle(t,e){let i=getPos(t,e),o=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),s=t.state.doc.lineAt(e);i={line:s.number,col:i.col,off:Math.min(i.off,s.length)},o=o.map(t.changes)}},get(e,s,n){let r=getPos(t,e);if(!r)return o;let l=rectangleFor(t.state,i,r);return l.length?n?EditorSelection.create(l.concat(o.ranges)):EditorSelection.create(l):o}}:null}function rectangularSelection(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return EditorView.mouseSelectionStyle.of(((t,i)=>e(i)?rectangleSelectionStyle(t,i):null))}const keys={Alt:[18,t=>t.altKey],Control:[17,t=>t.ctrlKey],Shift:[16,t=>t.shiftKey],Meta:[91,t=>t.metaKey]},showCrosshair={style:"cursor: crosshair"};function crosshairCursor(t={}){let[e,i]=keys[t.key||"Alt"],o=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventHandlers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(!1)},mousemove(t){this.set(i(t))}}});return[o,EditorView.contentAttributes.of((t=>{var e;return(null===(e=t.plugin(o))||void 0===e?void 0:e.isDown)?showCrosshair:null}))]}const Outside="-10000px";class TooltipViewManager{constructor(t,e,i){this.facet=e,this.createTooltipView=i,this.input=t.state.facet(e),this.tooltips=this.input.filter((t=>t)),this.tooltipViews=this.tooltips.map(i)}update(t){var e;let i=t.state.facet(this.facet),o=i.filter((t=>t));if(i===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let s=[];for(let e=0;e<o.length;e++){let i=o[e],n=-1;if(i){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==i.create&&(n=t)}if(n<0)s[e]=this.createTooltipView(i);else{let i=s[e]=this.tooltipViews[n];i.update&&i.update(t)}}}for(let t of this.tooltipViews)s.indexOf(t)<0&&(t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t));return this.input=i,this.tooltips=o,this.tooltipViews=s,!0}}function tooltips(t={}){return tooltipConfig.of(t)}function windowSpace(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const tooltipConfig=Facet.define({combine:t=>{var e,i,o;return{position:browser.ios?"absolute":(null===(e=t.find((t=>t.position)))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find((t=>t.parent)))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(o=t.find((t=>t.tooltipSpace)))||void 0===o?void 0:o.tooltipSpace)||windowSpace}}}),knownHeight=new WeakMap,tooltipPlugin=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(tooltipConfig);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new TooltipViewManager(t,showTooltip,(t=>this.createTooltip(t))),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver((t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()}),{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout((()=>{this.measureTimeout=-1,this.maybeMeasure()}),50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t);e&&this.observeIntersection();let i=e||t.geometryChanged,o=t.state.facet(tooltipConfig);if(o.position!=this.position){this.position=o.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=!0}if(o.parent!=this.parent){this.parent&&this.container.remove(),this.parent=o.parent,this.createContainer();for(let t of this.manager.tooltipViews)this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t){let e=t.create(this.view);if(e.dom.classList.add("cm-tooltip"),t.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=Outside,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews)e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);null===(e=this.intersectionObserver)||void 0===e||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect();return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,pos:this.manager.tooltips.map(((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)})),size:this.manager.tooltipViews.map((({dom:t})=>t.getBoundingClientRect())),space:this.view.state.facet(tooltipConfig).tooltipSpace(this.view)}}writeMeasure(t){var e;let{editor:i,space:o}=t,s=[];for(let n=0;n<this.manager.tooltips.length;n++){let r=this.manager.tooltips[n],l=this.manager.tooltipViews[n],{dom:a}=l,h=t.pos[n],c=t.size[n];if(!h||h.bottom<=Math.max(i.top,o.top)||h.top>=Math.min(i.bottom,o.bottom)||h.right<Math.max(i.left,o.left)-.1||h.left>Math.min(i.right,o.right)+.1){a.style.top=Outside;continue}let d=r.arrow?l.dom.querySelector(".cm-tooltip-arrow"):null,u=d?7:0,p=c.right-c.left,f=null!==(e=knownHeight.get(l))&&void 0!==e?e:c.bottom-c.top,g=l.offset||noOffset,m=this.view.textDirection==Direction.LTR,w=c.width>o.right-o.left?m?o.left:o.right-c.width:m?Math.min(h.left-(d?14:0)+g.x,o.right-p):Math.max(o.left,h.left-p+(d?14:0)-g.x),v=!!r.above;!r.strictSide&&(v?h.top-(c.bottom-c.top)-g.y<o.top:h.bottom+(c.bottom-c.top)+g.y>o.bottom)&&v==o.bottom-h.bottom>h.top-o.top&&(v=!v);let y=(v?h.top-o.top:o.bottom-h.bottom)-u;if(y<f&&!1!==l.resize){if(y<this.view.defaultLineHeight){a.style.top=Outside;continue}knownHeight.set(l,f),a.style.height=(f=y)+"px"}else a.style.height&&(a.style.height="");let b=v?h.top-f-u-g.y:h.bottom+u+g.y,S=w+p;if(!0!==l.overlap)for(let t of s)t.left<S&&t.right>w&&t.top<b+f&&t.bottom>b&&(b=v?t.top-f-2-u:t.bottom+u+2);"absolute"==this.position?(a.style.top=b-t.parent.top+"px",a.style.left=w-t.parent.left+"px"):(a.style.top=b+"px",a.style.left=w+"px"),d&&(d.style.left=h.left+(m?g.x:-g.x)-(w+14-7)+"px"),!0!==l.overlap&&s.push({left:w,top:b,right:S,bottom:b+f}),a.classList.toggle("cm-tooltip-above",v),a.classList.toggle("cm-tooltip-below",!v),l.positioned&&l.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Outside}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),baseTheme=EditorView.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),noOffset={x:0,y:0},showTooltip=Facet.define({enables:[tooltipPlugin,baseTheme]}),showHoverTooltip=Facet.define();class HoverTooltipHost{constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new TooltipViewManager(t,showHoverTooltip,(t=>this.createHostedView(t)))}static create(t){return new HoverTooltipHost(t)}createHostedView(t){let e=t.create(this.view);return e.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(e.dom),this.mounted&&e.mount&&e.mount(this.view),e}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null===(t=e.destroy)||void 0===t||t.call(e)}}const showHoverTooltipHost=showTooltip.compute([showHoverTooltip],(t=>{let e=t.facet(showHoverTooltip).filter((t=>t));return 0===e.length?null:{pos:Math.min(...e.map((t=>t.pos))),end:Math.max(...e.filter((t=>null!=t.end)).map((t=>t.end))),create:HoverTooltipHost.create,above:e[0].above,arrow:e.some((t=>t.arrow))}}));class HoverPlugin{constructor(t,e,i,o,s){this.view=t,this.source=e,this.field=i,this.setHover=o,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout((()=>this.startHover()),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{lastMove:t}=this,e=this.view.contentDOM.contains(t.target)?this.view.posAtCoords(t):null;if(null==e)return;let i=this.view.coordsAtPos(e);if(null==i||t.y<i.top||t.y>i.bottom||t.x<i.left-this.view.defaultCharacterWidth||t.x>i.right+this.view.defaultCharacterWidth)return;let o=this.view.bidiSpans(this.view.state.doc.lineAt(e)).find((t=>t.from<=e&&t.to>=e)),s=o&&o.dir==Direction.RTL?-1:1,n=this.source(this.view,e,t.x<i.left?-s:s);if(null==n?void 0:n.then){let t=this.pending={pos:e};n.then((e=>{this.pending==t&&(this.pending=null,e&&this.view.dispatch({effects:this.setHover.of(e)}))}),(t=>logException(this.view.state,t,"hover tooltip")))}else n&&this.view.dispatch({effects:this.setHover.of(n)})}mousemove(t){var e;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let i=this.active;if(i&&!isInTooltip(this.lastMove.target)||this.pending){let{pos:o}=i||this.pending,s=null!==(e=null==i?void 0:i.end)&&void 0!==e?e:o;(o==s?this.view.posAtCoords(this.lastMove)==o:isOverRange(this.view,o,s,t.clientX,t.clientY,6))||(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&!isInTooltip(t.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function isInTooltip(t){for(let e=t;e;e=e.parentNode)if(1==e.nodeType&&e.classList.contains("cm-tooltip"))return!0;return!1}function isOverRange(t,e,i,o,s,n){let r=document.createRange(),l=t.domAtPos(e),a=t.domAtPos(i);r.setEnd(a.node,a.offset),r.setStart(l.node,l.offset);let h=r.getClientRects();r.detach();for(let t=0;t<h.length;t++){let e=h[t];if(Math.max(e.top-s,s-e.bottom,e.left-o,o-e.right)<=n)return!0}return!1}function hoverTooltip(t,e={}){let i=StateEffect.define(),o=StateField.define({create:()=>null,update(t,o){if(t&&(e.hideOnChange&&(o.docChanged||o.selection)||e.hideOn&&e.hideOn(o,t)))return null;if(t&&o.docChanged){let e=o.changes.mapPos(t.pos,-1,MapMode.TrackDel);if(null==e)return null;let i=Object.assign(Object.create(null),t);i.pos=e,null!=t.end&&(i.end=o.changes.mapPos(t.end)),t=i}for(let e of o.effects)e.is(i)&&(t=e.value),e.is(closeHoverTooltipEffect)&&(t=null);return t},provide:t=>showHoverTooltip.from(t)});return[o,ViewPlugin.define((s=>new HoverPlugin(s,t,o,i,e.hoverTime||300))),showHoverTooltipHost]}function getTooltip(t,e){let i=t.plugin(tooltipPlugin);if(!i)return null;let o=i.manager.tooltips.indexOf(e);return o<0?null:i.manager.tooltipViews[o]}function hasHoverTooltips(t){return t.facet(showHoverTooltip).some((t=>t))}const closeHoverTooltipEffect=StateEffect.define(),closeHoverTooltips=closeHoverTooltipEffect.of(null);function repositionTooltips(t){var e;null===(e=t.plugin(tooltipPlugin))||void 0===e||e.maybeMeasure()}const panelConfig=Facet.define({combine(t){let e,i;for(let o of t)e=e||o.topContainer,i=i||o.bottomContainer;return{topContainer:e,bottomContainer:i}}});function panels(t){return t?[panelConfig.of(t)]:[]}function getPanel(t,e){let i=t.plugin(panelPlugin),o=i?i.specs.indexOf(e):-1;return o>-1?i.panels[o]:null}const panelPlugin=ViewPlugin.fromClass(class{constructor(t){this.input=t.state.facet(showPanel),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(panelConfig);this.top=new PanelGroup(t,!0,e.topContainer),this.bottom=new PanelGroup(t,!1,e.bottomContainer),this.top.sync(this.panels.filter((t=>t.top))),this.bottom.sync(this.panels.filter((t=>!t.top)));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(t){let e=t.state.facet(panelConfig);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new PanelGroup(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new PanelGroup(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(showPanel);if(i!=this.input){let e=i.filter((t=>t)),o=[],s=[],n=[],r=[];for(let i of e){let e,l=this.specs.indexOf(i);l<0?(e=i(t.view),r.push(e)):(e=this.panels[l],e.update&&e.update(t)),o.push(e),(e.top?s:n).push(e)}this.specs=e,this.panels=o,this.top.sync(s),this.bottom.sync(n);for(let t of r)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>EditorView.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class PanelGroup{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=rm(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=rm(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function rm(t){let e=t.nextSibling;return t.remove(),e}const showPanel=Facet.define({enables:panelPlugin});class GutterMarker extends RangeValue{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}GutterMarker.prototype.elementClass="",GutterMarker.prototype.toDOM=void 0,GutterMarker.prototype.mapMode=MapMode.TrackBefore,GutterMarker.prototype.startSide=GutterMarker.prototype.endSide=-1,GutterMarker.prototype.point=!0;const gutterLineClass=Facet.define(),defaults={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>RangeSet.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},activeGutters=Facet.define();function gutter(t){return[gutters(),activeGutters.of(Object.assign(Object.assign({},defaults),t))]}const unfixGutters=Facet.define({combine:t=>t.some((t=>t))});function gutters(t){let e=[gutterView];return t&&!1===t.fixed&&e.push(unfixGutters.of(!0)),e}const gutterView=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=t.state.facet(activeGutters).map((e=>new SingleGutterView(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(unfixGutters),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,o=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(o<.8*(i.to-i.from))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(unfixGutters)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=RangeSet.iter(this.view.state.facet(gutterLineClass),this.view.viewport.from),o=[],s=this.gutters.map((t=>new UpdateContext(t,this.view.viewport,-this.view.documentPadding.top)));for(let t of this.view.viewportLineBlocks){let e;if(Array.isArray(t.type)){for(let i of t.type)if(i.type==BlockType.Text){e=i;break}}else e=t.type==BlockType.Text?t:void 0;if(e){o.length&&(o=[]),advanceCursor(i,o,t.from);for(let t of s)t.line(this.view,e,o)}}for(let t of s)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(activeGutters),i=t.state.facet(activeGutters),o=t.docChanged||t.heightChanged||t.viewportChanged||!RangeSet.eq(t.startState.facet(gutterLineClass),t.state.facet(gutterLineClass),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(o=!0);else{o=!0;let s=[];for(let o of i){let i=e.indexOf(o);i<0?s.push(new SingleGutterView(this.view,o)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),s.indexOf(t)<0&&t.destroy();for(let t of s)this.dom.appendChild(t.dom);this.gutters=s}return o}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>EditorView.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==Direction.LTR?{left:i.dom.offsetWidth}:{right:i.dom.offsetWidth}:null}))});function asArray(t){return Array.isArray(t)?t:[t]}function advanceCursor(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class UpdateContext{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=RangeSet.iter(t.markers,e.from)}line(t,e,i){let o=[];advanceCursor(this.cursor,o,e.from),i.length&&(o=o.concat(i));let s=this.gutter.config.lineMarker(t,e,o);s&&o.unshift(s);let n=this.gutter;if(0==o.length&&!n.config.renderEmptyElements)return;let r=e.top-this.height;if(this.i==n.elements.length){let i=new GutterElement(t,e.height,r,o);n.elements.push(i),n.dom.appendChild(i.dom)}else n.elements[this.i].update(t,e.height,r,o);this.height=e.bottom,this.i++}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class SingleGutterView{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,(o=>{let s,n=o.target;if(n!=this.dom&&this.dom.contains(n)){for(;n.parentNode!=this.dom;)n=n.parentNode;let t=n.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=o.clientY;let r=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,r,o)&&o.preventDefault()}));this.markers=asArray(e.markers(t)),e.initialSpacer&&(this.spacer=new GutterElement(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=asArray(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!RangeSet.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class GutterElement{constructor(t,e,i,o){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,o)}update(t,e,i,o){this.height!=e&&(this.dom.style.height=(this.height=e)+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),sameMarkers(this.markers,o)||this.setMarkers(t,o)}setMarkers(t,e){let i="cm-gutterElement",o=this.dom.firstChild;for(let s=0,n=0;;){let r=n,l=s<e.length?e[s++]:null,a=!1;if(l){let t=l.elementClass;t&&(i+=" "+t);for(let t=n;t<this.markers.length;t++)if(this.markers[t].compare(l)){r=t,a=!0;break}}else r=this.markers.length;for(;n<r;){let t=this.markers[n++];if(t.toDOM){t.destroy(o);let e=o.nextSibling;o.remove(),o=e}}if(!l)break;l.toDOM&&(a?o=o.nextSibling:this.dom.insertBefore(l.toDOM(t),o)),a&&n++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}function sameMarkers(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}const lineNumberMarkers=Facet.define(),lineNumberConfig=Facet.define({combine:t=>combineConfig(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let o=i[t],s=e[t];i[t]=o?(t,e,i)=>o(t,e,i)||s(t,e,i):s}return i}})});class NumberMarker extends GutterMarker{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function formatNumber(t,e){return t.state.facet(lineNumberConfig).formatNumber(e,t.state)}const lineNumberGutter=activeGutters.compute([lineNumberConfig],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(lineNumberMarkers),lineMarker:(t,e,i)=>i.some((t=>t.toDOM))?null:new NumberMarker(formatNumber(t,t.state.doc.lineAt(e.from).number)),lineMarkerChange:t=>t.startState.facet(lineNumberConfig)!=t.state.facet(lineNumberConfig),initialSpacer:t=>new NumberMarker(formatNumber(t,maxLineNumber(t.state.doc.lines))),updateSpacer(t,e){let i=formatNumber(e.view,maxLineNumber(e.view.state.doc.lines));return i==t.number?t:new NumberMarker(i)},domEventHandlers:t.facet(lineNumberConfig).domEventHandlers})));function lineNumbers(t={}){return[lineNumberConfig.of(t),gutters(),lineNumberGutter]}function maxLineNumber(t){let e=9;for(;e<t;)e=10*e+9;return e}const activeLineGutterMarker=new class extends GutterMarker{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},activeLineGutterHighlighter=gutterLineClass.compute(["selection"],(t=>{let e=[],i=-1;for(let o of t.selection.ranges){let s=t.doc.lineAt(o.head).from;s>i&&(i=s,e.push(activeLineGutterMarker.range(s)))}return RangeSet.of(e)}));function highlightActiveLineGutter(){return activeLineGutterHighlighter}const WhitespaceDeco=new Map;function getWhitespaceDeco(t){let e=WhitespaceDeco.get(t);return e||WhitespaceDeco.set(t,e=Decoration.mark({attributes:"\t"===t?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":t.replace(/ /g,"·")}})),e}function matcher(t){return ViewPlugin.define((e=>({decorations:t.createDeco(e),update(e){this.decorations=t.updateDeco(e,this.decorations)}})),{decorations:t=>t.decorations})}const whitespaceHighlighter=matcher(new MatchDecorator({regexp:/\t| +/g,decoration:t=>getWhitespaceDeco(t[0]),boundary:/\S/}));function highlightWhitespace(){return whitespaceHighlighter}const trailingHighlighter=matcher(new MatchDecorator({regexp:/\s+$/g,decoration:Decoration.mark({class:"cm-trailingSpace"}),boundary:/\S/}));function highlightTrailingWhitespace(){return trailingHighlighter}const __test={HeightMap,HeightOracle,MeasuredHeights,QueryType,ChangedRange,computeOrder,moveVisually};export{BidiSpan,BlockInfo,BlockType,Decoration,Direction,EditorView,GutterMarker,MatchDecorator,RectangleMarker,ViewPlugin,ViewUpdate,WidgetType,__test,closeHoverTooltips,crosshairCursor,drawSelection,dropCursor,getPanel,getTooltip,gutter,gutterLineClass,gutters,hasHoverTooltips,highlightActiveLine,highlightActiveLineGutter,highlightSpecialChars,highlightTrailingWhitespace,highlightWhitespace,hoverTooltip,keymap,layer,lineNumberMarkers,lineNumbers,logException,panels,placeholder,rectangularSelection,repositionTooltips,runScopeHandlers,scrollPastEnd,showPanel,showTooltip,tooltips}; \ No newline at end of file +import{Text,RangeSet,MapMode,RangeValue,Facet,StateEffect,ChangeSet,findClusterBreak,EditorSelection,EditorState,findColumn,CharCategory,Annotation,Transaction,Prec,codePointAt,codePointSize,combineConfig,StateField,RangeSetBuilder,countColumn}from"@codemirror/state";import{StyleModule}from"style-mod";import{keyName,base,shift}from"w3c-keyname";function getSelection(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function contains(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function deepActiveElement(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function hasSelection(t,e){if(!e.anchorNode)return!1;try{return contains(t,e.anchorNode)}catch(t){return!1}}function clientRectsFor(t){return 3==t.nodeType?textRange(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function isEquivalentPosition(t,e,i,o){return!!i&&(scanFor(t,e,i,o,-1)||scanFor(t,e,i,o,1))}function domIndex(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function scanFor(t,e,i,o,s){for(;;){if(t==i&&e==o)return!0;if(e==(s<0?0:maxOffset(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=domIndex(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?maxOffset(t):0}}}function maxOffset(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}const Rect0={left:0,right:0,top:0,bottom:0};function flattenRect(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function windowRect(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function scrollRectIntoView(t,e,i,o,s,n,r,l){let a=t.ownerDocument,h=a.defaultView||window;for(let c=t;c;)if(1==c.nodeType){let t,d=c==a.body;if(d)t=windowRect(h);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();t={left:e.left,right:e.left+c.clientWidth,top:e.top,bottom:e.top+c.clientHeight}}let u=0,p=0;if("nearest"==s)e.top<t.top?(p=-(t.top-e.top+r),i>0&&e.bottom>t.bottom+p&&(p=e.bottom-t.bottom+p+r)):e.bottom>t.bottom&&(p=e.bottom-t.bottom+r,i<0&&e.top-p<t.top&&(p=-(t.top+p-e.top+r)));else{let o=e.bottom-e.top,n=t.bottom-t.top;p=("center"==s&&o<=n?e.top+o/2-n/2:"start"==s||"center"==s&&i<0?e.top-r:e.bottom-n+r)-t.top}if("nearest"==o)e.left<t.left?(u=-(t.left-e.left+n),i>0&&e.right>t.right+u&&(u=e.right-t.right+u+n)):e.right>t.right&&(u=e.right-t.right+n,i<0&&e.left<t.left+u&&(u=-(t.left+u-e.left+n)));else{u=("center"==o?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==o==l?e.left-n:e.right-(t.right-t.left)+n)-t.left}if(u||p)if(d)h.scrollBy(u,p);else{let t=0,i=0;if(p){let t=c.scrollTop;c.scrollTop+=p,i=c.scrollTop-t}if(u){let e=c.scrollLeft;c.scrollLeft+=u,t=c.scrollLeft-e}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-u)<1&&(o="nearest"),i&&Math.abs(i-p)<1&&(s="nearest")}if(d)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}function scrollableParent(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}class DOMSelectionState{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){this.set(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)}set(t,e,i,o){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=o}}let scratchRange,preventScrollSupported=null;function focusPreventScroll(t){if(t.setActive)return t.setActive();if(preventScrollSupported)return t.focus(preventScrollSupported);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==preventScrollSupported?{get preventScroll(){return preventScrollSupported={preventScroll:!0},!0}}:void 0),!preventScrollSupported){preventScrollSupported=!1;for(let t=0;t<e.length;){let i=e[t++],o=e[t++],s=e[t++];i.scrollTop!=o&&(i.scrollTop=o),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function textRange(t,e,i=e){let o=scratchRange||(scratchRange=document.createRange());return o.setEnd(t,i),o.setStart(t,e),o}function dispatchKey(t,e,i){let o={key:e,code:e,keyCode:i,which:i,cancelable:!0},s=new KeyboardEvent("keydown",o);s.synthetic=!0,t.dispatchEvent(s);let n=new KeyboardEvent("keyup",o);return n.synthetic=!0,t.dispatchEvent(n),s.defaultPrevented||n.defaultPrevented}function getRoot(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function clearAttributes(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function atElementStart(t,e){let i=e.focusNode,o=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=o)return!1;for(;;)if(o){if(1!=i.nodeType)return!1;let t=i.childNodes[o-1];"false"==t.contentEditable?o--:(i=t,o=maxOffset(i))}else{if(i==t)return!0;o=domIndex(i),i=i.parentNode}}class DOMPos{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new DOMPos(t.parentNode,domIndex(t),e)}static after(t,e){return new DOMPos(t.parentNode,domIndex(t)+1,e)}}const noChildren=[];class ContentView{constructor(){this.parent=null,this.dom=null,this.dirty=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}coordsAt(t,e){return null}sync(t,e){if(2&this.dirty){let i,o=this.dom,s=null;for(let n of this.children){if(n.dirty){if(!n.dom&&(i=s?s.nextSibling:o.firstChild)){let t=ContentView.get(i);(!t||!t.parent&&t.canReuseDOM(n))&&n.reuseDOM(i)}n.sync(t,e),n.dirty=0}if(i=s?s.nextSibling:o.firstChild,e&&!e.written&&e.node==o&&i!=n.dom&&(e.written=!0),n.dom.parentNode==o)for(;i&&i!=n.dom;)i=rm$1(i);else o.insertBefore(n.dom,i);s=n.dom}for(i=s?s.nextSibling:o.firstChild,i&&e&&e.node==o&&(e.written=!0);i;)i=rm$1(i)}else if(1&this.dirty)for(let i of this.children)i.dirty&&(i.sync(t,e),i.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let o=0==maxOffset(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==o&&e.firstChild!=e.lastChild&&(o=t==e.firstChild?-1:1),t=e}i=o<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!ContentView.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let o=this.children[t];if(o.dom==i)return e;e+=o.length+o.breakAfter}}domBoundsAround(t,e,i=0){let o=-1,s=-1,n=-1,r=-1;for(let l=0,a=i,h=i;l<this.children.length;l++){let i=this.children[l],c=a+i.length;if(a<t&&c>e)return i.domBoundsAround(t,e,a);if(c>=t&&-1==o&&(o=l,s=a),a>e&&i.dom.parentNode==this.dom){n=l,r=h;break}h=c,a=c+i.breakAfter}return{from:s,to:r<0?i+this.length:r,startDOM:(o?this.children[o-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:n<this.children.length&&n>=0?this.children[n].dom:null}}markDirty(t=!1){this.dirty|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.dirty|=2),1&e.dirty)return;e.dirty|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,this.dirty&&this.markParentsDirty(!0))}setDOM(t){this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=noChildren){this.markDirty();for(let i=t;i<e;i++){let t=this.children[i];t.parent==this&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new ChildCursor(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,o,s,n){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}}function rm$1(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}ContentView.prototype.breakAfter=0;class ChildCursor{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function replaceRange(t,e,i,o,s,n,r,l,a){let{children:h}=t,c=h.length?h[e]:null,d=n.length?n[n.length-1]:null,u=d?d.breakAfter:r;if(!(e==o&&c&&!r&&!u&&n.length<2&&c.merge(i,s,n.length?d:null,0==i,l,a))){if(o<h.length){let t=h[o];t&&s<t.length?(e==o&&(t=t.split(s),s=0),!u&&d&&t.merge(0,s,d,!0,0,a)?n[n.length-1]=t:(s&&t.merge(0,s,null,!1,0,a),n.push(t))):(null==t?void 0:t.breakAfter)&&(d?d.breakAfter=1:r=1),o++}for(c&&(c.breakAfter=r,i>0&&(!r&&n.length&&c.merge(i,c.length,n[0],!1,l,0)?c.breakAfter=n.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,l,0),e++));e<o&&n.length;)if(h[o-1].become(n[n.length-1]))o--,n.pop(),a=n.length?0:l;else{if(!h[e].become(n[0]))break;e++,n.shift(),l=n.length?0:a}!n.length&&e&&o<h.length&&!h[e-1].breakAfter&&h[o].merge(0,0,h[e-1],!1,l,a)&&e--,(e<o||n.length)&&t.replaceChildren(e,o,n)}}function mergeChildrenInto(t,e,i,o,s,n){let r=t.childCursor(),{i:l,off:a}=r.findPos(i,1),{i:h,off:c}=r.findPos(e,-1),d=e-i;for(let t of o)d+=t.length;t.length+=d,replaceRange(t,h,c,l,a,o,0,s,n)}let nav="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},doc="undefined"!=typeof document?document:{documentElement:{style:{}}};const ie_edge=/Edge\/(\d+)/.exec(nav.userAgent),ie_upto10=/MSIE \d/.test(nav.userAgent),ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent),ie=!!(ie_upto10||ie_11up||ie_edge),gecko=!ie&&/gecko\/(\d+)/i.test(nav.userAgent),chrome=!ie&&/Chrome\/(\d+)/.exec(nav.userAgent),webkit="webkitFontSmoothing"in doc.documentElement.style,safari=!ie&&/Apple Computer/.test(nav.vendor),ios=safari&&(/Mobile\/\w+/.test(nav.userAgent)||nav.maxTouchPoints>2);var browser={mac:ios||/Mac/.test(nav.platform),windows:/Win/.test(nav.platform),linux:/Linux|X11/.test(nav.platform),ie,ie_version:ie_upto10?doc.documentMode||6:ie_11up?+ie_11up[1]:ie_edge?+ie_edge[1]:0,gecko,gecko_version:gecko?+(/Firefox\/(\d+)/.exec(nav.userAgent)||[0,0])[1]:0,chrome:!!chrome,chrome_version:chrome?+chrome[1]:0,ios,android:/Android\b/.test(nav.userAgent),webkit,safari,webkit_version:webkit?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=doc.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const MaxJoinLen=256;class TextView extends ContentView{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof TextView&&!(this.length-(e-t)+i.length>256))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new TextView(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new DOMPos(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return textCoords(this.dom,t,e)}}class MarkView extends ContentView{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(clearAttributes(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.dirty|=6)}sync(t,e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,o,s,n){return(!i||!(!(i instanceof MarkView&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&n<=0))&&(mergeChildrenInto(this,t,e,i?i.children:[],s-1,n-1),this.markDirty(),!0)}split(t){let e=[],i=0,o=-1,s=0;for(let n of this.children){let r=i+n.length;r>t&&e.push(i<t?n.split(t-i):n),o<0&&i>=t&&(o=s),i=r,s++}let n=this.length-t;return this.length=t,o>-1&&(this.children.length=o,this.markDirty()),new MarkView(this.mark,e,n)}domAtPos(t){return inlineDOMAtPos(this,t)}coordsAt(t,e){return coordsInChildren(this,t,e)}}function textCoords(t,e,i){let o=t.nodeValue.length;e>o&&(e=o);let s=e,n=e,r=0;0==e&&i<0||e==o&&i>=0?browser.chrome||browser.gecko||(e?(s--,r=1):n<o&&(n++,r=-1)):i<0?s--:n<o&&n++;let l=textRange(t,s,n).getClientRects();if(!l.length)return Rect0;let a=l[(r?r<0:i>=0)?0:l.length-1];return browser.safari&&!r&&0==a.width&&(a=Array.prototype.find.call(l,(t=>t.width))||a),r?flattenRect(a,r<0):a||null}class WidgetView extends ContentView{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}static create(t,e,i){return new(t.customView||WidgetView)(t,e,i)}split(t){let e=WidgetView.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,o,s,n){return!(i&&(!(i instanceof WidgetView&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&n<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t.length==this.length&&t instanceof WidgetView&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return Text.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,o=this.posAtStart;return i?i.slice(o,o+this.length):Text.empty}domAtPos(t){return(this.length?0==t:this.side>0)?DOMPos.before(this.dom):DOMPos.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.dom.getClientRects(),o=null;if(!i.length)return Rect0;for(let e=t>0?i.length-1:0;o=i[e],!(t>0?0==e:e==i.length-1||o.top<o.bottom);e+=t>0?-1:1);return this.length?o:flattenRect(o,this.side>0)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class CompositionView extends WidgetView{domAtPos(t){let{topView:e,text:i}=this.widget;return e?scanCompositionTree(t,0,e,i,this.length-e.length,((t,e)=>t.domAtPos(e)),((t,e)=>new DOMPos(t,Math.min(e,t.nodeValue.length)))):new DOMPos(i,Math.min(t,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(t,e){let{topView:i,text:o}=this.widget;return i?posFromDOMInCompositionTree(t,e,i,o,this.length-i.length):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:o}=this.widget;return i?scanCompositionTree(t,e,i,o,this.length-i.length,((t,e,i)=>t.coordsAt(e,i)),((t,e,i)=>textCoords(t,e,i))):textCoords(o,t,e)}destroy(){var t;super.destroy(),null===(t=this.widget.topView)||void 0===t||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function scanCompositionTree(t,e,i,o,s,n,r){if(i instanceof MarkView){for(let l=i.dom.firstChild;l;l=l.nextSibling){let i=ContentView.get(l);if(i){let a=contains(l,o),h=i.length+(a?s:0);if(t<h||t==h&&i.getSide()<=0)return a?scanCompositionTree(t,e,i,o,s,n,r):n(i,t,e);t-=h}else{let i=scanCompositionNode(t,e,l,r);if("number"!=typeof i)return i;t=i}}return n(i,i.length,-1)}return i.dom==o?r(o,t,e):n(i,t,e)}function scanCompositionNode(t,e,i,o){if(3==i.nodeType){let s=i.nodeValue.length;if(t<=s)return o(i,t,e);t-=s}else if(1==i.nodeType&&"false"!=i.contentEditable)for(let s=i.firstChild;s;s=s.nextSibling){let i=scanCompositionNode(t,e,s,o);if("number"!=typeof i)return i;t=i}return t}function posFromDOMInCompositionTree(t,e,i,o,s){if(i instanceof MarkView){let n=0;for(let r=i.dom.firstChild;r;r=r.nextSibling){let i=ContentView.get(r);if(i){let l=contains(r,o);if(contains(r,t))return n+(l?posFromDOMInCompositionTree(t,e,i,o,s):i.localPosFromDOM(t,e));n+=i.length+(l?s:0)}else{let i=posFromDOMInOpaqueNode(t,e,r);if(null!=i.result)return n+i.result;n+=i.size}}}else if(i.dom==o)return Math.min(e,o.nodeValue.length);return i.localPosFromDOM(t,e)}function posFromDOMInOpaqueNode(t,e,i){if(3==i.nodeType)return t==i?{result:e}:{size:i.nodeValue.length};if(1!=i.nodeType||"false"==i.contentEditable)return i.contains(t)?{result:0}:{size:0};{let o=0;for(let s=i.firstChild,n=0;;s=s.nextSibling,n++){if(t==i&&n==e)return{result:o};if(!s)return{size:o};let r=posFromDOMInOpaqueNode(t,e,s);if(null!=r.result)return{result:e+r.result};o+=r.size}}}class WidgetBufferView extends ContentView{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof WidgetBufferView&&t.side==this.side}split(){return new WidgetBufferView(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?DOMPos.before(this.dom):DOMPos.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){let e=this.dom.getBoundingClientRect(),i=inlineSiblingRect(this,this.side>0?-1:1);return i&&i.top<e.bottom&&i.bottom>e.top?{left:e.left,right:e.right,top:i.top,bottom:i.bottom}:e}get overrideDOMText(){return Text.empty}get isHidden(){return!0}}function inlineSiblingRect(t,e){let i=t.parent,o=i?i.children.indexOf(t):-1;for(;i&&o>=0;)if(e<0?o>0:o<i.children.length){let t=i.children[o+e];if(t instanceof TextView){let i=t.coordsAt(e<0?t.length:0,e);if(i)return i}o+=e}else{if(!(i instanceof MarkView&&i.parent)){let t=i.dom.lastChild;if(t&&"BR"==t.nodeName)return t.getClientRects()[0];break}o=i.parent.children.indexOf(i)+(e<0?0:1),i=i.parent}}function inlineDOMAtPos(t,e){let i=t.dom,{children:o}=t,s=0;for(let t=0;s<o.length;s++){let n=o[s],r=t+n.length;if(!(r==t&&n.getSide()<=0)){if(e>t&&e<r&&n.dom.parentNode==i)return n.domAtPos(e-t);if(e<=t)break;t=r}}for(let t=s;t>0;t--){let e=o[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<o.length;t++){let e=o[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new DOMPos(i,0)}function joinInlineInto(t,e,i){let o,{children:s}=t;i>0&&e instanceof MarkView&&s.length&&(o=s[s.length-1])instanceof MarkView&&o.mark.eq(e.mark)?joinInlineInto(o,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function coordsInChildren(t,e,i){let o=null,s=-1,n=null,r=-1;!function t(e,l){for(let a=0,h=0;a<e.children.length&&h<=l;a++){let c=e.children[a],d=h+c.length;d>=l&&(c.children.length?t(c,l-h):(!n||n instanceof WidgetBufferView&&i>0)&&(d>l||h==d&&c.getSide()>0)?(n=c,r=l-h):(h<l||h==d&&c.getSide()<0)&&(o=c,s=l-h)),h=d}}(t,e);let l=(i<0?o:n)||o||n;return l?l.coordsAt(Math.max(0,l==o?s:r),i):fallbackRect(t)}function fallbackRect(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=clientRectsFor(e);return i[i.length-1]||null}function combineAttrs(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}function attrsEq(t,e){if(t==e)return!0;if(!t||!e)return!1;let i=Object.keys(t),o=Object.keys(e);if(i.length!=o.length)return!1;for(let s of i)if(-1==o.indexOf(s)||t[s]!==e[s])return!1;return!0}function updateAttrs(t,e,i){let o=null;if(e)for(let s in e)i&&s in i||t.removeAttribute(o=s);if(i)for(let s in i)e&&e[s]==i[s]||t.setAttribute(o=s,i[s]);return!!o}TextView.prototype.children=WidgetView.prototype.children=WidgetBufferView.prototype.children=noChildren;class WidgetType{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}ignoreEvent(t){return!0}get customView(){return null}get isHidden(){return!1}destroy(t){}}var BlockType=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(BlockType||(BlockType={}));class Decoration extends RangeValue{constructor(t,e,i,o){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=o}get heightRelevant(){return!1}static mark(t){return new MarkDecoration(t)}static widget(t){let e=t.side||0,i=!!t.block;return e+=i?e>0?3e8:-4e8:e>0?1e8:-1e8,new PointDecoration(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,o=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:n}=getInclusive(t,o);e=(s?o?-3e8:-1:5e8)-1,i=1+(n?o?2e8:1:-6e8)}return new PointDecoration(t,e,i,o,t.widget||null,!0)}static line(t){return new LineDecoration(t)}static set(t,e=!1){return RangeSet.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Decoration.none=RangeSet.empty;class MarkDecoration extends Decoration{constructor(t){let{start:e,end:i}=getInclusive(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){return this==t||t instanceof MarkDecoration&&this.tagName==t.tagName&&this.class==t.class&&attrsEq(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}MarkDecoration.prototype.point=!1;class LineDecoration extends Decoration{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof LineDecoration&&this.spec.class==t.spec.class&&attrsEq(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}LineDecoration.prototype.mapMode=MapMode.TrackBefore,LineDecoration.prototype.point=!0;class PointDecoration extends Decoration{constructor(t,e,i,o,s,n){super(e,i,s,t),this.block=o,this.isReplace=n,this.mapMode=o?e<=0?MapMode.TrackBefore:MapMode.TrackAfter:MapMode.TrackDel}get type(){return this.startSide<this.endSide?BlockType.WidgetRange:this.startSide<=0?BlockType.WidgetBefore:BlockType.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5}eq(t){return t instanceof PointDecoration&&widgetsEq(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function getInclusive(t,e=!1){let{inclusiveStart:i,inclusiveEnd:o}=t;return null==i&&(i=t.inclusive),null==o&&(o=t.inclusive),{start:null!=i?i:e,end:null!=o?o:e}}function widgetsEq(t,e){return t==e||!!(t&&e&&t.compare(e))}function addRange(t,e,i,o=0){let s=i.length-1;s>=0&&i[s]+o>=t?i[s]=Math.max(i[s],e):i.push(t,e)}PointDecoration.prototype.point=!0;class LineView extends ContentView{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,o,s,n){if(i){if(!(i instanceof LineView))return!1;this.dom||i.transferDOM(this)}return o&&this.setDeco(i?i.attrs:null),mergeChildrenInto(this,t,e,i?i.children:[],s,n),!0}split(t){let e=new LineView;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:o}=this.childPos(t);o&&(e.append(this.children[i].split(o),0),this.children[i].merge(o,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){attrsEq(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){joinInlineInto(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=combineAttrs(e,this.attrs||{})),i&&(this.attrs=combineAttrs({class:i},this.attrs||{}))}domAtPos(t){return inlineDOMAtPos(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(clearAttributes(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(updateAttrs(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let o=this.dom.lastChild;for(;o&&ContentView.get(o)instanceof MarkView;)o=o.lastChild;if(!(o&&this.length&&("BR"==o.nodeName||0!=(null===(i=ContentView.get(o))||void 0===i?void 0:i.isEditable)||browser.ios&&this.children.some((t=>t instanceof TextView))))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof TextView)||/[^ -~]/.test(i.text))return null;let o=clientRectsFor(i.dom);if(1!=o.length)return null;e+=o[0].width,t=o[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=coordsInChildren(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let o=(e-t.textHeight)/2;return{top:i.top+o,bottom:i.bottom-o,left:i.left,right:i.left}}}return i}become(t){return!1}get type(){return BlockType.Text}static find(t,e){for(let i=0,o=0;i<t.children.length;i++){let s=t.children[i],n=o+s.length;if(n>=e){if(s instanceof LineView)return s;if(n>e)break}o=n+s.breakAfter}return null}}class BlockWidgetView extends ContentView{constructor(t,e,i){super(),this.widget=t,this.length=e,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,o,s,n){return!(i&&(!(i instanceof BlockWidgetView&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&n<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?DOMPos.before(this.dom):DOMPos.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new BlockWidgetView(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return noChildren}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Text.empty}domBoundsAround(){return null}become(t){return t instanceof BlockWidgetView&&t.type==this.type&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class ContentBuilder{constructor(t,e,i,o){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=o,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof BlockWidgetView&&t.type==BlockType.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new LineView),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(wrapMarks(new WidgetBufferView(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:o}=this.cursor.next(this.skip);if(this.skip=0,o)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let o=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff,this.textOff+o)),e),i),this.atCursorPos=!0,this.textOff+=o,t-=o,i=0}}span(t,e,i,o){this.buildText(e-t,i,o),this.pos=e,this.openStart<0&&(this.openStart=o)}point(t,e,i,o,s,n){if(this.disallowBlockEffectsFor[n]&&i instanceof PointDecoration){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=e-t;if(i instanceof PointDecoration)if(i.block){let{type:t}=i;t!=BlockType.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new BlockWidgetView(i.widget||new NullWidget("div"),r,t))}else{let n=WidgetView.create(i.widget||new NullWidget("span"),r,r?0:i.startSide),l=this.atCursorPos&&!n.isEditable&&s<=o.length&&(t<e||i.startSide>0),a=!n.isEditable&&(t<e||s>o.length||i.startSide<=0),h=this.getLine();2!=this.pendingBuffer||l||n.isEditable||(this.pendingBuffer=0),this.flushBuffer(o),l&&(h.append(wrapMarks(new WidgetBufferView(1),o),s),s=o.length+Math.max(0,s-o.length)),h.append(wrapMarks(n,o),s),this.atCursorPos=a,this.pendingBuffer=a?t<e||s>o.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=o.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,o,s){let n=new ContentBuilder(t,e,i,s);return n.openEnd=RangeSet.spans(o,e,i,n),n.openStart<0&&(n.openStart=n.openEnd),n.finish(n.openEnd),n}}function wrapMarks(t,e){for(let i of e)t=new MarkView(i,[t],t.length);return t}class NullWidget extends WidgetType{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const clickAddsSelectionRange=Facet.define(),dragMovesSelection$1=Facet.define(),mouseSelectionStyle=Facet.define(),exceptionSink=Facet.define(),updateListener=Facet.define(),inputHandler=Facet.define(),focusChangeEffect=Facet.define(),perLineTextDirection=Facet.define({combine:t=>t.some((t=>t))}),nativeSelectionHidden=Facet.define({combine:t=>t.some((t=>t))});class ScrollTarget{constructor(t,e="nearest",i="nearest",o=5,s=5){this.range=t,this.y=e,this.x=i,this.yMargin=o,this.xMargin=s}map(t){return t.empty?this:new ScrollTarget(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const scrollIntoView=StateEffect.define({map:(t,e)=>t.map(e)});function logException(t,e,i){let o=t.facet(exceptionSink);o.length?o[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const editable=Facet.define({combine:t=>!t.length||t[0]});let nextPluginID=0;const viewPlugin=Facet.define();class ViewPlugin{constructor(t,e,i,o){this.id=t,this.create=e,this.domEventHandlers=i,this.extension=o(this)}static define(t,e){const{eventHandlers:i,provide:o,decorations:s}=e||{};return new ViewPlugin(nextPluginID++,t,i,(t=>{let e=[viewPlugin.of(t)];return s&&e.push(decorations.of((e=>{let i=e.plugin(t);return i?s(i):Decoration.none}))),o&&e.push(o(t)),e}))}static fromClass(t,e){return ViewPlugin.define((e=>new t(e)),e)}}class PluginInstance{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(logException(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){logException(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){logException(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const editorAttributes=Facet.define(),contentAttributes=Facet.define(),decorations=Facet.define(),atomicRanges=Facet.define(),scrollMargins=Facet.define(),styleModule=Facet.define();class ChangedRange{constructor(t,e,i,o){this.fromA=t,this.toA=e,this.fromB=i,this.toB=o}join(t){return new ChangedRange(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let o=t[e-1];if(!(o.fromA>i.toA)){if(o.toA<i.fromA)break;i=i.join(o),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let o=0,s=0,n=0,r=0;;o++){let l=o==t.length?null:t[o],a=n-r,h=l?l.fromB:1e9;for(;s<e.length&&e[s]<h;){let t=e[s],o=e[s+1],n=Math.max(r,t),l=Math.min(h,o);if(n<=l&&new ChangedRange(n+a,l+a,n,l).addToSet(i),o>h)break;s+=2}if(!l)return i;new ChangedRange(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),n=l.toA,r=l.toB}}}class ViewUpdate{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=ChangeSet.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let o=[];this.changes.iterChangedRanges(((t,e,i,s)=>o.push(new ChangedRange(t,e,i,s)))),this.changedRanges=o}static create(t,e,i){return new ViewUpdate(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}var Direction=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Direction||(Direction={}));const LTR=Direction.LTR,RTL=Direction.RTL;function dec(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const LowTypes=dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),ArabicTypes=dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Brackets=Object.create(null),BracketStack=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Brackets[e]=i,Brackets[i]=-e}function charType(t){return t<=247?LowTypes[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?ArabicTypes[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8203?256:64336<=t&&t<=65023?4:8204==t?256:1}const BidiRE=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class BidiSpan{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?RTL:LTR}side(t,e){return this.dir==e==t?this.to:this.from}static find(t,e,i,o){let s=-1;for(let n=0;n<t.length;n++){let r=t[n];if(r.from<=e&&r.to>=e){if(r.level==i)return n;(s<0||(0!=o?o<0?r.from<e:r.to>e:t[s].level>r.level))&&(s=n)}}if(s<0)throw new RangeError("Index out of range");return s}}const types=[];function computeOrder(t,e){let i=t.length,o=e==LTR?1:2,s=e==LTR?2:1;if(!t||1==o&&!BidiRE.test(t))return trivialOrder(i);for(let e=0,s=o,n=o;e<i;e++){let i=charType(t.charCodeAt(e));512==i?i=s:8==i&&4==n&&(i=16),types[e]=4==i?2:i,7&i&&(n=i),s=i}for(let t=0,e=o,s=o;t<i;t++){let o=types[t];if(128==o)t<i-1&&e==types[t+1]&&24&e?o=types[t]=e:types[t]=256;else if(64==o){let o=t+1;for(;o<i&&64==types[o];)o++;let n=t&&8==e||o<i&&8==types[o]?1==s?1:8:256;for(let e=t;e<o;e++)types[e]=n;t=o-1}else 8==o&&1==s&&(types[t]=1);e=o,7&o&&(s=o)}for(let e,n,r,l=0,a=0,h=0;l<i;l++)if(n=Brackets[e=t.charCodeAt(l)])if(n<0){for(let t=a-3;t>=0;t-=3)if(BracketStack[t+1]==-n){let e=BracketStack[t+2],i=2&e?o:4&e?1&e?s:o:0;i&&(types[l]=types[BracketStack[t]]=i),a=t;break}}else{if(189==BracketStack.length)break;BracketStack[a++]=l,BracketStack[a++]=e,BracketStack[a++]=h}else if(2==(r=types[l])||1==r){let t=r==o;h=t?0:1;for(let e=a-3;e>=0;e-=3){let i=BracketStack[e+2];if(2&i)break;if(t)BracketStack[e+2]|=2;else{if(4&i)break;BracketStack[e+2]|=4}}}for(let t=0;t<i;t++)if(256==types[t]){let e=t+1;for(;e<i&&256==types[e];)e++;let s=1==(t?types[t-1]:o),n=s==(1==(e<i?types[e]:o))?s?1:2:o;for(let i=t;i<e;i++)types[i]=n;t=e-1}let n=[];if(1==o)for(let t=0;t<i;){let e=t,o=1!=types[t++];for(;t<i&&o==(1!=types[t]);)t++;if(o)for(let i=t;i>e;){let t=i,o=2!=types[--i];for(;i>e&&o==(2!=types[i-1]);)i--;n.push(new BidiSpan(i,t,o?2:1))}else n.push(new BidiSpan(e,t,0))}else for(let t=0;t<i;){let e=t,o=2==types[t++];for(;t<i&&o==(2==types[t]);)t++;n.push(new BidiSpan(e,t,o?1:2))}return n}function trivialOrder(t){return[new BidiSpan(0,t,0)]}let movedOver="";function moveVisually(t,e,i,o,s){var n;let r=o.head-t.from,l=-1;if(0==r){if(!s||!t.length)return null;e[0].level!=i&&(r=e[0].side(!1,i),l=0)}else if(r==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(r=t.side(!0,i),l=e.length-1)}l<0&&(l=BidiSpan.find(e,r,null!==(n=o.bidiLevel)&&void 0!==n?n:-1,o.assoc));let a=e[l];r==a.side(s,i)&&(a=e[l+=s?1:-1],r=a.side(!s,i));let h=s==(a.dir==i),c=findClusterBreak(t.text,r,h);if(movedOver=t.text.slice(Math.min(r,c),Math.max(r,c)),c!=a.side(s,i))return EditorSelection.cursor(c+t.from,h?-1:1,a.level);let d=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return d||a.level==i?d&&d.level<a.level?EditorSelection.cursor(d.side(!s,i)+t.from,s?1:-1,d.level):EditorSelection.cursor(c+t.from,s?-1:1,a.level):EditorSelection.cursor(s?t.to:t.from,s?-1:1,i)}const LineBreakPlaceholder="ï¿¿";class DOMReader{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(EditorState.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+="ï¿¿"}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let o=t;;){this.findPointBefore(i,o),this.readNode(o);let t=o.nextSibling;if(t==e)break;let s=ContentView.get(o),n=ContentView.get(t);(s&&n?s.breakAfter:(s?s.breakAfter:isBlockElement(o))||isBlockElement(t)&&("BR"!=o.nodeName||o.cmIgnore))&&this.lineBreak(),o=t}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let s,n=-1,r=1;if(this.lineSeparator?(n=e.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(s=o.exec(e))&&(n=s.index,r=s[0].length),this.append(e.slice(i,n<0?e.length:n)),n<0)break;if(this.lineBreak(),r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=n+r}}readNode(t){if(t.cmIgnore)return;let e=ContentView.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+Math.min(e,i.offset))}}function isBlockElement(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class DOMPoint{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class DocView extends ContentView{constructor(t){super(),this.view=t,this.compositionDeco=Decoration.none,this.decorations=[],this.dynamicDecorationMap=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new LineView],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ChangedRange(0,0,0,t.state.doc.length)],0)}get length(){return this.view.state.doc.length}update(t){let e=t.changedRanges;this.minWidth>0&&e.length&&(e.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo))?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=Decoration.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=computeCompositionDeco(this.view,t.changes)),(browser.ie||browser.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=findChangedDeco(this.decorations,this.updateDeco(),t.changes);return e=ChangedRange.extendWithRanges(e,i),(0!=this.dirty||0!=e.length)&&(this.updateInner(e,t.startState.doc.length),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e);let{observer:i}=this.view;i.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=browser.chrome||browser.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.dirty=0,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}));let o=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof BlockWidgetView&&t.widget instanceof BlockGapWidget&&o.push(t.dom);i.updateGaps(o)}updateChildren(t,e){let i=this.childCursor(e);for(let e=t.length-1;;e--){let o=e>=0?t[e]:null;if(!o)break;let{fromA:s,toA:n,fromB:r,toB:l}=o,{content:a,breakAtStart:h,openStart:c,openEnd:d}=ContentBuilder.build(this.view.state.doc,r,l,this.decorations,this.dynamicDecorationMap),{i:u,off:p}=i.findPos(n,1),{i:f,off:g}=i.findPos(s,-1);replaceRange(this,f,g,u,p,a,h,c,d)}}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,o=i==this.dom,s=!o&&hasSelection(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(o||e||s))return;let n=this.forceSelection;this.forceSelection=!1;let r=this.view.state.selection.main,l=this.domAtPos(r.anchor),a=r.empty?l:this.domAtPos(r.head);if(browser.gecko&&r.empty&&!this.compositionDeco.size&&betweenUneditable(l)){let t=document.createTextNode("");this.view.observer.ignore((()=>l.node.insertBefore(t,l.node.childNodes[l.offset]||null))),l=a=new DOMPos(t,0),n=!0}let h=this.view.observer.selectionRange;!n&&h.focusNode&&isEquivalentPosition(l.node,l.offset,h.anchorNode,h.anchorOffset)&&isEquivalentPosition(a.node,a.offset,h.focusNode,h.focusOffset)||(this.view.observer.ignore((()=>{browser.android&&browser.chrome&&this.dom.contains(h.focusNode)&&inUneditable(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=getSelection(this.view.root);if(t)if(r.empty){if(browser.gecko){let t=nextToUneditable(l.node,l.offset);if(t&&3!=t){let e=nearbyTextNode(l.node,l.offset,1==t?1:-1);e&&(l=new DOMPos(e,1==t?0:e.nodeValue.length))}}t.collapse(l.node,l.offset),null!=r.bidiLevel&&null!=h.cursorBidiLevel&&(h.cursorBidiLevel=r.bidiLevel)}else if(t.extend){t.collapse(l.node,l.offset);try{t.extend(a.node,a.offset)}catch(t){}}else{let e=document.createRange();r.anchor>r.head&&([l,a]=[a,l]),e.setEnd(a.node,a.offset),e.setStart(l.node,l.offset),t.removeAllRanges(),t.addRange(e)}else;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(l,a)),this.impreciseAnchor=l.precise?null:new DOMPos(h.anchorNode,h.anchorOffset),this.impreciseHead=a.precise?null:new DOMPos(h.focusNode,h.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=getSelection(t.root),{anchorNode:o,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let n=LineView.find(this,e.head);if(!n)return;let r=n.posAtStart;if(e.head==r||e.head==r+n.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(e.head+e.assoc);i.collapse(h.node,h.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(o,s)}nearest(t){for(let e=t;e;){let t=ContentView.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof LineView)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){for(let i=this.length,o=this.children.length-1;;o--){let s=this.children[o],n=i-s.breakAfter-s.length;if(t>n||t==n&&s.type!=BlockType.WidgetBefore&&s.type!=BlockType.WidgetAfter&&(!o||2==e||this.children[o-1].breakAfter||this.children[o-1].type==BlockType.WidgetBefore&&e>-2))return s.coordsAt(t-n,e);i=n}}measureVisibleLineHeights(t){let e=[],{from:i,to:o}=t,s=this.view.contentDOM.clientWidth,n=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,l=this.view.textDirection==Direction.LTR;for(let t=0,a=0;a<this.children.length;a++){let h=this.children[a],c=t+h.length;if(c>o)break;if(t>=i){let i=h.dom.getBoundingClientRect();if(e.push(i.height),n){let e=h.dom.lastChild,o=e?clientRectsFor(e):[];if(o.length){let e=o[o.length-1],n=l?e.right-i.left:i.right-e.left;n>r&&(r=n,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+h.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?Direction.RTL:Direction.LTR}measureTextSize(){for(let t of this.children)if(t instanceof LineView){let e=t.measureTextSize();if(e)return e}let t,e,i,o=document.createElement("div");return o.className="cm-line",o.style.width="99999px",o.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(o);let s=clientRectsFor(o.firstChild)[0];t=o.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,o.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new ChildCursor(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,o=0;;o++){let s=o==e.viewports.length?null:e.viewports[o],n=s?s.from-1:this.length;if(n>i){let o=e.lineBlockAt(n).bottom-e.lineBlockAt(i).top;t.push(Decoration.replace({widget:new BlockGapWidget(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,n))}if(!s)break;i=s.to+1}return Decoration.set(t)}updateDeco(){let t=this.view.state.facet(decorations).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...t,this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){let e,{range:i}=t,o=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!o)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(o={left:Math.min(o.left,e.left),top:Math.min(o.top,e.top),right:Math.max(o.right,e.right),bottom:Math.max(o.bottom,e.bottom)});let s=0,n=0,r=0,l=0;for(let t of this.view.state.facet(scrollMargins).map((t=>t(this.view))))if(t){let{left:e,right:i,top:o,bottom:a}=t;null!=e&&(s=Math.max(s,e)),null!=i&&(n=Math.max(n,i)),null!=o&&(r=Math.max(r,o)),null!=a&&(l=Math.max(l,a))}let a={left:o.left-s,top:o.top-r,right:o.right+n,bottom:o.bottom+l};scrollRectIntoView(this.view.scrollDOM,a,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==Direction.LTR)}}function betweenUneditable(t){return 1==t.node.nodeType&&t.node.firstChild&&(0==t.offset||"false"==t.node.childNodes[t.offset-1].contentEditable)&&(t.offset==t.node.childNodes.length||"false"==t.node.childNodes[t.offset].contentEditable)}class BlockGapWidget extends WidgetType{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}function compositionSurroundingNode(t){let e=t.observer.selectionRange,i=e.focusNode&&nearbyTextNode(e.focusNode,e.focusOffset,0);if(!i)return null;let o=t.docView.nearest(i);if(!o)return null;if(o instanceof LineView){let t=i;for(;t.parentNode!=o.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!ContentView.get(e);)e=e.previousSibling;let s=e?ContentView.get(e).posAtEnd:o.posAtStart;return{from:s,to:s,node:t,text:i}}{for(;;){let{parent:t}=o;if(!t)return null;if(t instanceof LineView)break;o=t}let t=o.posAtStart;return{from:t,to:t+o.length,node:o.dom,text:i}}}function computeCompositionDeco(t,e){let i=compositionSurroundingNode(t);if(!i)return Decoration.none;let{from:o,to:s,node:n,text:r}=i,l=e.mapPos(o,1),a=Math.max(l,e.mapPos(s,-1)),{state:h}=t,c=3==n.nodeType?n.nodeValue:new DOMReader([],h).readRange(n.firstChild,null).text;if(a-l<c.length)if(h.doc.sliceString(l,Math.min(h.doc.length,l+c.length),"ï¿¿")==c)a=l+c.length;else{if(h.doc.sliceString(Math.max(0,a-c.length),a,"ï¿¿")!=c)return Decoration.none;l=a-c.length}else if(h.doc.sliceString(l,a,"ï¿¿")!=c)return Decoration.none;let d=ContentView.get(n);return d instanceof CompositionView?d=d.widget.topView:d&&(d.parent=null),Decoration.set(Decoration.replace({widget:new CompositionWidget(n,r,d),inclusive:!0}).range(l,a))}class CompositionWidget extends WidgetType{constructor(t,e,i){super(),this.top=t,this.text=e,this.topView=i}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return CompositionView}}function nearbyTextNode(t,e,i){if(i<=0)for(let i=t,o=e;;){if(3==i.nodeType)return i;if(!(1==i.nodeType&&o>0))break;i=i.childNodes[o-1],o=maxOffset(i)}if(i>=0)for(let o=t,s=e;;){if(3==o.nodeType)return o;if(!(1==o.nodeType&&s<o.childNodes.length&&i>=0))break;o=o.childNodes[s],s=0}return null}function nextToUneditable(t,e){return 1!=t.nodeType?0:(e&&"false"==t.childNodes[e-1].contentEditable?1:0)|(e<t.childNodes.length&&"false"==t.childNodes[e].contentEditable?2:0)}class DecorationComparator$1{constructor(){this.changes=[]}compareRange(t,e){addRange(t,e,this.changes)}comparePoint(t,e){addRange(t,e,this.changes)}}function findChangedDeco(t,e,i){let o=new DecorationComparator$1;return RangeSet.compare(t,e,i,o),o.changes}function inUneditable(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}function groupAt(t,e,i=1){let o=t.charCategorizer(e),s=t.doc.lineAt(e),n=e-s.from;if(0==s.length)return EditorSelection.cursor(e);0==n?i=1:n==s.length&&(i=-1);let r=n,l=n;i<0?r=findClusterBreak(s.text,n,!1):l=findClusterBreak(s.text,n);let a=o(s.text.slice(r,l));for(;r>0;){let t=findClusterBreak(s.text,r,!1);if(o(s.text.slice(t,r))!=a)break;r=t}for(;l<s.length;){let t=findClusterBreak(s.text,l);if(o(s.text.slice(l,t))!=a)break;l=t}return EditorSelection.range(r+s.from,l+s.from)}function getdx(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function getdy(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function yOverlap(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function upTop(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function upBot(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function domPosAtCoords(t,e,i){let o,s,n,r,l,a,h,c,d=!1;for(let u=t.firstChild;u;u=u.nextSibling){let t=clientRectsFor(u);for(let p=0;p<t.length;p++){let f=t[p];s&&yOverlap(s,f)&&(f=upTop(upBot(f,s.bottom),s.top));let g=getdx(e,f),m=getdy(i,f);if(0==g&&0==m)return 3==u.nodeType?domPosInText(u,e,i):domPosAtCoords(u,e,i);if(!o||r>m||r==m&&n>g){o=u,s=f,n=g,r=m;let l=m?i<f.top?-1:1:g?e<f.left?-1:1:0;d=!l||(l>0?p<t.length-1:p>0)}0==g?i>f.bottom&&(!h||h.bottom<f.bottom)?(l=u,h=f):i<f.top&&(!c||c.top>f.top)&&(a=u,c=f):h&&yOverlap(h,f)?h=upBot(h,f.bottom):c&&yOverlap(c,f)&&(c=upTop(c,f.top))}}if(h&&h.bottom>=i?(o=l,s=h):c&&c.top<=i&&(o=a,s=c),!o)return{node:t,offset:0};let u=Math.max(s.left,Math.min(s.right,e));return 3==o.nodeType?domPosInText(o,u,i):d&&"false"!=o.contentEditable?domPosAtCoords(o,u,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,o)+(e>=(s.left+s.right)/2?1:0)}}function domPosInText(t,e,i){let o=t.nodeValue.length,s=-1,n=1e9,r=0;for(let l=0;l<o;l++){let o=textRange(t,l,l+1).getClientRects();for(let a=0;a<o.length;a++){let h=o[a];if(h.top==h.bottom)continue;r||(r=e-h.left);let c=(h.top>i?h.top-i:i-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c<n){let i=e>=(h.left+h.right)/2,o=i;if(browser.chrome||browser.gecko){textRange(t,l).getBoundingClientRect().left==h.right&&(o=!i)}if(c<=0)return{node:t,offset:l+(o?1:0)};s=l+(o?1:0),n=c}}}return{node:t,offset:s>-1?s:r>0?t.nodeValue.length:0}}function posAtCoords(t,e,i,o=-1){var s,n;let r,l=t.contentDOM.getBoundingClientRect(),a=l.top+t.viewState.paddingTop,{docHeight:h}=t.viewState,{x:c,y:d}=e,u=d-a;if(u<0)return 0;if(u>h)return t.state.doc.length;for(let e=t.defaultLineHeight/2,s=!1;r=t.elementAtHeight(u),r.type!=BlockType.Text;)for(;u=o>0?r.bottom+e:r.top-e,!(u>=0&&u<=h);){if(s)return i?null:0;s=!0,o=-o}d=a+u;let p=r.from;if(p<t.viewport.from)return 0==t.viewport.from?0:i?null:posAtCoordsImprecise(t,l,r,c,d);if(p>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:posAtCoordsImprecise(t,l,r,c,d);let f=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:f,m=g.elementFromPoint(c,d);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(l.left+1,Math.min(l.right-1,c)),m=g.elementFromPoint(c,d),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(f.caretPositionFromPoint){let t=f.caretPositionFromPoint(c,d);t&&({offsetNode:w,offset:v}=t)}else if(f.caretRangeFromPoint){let e=f.caretRangeFromPoint(c,d);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||browser.safari&&isSuspiciousSafariCaretResult(w,v,c)||browser.chrome&&isSuspiciousChromeCaretResult(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=LineView.find(t.docView,p);if(!e)return u>r.top+r.height/2?r.to:r.from;({node:w,offset:v}=domPosAtCoords(e.dom,c,d))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(n=y.dom)||void 0===n?void 0:n.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function posAtCoordsImprecise(t,e,i,o,s){let n=Math.round((o-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){n+=Math.floor((s-i.top)/t.defaultLineHeight)*t.viewState.heightOracle.lineLength}let r=t.state.sliceDoc(i.from,i.to);return i.from+findColumn(r,n,t.state.tabSize)}function isSuspiciousSafariCaretResult(t,e,i){let o;if(3!=t.nodeType||e!=(o=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return textRange(t,o-1,o).getBoundingClientRect().left>i}function isSuspiciousChromeCaretResult(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}return i-(1==t.nodeType?t.getBoundingClientRect():textRange(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}function moveToLineBoundary(t,e,i,o){let s=t.state.doc.lineAt(e.head),n=o&&t.lineWrapping?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(n){let e=t.dom.getBoundingClientRect(),o=t.textDirectionAt(s.from),r=t.posAtCoords({x:i==(o==Direction.LTR)?e.right-1:e.left+1,y:(n.top+n.bottom)/2});if(null!=r)return EditorSelection.cursor(r,i?-1:1)}let r=LineView.find(t.docView,e.head),l=r?i?r.posAtEnd:r.posAtStart:i?s.to:s.from;return EditorSelection.cursor(l,i?-1:1)}function moveByChar(t,e,i,o){let s=t.state.doc.lineAt(e.head),n=t.bidiSpans(s),r=t.textDirectionAt(s.from);for(let l=e,a=null;;){let e=moveVisually(s,n,r,l,i),h=movedOver;if(!e){if(s.number==(i?t.state.doc.lines:1))return l;h="\n",s=t.state.doc.line(s.number+(i?1:-1)),n=t.bidiSpans(s),e=EditorSelection.cursor(i?s.from:s.to)}if(a){if(!a(h))return l}else{if(!o)return e;a=o(h)}l=e}}function byGroup(t,e,i){let o=t.state.charCategorizer(e),s=o(i);return t=>{let e=o(t);return s==CharCategory.Space&&(s=e),s==e}}function moveVertically(t,e,i,o){let s=e.head,n=i?1:-1;if(s==(i?t.state.doc.length:0))return EditorSelection.cursor(s,e.assoc);let r,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s),c=t.documentTop;if(h)null==l&&(l=h.left-a.left),r=n<0?h.top:h.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),r=(n<0?e.top:e.bottom)+c}let d=a.left+l,u=null!=o?o:t.defaultLineHeight>>1;for(let i=0;;i+=10){let o=r+(u+i)*n,h=posAtCoords(t,{x:d,y:o},!1,n);if(o<a.top||o>a.bottom||(n<0?h<s:h>s))return EditorSelection.cursor(h,e.assoc,void 0,l)}}function skipAtoms(t,e,i){let o=t.state.facet(atomicRanges).map((e=>e(t)));for(;;){let t=!1;for(let s of o)s.between(i.from-1,i.from+1,((o,s,n)=>{i.from>o&&i.from<s&&(i=e.head>i.from?EditorSelection.cursor(o,1):EditorSelection.cursor(s,-1),t=!0)}));if(!t)return i}}class InputState{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let e=(e,i)=>{this.ignoreDuringComposition(i)||"keydown"==i.type&&this.keydown(t,i)||(this.mustFlushObserver(i)&&t.observer.forceFlush(),this.runCustomHandlers(i.type,t,i)?i.preventDefault():e(t,i))};for(let i in handlers){let o=handlers[i];t.contentDOM.addEventListener(i,(i=>{eventBelongsToEditor(t,i)&&e(o,i)}),handlerOptions[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",(i=>{if(i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&(e(handlers.mousedown,i),!i.defaultPrevented&&2==i.button)){let e=t.contentDOM.style.minHeight;t.contentDOM.style.minHeight="100%",setTimeout((()=>t.contentDOM.style.minHeight=e),200)}})),browser.chrome&&102==browser.chrome_version&&t.scrollDOM.addEventListener("wheel",(()=>{this.chromeScrollHack<0?t.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout((()=>{this.chromeScrollHack=-1,t.contentDOM.style.pointerEvents=""}),100)}),{passive:!0}),this.notifiedFocused=t.hasFocus,browser.safari&&t.contentDOM.addEventListener("input",(()=>null))}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t,e){var i;let o;this.customHandlers=[];for(let s of e)if(o=null===(i=s.update(t).spec)||void 0===i?void 0:i.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:o});for(let e in o)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),t.contentDOM.addEventListener(e,(i=>{eventBelongsToEditor(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()})))}}runCustomHandlers(t,e,i){for(let o of this.customHandlers){let s=o.handlers[t];if(s)try{if(s.call(o.plugin,i,e)||i.defaultPrevented)return!0}catch(t){logException(e.state,t)}}return!1}runScrollHandlers(t,e){this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft;for(let i of this.customHandlers){let o=i.handlers.scroll;if(o)try{o.call(i.plugin,e,t)}catch(e){logException(t.state,e)}}}keydown(t,e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(browser.android&&browser.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!browser.ios||e.synthetic||e.altKey||e.metaKey||!((i=PendingKeys.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||EmacsyPendingKeys.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey))&&(this.pendingIOSKey=i||e,setTimeout((()=>this.flushIOSKey(t)),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,dispatchKey(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(browser.safari&&!browser.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const PendingKeys=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],EmacsyPendingKeys="dthko",modifierCodes=[16,17,18,20,91,92,224,225],dragScrollMargin=6;function dragScrollSpeed(t){return.7*Math.max(0,t)+8}class MouseSelection{constructor(t,e,i,o){this.view=t,this.style=i,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=scrollableParent(t.contentDOM);let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(EditorState.allowMultipleSelections)&&addsSelectionRange(t,e),this.dragMove=dragMovesSelection(t,e),this.dragging=!(!isInPrimarySelection(t,e)||1!=getClickType(e))&&null}start(t){!1===this.dragging&&(t.preventDefault(),this.select(t))}move(t){var e;if(0==t.buttons)return this.destroy();if(!1!==this.dragging)return;this.select(this.lastEvent=t);let i=0,o=0,s=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight};t.clientX<=s.left+6?i=-dragScrollSpeed(s.left-t.clientX):t.clientX>=s.right-6&&(i=dragScrollSpeed(t.clientX-s.right)),t.clientY<=s.top+6?o=-dragScrollSpeed(s.top-t.clientY):t.clientY>=s.bottom-6&&(o=dragScrollSpeed(t.clientY-s.bottom)),this.setScrollSpeed(i,o)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}select(t){let e=this.style.get(t,this.extend,this.multiple);!this.mustSelect&&e.eq(this.view.state.selection)&&e.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:e,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function addsSelectionRange(t,e){let i=t.state.facet(clickAddsSelectionRange);return i.length?i[0](e):browser.mac?e.metaKey:e.ctrlKey}function dragMovesSelection(t,e){let i=t.state.facet(dragMovesSelection$1);return i.length?i[0](e):browser.mac?!e.altKey:!e.ctrlKey}function isInPrimarySelection(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let o=getSelection(t.root);if(!o||0==o.rangeCount)return!0;let s=o.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}function eventBelongsToEditor(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,o=e.target;o!=t.contentDOM;o=o.parentNode)if(!o||11==o.nodeType||(i=ContentView.get(o))&&i.ignoreEvent(e))return!1;return!0}const handlers=Object.create(null),handlerOptions=Object.create(null),brokenClipboardAPI=browser.ie&&browser.ie_version<15||browser.ios&&browser.webkit_version<604;function capturePaste(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),doPaste(t,i.value)}),50)}function doPaste(t,e){let i,{state:o}=t,s=1,n=o.toText(e),r=n.lines==o.selection.ranges.length;if(null!=lastLinewiseCopy&&o.selection.ranges.every((t=>t.empty))&&lastLinewiseCopy==n.toString()){let t=-1;i=o.changeByRange((i=>{let l=o.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=o.toText((r?n.line(s++).text:e)+o.lineBreak);return{changes:{from:l.from,insert:a},range:EditorSelection.cursor(i.from+a.length)}}))}else i=r?o.changeByRange((t=>{let e=n.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:EditorSelection.cursor(t.from+e.length)}})):o.replaceSelection(n);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function rangeForClick(t,e,i,o){if(1==o)return EditorSelection.cursor(e,i);if(2==o)return groupAt(t.state,e,i);{let i=LineView.find(t.docView,e),o=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:o.from,n=i?i.posAtEnd:o.to;return n<t.state.doc.length&&n==o.to&&n++,EditorSelection.range(s,n)}}handlers.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode?t.inputState.lastEscPress=Date.now():modifierCodes.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0)},handlers.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},handlers.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},handlerOptions.touchstart=handlerOptions.touchmove={passive:!0},handlers.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let i=null;for(let o of t.state.facet(mouseSelectionStyle))if(i=o(t,e),i)break;if(i||0!=e.button||(i=basicMouseSelection(t,e)),i){let o=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new MouseSelection(t,e,i,o)),o&&t.observer.ignore((()=>focusPreventScroll(t.contentDOM))),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let insideY=(t,e)=>t>=e.top&&t<=e.bottom,inside=(t,e,i)=>insideY(e,i)&&t>=i.left&&t<=i.right;function findPositionSide(t,e,i,o){let s=LineView.find(t.docView,e);if(!s)return 1;let n=e-s.posAtStart;if(0==n)return 1;if(n==s.length)return-1;let r=s.coordsAt(n,-1);if(r&&inside(i,o,r))return-1;let l=s.coordsAt(n,1);return l&&inside(i,o,l)?1:r&&insideY(o,r)?-1:1}function queryPos(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:findPositionSide(t,i,e.clientX,e.clientY)}}const BadMouseDetail=browser.ie&&browser.ie_version<=11;let lastMouseDown=null,lastMouseDownCount=0,lastMouseDownTime=0;function getClickType(t){if(!BadMouseDetail)return t.detail;let e=lastMouseDown,i=lastMouseDownTime;return lastMouseDown=t,lastMouseDownTime=Date.now(),lastMouseDownCount=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(lastMouseDownCount+1)%3:1}function basicMouseSelection(t,e){let i=queryPos(t,e),o=getClickType(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,n,r){let l,a=queryPos(t,e),h=rangeForClick(t,a.pos,a.bias,o);if(i.pos!=a.pos&&!n){let e=rangeForClick(t,i.pos,i.bias,o),s=Math.min(e.from,h.from),n=Math.max(e.to,h.to);h=s<h.from?EditorSelection.range(s,n):EditorSelection.range(n,s)}return n?s.replaceRange(s.main.extend(h.from,h.to)):r&&1==o&&s.ranges.length>1&&(l=removeRangeAround(s,a.pos))?l:r?s.addRange(h):EditorSelection.create([h])}}}function removeRangeAround(t,e){for(let i=0;i<t.ranges.length;i++){let{from:o,to:s}=t.ranges[i];if(o<=e&&s>=e)return EditorSelection.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}function dropText(t,e,i,o){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:n}=t.inputState,r=o&&n&&n.dragging&&n.dragMove?{from:n.dragging.from,to:n.dragging.to}:null,l={from:s,insert:i},a=t.state.changes(r?[r,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:r?"move.drop":"input.drop"})}function captureCopy(t,e){let i=t.dom.parentNode;if(!i)return;let o=i.appendChild(document.createElement("textarea"));o.style.cssText="position: fixed; left: -10000px; top: 10px",o.value=e,o.focus(),o.selectionEnd=e.length,o.selectionStart=0,setTimeout((()=>{o.remove(),t.focus()}),50)}function copiedRange(t){let e=[],i=[],o=!1;for(let o of t.selection.ranges)o.empty||(e.push(t.sliceDoc(o.from,o.to)),i.push(o));if(!e.length){let s=-1;for(let{from:o}of t.selection.ranges){let n=t.doc.lineAt(o);n.number>s&&(e.push(n.text),i.push({from:n.from,to:Math.min(t.doc.length,n.to+1)})),s=n.number}o=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:o}}handlers.dragstart=(t,e)=>{let{selection:{main:i}}=t.state,{mouseSelection:o}=t.inputState;o&&(o.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},handlers.drop=(t,e)=>{if(!e.dataTransfer)return;if(t.state.readOnly)return e.preventDefault();let i=e.dataTransfer.files;if(i&&i.length){e.preventDefault();let o=Array(i.length),s=0,n=()=>{++s==i.length&&dropText(t,e,o.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=n,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(o[t]=e.result),n()},e.readAsText(i[t])}}else dropText(t,e,e.dataTransfer.getData("Text"),!0)},handlers.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=brokenClipboardAPI?null:e.clipboardData;i?(doPaste(t,i.getData("text/plain")||i.getData("text/uri-text")),e.preventDefault()):capturePaste(t)};let lastLinewiseCopy=null;handlers.copy=handlers.cut=(t,e)=>{let{text:i,ranges:o,linewise:s}=copiedRange(t.state);if(!i&&!s)return;lastLinewiseCopy=s?i:null;let n=brokenClipboardAPI?null:e.clipboardData;n?(e.preventDefault(),n.clearData(),n.setData("text/plain",i)):captureCopy(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:o,scrollIntoView:!0,userEvent:"delete.cut"})};const isFocusChange=Annotation.define();function focusChangeTransaction(t,e){let i=[];for(let o of t.facet(focusChangeEffect)){let s=o(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:isFocusChange.of(!0)}):null}function updateForFocusChange(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=focusChangeTransaction(t.state,e);i?t.dispatch(i):t.update([])}}),10)}handlers.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),updateForFocusChange(t)},handlers.blur=t=>{t.observer.clearSelectionRange(),updateForFocusChange(t)},handlers.compositionstart=handlers.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},handlers.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,browser.chrome&&browser.android&&t.observer.flushSoon(),setTimeout((()=>{t.inputState.composing<0&&t.docView.compositionDeco.size&&t.update([])}),50)},handlers.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},handlers.beforeinput=(t,e)=>{var i;let o;if(browser.chrome&&browser.android&&(o=PendingKeys.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(o.key,o.keyCode),"Backspace"==o.key||"Delete"==o.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}};const wrappingWhiteSpace=["pre-wrap","normal","pre-line","break-spaces"];class HeightOracle{constructor(t){this.lineWrapping=t,this.doc=Text.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return wrappingWhiteSpace.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let o=t[i];o<0?i++:this.heightSamples[Math.floor(10*o)]||(e=!0,this.heightSamples[Math.floor(10*o)]=!0)}return e}refresh(t,e,i,o,s,n){let r=wrappingWhiteSpace.indexOf(t)>-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=o,this.lineLength=s,l){this.heightSamples={};for(let t=0;t<n.length;t++){let e=n[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return l}}class MeasuredHeights{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class BlockInfo{constructor(t,e,i,o,s){this.from=t,this.length=e,this.top=i,this.height=o,this.type=s}get to(){return this.from+this.length}get bottom(){return this.top+this.height}join(t){let e=(Array.isArray(this.type)?this.type:[this]).concat(Array.isArray(t.type)?t.type:[t]);return new BlockInfo(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var QueryType=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(QueryType||(QueryType={}));const Epsilon=.001;class HeightMap{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>.001&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return HeightMap.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,o){let s=this,n=i.doc;for(let r=o.length-1;r>=0;r--){let{fromA:l,toA:a,fromB:h,toB:c}=o[r],d=s.lineAt(l,QueryType.ByPosNoHeight,i.setDoc(e),0,0),u=d.to>=a?d:s.lineAt(a,QueryType.ByPosNoHeight,i,0,0);for(c+=u.to-a,a=u.to;r>0&&d.from<=o[r-1].toA;)l=o[r-1].fromA,h=o[r-1].fromB,r--,l<d.from&&(d=s.lineAt(l,QueryType.ByPosNoHeight,i,0,0));h+=d.from-l,l=d.from;let p=NodeBuilder.build(i.setDoc(n),t,h,c);s=s.replace(l,a,p)}return s.updateHeight(i,0)}static empty(){return new HeightMapText(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,o=0,s=0;for(;;)if(e==i)if(o>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,o-=s.size}else{if(!(s>2*o))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(o<s){let i=t[e++];i&&(o+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let n=0;return null==t[e-1]?(n=1,e--):null==t[e]&&(n=1,i++),new HeightMapBranch(HeightMap.of(t.slice(0,e)),n,HeightMap.of(t.slice(i)))}}HeightMap.prototype.size=1;class HeightMapBlock extends HeightMap{constructor(t,e,i){super(t,e),this.type=i}blockAt(t,e,i,o){return new BlockInfo(o,this.length,i,this.height,this.type)}lineAt(t,e,i,o,s){return this.blockAt(0,i,o,s)}forEachLine(t,e,i,o,s,n){t<=s+this.length&&e>=s&&n(this.blockAt(0,i,o,s))}updateHeight(t,e=0,i=!1,o){return o&&o.from<=e&&o.more&&this.setHeight(t,o.heights[o.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class HeightMapText extends HeightMapBlock{constructor(t,e){super(t,e,BlockType.Text),this.collapsed=0,this.widgetHeight=0}replace(t,e,i){let o=i[0];return 1==i.length&&(o instanceof HeightMapText||o instanceof HeightMapGap&&4&o.flags)&&Math.abs(this.length-o.length)<10?(o instanceof HeightMapGap?o=new HeightMapText(o.length,this.height):o.height=this.height,this.outdated||(o.outdated=!1),o):HeightMap.of(i)}updateHeight(t,e=0,i=!1,o){return o&&o.from<=e&&o.more?this.setHeight(t,o.heights[o.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class HeightMapGap extends HeightMap{constructor(t){super(t,0)}heightMetrics(t,e){let i,o=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,n=s-o+1,r=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*n);i=e/n,this.length>n+1&&(r=(this.height-e)/(this.length-n-1))}else i=this.height/n;return{firstLine:o,lastLine:s,perLine:i,perChar:r}}blockAt(t,e,i,o){let{firstLine:s,lastLine:n,perLine:r,perChar:l}=this.heightMetrics(e,o);if(e.lineWrapping){let s=o+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),n=e.doc.lineAt(s),a=r+n.length*l,h=Math.max(i,t-a/2);return new BlockInfo(n.from,n.length,h,a,BlockType.Text)}{let o=Math.max(0,Math.min(n-s,Math.floor((t-i)/r))),{from:l,length:a}=e.doc.line(s+o);return new BlockInfo(l,a,i+r*o,r,BlockType.Text)}}lineAt(t,e,i,o,s){if(e==QueryType.ByHeight)return this.blockAt(t,i,o,s);if(e==QueryType.ByPosNoHeight){let{from:e,to:o}=i.doc.lineAt(t);return new BlockInfo(e,o-e,0,0,BlockType.Text)}let{firstLine:n,perLine:r,perChar:l}=this.heightMetrics(i,s),a=i.doc.lineAt(t),h=r+a.length*l,c=a.number-n,d=o+r*c+l*(a.from-s-c);return new BlockInfo(a.from,a.length,Math.max(o,Math.min(d,o+this.height-h)),h,BlockType.Text)}forEachLine(t,e,i,o,s,n){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:r,perLine:l,perChar:a}=this.heightMetrics(i,s);for(let h=t,c=o;h<=e;){let e=i.doc.lineAt(h);if(h==t){let i=e.number-r;c+=l*i+a*(t-s-i)}let o=l+a*e.length;n(new BlockInfo(e.from,e.length,c,o,BlockType.Text)),c+=o,h=e.to+1}}replace(t,e,i){let o=this.length-e;if(o>0){let t=i[i.length-1];t instanceof HeightMapGap?i[i.length-1]=new HeightMapGap(t.length+o):i.push(null,new HeightMapGap(o-1))}if(t>0){let e=i[0];e instanceof HeightMapGap?i[0]=new HeightMapGap(t+e.length):i.unshift(new HeightMapGap(t-1),null)}return HeightMap.of(i)}decomposeLeft(t,e){e.push(new HeightMapGap(t-1),null)}decomposeRight(t,e){e.push(null,new HeightMapGap(this.length-t-1))}updateHeight(t,e=0,i=!1,o){let s=e+this.length;if(o&&o.from<=e+this.length&&o.more){let i=[],n=Math.max(e,o.from),r=-1;for(o.from>e&&i.push(new HeightMapGap(o.from-e-1).updateHeight(t,e));n<=s&&o.more;){let e=t.doc.lineAt(n).length;i.length&&i.push(null);let s=o.heights[o.index++];-1==r?r=s:Math.abs(s-r)>=.001&&(r=-2);let l=new HeightMapText(e,s);l.outdated=!1,i.push(l),n+=e+1}n<=s&&i.push(null,new HeightMapGap(s-n).updateHeight(t,n));let l=HeightMap.of(i);return(r<0||Math.abs(l.height-this.height)>=.001||Math.abs(r-this.heightMetrics(t,e).perLine)>=.001)&&(t.heightChanged=!0),l}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class HeightMapBranch extends HeightMap{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,o){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,o):this.right.blockAt(t,e,s,o+this.left.length+this.break)}lineAt(t,e,i,o,s){let n=o+this.left.height,r=s+this.left.length+this.break,l=e==QueryType.ByHeight?t<n:t<r,a=l?this.left.lineAt(t,e,i,o,s):this.right.lineAt(t,e,i,n,r);if(this.break||(l?a.to<r:a.from>r))return a;let h=e==QueryType.ByPosNoHeight?QueryType.ByPosNoHeight:QueryType.ByPos;return l?a.join(this.right.lineAt(r,h,i,n,r)):this.left.lineAt(r,h,i,o,s).join(a)}forEachLine(t,e,i,o,s,n){let r=o+this.left.height,l=s+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,o,s,n),e>=l&&this.right.forEachLine(t,e,i,r,l,n);else{let a=this.lineAt(l,QueryType.ByPos,i,o,s);t<a.from&&this.left.forEachLine(t,a.from-1,i,o,s,n),a.to>=t&&a.from<=e&&n(a),e>a.to&&this.right.forEachLine(a.to+1,e,i,r,l,n)}}replace(t,e,i){let o=this.left.length+this.break;if(e<o)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-o,e-o,i));let s=[];t>0&&this.decomposeLeft(t,s);let n=s.length;for(let t of i)s.push(t);if(t>0&&mergeGaps(s,n-1),e<this.length){let t=s.length;this.decomposeRight(e,s),mergeGaps(s,t)}return HeightMap.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,o=i+this.break;if(t>=o)return this.right.decomposeRight(t-o,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<o&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?HeightMap.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,o){let{left:s,right:n}=this,r=e+s.length+this.break,l=null;return o&&o.from<=e+s.length&&o.more?l=s=s.updateHeight(t,e,i,o):s.updateHeight(t,e,i),o&&o.from<=r+n.length&&o.more?l=n=n.updateHeight(t,r,i,o):n.updateHeight(t,r,i),l?this.balanced(s,n):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function mergeGaps(t,e){let i,o;null==t[e]&&(i=t[e-1])instanceof HeightMapGap&&(o=t[e+1])instanceof HeightMapGap&&t.splice(e-1,3,new HeightMapGap(i.length+1+o.length))}const relevantWidgetHeight=5;class NodeBuilder{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof HeightMapText?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new HeightMapText(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let o=i.widget?i.widget.estimatedHeight:0;o<0&&(o=this.oracle.lineHeight);let s=e-t;i.block?this.addBlock(new HeightMapBlock(s,o,i.type)):(s||o>=5)&&this.addLineDeco(o,s)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new HeightMapText(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new HeightMapGap(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof HeightMapText)return t;let e=new HeightMapText(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine(),t.type!=BlockType.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=BlockType.WidgetBefore&&(this.covering=t)}addLineDeco(t,e){let i=this.ensureLine();i.length+=e,i.collapsed+=e,i.widgetHeight=Math.max(i.widgetHeight,t),this.writtenTo=this.pos=this.pos+e}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof HeightMapText||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new HeightMapText(0,-1));let i=t;for(let t of this.nodes)t instanceof HeightMapText&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,o){let s=new NodeBuilder(i,t);return RangeSet.spans(e,i,o,s,0),s.finish(i)}}function heightRelevantDecoChanges(t,e,i){let o=new DecorationComparator;return RangeSet.compare(t,e,i,o,0),o.changes}class DecorationComparator{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,o){(t<e||i&&i.heightRelevant||o&&o.heightRelevant)&&addRange(t,e,this.changes,5)}}function visiblePixelRange(t,e){let i=t.getBoundingClientRect(),o=t.ownerDocument,s=o.defaultView||window,n=Math.max(0,i.left),r=Math.min(s.innerWidth,i.right),l=Math.max(0,i.top),a=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=o.body;)if(1==e.nodeType){let i=e,o=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=o.overflow){let o=i.getBoundingClientRect();n=Math.max(n,o.left),r=Math.min(r,o.right),l=Math.max(l,o.top),a=e==t.parentNode?o.bottom:Math.min(a,o.bottom)}e="absolute"==o.position||"fixed"==o.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:n-i.left,right:Math.max(n,r)-i.left,top:l-(i.top+e),bottom:Math.max(l,a)-(i.top+e)}}function fullPixelRange(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class LineGap{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let o=t[i],s=e[i];if(o.from!=s.from||o.to!=s.to||o.size!=s.size)return!1}return!0}draw(t){return Decoration.replace({widget:new LineGapWidget(this.size,t)}).range(this.from,this.to)}}class LineGapWidget extends WidgetType{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class ViewState{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaler=IdScaler,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Direction.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(contentAttributes).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new HeightOracle(e),this.stateDeco=t.facet(decorations).filter((t=>"function"!=typeof t)),this.heightMap=HeightMap.empty().applyChanges(this.stateDeco,Text.empty,this.heightOracle.setDoc(t.doc),[new ChangedRange(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Decoration.set(this.lineGaps.map((t=>t.draw(!1)))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let o=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>o>=t&&o<=e))){let{from:e,to:i}=this.lineBlockAt(o);t.push(new Viewport(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?IdScaler:new BigScaler(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:scaleBlock(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(decorations).filter((t=>"function"!=typeof t));let o=t.changedRanges,s=ChangedRange.extendWithRanges(o,heightRelevantDecoChanges(i,this.stateDeco,t?t.changes:ChangeSet.empty(this.state.doc.length))),n=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=n&&(t.flags|=2);let r=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<r.from||e.range.head>r.to)||!this.viewportIsAppropriate(r))&&(r=this.getViewport(0,e));let l=!t.changes.empty||2&t.flags||r.from!=this.viewport.from||r.to!=this.viewport.to;this.viewport=r,this.updateForViewport(),l&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(nativeSelectionHidden)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),o=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Direction.RTL:Direction.LTR;let n=this.heightOracle.mustRefreshForWrapping(s),r=e.getBoundingClientRect(),l=n||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let a=0,h=0,c=parseInt(i.paddingTop)||0,d=parseInt(i.paddingBottom)||0;this.paddingTop==c&&this.paddingBottom==d||(this.paddingTop=c,this.paddingBottom=d,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(o.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let u=(this.printing?fullPixelRange:visiblePixelRange)(e,this.paddingTop),p=u.top-this.pixelViewport.top,f=u.bottom-this.pixelViewport.bottom;this.pixelViewport=u;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let m=r.width;if(this.contentDOMWidth==m&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=r.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(e)&&(n=!0),n||o.lineWrapping&&Math.abs(m-this.contentDOMWidth)>o.charWidth){let{lineHeight:i,charWidth:r,textHeight:l}=t.docView.measureTextSize();n=i>0&&o.refresh(s,i,r,l,m/r,e),n&&(t.docView.minWidth=0,a|=8)}p>0&&f>0?h=Math.max(p,f):p<0&&f<0&&(h=Math.min(p,f)),o.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(n?HeightMap.empty().applyChanges(this.stateDeco,Text.empty,this.heightOracle,[new ChangedRange(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(o,0,n,new MeasuredHeights(i.from,s))}o.heightChanged&&(a|=2)}let w=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return w&&(this.viewport=this.getViewport(h,this.scrollTarget)),this.updateForViewport(),(2&a||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(n?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),o=this.heightMap,s=this.heightOracle,{visibleTop:n,visibleBottom:r}=this,l=new Viewport(o.lineAt(n-1e3*i,QueryType.ByHeight,s,0,0).from,o.lineAt(r+1e3*(1-i),QueryType.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let i,n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=o.lineAt(t,QueryType.ByPos,s,0,0);i="center"==e.y?(r.top+r.bottom)/2-n/2:"start"==e.y||"nearest"==e.y&&t<l.from?r.top:r.bottom-n,l=new Viewport(o.lineAt(i-500,QueryType.ByHeight,s,0,0).from,o.lineAt(i+n+500,QueryType.ByHeight,s,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),o=e.mapPos(t.to,1);return new Viewport(this.heightMap.lineAt(i,QueryType.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(o,QueryType.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:o}=this.heightMap.lineAt(t,QueryType.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,QueryType.ByPos,this.heightOracle,0,0),{visibleTop:n,visibleBottom:r}=this;return(0==t||o<=n-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=r+Math.max(10,Math.min(i,250)))&&o>n-2e3&&s<r+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let o of t)e.touchesRange(o.from,o.to)||i.push(new LineGap(e.mapPos(o.from),e.mapPos(o.to),o.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,o=i?1e4:2e3,s=o>>1,n=o<<1;if(this.defaultTextDirection!=Direction.LTR&&!i)return[];let r=[],l=(o,n,a,h)=>{if(n-o<s)return;let c=this.state.selection.main,d=[c.from];c.empty||d.push(c.to);for(let t of d)if(t>o&&t<n)return l(o,t-10,a,h),void l(t+10,n,a,h);let u=find(t,(t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-o)<s&&Math.abs(t.to-n)<s&&!d.some((e=>t.from<e&&t.to>e))));if(!u){if(n<a.to&&e&&i&&e.visibleRanges.some((t=>t.from<=n&&t.to>=n))){let t=e.moveToLineBoundary(EditorSelection.cursor(n),!1,!0).head;t>o&&(n=t)}u=new LineGap(o,n,this.gapSize(a,o,n,h))}r.push(u)};for(let t of this.viewportLines){if(t.length<n)continue;let e=lineStructure(t.from,t.to,this.stateDeco);if(e.total<n)continue;let s,r,a=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,n,l=o/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=a){let o=findFraction(e,a),s=((this.visibleBottom-this.visibleTop)/2+l)/t.height;i=o-s,n=o+s}else i=(this.visibleTop-t.top-l)/t.height,n=(this.visibleBottom-t.top+l)/t.height;s=findPosition(e,i),r=findPosition(e,n)}else{let t,i,n=e.total*this.heightOracle.charWidth,l=o*this.heightOracle.charWidth;if(null!=a){let o=findFraction(e,a),s=((this.pixelViewport.right-this.pixelViewport.left)/2+l)/n;t=o-s,i=o+s}else t=(this.pixelViewport.left-l)/n,i=(this.pixelViewport.right+l)/n;s=findPosition(e,t),r=findPosition(e,i)}s>t.from&&l(t.from,s,t,e),r<t.to&&l(r,t.to,t,e)}return r}gapSize(t,e,i,o){let s=findFraction(o,i)-findFraction(o,e);return this.heightOracle.lineWrapping?t.height*s:o.total*this.heightOracle.charWidth*s}updateLineGaps(t){LineGap.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Decoration.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];RangeSet.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||scaleBlock(this.heightMap.lineAt(t,QueryType.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(t),QueryType.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Viewport{constructor(t,e){this.from=t,this.to=e}}function lineStructure(t,e,i){let o=[],s=t,n=0;return RangeSet.spans(i,t,e,{span(){},point(t,e){t>s&&(o.push({from:s,to:t}),n+=t-s),s=e}},20),s<e&&(o.push({from:s,to:e}),n+=e-s),{total:n,ranges:o}}function findPosition({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let o=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],n=s-i;if(o<=n)return i+o;o-=n}}function findFraction(t,e){let i=0;for(let{from:o,to:s}of t.ranges){if(e<=s){i+=e-o;break}i+=s-o}return i/t.total}function find(t,e){for(let i of t)if(e(i))return i}const IdScaler={toDOM:t=>t,fromDOM:t=>t,scale:1};class BigScaler{constructor(t,e,i){let o=0,s=0,n=0;this.viewports=i.map((({from:i,to:s})=>{let n=e.lineAt(i,QueryType.ByPos,t,0,0).top,r=e.lineAt(s,QueryType.ByPos,t,0,0).bottom;return o+=r-n,{from:i,to:s,top:n,bottom:r,domTop:0,domBottom:0}})),this.scale=(7e6-o)/(e.height-o);for(let t of this.viewports)t.domTop=n+(t.top-s)*this.scale,n=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,o=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return o+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,o=s.domBottom}}fromDOM(t){for(let e=0,i=0,o=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-o)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,o=s.domBottom}}}function scaleBlock(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),o=e.toDOM(t.bottom);return new BlockInfo(t.from,t.length,i,o-i,Array.isArray(t.type)?t.type.map((t=>scaleBlock(t,e))):t.type)}const theme=Facet.define({combine:t=>t.join(" ")}),darkTheme=Facet.define({combine:t=>t.indexOf(!0)>-1}),baseThemeID=StyleModule.newName(),baseLightID=StyleModule.newName(),baseDarkID=StyleModule.newName(),lightDarkIDs={"&light":"."+baseLightID,"&dark":"."+baseDarkID};function buildTheme(t,e,i){return new StyleModule(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const baseTheme$1=buildTheme("."+baseThemeID,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},lightDarkIDs);class DOMChange{constructor(t,e,i,o){this.typeOver=o,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:n}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||n?[]:selectionPoints(t),i=new DOMReader(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=selectionFromPoints(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!contains(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),o=n&&n.node==e.anchorNode&&n.offset==e.anchorOffset||!contains(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=EditorSelection.single(o,i)}}}function applyDOMChange(t,e){let i,{newSel:o}=e,s=t.state.selection.main;if(e.bounds){let{from:o,to:n}=e.bounds,r=s.from,l=null;(8===t.inputState.lastKeyCode&&t.inputState.lastKeyTime>Date.now()-100||browser.android&&e.text.length<n-o)&&(r=s.to,l="end");let a=findDiff(t.state.doc.sliceString(o,n,"ï¿¿"),e.text,r-o,l);a&&(browser.chrome&&13==t.inputState.lastKeyCode&&a.toB==a.from+2&&"ï¿¿ï¿¿"==e.text.slice(a.from,a.toB)&&a.toB--,i={from:o+a.from,to:o+a.toA,insert:Text.of(e.text.slice(a.from,a.toB).split("ï¿¿"))})}else o&&(!t.hasFocus&&t.state.facet(editable)||o.main.eq(s))&&(o=null);if(!i&&!o)return!1;if(!i&&e.typeOver&&!s.empty&&o&&o.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(browser.mac||browser.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(o&&2==i.insert.length&&(o=EditorSelection.single(o.main.anchor-1,o.main.head-1)),i={from:s.from,to:s.to,insert:Text.of([" "])}):browser.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(o&&(o=EditorSelection.single(o.main.anchor-1,o.main.head-1)),i={from:s.from,to:s.to,insert:Text.of([" "])}),i){let e=t.state;if(browser.ios&&t.inputState.flushIOSKey(t))return!0;if(browser.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&dispatchKey(t.contentDOM,"Enter",13)||i.from==s.from-1&&i.to==s.to&&0==i.insert.length&&dispatchKey(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&dispatchKey(t.contentDOM,"Delete",46)))return!0;let n,r=i.insert.toString();if(t.state.facet(inputHandler).some((e=>e(t,i.from,i.to,r))))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=s.from&&i.to<=s.to&&i.to-i.from>=(s.to-s.from)/3&&(!o||o.main.empty&&o.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let o=s.from<i.from?e.sliceDoc(s.from,i.from):"",r=s.to>i.to?e.sliceDoc(i.to,s.to):"";n=e.replaceSelection(t.state.toText(o+i.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=e.changes(i),l=o&&o.main.to<=r.newLength?o.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=s.to&&i.to>=s.to-10){let o=t.state.sliceDoc(i.from,i.to),a=compositionSurroundingNode(t)||t.state.doc.lineAt(s.head),h=s.to-i.to,c=s.to-s.from;n=e.changeByRange((n=>{if(n.from==s.from&&n.to==s.to)return{changes:r,range:l||n.map(r)};let d=n.to-h,u=d-o.length;if(n.to-n.from!=c||t.state.sliceDoc(u,d)!=o||a&&n.to>=a.from&&n.from<=a.to)return{range:n};let p=e.changes({from:u,to:d,insert:i.insert}),f=n.to-s.to;return{changes:p,range:l?EditorSelection.range(Math.max(0,l.anchor+f),Math.max(0,l.head+f)):n.map(p)}}))}else n={changes:r,selection:l&&e.selection.replaceRange(l)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(n,{scrollIntoView:!0,userEvent:l}),!0}if(o&&!o.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:o,scrollIntoView:e,userEvent:i}),!0}return!1}function findDiff(t,e,i,o){let s=Math.min(t.length,e.length),n=0;for(;n<s&&t.charCodeAt(n)==e.charCodeAt(n);)n++;if(n==s&&t.length==e.length)return null;let r=t.length,l=e.length;for(;r>0&&l>0&&t.charCodeAt(r-1)==e.charCodeAt(l-1);)r--,l--;if("end"==o){i-=r+Math.max(0,n-Math.min(r,l))-n}if(r<n&&t.length<e.length){n-=i<=n&&i>=r?n-i:0,l=n+(l-r),r=n}else if(l<n){n-=i<=n&&i>=l?n-i:0,r=n+(r-l),l=n}return{from:n,toA:r,toB:l}}function selectionPoints(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:n}=t.observer.selectionRange;return i&&(e.push(new DOMPoint(i,o)),s==i&&n==o||e.push(new DOMPoint(s,n))),e}function selectionFromPoints(t,e){if(0==t.length)return null;let i=t[0].pos,o=2==t.length?t[1].pos:i;return i>-1&&o>-1?EditorSelection.single(i+e,o+e):null}const observeOptions={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},useCharData=browser.ie&&browser.ie_version<=11;class DOMObserver{constructor(t){this.view=t,this.active=!1,this.selectionRange=new DOMSelectionState,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(browser.ie&&browser.ie_version<=11||browser.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),useCharData&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM),this.resizeContent=new ResizeObserver((()=>this.view.requestMeasure())),this.resizeContent.observe(t.contentDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runScrollHandlers(this.view,t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,o=this.selectionRange;if(i.state.facet(editable)?i.root.activeElement!=this.dom:!hasSelection(i.dom,o))return;let s=o.anchorNode&&i.docView.nearest(o.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(browser.ie&&browser.ie_version<=11||browser.android&&browser.chrome)&&!i.state.selection.main.empty&&o.focusNode&&isEquivalentPosition(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=browser.safari&&11==t.root.nodeType&&deepActiveElement(this.dom.ownerDocument)==this.dom&&safariSelectionRangeHack(this.view)||getSelection(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=hasSelection(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&atElementStart(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,observeOptions),useCharData&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),useCharData&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),!this.flush()&&t.force&&dispatchKey(this.dom,t.key,t.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,o=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(o=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:o}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),o=this.selectionChanged&&hasSelection(this.dom,this.selectionRange);return t<0&&!o?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new DOMChange(this.view,t,e,i))}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return!1;let i=this.view.state,o=applyDOMChange(this.view,e);return this.view.state==i&&this.view.update([]),o}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.dirty|=4),"childList"==t.type){let i=findChild(e,t.previousSibling||t.target.previousSibling,-1),o=findChild(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:o?e.posBefore(o):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i,o;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),null===(o=this.resizeContent)||void 0===o||o.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function findChild(t,e,i){for(;e;){let o=ContentView.get(e);if(o&&o.parent==t)return o;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function safariSelectionRangeHack(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let o=e.startContainer,s=e.startOffset,n=e.endContainer,r=e.endOffset,l=t.docView.domAtPos(t.state.selection.main.anchor);return isEquivalentPosition(l.node,l.offset,n,r)&&([o,s,n,r]=[n,r,o,s]),{anchorNode:o,anchorOffset:s,focusNode:n,focusOffset:r}}class EditorView{constructor(t={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: fixed; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=t.root||getRoot(t.parent)||document,this.viewState=new ViewState(t.state||EditorState.create(t)),this.plugins=this.state.facet(viewPlugin).map((t=>new PluginInstance(t)));for(let t of this.plugins)t.update(this);this.observer=new DOMObserver(this),this.inputState=new InputState(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new DocView(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...t){this._dispatch(1==t.length&&t[0]instanceof Transaction?t[0]:this.state.update(...t))}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,o=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let n=this.hasFocus,r=0,l=null;t.some((t=>t.annotation(isFocusChange)))?(this.inputState.notifiedFocused=n,r=1):n!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=n,l=focusChangeTransaction(s,n),l||(r=1));let a=this.observer.delayedAndroidKey,h=null;if(a?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(EditorState.phrases)!=this.state.facet(EditorState.phrases))return this.setState(s);e=ViewUpdate.create(this,s,t),e.flags|=r;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new ScrollTarget(t.empty?t:EditorSelection.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(scrollIntoView)&&(c=t.value)}this.viewState.update(e,c),this.bidiCache=CachedOrder.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(styleModule)!=this.styleModules&&this.mountStyles(),o=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(theme)!=e.state.facet(theme)&&(this.viewState.mustMeasureContent=!0),(i||o||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(updateListener))t(e);(l||h)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!applyDOMChange(this,h)&&a.force&&dispatchKey(this.contentDOM,a.key,a.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new ViewState(t),this.plugins=t.facet(viewPlugin).map((t=>new PluginInstance(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new DocView(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(viewPlugin),i=t.state.facet(viewPlugin);if(e!=i){let o=[];for(let s of i){let i=e.indexOf(s);if(i<0)o.push(new PluginInstance(s));else{let e=this.plugins[i];e.mustUpdate=t,o.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=o,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this)}measure(t=!0){if(this.destroyed)return;this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,{scrollHeight:i,scrollTop:o,clientHeight:s}=this.scrollDOM,n=o>i-s-4?i:o;try{for(let t=0;;t++){this.updateState=1;let i=this.viewport,o=this.viewState.lineBlockAtHeight(n),s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let r=[];4&s||([this.measureRequests,r]=[r,this.measureRequests]);let l=r.map((t=>{try{return t.read(this)}catch(t){return logException(this.state,t),BadMeasure}})),a=ViewUpdate.create(this,this.state,[]),h=!1,c=!1;a.flags|=s,e?e.flags|=s:e=a,this.updateState=2,a.empty||(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),h=this.docView.update(a));for(let t=0;t<r.length;t++)if(l[t]!=BadMeasure)try{let e=r[t];e.write&&e.write(l[t],this)}catch(t){logException(this.state,t)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,c=!0;else{let t=this.viewState.lineBlockAt(o.from).top-o.top;(t>1||t<-1)&&(this.scrollDOM.scrollTop+=t,c=!0)}if(h&&this.docView.updateSelection(!0),this.viewport.from==i.from&&this.viewport.to==i.to&&!c&&0==this.measureRequests.length)break}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(updateListener))t(e)}get themeClasses(){return baseThemeID+" "+(this.state.facet(darkTheme)?baseDarkID:baseLightID)+" "+this.state.facet(theme)}updateAttrs(){let t=attrsFromFacet(this,editorAttributes,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(editable)?"true":"false",class:"cm-content",style:`${browser.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),attrsFromFacet(this,contentAttributes,e);let i=this.observer.ignore((()=>{let i=updateAttrs(this.contentDOM,this.contentAttrs,e),o=updateAttrs(this.dom,this.editorAttrs,t);return i||o}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(EditorView.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(styleModule),StyleModule.mount(this.root,this.styleModules.concat(baseTheme$1).reverse())}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return skipAtoms(this,t,moveByChar(this,t,e,i))}moveByGroup(t,e){return skipAtoms(this,t,moveByChar(this,t,e,(e=>byGroup(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return moveToLineBoundary(this,t,e,i)}moveVertically(t,e,i){return skipAtoms(this,t,moveVertically(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),posAtCoords(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let o=this.state.doc.lineAt(t),s=this.bidiSpans(o);return flattenRect(i,s[BidiSpan.find(s,t-o.from,-1,e)].dir==Direction.LTR==e>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(perLineTextDirection)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>MaxBidiLine)return trivialOrder(t.length);let e=this.textDirectionAt(t.from);for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e)return i.order;let i=computeOrder(t.text,e);return this.bidiCache.push(new CachedOrder(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||browser.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{focusPreventScroll(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return scrollIntoView.of(new ScrollTarget("number"==typeof t?EditorSelection.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return ViewPlugin.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=StyleModule.newName(),o=[theme.of(i),styleModule.of(buildTheme(`.${i}`,t))];return e&&e.dark&&o.push(darkTheme.of(!0)),o}static baseTheme(t){return Prec.lowest(styleModule.of(buildTheme("."+baseThemeID,t,lightDarkIDs)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),o=i&&ContentView.get(i)||ContentView.get(t);return(null===(e=null==o?void 0:o.rootView)||void 0===e?void 0:e.view)||null}}EditorView.styleModule=styleModule,EditorView.inputHandler=inputHandler,EditorView.focusChangeEffect=focusChangeEffect,EditorView.perLineTextDirection=perLineTextDirection,EditorView.exceptionSink=exceptionSink,EditorView.updateListener=updateListener,EditorView.editable=editable,EditorView.mouseSelectionStyle=mouseSelectionStyle,EditorView.dragMovesSelection=dragMovesSelection$1,EditorView.clickAddsSelectionRange=clickAddsSelectionRange,EditorView.decorations=decorations,EditorView.atomicRanges=atomicRanges,EditorView.scrollMargins=scrollMargins,EditorView.darkTheme=darkTheme,EditorView.contentAttributes=contentAttributes,EditorView.editorAttributes=editorAttributes,EditorView.lineWrapping=EditorView.contentAttributes.of({class:"cm-lineWrapping"}),EditorView.announce=StateEffect.define();const MaxBidiLine=4096,BadMeasure={};class CachedOrder{constructor(t,e,i,o){this.from=t,this.to=e,this.dir=i,this.order=o}static update(t,e){if(e.empty)return t;let i=[],o=t.length?t[t.length-1].dir:Direction.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let n=t[s];n.dir!=o||e.touchesRange(n.from,n.to)||i.push(new CachedOrder(e.mapPos(n.from,1),e.mapPos(n.to,-1),n.dir,n.order))}return i}}function attrsFromFacet(t,e,i){for(let o=t.state.facet(e),s=o.length-1;s>=0;s--){let e=o[s],n="function"==typeof e?e(t):e;n&&combineAttrs(n,i)}return i}const currentPlatform=browser.mac?"mac":browser.windows?"win":browser.linux?"linux":"key";function normalizeKeyName(t,e){const i=t.split(/-(?!$)/);let o,s,n,r,l=i[i.length-1];"Space"==l&&(l=" ");for(let t=0;t<i.length-1;++t){const l=i[t];if(/^(cmd|meta|m)$/i.test(l))r=!0;else if(/^a(lt)?$/i.test(l))o=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))n=!0;else{if(!/^mod$/i.test(l))throw new Error("Unrecognized modifier name: "+l);"mac"==e?r=!0:s=!0}}return o&&(l="Alt-"+l),s&&(l="Ctrl-"+l),r&&(l="Meta-"+l),n&&(l="Shift-"+l),l}function modifiers(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}const handleKeyEvents=Prec.default(EditorView.domEventHandlers({keydown:(t,e)=>runHandlers(getKeymap(e.state),t,e,"editor")})),keymap=Facet.define({enables:handleKeyEvents}),Keymaps=new WeakMap;function getKeymap(t){let e=t.facet(keymap),i=Keymaps.get(e);return i||Keymaps.set(e,i=buildKeymap(e.reduce(((t,e)=>t.concat(e)),[]))),i}function runScopeHandlers(t,e,i){return runHandlers(getKeymap(t.state),e,t,i)}let storedPrefix=null;const PrefixTimeout=4e3;function buildKeymap(t,e=currentPlatform){let i=Object.create(null),o=Object.create(null),s=(t,e)=>{let i=o[t];if(null==i)o[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},n=(t,o,n,r)=>{var l,a;let h=i[t]||(i[t]=Object.create(null)),c=o.split(/ (?!$)/).map((t=>normalizeKeyName(t,e)));for(let e=1;e<c.length;e++){let i=c.slice(0,e).join(" ");s(i,!0),h[i]||(h[i]={preventDefault:!0,run:[e=>{let o=storedPrefix={view:e,prefix:i,scope:t};return setTimeout((()=>{storedPrefix==o&&(storedPrefix=null)}),PrefixTimeout),!0}]})}let d=c.join(" ");s(d,!1);let u=h[d]||(h[d]={preventDefault:!1,run:(null===(a=null===(l=h._any)||void 0===l?void 0:l.run)||void 0===a?void 0:a.slice())||[]});n&&u.run.push(n),r&&(u.preventDefault=!0)};for(let o of t){let t=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,run:[]});for(let e in t)t[e].run.push(o.any)}let s=o[e]||o.key;if(s)for(let e of t)n(e,s,o.run,o.preventDefault),o.shift&&n(e,"Shift-"+s,o.shift,o.preventDefault)}return i}function runHandlers(t,e,i,o){let s=keyName(e),n=codePointAt(s,0),r=codePointSize(n)==s.length&&" "!=s,l="",a=!1;storedPrefix&&storedPrefix.view==i&&storedPrefix.scope==o&&(l=storedPrefix.prefix+" ",(a=modifierCodes.indexOf(e.keyCode)<0)&&(storedPrefix=null));let h,c,d=new Set,u=t=>{if(t){for(let o of t.run)if(!d.has(o)&&(d.add(o),o(i,e)))return!0;t.preventDefault&&(a=!0)}return!1},p=t[o];if(p){if(u(p[l+modifiers(s,e,!r)]))return!0;if(r&&(e.altKey||e.metaKey||e.ctrlKey)&&!(browser.windows&&e.ctrlKey&&e.altKey)&&(h=base[e.keyCode])&&h!=s){if(u(p[l+modifiers(h,e,!0)]))return!0;if(e.shiftKey&&(c=shift[e.keyCode])!=s&&c!=h&&u(p[l+modifiers(c,e,!1)]))return!0}else if(r&&e.shiftKey&&u(p[l+modifiers(s,e,!0)]))return!0;if(u(p._any))return!0}return a}class RectangleMarker{constructor(t,e,i,o,s){this.className=t,this.left=e,this.top=i,this.width=o,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(i.empty){let o=t.coordsAtPos(i.head,i.assoc||1);if(!o)return[];let s=getBase(t);return[new RectangleMarker(e,o.left-s.left,o.top-s.top,null,o.bottom-o.top)]}return rectanglesForRange(t,e,i)}}function getBase(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Direction.LTR?e.left:e.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,top:e.top-t.scrollDOM.scrollTop}}function wrappedLine(t,e,i){let o=EditorSelection.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(o,!1,!0).from),to:Math.min(i.to,t.moveToLineBoundary(o,!0,!0).from),type:BlockType.Text}}function blockAt(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==BlockType.Text))return t;return i}function rectanglesForRange(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let o=Math.max(i.from,t.viewport.from),s=Math.min(i.to,t.viewport.to),n=t.textDirection==Direction.LTR,r=t.contentDOM,l=r.getBoundingClientRect(),a=getBase(t),h=r.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),d=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),p=blockAt(t,o),f=blockAt(t,s),g=p.type==BlockType.Text?p:null,m=f.type==BlockType.Text?f:null;if(t.lineWrapping&&(g&&(g=wrappedLine(t,o,g)),m&&(m=wrappedLine(t,s,m))),g&&m&&g.from==m.from)return v(y(i.from,i.to,g));{let e=g?y(i.from,null,g):b(p,!1),o=m?y(null,i.to,m):b(f,!0),s=[];return(g||p).to<(m||f).from-1?s.push(w(d,e.bottom,u,o.top)):e.bottom<o.top&&t.elementAtHeight((e.bottom+o.top)/2).type==BlockType.Text&&(e.bottom=o.top=(e.bottom+o.top)/2),v(e).concat(s).concat(v(o))}function w(t,i,o,s){return new RectangleMarker(e,t-a.left,i-a.top-.01,o-t,s-i+.01)}function v({top:t,bottom:e,horizontal:i}){let o=[];for(let s=0;s<i.length;s+=2)o.push(w(i[s],t,i[s+1],e));return o}function y(e,i,o){let s=1e9,r=-1e9,l=[];function a(e,i,a,h,c){let p=t.coordsAtPos(e,e==o.to?-2:2),f=t.coordsAtPos(a,a==o.from?2:-2);s=Math.min(p.top,f.top,s),r=Math.max(p.bottom,f.bottom,r),c==Direction.LTR?l.push(n&&i?d:p.left,n&&h?u:f.right):l.push(!n&&h?d:f.left,!n&&i?u:p.right)}let h=null!=e?e:o.from,c=null!=i?i:o.to;for(let o of t.visibleRanges)if(o.to>h&&o.from<c)for(let s=Math.max(o.from,h),n=Math.min(o.to,c);;){let o=t.state.doc.lineAt(s);for(let r of t.bidiSpans(o)){let t=r.from+o.from,l=r.to+o.from;if(t>=n)break;l>s&&a(Math.max(t,s),null==e&&t<=h,Math.min(l,n),null==i&&l>=c,r.dir)}if(s=o.to+1,s>=n)break}return 0==l.length&&a(h,null==e,c,null==i,t.textDirection),{top:s,bottom:r,horizontal:l}}function b(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}function sameMarker(t,e){return t.constructor==e.constructor&&t.eq(e)}class LayerView{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(layerOrder)!=t.state.facet(layerOrder)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&t.view.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(layerOrder);for(;e<i.length&&i[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}draw(t){if(t.length!=this.drawn.length||t.some(((t,e)=>!sameMarker(t,this.drawn[e])))){let e=this.dom.firstChild,i=0;for(let o of t)o.update&&e&&o.constructor&&this.drawn[i].constructor&&o.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(o.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const layerOrder=Facet.define();function layer(t){return[ViewPlugin.define((e=>new LayerView(e,t))),layerOrder.of(t)]}const CanHidePrimary=!browser.ios,selectionConfig=Facet.define({combine:t=>combineConfig(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function drawSelection(t={}){return[selectionConfig.of(t),cursorLayer,selectionLayer,hideNativeSelection,nativeSelectionHidden.of(!0)]}function configChanged(t){return t.startState.facet(selectionConfig)!=t.state.facet(selectionConfig)}const cursorLayer=layer({above:!0,markers(t){let{state:e}=t,i=e.facet(selectionConfig),o=[];for(let s of e.selection.ranges){let n=s==e.selection.main;if(s.empty?!n||CanHidePrimary:i.drawRangeCursor){let e=n?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=s.empty?s:EditorSelection.cursor(s.head,s.head>s.anchor?-1:1);for(let s of RectangleMarker.forRange(t,e,i))o.push(s)}}return o},update(t,e){t.transactions.some((t=>t.selection))&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let i=configChanged(t);return i&&setBlinkRate(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){setBlinkRate(e.state,t)},class:"cm-cursorLayer"});function setBlinkRate(t,e){e.style.animationDuration=t.facet(selectionConfig).cursorBlinkRate+"ms"}const selectionLayer=layer({above:!1,markers:t=>t.state.selection.ranges.map((e=>e.empty?[]:RectangleMarker.forRange(t,"cm-selectionBackground",e))).reduce(((t,e)=>t.concat(e))),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||configChanged(t),class:"cm-selectionLayer"}),themeSpec={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};CanHidePrimary&&(themeSpec[".cm-line"].caretColor="transparent !important");const hideNativeSelection=Prec.highest(EditorView.theme(themeSpec)),setDropCursorPos=StateEffect.define({map:(t,e)=>null==t?null:e.mapPos(t)}),dropCursorPos=StateField.define({create:()=>null,update:(t,e)=>(null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce(((t,e)=>e.is(setDropCursorPos)?e.value:t),t))}),drawDropCursor=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let i=t.state.field(dropCursorPos);null==i?null!=this.cursor&&(null===(e=this.cursor)||void 0===e||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(dropCursorPos)!=i||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let t=this.view.state.field(dropCursorPos),e=null!=t&&this.view.coordsAtPos(t);if(!e)return null;let i=this.view.scrollDOM.getBoundingClientRect();return{left:e.left-i.left+this.view.scrollDOM.scrollLeft,top:e.top-i.top+this.view.scrollDOM.scrollTop,height:e.bottom-e.top}}drawCursor(t){this.cursor&&(t?(this.cursor.style.left=t.left+"px",this.cursor.style.top=t.top+"px",this.cursor.style.height=t.height+"px"):this.cursor.style.left="-100000px")}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(dropCursorPos)!=t&&this.view.dispatch({effects:setDropCursorPos.of(t)})}},{eventHandlers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function dropCursor(){return[dropCursorPos,drawDropCursor]}function iterMatches(t,e,i,o,s){e.lastIndex=0;for(let n,r=t.iterRange(i,o),l=i;!r.next().done;l+=r.value.length)if(!r.lineBreak)for(;n=e.exec(r.value);)s(l+n.index,n)}function matchRanges(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let o=[];for(let{from:s,to:n}of i)s=Math.max(t.state.doc.lineAt(s).from,s-e),n=Math.min(t.state.doc.lineAt(n).to,n+e),o.length&&o[o.length-1].to>=s?o[o.length-1].to=n:o.push({from:s,to:n});return o}class MatchDecorator{constructor(t){const{regexp:e,decoration:i,decorate:o,boundary:s,maxLength:n=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,o)this.addMatch=(t,e,i,s)=>o(s,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,o,s)=>{let n=i(t,e,o);n&&s(o,o+t[0].length,n)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(t,e,o,s)=>s(o,o+t[0].length,i)}this.boundary=s,this.maxLength=n}createDeco(t){let e=new RangeSetBuilder,i=e.add.bind(e);for(let{from:e,to:o}of matchRanges(t,this.maxLength))iterMatches(t.state.doc,this.regexp,e,o,((e,o)=>this.addMatch(o,t,e,i)));return e.finish()}updateDeco(t,e){let i=1e9,o=-1;return t.docChanged&&t.changes.iterChanges(((e,s,n,r)=>{r>t.view.viewport.from&&n<t.view.viewport.to&&(i=Math.min(n,i),o=Math.max(r,o))})),t.viewportChanged||o-i>1e3?this.createDeco(t.view):o>-1?this.updateRange(t.view,e.map(t.changes),i,o):e}updateRange(t,e,i,o){for(let s of t.visibleRanges){let n=Math.max(s.from,i),r=Math.min(s.to,o);if(r>n){let i=t.state.doc.lineAt(n),o=i.to<r?t.state.doc.lineAt(r):i,l=Math.max(s.from,i.from),a=Math.min(s.to,o.to);if(this.boundary){for(;n>i.from;n--)if(this.boundary.test(i.text[n-1-i.from])){l=n;break}for(;r<o.to;r++)if(this.boundary.test(o.text[r-o.from])){a=r;break}}let h,c=[],d=(t,e,i)=>c.push(i.range(t,e));if(i==o)for(this.regexp.lastIndex=l-i.from;(h=this.regexp.exec(i.text))&&h.index<a-i.from;)this.addMatch(h,t,h.index+i.from,d);else iterMatches(t.state.doc,this.regexp,l,a,((e,i)=>this.addMatch(i,t,e,d)));e=e.update({filterFrom:l,filterTo:a,filter:(t,e)=>t<l||e>a,add:c})}}return e}}const UnicodeRegexpSupport=null!=/x/.unicode?"gu":"g",Specials=new RegExp("[\0-\b\n--ÂŸÂØœâ€‹â€Žâ€\u2028\u2029â€â€®â¦â§â©\ufeff-]",UnicodeRegexpSupport),Names={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let _supportsTabSize=null;function supportsTabSize(){var t;if(null==_supportsTabSize&&"undefined"!=typeof document&&document.body){let e=document.body.style;_supportsTabSize=null!=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)}return _supportsTabSize||!1}const specialCharConfig=Facet.define({combine(t){let e=combineConfig(t,{render:null,specialChars:Specials,addSpecialChars:null});return(e.replaceTabs=!supportsTabSize())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,UnicodeRegexpSupport)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,UnicodeRegexpSupport)),e}});function highlightSpecialChars(t={}){return[specialCharConfig.of(t),specialCharPlugin()]}let _plugin=null;function specialCharPlugin(){return _plugin||(_plugin=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.decorations=Decoration.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(specialCharConfig)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new MatchDecorator({regexp:t.specialChars,decoration:(e,i,o)=>{let{doc:s}=i.state,n=codePointAt(e[0],0);if(9==n){let t=s.lineAt(o),e=i.state.tabSize,n=countColumn(t.text,e,o-t.from);return Decoration.replace({widget:new TabWidget((e-n%e)*this.view.defaultCharacterWidth)})}return this.decorationCache[n]||(this.decorationCache[n]=Decoration.replace({widget:new SpecialCharWidget(t,n)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(specialCharConfig);t.startState.facet(specialCharConfig)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const DefaultPlaceholder="•";function placeholder$1(t){return t>=32?"•":10==t?"â¤":String.fromCharCode(9216+t)}class SpecialCharWidget extends WidgetType{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=placeholder$1(this.code),i=t.state.phrase("Control character")+" "+(Names[this.code]||"0x"+this.code.toString(16)),o=this.options.render&&this.options.render(this.code,i,e);if(o)return o;let s=document.createElement("span");return s.textContent=e,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class TabWidget extends WidgetType{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent="\t",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}const plugin=ViewPlugin.fromClass(class{constructor(){this.height=1e3,this.attrs={style:"padding-bottom: 1000px"}}update(t){let{view:e}=t,i=e.viewState.editorHeight-e.defaultLineHeight-e.documentPadding.top-.5;i!=this.height&&(this.height=i,this.attrs={style:`padding-bottom: ${i}px`})}});function scrollPastEnd(){return[plugin,contentAttributes.of((t=>{var e;return(null===(e=t.plugin(plugin))||void 0===e?void 0:e.attrs)||null}))]}function highlightActiveLine(){return activeLineHighlighter}const lineDeco=Decoration.line({class:"cm-activeLine"}),activeLineHighlighter=ViewPlugin.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let o of t.state.selection.ranges){let s=t.lineBlockAt(o.head);s.from>e&&(i.push(lineDeco.range(s.from)),e=s.from)}return Decoration.set(i)}},{decorations:t=>t.decorations});class Placeholder extends WidgetType{constructor(t){super(),this.content=t}toDOM(){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):this.content),"string"==typeof this.content?t.setAttribute("aria-label","placeholder "+this.content):t.setAttribute("aria-hidden","true"),t}ignoreEvent(){return!1}}function placeholder(t){return ViewPlugin.fromClass(class{constructor(e){this.view=e,this.placeholder=Decoration.set([Decoration.widget({widget:new Placeholder(t),side:1}).range(0)])}get decorations(){return this.view.state.doc.length?Decoration.none:this.placeholder}},{decorations:t=>t.decorations})}const MaxOff=2e3;function rectangleFor(t,e,i){let o=Math.min(e.line,i.line),s=Math.max(e.line,i.line),n=[];if(e.off>MaxOff||i.off>MaxOff||e.col<0||i.col<0){let r=Math.min(e.off,i.off),l=Math.max(e.off,i.off);for(let e=o;e<=s;e++){let i=t.doc.line(e);i.length<=l&&n.push(EditorSelection.range(i.from+r,i.to+l))}}else{let r=Math.min(e.col,i.col),l=Math.max(e.col,i.col);for(let e=o;e<=s;e++){let i=t.doc.line(e),o=findColumn(i.text,r,t.tabSize,!0);if(o<0)n.push(EditorSelection.cursor(i.to));else{let e=findColumn(i.text,l,t.tabSize);n.push(EditorSelection.range(i.from+o,i.from+e))}}}return n}function absoluteColumn(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}function getPos(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),o=t.state.doc.lineAt(i),s=i-o.from,n=s>MaxOff?-1:s==o.length?absoluteColumn(t,e.clientX):countColumn(o.text,t.state.tabSize,i-o.from);return{line:o.number,col:n,off:s}}function rectangleSelectionStyle(t,e){let i=getPos(t,e),o=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),s=t.state.doc.lineAt(e);i={line:s.number,col:i.col,off:Math.min(i.off,s.length)},o=o.map(t.changes)}},get(e,s,n){let r=getPos(t,e);if(!r)return o;let l=rectangleFor(t.state,i,r);return l.length?n?EditorSelection.create(l.concat(o.ranges)):EditorSelection.create(l):o}}:null}function rectangularSelection(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return EditorView.mouseSelectionStyle.of(((t,i)=>e(i)?rectangleSelectionStyle(t,i):null))}const keys={Alt:[18,t=>t.altKey],Control:[17,t=>t.ctrlKey],Shift:[16,t=>t.shiftKey],Meta:[91,t=>t.metaKey]},showCrosshair={style:"cursor: crosshair"};function crosshairCursor(t={}){let[e,i]=keys[t.key||"Alt"],o=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventHandlers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(!1)},mousemove(t){this.set(i(t))}}});return[o,EditorView.contentAttributes.of((t=>{var e;return(null===(e=t.plugin(o))||void 0===e?void 0:e.isDown)?showCrosshair:null}))]}const Outside="-10000px";class TooltipViewManager{constructor(t,e,i){this.facet=e,this.createTooltipView=i,this.input=t.state.facet(e),this.tooltips=this.input.filter((t=>t)),this.tooltipViews=this.tooltips.map(i)}update(t){var e;let i=t.state.facet(this.facet),o=i.filter((t=>t));if(i===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let s=[];for(let e=0;e<o.length;e++){let i=o[e],n=-1;if(i){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==i.create&&(n=t)}if(n<0)s[e]=this.createTooltipView(i);else{let i=s[e]=this.tooltipViews[n];i.update&&i.update(t)}}}for(let t of this.tooltipViews)s.indexOf(t)<0&&(t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t));return this.input=i,this.tooltips=o,this.tooltipViews=s,!0}}function tooltips(t={}){return tooltipConfig.of(t)}function windowSpace(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const tooltipConfig=Facet.define({combine:t=>{var e,i,o;return{position:browser.ios?"absolute":(null===(e=t.find((t=>t.position)))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find((t=>t.parent)))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(o=t.find((t=>t.tooltipSpace)))||void 0===o?void 0:o.tooltipSpace)||windowSpace}}}),knownHeight=new WeakMap,tooltipPlugin=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(tooltipConfig);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new TooltipViewManager(t,showTooltip,(t=>this.createTooltip(t))),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver((t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()}),{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout((()=>{this.measureTimeout=-1,this.maybeMeasure()}),50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t);e&&this.observeIntersection();let i=e||t.geometryChanged,o=t.state.facet(tooltipConfig);if(o.position!=this.position){this.position=o.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=!0}if(o.parent!=this.parent){this.parent&&this.container.remove(),this.parent=o.parent,this.createContainer();for(let t of this.manager.tooltipViews)this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t){let e=t.create(this.view);if(e.dom.classList.add("cm-tooltip"),t.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=Outside,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews)e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);null===(e=this.intersectionObserver)||void 0===e||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect();return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,pos:this.manager.tooltips.map(((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)})),size:this.manager.tooltipViews.map((({dom:t})=>t.getBoundingClientRect())),space:this.view.state.facet(tooltipConfig).tooltipSpace(this.view)}}writeMeasure(t){var e;let{editor:i,space:o}=t,s=[];for(let n=0;n<this.manager.tooltips.length;n++){let r=this.manager.tooltips[n],l=this.manager.tooltipViews[n],{dom:a}=l,h=t.pos[n],c=t.size[n];if(!h||h.bottom<=Math.max(i.top,o.top)||h.top>=Math.min(i.bottom,o.bottom)||h.right<Math.max(i.left,o.left)-.1||h.left>Math.min(i.right,o.right)+.1){a.style.top=Outside;continue}let d=r.arrow?l.dom.querySelector(".cm-tooltip-arrow"):null,u=d?7:0,p=c.right-c.left,f=null!==(e=knownHeight.get(l))&&void 0!==e?e:c.bottom-c.top,g=l.offset||noOffset,m=this.view.textDirection==Direction.LTR,w=c.width>o.right-o.left?m?o.left:o.right-c.width:m?Math.min(h.left-(d?14:0)+g.x,o.right-p):Math.max(o.left,h.left-p+(d?14:0)-g.x),v=!!r.above;!r.strictSide&&(v?h.top-(c.bottom-c.top)-g.y<o.top:h.bottom+(c.bottom-c.top)+g.y>o.bottom)&&v==o.bottom-h.bottom>h.top-o.top&&(v=!v);let y=(v?h.top-o.top:o.bottom-h.bottom)-u;if(y<f&&!1!==l.resize){if(y<this.view.defaultLineHeight){a.style.top=Outside;continue}knownHeight.set(l,f),a.style.height=(f=y)+"px"}else a.style.height&&(a.style.height="");let b=v?h.top-f-u-g.y:h.bottom+u+g.y,S=w+p;if(!0!==l.overlap)for(let t of s)t.left<S&&t.right>w&&t.top<b+f&&t.bottom>b&&(b=v?t.top-f-2-u:t.bottom+u+2);"absolute"==this.position?(a.style.top=b-t.parent.top+"px",a.style.left=w-t.parent.left+"px"):(a.style.top=b+"px",a.style.left=w+"px"),d&&(d.style.left=h.left+(m?g.x:-g.x)-(w+14-7)+"px"),!0!==l.overlap&&s.push({left:w,top:b,right:S,bottom:b+f}),a.classList.toggle("cm-tooltip-above",v),a.classList.toggle("cm-tooltip-below",!v),l.positioned&&l.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Outside}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),baseTheme=EditorView.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),noOffset={x:0,y:0},showTooltip=Facet.define({enables:[tooltipPlugin,baseTheme]}),showHoverTooltip=Facet.define();class HoverTooltipHost{constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new TooltipViewManager(t,showHoverTooltip,(t=>this.createHostedView(t)))}static create(t){return new HoverTooltipHost(t)}createHostedView(t){let e=t.create(this.view);return e.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(e.dom),this.mounted&&e.mount&&e.mount(this.view),e}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null===(t=e.destroy)||void 0===t||t.call(e)}}const showHoverTooltipHost=showTooltip.compute([showHoverTooltip],(t=>{let e=t.facet(showHoverTooltip).filter((t=>t));return 0===e.length?null:{pos:Math.min(...e.map((t=>t.pos))),end:Math.max(...e.filter((t=>null!=t.end)).map((t=>t.end))),create:HoverTooltipHost.create,above:e[0].above,arrow:e.some((t=>t.arrow))}}));class HoverPlugin{constructor(t,e,i,o,s){this.view=t,this.source=e,this.field=i,this.setHover=o,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout((()=>this.startHover()),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{lastMove:t}=this,e=this.view.contentDOM.contains(t.target)?this.view.posAtCoords(t):null;if(null==e)return;let i=this.view.coordsAtPos(e);if(null==i||t.y<i.top||t.y>i.bottom||t.x<i.left-this.view.defaultCharacterWidth||t.x>i.right+this.view.defaultCharacterWidth)return;let o=this.view.bidiSpans(this.view.state.doc.lineAt(e)).find((t=>t.from<=e&&t.to>=e)),s=o&&o.dir==Direction.RTL?-1:1,n=this.source(this.view,e,t.x<i.left?-s:s);if(null==n?void 0:n.then){let t=this.pending={pos:e};n.then((e=>{this.pending==t&&(this.pending=null,e&&this.view.dispatch({effects:this.setHover.of(e)}))}),(t=>logException(this.view.state,t,"hover tooltip")))}else n&&this.view.dispatch({effects:this.setHover.of(n)})}mousemove(t){var e;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let i=this.active;if(i&&!isInTooltip(this.lastMove.target)||this.pending){let{pos:o}=i||this.pending,s=null!==(e=null==i?void 0:i.end)&&void 0!==e?e:o;(o==s?this.view.posAtCoords(this.lastMove)==o:isOverRange(this.view,o,s,t.clientX,t.clientY,6))||(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&!isInTooltip(t.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function isInTooltip(t){for(let e=t;e;e=e.parentNode)if(1==e.nodeType&&e.classList.contains("cm-tooltip"))return!0;return!1}function isOverRange(t,e,i,o,s,n){let r=document.createRange(),l=t.domAtPos(e),a=t.domAtPos(i);r.setEnd(a.node,a.offset),r.setStart(l.node,l.offset);let h=r.getClientRects();r.detach();for(let t=0;t<h.length;t++){let e=h[t];if(Math.max(e.top-s,s-e.bottom,e.left-o,o-e.right)<=n)return!0}return!1}function hoverTooltip(t,e={}){let i=StateEffect.define(),o=StateField.define({create:()=>null,update(t,o){if(t&&(e.hideOnChange&&(o.docChanged||o.selection)||e.hideOn&&e.hideOn(o,t)))return null;if(t&&o.docChanged){let e=o.changes.mapPos(t.pos,-1,MapMode.TrackDel);if(null==e)return null;let i=Object.assign(Object.create(null),t);i.pos=e,null!=t.end&&(i.end=o.changes.mapPos(t.end)),t=i}for(let e of o.effects)e.is(i)&&(t=e.value),e.is(closeHoverTooltipEffect)&&(t=null);return t},provide:t=>showHoverTooltip.from(t)});return[o,ViewPlugin.define((s=>new HoverPlugin(s,t,o,i,e.hoverTime||300))),showHoverTooltipHost]}function getTooltip(t,e){let i=t.plugin(tooltipPlugin);if(!i)return null;let o=i.manager.tooltips.indexOf(e);return o<0?null:i.manager.tooltipViews[o]}function hasHoverTooltips(t){return t.facet(showHoverTooltip).some((t=>t))}const closeHoverTooltipEffect=StateEffect.define(),closeHoverTooltips=closeHoverTooltipEffect.of(null);function repositionTooltips(t){var e;null===(e=t.plugin(tooltipPlugin))||void 0===e||e.maybeMeasure()}const panelConfig=Facet.define({combine(t){let e,i;for(let o of t)e=e||o.topContainer,i=i||o.bottomContainer;return{topContainer:e,bottomContainer:i}}});function panels(t){return t?[panelConfig.of(t)]:[]}function getPanel(t,e){let i=t.plugin(panelPlugin),o=i?i.specs.indexOf(e):-1;return o>-1?i.panels[o]:null}const panelPlugin=ViewPlugin.fromClass(class{constructor(t){this.input=t.state.facet(showPanel),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(panelConfig);this.top=new PanelGroup(t,!0,e.topContainer),this.bottom=new PanelGroup(t,!1,e.bottomContainer),this.top.sync(this.panels.filter((t=>t.top))),this.bottom.sync(this.panels.filter((t=>!t.top)));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(t){let e=t.state.facet(panelConfig);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new PanelGroup(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new PanelGroup(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(showPanel);if(i!=this.input){let e=i.filter((t=>t)),o=[],s=[],n=[],r=[];for(let i of e){let e,l=this.specs.indexOf(i);l<0?(e=i(t.view),r.push(e)):(e=this.panels[l],e.update&&e.update(t)),o.push(e),(e.top?s:n).push(e)}this.specs=e,this.panels=o,this.top.sync(s),this.bottom.sync(n);for(let t of r)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>EditorView.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class PanelGroup{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=rm(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=rm(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function rm(t){let e=t.nextSibling;return t.remove(),e}const showPanel=Facet.define({enables:panelPlugin});class GutterMarker extends RangeValue{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}GutterMarker.prototype.elementClass="",GutterMarker.prototype.toDOM=void 0,GutterMarker.prototype.mapMode=MapMode.TrackBefore,GutterMarker.prototype.startSide=GutterMarker.prototype.endSide=-1,GutterMarker.prototype.point=!0;const gutterLineClass=Facet.define(),defaults={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>RangeSet.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},activeGutters=Facet.define();function gutter(t){return[gutters(),activeGutters.of(Object.assign(Object.assign({},defaults),t))]}const unfixGutters=Facet.define({combine:t=>t.some((t=>t))});function gutters(t){let e=[gutterView];return t&&!1===t.fixed&&e.push(unfixGutters.of(!0)),e}const gutterView=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=t.state.facet(activeGutters).map((e=>new SingleGutterView(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(unfixGutters),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,o=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(o<.8*(i.to-i.from))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(unfixGutters)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=RangeSet.iter(this.view.state.facet(gutterLineClass),this.view.viewport.from),o=[],s=this.gutters.map((t=>new UpdateContext(t,this.view.viewport,-this.view.documentPadding.top)));for(let t of this.view.viewportLineBlocks){let e;if(Array.isArray(t.type)){for(let i of t.type)if(i.type==BlockType.Text){e=i;break}}else e=t.type==BlockType.Text?t:void 0;if(e){o.length&&(o=[]),advanceCursor(i,o,t.from);for(let t of s)t.line(this.view,e,o)}}for(let t of s)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(activeGutters),i=t.state.facet(activeGutters),o=t.docChanged||t.heightChanged||t.viewportChanged||!RangeSet.eq(t.startState.facet(gutterLineClass),t.state.facet(gutterLineClass),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(o=!0);else{o=!0;let s=[];for(let o of i){let i=e.indexOf(o);i<0?s.push(new SingleGutterView(this.view,o)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),s.indexOf(t)<0&&t.destroy();for(let t of s)this.dom.appendChild(t.dom);this.gutters=s}return o}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>EditorView.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==Direction.LTR?{left:i.dom.offsetWidth}:{right:i.dom.offsetWidth}:null}))});function asArray(t){return Array.isArray(t)?t:[t]}function advanceCursor(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class UpdateContext{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=RangeSet.iter(t.markers,e.from)}line(t,e,i){let o=[];advanceCursor(this.cursor,o,e.from),i.length&&(o=o.concat(i));let s=this.gutter.config.lineMarker(t,e,o);s&&o.unshift(s);let n=this.gutter;if(0==o.length&&!n.config.renderEmptyElements)return;let r=e.top-this.height;if(this.i==n.elements.length){let i=new GutterElement(t,e.height,r,o);n.elements.push(i),n.dom.appendChild(i.dom)}else n.elements[this.i].update(t,e.height,r,o);this.height=e.bottom,this.i++}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class SingleGutterView{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,(o=>{let s,n=o.target;if(n!=this.dom&&this.dom.contains(n)){for(;n.parentNode!=this.dom;)n=n.parentNode;let t=n.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=o.clientY;let r=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,r,o)&&o.preventDefault()}));this.markers=asArray(e.markers(t)),e.initialSpacer&&(this.spacer=new GutterElement(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=asArray(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!RangeSet.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class GutterElement{constructor(t,e,i,o){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,o)}update(t,e,i,o){this.height!=e&&(this.dom.style.height=(this.height=e)+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),sameMarkers(this.markers,o)||this.setMarkers(t,o)}setMarkers(t,e){let i="cm-gutterElement",o=this.dom.firstChild;for(let s=0,n=0;;){let r=n,l=s<e.length?e[s++]:null,a=!1;if(l){let t=l.elementClass;t&&(i+=" "+t);for(let t=n;t<this.markers.length;t++)if(this.markers[t].compare(l)){r=t,a=!0;break}}else r=this.markers.length;for(;n<r;){let t=this.markers[n++];if(t.toDOM){t.destroy(o);let e=o.nextSibling;o.remove(),o=e}}if(!l)break;l.toDOM&&(a?o=o.nextSibling:this.dom.insertBefore(l.toDOM(t),o)),a&&n++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}function sameMarkers(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}const lineNumberMarkers=Facet.define(),lineNumberConfig=Facet.define({combine:t=>combineConfig(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let o=i[t],s=e[t];i[t]=o?(t,e,i)=>o(t,e,i)||s(t,e,i):s}return i}})});class NumberMarker extends GutterMarker{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function formatNumber(t,e){return t.state.facet(lineNumberConfig).formatNumber(e,t.state)}const lineNumberGutter=activeGutters.compute([lineNumberConfig],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(lineNumberMarkers),lineMarker:(t,e,i)=>i.some((t=>t.toDOM))?null:new NumberMarker(formatNumber(t,t.state.doc.lineAt(e.from).number)),lineMarkerChange:t=>t.startState.facet(lineNumberConfig)!=t.state.facet(lineNumberConfig),initialSpacer:t=>new NumberMarker(formatNumber(t,maxLineNumber(t.state.doc.lines))),updateSpacer(t,e){let i=formatNumber(e.view,maxLineNumber(e.view.state.doc.lines));return i==t.number?t:new NumberMarker(i)},domEventHandlers:t.facet(lineNumberConfig).domEventHandlers})));function lineNumbers(t={}){return[lineNumberConfig.of(t),gutters(),lineNumberGutter]}function maxLineNumber(t){let e=9;for(;e<t;)e=10*e+9;return e}const activeLineGutterMarker=new class extends GutterMarker{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},activeLineGutterHighlighter=gutterLineClass.compute(["selection"],(t=>{let e=[],i=-1;for(let o of t.selection.ranges){let s=t.doc.lineAt(o.head).from;s>i&&(i=s,e.push(activeLineGutterMarker.range(s)))}return RangeSet.of(e)}));function highlightActiveLineGutter(){return activeLineGutterHighlighter}const WhitespaceDeco=new Map;function getWhitespaceDeco(t){let e=WhitespaceDeco.get(t);return e||WhitespaceDeco.set(t,e=Decoration.mark({attributes:"\t"===t?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":t.replace(/ /g,"·")}})),e}function matcher(t){return ViewPlugin.define((e=>({decorations:t.createDeco(e),update(e){this.decorations=t.updateDeco(e,this.decorations)}})),{decorations:t=>t.decorations})}const whitespaceHighlighter=matcher(new MatchDecorator({regexp:/\t| +/g,decoration:t=>getWhitespaceDeco(t[0]),boundary:/\S/}));function highlightWhitespace(){return whitespaceHighlighter}const trailingHighlighter=matcher(new MatchDecorator({regexp:/\s+$/g,decoration:Decoration.mark({class:"cm-trailingSpace"}),boundary:/\S/}));function highlightTrailingWhitespace(){return trailingHighlighter}const __test={HeightMap,HeightOracle,MeasuredHeights,QueryType,ChangedRange,computeOrder,moveVisually};export{BidiSpan,BlockInfo,BlockType,Decoration,Direction,EditorView,GutterMarker,MatchDecorator,RectangleMarker,ViewPlugin,ViewUpdate,WidgetType,__test,closeHoverTooltips,crosshairCursor,drawSelection,dropCursor,getPanel,getTooltip,gutter,gutterLineClass,gutters,hasHoverTooltips,highlightActiveLine,highlightActiveLineGutter,highlightSpecialChars,highlightTrailingWhitespace,highlightWhitespace,hoverTooltip,keymap,layer,lineNumberMarkers,lineNumbers,logException,panels,placeholder,rectangularSelection,repositionTooltips,runScopeHandlers,scrollPastEnd,showPanel,showTooltip,tooltips}; \ No newline at end of file diff --git a/typo3/sysext/t3editor/Resources/Public/JavaScript/Contrib/@lezer/common.js b/typo3/sysext/t3editor/Resources/Public/JavaScript/Contrib/@lezer/common.js index 733aa35c0cffd7ea835dd2e8ce7f8a8111554699..af09dbc6af92bf3ac60ce928960578bf22a156de 100644 --- a/typo3/sysext/t3editor/Resources/Public/JavaScript/Contrib/@lezer/common.js +++ b/typo3/sysext/t3editor/Resources/Public/JavaScript/Contrib/@lezer/common.js @@ -1 +1 @@ -const DefaultBufferLength=1024;let nextPropID=0;class Range{constructor(e,t){this.from=e,this.to=t}}class NodeProp{constructor(e={}){this.id=nextPropID++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=NodeType.match(e)),t=>{let r=e(t);return void 0===r?null:[this,r]}}}NodeProp.closedBy=new NodeProp({deserialize:e=>e.split(" ")}),NodeProp.openedBy=new NodeProp({deserialize:e=>e.split(" ")}),NodeProp.group=new NodeProp({deserialize:e=>e.split(" ")}),NodeProp.contextHash=new NodeProp({perNode:!0}),NodeProp.lookAhead=new NodeProp({perNode:!0}),NodeProp.mounted=new NodeProp({perNode:!0});class MountedTree{constructor(e,t,r){this.tree=e,this.overlay=t,this.parser=r}}const noProps=Object.create(null);class NodeType{constructor(e,t,r,n=0){this.name=e,this.props=t,this.id=r,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):noProps,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),n=new NodeType(e.name||"",t,e.id,r);if(e.props)for(let r of e.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}return n}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(NodeProp.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let n of r.split(" "))t[n]=e[r];return e=>{for(let r=e.prop(NodeProp.group),n=-1;n<(r?r.length:0);n++){let i=t[n<0?e.name:r[n]];if(i)return i}}}}NodeType.none=new NodeType("",Object.create(null),0,8);class NodeSet{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let r of this.types){let n=null;for(let t of e){let e=t(r);e&&(n||(n=Object.assign({},r.props)),n[e[0].id]=e[1])}t.push(n?new NodeType(r.name,n,r.id,r.flags):r)}return new NodeSet(t)}}const CachedNode=new WeakMap,CachedInnerNode=new WeakMap;var IterMode;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(IterMode||(IterMode={}));class Tree{constructor(e,t,r,n,i){if(this.type=e,this.children=t,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=this.prop(NodeProp.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let r=e.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new TreeCursor(this.topNode,e)}cursorAt(e,t=0,r=0){let n=CachedNode.get(this)||this.topNode,i=new TreeCursor(n);return i.moveTo(e,t),CachedNode.set(this,i._tree),i}get topNode(){return new TreeNode(this,0,0,null)}resolve(e,t=0){let r=resolveNode(CachedNode.get(this)||this.topNode,e,t,!1);return CachedNode.set(this,r),r}resolveInner(e,t=0){let r=resolveNode(CachedInnerNode.get(this)||this.topNode,e,t,!0);return CachedInnerNode.set(this,r),r}iterate(e){let{enter:t,leave:r,from:n=0,to:i=this.length}=e;for(let s=this.cursor((e.mode||0)|IterMode.IncludeAnonymous);;){let e=!1;if(s.from<=i&&s.to>=n&&(s.type.isAnonymous||!1!==t(s))){if(s.firstChild())continue;e=!0}for(;e&&r&&!s.type.isAnonymous&&r(s),!s.nextSibling();){if(!s.parent())return;e=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:balanceRange(NodeType.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,r)=>new Tree(this.type,e,t,r,this.propValues)),e.makeTree||((e,t,r)=>new Tree(NodeType.none,e,t,r)))}static build(e){return buildTree(e)}}Tree.empty=new Tree(NodeType.none,[],[],0);class FlatBufferCursor{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new FlatBufferCursor(this.buffer,this.index)}}class TreeBuffer{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return NodeType.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],r=this.buffer[e+3],n=this.set.types[t],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),r==(e+=4))return i;let s=[];for(;e<r;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,t,r,n,i){let{buffer:s}=this,o=-1;for(let h=e;h!=t&&!(checkSide(i,n,s[h+1],s[h+2])&&(o=h,r>0));h=s[h+3]);return o}slice(e,t,r){let n=this.buffer,i=new Uint16Array(t-e),s=0;for(let o=e,h=0;o<t;){i[h++]=n[o++],i[h++]=n[o++]-r;let t=i[h++]=n[o++]-r;i[h++]=n[o++]-e,s=Math.max(s,t)}return new TreeBuffer(i,s,this.set)}}function checkSide(e,t,r,n){switch(e){case-2:return r<t;case-1:return n>=t&&r<t;case 0:return r<t&&n>t;case 1:return r<=t&&n>t;case 2:return n>t;case 4:return!0}}function enterUnfinishedNodesBefore(e,t){let r=e.childBefore(t);for(;r;){let t=r.lastChild;if(!t||t.to!=r.to)break;t.type.isError&&t.from==t.to?(e=r,r=t.prevSibling):r=t}return e}function resolveNode(e,t,r,n){for(var i;e.from==e.to||(r<1?e.from>=t:e.from>t)||(r>-1?e.to<=t:e.to<t);){let t=!n&&e instanceof TreeNode&&e.index<0?null:e.parent;if(!t)return e;e=t}let s=n?0:IterMode.IgnoreOverlays;if(n)for(let n=e,o=n.parent;o;n=o,o=n.parent)n instanceof TreeNode&&n.index<0&&(null===(i=o.enter(t,r,s))||void 0===i?void 0:i.from)!=n.from&&(e=o);for(;;){let n=e.enter(t,r,s);if(!n)return e;e=n}}class TreeNode{constructor(e,t,r,n){this._tree=e,this.from=t,this.index=r,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,n,i=0){for(let s=this;;){for(let{children:o,positions:h}=s._tree,f=t>0?o.length:-1;e!=f;e+=t){let f=o[e],l=h[e]+s.from;if(checkSide(n,r,l,l+f.length))if(f instanceof TreeBuffer){if(i&IterMode.ExcludeBuffers)continue;let o=f.findChild(0,f.buffer.length,t,r-l,n);if(o>-1)return new BufferNode(new BufferContext(s,f,e,l),null,o)}else if(i&IterMode.IncludeAnonymous||!f.type.isAnonymous||hasChild(f)){let o;if(!(i&IterMode.IgnoreMounts)&&f.props&&(o=f.prop(NodeProp.mounted))&&!o.overlay)return new TreeNode(o.tree,l,e,s);let h=new TreeNode(f,l,e,s);return i&IterMode.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(t<0?f.children.length-1:0,t,r,n)}}if(i&IterMode.IncludeAnonymous||!s.type.isAnonymous)return null;if(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,r=0){let n;if(!(r&IterMode.IgnoreOverlays)&&(n=this._tree.prop(NodeProp.mounted))&&n.overlay){let r=e-this.from;for(let{from:e,to:i}of n.overlay)if((t>0?e<=r:e<r)&&(t<0?i>=r:i>r))return new TreeNode(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new TreeCursor(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return resolveNode(this,e,t,!1)}resolveInner(e,t=0){return resolveNode(this,e,t,!0)}enterUnfinishedNodesBefore(e){return enterUnfinishedNodesBefore(this,e)}getChild(e,t=null,r=null){let n=getChildren(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return getChildren(this,e,t,r)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return matchNodeContext(this,e)}}function getChildren(e,t,r,n){let i=e.cursor(),s=[];if(!i.firstChild())return s;if(null!=r)for(;!i.type.is(r);)if(!i.nextSibling())return s;for(;;){if(null!=n&&i.type.is(n))return s;if(i.type.is(t)&&s.push(i.node),!i.nextSibling())return null==n?s:[]}}function matchNodeContext(e,t,r=t.length-1){for(let n=e.parent;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[r]&&t[r]!=n.name)return!1;r--}}return!0}class BufferContext{constructor(e,t,r,n){this.parent=e,this.buffer=t,this.index=r,this.start=n}}class BufferNode{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,r){this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,r);return i<0?null:new BufferNode(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,r=0){if(r&IterMode.ExcludeBuffers)return null;let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new BufferNode(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new BufferNode(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new BufferNode(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new TreeCursor(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1];e.push(r.slice(n,i,s)),t.push(0)}return new Tree(this.type,e,t,this.to-this.from)}resolve(e,t=0){return resolveNode(this,e,t,!1)}resolveInner(e,t=0){return resolveNode(this,e,t,!0)}enterUnfinishedNodesBefore(e){return enterUnfinishedNodesBefore(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,r=null){let n=getChildren(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return getChildren(this,e,t,r)}get node(){return this}matchContext(e){return matchNodeContext(this,e)}}class TreeCursor{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof TreeNode)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:r,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=r+n.buffer[e+1],this.to=r+n.buffer[e+2],!0}yield(e){return!!e&&(e instanceof TreeNode?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,r);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?!(r&IterMode.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&IterMode.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&IterMode.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let e=r<0?0:this.stack[r]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(e)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(n.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:r}=n)}else({index:t,_parent:r}=this._tree);for(;r;({index:t,_parent:r}=r))if(t>-1)for(let n=t+e,i=e<0?-1:r._tree.children.length;n!=i;n+=e){let e=r._tree.children[n];if(this.mode&IterMode.IncludeAnonymous||e instanceof TreeBuffer||!e.type.isAnonymous||hasChild(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,r=0;if(e&&e.context==this.buffer)e:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==n){if(n==this.index)return s;t=s,r=i+1;break e}n=this.stack[--i]}for(let e=r;e<this.stack.length;e++)t=new BufferNode(this.buffer,t,this.stack[e]);return this.bufferNode=new BufferNode(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let n=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){r++;continue}this.type.isAnonymous||(n=!0)}for(;n&&t&&t(this),n=this.type.isAnonymous,!this.nextSibling();){if(!r)return;this.parent(),r--,n=!0}}}matchContext(e){if(!this.buffer)return matchNodeContext(this.node,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let n=e.length-1,i=this.stack.length-1;n>=0;i--){if(i<0)return matchNodeContext(this.node,e,n);let s=r[t.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[n]&&e[n]!=s.name)return!1;n--}}return!0}}function hasChild(e){return e.children.some((e=>e instanceof TreeBuffer||!e.type.isAnonymous||hasChild(e)))}function buildTree(e){var t;let{buffer:r,nodeSet:n,maxBufferLength:i=DefaultBufferLength,reused:s=[],minRepeatType:o=n.types.length}=e,h=Array.isArray(r)?new FlatBufferCursor(r,r.length):r,f=n.types,l=0,u=0;function a(e,t,r,g,m){let{id:x,start:b,end:y,size:N}=h,C=u;for(;N<0;){if(h.next(),-1==N){let t=s[x];return r.push(t),void g.push(b-e)}if(-3==N)return void(l=x);if(-4==N)return void(u=x);throw new RangeError(`Unrecognized record size: ${N}`)}let v,w,T=f[x],I=b-e;if(y-b<=i&&(w=function(e,t){let r=h.fork(),n=0,s=0,f=0,l=r.end-i,u={size:0,start:0,skip:0};e:for(let i=r.pos-e;r.pos>i;){let e=r.size;if(r.id==t&&e>=0){u.size=n,u.start=s,u.skip=f,f+=4,n+=4,r.next();continue}let h=r.pos-e;if(e<0||h<i||r.start<l)break;let a=r.id>=o?4:0,d=r.start;for(r.next();r.pos>h;){if(r.size<0){if(-3!=r.size)break e;a+=4}else r.id>=o&&(a+=4);r.next()}s=d,n+=e,f+=a}(t<0||n==e)&&(u.size=n,u.start=s,u.skip=f);return u.size>4?u:void 0}(h.pos-t,m))){let t=new Uint16Array(w.size-w.skip),r=h.pos-w.size,i=t.length;for(;h.pos>r;)i=c(w.start,t,i);v=new TreeBuffer(t,y-w.start,n),I=w.start-e}else{let e=h.pos-N;h.next();let t=[],r=[],n=x>=o?x:-1,s=0,f=y;for(;h.pos>e;)n>=0&&h.id==n&&h.size>=0?(h.end<=f-i&&(d(t,r,b,s,h.end,f,n,C),s=t.length,f=h.end),h.next()):a(b,e,t,r,n);if(n>=0&&s>0&&s<t.length&&d(t,r,b,s,b,f,n,C),t.reverse(),r.reverse(),n>-1&&s>0){let e=function(e){return(t,r,n)=>{let i,s,o=0,h=t.length-1;if(h>=0&&(i=t[h])instanceof Tree){if(!h&&i.type==e&&i.length==n)return i;(s=i.prop(NodeProp.lookAhead))&&(o=r[h]+i.length+s)}return p(e,t,r,n,o)}}(T);v=balanceRange(T,t,r,0,t.length,0,y-b,e,e)}else v=p(T,t,r,y-b,C-y)}r.push(v),g.push(I)}function d(e,t,r,i,s,o,h,f){let l=[],u=[];for(;e.length>i;)l.push(e.pop()),u.push(t.pop()+r-s);e.push(p(n.types[h],l,u,o-s,f-o)),t.push(s-r)}function p(e,t,r,n,i=0,s){if(l){let e=[NodeProp.contextHash,l];s=s?[e].concat(s):[e]}if(i>25){let e=[NodeProp.lookAhead,i];s=s?[e].concat(s):[e]}return new Tree(e,t,r,n,s)}function c(e,t,r){let{id:n,start:i,end:s,size:f}=h;if(h.next(),f>=0&&n<o){let o=r;if(f>4){let n=h.pos-(f-4);for(;h.pos>n;)r=c(e,t,r)}t[--r]=o,t[--r]=s-e,t[--r]=i-e,t[--r]=n}else-3==f?l=n:-4==f&&(u=n);return r}let g=[],m=[];for(;h.pos>0;)a(e.start||0,e.bufferStart||0,g,m,-1);let x=null!==(t=e.length)&&void 0!==t?t:g.length?m[0]+g[0].length:0;return new Tree(f[e.topID],g.reverse(),m.reverse(),x)}const nodeSizeCache=new WeakMap;function nodeSize(e,t){if(!e.isAnonymous||t instanceof TreeBuffer||t.type!=e)return 1;let r=nodeSizeCache.get(t);if(null==r){r=1;for(let n of t.children){if(n.type!=e||!(n instanceof Tree)){r=1;break}r+=nodeSize(e,n)}nodeSizeCache.set(t,r)}return r}function balanceRange(e,t,r,n,i,s,o,h,f){let l=0;for(let r=n;r<i;r++)l+=nodeSize(e,t[r]);let u=Math.ceil(1.5*l/8),a=[],d=[];return function t(r,n,i,o,h){for(let l=i;l<o;){let i=l,p=n[l],c=nodeSize(e,r[l]);for(l++;l<o;l++){let t=nodeSize(e,r[l]);if(c+t>=u)break;c+=t}if(l==i+1){if(c>u){let e=r[i];t(e.children,e.positions,0,e.children.length,n[i]+h);continue}a.push(r[i])}else{let t=n[l-1]+r[l-1].length-p;a.push(balanceRange(e,r,n,i,l,p,t,null,f))}d.push(p+h-s)}}(t,r,n,i,0),(h||f)(a,d,o)}class NodeWeakMap{constructor(){this.map=new WeakMap}setBuffer(e,t,r){let n=this.map.get(e);n||this.map.set(e,n=new Map),n.set(t,r)}getBuffer(e,t){let r=this.map.get(e);return r&&r.get(t)}set(e,t){e instanceof BufferNode?this.setBuffer(e.context.buffer,e.index,t):e instanceof TreeNode&&this.map.set(e.tree,t)}get(e){return e instanceof BufferNode?this.getBuffer(e.context.buffer,e.index):e instanceof TreeNode?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class TreeFragment{constructor(e,t,r,n,i=!1,s=!1){this.from=e,this.to=t,this.tree=r,this.offset=n,this.open=(i?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],r=!1){let n=[new TreeFragment(0,e.length,e,0,!1,r)];for(let r of t)r.to>e.length&&n.push(r);return n}static applyChanges(e,t,r=128){if(!t.length)return e;let n=[],i=1,s=e.length?e[0]:null;for(let o=0,h=0,f=0;;o++){let l=o<t.length?t[o]:null,u=l?l.fromA:1e9;if(u-h>=r)for(;s&&s.from<u;){let t=s;if(h>=t.from||u<=t.to||f){let e=Math.max(t.from,h)-f,r=Math.min(t.to,u)-f;t=e>=r?null:new TreeFragment(e,r,t.tree,t.offset+f,o>0,!!l)}if(t&&n.push(t),s.to>u)break;s=i<e.length?e[i++]:null}if(!l)break;h=l.toA,f=l.toA-l.toB}return n}}class Parser{startParse(e,t,r){return"string"==typeof e&&(e=new StringInput(e)),r=r?r.length?r.map((e=>new Range(e.from,e.to))):[new Range(0,0)]:[new Range(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let n=this.startParse(e,t,r);for(;;){let e=n.advance();if(e)return e}}}class StringInput{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function parseMixed(e){return(t,r,n,i)=>new MixedParse(t,e,r,n,i)}class InnerParse{constructor(e,t,r,n,i){this.parser=e,this.parse=t,this.overlay=r,this.target=n,this.ranges=i}}class ActiveOverlay{constructor(e,t,r,n,i,s,o){this.parser=e,this.predicate=t,this.mounts=r,this.index=n,this.start=i,this.target=s,this.prev=o,this.depth=0,this.ranges=[]}}const stoppedInner=new NodeProp({perNode:!0});class MixedParse{constructor(e,t,r,n,i){this.nest=t,this.input=r,this.fragments=n,this.ranges=i,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),null!=this.stoppedAt)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return null!=this.stoppedAt&&(e=new Tree(e.type,e.children,e.positions,e.length,e.propValues.concat([[stoppedInner,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[NodeProp.mounted.id]=new MountedTree(t,e.overlay,e.parser),e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].ranges[0].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new FragmentCursor(this.fragments),t=null,r=null,n=new TreeCursor(new TreeNode(this.baseTree,this.ranges[0].from,0,null),IterMode.IncludeAnonymous|IterMode.IgnoreMounts);e:for(let i,s;null==this.stoppedAt||n.from<this.stoppedAt;){let o,h=!0;if(e.hasNode(n)){if(t){let e=t.mounts.find((e=>e.frag.from<=n.from&&e.frag.to>=n.to&&e.mount.overlay));if(e)for(let r of e.mount.overlay){let i=r.from+e.pos,s=r.to+e.pos;i>=n.from&&s<=n.to&&!t.ranges.some((e=>e.from<s&&e.to>i))&&t.ranges.push({from:i,to:s})}}h=!1}else if(r&&(s=checkCover(r.ranges,n.from,n.to)))h=2!=s;else if(!n.type.isAnonymous&&n.from<n.to&&(i=this.nest(n,this.input))){n.tree||materialize(n);let s=e.findMounts(n.from,i.parser);if("function"==typeof i.overlay)t=new ActiveOverlay(i.parser,i.overlay,s,this.inner.length,n.from,n.tree,t);else{let e=punchRanges(this.ranges,i.overlay||[new Range(n.from,n.to)]);e.length&&this.inner.push(new InnerParse(i.parser,i.parser.startParse(this.input,enterFragments(s,e),e),i.overlay?i.overlay.map((e=>new Range(e.from-n.from,e.to-n.from))):null,n.tree,e)),i.overlay?e.length&&(r={ranges:e,depth:0,prev:r}):h=!1}}else t&&(o=t.predicate(n))&&(!0===o&&(o=new Range(n.from,n.to)),o.from<o.to&&t.ranges.push(o));if(h&&n.firstChild())t&&t.depth++,r&&r.depth++;else for(;!n.nextSibling();){if(!n.parent())break e;if(t&&!--t.depth){let e=punchRanges(this.ranges,t.ranges);e.length&&this.inner.splice(t.index,0,new InnerParse(t.parser,t.parser.startParse(this.input,enterFragments(t.mounts,e),e),t.ranges.map((e=>new Range(e.from-t.start,e.to-t.start))),t.target,e)),t=t.prev}r&&!--r.depth&&(r=r.prev)}}}}function checkCover(e,t,r){for(let n of e){if(n.from>=r)break;if(n.to>t)return n.from<=t&&n.to>=r?2:1}return 0}function sliceBuf(e,t,r,n,i,s){if(t<r){let o=e.buffer[t+1];n.push(e.slice(t,r,o)),i.push(o-s)}}function materialize(e){let{node:t}=e,r=0;do{e.parent(),r++}while(!e.tree);let n=0,i=e.tree,s=0;for(;s=i.positions[n]+e.from,!(s<=t.from&&s+i.children[n].length>=t.to);n++);let o=i.children[n],h=o.buffer;i.children[n]=function e(r,n,i,f,l){let u=r;for(;h[u+2]+s<=t.from;)u=h[u+3];let a=[],d=[];sliceBuf(o,r,u,a,d,f);let p=h[u+1],c=h[u+2],g=p+s==t.from&&c+s==t.to&&h[u]==t.type.id;return a.push(g?t.toTree():e(u+4,h[u+3],o.set.types[h[u]],p,c-p)),d.push(p-f),sliceBuf(o,h[u+3],n,a,d,f),new Tree(i,a,d,l)}(0,h.length,NodeType.none,0,o.length);for(let n=0;n<=r;n++)e.childAfter(t.from)}class StructureCursor{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(IterMode.IncludeAnonymous|IterMode.IgnoreMounts)}moveTo(e){let{cursor:t}=this,r=e-this.offset;for(;!this.done&&t.from<r;)t.to>=e&&t.enter(r,1,IterMode.IgnoreOverlays|IterMode.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(!(t.children.length&&0==t.positions[0]&&t.children[0]instanceof Tree))break;t=t.children[0]}return!1}}class FragmentCursor{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let r=this.curFrag=e[0];this.curTo=null!==(t=r.tree.prop(stoppedInner))&&void 0!==t?t:r.to,this.inner=new StructureCursor(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=null!==(e=t.tree.prop(stoppedInner))&&void 0!==e?e:t.to,this.inner=new StructureCursor(t.tree,-t.offset)}}findMounts(e,t){var r;let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let i=null===(r=e.tree)||void 0===r?void 0:r.prop(NodeProp.mounted);if(i&&i.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let r=this.fragments[t];if(r.from>=e.to)break;r.tree==this.curFrag.tree&&n.push({frag:r,pos:e.from-r.offset,mount:i})}}}return n}}function punchRanges(e,t){let r=null,n=t;for(let i=1,s=0;i<e.length;i++){let o=e[i-1].to,h=e[i].from;for(;s<n.length;s++){let e=n[s];if(e.from>=h)break;e.to<=o||(r||(n=r=t.slice()),e.from<o?(r[s]=new Range(e.from,o),e.to>h&&r.splice(s+1,0,new Range(h,e.to))):e.to>h?r[s--]=new Range(h,e.to):r.splice(s--,1))}}return n}function findCoverChanges(e,t,r,n){let i=0,s=0,o=!1,h=!1,f=-1e9,l=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from,a=s==t.length?1e9:h?t[s].to:t[s].from;if(o!=h){let e=Math.max(f,r),t=Math.min(u,a,n);e<t&&l.push(new Range(e,t))}if(f=Math.min(u,a),1e9==f)break;u==f&&(o?(o=!1,i++):o=!0),a==f&&(h?(h=!1,s++):h=!0)}return l}function enterFragments(e,t){let r=[];for(let{pos:n,mount:i,frag:s}of e){let e=n+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length,h=Math.max(s.from,e),f=Math.min(s.to,o);if(i.overlay){let o=findCoverChanges(t,i.overlay.map((e=>new Range(e.from+n,e.to+n))),h,f);for(let t=0,n=h;;t++){let h=t==o.length,l=h?f:o[t].from;if(l>n&&r.push(new TreeFragment(n,l,i.tree,-e,s.from>=n||s.openStart,s.to<=l||s.openEnd)),h)break;n=o[t].to}}else r.push(new TreeFragment(h,f,i.tree,-e,s.from>=e||s.openStart,s.to<=o||s.openEnd))}return r}export{DefaultBufferLength,IterMode,MountedTree,NodeProp,NodeSet,NodeType,NodeWeakMap,Parser,Tree,TreeBuffer,TreeCursor,TreeFragment,parseMixed}; \ No newline at end of file +const DefaultBufferLength=1024;let nextPropID=0;class Range{constructor(e,t){this.from=e,this.to=t}}class NodeProp{constructor(e={}){this.id=nextPropID++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=NodeType.match(e)),t=>{let r=e(t);return void 0===r?null:[this,r]}}}NodeProp.closedBy=new NodeProp({deserialize:e=>e.split(" ")}),NodeProp.openedBy=new NodeProp({deserialize:e=>e.split(" ")}),NodeProp.group=new NodeProp({deserialize:e=>e.split(" ")}),NodeProp.contextHash=new NodeProp({perNode:!0}),NodeProp.lookAhead=new NodeProp({perNode:!0}),NodeProp.mounted=new NodeProp({perNode:!0});class MountedTree{constructor(e,t,r){this.tree=e,this.overlay=t,this.parser=r}}const noProps=Object.create(null);class NodeType{constructor(e,t,r,n=0){this.name=e,this.props=t,this.id=r,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):noProps,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),n=new NodeType(e.name||"",t,e.id,r);if(e.props)for(let r of e.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}return n}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(NodeProp.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let n of r.split(" "))t[n]=e[r];return e=>{for(let r=e.prop(NodeProp.group),n=-1;n<(r?r.length:0);n++){let i=t[n<0?e.name:r[n]];if(i)return i}}}}NodeType.none=new NodeType("",Object.create(null),0,8);class NodeSet{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let r of this.types){let n=null;for(let t of e){let e=t(r);e&&(n||(n=Object.assign({},r.props)),n[e[0].id]=e[1])}t.push(n?new NodeType(r.name,n,r.id,r.flags):r)}return new NodeSet(t)}}const CachedNode=new WeakMap,CachedInnerNode=new WeakMap;var IterMode;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(IterMode||(IterMode={}));class Tree{constructor(e,t,r,n,i){if(this.type=e,this.children=t,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=this.prop(NodeProp.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let r=e.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new TreeCursor(this.topNode,e)}cursorAt(e,t=0,r=0){let n=CachedNode.get(this)||this.topNode,i=new TreeCursor(n);return i.moveTo(e,t),CachedNode.set(this,i._tree),i}get topNode(){return new TreeNode(this,0,0,null)}resolve(e,t=0){let r=resolveNode(CachedNode.get(this)||this.topNode,e,t,!1);return CachedNode.set(this,r),r}resolveInner(e,t=0){let r=resolveNode(CachedInnerNode.get(this)||this.topNode,e,t,!0);return CachedInnerNode.set(this,r),r}iterate(e){let{enter:t,leave:r,from:n=0,to:i=this.length}=e;for(let s=this.cursor((e.mode||0)|IterMode.IncludeAnonymous);;){let e=!1;if(s.from<=i&&s.to>=n&&(s.type.isAnonymous||!1!==t(s))){if(s.firstChild())continue;e=!0}for(;e&&r&&!s.type.isAnonymous&&r(s),!s.nextSibling();){if(!s.parent())return;e=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:balanceRange(NodeType.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,r)=>new Tree(this.type,e,t,r,this.propValues)),e.makeTree||((e,t,r)=>new Tree(NodeType.none,e,t,r)))}static build(e){return buildTree(e)}}Tree.empty=new Tree(NodeType.none,[],[],0);class FlatBufferCursor{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new FlatBufferCursor(this.buffer,this.index)}}class TreeBuffer{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return NodeType.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],r=this.buffer[e+3],n=this.set.types[t],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),r==(e+=4))return i;let s=[];for(;e<r;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,t,r,n,i){let{buffer:s}=this,o=-1;for(let h=e;h!=t&&!(checkSide(i,n,s[h+1],s[h+2])&&(o=h,r>0));h=s[h+3]);return o}slice(e,t,r){let n=this.buffer,i=new Uint16Array(t-e),s=0;for(let o=e,h=0;o<t;){i[h++]=n[o++],i[h++]=n[o++]-r;let t=i[h++]=n[o++]-r;i[h++]=n[o++]-e,s=Math.max(s,t)}return new TreeBuffer(i,s,this.set)}}function checkSide(e,t,r,n){switch(e){case-2:return r<t;case-1:return n>=t&&r<t;case 0:return r<t&&n>t;case 1:return r<=t&&n>t;case 2:return n>t;case 4:return!0}}function enterUnfinishedNodesBefore(e,t){let r=e.childBefore(t);for(;r;){let t=r.lastChild;if(!t||t.to!=r.to)break;t.type.isError&&t.from==t.to?(e=r,r=t.prevSibling):r=t}return e}function resolveNode(e,t,r,n){for(var i;e.from==e.to||(r<1?e.from>=t:e.from>t)||(r>-1?e.to<=t:e.to<t);){let t=!n&&e instanceof TreeNode&&e.index<0?null:e.parent;if(!t)return e;e=t}let s=n?0:IterMode.IgnoreOverlays;if(n)for(let n=e,o=n.parent;o;n=o,o=n.parent)n instanceof TreeNode&&n.index<0&&(null===(i=o.enter(t,r,s))||void 0===i?void 0:i.from)!=n.from&&(e=o);for(;;){let n=e.enter(t,r,s);if(!n)return e;e=n}}class TreeNode{constructor(e,t,r,n){this._tree=e,this.from=t,this.index=r,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,n,i=0){for(let s=this;;){for(let{children:o,positions:h}=s._tree,f=t>0?o.length:-1;e!=f;e+=t){let f=o[e],l=h[e]+s.from;if(checkSide(n,r,l,l+f.length))if(f instanceof TreeBuffer){if(i&IterMode.ExcludeBuffers)continue;let o=f.findChild(0,f.buffer.length,t,r-l,n);if(o>-1)return new BufferNode(new BufferContext(s,f,e,l),null,o)}else if(i&IterMode.IncludeAnonymous||!f.type.isAnonymous||hasChild(f)){let o;if(!(i&IterMode.IgnoreMounts)&&f.props&&(o=f.prop(NodeProp.mounted))&&!o.overlay)return new TreeNode(o.tree,l,e,s);let h=new TreeNode(f,l,e,s);return i&IterMode.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(t<0?f.children.length-1:0,t,r,n)}}if(i&IterMode.IncludeAnonymous||!s.type.isAnonymous)return null;if(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,r=0){let n;if(!(r&IterMode.IgnoreOverlays)&&(n=this._tree.prop(NodeProp.mounted))&&n.overlay){let r=e-this.from;for(let{from:e,to:i}of n.overlay)if((t>0?e<=r:e<r)&&(t<0?i>=r:i>r))return new TreeNode(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new TreeCursor(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return resolveNode(this,e,t,!1)}resolveInner(e,t=0){return resolveNode(this,e,t,!0)}enterUnfinishedNodesBefore(e){return enterUnfinishedNodesBefore(this,e)}getChild(e,t=null,r=null){let n=getChildren(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return getChildren(this,e,t,r)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return matchNodeContext(this,e)}}function getChildren(e,t,r,n){let i=e.cursor(),s=[];if(!i.firstChild())return s;if(null!=r)for(;!i.type.is(r);)if(!i.nextSibling())return s;for(;;){if(null!=n&&i.type.is(n))return s;if(i.type.is(t)&&s.push(i.node),!i.nextSibling())return null==n?s:[]}}function matchNodeContext(e,t,r=t.length-1){for(let n=e.parent;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[r]&&t[r]!=n.name)return!1;r--}}return!0}class BufferContext{constructor(e,t,r,n){this.parent=e,this.buffer=t,this.index=r,this.start=n}}class BufferNode{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,r){this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,r);return i<0?null:new BufferNode(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,r=0){if(r&IterMode.ExcludeBuffers)return null;let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new BufferNode(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new BufferNode(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new BufferNode(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new TreeCursor(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1];e.push(r.slice(n,i,s)),t.push(0)}return new Tree(this.type,e,t,this.to-this.from)}resolve(e,t=0){return resolveNode(this,e,t,!1)}resolveInner(e,t=0){return resolveNode(this,e,t,!0)}enterUnfinishedNodesBefore(e){return enterUnfinishedNodesBefore(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,r=null){let n=getChildren(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return getChildren(this,e,t,r)}get node(){return this}matchContext(e){return matchNodeContext(this,e)}}class TreeCursor{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof TreeNode)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:r,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=r+n.buffer[e+1],this.to=r+n.buffer[e+2],!0}yield(e){return!!e&&(e instanceof TreeNode?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,r);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?!(r&IterMode.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&IterMode.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&IterMode.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let e=r<0?0:this.stack[r]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(e)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(n.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:r}=n)}else({index:t,_parent:r}=this._tree);for(;r;({index:t,_parent:r}=r))if(t>-1)for(let n=t+e,i=e<0?-1:r._tree.children.length;n!=i;n+=e){let e=r._tree.children[n];if(this.mode&IterMode.IncludeAnonymous||e instanceof TreeBuffer||!e.type.isAnonymous||hasChild(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,r=0;if(e&&e.context==this.buffer)e:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==n){if(n==this.index)return s;t=s,r=i+1;break e}n=this.stack[--i]}for(let e=r;e<this.stack.length;e++)t=new BufferNode(this.buffer,t,this.stack[e]);return this.bufferNode=new BufferNode(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let n=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){r++;continue}this.type.isAnonymous||(n=!0)}for(;n&&t&&t(this),n=this.type.isAnonymous,!this.nextSibling();){if(!r)return;this.parent(),r--,n=!0}}}matchContext(e){if(!this.buffer)return matchNodeContext(this.node,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let n=e.length-1,i=this.stack.length-1;n>=0;i--){if(i<0)return matchNodeContext(this.node,e,n);let s=r[t.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[n]&&e[n]!=s.name)return!1;n--}}return!0}}function hasChild(e){return e.children.some((e=>e instanceof TreeBuffer||!e.type.isAnonymous||hasChild(e)))}function buildTree(e){var t;let{buffer:r,nodeSet:n,maxBufferLength:i=DefaultBufferLength,reused:s=[],minRepeatType:o=n.types.length}=e,h=Array.isArray(r)?new FlatBufferCursor(r,r.length):r,f=n.types,l=0,u=0;function a(e,t,r,g,m){let{id:x,start:b,end:y,size:N}=h,C=u;for(;N<0;){if(h.next(),-1==N){let t=s[x];return r.push(t),void g.push(b-e)}if(-3==N)return void(l=x);if(-4==N)return void(u=x);throw new RangeError(`Unrecognized record size: ${N}`)}let v,w,T=f[x],I=b-e;if(y-b<=i&&(w=function(e,t){let r=h.fork(),n=0,s=0,f=0,l=r.end-i,u={size:0,start:0,skip:0};e:for(let i=r.pos-e;r.pos>i;){let e=r.size;if(r.id==t&&e>=0){u.size=n,u.start=s,u.skip=f,f+=4,n+=4,r.next();continue}let h=r.pos-e;if(e<0||h<i||r.start<l)break;let a=r.id>=o?4:0,d=r.start;for(r.next();r.pos>h;){if(r.size<0){if(-3!=r.size)break e;a+=4}else r.id>=o&&(a+=4);r.next()}s=d,n+=e,f+=a}(t<0||n==e)&&(u.size=n,u.start=s,u.skip=f);return u.size>4?u:void 0}(h.pos-t,m))){let t=new Uint16Array(w.size-w.skip),r=h.pos-w.size,i=t.length;for(;h.pos>r;)i=c(w.start,t,i);v=new TreeBuffer(t,y-w.start,n),I=w.start-e}else{let e=h.pos-N;h.next();let t=[],r=[],n=x>=o?x:-1,s=0,f=y;for(;h.pos>e;)n>=0&&h.id==n&&h.size>=0?(h.end<=f-i&&(d(t,r,b,s,h.end,f,n,C),s=t.length,f=h.end),h.next()):a(b,e,t,r,n);if(n>=0&&s>0&&s<t.length&&d(t,r,b,s,b,f,n,C),t.reverse(),r.reverse(),n>-1&&s>0){let e=function(e){return(t,r,n)=>{let i,s,o=0,h=t.length-1;if(h>=0&&(i=t[h])instanceof Tree){if(!h&&i.type==e&&i.length==n)return i;(s=i.prop(NodeProp.lookAhead))&&(o=r[h]+i.length+s)}return p(e,t,r,n,o)}}(T);v=balanceRange(T,t,r,0,t.length,0,y-b,e,e)}else v=p(T,t,r,y-b,C-y)}r.push(v),g.push(I)}function d(e,t,r,i,s,o,h,f){let l=[],u=[];for(;e.length>i;)l.push(e.pop()),u.push(t.pop()+r-s);e.push(p(n.types[h],l,u,o-s,f-o)),t.push(s-r)}function p(e,t,r,n,i=0,s){if(l){let e=[NodeProp.contextHash,l];s=s?[e].concat(s):[e]}if(i>25){let e=[NodeProp.lookAhead,i];s=s?[e].concat(s):[e]}return new Tree(e,t,r,n,s)}function c(e,t,r){let{id:n,start:i,end:s,size:f}=h;if(h.next(),f>=0&&n<o){let o=r;if(f>4){let n=h.pos-(f-4);for(;h.pos>n;)r=c(e,t,r)}t[--r]=o,t[--r]=s-e,t[--r]=i-e,t[--r]=n}else-3==f?l=n:-4==f&&(u=n);return r}let g=[],m=[];for(;h.pos>0;)a(e.start||0,e.bufferStart||0,g,m,-1);let x=null!==(t=e.length)&&void 0!==t?t:g.length?m[0]+g[0].length:0;return new Tree(f[e.topID],g.reverse(),m.reverse(),x)}const nodeSizeCache=new WeakMap;function nodeSize(e,t){if(!e.isAnonymous||t instanceof TreeBuffer||t.type!=e)return 1;let r=nodeSizeCache.get(t);if(null==r){r=1;for(let n of t.children){if(n.type!=e||!(n instanceof Tree)){r=1;break}r+=nodeSize(e,n)}nodeSizeCache.set(t,r)}return r}function balanceRange(e,t,r,n,i,s,o,h,f){let l=0;for(let r=n;r<i;r++)l+=nodeSize(e,t[r]);let u=Math.ceil(1.5*l/8),a=[],d=[];return function t(r,n,i,o,h){for(let l=i;l<o;){let i=l,p=n[l],c=nodeSize(e,r[l]);for(l++;l<o;l++){let t=nodeSize(e,r[l]);if(c+t>=u)break;c+=t}if(l==i+1){if(c>u){let e=r[i];t(e.children,e.positions,0,e.children.length,n[i]+h);continue}a.push(r[i])}else{let t=n[l-1]+r[l-1].length-p;a.push(balanceRange(e,r,n,i,l,p,t,null,f))}d.push(p+h-s)}}(t,r,n,i,0),(h||f)(a,d,o)}class NodeWeakMap{constructor(){this.map=new WeakMap}setBuffer(e,t,r){let n=this.map.get(e);n||this.map.set(e,n=new Map),n.set(t,r)}getBuffer(e,t){let r=this.map.get(e);return r&&r.get(t)}set(e,t){e instanceof BufferNode?this.setBuffer(e.context.buffer,e.index,t):e instanceof TreeNode&&this.map.set(e.tree,t)}get(e){return e instanceof BufferNode?this.getBuffer(e.context.buffer,e.index):e instanceof TreeNode?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class TreeFragment{constructor(e,t,r,n,i=!1,s=!1){this.from=e,this.to=t,this.tree=r,this.offset=n,this.open=(i?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],r=!1){let n=[new TreeFragment(0,e.length,e,0,!1,r)];for(let r of t)r.to>e.length&&n.push(r);return n}static applyChanges(e,t,r=128){if(!t.length)return e;let n=[],i=1,s=e.length?e[0]:null;for(let o=0,h=0,f=0;;o++){let l=o<t.length?t[o]:null,u=l?l.fromA:1e9;if(u-h>=r)for(;s&&s.from<u;){let t=s;if(h>=t.from||u<=t.to||f){let e=Math.max(t.from,h)-f,r=Math.min(t.to,u)-f;t=e>=r?null:new TreeFragment(e,r,t.tree,t.offset+f,o>0,!!l)}if(t&&n.push(t),s.to>u)break;s=i<e.length?e[i++]:null}if(!l)break;h=l.toA,f=l.toA-l.toB}return n}}class Parser{startParse(e,t,r){return"string"==typeof e&&(e=new StringInput(e)),r=r?r.length?r.map((e=>new Range(e.from,e.to))):[new Range(0,0)]:[new Range(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let n=this.startParse(e,t,r);for(;;){let e=n.advance();if(e)return e}}}class StringInput{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function parseMixed(e){return(t,r,n,i)=>new MixedParse(t,e,r,n,i)}class InnerParse{constructor(e,t,r,n,i){this.parser=e,this.parse=t,this.overlay=r,this.target=n,this.ranges=i}}class ActiveOverlay{constructor(e,t,r,n,i,s,o){this.parser=e,this.predicate=t,this.mounts=r,this.index=n,this.start=i,this.target=s,this.prev=o,this.depth=0,this.ranges=[]}}const stoppedInner=new NodeProp({perNode:!0});class MixedParse{constructor(e,t,r,n,i){this.nest=t,this.input=r,this.fragments=n,this.ranges=i,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),null!=this.stoppedAt)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return null!=this.stoppedAt&&(e=new Tree(e.type,e.children,e.positions,e.length,e.propValues.concat([[stoppedInner,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[NodeProp.mounted.id]=new MountedTree(t,e.overlay,e.parser),e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].ranges[0].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new FragmentCursor(this.fragments),t=null,r=null,n=new TreeCursor(new TreeNode(this.baseTree,this.ranges[0].from,0,null),IterMode.IncludeAnonymous|IterMode.IgnoreMounts);e:for(let i,s;null==this.stoppedAt||n.from<this.stoppedAt;){let o,h=!0;if(e.hasNode(n)){if(t){let e=t.mounts.find((e=>e.frag.from<=n.from&&e.frag.to>=n.to&&e.mount.overlay));if(e)for(let r of e.mount.overlay){let i=r.from+e.pos,s=r.to+e.pos;i>=n.from&&s<=n.to&&!t.ranges.some((e=>e.from<s&&e.to>i))&&t.ranges.push({from:i,to:s})}}h=!1}else if(r&&(s=checkCover(r.ranges,n.from,n.to)))h=2!=s;else if(!n.type.isAnonymous&&n.from<n.to&&(i=this.nest(n,this.input))){n.tree||materialize(n);let s=e.findMounts(n.from,i.parser);if("function"==typeof i.overlay)t=new ActiveOverlay(i.parser,i.overlay,s,this.inner.length,n.from,n.tree,t);else{let e=punchRanges(this.ranges,i.overlay||[new Range(n.from,n.to)]);e.length&&this.inner.push(new InnerParse(i.parser,i.parser.startParse(this.input,enterFragments(s,e),e),i.overlay?i.overlay.map((e=>new Range(e.from-n.from,e.to-n.from))):null,n.tree,e)),i.overlay?e.length&&(r={ranges:e,depth:0,prev:r}):h=!1}}else t&&(o=t.predicate(n))&&(!0===o&&(o=new Range(n.from,n.to)),o.from<o.to&&t.ranges.push(o));if(h&&n.firstChild())t&&t.depth++,r&&r.depth++;else for(;!n.nextSibling();){if(!n.parent())break e;if(t&&! --t.depth){let e=punchRanges(this.ranges,t.ranges);e.length&&this.inner.splice(t.index,0,new InnerParse(t.parser,t.parser.startParse(this.input,enterFragments(t.mounts,e),e),t.ranges.map((e=>new Range(e.from-t.start,e.to-t.start))),t.target,e)),t=t.prev}r&&! --r.depth&&(r=r.prev)}}}}function checkCover(e,t,r){for(let n of e){if(n.from>=r)break;if(n.to>t)return n.from<=t&&n.to>=r?2:1}return 0}function sliceBuf(e,t,r,n,i,s){if(t<r){let o=e.buffer[t+1];n.push(e.slice(t,r,o)),i.push(o-s)}}function materialize(e){let{node:t}=e,r=0;do{e.parent(),r++}while(!e.tree);let n=0,i=e.tree,s=0;for(;s=i.positions[n]+e.from,!(s<=t.from&&s+i.children[n].length>=t.to);n++);let o=i.children[n],h=o.buffer;i.children[n]=function e(r,n,i,f,l){let u=r;for(;h[u+2]+s<=t.from;)u=h[u+3];let a=[],d=[];sliceBuf(o,r,u,a,d,f);let p=h[u+1],c=h[u+2],g=p+s==t.from&&c+s==t.to&&h[u]==t.type.id;return a.push(g?t.toTree():e(u+4,h[u+3],o.set.types[h[u]],p,c-p)),d.push(p-f),sliceBuf(o,h[u+3],n,a,d,f),new Tree(i,a,d,l)}(0,h.length,NodeType.none,0,o.length);for(let n=0;n<=r;n++)e.childAfter(t.from)}class StructureCursor{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(IterMode.IncludeAnonymous|IterMode.IgnoreMounts)}moveTo(e){let{cursor:t}=this,r=e-this.offset;for(;!this.done&&t.from<r;)t.to>=e&&t.enter(r,1,IterMode.IgnoreOverlays|IterMode.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(!(t.children.length&&0==t.positions[0]&&t.children[0]instanceof Tree))break;t=t.children[0]}return!1}}class FragmentCursor{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let r=this.curFrag=e[0];this.curTo=null!==(t=r.tree.prop(stoppedInner))&&void 0!==t?t:r.to,this.inner=new StructureCursor(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=null!==(e=t.tree.prop(stoppedInner))&&void 0!==e?e:t.to,this.inner=new StructureCursor(t.tree,-t.offset)}}findMounts(e,t){var r;let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let i=null===(r=e.tree)||void 0===r?void 0:r.prop(NodeProp.mounted);if(i&&i.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let r=this.fragments[t];if(r.from>=e.to)break;r.tree==this.curFrag.tree&&n.push({frag:r,pos:e.from-r.offset,mount:i})}}}return n}}function punchRanges(e,t){let r=null,n=t;for(let i=1,s=0;i<e.length;i++){let o=e[i-1].to,h=e[i].from;for(;s<n.length;s++){let e=n[s];if(e.from>=h)break;e.to<=o||(r||(n=r=t.slice()),e.from<o?(r[s]=new Range(e.from,o),e.to>h&&r.splice(s+1,0,new Range(h,e.to))):e.to>h?r[s--]=new Range(h,e.to):r.splice(s--,1))}}return n}function findCoverChanges(e,t,r,n){let i=0,s=0,o=!1,h=!1,f=-1e9,l=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from,a=s==t.length?1e9:h?t[s].to:t[s].from;if(o!=h){let e=Math.max(f,r),t=Math.min(u,a,n);e<t&&l.push(new Range(e,t))}if(f=Math.min(u,a),1e9==f)break;u==f&&(o?(o=!1,i++):o=!0),a==f&&(h?(h=!1,s++):h=!0)}return l}function enterFragments(e,t){let r=[];for(let{pos:n,mount:i,frag:s}of e){let e=n+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length,h=Math.max(s.from,e),f=Math.min(s.to,o);if(i.overlay){let o=findCoverChanges(t,i.overlay.map((e=>new Range(e.from+n,e.to+n))),h,f);for(let t=0,n=h;;t++){let h=t==o.length,l=h?f:o[t].from;if(l>n&&r.push(new TreeFragment(n,l,i.tree,-e,s.from>=n||s.openStart,s.to<=l||s.openEnd)),h)break;n=o[t].to}}else r.push(new TreeFragment(h,f,i.tree,-e,s.from>=e||s.openStart,s.to<=o||s.openEnd))}return r}export{DefaultBufferLength,IterMode,MountedTree,NodeProp,NodeSet,NodeType,NodeWeakMap,Parser,Tree,TreeBuffer,TreeCursor,TreeFragment,parseMixed}; \ No newline at end of file