{"version":3,"file":"vendors-node_modules_tinymce_tinymce_js.d152cf98c45d962fa693.bundle.js","mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":["webpack://HRMSPortal/./node_modules/tinymce/tinymce.js"],"sourcesContent":["/**\n * TinyMCE version 6.8.3 (2024-02-08)\n */\n\n(function () {\n 'use strict';\n\n var typeOf$1 = function (x) {\n if (x === null) {\n return 'null';\n }\n if (x === undefined) {\n return 'undefined';\n }\n var t = typeof x;\n if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {\n return 'array';\n }\n if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {\n return 'string';\n }\n return t;\n };\n var isEquatableType = function (x) {\n return [\n 'undefined',\n 'boolean',\n 'number',\n 'string',\n 'function',\n 'xml',\n 'null'\n ].indexOf(x) !== -1;\n };\n\n var sort$1 = function (xs, compareFn) {\n var clone = Array.prototype.slice.call(xs);\n return clone.sort(compareFn);\n };\n\n var contramap = function (eqa, f) {\n return eq$2(function (x, y) {\n return eqa.eq(f(x), f(y));\n });\n };\n var eq$2 = function (f) {\n return { eq: f };\n };\n var tripleEq = eq$2(function (x, y) {\n return x === y;\n });\n var eqString = tripleEq;\n var eqArray = function (eqa) {\n return eq$2(function (x, y) {\n if (x.length !== y.length) {\n return false;\n }\n var len = x.length;\n for (var i = 0; i < len; i++) {\n if (!eqa.eq(x[i], y[i])) {\n return false;\n }\n }\n return true;\n });\n };\n var eqSortedArray = function (eqa, compareFn) {\n return contramap(eqArray(eqa), function (xs) {\n return sort$1(xs, compareFn);\n });\n };\n var eqRecord = function (eqa) {\n return eq$2(function (x, y) {\n var kx = Object.keys(x);\n var ky = Object.keys(y);\n if (!eqSortedArray(eqString).eq(kx, ky)) {\n return false;\n }\n var len = kx.length;\n for (var i = 0; i < len; i++) {\n var q = kx[i];\n if (!eqa.eq(x[q], y[q])) {\n return false;\n }\n }\n return true;\n });\n };\n var eqAny = eq$2(function (x, y) {\n if (x === y) {\n return true;\n }\n var tx = typeOf$1(x);\n var ty = typeOf$1(y);\n if (tx !== ty) {\n return false;\n }\n if (isEquatableType(tx)) {\n return x === y;\n } else if (tx === 'array') {\n return eqArray(eqAny).eq(x, y);\n } else if (tx === 'object') {\n return eqRecord(eqAny).eq(x, y);\n }\n return false;\n });\n\n const getPrototypeOf$2 = Object.getPrototypeOf;\n const hasProto = (v, constructor, predicate) => {\n var _a;\n if (predicate(v, constructor.prototype)) {\n return true;\n } else {\n return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;\n }\n };\n const typeOf = x => {\n const t = typeof x;\n if (x === null) {\n return 'null';\n } else if (t === 'object' && Array.isArray(x)) {\n return 'array';\n } else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {\n return 'string';\n } else {\n return t;\n }\n };\n const isType$1 = type => value => typeOf(value) === type;\n const isSimpleType = type => value => typeof value === type;\n const eq$1 = t => a => t === a;\n const is$4 = (value, constructor) => isObject(value) && hasProto(value, constructor, (o, proto) => getPrototypeOf$2(o) === proto);\n const isString = isType$1('string');\n const isObject = isType$1('object');\n const isPlainObject = value => is$4(value, Object);\n const isArray$1 = isType$1('array');\n const isNull = eq$1(null);\n const isBoolean = isSimpleType('boolean');\n const isUndefined = eq$1(undefined);\n const isNullable = a => a === null || a === undefined;\n const isNonNullable = a => !isNullable(a);\n const isFunction = isSimpleType('function');\n const isNumber = isSimpleType('number');\n const isArrayOf = (value, pred) => {\n if (isArray$1(value)) {\n for (let i = 0, len = value.length; i < len; ++i) {\n if (!pred(value[i])) {\n return false;\n }\n }\n return true;\n }\n return false;\n };\n\n const noop = () => {\n };\n const compose = (fa, fb) => {\n return (...args) => {\n return fa(fb.apply(null, args));\n };\n };\n const compose1 = (fbc, fab) => a => fbc(fab(a));\n const constant = value => {\n return () => {\n return value;\n };\n };\n const identity = x => {\n return x;\n };\n const tripleEquals = (a, b) => {\n return a === b;\n };\n function curry(fn, ...initialArgs) {\n return (...restArgs) => {\n const all = initialArgs.concat(restArgs);\n return fn.apply(null, all);\n };\n }\n const not = f => t => !f(t);\n const die = msg => {\n return () => {\n throw new Error(msg);\n };\n };\n const apply$1 = f => {\n return f();\n };\n const call = f => {\n f();\n };\n const never = constant(false);\n const always = constant(true);\n\n class Optional {\n constructor(tag, value) {\n this.tag = tag;\n this.value = value;\n }\n static some(value) {\n return new Optional(true, value);\n }\n static none() {\n return Optional.singletonNone;\n }\n fold(onNone, onSome) {\n if (this.tag) {\n return onSome(this.value);\n } else {\n return onNone();\n }\n }\n isSome() {\n return this.tag;\n }\n isNone() {\n return !this.tag;\n }\n map(mapper) {\n if (this.tag) {\n return Optional.some(mapper(this.value));\n } else {\n return Optional.none();\n }\n }\n bind(binder) {\n if (this.tag) {\n return binder(this.value);\n } else {\n return Optional.none();\n }\n }\n exists(predicate) {\n return this.tag && predicate(this.value);\n }\n forall(predicate) {\n return !this.tag || predicate(this.value);\n }\n filter(predicate) {\n if (!this.tag || predicate(this.value)) {\n return this;\n } else {\n return Optional.none();\n }\n }\n getOr(replacement) {\n return this.tag ? this.value : replacement;\n }\n or(replacement) {\n return this.tag ? this : replacement;\n }\n getOrThunk(thunk) {\n return this.tag ? this.value : thunk();\n }\n orThunk(thunk) {\n return this.tag ? this : thunk();\n }\n getOrDie(message) {\n if (!this.tag) {\n throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');\n } else {\n return this.value;\n }\n }\n static from(value) {\n return isNonNullable(value) ? Optional.some(value) : Optional.none();\n }\n getOrNull() {\n return this.tag ? this.value : null;\n }\n getOrUndefined() {\n return this.value;\n }\n each(worker) {\n if (this.tag) {\n worker(this.value);\n }\n }\n toArray() {\n return this.tag ? [this.value] : [];\n }\n toString() {\n return this.tag ? `some(${ this.value })` : 'none()';\n }\n }\n Optional.singletonNone = new Optional(false);\n\n const nativeSlice = Array.prototype.slice;\n const nativeIndexOf = Array.prototype.indexOf;\n const nativePush = Array.prototype.push;\n const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);\n const indexOf$1 = (xs, x) => {\n const r = rawIndexOf(xs, x);\n return r === -1 ? Optional.none() : Optional.some(r);\n };\n const contains$2 = (xs, x) => rawIndexOf(xs, x) > -1;\n const exists = (xs, pred) => {\n for (let i = 0, len = xs.length; i < len; i++) {\n const x = xs[i];\n if (pred(x, i)) {\n return true;\n }\n }\n return false;\n };\n const map$3 = (xs, f) => {\n const len = xs.length;\n const r = new Array(len);\n for (let i = 0; i < len; i++) {\n const x = xs[i];\n r[i] = f(x, i);\n }\n return r;\n };\n const each$e = (xs, f) => {\n for (let i = 0, len = xs.length; i < len; i++) {\n const x = xs[i];\n f(x, i);\n }\n };\n const eachr = (xs, f) => {\n for (let i = xs.length - 1; i >= 0; i--) {\n const x = xs[i];\n f(x, i);\n }\n };\n const partition$2 = (xs, pred) => {\n const pass = [];\n const fail = [];\n for (let i = 0, len = xs.length; i < len; i++) {\n const x = xs[i];\n const arr = pred(x, i) ? pass : fail;\n arr.push(x);\n }\n return {\n pass,\n fail\n };\n };\n const filter$5 = (xs, pred) => {\n const r = [];\n for (let i = 0, len = xs.length; i < len; i++) {\n const x = xs[i];\n if (pred(x, i)) {\n r.push(x);\n }\n }\n return r;\n };\n const foldr = (xs, f, acc) => {\n eachr(xs, (x, i) => {\n acc = f(acc, x, i);\n });\n return acc;\n };\n const foldl = (xs, f, acc) => {\n each$e(xs, (x, i) => {\n acc = f(acc, x, i);\n });\n return acc;\n };\n const findUntil$1 = (xs, pred, until) => {\n for (let i = 0, len = xs.length; i < len; i++) {\n const x = xs[i];\n if (pred(x, i)) {\n return Optional.some(x);\n } else if (until(x, i)) {\n break;\n }\n }\n return Optional.none();\n };\n const find$2 = (xs, pred) => {\n return findUntil$1(xs, pred, never);\n };\n const findIndex$2 = (xs, pred) => {\n for (let i = 0, len = xs.length; i < len; i++) {\n const x = xs[i];\n if (pred(x, i)) {\n return Optional.some(i);\n }\n }\n return Optional.none();\n };\n const flatten = xs => {\n const r = [];\n for (let i = 0, len = xs.length; i < len; ++i) {\n if (!isArray$1(xs[i])) {\n throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);\n }\n nativePush.apply(r, xs[i]);\n }\n return r;\n };\n const bind$3 = (xs, f) => flatten(map$3(xs, f));\n const forall = (xs, pred) => {\n for (let i = 0, len = xs.length; i < len; ++i) {\n const x = xs[i];\n if (pred(x, i) !== true) {\n return false;\n }\n }\n return true;\n };\n const reverse = xs => {\n const r = nativeSlice.call(xs, 0);\n r.reverse();\n return r;\n };\n const difference = (a1, a2) => filter$5(a1, x => !contains$2(a2, x));\n const mapToObject = (xs, f) => {\n const r = {};\n for (let i = 0, len = xs.length; i < len; i++) {\n const x = xs[i];\n r[String(x)] = f(x, i);\n }\n return r;\n };\n const sort = (xs, comparator) => {\n const copy = nativeSlice.call(xs, 0);\n copy.sort(comparator);\n return copy;\n };\n const get$b = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();\n const head = xs => get$b(xs, 0);\n const last$3 = xs => get$b(xs, xs.length - 1);\n const from = isFunction(Array.from) ? Array.from : x => nativeSlice.call(x);\n const findMap = (arr, f) => {\n for (let i = 0; i < arr.length; i++) {\n const r = f(arr[i], i);\n if (r.isSome()) {\n return r;\n }\n }\n return Optional.none();\n };\n const unique$1 = (xs, comparator) => {\n const r = [];\n const isDuplicated = isFunction(comparator) ? x => exists(r, i => comparator(i, x)) : x => contains$2(r, x);\n for (let i = 0, len = xs.length; i < len; i++) {\n const x = xs[i];\n if (!isDuplicated(x)) {\n r.push(x);\n }\n }\n return r;\n };\n\n const keys = Object.keys;\n const hasOwnProperty$1 = Object.hasOwnProperty;\n const each$d = (obj, f) => {\n const props = keys(obj);\n for (let k = 0, len = props.length; k < len; k++) {\n const i = props[k];\n const x = obj[i];\n f(x, i);\n }\n };\n const map$2 = (obj, f) => {\n return tupleMap(obj, (x, i) => ({\n k: i,\n v: f(x, i)\n }));\n };\n const tupleMap = (obj, f) => {\n const r = {};\n each$d(obj, (x, i) => {\n const tuple = f(x, i);\n r[tuple.k] = tuple.v;\n });\n return r;\n };\n const objAcc = r => (x, i) => {\n r[i] = x;\n };\n const internalFilter = (obj, pred, onTrue, onFalse) => {\n each$d(obj, (x, i) => {\n (pred(x, i) ? onTrue : onFalse)(x, i);\n });\n };\n const bifilter = (obj, pred) => {\n const t = {};\n const f = {};\n internalFilter(obj, pred, objAcc(t), objAcc(f));\n return {\n t,\n f\n };\n };\n const filter$4 = (obj, pred) => {\n const t = {};\n internalFilter(obj, pred, objAcc(t), noop);\n return t;\n };\n const mapToArray = (obj, f) => {\n const r = [];\n each$d(obj, (value, name) => {\n r.push(f(value, name));\n });\n return r;\n };\n const values = obj => {\n return mapToArray(obj, identity);\n };\n const get$a = (obj, key) => {\n return has$2(obj, key) ? Optional.from(obj[key]) : Optional.none();\n };\n const has$2 = (obj, key) => hasOwnProperty$1.call(obj, key);\n const hasNonNullableKey = (obj, key) => has$2(obj, key) && obj[key] !== undefined && obj[key] !== null;\n const equal$1 = (a1, a2, eq = eqAny) => eqRecord(eq).eq(a1, a2);\n\n const stringArray = a => {\n const all = {};\n each$e(a, key => {\n all[key] = {};\n });\n return keys(all);\n };\n\n const isArrayLike = o => o.length !== undefined;\n const isArray = Array.isArray;\n const toArray$1 = obj => {\n if (!isArray(obj)) {\n const array = [];\n for (let i = 0, l = obj.length; i < l; i++) {\n array[i] = obj[i];\n }\n return array;\n } else {\n return obj;\n }\n };\n const each$c = (o, cb, s) => {\n if (!o) {\n return false;\n }\n s = s || o;\n if (isArrayLike(o)) {\n for (let n = 0, l = o.length; n < l; n++) {\n if (cb.call(s, o[n], n, o) === false) {\n return false;\n }\n }\n } else {\n for (const n in o) {\n if (has$2(o, n)) {\n if (cb.call(s, o[n], n, o) === false) {\n return false;\n }\n }\n }\n }\n return true;\n };\n const map$1 = (array, callback) => {\n const out = [];\n each$c(array, (item, index) => {\n out.push(callback(item, index, array));\n });\n return out;\n };\n const filter$3 = (a, f) => {\n const o = [];\n each$c(a, (v, index) => {\n if (!f || f(v, index, a)) {\n o.push(v);\n }\n });\n return o;\n };\n const indexOf = (a, v) => {\n if (a) {\n for (let i = 0, l = a.length; i < l; i++) {\n if (a[i] === v) {\n return i;\n }\n }\n }\n return -1;\n };\n const reduce = (collection, iteratee, accumulator, thisArg) => {\n let acc = isUndefined(accumulator) ? collection[0] : accumulator;\n for (let i = 0; i < collection.length; i++) {\n acc = iteratee.call(thisArg, acc, collection[i], i);\n }\n return acc;\n };\n const findIndex$1 = (array, predicate, thisArg) => {\n for (let i = 0, l = array.length; i < l; i++) {\n if (predicate.call(thisArg, array[i], i, array)) {\n return i;\n }\n }\n return -1;\n };\n const last$2 = collection => collection[collection.length - 1];\n\n const cached = f => {\n let called = false;\n let r;\n return (...args) => {\n if (!called) {\n called = true;\n r = f.apply(null, args);\n }\n return r;\n };\n };\n\n const DeviceType = (os, browser, userAgent, mediaMatch) => {\n const isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;\n const isiPhone = os.isiOS() && !isiPad;\n const isMobile = os.isiOS() || os.isAndroid();\n const isTouch = isMobile || mediaMatch('(pointer:coarse)');\n const isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');\n const isPhone = isiPhone || isMobile && !isTablet;\n const iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;\n const isDesktop = !isPhone && !isTablet && !iOSwebview;\n return {\n isiPad: constant(isiPad),\n isiPhone: constant(isiPhone),\n isTablet: constant(isTablet),\n isPhone: constant(isPhone),\n isTouch: constant(isTouch),\n isAndroid: os.isAndroid,\n isiOS: os.isiOS,\n isWebView: constant(iOSwebview),\n isDesktop: constant(isDesktop)\n };\n };\n\n const firstMatch = (regexes, s) => {\n for (let i = 0; i < regexes.length; i++) {\n const x = regexes[i];\n if (x.test(s)) {\n return x;\n }\n }\n return undefined;\n };\n const find$1 = (regexes, agent) => {\n const r = firstMatch(regexes, agent);\n if (!r) {\n return {\n major: 0,\n minor: 0\n };\n }\n const group = i => {\n return Number(agent.replace(r, '$' + i));\n };\n return nu$3(group(1), group(2));\n };\n const detect$5 = (versionRegexes, agent) => {\n const cleanedAgent = String(agent).toLowerCase();\n if (versionRegexes.length === 0) {\n return unknown$2();\n }\n return find$1(versionRegexes, cleanedAgent);\n };\n const unknown$2 = () => {\n return nu$3(0, 0);\n };\n const nu$3 = (major, minor) => {\n return {\n major,\n minor\n };\n };\n const Version = {\n nu: nu$3,\n detect: detect$5,\n unknown: unknown$2\n };\n\n const detectBrowser$1 = (browsers, userAgentData) => {\n return findMap(userAgentData.brands, uaBrand => {\n const lcBrand = uaBrand.brand.toLowerCase();\n return find$2(browsers, browser => {\n var _a;\n return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());\n }).map(info => ({\n current: info.name,\n version: Version.nu(parseInt(uaBrand.version, 10), 0)\n }));\n });\n };\n\n const detect$4 = (candidates, userAgent) => {\n const agent = String(userAgent).toLowerCase();\n return find$2(candidates, candidate => {\n return candidate.search(agent);\n });\n };\n const detectBrowser = (browsers, userAgent) => {\n return detect$4(browsers, userAgent).map(browser => {\n const version = Version.detect(browser.versionRegexes, userAgent);\n return {\n current: browser.name,\n version\n };\n });\n };\n const detectOs = (oses, userAgent) => {\n return detect$4(oses, userAgent).map(os => {\n const version = Version.detect(os.versionRegexes, userAgent);\n return {\n current: os.name,\n version\n };\n });\n };\n\n const removeFromStart = (str, numChars) => {\n return str.substring(numChars);\n };\n\n const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;\n const removeLeading = (str, prefix) => {\n return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;\n };\n const contains$1 = (str, substr, start = 0, end) => {\n const idx = str.indexOf(substr, start);\n if (idx !== -1) {\n return isUndefined(end) ? true : idx + substr.length <= end;\n } else {\n return false;\n }\n };\n const startsWith = (str, prefix) => {\n return checkRange(str, prefix, 0);\n };\n const endsWith = (str, suffix) => {\n return checkRange(str, suffix, str.length - suffix.length);\n };\n const blank = r => s => s.replace(r, '');\n const trim$4 = blank(/^\\s+|\\s+$/g);\n const lTrim = blank(/^\\s+/g);\n const rTrim = blank(/\\s+$/g);\n const isNotEmpty = s => s.length > 0;\n const isEmpty$3 = s => !isNotEmpty(s);\n const repeat = (s, count) => count <= 0 ? '' : new Array(count + 1).join(s);\n const toInt = (value, radix = 10) => {\n const num = parseInt(value, radix);\n return isNaN(num) ? Optional.none() : Optional.some(num);\n };\n\n const normalVersionRegex = /.*?version\\/\\ ?([0-9]+)\\.([0-9]+).*/;\n const checkContains = target => {\n return uastring => {\n return contains$1(uastring, target);\n };\n };\n const browsers = [\n {\n name: 'Edge',\n versionRegexes: [/.*?edge\\/ ?([0-9]+)\\.([0-9]+)$/],\n search: uastring => {\n return contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit');\n }\n },\n {\n name: 'Chromium',\n brand: 'Chromium',\n versionRegexes: [\n /.*?chrome\\/([0-9]+)\\.([0-9]+).*/,\n normalVersionRegex\n ],\n search: uastring => {\n return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe');\n }\n },\n {\n name: 'IE',\n versionRegexes: [\n /.*?msie\\ ?([0-9]+)\\.([0-9]+).*/,\n /.*?rv:([0-9]+)\\.([0-9]+).*/\n ],\n search: uastring => {\n return contains$1(uastring, 'msie') || contains$1(uastring, 'trident');\n }\n },\n {\n name: 'Opera',\n versionRegexes: [\n normalVersionRegex,\n /.*?opera\\/([0-9]+)\\.([0-9]+).*/\n ],\n search: checkContains('opera')\n },\n {\n name: 'Firefox',\n versionRegexes: [/.*?firefox\\/\\ ?([0-9]+)\\.([0-9]+).*/],\n search: checkContains('firefox')\n },\n {\n name: 'Safari',\n versionRegexes: [\n normalVersionRegex,\n /.*?cpu os ([0-9]+)_([0-9]+).*/\n ],\n search: uastring => {\n return (contains$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit');\n }\n }\n ];\n const oses = [\n {\n name: 'Windows',\n search: checkContains('win'),\n versionRegexes: [/.*?windows\\ nt\\ ?([0-9]+)\\.([0-9]+).*/]\n },\n {\n name: 'iOS',\n search: uastring => {\n return contains$1(uastring, 'iphone') || contains$1(uastring, 'ipad');\n },\n versionRegexes: [\n /.*?version\\/\\ ?([0-9]+)\\.([0-9]+).*/,\n /.*cpu os ([0-9]+)_([0-9]+).*/,\n /.*cpu iphone os ([0-9]+)_([0-9]+).*/\n ]\n },\n {\n name: 'Android',\n search: checkContains('android'),\n versionRegexes: [/.*?android\\ ?([0-9]+)\\.([0-9]+).*/]\n },\n {\n name: 'macOS',\n search: checkContains('mac os x'),\n versionRegexes: [/.*?mac\\ os\\ x\\ ?([0-9]+)_([0-9]+).*/]\n },\n {\n name: 'Linux',\n search: checkContains('linux'),\n versionRegexes: []\n },\n {\n name: 'Solaris',\n search: checkContains('sunos'),\n versionRegexes: []\n },\n {\n name: 'FreeBSD',\n search: checkContains('freebsd'),\n versionRegexes: []\n },\n {\n name: 'ChromeOS',\n search: checkContains('cros'),\n versionRegexes: [/.*?chrome\\/([0-9]+)\\.([0-9]+).*/]\n }\n ];\n const PlatformInfo = {\n browsers: constant(browsers),\n oses: constant(oses)\n };\n\n const edge = 'Edge';\n const chromium = 'Chromium';\n const ie = 'IE';\n const opera = 'Opera';\n const firefox = 'Firefox';\n const safari = 'Safari';\n const unknown$1 = () => {\n return nu$2({\n current: undefined,\n version: Version.unknown()\n });\n };\n const nu$2 = info => {\n const current = info.current;\n const version = info.version;\n const isBrowser = name => () => current === name;\n return {\n current,\n version,\n isEdge: isBrowser(edge),\n isChromium: isBrowser(chromium),\n isIE: isBrowser(ie),\n isOpera: isBrowser(opera),\n isFirefox: isBrowser(firefox),\n isSafari: isBrowser(safari)\n };\n };\n const Browser = {\n unknown: unknown$1,\n nu: nu$2,\n edge: constant(edge),\n chromium: constant(chromium),\n ie: constant(ie),\n opera: constant(opera),\n firefox: constant(firefox),\n safari: constant(safari)\n };\n\n const windows = 'Windows';\n const ios = 'iOS';\n const android = 'Android';\n const linux = 'Linux';\n const macos = 'macOS';\n const solaris = 'Solaris';\n const freebsd = 'FreeBSD';\n const chromeos = 'ChromeOS';\n const unknown = () => {\n return nu$1({\n current: undefined,\n version: Version.unknown()\n });\n };\n const nu$1 = info => {\n const current = info.current;\n const version = info.version;\n const isOS = name => () => current === name;\n return {\n current,\n version,\n isWindows: isOS(windows),\n isiOS: isOS(ios),\n isAndroid: isOS(android),\n isMacOS: isOS(macos),\n isLinux: isOS(linux),\n isSolaris: isOS(solaris),\n isFreeBSD: isOS(freebsd),\n isChromeOS: isOS(chromeos)\n };\n };\n const OperatingSystem = {\n unknown,\n nu: nu$1,\n windows: constant(windows),\n ios: constant(ios),\n android: constant(android),\n linux: constant(linux),\n macos: constant(macos),\n solaris: constant(solaris),\n freebsd: constant(freebsd),\n chromeos: constant(chromeos)\n };\n\n const detect$3 = (userAgent, userAgentDataOpt, mediaMatch) => {\n const browsers = PlatformInfo.browsers();\n const oses = PlatformInfo.oses();\n const browser = userAgentDataOpt.bind(userAgentData => detectBrowser$1(browsers, userAgentData)).orThunk(() => detectBrowser(browsers, userAgent)).fold(Browser.unknown, Browser.nu);\n const os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);\n const deviceType = DeviceType(os, browser, userAgent, mediaMatch);\n return {\n browser,\n os,\n deviceType\n };\n };\n const PlatformDetection = { detect: detect$3 };\n\n const mediaMatch = query => window.matchMedia(query).matches;\n let platform$4 = cached(() => PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch));\n const detect$2 = () => platform$4();\n\n const userAgent = navigator.userAgent;\n const platform$3 = detect$2();\n const browser$3 = platform$3.browser;\n const os$1 = platform$3.os;\n const deviceType = platform$3.deviceType;\n const windowsPhone = userAgent.indexOf('Windows Phone') !== -1;\n const Env = {\n transparentSrc: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',\n documentMode: browser$3.isIE() ? document.documentMode || 7 : 10,\n cacheSuffix: null,\n container: null,\n canHaveCSP: !browser$3.isIE(),\n windowsPhone,\n browser: {\n current: browser$3.current,\n version: browser$3.version,\n isChromium: browser$3.isChromium,\n isEdge: browser$3.isEdge,\n isFirefox: browser$3.isFirefox,\n isIE: browser$3.isIE,\n isOpera: browser$3.isOpera,\n isSafari: browser$3.isSafari\n },\n os: {\n current: os$1.current,\n version: os$1.version,\n isAndroid: os$1.isAndroid,\n isChromeOS: os$1.isChromeOS,\n isFreeBSD: os$1.isFreeBSD,\n isiOS: os$1.isiOS,\n isLinux: os$1.isLinux,\n isMacOS: os$1.isMacOS,\n isSolaris: os$1.isSolaris,\n isWindows: os$1.isWindows\n },\n deviceType: {\n isDesktop: deviceType.isDesktop,\n isiPad: deviceType.isiPad,\n isiPhone: deviceType.isiPhone,\n isPhone: deviceType.isPhone,\n isTablet: deviceType.isTablet,\n isTouch: deviceType.isTouch,\n isWebView: deviceType.isWebView\n }\n };\n\n const whiteSpaceRegExp$1 = /^\\s*|\\s*$/g;\n const trim$3 = str => {\n return isNullable(str) ? '' : ('' + str).replace(whiteSpaceRegExp$1, '');\n };\n const is$3 = (obj, type) => {\n if (!type) {\n return obj !== undefined;\n }\n if (type === 'array' && isArray(obj)) {\n return true;\n }\n return typeof obj === type;\n };\n const makeMap$4 = (items, delim, map = {}) => {\n const resolvedItems = isString(items) ? items.split(delim || ',') : items || [];\n let i = resolvedItems.length;\n while (i--) {\n map[resolvedItems[i]] = {};\n }\n return map;\n };\n const hasOwnProperty = has$2;\n const extend$3 = (obj, ...exts) => {\n for (let i = 0; i < exts.length; i++) {\n const ext = exts[i];\n for (const name in ext) {\n if (has$2(ext, name)) {\n const value = ext[name];\n if (value !== undefined) {\n obj[name] = value;\n }\n }\n }\n }\n return obj;\n };\n const walk$4 = function (o, f, n, s) {\n s = s || this;\n if (o) {\n if (n) {\n o = o[n];\n }\n each$c(o, (o, i) => {\n if (f.call(s, o, i, n) === false) {\n return false;\n } else {\n walk$4(o, f, n, s);\n return true;\n }\n });\n }\n };\n const resolve$3 = (n, o = window) => {\n const path = n.split('.');\n for (let i = 0, l = path.length; i < l; i++) {\n o = o[path[i]];\n if (!o) {\n break;\n }\n }\n return o;\n };\n const explode$3 = (s, d) => {\n if (isArray$1(s)) {\n return s;\n } else if (s === '') {\n return [];\n } else {\n return map$1(s.split(d || ','), trim$3);\n }\n };\n const _addCacheSuffix = url => {\n const cacheSuffix = Env.cacheSuffix;\n if (cacheSuffix) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + cacheSuffix;\n }\n return url;\n };\n const Tools = {\n trim: trim$3,\n isArray: isArray,\n is: is$3,\n toArray: toArray$1,\n makeMap: makeMap$4,\n each: each$c,\n map: map$1,\n grep: filter$3,\n inArray: indexOf,\n hasOwn: hasOwnProperty,\n extend: extend$3,\n walk: walk$4,\n resolve: resolve$3,\n explode: explode$3,\n _addCacheSuffix\n };\n\n const is$2 = (lhs, rhs, comparator = tripleEquals) => lhs.exists(left => comparator(left, rhs));\n const equals = (lhs, rhs, comparator = tripleEquals) => lift2(lhs, rhs, comparator).getOr(lhs.isNone() && rhs.isNone());\n const cat = arr => {\n const r = [];\n const push = x => {\n r.push(x);\n };\n for (let i = 0; i < arr.length; i++) {\n arr[i].each(push);\n }\n return r;\n };\n const lift2 = (oa, ob, f) => oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();\n const lift3 = (oa, ob, oc, f) => oa.isSome() && ob.isSome() && oc.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie(), oc.getOrDie())) : Optional.none();\n const someIf = (b, a) => b ? Optional.some(a) : Optional.none();\n\n const Global = typeof window !== 'undefined' ? window : Function('return this;')();\n\n const path = (parts, scope) => {\n let o = scope !== undefined && scope !== null ? scope : Global;\n for (let i = 0; i < parts.length && o !== undefined && o !== null; ++i) {\n o = o[parts[i]];\n }\n return o;\n };\n const resolve$2 = (p, scope) => {\n const parts = p.split('.');\n return path(parts, scope);\n };\n\n const unsafe = (name, scope) => {\n return resolve$2(name, scope);\n };\n const getOrDie = (name, scope) => {\n const actual = unsafe(name, scope);\n if (actual === undefined || actual === null) {\n throw new Error(name + ' not available on this browser');\n }\n return actual;\n };\n\n const getPrototypeOf$1 = Object.getPrototypeOf;\n const sandHTMLElement = scope => {\n return getOrDie('HTMLElement', scope);\n };\n const isPrototypeOf = x => {\n const scope = resolve$2('ownerDocument.defaultView', x);\n return isObject(x) && (sandHTMLElement(scope).prototype.isPrototypeOf(x) || /^HTML\\w*Element$/.test(getPrototypeOf$1(x).constructor.name));\n };\n\n const COMMENT = 8;\n const DOCUMENT = 9;\n const DOCUMENT_FRAGMENT = 11;\n const ELEMENT = 1;\n const TEXT = 3;\n\n const name = element => {\n const r = element.dom.nodeName;\n return r.toLowerCase();\n };\n const type$1 = element => element.dom.nodeType;\n const isType = t => element => type$1(element) === t;\n const isComment$1 = element => type$1(element) === COMMENT || name(element) === '#comment';\n const isHTMLElement$1 = element => isElement$7(element) && isPrototypeOf(element.dom);\n const isElement$7 = isType(ELEMENT);\n const isText$b = isType(TEXT);\n const isDocument$2 = isType(DOCUMENT);\n const isDocumentFragment$1 = isType(DOCUMENT_FRAGMENT);\n const isTag = tag => e => isElement$7(e) && name(e) === tag;\n\n const rawSet = (dom, key, value) => {\n if (isString(value) || isBoolean(value) || isNumber(value)) {\n dom.setAttribute(key, value + '');\n } else {\n console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);\n throw new Error('Attribute value was not simple');\n }\n };\n const set$3 = (element, key, value) => {\n rawSet(element.dom, key, value);\n };\n const setAll$1 = (element, attrs) => {\n const dom = element.dom;\n each$d(attrs, (v, k) => {\n rawSet(dom, k, v);\n });\n };\n const get$9 = (element, key) => {\n const v = element.dom.getAttribute(key);\n return v === null ? undefined : v;\n };\n const getOpt = (element, key) => Optional.from(get$9(element, key));\n const has$1 = (element, key) => {\n const dom = element.dom;\n return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;\n };\n const remove$a = (element, key) => {\n element.dom.removeAttribute(key);\n };\n const hasNone = element => {\n const attrs = element.dom.attributes;\n return attrs === undefined || attrs === null || attrs.length === 0;\n };\n const clone$4 = element => foldl(element.dom.attributes, (acc, attr) => {\n acc[attr.name] = attr.value;\n return acc;\n }, {});\n\n const read$4 = (element, attr) => {\n const value = get$9(element, attr);\n return value === undefined || value === '' ? [] : value.split(' ');\n };\n const add$4 = (element, attr, id) => {\n const old = read$4(element, attr);\n const nu = old.concat([id]);\n set$3(element, attr, nu.join(' '));\n return true;\n };\n const remove$9 = (element, attr, id) => {\n const nu = filter$5(read$4(element, attr), v => v !== id);\n if (nu.length > 0) {\n set$3(element, attr, nu.join(' '));\n } else {\n remove$a(element, attr);\n }\n return false;\n };\n\n const supports = element => element.dom.classList !== undefined;\n const get$8 = element => read$4(element, 'class');\n const add$3 = (element, clazz) => add$4(element, 'class', clazz);\n const remove$8 = (element, clazz) => remove$9(element, 'class', clazz);\n const toggle$2 = (element, clazz) => {\n if (contains$2(get$8(element), clazz)) {\n return remove$8(element, clazz);\n } else {\n return add$3(element, clazz);\n }\n };\n\n const add$2 = (element, clazz) => {\n if (supports(element)) {\n element.dom.classList.add(clazz);\n } else {\n add$3(element, clazz);\n }\n };\n const cleanClass = element => {\n const classList = supports(element) ? element.dom.classList : get$8(element);\n if (classList.length === 0) {\n remove$a(element, 'class');\n }\n };\n const remove$7 = (element, clazz) => {\n if (supports(element)) {\n const classList = element.dom.classList;\n classList.remove(clazz);\n } else {\n remove$8(element, clazz);\n }\n cleanClass(element);\n };\n const toggle$1 = (element, clazz) => {\n const result = supports(element) ? element.dom.classList.toggle(clazz) : toggle$2(element, clazz);\n cleanClass(element);\n return result;\n };\n const has = (element, clazz) => supports(element) && element.dom.classList.contains(clazz);\n\n const fromHtml$1 = (html, scope) => {\n const doc = scope || document;\n const div = doc.createElement('div');\n div.innerHTML = html;\n if (!div.hasChildNodes() || div.childNodes.length > 1) {\n const message = 'HTML does not have a single root node';\n console.error(message, html);\n throw new Error(message);\n }\n return fromDom$2(div.childNodes[0]);\n };\n const fromTag = (tag, scope) => {\n const doc = scope || document;\n const node = doc.createElement(tag);\n return fromDom$2(node);\n };\n const fromText = (text, scope) => {\n const doc = scope || document;\n const node = doc.createTextNode(text);\n return fromDom$2(node);\n };\n const fromDom$2 = node => {\n if (node === null || node === undefined) {\n throw new Error('Node cannot be null or undefined');\n }\n return { dom: node };\n };\n const fromPoint$2 = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom$2);\n const SugarElement = {\n fromHtml: fromHtml$1,\n fromTag,\n fromText,\n fromDom: fromDom$2,\n fromPoint: fromPoint$2\n };\n\n const toArray = (target, f) => {\n const r = [];\n const recurse = e => {\n r.push(e);\n return f(e);\n };\n let cur = f(target);\n do {\n cur = cur.bind(recurse);\n } while (cur.isSome());\n return r;\n };\n\n const is$1 = (element, selector) => {\n const dom = element.dom;\n if (dom.nodeType !== ELEMENT) {\n return false;\n } else {\n const elem = dom;\n if (elem.matches !== undefined) {\n return elem.matches(selector);\n } else if (elem.msMatchesSelector !== undefined) {\n return elem.msMatchesSelector(selector);\n } else if (elem.webkitMatchesSelector !== undefined) {\n return elem.webkitMatchesSelector(selector);\n } else if (elem.mozMatchesSelector !== undefined) {\n return elem.mozMatchesSelector(selector);\n } else {\n throw new Error('Browser lacks native selectors');\n }\n }\n };\n const bypassSelector = dom => dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0;\n const all = (selector, scope) => {\n const base = scope === undefined ? document : scope.dom;\n return bypassSelector(base) ? [] : map$3(base.querySelectorAll(selector), SugarElement.fromDom);\n };\n const one = (selector, scope) => {\n const base = scope === undefined ? document : scope.dom;\n return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom);\n };\n\n const eq = (e1, e2) => e1.dom === e2.dom;\n const contains = (e1, e2) => {\n const d1 = e1.dom;\n const d2 = e2.dom;\n return d1 === d2 ? false : d1.contains(d2);\n };\n\n const owner$1 = element => SugarElement.fromDom(element.dom.ownerDocument);\n const documentOrOwner = dos => isDocument$2(dos) ? dos : owner$1(dos);\n const documentElement = element => SugarElement.fromDom(documentOrOwner(element).dom.documentElement);\n const defaultView = element => SugarElement.fromDom(documentOrOwner(element).dom.defaultView);\n const parent = element => Optional.from(element.dom.parentNode).map(SugarElement.fromDom);\n const parentElement = element => Optional.from(element.dom.parentElement).map(SugarElement.fromDom);\n const parents$1 = (element, isRoot) => {\n const stop = isFunction(isRoot) ? isRoot : never;\n let dom = element.dom;\n const ret = [];\n while (dom.parentNode !== null && dom.parentNode !== undefined) {\n const rawParent = dom.parentNode;\n const p = SugarElement.fromDom(rawParent);\n ret.push(p);\n if (stop(p) === true) {\n break;\n } else {\n dom = rawParent;\n }\n }\n return ret;\n };\n const siblings = element => {\n const filterSelf = elements => filter$5(elements, x => !eq(element, x));\n return parent(element).map(children$1).map(filterSelf).getOr([]);\n };\n const prevSibling = element => Optional.from(element.dom.previousSibling).map(SugarElement.fromDom);\n const nextSibling = element => Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);\n const prevSiblings = element => reverse(toArray(element, prevSibling));\n const nextSiblings = element => toArray(element, nextSibling);\n const children$1 = element => map$3(element.dom.childNodes, SugarElement.fromDom);\n const child$1 = (element, index) => {\n const cs = element.dom.childNodes;\n return Optional.from(cs[index]).map(SugarElement.fromDom);\n };\n const firstChild = element => child$1(element, 0);\n const lastChild = element => child$1(element, element.dom.childNodes.length - 1);\n const childNodesCount = element => element.dom.childNodes.length;\n const hasChildNodes = element => element.dom.hasChildNodes();\n\n const getHead = doc => {\n const b = doc.dom.head;\n if (b === null || b === undefined) {\n throw new Error('Head is not available yet');\n }\n return SugarElement.fromDom(b);\n };\n\n const isShadowRoot = dos => isDocumentFragment$1(dos) && isNonNullable(dos.dom.host);\n const supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);\n const isSupported$1 = constant(supported);\n const getRootNode = supported ? e => SugarElement.fromDom(e.dom.getRootNode()) : documentOrOwner;\n const getStyleContainer = dos => isShadowRoot(dos) ? dos : getHead(documentOrOwner(dos));\n const getContentContainer = dos => isShadowRoot(dos) ? dos : SugarElement.fromDom(documentOrOwner(dos).dom.body);\n const getShadowRoot = e => {\n const r = getRootNode(e);\n return isShadowRoot(r) ? Optional.some(r) : Optional.none();\n };\n const getShadowHost = e => SugarElement.fromDom(e.dom.host);\n const getOriginalEventTarget = event => {\n if (isSupported$1() && isNonNullable(event.target)) {\n const el = SugarElement.fromDom(event.target);\n if (isElement$7(el) && isOpenShadowHost(el)) {\n if (event.composed && event.composedPath) {\n const composedPath = event.composedPath();\n if (composedPath) {\n return head(composedPath);\n }\n }\n }\n }\n return Optional.from(event.target);\n };\n const isOpenShadowHost = element => isNonNullable(element.dom.shadowRoot);\n\n const inBody = element => {\n const dom = isText$b(element) ? element.dom.parentNode : element.dom;\n if (dom === undefined || dom === null || dom.ownerDocument === null) {\n return false;\n }\n const doc = dom.ownerDocument;\n return getShadowRoot(SugarElement.fromDom(dom)).fold(() => doc.body.contains(dom), compose1(inBody, getShadowHost));\n };\n\n var ClosestOrAncestor = (is, ancestor, scope, a, isRoot) => {\n if (is(scope, a)) {\n return Optional.some(scope);\n } else if (isFunction(isRoot) && isRoot(scope)) {\n return Optional.none();\n } else {\n return ancestor(scope, a, isRoot);\n }\n };\n\n const ancestor$4 = (scope, predicate, isRoot) => {\n let element = scope.dom;\n const stop = isFunction(isRoot) ? isRoot : never;\n while (element.parentNode) {\n element = element.parentNode;\n const el = SugarElement.fromDom(element);\n if (predicate(el)) {\n return Optional.some(el);\n } else if (stop(el)) {\n break;\n }\n }\n return Optional.none();\n };\n const closest$4 = (scope, predicate, isRoot) => {\n const is = (s, test) => test(s);\n return ClosestOrAncestor(is, ancestor$4, scope, predicate, isRoot);\n };\n const sibling$1 = (scope, predicate) => {\n const element = scope.dom;\n if (!element.parentNode) {\n return Optional.none();\n }\n return child(SugarElement.fromDom(element.parentNode), x => !eq(scope, x) && predicate(x));\n };\n const child = (scope, predicate) => {\n const pred = node => predicate(SugarElement.fromDom(node));\n const result = find$2(scope.dom.childNodes, pred);\n return result.map(SugarElement.fromDom);\n };\n const descendant$2 = (scope, predicate) => {\n const descend = node => {\n for (let i = 0; i < node.childNodes.length; i++) {\n const child = SugarElement.fromDom(node.childNodes[i]);\n if (predicate(child)) {\n return Optional.some(child);\n }\n const res = descend(node.childNodes[i]);\n if (res.isSome()) {\n return res;\n }\n }\n return Optional.none();\n };\n return descend(scope.dom);\n };\n\n const ancestor$3 = (scope, selector, isRoot) => ancestor$4(scope, e => is$1(e, selector), isRoot);\n const descendant$1 = (scope, selector) => one(selector, scope);\n const closest$3 = (scope, selector, isRoot) => {\n const is = (element, selector) => is$1(element, selector);\n return ClosestOrAncestor(is, ancestor$3, scope, selector, isRoot);\n };\n\n const closest$2 = target => closest$3(target, '[contenteditable]');\n const isEditable$2 = (element, assumeEditable = false) => {\n if (inBody(element)) {\n return element.dom.isContentEditable;\n } else {\n return closest$2(element).fold(constant(assumeEditable), editable => getRaw$1(editable) === 'true');\n }\n };\n const getRaw$1 = element => element.dom.contentEditable;\n\n const isSupported = dom => dom.style !== undefined && isFunction(dom.style.getPropertyValue);\n\n const internalSet = (dom, property, value) => {\n if (!isString(value)) {\n console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);\n throw new Error('CSS value must be a string: ' + value);\n }\n if (isSupported(dom)) {\n dom.style.setProperty(property, value);\n }\n };\n const internalRemove = (dom, property) => {\n if (isSupported(dom)) {\n dom.style.removeProperty(property);\n }\n };\n const set$2 = (element, property, value) => {\n const dom = element.dom;\n internalSet(dom, property, value);\n };\n const setAll = (element, css) => {\n const dom = element.dom;\n each$d(css, (v, k) => {\n internalSet(dom, k, v);\n });\n };\n const get$7 = (element, property) => {\n const dom = element.dom;\n const styles = window.getComputedStyle(dom);\n const r = styles.getPropertyValue(property);\n return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;\n };\n const getUnsafeProperty = (dom, property) => isSupported(dom) ? dom.style.getPropertyValue(property) : '';\n const getRaw = (element, property) => {\n const dom = element.dom;\n const raw = getUnsafeProperty(dom, property);\n return Optional.from(raw).filter(r => r.length > 0);\n };\n const getAllRaw = element => {\n const css = {};\n const dom = element.dom;\n if (isSupported(dom)) {\n for (let i = 0; i < dom.style.length; i++) {\n const ruleName = dom.style.item(i);\n css[ruleName] = dom.style[ruleName];\n }\n }\n return css;\n };\n const remove$6 = (element, property) => {\n const dom = element.dom;\n internalRemove(dom, property);\n if (is$2(getOpt(element, 'style').map(trim$4), '')) {\n remove$a(element, 'style');\n }\n };\n const reflow = e => e.dom.offsetWidth;\n\n const before$3 = (marker, element) => {\n const parent$1 = parent(marker);\n parent$1.each(v => {\n v.dom.insertBefore(element.dom, marker.dom);\n });\n };\n const after$4 = (marker, element) => {\n const sibling = nextSibling(marker);\n sibling.fold(() => {\n const parent$1 = parent(marker);\n parent$1.each(v => {\n append$1(v, element);\n });\n }, v => {\n before$3(v, element);\n });\n };\n const prepend = (parent, element) => {\n const firstChild$1 = firstChild(parent);\n firstChild$1.fold(() => {\n append$1(parent, element);\n }, v => {\n parent.dom.insertBefore(element.dom, v.dom);\n });\n };\n const append$1 = (parent, element) => {\n parent.dom.appendChild(element.dom);\n };\n const wrap$2 = (element, wrapper) => {\n before$3(element, wrapper);\n append$1(wrapper, element);\n };\n\n const after$3 = (marker, elements) => {\n each$e(elements, (x, i) => {\n const e = i === 0 ? marker : elements[i - 1];\n after$4(e, x);\n });\n };\n const append = (parent, elements) => {\n each$e(elements, x => {\n append$1(parent, x);\n });\n };\n\n const empty = element => {\n element.dom.textContent = '';\n each$e(children$1(element), rogue => {\n remove$5(rogue);\n });\n };\n const remove$5 = element => {\n const dom = element.dom;\n if (dom.parentNode !== null) {\n dom.parentNode.removeChild(dom);\n }\n };\n const unwrap = wrapper => {\n const children = children$1(wrapper);\n if (children.length > 0) {\n after$3(wrapper, children);\n }\n remove$5(wrapper);\n };\n\n const fromHtml = (html, scope) => {\n const doc = scope || document;\n const div = doc.createElement('div');\n div.innerHTML = html;\n return children$1(SugarElement.fromDom(div));\n };\n const fromDom$1 = nodes => map$3(nodes, SugarElement.fromDom);\n\n const get$6 = element => element.dom.innerHTML;\n const set$1 = (element, content) => {\n const owner = owner$1(element);\n const docDom = owner.dom;\n const fragment = SugarElement.fromDom(docDom.createDocumentFragment());\n const contentElements = fromHtml(content, docDom);\n append(fragment, contentElements);\n empty(element);\n append$1(element, fragment);\n };\n const getOuter = element => {\n const container = SugarElement.fromTag('div');\n const clone = SugarElement.fromDom(element.dom.cloneNode(true));\n append$1(container, clone);\n return get$6(container);\n };\n\n const mkEvent = (target, x, y, stop, prevent, kill, raw) => ({\n target,\n x,\n y,\n stop,\n prevent,\n kill,\n raw\n });\n const fromRawEvent = rawEvent => {\n const target = SugarElement.fromDom(getOriginalEventTarget(rawEvent).getOr(rawEvent.target));\n const stop = () => rawEvent.stopPropagation();\n const prevent = () => rawEvent.preventDefault();\n const kill = compose(prevent, stop);\n return mkEvent(target, rawEvent.clientX, rawEvent.clientY, stop, prevent, kill, rawEvent);\n };\n const handle$1 = (filter, handler) => rawEvent => {\n if (filter(rawEvent)) {\n handler(fromRawEvent(rawEvent));\n }\n };\n const binder = (element, event, filter, handler, useCapture) => {\n const wrapped = handle$1(filter, handler);\n element.dom.addEventListener(event, wrapped, useCapture);\n return { unbind: curry(unbind, element, event, wrapped, useCapture) };\n };\n const bind$2 = (element, event, filter, handler) => binder(element, event, filter, handler, false);\n const unbind = (element, event, handler, useCapture) => {\n element.dom.removeEventListener(event, handler, useCapture);\n };\n\n const r = (left, top) => {\n const translate = (x, y) => r(left + x, top + y);\n return {\n left,\n top,\n translate\n };\n };\n const SugarPosition = r;\n\n const boxPosition = dom => {\n const box = dom.getBoundingClientRect();\n return SugarPosition(box.left, box.top);\n };\n const firstDefinedOrZero = (a, b) => {\n if (a !== undefined) {\n return a;\n } else {\n return b !== undefined ? b : 0;\n }\n };\n const absolute = element => {\n const doc = element.dom.ownerDocument;\n const body = doc.body;\n const win = doc.defaultView;\n const html = doc.documentElement;\n if (body === element.dom) {\n return SugarPosition(body.offsetLeft, body.offsetTop);\n }\n const scrollTop = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageYOffset, html.scrollTop);\n const scrollLeft = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageXOffset, html.scrollLeft);\n const clientTop = firstDefinedOrZero(html.clientTop, body.clientTop);\n const clientLeft = firstDefinedOrZero(html.clientLeft, body.clientLeft);\n return viewport(element).translate(scrollLeft - clientLeft, scrollTop - clientTop);\n };\n const viewport = element => {\n const dom = element.dom;\n const doc = dom.ownerDocument;\n const body = doc.body;\n if (body === dom) {\n return SugarPosition(body.offsetLeft, body.offsetTop);\n }\n if (!inBody(element)) {\n return SugarPosition(0, 0);\n }\n return boxPosition(dom);\n };\n\n const get$5 = _DOC => {\n const doc = _DOC !== undefined ? _DOC.dom : document;\n const x = doc.body.scrollLeft || doc.documentElement.scrollLeft;\n const y = doc.body.scrollTop || doc.documentElement.scrollTop;\n return SugarPosition(x, y);\n };\n const to = (x, y, _DOC) => {\n const doc = _DOC !== undefined ? _DOC.dom : document;\n const win = doc.defaultView;\n if (win) {\n win.scrollTo(x, y);\n }\n };\n const intoView = (element, alignToTop) => {\n const isSafari = detect$2().browser.isSafari();\n if (isSafari && isFunction(element.dom.scrollIntoViewIfNeeded)) {\n element.dom.scrollIntoViewIfNeeded(false);\n } else {\n element.dom.scrollIntoView(alignToTop);\n }\n };\n\n const get$4 = _win => {\n const win = _win === undefined ? window : _win;\n if (detect$2().browser.isFirefox()) {\n return Optional.none();\n } else {\n return Optional.from(win.visualViewport);\n }\n };\n const bounds = (x, y, width, height) => ({\n x,\n y,\n width,\n height,\n right: x + width,\n bottom: y + height\n });\n const getBounds = _win => {\n const win = _win === undefined ? window : _win;\n const doc = win.document;\n const scroll = get$5(SugarElement.fromDom(doc));\n return get$4(win).fold(() => {\n const html = win.document.documentElement;\n const width = html.clientWidth;\n const height = html.clientHeight;\n return bounds(scroll.left, scroll.top, width, height);\n }, visualViewport => bounds(Math.max(visualViewport.pageLeft, scroll.left), Math.max(visualViewport.pageTop, scroll.top), visualViewport.width, visualViewport.height));\n };\n\n const children = (scope, predicate) => filter$5(children$1(scope), predicate);\n const descendants$1 = (scope, predicate) => {\n let result = [];\n each$e(children$1(scope), x => {\n if (predicate(x)) {\n result = result.concat([x]);\n }\n result = result.concat(descendants$1(x, predicate));\n });\n return result;\n };\n\n const descendants = (scope, selector) => all(selector, scope);\n\n const ancestor$2 = (scope, selector, isRoot) => ancestor$3(scope, selector, isRoot).isSome();\n\n class DomTreeWalker {\n constructor(startNode, rootNode) {\n this.node = startNode;\n this.rootNode = rootNode;\n this.current = this.current.bind(this);\n this.next = this.next.bind(this);\n this.prev = this.prev.bind(this);\n this.prev2 = this.prev2.bind(this);\n }\n current() {\n return this.node;\n }\n next(shallow) {\n this.node = this.findSibling(this.node, 'firstChild', 'nextSibling', shallow);\n return this.node;\n }\n prev(shallow) {\n this.node = this.findSibling(this.node, 'lastChild', 'previousSibling', shallow);\n return this.node;\n }\n prev2(shallow) {\n this.node = this.findPreviousNode(this.node, shallow);\n return this.node;\n }\n findSibling(node, startName, siblingName, shallow) {\n if (node) {\n if (!shallow && node[startName]) {\n return node[startName];\n }\n if (node !== this.rootNode) {\n let sibling = node[siblingName];\n if (sibling) {\n return sibling;\n }\n for (let parent = node.parentNode; parent && parent !== this.rootNode; parent = parent.parentNode) {\n sibling = parent[siblingName];\n if (sibling) {\n return sibling;\n }\n }\n }\n }\n return undefined;\n }\n findPreviousNode(node, shallow) {\n if (node) {\n const sibling = node.previousSibling;\n if (this.rootNode && sibling === this.rootNode) {\n return;\n }\n if (sibling) {\n if (!shallow) {\n for (let child = sibling.lastChild; child; child = child.lastChild) {\n if (!child.lastChild) {\n return child;\n }\n }\n }\n return sibling;\n }\n const parent = node.parentNode;\n if (parent && parent !== this.rootNode) {\n return parent;\n }\n }\n return undefined;\n }\n }\n\n const isNodeType = type => {\n return node => {\n return !!node && node.nodeType === type;\n };\n };\n const isRestrictedNode = node => !!node && !Object.getPrototypeOf(node);\n const isElement$6 = isNodeType(1);\n const isHTMLElement = node => isElement$6(node) && isHTMLElement$1(SugarElement.fromDom(node));\n const isSVGElement = node => isElement$6(node) && node.namespaceURI === 'http://www.w3.org/2000/svg';\n const matchNodeName = name => {\n const lowerCasedName = name.toLowerCase();\n return node => isNonNullable(node) && node.nodeName.toLowerCase() === lowerCasedName;\n };\n const matchNodeNames = names => {\n const lowerCasedNames = names.map(s => s.toLowerCase());\n return node => {\n if (node && node.nodeName) {\n const nodeName = node.nodeName.toLowerCase();\n return contains$2(lowerCasedNames, nodeName);\n }\n return false;\n };\n };\n const matchStyleValues = (name, values) => {\n const items = values.toLowerCase().split(' ');\n return node => {\n if (isElement$6(node)) {\n const win = node.ownerDocument.defaultView;\n if (win) {\n for (let i = 0; i < items.length; i++) {\n const computed = win.getComputedStyle(node, null);\n const cssValue = computed ? computed.getPropertyValue(name) : null;\n if (cssValue === items[i]) {\n return true;\n }\n }\n }\n }\n return false;\n };\n };\n const hasAttribute = attrName => {\n return node => {\n return isElement$6(node) && node.hasAttribute(attrName);\n };\n };\n const hasAttributeValue = (attrName, attrValue) => {\n return node => {\n return isElement$6(node) && node.getAttribute(attrName) === attrValue;\n };\n };\n const isBogus$2 = node => isElement$6(node) && node.hasAttribute('data-mce-bogus');\n const isBogusAll$1 = node => isElement$6(node) && node.getAttribute('data-mce-bogus') === 'all';\n const isTable$2 = node => isElement$6(node) && node.tagName === 'TABLE';\n const hasContentEditableState = value => {\n return node => {\n if (isHTMLElement(node)) {\n if (node.contentEditable === value) {\n return true;\n }\n if (node.getAttribute('data-mce-contenteditable') === value) {\n return true;\n }\n }\n return false;\n };\n };\n const isTextareaOrInput = matchNodeNames([\n 'textarea',\n 'input'\n ]);\n const isText$a = isNodeType(3);\n const isCData = isNodeType(4);\n const isPi = isNodeType(7);\n const isComment = isNodeType(8);\n const isDocument$1 = isNodeType(9);\n const isDocumentFragment = isNodeType(11);\n const isBr$6 = matchNodeName('br');\n const isImg = matchNodeName('img');\n const isContentEditableTrue$3 = hasContentEditableState('true');\n const isContentEditableFalse$b = hasContentEditableState('false');\n const isTableCell$3 = matchNodeNames([\n 'td',\n 'th'\n ]);\n const isTableCellOrCaption = matchNodeNames([\n 'td',\n 'th',\n 'caption'\n ]);\n const isMedia$2 = matchNodeNames([\n 'video',\n 'audio',\n 'object',\n 'embed'\n ]);\n const isListItem$2 = matchNodeName('li');\n const isDetails = matchNodeName('details');\n const isSummary$1 = matchNodeName('summary');\n\n const zeroWidth = '\\uFEFF';\n const nbsp = '\\xA0';\n const isZwsp$2 = char => char === zeroWidth;\n const removeZwsp = s => s.replace(/\\uFEFF/g, '');\n\n const NodeValue = (is, name) => {\n const get = element => {\n if (!is(element)) {\n throw new Error('Can only get ' + name + ' value of a ' + name + ' node');\n }\n return getOption(element).getOr('');\n };\n const getOption = element => is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();\n const set = (element, value) => {\n if (!is(element)) {\n throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');\n }\n element.dom.nodeValue = value;\n };\n return {\n get,\n getOption,\n set\n };\n };\n\n const api$1 = NodeValue(isText$b, 'text');\n const get$3 = element => api$1.get(element);\n const getOption = element => api$1.getOption(element);\n const set = (element, value) => api$1.set(element, value);\n\n const tableCells = [\n 'td',\n 'th'\n ];\n const tableSections = [\n 'thead',\n 'tbody',\n 'tfoot'\n ];\n const textBlocks = [\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'p',\n 'div',\n 'address',\n 'pre',\n 'form',\n 'blockquote',\n 'center',\n 'dir',\n 'fieldset',\n 'header',\n 'footer',\n 'article',\n 'section',\n 'hgroup',\n 'aside',\n 'nav',\n 'figure'\n ];\n const listItems$1 = [\n 'li',\n 'dd',\n 'dt'\n ];\n const lists = [\n 'ul',\n 'ol',\n 'dl'\n ];\n const wsElements = [\n 'pre',\n 'script',\n 'textarea',\n 'style'\n ];\n const lazyLookup = items => {\n let lookup;\n return node => {\n lookup = lookup ? lookup : mapToObject(items, always);\n return has$2(lookup, name(node));\n };\n };\n const isTable$1 = node => name(node) === 'table';\n const isBr$5 = node => isElement$7(node) && name(node) === 'br';\n const isTextBlock$2 = lazyLookup(textBlocks);\n const isList = lazyLookup(lists);\n const isListItem$1 = lazyLookup(listItems$1);\n const isTableSection = lazyLookup(tableSections);\n const isTableCell$2 = lazyLookup(tableCells);\n const isWsPreserveElement = lazyLookup(wsElements);\n\n const getLastChildren$1 = elm => {\n const children = [];\n let rawNode = elm.dom;\n while (rawNode) {\n children.push(SugarElement.fromDom(rawNode));\n rawNode = rawNode.lastChild;\n }\n return children;\n };\n const removeTrailingBr = elm => {\n const allBrs = descendants(elm, 'br');\n const brs = filter$5(getLastChildren$1(elm).slice(-1), isBr$5);\n if (allBrs.length === brs.length) {\n each$e(brs, remove$5);\n }\n };\n const createPaddingBr = () => {\n const br = SugarElement.fromTag('br');\n set$3(br, 'data-mce-bogus', '1');\n return br;\n };\n const fillWithPaddingBr = elm => {\n empty(elm);\n append$1(elm, createPaddingBr());\n };\n const trimBlockTrailingBr = (elm, schema) => {\n lastChild(elm).each(lastChild => {\n prevSibling(lastChild).each(lastChildPrevSibling => {\n if (schema.isBlock(name(elm)) && isBr$5(lastChild) && schema.isBlock(name(lastChildPrevSibling))) {\n remove$5(lastChild);\n }\n });\n });\n };\n\n const ZWSP$1 = zeroWidth;\n const isZwsp$1 = isZwsp$2;\n const trim$2 = removeZwsp;\n const insert$5 = editor => editor.insertContent(ZWSP$1, { preserve_zwsp: true });\n\n const isElement$5 = isElement$6;\n const isText$9 = isText$a;\n const isCaretContainerBlock$1 = node => {\n if (isText$9(node)) {\n node = node.parentNode;\n }\n return isElement$5(node) && node.hasAttribute('data-mce-caret');\n };\n const isCaretContainerInline = node => isText$9(node) && isZwsp$1(node.data);\n const isCaretContainer$2 = node => isCaretContainerBlock$1(node) || isCaretContainerInline(node);\n const hasContent = node => node.firstChild !== node.lastChild || !isBr$6(node.firstChild);\n const insertInline$1 = (node, before) => {\n var _a;\n const doc = (_a = node.ownerDocument) !== null && _a !== void 0 ? _a : document;\n const textNode = doc.createTextNode(ZWSP$1);\n const parentNode = node.parentNode;\n if (!before) {\n const sibling = node.nextSibling;\n if (isText$9(sibling)) {\n if (isCaretContainer$2(sibling)) {\n return sibling;\n }\n if (startsWithCaretContainer$1(sibling)) {\n sibling.splitText(1);\n return sibling;\n }\n }\n if (node.nextSibling) {\n parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(textNode, node.nextSibling);\n } else {\n parentNode === null || parentNode === void 0 ? void 0 : parentNode.appendChild(textNode);\n }\n } else {\n const sibling = node.previousSibling;\n if (isText$9(sibling)) {\n if (isCaretContainer$2(sibling)) {\n return sibling;\n }\n if (endsWithCaretContainer$1(sibling)) {\n return sibling.splitText(sibling.data.length - 1);\n }\n }\n parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(textNode, node);\n }\n return textNode;\n };\n const isBeforeInline = pos => {\n const container = pos.container();\n if (!isText$a(container)) {\n return false;\n }\n return container.data.charAt(pos.offset()) === ZWSP$1 || pos.isAtStart() && isCaretContainerInline(container.previousSibling);\n };\n const isAfterInline = pos => {\n const container = pos.container();\n if (!isText$a(container)) {\n return false;\n }\n return container.data.charAt(pos.offset() - 1) === ZWSP$1 || pos.isAtEnd() && isCaretContainerInline(container.nextSibling);\n };\n const insertBlock = (blockName, node, before) => {\n var _a;\n const doc = (_a = node.ownerDocument) !== null && _a !== void 0 ? _a : document;\n const blockNode = doc.createElement(blockName);\n blockNode.setAttribute('data-mce-caret', before ? 'before' : 'after');\n blockNode.setAttribute('data-mce-bogus', 'all');\n blockNode.appendChild(createPaddingBr().dom);\n const parentNode = node.parentNode;\n if (!before) {\n if (node.nextSibling) {\n parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(blockNode, node.nextSibling);\n } else {\n parentNode === null || parentNode === void 0 ? void 0 : parentNode.appendChild(blockNode);\n }\n } else {\n parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(blockNode, node);\n }\n return blockNode;\n };\n const startsWithCaretContainer$1 = node => isText$9(node) && node.data[0] === ZWSP$1;\n const endsWithCaretContainer$1 = node => isText$9(node) && node.data[node.data.length - 1] === ZWSP$1;\n const trimBogusBr = elm => {\n var _a;\n const brs = elm.getElementsByTagName('br');\n const lastBr = brs[brs.length - 1];\n if (isBogus$2(lastBr)) {\n (_a = lastBr.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(lastBr);\n }\n };\n const showCaretContainerBlock = caretContainer => {\n if (caretContainer && caretContainer.hasAttribute('data-mce-caret')) {\n trimBogusBr(caretContainer);\n caretContainer.removeAttribute('data-mce-caret');\n caretContainer.removeAttribute('data-mce-bogus');\n caretContainer.removeAttribute('style');\n caretContainer.removeAttribute('data-mce-style');\n caretContainer.removeAttribute('_moz_abspos');\n return caretContainer;\n }\n return null;\n };\n const isRangeInCaretContainerBlock = range => isCaretContainerBlock$1(range.startContainer);\n\n const isContentEditableTrue$2 = isContentEditableTrue$3;\n const isContentEditableFalse$a = isContentEditableFalse$b;\n const isBr$4 = isBr$6;\n const isText$8 = isText$a;\n const isInvalidTextElement = matchNodeNames([\n 'script',\n 'style',\n 'textarea'\n ]);\n const isAtomicInline = matchNodeNames([\n 'img',\n 'input',\n 'textarea',\n 'hr',\n 'iframe',\n 'video',\n 'audio',\n 'object',\n 'embed'\n ]);\n const isTable = matchNodeNames(['table']);\n const isCaretContainer$1 = isCaretContainer$2;\n const isCaretCandidate$3 = node => {\n if (isCaretContainer$1(node)) {\n return false;\n }\n if (isText$8(node)) {\n return !isInvalidTextElement(node.parentNode);\n }\n return isAtomicInline(node) || isBr$4(node) || isTable(node) || isNonUiContentEditableFalse(node);\n };\n const isUnselectable = node => isElement$6(node) && node.getAttribute('unselectable') === 'true';\n const isNonUiContentEditableFalse = node => !isUnselectable(node) && isContentEditableFalse$a(node);\n const isInEditable = (node, root) => {\n for (let tempNode = node.parentNode; tempNode && tempNode !== root; tempNode = tempNode.parentNode) {\n if (isNonUiContentEditableFalse(tempNode)) {\n return false;\n }\n if (isContentEditableTrue$2(tempNode)) {\n return true;\n }\n }\n return true;\n };\n const isAtomicContentEditableFalse = node => {\n if (!isNonUiContentEditableFalse(node)) {\n return false;\n }\n return !foldl(from(node.getElementsByTagName('*')), (result, elm) => {\n return result || isContentEditableTrue$2(elm);\n }, false);\n };\n const isAtomic$1 = node => isAtomicInline(node) || isAtomicContentEditableFalse(node);\n const isEditableCaretCandidate$1 = (node, root) => isCaretCandidate$3(node) && isInEditable(node, root);\n\n const whiteSpaceRegExp = /^[ \\t\\r\\n]*$/;\n const isWhitespaceText = text => whiteSpaceRegExp.test(text);\n const isZwsp = text => {\n for (const c of text) {\n if (!isZwsp$2(c)) {\n return false;\n }\n }\n return true;\n };\n const isCollapsibleWhitespace$1 = c => ' \\f\\t\\x0B'.indexOf(c) !== -1;\n const isNewLineChar = c => c === '\\n' || c === '\\r';\n const isNewline = (text, idx) => idx < text.length && idx >= 0 ? isNewLineChar(text[idx]) : false;\n const normalize$4 = (text, tabSpaces = 4, isStartOfContent = true, isEndOfContent = true) => {\n const tabSpace = repeat(' ', tabSpaces);\n const normalizedText = text.replace(/\\t/g, tabSpace);\n const result = foldl(normalizedText, (acc, c) => {\n if (isCollapsibleWhitespace$1(c) || c === nbsp) {\n if (acc.pcIsSpace || acc.str === '' && isStartOfContent || acc.str.length === normalizedText.length - 1 && isEndOfContent || isNewline(normalizedText, acc.str.length + 1)) {\n return {\n pcIsSpace: false,\n str: acc.str + nbsp\n };\n } else {\n return {\n pcIsSpace: true,\n str: acc.str + ' '\n };\n }\n } else {\n return {\n pcIsSpace: isNewLineChar(c),\n str: acc.str + c\n };\n }\n }, {\n pcIsSpace: false,\n str: ''\n });\n return result.str;\n };\n\n const hasWhitespacePreserveParent = (node, rootNode) => {\n const rootElement = SugarElement.fromDom(rootNode);\n const startNode = SugarElement.fromDom(node);\n return ancestor$2(startNode, 'pre,code', curry(eq, rootElement));\n };\n const isWhitespace$1 = (node, rootNode) => {\n return isText$a(node) && isWhitespaceText(node.data) && !hasWhitespacePreserveParent(node, rootNode);\n };\n const isNamedAnchor = node => {\n return isElement$6(node) && node.nodeName === 'A' && !node.hasAttribute('href') && (node.hasAttribute('name') || node.hasAttribute('id'));\n };\n const isContent$1 = (node, rootNode) => {\n return isCaretCandidate$3(node) && !isWhitespace$1(node, rootNode) || isNamedAnchor(node) || isBookmark(node);\n };\n const isBookmark = hasAttribute('data-mce-bookmark');\n const isBogus$1 = hasAttribute('data-mce-bogus');\n const isBogusAll = hasAttributeValue('data-mce-bogus', 'all');\n const hasNonEditableParent = node => parentElement(SugarElement.fromDom(node)).exists(parent => !isEditable$2(parent));\n const isEmptyNode = (targetNode, skipBogus) => {\n let brCount = 0;\n if (isContent$1(targetNode, targetNode)) {\n return false;\n } else {\n let node = targetNode.firstChild;\n if (!node) {\n return true;\n }\n const walker = new DomTreeWalker(node, targetNode);\n do {\n if (skipBogus) {\n if (isBogusAll(node)) {\n node = walker.next(true);\n continue;\n }\n if (isBogus$1(node)) {\n node = walker.next();\n continue;\n }\n }\n if (isContentEditableTrue$3(node) && hasNonEditableParent(node)) {\n return false;\n }\n if (isBr$6(node)) {\n brCount++;\n node = walker.next();\n continue;\n }\n if (isContent$1(node, targetNode)) {\n return false;\n }\n node = walker.next();\n } while (node);\n return brCount <= 1;\n }\n };\n const isEmpty$2 = (elm, skipBogus = true) => isEmptyNode(elm.dom, skipBogus);\n\n const isNonHtmlElementRootName = name => name.toLowerCase() === 'svg';\n const isNonHtmlElementRoot = node => isNonHtmlElementRootName(node.nodeName);\n const toScopeType = node => (node === null || node === void 0 ? void 0 : node.nodeName) === 'svg' ? 'svg' : 'html';\n const namespaceElements = ['svg'];\n const createNamespaceTracker = () => {\n let scopes = [];\n const peek = () => scopes[scopes.length - 1];\n const track = node => {\n if (isNonHtmlElementRoot(node)) {\n scopes.push(node);\n }\n let currentScope = peek();\n if (currentScope && !currentScope.contains(node)) {\n scopes.pop();\n currentScope = peek();\n }\n return toScopeType(currentScope);\n };\n const current = () => toScopeType(peek());\n const reset = () => {\n scopes = [];\n };\n return {\n track,\n current,\n reset\n };\n };\n\n const transparentBlockAttr = 'data-mce-block';\n const elementNames = map => filter$5(keys(map), key => !/[A-Z]/.test(key));\n const makeSelectorFromSchemaMap = map => map$3(elementNames(map), name => {\n return `${ name }:` + map$3(namespaceElements, ns => `not(${ ns } ${ name })`).join(':');\n }).join(',');\n const updateTransparent = (blocksSelector, transparent) => {\n if (isNonNullable(transparent.querySelector(blocksSelector))) {\n transparent.setAttribute(transparentBlockAttr, 'true');\n if (transparent.getAttribute('data-mce-selected') === 'inline-boundary') {\n transparent.removeAttribute('data-mce-selected');\n }\n return true;\n } else {\n transparent.removeAttribute(transparentBlockAttr);\n return false;\n }\n };\n const updateBlockStateOnChildren = (schema, scope) => {\n const transparentSelector = makeSelectorFromSchemaMap(schema.getTransparentElements());\n const blocksSelector = makeSelectorFromSchemaMap(schema.getBlockElements());\n return filter$5(scope.querySelectorAll(transparentSelector), transparent => updateTransparent(blocksSelector, transparent));\n };\n const trimEdge = (el, leftSide) => {\n var _a;\n const childPropertyName = leftSide ? 'lastChild' : 'firstChild';\n for (let child = el[childPropertyName]; child; child = child[childPropertyName]) {\n if (isEmpty$2(SugarElement.fromDom(child))) {\n (_a = child.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(child);\n return;\n }\n }\n };\n const split$2 = (parentElm, splitElm) => {\n const range = document.createRange();\n const parentNode = parentElm.parentNode;\n if (parentNode) {\n range.setStartBefore(parentElm);\n range.setEndBefore(splitElm);\n const beforeFragment = range.extractContents();\n trimEdge(beforeFragment, true);\n range.setStartAfter(splitElm);\n range.setEndAfter(parentElm);\n const afterFragment = range.extractContents();\n trimEdge(afterFragment, false);\n if (!isEmpty$2(SugarElement.fromDom(beforeFragment))) {\n parentNode.insertBefore(beforeFragment, parentElm);\n }\n if (!isEmpty$2(SugarElement.fromDom(splitElm))) {\n parentNode.insertBefore(splitElm, parentElm);\n }\n if (!isEmpty$2(SugarElement.fromDom(afterFragment))) {\n parentNode.insertBefore(afterFragment, parentElm);\n }\n parentNode.removeChild(parentElm);\n }\n };\n const splitInvalidChildren = (schema, scope, transparentBlocks) => {\n const blocksElements = schema.getBlockElements();\n const rootNode = SugarElement.fromDom(scope);\n const isBlock = el => name(el) in blocksElements;\n const isRoot = el => eq(el, rootNode);\n each$e(fromDom$1(transparentBlocks), transparentBlock => {\n ancestor$4(transparentBlock, isBlock, isRoot).each(parentBlock => {\n const invalidChildren = children(transparentBlock, el => isBlock(el) && !schema.isValidChild(name(parentBlock), name(el)));\n if (invalidChildren.length > 0) {\n const stateScope = parentElement(parentBlock);\n each$e(invalidChildren, child => {\n ancestor$4(child, isBlock, isRoot).each(parentBlock => {\n split$2(parentBlock.dom, child.dom);\n });\n });\n stateScope.each(scope => updateBlockStateOnChildren(schema, scope.dom));\n }\n });\n });\n };\n const unwrapInvalidChildren = (schema, scope, transparentBlocks) => {\n each$e([\n ...transparentBlocks,\n ...isTransparentBlock(schema, scope) ? [scope] : []\n ], block => each$e(descendants(SugarElement.fromDom(block), block.nodeName.toLowerCase()), elm => {\n if (isTransparentInline(schema, elm.dom)) {\n unwrap(elm);\n }\n }));\n };\n const updateChildren = (schema, scope) => {\n const transparentBlocks = updateBlockStateOnChildren(schema, scope);\n splitInvalidChildren(schema, scope, transparentBlocks);\n unwrapInvalidChildren(schema, scope, transparentBlocks);\n };\n const updateElement = (schema, target) => {\n if (isTransparentElement(schema, target)) {\n const blocksSelector = makeSelectorFromSchemaMap(schema.getBlockElements());\n updateTransparent(blocksSelector, target);\n }\n };\n const updateCaret = (schema, root, caretParent) => {\n const isRoot = el => eq(el, SugarElement.fromDom(root));\n const parents = parents$1(SugarElement.fromDom(caretParent), isRoot);\n get$b(parents, parents.length - 2).filter(isElement$7).fold(() => updateChildren(schema, root), scope => updateChildren(schema, scope.dom));\n };\n const hasBlockAttr = el => el.hasAttribute(transparentBlockAttr);\n const isTransparentElementName = (schema, name) => has$2(schema.getTransparentElements(), name);\n const isTransparentElement = (schema, node) => isElement$6(node) && isTransparentElementName(schema, node.nodeName);\n const isTransparentBlock = (schema, node) => isTransparentElement(schema, node) && hasBlockAttr(node);\n const isTransparentInline = (schema, node) => isTransparentElement(schema, node) && !hasBlockAttr(node);\n const isTransparentAstBlock = (schema, node) => node.type === 1 && isTransparentElementName(schema, node.name) && isString(node.attr(transparentBlockAttr));\n\n const browser$2 = detect$2().browser;\n const firstElement = nodes => find$2(nodes, isElement$7);\n const getTableCaptionDeltaY = elm => {\n if (browser$2.isFirefox() && name(elm) === 'table') {\n return firstElement(children$1(elm)).filter(elm => {\n return name(elm) === 'caption';\n }).bind(caption => {\n return firstElement(nextSiblings(caption)).map(body => {\n const bodyTop = body.dom.offsetTop;\n const captionTop = caption.dom.offsetTop;\n const captionHeight = caption.dom.offsetHeight;\n return bodyTop <= captionTop ? -captionHeight : 0;\n });\n }).getOr(0);\n } else {\n return 0;\n }\n };\n const hasChild = (elm, child) => elm.children && contains$2(elm.children, child);\n const getPos = (body, elm, rootElm) => {\n let x = 0, y = 0;\n const doc = body.ownerDocument;\n rootElm = rootElm ? rootElm : body;\n if (elm) {\n if (rootElm === body && elm.getBoundingClientRect && get$7(SugarElement.fromDom(body), 'position') === 'static') {\n const pos = elm.getBoundingClientRect();\n x = pos.left + (doc.documentElement.scrollLeft || body.scrollLeft) - doc.documentElement.clientLeft;\n y = pos.top + (doc.documentElement.scrollTop || body.scrollTop) - doc.documentElement.clientTop;\n return {\n x,\n y\n };\n }\n let offsetParent = elm;\n while (offsetParent && offsetParent !== rootElm && offsetParent.nodeType && !hasChild(offsetParent, rootElm)) {\n const castOffsetParent = offsetParent;\n x += castOffsetParent.offsetLeft || 0;\n y += castOffsetParent.offsetTop || 0;\n offsetParent = castOffsetParent.offsetParent;\n }\n offsetParent = elm.parentNode;\n while (offsetParent && offsetParent !== rootElm && offsetParent.nodeType && !hasChild(offsetParent, rootElm)) {\n x -= offsetParent.scrollLeft || 0;\n y -= offsetParent.scrollTop || 0;\n offsetParent = offsetParent.parentNode;\n }\n y += getTableCaptionDeltaY(SugarElement.fromDom(elm));\n }\n return {\n x,\n y\n };\n };\n\n const StyleSheetLoader = (documentOrShadowRoot, settings = {}) => {\n let idCount = 0;\n const loadedStates = {};\n const edos = SugarElement.fromDom(documentOrShadowRoot);\n const doc = documentOrOwner(edos);\n const _setReferrerPolicy = referrerPolicy => {\n settings.referrerPolicy = referrerPolicy;\n };\n const _setContentCssCors = contentCssCors => {\n settings.contentCssCors = contentCssCors;\n };\n const addStyle = element => {\n append$1(getStyleContainer(edos), element);\n };\n const removeStyle = id => {\n const styleContainer = getStyleContainer(edos);\n descendant$1(styleContainer, '#' + id).each(remove$5);\n };\n const getOrCreateState = url => get$a(loadedStates, url).getOrThunk(() => ({\n id: 'mce-u' + idCount++,\n passed: [],\n failed: [],\n count: 0\n }));\n const load = url => new Promise((success, failure) => {\n let link;\n const urlWithSuffix = Tools._addCacheSuffix(url);\n const state = getOrCreateState(urlWithSuffix);\n loadedStates[urlWithSuffix] = state;\n state.count++;\n const resolve = (callbacks, status) => {\n each$e(callbacks, call);\n state.status = status;\n state.passed = [];\n state.failed = [];\n if (link) {\n link.onload = null;\n link.onerror = null;\n link = null;\n }\n };\n const passed = () => resolve(state.passed, 2);\n const failed = () => resolve(state.failed, 3);\n if (success) {\n state.passed.push(success);\n }\n if (failure) {\n state.failed.push(failure);\n }\n if (state.status === 1) {\n return;\n }\n if (state.status === 2) {\n passed();\n return;\n }\n if (state.status === 3) {\n failed();\n return;\n }\n state.status = 1;\n const linkElem = SugarElement.fromTag('link', doc.dom);\n setAll$1(linkElem, {\n rel: 'stylesheet',\n type: 'text/css',\n id: state.id\n });\n if (settings.contentCssCors) {\n set$3(linkElem, 'crossOrigin', 'anonymous');\n }\n if (settings.referrerPolicy) {\n set$3(linkElem, 'referrerpolicy', settings.referrerPolicy);\n }\n link = linkElem.dom;\n link.onload = passed;\n link.onerror = failed;\n addStyle(linkElem);\n set$3(linkElem, 'href', urlWithSuffix);\n });\n const loadRawCss = (key, css) => {\n const state = getOrCreateState(key);\n loadedStates[key] = state;\n state.count++;\n const styleElem = SugarElement.fromTag('style', doc.dom);\n setAll$1(styleElem, {\n rel: 'stylesheet',\n type: 'text/css',\n id: state.id\n });\n styleElem.dom.innerHTML = css;\n addStyle(styleElem);\n };\n const loadAll = urls => {\n const loadedUrls = Promise.allSettled(map$3(urls, url => load(url).then(constant(url))));\n return loadedUrls.then(results => {\n const parts = partition$2(results, r => r.status === 'fulfilled');\n if (parts.fail.length > 0) {\n return Promise.reject(map$3(parts.fail, result => result.reason));\n } else {\n return map$3(parts.pass, result => result.value);\n }\n });\n };\n const unload = url => {\n const urlWithSuffix = Tools._addCacheSuffix(url);\n get$a(loadedStates, urlWithSuffix).each(state => {\n const count = --state.count;\n if (count === 0) {\n delete loadedStates[urlWithSuffix];\n removeStyle(state.id);\n }\n });\n };\n const unloadRawCss = key => {\n get$a(loadedStates, key).each(state => {\n const count = --state.count;\n if (count === 0) {\n delete loadedStates[key];\n removeStyle(state.id);\n }\n });\n };\n const unloadAll = urls => {\n each$e(urls, url => {\n unload(url);\n });\n };\n return {\n load,\n loadRawCss,\n loadAll,\n unload,\n unloadRawCss,\n unloadAll,\n _setReferrerPolicy,\n _setContentCssCors\n };\n };\n\n const create$d = () => {\n const map = new WeakMap();\n const forElement = (referenceElement, settings) => {\n const root = getRootNode(referenceElement);\n const rootDom = root.dom;\n return Optional.from(map.get(rootDom)).getOrThunk(() => {\n const sl = StyleSheetLoader(rootDom, settings);\n map.set(rootDom, sl);\n return sl;\n });\n };\n return { forElement };\n };\n const instance = create$d();\n\n const isSpan = node => node.nodeName.toLowerCase() === 'span';\n const isInlineContent = (node, root, schema) => isNonNullable(node) && (isContent$1(node, root) || schema.isInline(node.nodeName.toLowerCase()));\n const surroundedByInlineContent = (node, root, schema) => {\n const prev = new DomTreeWalker(node, root).prev(false);\n const next = new DomTreeWalker(node, root).next(false);\n const prevIsInline = isUndefined(prev) || isInlineContent(prev, root, schema);\n const nextIsInline = isUndefined(next) || isInlineContent(next, root, schema);\n return prevIsInline && nextIsInline;\n };\n const isBookmarkNode$2 = node => isSpan(node) && node.getAttribute('data-mce-type') === 'bookmark';\n const isKeepTextNode = (node, root, schema) => isText$a(node) && node.data.length > 0 && surroundedByInlineContent(node, root, schema);\n const isKeepElement = node => isElement$6(node) ? node.childNodes.length > 0 : false;\n const isDocument = node => isDocumentFragment(node) || isDocument$1(node);\n const trimNode = (dom, node, schema, root) => {\n var _a;\n const rootNode = root || node;\n if (isElement$6(node) && isBookmarkNode$2(node)) {\n return node;\n }\n const children = node.childNodes;\n for (let i = children.length - 1; i >= 0; i--) {\n trimNode(dom, children[i], schema, rootNode);\n }\n if (isElement$6(node)) {\n const currentChildren = node.childNodes;\n if (currentChildren.length === 1 && isBookmarkNode$2(currentChildren[0])) {\n (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(currentChildren[0], node);\n }\n }\n if (!isDocument(node) && !isContent$1(node, rootNode) && !isKeepElement(node) && !isKeepTextNode(node, rootNode, schema)) {\n dom.remove(node);\n }\n return node;\n };\n\n const makeMap$3 = Tools.makeMap;\n const attrsCharsRegExp = /[&<>\\\"\\u0060\\u007E-\\uD7FF\\uE000-\\uFFEF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n const textCharsRegExp = /[<>&\\u007E-\\uD7FF\\uE000-\\uFFEF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n const rawCharsRegExp = /[<>&\\\"\\']/g;\n const entityRegExp = /&#([a-z0-9]+);?|&([a-z0-9]+);/gi;\n const asciiMap = {\n 128: '\\u20AC',\n 130: '\\u201A',\n 131: '\\u0192',\n 132: '\\u201E',\n 133: '\\u2026',\n 134: '\\u2020',\n 135: '\\u2021',\n 136: '\\u02c6',\n 137: '\\u2030',\n 138: '\\u0160',\n 139: '\\u2039',\n 140: '\\u0152',\n 142: '\\u017d',\n 145: '\\u2018',\n 146: '\\u2019',\n 147: '\\u201C',\n 148: '\\u201D',\n 149: '\\u2022',\n 150: '\\u2013',\n 151: '\\u2014',\n 152: '\\u02DC',\n 153: '\\u2122',\n 154: '\\u0161',\n 155: '\\u203A',\n 156: '\\u0153',\n 158: '\\u017e',\n 159: '\\u0178'\n };\n const baseEntities = {\n '\"': '"',\n '\\'': ''',\n '<': '<',\n '>': '>',\n '&': '&',\n '`': '`'\n };\n const reverseEntities = {\n '<': '<',\n '>': '>',\n '&': '&',\n '"': '\"',\n ''': `'`\n };\n const nativeDecode = text => {\n const elm = SugarElement.fromTag('div').dom;\n elm.innerHTML = text;\n return elm.textContent || elm.innerText || text;\n };\n const buildEntitiesLookup = (items, radix) => {\n const lookup = {};\n if (items) {\n const itemList = items.split(',');\n radix = radix || 10;\n for (let i = 0; i < itemList.length; i += 2) {\n const chr = String.fromCharCode(parseInt(itemList[i], radix));\n if (!baseEntities[chr]) {\n const entity = '&' + itemList[i + 1] + ';';\n lookup[chr] = entity;\n lookup[entity] = chr;\n }\n }\n return lookup;\n } else {\n return undefined;\n }\n };\n const namedEntities = buildEntitiesLookup('50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,' + '5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,' + '5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,' + '5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,' + '68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,' + '6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,' + '6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,' + '75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,' + '7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,' + '7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,' + 'sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,' + 'st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,' + 't9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,' + 'tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,' + 'u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,' + '81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,' + '8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,' + '8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,' + '8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,' + '8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,' + 'nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,' + 'rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,' + 'Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,' + '80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,' + '811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro', 32);\n const encodeRaw = (text, attr) => text.replace(attr ? attrsCharsRegExp : textCharsRegExp, chr => {\n return baseEntities[chr] || chr;\n });\n const encodeAllRaw = text => ('' + text).replace(rawCharsRegExp, chr => {\n return baseEntities[chr] || chr;\n });\n const encodeNumeric = (text, attr) => text.replace(attr ? attrsCharsRegExp : textCharsRegExp, chr => {\n if (chr.length > 1) {\n return '&#' + ((chr.charCodeAt(0) - 55296) * 1024 + (chr.charCodeAt(1) - 56320) + 65536) + ';';\n }\n return baseEntities[chr] || '&#' + chr.charCodeAt(0) + ';';\n });\n const encodeNamed = (text, attr, entities) => {\n const resolveEntities = entities || namedEntities;\n return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, chr => {\n return baseEntities[chr] || resolveEntities[chr] || chr;\n });\n };\n const getEncodeFunc = (name, entities) => {\n const entitiesMap = buildEntitiesLookup(entities) || namedEntities;\n const encodeNamedAndNumeric = (text, attr) => text.replace(attr ? attrsCharsRegExp : textCharsRegExp, chr => {\n if (baseEntities[chr] !== undefined) {\n return baseEntities[chr];\n }\n if (entitiesMap[chr] !== undefined) {\n return entitiesMap[chr];\n }\n if (chr.length > 1) {\n return '&#' + ((chr.charCodeAt(0) - 55296) * 1024 + (chr.charCodeAt(1) - 56320) + 65536) + ';';\n }\n return '&#' + chr.charCodeAt(0) + ';';\n });\n const encodeCustomNamed = (text, attr) => {\n return encodeNamed(text, attr, entitiesMap);\n };\n const nameMap = makeMap$3(name.replace(/\\+/g, ','));\n if (nameMap.named && nameMap.numeric) {\n return encodeNamedAndNumeric;\n }\n if (nameMap.named) {\n if (entities) {\n return encodeCustomNamed;\n }\n return encodeNamed;\n }\n if (nameMap.numeric) {\n return encodeNumeric;\n }\n return encodeRaw;\n };\n const decode = text => text.replace(entityRegExp, (all, numeric) => {\n if (numeric) {\n if (numeric.charAt(0).toLowerCase() === 'x') {\n numeric = parseInt(numeric.substr(1), 16);\n } else {\n numeric = parseInt(numeric, 10);\n }\n if (numeric > 65535) {\n numeric -= 65536;\n return String.fromCharCode(55296 + (numeric >> 10), 56320 + (numeric & 1023));\n }\n return asciiMap[numeric] || String.fromCharCode(numeric);\n }\n return reverseEntities[all] || namedEntities[all] || nativeDecode(all);\n });\n const Entities = {\n encodeRaw,\n encodeAllRaw,\n encodeNumeric,\n encodeNamed,\n getEncodeFunc,\n decode\n };\n\n const split$1 = (items, delim) => {\n items = Tools.trim(items);\n return items ? items.split(delim || ' ') : [];\n };\n const patternToRegExp = str => new RegExp('^' + str.replace(/([?+*])/g, '.$1') + '$');\n\n const parseCustomElementsRules = value => {\n const customElementRegExp = /^(~)?(.+)$/;\n return bind$3(split$1(value, ','), rule => {\n const matches = customElementRegExp.exec(rule);\n if (matches) {\n const inline = matches[1] === '~';\n const cloneName = inline ? 'span' : 'div';\n const name = matches[2];\n return [{\n inline,\n cloneName,\n name\n }];\n } else {\n return [];\n }\n });\n };\n\n const getElementSetsAsStrings = type => {\n let globalAttributes, blockContent;\n let phrasingContent;\n globalAttributes = 'id accesskey class dir lang style tabindex title role';\n blockContent = 'address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul';\n phrasingContent = 'a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd ' + 'label map noscript object q s samp script select small span strong sub sup ' + 'textarea u var #text #comment';\n if (type !== 'html4') {\n const transparentContent = 'a ins del canvas map';\n globalAttributes += ' contenteditable contextmenu draggable dropzone ' + 'hidden spellcheck translate';\n blockContent += ' article aside details dialog figure main header footer hgroup section nav ' + transparentContent;\n phrasingContent += ' audio canvas command datalist mark meter output picture ' + 'progress time wbr video ruby bdi keygen svg';\n }\n if (type !== 'html5-strict') {\n globalAttributes += ' xml:lang';\n const html4PhrasingContent = 'acronym applet basefont big font strike tt';\n phrasingContent = [\n phrasingContent,\n html4PhrasingContent\n ].join(' ');\n const html4BlockContent = 'center dir isindex noframes';\n blockContent = [\n blockContent,\n html4BlockContent\n ].join(' ');\n }\n const flowContent = [\n blockContent,\n phrasingContent\n ].join(' ');\n return {\n globalAttributes,\n blockContent,\n phrasingContent,\n flowContent\n };\n };\n\n const makeSchema = type => {\n const {globalAttributes, phrasingContent, flowContent} = getElementSetsAsStrings(type);\n const schema = {};\n const addElement = (name, attributes, children) => {\n schema[name] = {\n attributes: mapToObject(attributes, constant({})),\n attributesOrder: attributes,\n children: mapToObject(children, constant({}))\n };\n };\n const add = (name, attributes = '', children = '') => {\n const childNames = split$1(children);\n const names = split$1(name);\n let ni = names.length;\n const allAttributes = split$1([\n globalAttributes,\n attributes\n ].join(' '));\n while (ni--) {\n addElement(names[ni], allAttributes.slice(), childNames);\n }\n };\n const addAttrs = (name, attributes) => {\n const names = split$1(name);\n const attrs = split$1(attributes);\n let ni = names.length;\n while (ni--) {\n const schemaItem = schema[names[ni]];\n for (let i = 0, l = attrs.length; i < l; i++) {\n schemaItem.attributes[attrs[i]] = {};\n schemaItem.attributesOrder.push(attrs[i]);\n }\n }\n };\n if (type !== 'html5-strict') {\n const html4PhrasingContent = 'acronym applet basefont big font strike tt';\n each$e(split$1(html4PhrasingContent), name => {\n add(name, '', phrasingContent);\n });\n const html4BlockContent = 'center dir isindex noframes';\n each$e(split$1(html4BlockContent), name => {\n add(name, '', flowContent);\n });\n }\n add('html', 'manifest', 'head body');\n add('head', '', 'base command link meta noscript script style title');\n add('title hr noscript br');\n add('base', 'href target');\n add('link', 'href rel media hreflang type sizes hreflang');\n add('meta', 'name http-equiv content charset');\n add('style', 'media type scoped');\n add('script', 'src async defer type charset');\n add('body', 'onafterprint onbeforeprint onbeforeunload onblur onerror onfocus ' + 'onhashchange onload onmessage onoffline ononline onpagehide onpageshow ' + 'onpopstate onresize onscroll onstorage onunload', flowContent);\n add('dd div', '', flowContent);\n add('address dt caption', '', type === 'html4' ? phrasingContent : flowContent);\n add('h1 h2 h3 h4 h5 h6 pre p abbr code var samp kbd sub sup i b u bdo span legend em strong small s cite dfn', '', phrasingContent);\n add('blockquote', 'cite', flowContent);\n add('ol', 'reversed start type', 'li');\n add('ul', '', 'li');\n add('li', 'value', flowContent);\n add('dl', '', 'dt dd');\n add('a', 'href target rel media hreflang type', type === 'html4' ? phrasingContent : flowContent);\n add('q', 'cite', phrasingContent);\n add('ins del', 'cite datetime', flowContent);\n add('img', 'src sizes srcset alt usemap ismap width height');\n add('iframe', 'src name width height', flowContent);\n add('embed', 'src type width height');\n add('object', 'data type typemustmatch name usemap form width height', [\n flowContent,\n 'param'\n ].join(' '));\n add('param', 'name value');\n add('map', 'name', [\n flowContent,\n 'area'\n ].join(' '));\n add('area', 'alt coords shape href target rel media hreflang type');\n add('table', 'border', 'caption colgroup thead tfoot tbody tr' + (type === 'html4' ? ' col' : ''));\n add('colgroup', 'span', 'col');\n add('col', 'span');\n add('tbody thead tfoot', '', 'tr');\n add('tr', '', 'td th');\n add('td', 'colspan rowspan headers', flowContent);\n add('th', 'colspan rowspan headers scope abbr', flowContent);\n add('form', 'accept-charset action autocomplete enctype method name novalidate target', flowContent);\n add('fieldset', 'disabled form name', [\n flowContent,\n 'legend'\n ].join(' '));\n add('label', 'form for', phrasingContent);\n add('input', 'accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate ' + 'formtarget height list max maxlength min multiple name pattern readonly required size src step type value width');\n add('button', 'disabled form formaction formenctype formmethod formnovalidate formtarget name type value', type === 'html4' ? flowContent : phrasingContent);\n add('select', 'disabled form multiple name required size', 'option optgroup');\n add('optgroup', 'disabled label', 'option');\n add('option', 'disabled label selected value');\n add('textarea', 'cols dirname disabled form maxlength name readonly required rows wrap');\n add('menu', 'type label', [\n flowContent,\n 'li'\n ].join(' '));\n add('noscript', '', flowContent);\n if (type !== 'html4') {\n add('wbr');\n add('ruby', '', [\n phrasingContent,\n 'rt rp'\n ].join(' '));\n add('figcaption', '', flowContent);\n add('mark rt rp bdi', '', phrasingContent);\n add('summary', '', [\n phrasingContent,\n 'h1 h2 h3 h4 h5 h6'\n ].join(' '));\n add('canvas', 'width height', flowContent);\n add('video', 'src crossorigin poster preload autoplay mediagroup loop ' + 'muted controls width height buffered', [\n flowContent,\n 'track source'\n ].join(' '));\n add('audio', 'src crossorigin preload autoplay mediagroup loop muted controls ' + 'buffered volume', [\n flowContent,\n 'track source'\n ].join(' '));\n add('picture', '', 'img source');\n add('source', 'src srcset type media sizes');\n add('track', 'kind src srclang label default');\n add('datalist', '', [\n phrasingContent,\n 'option'\n ].join(' '));\n add('article section nav aside main header footer', '', flowContent);\n add('hgroup', '', 'h1 h2 h3 h4 h5 h6');\n add('figure', '', [\n flowContent,\n 'figcaption'\n ].join(' '));\n add('time', 'datetime', phrasingContent);\n add('dialog', 'open', flowContent);\n add('command', 'type label icon disabled checked radiogroup command');\n add('output', 'for form name', phrasingContent);\n add('progress', 'value max', phrasingContent);\n add('meter', 'value min max low high optimum', phrasingContent);\n add('details', 'open', [\n flowContent,\n 'summary'\n ].join(' '));\n add('keygen', 'autofocus challenge disabled form keytype name');\n addElement('svg', 'id tabindex lang xml:space class style x y width height viewBox preserveAspectRatio zoomAndPan transform'.split(' '), []);\n }\n if (type !== 'html5-strict') {\n addAttrs('script', 'language xml:space');\n addAttrs('style', 'xml:space');\n addAttrs('object', 'declare classid code codebase codetype archive standby align border hspace vspace');\n addAttrs('embed', 'align name hspace vspace');\n addAttrs('param', 'valuetype type');\n addAttrs('a', 'charset name rev shape coords');\n addAttrs('br', 'clear');\n addAttrs('applet', 'codebase archive code object alt name width height align hspace vspace');\n addAttrs('img', 'name longdesc align border hspace vspace');\n addAttrs('iframe', 'longdesc frameborder marginwidth marginheight scrolling align');\n addAttrs('font basefont', 'size color face');\n addAttrs('input', 'usemap align');\n addAttrs('select');\n addAttrs('textarea');\n addAttrs('h1 h2 h3 h4 h5 h6 div p legend caption', 'align');\n addAttrs('ul', 'type compact');\n addAttrs('li', 'type');\n addAttrs('ol dl menu dir', 'compact');\n addAttrs('pre', 'width xml:space');\n addAttrs('hr', 'align noshade size width');\n addAttrs('isindex', 'prompt');\n addAttrs('table', 'summary width frame rules cellspacing cellpadding align bgcolor');\n addAttrs('col', 'width align char charoff valign');\n addAttrs('colgroup', 'width align char charoff valign');\n addAttrs('thead', 'align char charoff valign');\n addAttrs('tr', 'align char charoff valign bgcolor');\n addAttrs('th', 'axis align char charoff valign nowrap bgcolor width height');\n addAttrs('form', 'accept');\n addAttrs('td', 'abbr axis scope align char charoff valign nowrap bgcolor width height');\n addAttrs('tfoot', 'align char charoff valign');\n addAttrs('tbody', 'align char charoff valign');\n addAttrs('area', 'nohref');\n addAttrs('body', 'background bgcolor text link vlink alink');\n }\n if (type !== 'html4') {\n addAttrs('input button select textarea', 'autofocus');\n addAttrs('input textarea', 'placeholder');\n addAttrs('a', 'download');\n addAttrs('link script img', 'crossorigin');\n addAttrs('img', 'loading');\n addAttrs('iframe', 'sandbox seamless allow allowfullscreen loading');\n }\n if (type !== 'html4') {\n each$e([\n schema.video,\n schema.audio\n ], item => {\n delete item.children.audio;\n delete item.children.video;\n });\n }\n each$e(split$1('a form meter progress dfn'), name => {\n if (schema[name]) {\n delete schema[name].children[name];\n }\n });\n delete schema.caption.children.table;\n delete schema.script;\n return schema;\n };\n\n const prefixToOperation = prefix => prefix === '-' ? 'remove' : 'add';\n const parseValidChildrenRules = value => {\n const childRuleRegExp = /^([+\\-]?)([A-Za-z0-9_\\-.\\u00b7\\u00c0-\\u00d6\\u00d8-\\u00f6\\u00f8-\\u037d\\u037f-\\u1fff\\u200c-\\u200d\\u203f-\\u2040\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\ufffd]+)\\[([^\\]]+)]$/;\n return bind$3(split$1(value, ','), rule => {\n const matches = childRuleRegExp.exec(rule);\n if (matches) {\n const prefix = matches[1];\n const operation = prefix ? prefixToOperation(prefix) : 'replace';\n const name = matches[2];\n const validChildren = split$1(matches[3], '|');\n return [{\n operation,\n name,\n validChildren\n }];\n } else {\n return [];\n }\n });\n };\n\n const parseValidElementsAttrDataIntoElement = (attrData, targetElement) => {\n const attrRuleRegExp = /^([!\\-])?(\\w+[\\\\:]:\\w+|[^=~<]+)?(?:([=~<])(.*))?$/;\n const hasPatternsRegExp = /[*?+]/;\n const {attributes, attributesOrder} = targetElement;\n return each$e(split$1(attrData, '|'), rule => {\n const matches = attrRuleRegExp.exec(rule);\n if (matches) {\n const attr = {};\n const attrType = matches[1];\n const attrName = matches[2].replace(/[\\\\:]:/g, ':');\n const attrPrefix = matches[3];\n const value = matches[4];\n if (attrType === '!') {\n targetElement.attributesRequired = targetElement.attributesRequired || [];\n targetElement.attributesRequired.push(attrName);\n attr.required = true;\n }\n if (attrType === '-') {\n delete attributes[attrName];\n attributesOrder.splice(Tools.inArray(attributesOrder, attrName), 1);\n return;\n }\n if (attrPrefix) {\n if (attrPrefix === '=') {\n targetElement.attributesDefault = targetElement.attributesDefault || [];\n targetElement.attributesDefault.push({\n name: attrName,\n value\n });\n attr.defaultValue = value;\n } else if (attrPrefix === '~') {\n targetElement.attributesForced = targetElement.attributesForced || [];\n targetElement.attributesForced.push({\n name: attrName,\n value\n });\n attr.forcedValue = value;\n } else if (attrPrefix === '<') {\n attr.validValues = Tools.makeMap(value, '?');\n }\n }\n if (hasPatternsRegExp.test(attrName)) {\n const attrPattern = attr;\n targetElement.attributePatterns = targetElement.attributePatterns || [];\n attrPattern.pattern = patternToRegExp(attrName);\n targetElement.attributePatterns.push(attrPattern);\n } else {\n if (!attributes[attrName]) {\n attributesOrder.push(attrName);\n }\n attributes[attrName] = attr;\n }\n }\n });\n };\n const cloneAttributesInto = (from, to) => {\n each$d(from.attributes, (value, key) => {\n to.attributes[key] = value;\n });\n to.attributesOrder.push(...from.attributesOrder);\n };\n const parseValidElementsRules = (globalElement, validElements) => {\n const elementRuleRegExp = /^([#+\\-])?([^\\[!\\/]+)(?:\\/([^\\[!]+))?(?:(!?)\\[([^\\]]+)])?$/;\n return bind$3(split$1(validElements, ','), rule => {\n const matches = elementRuleRegExp.exec(rule);\n if (matches) {\n const prefix = matches[1];\n const elementName = matches[2];\n const outputName = matches[3];\n const attrsPrefix = matches[4];\n const attrData = matches[5];\n const element = {\n attributes: {},\n attributesOrder: []\n };\n globalElement.each(el => cloneAttributesInto(el, element));\n if (prefix === '#') {\n element.paddEmpty = true;\n } else if (prefix === '-') {\n element.removeEmpty = true;\n }\n if (attrsPrefix === '!') {\n element.removeEmptyAttrs = true;\n }\n if (attrData) {\n parseValidElementsAttrDataIntoElement(attrData, element);\n }\n if (outputName) {\n element.outputName = elementName;\n }\n if (elementName === '@') {\n if (globalElement.isNone()) {\n globalElement = Optional.some(element);\n } else {\n return [];\n }\n }\n return [outputName ? {\n name: elementName,\n element,\n aliasName: outputName\n } : {\n name: elementName,\n element\n }];\n } else {\n return [];\n }\n });\n };\n\n const mapCache = {};\n const makeMap$2 = Tools.makeMap, each$b = Tools.each, extend$2 = Tools.extend, explode$2 = Tools.explode;\n const createMap = (defaultValue, extendWith = {}) => {\n const value = makeMap$2(defaultValue, ' ', makeMap$2(defaultValue.toUpperCase(), ' '));\n return extend$2(value, extendWith);\n };\n const getTextRootBlockElements = schema => createMap('td th li dt dd figcaption caption details summary', schema.getTextBlockElements());\n const compileElementMap = (value, mode) => {\n if (value) {\n const styles = {};\n if (isString(value)) {\n value = { '*': value };\n }\n each$b(value, (value, key) => {\n styles[key] = styles[key.toUpperCase()] = mode === 'map' ? makeMap$2(value, /[, ]/) : explode$2(value, /[, ]/);\n });\n return styles;\n } else {\n return undefined;\n }\n };\n const Schema = (settings = {}) => {\n var _a;\n const elements = {};\n const children = {};\n let patternElements = [];\n const customElementsMap = {};\n const specialElements = {};\n const createLookupTable = (option, defaultValue, extendWith) => {\n const value = settings[option];\n if (!value) {\n let newValue = mapCache[option];\n if (!newValue) {\n newValue = createMap(defaultValue, extendWith);\n mapCache[option] = newValue;\n }\n return newValue;\n } else {\n return makeMap$2(value, /[, ]/, makeMap$2(value.toUpperCase(), /[, ]/));\n }\n };\n const schemaType = (_a = settings.schema) !== null && _a !== void 0 ? _a : 'html5';\n const schemaItems = makeSchema(schemaType);\n if (settings.verify_html === false) {\n settings.valid_elements = '*[*]';\n }\n const validStyles = compileElementMap(settings.valid_styles);\n const invalidStyles = compileElementMap(settings.invalid_styles, 'map');\n const validClasses = compileElementMap(settings.valid_classes, 'map');\n const whitespaceElementsMap = createLookupTable('whitespace_elements', 'pre script noscript style textarea video audio iframe object code');\n const selfClosingElementsMap = createLookupTable('self_closing_elements', 'colgroup dd dt li option p td tfoot th thead tr');\n const voidElementsMap = createLookupTable('void_elements', 'area base basefont br col frame hr img input isindex link ' + 'meta param embed source wbr track');\n const boolAttrMap = createLookupTable('boolean_attributes', 'checked compact declare defer disabled ismap multiple nohref noresize ' + 'noshade nowrap readonly selected autoplay loop controls allowfullscreen');\n const nonEmptyOrMoveCaretBeforeOnEnter = 'td th iframe video audio object script code';\n const nonEmptyElementsMap = createLookupTable('non_empty_elements', nonEmptyOrMoveCaretBeforeOnEnter + ' pre svg', voidElementsMap);\n const moveCaretBeforeOnEnterElementsMap = createLookupTable('move_caret_before_on_enter_elements', nonEmptyOrMoveCaretBeforeOnEnter + ' table', voidElementsMap);\n const headings = 'h1 h2 h3 h4 h5 h6';\n const textBlockElementsMap = createLookupTable('text_block_elements', headings + ' p div address pre form ' + 'blockquote center dir fieldset header footer article section hgroup aside main nav figure');\n const blockElementsMap = createLookupTable('block_elements', 'hr table tbody thead tfoot ' + 'th tr td li ol ul caption dl dt dd noscript menu isindex option ' + 'datalist select optgroup figcaption details summary html body multicol listing', textBlockElementsMap);\n const textInlineElementsMap = createLookupTable('text_inline_elements', 'span strong b em i font s strike u var cite ' + 'dfn code mark q sup sub samp');\n const transparentElementsMap = createLookupTable('transparent_elements', 'a ins del canvas map');\n const wrapBlockElementsMap = createLookupTable('wrap_block_elements', 'pre ' + headings);\n each$b('script noscript iframe noframes noembed title style textarea xmp plaintext'.split(' '), name => {\n specialElements[name] = new RegExp(']*>', 'gi');\n });\n const addValidElements = validElements => {\n const globalElement = Optional.from(elements['@']);\n const hasPatternsRegExp = /[*?+]/;\n each$e(parseValidElementsRules(globalElement, validElements !== null && validElements !== void 0 ? validElements : ''), ({name, element, aliasName}) => {\n if (aliasName) {\n elements[aliasName] = element;\n }\n if (hasPatternsRegExp.test(name)) {\n const patternElement = element;\n patternElement.pattern = patternToRegExp(name);\n patternElements.push(patternElement);\n } else {\n elements[name] = element;\n }\n });\n };\n const setValidElements = validElements => {\n patternElements = [];\n each$e(keys(elements), name => {\n delete elements[name];\n });\n addValidElements(validElements);\n };\n const addCustomElements = customElements => {\n delete mapCache.text_block_elements;\n delete mapCache.block_elements;\n each$e(parseCustomElementsRules(customElements !== null && customElements !== void 0 ? customElements : ''), ({inline, name, cloneName}) => {\n children[name] = children[cloneName];\n customElementsMap[name] = cloneName;\n nonEmptyElementsMap[name.toUpperCase()] = {};\n nonEmptyElementsMap[name] = {};\n if (!inline) {\n blockElementsMap[name.toUpperCase()] = {};\n blockElementsMap[name] = {};\n }\n if (!elements[name]) {\n let customRule = elements[cloneName];\n customRule = extend$2({}, customRule);\n delete customRule.removeEmptyAttrs;\n delete customRule.removeEmpty;\n elements[name] = customRule;\n }\n each$d(children, (element, elmName) => {\n if (element[cloneName]) {\n children[elmName] = element = extend$2({}, children[elmName]);\n element[name] = element[cloneName];\n }\n });\n });\n };\n const addValidChildren = validChildren => {\n each$e(parseValidChildrenRules(validChildren !== null && validChildren !== void 0 ? validChildren : ''), ({operation, name, validChildren}) => {\n const parent = operation === 'replace' ? { '#comment': {} } : children[name];\n each$e(validChildren, child => {\n if (operation === 'remove') {\n delete parent[child];\n } else {\n parent[child] = {};\n }\n });\n children[name] = parent;\n });\n };\n const getElementRule = name => {\n const element = elements[name];\n if (element) {\n return element;\n }\n let i = patternElements.length;\n while (i--) {\n const patternElement = patternElements[i];\n if (patternElement.pattern.test(name)) {\n return patternElement;\n }\n }\n return undefined;\n };\n if (!settings.valid_elements) {\n each$b(schemaItems, (element, name) => {\n elements[name] = {\n attributes: element.attributes,\n attributesOrder: element.attributesOrder\n };\n children[name] = element.children;\n });\n each$b(split$1('strong/b em/i'), item => {\n const items = split$1(item, '/');\n elements[items[1]].outputName = items[0];\n });\n each$b(textInlineElementsMap, (_val, name) => {\n if (elements[name]) {\n if (settings.padd_empty_block_inline_children) {\n elements[name].paddInEmptyBlock = true;\n }\n elements[name].removeEmpty = true;\n }\n });\n each$b(split$1('ol ul blockquote a table tbody'), name => {\n if (elements[name]) {\n elements[name].removeEmpty = true;\n }\n });\n each$b(split$1('p h1 h2 h3 h4 h5 h6 th td pre div address caption li summary'), name => {\n if (elements[name]) {\n elements[name].paddEmpty = true;\n }\n });\n each$b(split$1('span'), name => {\n elements[name].removeEmptyAttrs = true;\n });\n } else {\n setValidElements(settings.valid_elements);\n each$b(schemaItems, (element, name) => {\n children[name] = element.children;\n });\n }\n delete elements.svg;\n addCustomElements(settings.custom_elements);\n addValidChildren(settings.valid_children);\n addValidElements(settings.extended_valid_elements);\n addValidChildren('+ol[ul|ol],+ul[ul|ol]');\n each$b({\n dd: 'dl',\n dt: 'dl',\n li: 'ul ol',\n td: 'tr',\n th: 'tr',\n tr: 'tbody thead tfoot',\n tbody: 'table',\n thead: 'table',\n tfoot: 'table',\n legend: 'fieldset',\n area: 'map',\n param: 'video audio object'\n }, (parents, item) => {\n if (elements[item]) {\n elements[item].parentsRequired = split$1(parents);\n }\n });\n if (settings.invalid_elements) {\n each$b(explode$2(settings.invalid_elements), item => {\n if (elements[item]) {\n delete elements[item];\n }\n });\n }\n if (!getElementRule('span')) {\n addValidElements('span[!data-mce-type|*]');\n }\n const getValidStyles = constant(validStyles);\n const getInvalidStyles = constant(invalidStyles);\n const getValidClasses = constant(validClasses);\n const getBoolAttrs = constant(boolAttrMap);\n const getBlockElements = constant(blockElementsMap);\n const getTextBlockElements = constant(textBlockElementsMap);\n const getTextInlineElements = constant(textInlineElementsMap);\n const getVoidElements = constant(Object.seal(voidElementsMap));\n const getSelfClosingElements = constant(selfClosingElementsMap);\n const getNonEmptyElements = constant(nonEmptyElementsMap);\n const getMoveCaretBeforeOnEnterElements = constant(moveCaretBeforeOnEnterElementsMap);\n const getWhitespaceElements = constant(whitespaceElementsMap);\n const getTransparentElements = constant(transparentElementsMap);\n const getWrapBlockElements = constant(wrapBlockElementsMap);\n const getSpecialElements = constant(Object.seal(specialElements));\n const isValidChild = (name, child) => {\n const parent = children[name.toLowerCase()];\n return !!(parent && parent[child.toLowerCase()]);\n };\n const isValid = (name, attr) => {\n const rule = getElementRule(name);\n if (rule) {\n if (attr) {\n if (rule.attributes[attr]) {\n return true;\n }\n const attrPatterns = rule.attributePatterns;\n if (attrPatterns) {\n let i = attrPatterns.length;\n while (i--) {\n if (attrPatterns[i].pattern.test(attr)) {\n return true;\n }\n }\n }\n } else {\n return true;\n }\n }\n return false;\n };\n const isBlock = name => has$2(getBlockElements(), name);\n const isInline = name => !startsWith(name, '#') && isValid(name) && !isBlock(name);\n const isWrapper = name => has$2(getWrapBlockElements(), name) || isInline(name);\n const getCustomElements = constant(customElementsMap);\n return {\n type: schemaType,\n children,\n elements,\n getValidStyles,\n getValidClasses,\n getBlockElements,\n getInvalidStyles,\n getVoidElements,\n getTextBlockElements,\n getTextInlineElements,\n getBoolAttrs,\n getElementRule,\n getSelfClosingElements,\n getNonEmptyElements,\n getMoveCaretBeforeOnEnterElements,\n getWhitespaceElements,\n getTransparentElements,\n getSpecialElements,\n isValidChild,\n isValid,\n isBlock,\n isInline,\n isWrapper,\n getCustomElements,\n addValidElements,\n setValidElements,\n addCustomElements,\n addValidChildren\n };\n };\n\n const hexColour = value => ({ value: normalizeHex(value) });\n const normalizeHex = hex => removeLeading(hex, '#').toUpperCase();\n const toHex = component => {\n const hex = component.toString(16);\n return (hex.length === 1 ? '0' + hex : hex).toUpperCase();\n };\n const fromRgba = rgbaColour => {\n const value = toHex(rgbaColour.red) + toHex(rgbaColour.green) + toHex(rgbaColour.blue);\n return hexColour(value);\n };\n\n const rgbRegex = /^\\s*rgb\\s*\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)\\s*$/i;\n const rgbaRegex = /^\\s*rgba\\s*\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d?(?:\\.\\d+)?)\\s*\\)\\s*$/i;\n const rgbaColour = (red, green, blue, alpha) => ({\n red,\n green,\n blue,\n alpha\n });\n const fromStringValues = (red, green, blue, alpha) => {\n const r = parseInt(red, 10);\n const g = parseInt(green, 10);\n const b = parseInt(blue, 10);\n const a = parseFloat(alpha);\n return rgbaColour(r, g, b, a);\n };\n const fromString = rgbaString => {\n if (rgbaString === 'transparent') {\n return Optional.some(rgbaColour(0, 0, 0, 0));\n }\n const rgbMatch = rgbRegex.exec(rgbaString);\n if (rgbMatch !== null) {\n return Optional.some(fromStringValues(rgbMatch[1], rgbMatch[2], rgbMatch[3], '1'));\n }\n const rgbaMatch = rgbaRegex.exec(rgbaString);\n if (rgbaMatch !== null) {\n return Optional.some(fromStringValues(rgbaMatch[1], rgbaMatch[2], rgbaMatch[3], rgbaMatch[4]));\n }\n return Optional.none();\n };\n const toString = rgba => `rgba(${ rgba.red },${ rgba.green },${ rgba.blue },${ rgba.alpha })`;\n\n const rgbaToHexString = color => fromString(color).map(fromRgba).map(h => '#' + h.value).getOr(color);\n\n const Styles = (settings = {}, schema) => {\n const urlOrStrRegExp = /(?:url(?:(?:\\(\\s*\\\"([^\\\"]+)\\\"\\s*\\))|(?:\\(\\s*\\'([^\\']+)\\'\\s*\\))|(?:\\(\\s*([^)\\s]+)\\s*\\))))|(?:\\'([^\\']+)\\')|(?:\\\"([^\\\"]+)\\\")/gi;\n const styleRegExp = /\\s*([^:]+):\\s*([^;]+);?/g;\n const trimRightRegExp = /\\s+$/;\n const encodingLookup = {};\n let validStyles;\n let invalidStyles;\n const invisibleChar = zeroWidth;\n if (schema) {\n validStyles = schema.getValidStyles();\n invalidStyles = schema.getInvalidStyles();\n }\n const encodingItems = (`\\\\\" \\\\' \\\\; \\\\: ; : ` + invisibleChar).split(' ');\n for (let i = 0; i < encodingItems.length; i++) {\n encodingLookup[encodingItems[i]] = invisibleChar + i;\n encodingLookup[invisibleChar + i] = encodingItems[i];\n }\n const self = {\n parse: css => {\n const styles = {};\n let isEncoded = false;\n const urlConverter = settings.url_converter;\n const urlConverterScope = settings.url_converter_scope || self;\n const compress = (prefix, suffix, noJoin) => {\n const top = styles[prefix + '-top' + suffix];\n if (!top) {\n return;\n }\n const right = styles[prefix + '-right' + suffix];\n if (!right) {\n return;\n }\n const bottom = styles[prefix + '-bottom' + suffix];\n if (!bottom) {\n return;\n }\n const left = styles[prefix + '-left' + suffix];\n if (!left) {\n return;\n }\n const box = [\n top,\n right,\n bottom,\n left\n ];\n let i = box.length - 1;\n while (i--) {\n if (box[i] !== box[i + 1]) {\n break;\n }\n }\n if (i > -1 && noJoin) {\n return;\n }\n styles[prefix + suffix] = i === -1 ? box[0] : box.join(' ');\n delete styles[prefix + '-top' + suffix];\n delete styles[prefix + '-right' + suffix];\n delete styles[prefix + '-bottom' + suffix];\n delete styles[prefix + '-left' + suffix];\n };\n const canCompress = key => {\n const value = styles[key];\n if (!value) {\n return;\n }\n const values = value.indexOf(',') > -1 ? [value] : value.split(' ');\n let i = values.length;\n while (i--) {\n if (values[i] !== values[0]) {\n return false;\n }\n }\n styles[key] = values[0];\n return true;\n };\n const compress2 = (target, a, b, c) => {\n if (!canCompress(a)) {\n return;\n }\n if (!canCompress(b)) {\n return;\n }\n if (!canCompress(c)) {\n return;\n }\n styles[target] = styles[a] + ' ' + styles[b] + ' ' + styles[c];\n delete styles[a];\n delete styles[b];\n delete styles[c];\n };\n const encode = str => {\n isEncoded = true;\n return encodingLookup[str];\n };\n const decode = (str, keepSlashes) => {\n if (isEncoded) {\n str = str.replace(/\\uFEFF[0-9]/g, str => {\n return encodingLookup[str];\n });\n }\n if (!keepSlashes) {\n str = str.replace(/\\\\([\\'\\\";:])/g, '$1');\n }\n return str;\n };\n const decodeSingleHexSequence = escSeq => {\n return String.fromCharCode(parseInt(escSeq.slice(1), 16));\n };\n const decodeHexSequences = value => {\n return value.replace(/\\\\[0-9a-f]+/gi, decodeSingleHexSequence);\n };\n const processUrl = (match, url, url2, url3, str, str2) => {\n str = str || str2;\n if (str) {\n str = decode(str);\n return `'` + str.replace(/\\'/g, `\\\\'`) + `'`;\n }\n url = decode(url || url2 || url3 || '');\n if (!settings.allow_script_urls) {\n const scriptUrl = url.replace(/[\\s\\r\\n]+/g, '');\n if (/(java|vb)script:/i.test(scriptUrl)) {\n return '';\n }\n if (!settings.allow_svg_data_urls && /^data:image\\/svg/i.test(scriptUrl)) {\n return '';\n }\n }\n if (urlConverter) {\n url = urlConverter.call(urlConverterScope, url, 'style');\n }\n return `url('` + url.replace(/\\'/g, `\\\\'`) + `')`;\n };\n if (css) {\n css = css.replace(/[\\u0000-\\u001F]/g, '');\n css = css.replace(/\\\\[\\\"\\';:\\uFEFF]/g, encode).replace(/\\\"[^\\\"]+\\\"|\\'[^\\']+\\'/g, str => {\n return str.replace(/[;:]/g, encode);\n });\n let matches;\n while (matches = styleRegExp.exec(css)) {\n styleRegExp.lastIndex = matches.index + matches[0].length;\n let name = matches[1].replace(trimRightRegExp, '').toLowerCase();\n let value = matches[2].replace(trimRightRegExp, '');\n if (name && value) {\n name = decodeHexSequences(name);\n value = decodeHexSequences(value);\n if (name.indexOf(invisibleChar) !== -1 || name.indexOf('\"') !== -1) {\n continue;\n }\n if (!settings.allow_script_urls && (name === 'behavior' || /expression\\s*\\(|\\/\\*|\\*\\//.test(value))) {\n continue;\n }\n if (name === 'font-weight' && value === '700') {\n value = 'bold';\n } else if (name === 'color' || name === 'background-color') {\n value = value.toLowerCase();\n }\n if (isString(settings.force_hex_color) && settings.force_hex_color !== 'off') {\n fromString(value).each(rgba => {\n if (settings.force_hex_color === 'always' || rgba.alpha === 1) {\n value = rgbaToHexString(toString(rgba));\n }\n });\n }\n value = value.replace(urlOrStrRegExp, processUrl);\n styles[name] = isEncoded ? decode(value, true) : value;\n }\n }\n compress('border', '', true);\n compress('border', '-width');\n compress('border', '-color');\n compress('border', '-style');\n compress('padding', '');\n compress('margin', '');\n compress2('border', 'border-width', 'border-style', 'border-color');\n if (styles.border === 'medium none') {\n delete styles.border;\n }\n if (styles['border-image'] === 'none') {\n delete styles['border-image'];\n }\n }\n return styles;\n },\n serialize: (styles, elementName) => {\n let css = '';\n const serializeStyles = (elemName, validStyleList) => {\n const styleList = validStyleList[elemName];\n if (styleList) {\n for (let i = 0, l = styleList.length; i < l; i++) {\n const name = styleList[i];\n const value = styles[name];\n if (value) {\n css += (css.length > 0 ? ' ' : '') + name + ': ' + value + ';';\n }\n }\n }\n };\n const isValid = (name, elemName) => {\n if (!invalidStyles || !elemName) {\n return true;\n }\n let styleMap = invalidStyles['*'];\n if (styleMap && styleMap[name]) {\n return false;\n }\n styleMap = invalidStyles[elemName];\n return !(styleMap && styleMap[name]);\n };\n if (elementName && validStyles) {\n serializeStyles('*', validStyles);\n serializeStyles(elementName, validStyles);\n } else {\n each$d(styles, (value, name) => {\n if (value && isValid(name, elementName)) {\n css += (css.length > 0 ? ' ' : '') + name + ': ' + value + ';';\n }\n });\n }\n return css;\n }\n };\n return self;\n };\n\n const deprecated = {\n keyLocation: true,\n layerX: true,\n layerY: true,\n returnValue: true,\n webkitMovementX: true,\n webkitMovementY: true,\n keyIdentifier: true,\n mozPressure: true\n };\n const isNativeEvent = event => event instanceof Event || isFunction(event.initEvent);\n const hasIsDefaultPrevented = event => event.isDefaultPrevented === always || event.isDefaultPrevented === never;\n const needsNormalizing = event => isNullable(event.preventDefault) || isNativeEvent(event);\n const clone$3 = (originalEvent, data) => {\n const event = data !== null && data !== void 0 ? data : {};\n for (const name in originalEvent) {\n if (!has$2(deprecated, name)) {\n event[name] = originalEvent[name];\n }\n }\n if (isNonNullable(originalEvent.composedPath)) {\n event.composedPath = () => originalEvent.composedPath();\n }\n if (isNonNullable(originalEvent.getModifierState)) {\n event.getModifierState = keyArg => originalEvent.getModifierState(keyArg);\n }\n if (isNonNullable(originalEvent.getTargetRanges)) {\n event.getTargetRanges = () => originalEvent.getTargetRanges();\n }\n return event;\n };\n const normalize$3 = (type, originalEvent, fallbackTarget, data) => {\n var _a;\n const event = clone$3(originalEvent, data);\n event.type = type;\n if (isNullable(event.target)) {\n event.target = (_a = event.srcElement) !== null && _a !== void 0 ? _a : fallbackTarget;\n }\n if (needsNormalizing(originalEvent)) {\n event.preventDefault = () => {\n event.defaultPrevented = true;\n event.isDefaultPrevented = always;\n if (isFunction(originalEvent.preventDefault)) {\n originalEvent.preventDefault();\n }\n };\n event.stopPropagation = () => {\n event.cancelBubble = true;\n event.isPropagationStopped = always;\n if (isFunction(originalEvent.stopPropagation)) {\n originalEvent.stopPropagation();\n }\n };\n event.stopImmediatePropagation = () => {\n event.isImmediatePropagationStopped = always;\n event.stopPropagation();\n };\n if (!hasIsDefaultPrevented(event)) {\n event.isDefaultPrevented = event.defaultPrevented === true ? always : never;\n event.isPropagationStopped = event.cancelBubble === true ? always : never;\n event.isImmediatePropagationStopped = never;\n }\n }\n return event;\n };\n\n const eventExpandoPrefix = 'mce-data-';\n const mouseEventRe = /^(?:mouse|contextmenu)|click/;\n const addEvent = (target, name, callback, capture) => {\n target.addEventListener(name, callback, capture || false);\n };\n const removeEvent = (target, name, callback, capture) => {\n target.removeEventListener(name, callback, capture || false);\n };\n const isMouseEvent = event => isNonNullable(event) && mouseEventRe.test(event.type);\n const fix = (originalEvent, data) => {\n const event = normalize$3(originalEvent.type, originalEvent, document, data);\n if (isMouseEvent(originalEvent) && isUndefined(originalEvent.pageX) && !isUndefined(originalEvent.clientX)) {\n const eventDoc = event.target.ownerDocument || document;\n const doc = eventDoc.documentElement;\n const body = eventDoc.body;\n const mouseEvent = event;\n mouseEvent.pageX = originalEvent.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);\n mouseEvent.pageY = originalEvent.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);\n }\n return event;\n };\n const bindOnReady = (win, callback, eventUtils) => {\n const doc = win.document, event = { type: 'ready' };\n if (eventUtils.domLoaded) {\n callback(event);\n return;\n }\n const isDocReady = () => {\n return doc.readyState === 'complete' || doc.readyState === 'interactive' && doc.body;\n };\n const readyHandler = () => {\n removeEvent(win, 'DOMContentLoaded', readyHandler);\n removeEvent(win, 'load', readyHandler);\n if (!eventUtils.domLoaded) {\n eventUtils.domLoaded = true;\n callback(event);\n }\n win = null;\n };\n if (isDocReady()) {\n readyHandler();\n } else {\n addEvent(win, 'DOMContentLoaded', readyHandler);\n }\n if (!eventUtils.domLoaded) {\n addEvent(win, 'load', readyHandler);\n }\n };\n class EventUtils {\n constructor() {\n this.domLoaded = false;\n this.events = {};\n this.count = 1;\n this.expando = eventExpandoPrefix + (+new Date()).toString(32);\n this.hasFocusIn = 'onfocusin' in document.documentElement;\n this.count = 1;\n }\n bind(target, names, callback, scope) {\n const self = this;\n let callbackList;\n const win = window;\n const defaultNativeHandler = evt => {\n self.executeHandlers(fix(evt || win.event), id);\n };\n if (!target || isText$a(target) || isComment(target)) {\n return callback;\n }\n let id;\n if (!target[self.expando]) {\n id = self.count++;\n target[self.expando] = id;\n self.events[id] = {};\n } else {\n id = target[self.expando];\n }\n scope = scope || target;\n const namesList = names.split(' ');\n let i = namesList.length;\n while (i--) {\n let name = namesList[i];\n let nativeHandler = defaultNativeHandler;\n let capture = false;\n let fakeName = false;\n if (name === 'DOMContentLoaded') {\n name = 'ready';\n }\n if (self.domLoaded && name === 'ready' && target.readyState === 'complete') {\n callback.call(scope, fix({ type: name }));\n continue;\n }\n if (!self.hasFocusIn && (name === 'focusin' || name === 'focusout')) {\n capture = true;\n fakeName = name === 'focusin' ? 'focus' : 'blur';\n nativeHandler = evt => {\n const event = fix(evt || win.event);\n event.type = event.type === 'focus' ? 'focusin' : 'focusout';\n self.executeHandlers(event, id);\n };\n }\n callbackList = self.events[id][name];\n if (!callbackList) {\n self.events[id][name] = callbackList = [{\n func: callback,\n scope\n }];\n callbackList.fakeName = fakeName;\n callbackList.capture = capture;\n callbackList.nativeHandler = nativeHandler;\n if (name === 'ready') {\n bindOnReady(target, nativeHandler, self);\n } else {\n addEvent(target, fakeName || name, nativeHandler, capture);\n }\n } else {\n if (name === 'ready' && self.domLoaded) {\n callback(fix({ type: name }));\n } else {\n callbackList.push({\n func: callback,\n scope\n });\n }\n }\n }\n target = callbackList = null;\n return callback;\n }\n unbind(target, names, callback) {\n if (!target || isText$a(target) || isComment(target)) {\n return this;\n }\n const id = target[this.expando];\n if (id) {\n let eventMap = this.events[id];\n if (names) {\n const namesList = names.split(' ');\n let i = namesList.length;\n while (i--) {\n const name = namesList[i];\n const callbackList = eventMap[name];\n if (callbackList) {\n if (callback) {\n let ci = callbackList.length;\n while (ci--) {\n if (callbackList[ci].func === callback) {\n const nativeHandler = callbackList.nativeHandler;\n const fakeName = callbackList.fakeName, capture = callbackList.capture;\n const newCallbackList = callbackList.slice(0, ci).concat(callbackList.slice(ci + 1));\n newCallbackList.nativeHandler = nativeHandler;\n newCallbackList.fakeName = fakeName;\n newCallbackList.capture = capture;\n eventMap[name] = newCallbackList;\n }\n }\n }\n if (!callback || callbackList.length === 0) {\n delete eventMap[name];\n removeEvent(target, callbackList.fakeName || name, callbackList.nativeHandler, callbackList.capture);\n }\n }\n }\n } else {\n each$d(eventMap, (callbackList, name) => {\n removeEvent(target, callbackList.fakeName || name, callbackList.nativeHandler, callbackList.capture);\n });\n eventMap = {};\n }\n for (const name in eventMap) {\n if (has$2(eventMap, name)) {\n return this;\n }\n }\n delete this.events[id];\n try {\n delete target[this.expando];\n } catch (ex) {\n target[this.expando] = null;\n }\n }\n return this;\n }\n fire(target, name, args) {\n return this.dispatch(target, name, args);\n }\n dispatch(target, name, args) {\n if (!target || isText$a(target) || isComment(target)) {\n return this;\n }\n const event = fix({\n type: name,\n target\n }, args);\n do {\n const id = target[this.expando];\n if (id) {\n this.executeHandlers(event, id);\n }\n target = target.parentNode || target.ownerDocument || target.defaultView || target.parentWindow;\n } while (target && !event.isPropagationStopped());\n return this;\n }\n clean(target) {\n if (!target || isText$a(target) || isComment(target)) {\n return this;\n }\n if (target[this.expando]) {\n this.unbind(target);\n }\n if (!target.getElementsByTagName) {\n target = target.document;\n }\n if (target && target.getElementsByTagName) {\n this.unbind(target);\n const children = target.getElementsByTagName('*');\n let i = children.length;\n while (i--) {\n target = children[i];\n if (target[this.expando]) {\n this.unbind(target);\n }\n }\n }\n return this;\n }\n destroy() {\n this.events = {};\n }\n cancel(e) {\n if (e) {\n e.preventDefault();\n e.stopImmediatePropagation();\n }\n return false;\n }\n executeHandlers(evt, id) {\n const container = this.events[id];\n const callbackList = container && container[evt.type];\n if (callbackList) {\n for (let i = 0, l = callbackList.length; i < l; i++) {\n const callback = callbackList[i];\n if (callback && callback.func.call(callback.scope, evt) === false) {\n evt.preventDefault();\n }\n if (evt.isImmediatePropagationStopped()) {\n return;\n }\n }\n }\n }\n }\n EventUtils.Event = new EventUtils();\n\n const each$a = Tools.each;\n const grep = Tools.grep;\n const internalStyleName = 'data-mce-style';\n const numericalCssMap = Tools.makeMap('fill-opacity font-weight line-height opacity orphans widows z-index zoom', ' ');\n const legacySetAttribute = (elm, name, value) => {\n if (isNullable(value) || value === '') {\n remove$a(elm, name);\n } else {\n set$3(elm, name, value);\n }\n };\n const camelCaseToHyphens = name => name.replace(/[A-Z]/g, v => '-' + v.toLowerCase());\n const findNodeIndex = (node, normalized) => {\n let idx = 0;\n if (node) {\n for (let lastNodeType = node.nodeType, tempNode = node.previousSibling; tempNode; tempNode = tempNode.previousSibling) {\n const nodeType = tempNode.nodeType;\n if (normalized && isText$a(tempNode)) {\n if (nodeType === lastNodeType || !tempNode.data.length) {\n continue;\n }\n }\n idx++;\n lastNodeType = nodeType;\n }\n }\n return idx;\n };\n const updateInternalStyleAttr = (styles, elm) => {\n const rawValue = get$9(elm, 'style');\n const value = styles.serialize(styles.parse(rawValue), name(elm));\n legacySetAttribute(elm, internalStyleName, value);\n };\n const convertStyleToString = (cssValue, cssName) => {\n if (isNumber(cssValue)) {\n return has$2(numericalCssMap, cssName) ? cssValue + '' : cssValue + 'px';\n } else {\n return cssValue;\n }\n };\n const applyStyle$1 = ($elm, cssName, cssValue) => {\n const normalizedName = camelCaseToHyphens(cssName);\n if (isNullable(cssValue) || cssValue === '') {\n remove$6($elm, normalizedName);\n } else {\n set$2($elm, normalizedName, convertStyleToString(cssValue, normalizedName));\n }\n };\n const setupAttrHooks = (styles, settings, getContext) => {\n const keepValues = settings.keep_values;\n const keepUrlHook = {\n set: (elm, value, name) => {\n const sugarElm = SugarElement.fromDom(elm);\n if (isFunction(settings.url_converter) && isNonNullable(value)) {\n value = settings.url_converter.call(settings.url_converter_scope || getContext(), String(value), name, elm);\n }\n const internalName = 'data-mce-' + name;\n legacySetAttribute(sugarElm, internalName, value);\n legacySetAttribute(sugarElm, name, value);\n },\n get: (elm, name) => {\n const sugarElm = SugarElement.fromDom(elm);\n return get$9(sugarElm, 'data-mce-' + name) || get$9(sugarElm, name);\n }\n };\n const attrHooks = {\n style: {\n set: (elm, value) => {\n const sugarElm = SugarElement.fromDom(elm);\n if (keepValues) {\n legacySetAttribute(sugarElm, internalStyleName, value);\n }\n remove$a(sugarElm, 'style');\n if (isString(value)) {\n setAll(sugarElm, styles.parse(value));\n }\n },\n get: elm => {\n const sugarElm = SugarElement.fromDom(elm);\n const value = get$9(sugarElm, internalStyleName) || get$9(sugarElm, 'style');\n return styles.serialize(styles.parse(value), name(sugarElm));\n }\n }\n };\n if (keepValues) {\n attrHooks.href = attrHooks.src = keepUrlHook;\n }\n return attrHooks;\n };\n const DOMUtils = (doc, settings = {}) => {\n const addedStyles = {};\n const win = window;\n const files = {};\n let counter = 0;\n const stdMode = true;\n const boxModel = true;\n const styleSheetLoader = instance.forElement(SugarElement.fromDom(doc), {\n contentCssCors: settings.contentCssCors,\n referrerPolicy: settings.referrerPolicy\n });\n const boundEvents = [];\n const schema = settings.schema ? settings.schema : Schema({});\n const styles = Styles({\n url_converter: settings.url_converter,\n url_converter_scope: settings.url_converter_scope,\n force_hex_color: settings.force_hex_color\n }, settings.schema);\n const events = settings.ownEvents ? new EventUtils() : EventUtils.Event;\n const blockElementsMap = schema.getBlockElements();\n const isBlock = node => {\n if (isString(node)) {\n return has$2(blockElementsMap, node);\n } else {\n return isElement$6(node) && (has$2(blockElementsMap, node.nodeName) || isTransparentBlock(schema, node));\n }\n };\n const get = elm => elm && doc && isString(elm) ? doc.getElementById(elm) : elm;\n const _get = elm => {\n const value = get(elm);\n return isNonNullable(value) ? SugarElement.fromDom(value) : null;\n };\n const getAttrib = (elm, name, defaultVal = '') => {\n let value;\n const $elm = _get(elm);\n if (isNonNullable($elm) && isElement$7($elm)) {\n const hook = attrHooks[name];\n if (hook && hook.get) {\n value = hook.get($elm.dom, name);\n } else {\n value = get$9($elm, name);\n }\n }\n return isNonNullable(value) ? value : defaultVal;\n };\n const getAttribs = elm => {\n const node = get(elm);\n return isNullable(node) ? [] : node.attributes;\n };\n const setAttrib = (elm, name, value) => {\n run(elm, e => {\n if (isElement$6(e)) {\n const $elm = SugarElement.fromDom(e);\n const val = value === '' ? null : value;\n const originalValue = get$9($elm, name);\n const hook = attrHooks[name];\n if (hook && hook.set) {\n hook.set($elm.dom, val, name);\n } else {\n legacySetAttribute($elm, name, val);\n }\n if (originalValue !== val && settings.onSetAttrib) {\n settings.onSetAttrib({\n attrElm: $elm.dom,\n attrName: name,\n attrValue: val\n });\n }\n }\n });\n };\n const clone = (node, deep) => {\n return node.cloneNode(deep);\n };\n const getRoot = () => settings.root_element || doc.body;\n const getViewPort = argWin => {\n const vp = getBounds(argWin);\n return {\n x: vp.x,\n y: vp.y,\n w: vp.width,\n h: vp.height\n };\n };\n const getPos$1 = (elm, rootElm) => getPos(doc.body, get(elm), rootElm);\n const setStyle = (elm, name, value) => {\n run(elm, e => {\n const $elm = SugarElement.fromDom(e);\n applyStyle$1($elm, name, value);\n if (settings.update_styles) {\n updateInternalStyleAttr(styles, $elm);\n }\n });\n };\n const setStyles = (elm, stylesArg) => {\n run(elm, e => {\n const $elm = SugarElement.fromDom(e);\n each$d(stylesArg, (v, n) => {\n applyStyle$1($elm, n, v);\n });\n if (settings.update_styles) {\n updateInternalStyleAttr(styles, $elm);\n }\n });\n };\n const getStyle = (elm, name, computed) => {\n const $elm = get(elm);\n if (isNullable($elm) || !isHTMLElement($elm) && !isSVGElement($elm)) {\n return undefined;\n }\n if (computed) {\n return get$7(SugarElement.fromDom($elm), camelCaseToHyphens(name));\n } else {\n name = name.replace(/-(\\D)/g, (a, b) => b.toUpperCase());\n if (name === 'float') {\n name = 'cssFloat';\n }\n return $elm.style ? $elm.style[name] : undefined;\n }\n };\n const getSize = elm => {\n const $elm = get(elm);\n if (!$elm) {\n return {\n w: 0,\n h: 0\n };\n }\n let w = getStyle($elm, 'width');\n let h = getStyle($elm, 'height');\n if (!w || w.indexOf('px') === -1) {\n w = '0';\n }\n if (!h || h.indexOf('px') === -1) {\n h = '0';\n }\n return {\n w: parseInt(w, 10) || $elm.offsetWidth || $elm.clientWidth,\n h: parseInt(h, 10) || $elm.offsetHeight || $elm.clientHeight\n };\n };\n const getRect = elm => {\n const $elm = get(elm);\n const pos = getPos$1($elm);\n const size = getSize($elm);\n return {\n x: pos.x,\n y: pos.y,\n w: size.w,\n h: size.h\n };\n };\n const is = (elm, selector) => {\n if (!elm) {\n return false;\n }\n const elms = isArray$1(elm) ? elm : [elm];\n return exists(elms, e => {\n return is$1(SugarElement.fromDom(e), selector);\n });\n };\n const getParents = (elm, selector, root, collect) => {\n const result = [];\n let node = get(elm);\n collect = collect === undefined;\n const resolvedRoot = root || (getRoot().nodeName !== 'BODY' ? getRoot().parentNode : null);\n if (isString(selector)) {\n if (selector === '*') {\n selector = isElement$6;\n } else {\n const selectorVal = selector;\n selector = node => is(node, selectorVal);\n }\n }\n while (node) {\n if (node === resolvedRoot || isNullable(node.nodeType) || isDocument$1(node) || isDocumentFragment(node)) {\n break;\n }\n if (!selector || selector(node)) {\n if (collect) {\n result.push(node);\n } else {\n return [node];\n }\n }\n node = node.parentNode;\n }\n return collect ? result : null;\n };\n const getParent = (node, selector, root) => {\n const parents = getParents(node, selector, root, false);\n return parents && parents.length > 0 ? parents[0] : null;\n };\n const _findSib = (node, selector, name) => {\n let func = selector;\n if (node) {\n if (isString(selector)) {\n func = node => {\n return is(node, selector);\n };\n }\n for (let tempNode = node[name]; tempNode; tempNode = tempNode[name]) {\n if (isFunction(func) && func(tempNode)) {\n return tempNode;\n }\n }\n }\n return null;\n };\n const getNext = (node, selector) => _findSib(node, selector, 'nextSibling');\n const getPrev = (node, selector) => _findSib(node, selector, 'previousSibling');\n const isParentNode = node => isFunction(node.querySelectorAll);\n const select = (selector, scope) => {\n var _a, _b;\n const elm = (_b = (_a = get(scope)) !== null && _a !== void 0 ? _a : settings.root_element) !== null && _b !== void 0 ? _b : doc;\n return isParentNode(elm) ? from(elm.querySelectorAll(selector)) : [];\n };\n const run = function (elm, func, scope) {\n const context = scope !== null && scope !== void 0 ? scope : this;\n if (isArray$1(elm)) {\n const result = [];\n each$a(elm, (e, i) => {\n const node = get(e);\n if (node) {\n result.push(func.call(context, node, i));\n }\n });\n return result;\n } else {\n const node = get(elm);\n return !node ? false : func.call(context, node);\n }\n };\n const setAttribs = (elm, attrs) => {\n run(elm, $elm => {\n each$d(attrs, (value, name) => {\n setAttrib($elm, name, value);\n });\n });\n };\n const setHTML = (elm, html) => {\n run(elm, e => {\n const $elm = SugarElement.fromDom(e);\n set$1($elm, html);\n });\n };\n const add = (parentElm, name, attrs, html, create) => run(parentElm, parentElm => {\n const newElm = isString(name) ? doc.createElement(name) : name;\n if (isNonNullable(attrs)) {\n setAttribs(newElm, attrs);\n }\n if (html) {\n if (!isString(html) && html.nodeType) {\n newElm.appendChild(html);\n } else if (isString(html)) {\n setHTML(newElm, html);\n }\n }\n return !create ? parentElm.appendChild(newElm) : newElm;\n });\n const create = (name, attrs, html) => add(doc.createElement(name), name, attrs, html, true);\n const decode = Entities.decode;\n const encode = Entities.encodeAllRaw;\n const createHTML = (name, attrs, html = '') => {\n let outHtml = '<' + name;\n for (const key in attrs) {\n if (hasNonNullableKey(attrs, key)) {\n outHtml += ' ' + key + '=\"' + encode(attrs[key]) + '\"';\n }\n }\n if (isEmpty$3(html) && has$2(schema.getVoidElements(), name)) {\n return outHtml + ' />';\n } else {\n return outHtml + '>' + html + '';\n }\n };\n const createFragment = html => {\n const container = doc.createElement('div');\n const frag = doc.createDocumentFragment();\n frag.appendChild(container);\n if (html) {\n container.innerHTML = html;\n }\n let node;\n while (node = container.firstChild) {\n frag.appendChild(node);\n }\n frag.removeChild(container);\n return frag;\n };\n const remove = (node, keepChildren) => {\n return run(node, n => {\n const $node = SugarElement.fromDom(n);\n if (keepChildren) {\n each$e(children$1($node), child => {\n if (isText$b(child) && child.dom.length === 0) {\n remove$5(child);\n } else {\n before$3($node, child);\n }\n });\n }\n remove$5($node);\n return $node.dom;\n });\n };\n const removeAllAttribs = e => run(e, e => {\n const attrs = e.attributes;\n for (let i = attrs.length - 1; i >= 0; i--) {\n e.removeAttributeNode(attrs.item(i));\n }\n });\n const parseStyle = cssText => styles.parse(cssText);\n const serializeStyle = (stylesArg, name) => styles.serialize(stylesArg, name);\n const addStyle = cssText => {\n if (self !== DOMUtils.DOM && doc === document) {\n if (addedStyles[cssText]) {\n return;\n }\n addedStyles[cssText] = true;\n }\n let styleElm = doc.getElementById('mceDefaultStyles');\n if (!styleElm) {\n styleElm = doc.createElement('style');\n styleElm.id = 'mceDefaultStyles';\n styleElm.type = 'text/css';\n const head = doc.head;\n if (head.firstChild) {\n head.insertBefore(styleElm, head.firstChild);\n } else {\n head.appendChild(styleElm);\n }\n }\n if (styleElm.styleSheet) {\n styleElm.styleSheet.cssText += cssText;\n } else {\n styleElm.appendChild(doc.createTextNode(cssText));\n }\n };\n const loadCSS = urls => {\n if (!urls) {\n urls = '';\n }\n each$e(urls.split(','), url => {\n files[url] = true;\n styleSheetLoader.load(url).catch(noop);\n });\n };\n const toggleClass = (elm, cls, state) => {\n run(elm, e => {\n if (isElement$6(e)) {\n const $elm = SugarElement.fromDom(e);\n const classes = cls.split(' ');\n each$e(classes, c => {\n if (isNonNullable(state)) {\n const fn = state ? add$2 : remove$7;\n fn($elm, c);\n } else {\n toggle$1($elm, c);\n }\n });\n }\n });\n };\n const addClass = (elm, cls) => {\n toggleClass(elm, cls, true);\n };\n const removeClass = (elm, cls) => {\n toggleClass(elm, cls, false);\n };\n const hasClass = (elm, cls) => {\n const $elm = _get(elm);\n const classes = cls.split(' ');\n return isNonNullable($elm) && forall(classes, c => has($elm, c));\n };\n const show = elm => {\n run(elm, e => remove$6(SugarElement.fromDom(e), 'display'));\n };\n const hide = elm => {\n run(elm, e => set$2(SugarElement.fromDom(e), 'display', 'none'));\n };\n const isHidden = elm => {\n const $elm = _get(elm);\n return isNonNullable($elm) && is$2(getRaw($elm, 'display'), 'none');\n };\n const uniqueId = prefix => (!prefix ? 'mce_' : prefix) + counter++;\n const getOuterHTML = elm => {\n const $elm = _get(elm);\n if (isNonNullable($elm)) {\n return isElement$6($elm.dom) ? $elm.dom.outerHTML : getOuter($elm);\n } else {\n return '';\n }\n };\n const setOuterHTML = (elm, html) => {\n run(elm, $elm => {\n if (isElement$6($elm)) {\n $elm.outerHTML = html;\n }\n });\n };\n const insertAfter = (node, reference) => {\n const referenceNode = get(reference);\n return run(node, node => {\n const parent = referenceNode === null || referenceNode === void 0 ? void 0 : referenceNode.parentNode;\n const nextSibling = referenceNode === null || referenceNode === void 0 ? void 0 : referenceNode.nextSibling;\n if (parent) {\n if (nextSibling) {\n parent.insertBefore(node, nextSibling);\n } else {\n parent.appendChild(node);\n }\n }\n return node;\n });\n };\n const replace = (newElm, oldElm, keepChildren) => run(oldElm, elm => {\n var _a;\n const replacee = isArray$1(oldElm) ? newElm.cloneNode(true) : newElm;\n if (keepChildren) {\n each$a(grep(elm.childNodes), node => {\n replacee.appendChild(node);\n });\n }\n (_a = elm.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(replacee, elm);\n return elm;\n });\n const rename = (elm, name) => {\n if (elm.nodeName !== name.toUpperCase()) {\n const newElm = create(name);\n each$a(getAttribs(elm), attrNode => {\n setAttrib(newElm, attrNode.nodeName, getAttrib(elm, attrNode.nodeName));\n });\n replace(newElm, elm, true);\n return newElm;\n } else {\n return elm;\n }\n };\n const findCommonAncestor = (a, b) => {\n let ps = a;\n while (ps) {\n let pe = b;\n while (pe && ps !== pe) {\n pe = pe.parentNode;\n }\n if (ps === pe) {\n break;\n }\n ps = ps.parentNode;\n }\n if (!ps && a.ownerDocument) {\n return a.ownerDocument.documentElement;\n } else {\n return ps;\n }\n };\n const isNonEmptyElement = node => {\n if (isElement$6(node)) {\n const isNamedAnchor = node.nodeName.toLowerCase() === 'a' && !getAttrib(node, 'href') && getAttrib(node, 'id');\n if (getAttrib(node, 'name') || getAttrib(node, 'data-mce-bookmark') || isNamedAnchor) {\n return true;\n }\n }\n return false;\n };\n const isEmpty = (node, elements, options) => {\n let brCount = 0;\n if (isNonEmptyElement(node)) {\n return false;\n }\n const firstChild = node.firstChild;\n if (firstChild) {\n const walker = new DomTreeWalker(firstChild, node);\n const whitespaceElements = schema ? schema.getWhitespaceElements() : {};\n const nonEmptyElements = elements || (schema ? schema.getNonEmptyElements() : null);\n let tempNode = firstChild;\n do {\n if (isElement$6(tempNode)) {\n const bogusVal = tempNode.getAttribute('data-mce-bogus');\n if (bogusVal) {\n tempNode = walker.next(bogusVal === 'all');\n continue;\n }\n const name = tempNode.nodeName.toLowerCase();\n if (nonEmptyElements && nonEmptyElements[name]) {\n if (name === 'br') {\n brCount++;\n tempNode = walker.next();\n continue;\n }\n return false;\n }\n if (isNonEmptyElement(tempNode)) {\n return false;\n }\n }\n if (isComment(tempNode)) {\n return false;\n }\n if (isText$a(tempNode) && !isWhitespaceText(tempNode.data) && (!(options === null || options === void 0 ? void 0 : options.includeZwsp) || !isZwsp(tempNode.data))) {\n return false;\n }\n if (isText$a(tempNode) && tempNode.parentNode && whitespaceElements[tempNode.parentNode.nodeName] && isWhitespaceText(tempNode.data)) {\n return false;\n }\n tempNode = walker.next();\n } while (tempNode);\n }\n return brCount <= 1;\n };\n const createRng = () => doc.createRange();\n const split = (parentElm, splitElm, replacementElm) => {\n let range = createRng();\n let beforeFragment;\n let afterFragment;\n if (parentElm && splitElm && parentElm.parentNode && splitElm.parentNode) {\n const parentNode = parentElm.parentNode;\n range.setStart(parentNode, findNodeIndex(parentElm));\n range.setEnd(splitElm.parentNode, findNodeIndex(splitElm));\n beforeFragment = range.extractContents();\n range = createRng();\n range.setStart(splitElm.parentNode, findNodeIndex(splitElm) + 1);\n range.setEnd(parentNode, findNodeIndex(parentElm) + 1);\n afterFragment = range.extractContents();\n parentNode.insertBefore(trimNode(self, beforeFragment, schema), parentElm);\n if (replacementElm) {\n parentNode.insertBefore(replacementElm, parentElm);\n } else {\n parentNode.insertBefore(splitElm, parentElm);\n }\n parentNode.insertBefore(trimNode(self, afterFragment, schema), parentElm);\n remove(parentElm);\n return replacementElm || splitElm;\n } else {\n return undefined;\n }\n };\n const bind = (target, name, func, scope) => {\n if (isArray$1(target)) {\n let i = target.length;\n const rv = [];\n while (i--) {\n rv[i] = bind(target[i], name, func, scope);\n }\n return rv;\n } else {\n if (settings.collect && (target === doc || target === win)) {\n boundEvents.push([\n target,\n name,\n func,\n scope\n ]);\n }\n return events.bind(target, name, func, scope || self);\n }\n };\n const unbind = (target, name, func) => {\n if (isArray$1(target)) {\n let i = target.length;\n const rv = [];\n while (i--) {\n rv[i] = unbind(target[i], name, func);\n }\n return rv;\n } else {\n if (boundEvents.length > 0 && (target === doc || target === win)) {\n let i = boundEvents.length;\n while (i--) {\n const [boundTarget, boundName, boundFunc] = boundEvents[i];\n if (target === boundTarget && (!name || name === boundName) && (!func || func === boundFunc)) {\n events.unbind(boundTarget, boundName, boundFunc);\n }\n }\n }\n return events.unbind(target, name, func);\n }\n };\n const dispatch = (target, name, evt) => events.dispatch(target, name, evt);\n const fire = (target, name, evt) => events.dispatch(target, name, evt);\n const getContentEditable = node => {\n if (node && isHTMLElement(node)) {\n const contentEditable = node.getAttribute('data-mce-contenteditable');\n if (contentEditable && contentEditable !== 'inherit') {\n return contentEditable;\n }\n return node.contentEditable !== 'inherit' ? node.contentEditable : null;\n } else {\n return null;\n }\n };\n const getContentEditableParent = node => {\n const root = getRoot();\n let state = null;\n for (let tempNode = node; tempNode && tempNode !== root; tempNode = tempNode.parentNode) {\n state = getContentEditable(tempNode);\n if (state !== null) {\n break;\n }\n }\n return state;\n };\n const isEditable = node => {\n if (isNonNullable(node)) {\n const scope = isElement$6(node) ? node : node.parentElement;\n return isNonNullable(scope) && isHTMLElement(scope) && isEditable$2(SugarElement.fromDom(scope));\n } else {\n return false;\n }\n };\n const destroy = () => {\n if (boundEvents.length > 0) {\n let i = boundEvents.length;\n while (i--) {\n const [boundTarget, boundName, boundFunc] = boundEvents[i];\n events.unbind(boundTarget, boundName, boundFunc);\n }\n }\n each$d(files, (_, url) => {\n styleSheetLoader.unload(url);\n delete files[url];\n });\n };\n const isChildOf = (node, parent) => {\n return node === parent || parent.contains(node);\n };\n const dumpRng = r => 'startContainer: ' + r.startContainer.nodeName + ', startOffset: ' + r.startOffset + ', endContainer: ' + r.endContainer.nodeName + ', endOffset: ' + r.endOffset;\n const self = {\n doc,\n settings,\n win,\n files,\n stdMode,\n boxModel,\n styleSheetLoader,\n boundEvents,\n styles,\n schema,\n events,\n isBlock: isBlock,\n root: null,\n clone,\n getRoot,\n getViewPort,\n getRect,\n getSize,\n getParent,\n getParents: getParents,\n get,\n getNext,\n getPrev,\n select,\n is,\n add,\n create,\n createHTML,\n createFragment,\n remove,\n setStyle,\n getStyle: getStyle,\n setStyles,\n removeAllAttribs,\n setAttrib,\n setAttribs,\n getAttrib,\n getPos: getPos$1,\n parseStyle,\n serializeStyle,\n addStyle,\n loadCSS,\n addClass,\n removeClass,\n hasClass,\n toggleClass,\n show,\n hide,\n isHidden,\n uniqueId,\n setHTML,\n getOuterHTML,\n setOuterHTML,\n decode,\n encode,\n insertAfter,\n replace,\n rename,\n findCommonAncestor,\n run,\n getAttribs,\n isEmpty,\n createRng,\n nodeIndex: findNodeIndex,\n split,\n bind: bind,\n unbind: unbind,\n fire,\n dispatch,\n getContentEditable,\n getContentEditableParent,\n isEditable,\n destroy,\n isChildOf,\n dumpRng\n };\n const attrHooks = setupAttrHooks(styles, settings, constant(self));\n return self;\n };\n DOMUtils.DOM = DOMUtils(document);\n DOMUtils.nodeIndex = findNodeIndex;\n\n const DOM$b = DOMUtils.DOM;\n const QUEUED = 0;\n const LOADING = 1;\n const LOADED = 2;\n const FAILED = 3;\n class ScriptLoader {\n constructor(settings = {}) {\n this.states = {};\n this.queue = [];\n this.scriptLoadedCallbacks = {};\n this.queueLoadedCallbacks = [];\n this.loading = false;\n this.settings = settings;\n }\n _setReferrerPolicy(referrerPolicy) {\n this.settings.referrerPolicy = referrerPolicy;\n }\n loadScript(url) {\n return new Promise((resolve, reject) => {\n const dom = DOM$b;\n let elm;\n const cleanup = () => {\n dom.remove(id);\n if (elm) {\n elm.onerror = elm.onload = elm = null;\n }\n };\n const done = () => {\n cleanup();\n resolve();\n };\n const error = () => {\n cleanup();\n reject('Failed to load script: ' + url);\n };\n const id = dom.uniqueId();\n elm = document.createElement('script');\n elm.id = id;\n elm.type = 'text/javascript';\n elm.src = Tools._addCacheSuffix(url);\n if (this.settings.referrerPolicy) {\n dom.setAttrib(elm, 'referrerpolicy', this.settings.referrerPolicy);\n }\n elm.onload = done;\n elm.onerror = error;\n (document.getElementsByTagName('head')[0] || document.body).appendChild(elm);\n });\n }\n isDone(url) {\n return this.states[url] === LOADED;\n }\n markDone(url) {\n this.states[url] = LOADED;\n }\n add(url) {\n const self = this;\n self.queue.push(url);\n const state = self.states[url];\n if (state === undefined) {\n self.states[url] = QUEUED;\n }\n return new Promise((resolve, reject) => {\n if (!self.scriptLoadedCallbacks[url]) {\n self.scriptLoadedCallbacks[url] = [];\n }\n self.scriptLoadedCallbacks[url].push({\n resolve,\n reject\n });\n });\n }\n load(url) {\n return this.add(url);\n }\n remove(url) {\n delete this.states[url];\n delete this.scriptLoadedCallbacks[url];\n }\n loadQueue() {\n const queue = this.queue;\n this.queue = [];\n return this.loadScripts(queue);\n }\n loadScripts(scripts) {\n const self = this;\n const execCallbacks = (name, url) => {\n get$a(self.scriptLoadedCallbacks, url).each(callbacks => {\n each$e(callbacks, callback => callback[name](url));\n });\n delete self.scriptLoadedCallbacks[url];\n };\n const processResults = results => {\n const failures = filter$5(results, result => result.status === 'rejected');\n if (failures.length > 0) {\n return Promise.reject(bind$3(failures, ({reason}) => isArray$1(reason) ? reason : [reason]));\n } else {\n return Promise.resolve();\n }\n };\n const load = urls => Promise.allSettled(map$3(urls, url => {\n if (self.states[url] === LOADED) {\n execCallbacks('resolve', url);\n return Promise.resolve();\n } else if (self.states[url] === FAILED) {\n execCallbacks('reject', url);\n return Promise.reject(url);\n } else {\n self.states[url] = LOADING;\n return self.loadScript(url).then(() => {\n self.states[url] = LOADED;\n execCallbacks('resolve', url);\n const queue = self.queue;\n if (queue.length > 0) {\n self.queue = [];\n return load(queue).then(processResults);\n } else {\n return Promise.resolve();\n }\n }, () => {\n self.states[url] = FAILED;\n execCallbacks('reject', url);\n return Promise.reject(url);\n });\n }\n }));\n const processQueue = urls => {\n self.loading = true;\n return load(urls).then(results => {\n self.loading = false;\n const nextQueuedItem = self.queueLoadedCallbacks.shift();\n Optional.from(nextQueuedItem).each(call);\n return processResults(results);\n });\n };\n const uniqueScripts = stringArray(scripts);\n if (self.loading) {\n return new Promise((resolve, reject) => {\n self.queueLoadedCallbacks.push(() => {\n processQueue(uniqueScripts).then(resolve, reject);\n });\n });\n } else {\n return processQueue(uniqueScripts);\n }\n }\n }\n ScriptLoader.ScriptLoader = new ScriptLoader();\n\n const Cell = initial => {\n let value = initial;\n const get = () => {\n return value;\n };\n const set = v => {\n value = v;\n };\n return {\n get,\n set\n };\n };\n\n const isDuplicated = (items, item) => {\n const firstIndex = items.indexOf(item);\n return firstIndex !== -1 && items.indexOf(item, firstIndex + 1) > firstIndex;\n };\n const isRaw = str => isObject(str) && has$2(str, 'raw');\n const isTokenised = str => isArray$1(str) && str.length > 1;\n const data = {};\n const currentCode = Cell('en');\n const getLanguageData = () => get$a(data, currentCode.get());\n const getData$1 = () => map$2(data, value => ({ ...value }));\n const setCode = newCode => {\n if (newCode) {\n currentCode.set(newCode);\n }\n };\n const getCode = () => currentCode.get();\n const add$1 = (code, items) => {\n let langData = data[code];\n if (!langData) {\n data[code] = langData = {};\n }\n const lcNames = map$3(keys(items), name => name.toLowerCase());\n each$d(items, (translation, name) => {\n const lcName = name.toLowerCase();\n if (lcName !== name && isDuplicated(lcNames, lcName)) {\n if (!has$2(items, lcName)) {\n langData[lcName] = translation;\n }\n langData[name] = translation;\n } else {\n langData[lcName] = translation;\n }\n });\n };\n const translate = text => {\n const langData = getLanguageData().getOr({});\n const toString = obj => {\n if (isFunction(obj)) {\n return Object.prototype.toString.call(obj);\n }\n return !isEmpty(obj) ? '' + obj : '';\n };\n const isEmpty = text => text === '' || text === null || text === undefined;\n const getLangData = text => {\n const textStr = toString(text);\n return has$2(langData, textStr) ? toString(langData[textStr]) : get$a(langData, textStr.toLowerCase()).map(toString).getOr(textStr);\n };\n const removeContext = str => str.replace(/{context:\\w+}$/, '');\n if (isEmpty(text)) {\n return '';\n }\n if (isRaw(text)) {\n return toString(text.raw);\n }\n if (isTokenised(text)) {\n const values = text.slice(1);\n const substitued = getLangData(text[0]).replace(/\\{([0-9]+)\\}/g, ($1, $2) => has$2(values, $2) ? toString(values[$2]) : $1);\n return removeContext(substitued);\n }\n return removeContext(getLangData(text));\n };\n const isRtl$1 = () => getLanguageData().bind(items => get$a(items, '_dir')).exists(dir => dir === 'rtl');\n const hasCode = code => has$2(data, code);\n const I18n = {\n getData: getData$1,\n setCode,\n getCode,\n add: add$1,\n translate,\n isRtl: isRtl$1,\n hasCode\n };\n\n const AddOnManager = () => {\n const items = [];\n const urls = {};\n const lookup = {};\n const _listeners = [];\n const runListeners = (name, state) => {\n const matchedListeners = filter$5(_listeners, listener => listener.name === name && listener.state === state);\n each$e(matchedListeners, listener => listener.resolve());\n };\n const isLoaded = name => has$2(urls, name);\n const isAdded = name => has$2(lookup, name);\n const get = name => {\n if (lookup[name]) {\n return lookup[name].instance;\n }\n return undefined;\n };\n const loadLanguagePack = (name, languages) => {\n const language = I18n.getCode();\n const wrappedLanguages = ',' + (languages || '') + ',';\n if (!language || languages && wrappedLanguages.indexOf(',' + language + ',') === -1) {\n return;\n }\n ScriptLoader.ScriptLoader.add(urls[name] + '/langs/' + language + '.js');\n };\n const requireLangPack = (name, languages) => {\n if (AddOnManager.languageLoad !== false) {\n if (isLoaded(name)) {\n loadLanguagePack(name, languages);\n } else {\n waitFor(name, 'loaded').then(() => loadLanguagePack(name, languages));\n }\n }\n };\n const add = (id, addOn) => {\n items.push(addOn);\n lookup[id] = { instance: addOn };\n runListeners(id, 'added');\n return addOn;\n };\n const remove = name => {\n delete urls[name];\n delete lookup[name];\n };\n const createUrl = (baseUrl, dep) => {\n if (isString(dep)) {\n return isString(baseUrl) ? {\n prefix: '',\n resource: dep,\n suffix: ''\n } : {\n prefix: baseUrl.prefix,\n resource: dep,\n suffix: baseUrl.suffix\n };\n } else {\n return dep;\n }\n };\n const load = (name, addOnUrl) => {\n if (urls[name]) {\n return Promise.resolve();\n }\n let urlString = isString(addOnUrl) ? addOnUrl : addOnUrl.prefix + addOnUrl.resource + addOnUrl.suffix;\n if (urlString.indexOf('/') !== 0 && urlString.indexOf('://') === -1) {\n urlString = AddOnManager.baseURL + '/' + urlString;\n }\n urls[name] = urlString.substring(0, urlString.lastIndexOf('/'));\n const done = () => {\n runListeners(name, 'loaded');\n return Promise.resolve();\n };\n if (lookup[name]) {\n return done();\n } else {\n return ScriptLoader.ScriptLoader.add(urlString).then(done);\n }\n };\n const waitFor = (name, state = 'added') => {\n if (state === 'added' && isAdded(name)) {\n return Promise.resolve();\n } else if (state === 'loaded' && isLoaded(name)) {\n return Promise.resolve();\n } else {\n return new Promise(resolve => {\n _listeners.push({\n name,\n state,\n resolve\n });\n });\n }\n };\n return {\n items,\n urls,\n lookup,\n get,\n requireLangPack,\n add,\n remove,\n createUrl,\n load,\n waitFor\n };\n };\n AddOnManager.languageLoad = true;\n AddOnManager.baseURL = '';\n AddOnManager.PluginManager = AddOnManager();\n AddOnManager.ThemeManager = AddOnManager();\n AddOnManager.ModelManager = AddOnManager();\n\n const singleton = doRevoke => {\n const subject = Cell(Optional.none());\n const revoke = () => subject.get().each(doRevoke);\n const clear = () => {\n revoke();\n subject.set(Optional.none());\n };\n const isSet = () => subject.get().isSome();\n const get = () => subject.get();\n const set = s => {\n revoke();\n subject.set(Optional.some(s));\n };\n return {\n clear,\n isSet,\n get,\n set\n };\n };\n const repeatable = delay => {\n const intervalId = Cell(Optional.none());\n const revoke = () => intervalId.get().each(id => clearInterval(id));\n const clear = () => {\n revoke();\n intervalId.set(Optional.none());\n };\n const isSet = () => intervalId.get().isSome();\n const get = () => intervalId.get();\n const set = functionToRepeat => {\n revoke();\n intervalId.set(Optional.some(setInterval(functionToRepeat, delay)));\n };\n return {\n clear,\n isSet,\n get,\n set\n };\n };\n const value$2 = () => {\n const subject = singleton(noop);\n const on = f => subject.get().each(f);\n return {\n ...subject,\n on\n };\n };\n\n const first$1 = (fn, rate) => {\n let timer = null;\n const cancel = () => {\n if (!isNull(timer)) {\n clearTimeout(timer);\n timer = null;\n }\n };\n const throttle = (...args) => {\n if (isNull(timer)) {\n timer = setTimeout(() => {\n timer = null;\n fn.apply(null, args);\n }, rate);\n }\n };\n return {\n cancel,\n throttle\n };\n };\n const last$1 = (fn, rate) => {\n let timer = null;\n const cancel = () => {\n if (!isNull(timer)) {\n clearTimeout(timer);\n timer = null;\n }\n };\n const throttle = (...args) => {\n cancel();\n timer = setTimeout(() => {\n timer = null;\n fn.apply(null, args);\n }, rate);\n };\n return {\n cancel,\n throttle\n };\n };\n\n const annotation = constant('mce-annotation');\n const dataAnnotation = constant('data-mce-annotation');\n const dataAnnotationId = constant('data-mce-annotation-uid');\n const dataAnnotationActive = constant('data-mce-annotation-active');\n const dataAnnotationClasses = constant('data-mce-annotation-classes');\n const dataAnnotationAttributes = constant('data-mce-annotation-attrs');\n\n const isRoot$1 = root => node => eq(node, root);\n const identify = (editor, annotationName) => {\n const rng = editor.selection.getRng();\n const start = SugarElement.fromDom(rng.startContainer);\n const root = SugarElement.fromDom(editor.getBody());\n const selector = annotationName.fold(() => '.' + annotation(), an => `[${ dataAnnotation() }=\"${ an }\"]`);\n const newStart = child$1(start, rng.startOffset).getOr(start);\n const closest = closest$3(newStart, selector, isRoot$1(root));\n return closest.bind(c => getOpt(c, `${ dataAnnotationId() }`).bind(uid => getOpt(c, `${ dataAnnotation() }`).map(name => {\n const elements = findMarkers(editor, uid);\n return {\n uid,\n name,\n elements\n };\n })));\n };\n const isAnnotation = elem => isElement$7(elem) && has(elem, annotation());\n const isBogusElement = (elem, root) => has$1(elem, 'data-mce-bogus') || ancestor$2(elem, '[data-mce-bogus=\"all\"]', isRoot$1(root));\n const findMarkers = (editor, uid) => {\n const body = SugarElement.fromDom(editor.getBody());\n const descendants$1 = descendants(body, `[${ dataAnnotationId() }=\"${ uid }\"]`);\n return filter$5(descendants$1, descendant => !isBogusElement(descendant, body));\n };\n const findAll = (editor, name) => {\n const body = SugarElement.fromDom(editor.getBody());\n const markers = descendants(body, `[${ dataAnnotation() }=\"${ name }\"]`);\n const directory = {};\n each$e(markers, m => {\n if (!isBogusElement(m, body)) {\n const uid = get$9(m, dataAnnotationId());\n const nodesAlready = get$a(directory, uid).getOr([]);\n directory[uid] = nodesAlready.concat([m]);\n }\n });\n return directory;\n };\n\n const setup$y = (editor, registry) => {\n const changeCallbacks = Cell({});\n const initData = () => ({\n listeners: [],\n previous: value$2()\n });\n const withCallbacks = (name, f) => {\n updateCallbacks(name, data => {\n f(data);\n return data;\n });\n };\n const updateCallbacks = (name, f) => {\n const callbackMap = changeCallbacks.get();\n const data = get$a(callbackMap, name).getOrThunk(initData);\n const outputData = f(data);\n callbackMap[name] = outputData;\n changeCallbacks.set(callbackMap);\n };\n const fireCallbacks = (name, uid, elements) => {\n withCallbacks(name, data => {\n each$e(data.listeners, f => f(true, name, {\n uid,\n nodes: map$3(elements, elem => elem.dom)\n }));\n });\n };\n const fireNoAnnotation = name => {\n withCallbacks(name, data => {\n each$e(data.listeners, f => f(false, name));\n });\n };\n const toggleActiveAttr = (uid, state) => {\n each$e(findMarkers(editor, uid), elem => {\n if (state) {\n set$3(elem, dataAnnotationActive(), 'true');\n } else {\n remove$a(elem, dataAnnotationActive());\n }\n });\n };\n const onNodeChange = last$1(() => {\n const annotations = sort(registry.getNames());\n each$e(annotations, name => {\n updateCallbacks(name, data => {\n const prev = data.previous.get();\n identify(editor, Optional.some(name)).fold(() => {\n prev.each(uid => {\n fireNoAnnotation(name);\n data.previous.clear();\n toggleActiveAttr(uid, false);\n });\n }, ({uid, name, elements}) => {\n if (!is$2(prev, uid)) {\n prev.each(uid => toggleActiveAttr(uid, false));\n fireCallbacks(name, uid, elements);\n data.previous.set(uid);\n toggleActiveAttr(uid, true);\n }\n });\n return {\n previous: data.previous,\n listeners: data.listeners\n };\n });\n });\n }, 30);\n editor.on('remove', () => {\n onNodeChange.cancel();\n });\n editor.on('NodeChange', () => {\n onNodeChange.throttle();\n });\n const addListener = (name, f) => {\n updateCallbacks(name, data => ({\n previous: data.previous,\n listeners: data.listeners.concat([f])\n }));\n };\n return { addListener };\n };\n\n const setup$x = (editor, registry) => {\n const dataAnnotation$1 = dataAnnotation();\n const identifyParserNode = node => Optional.from(node.attr(dataAnnotation$1)).bind(registry.lookup);\n const removeDirectAnnotation = node => {\n var _a, _b;\n node.attr(dataAnnotationId(), null);\n node.attr(dataAnnotation(), null);\n node.attr(dataAnnotationActive(), null);\n const customAttrNames = Optional.from(node.attr(dataAnnotationAttributes())).map(names => names.split(',')).getOr([]);\n const customClasses = Optional.from(node.attr(dataAnnotationClasses())).map(names => names.split(',')).getOr([]);\n each$e(customAttrNames, name => node.attr(name, null));\n const classList = (_b = (_a = node.attr('class')) === null || _a === void 0 ? void 0 : _a.split(' ')) !== null && _b !== void 0 ? _b : [];\n const newClassList = difference(classList, [annotation()].concat(customClasses));\n node.attr('class', newClassList.length > 0 ? newClassList.join(' ') : null);\n node.attr(dataAnnotationClasses(), null);\n node.attr(dataAnnotationAttributes(), null);\n };\n editor.serializer.addTempAttr(dataAnnotationActive());\n editor.serializer.addAttributeFilter(dataAnnotation$1, nodes => {\n for (const node of nodes) {\n identifyParserNode(node).each(settings => {\n if (settings.persistent === false) {\n if (node.name === 'span') {\n node.unwrap();\n } else {\n removeDirectAnnotation(node);\n }\n }\n });\n }\n });\n };\n\n const create$c = () => {\n const annotations = {};\n const register = (name, settings) => {\n annotations[name] = {\n name,\n settings\n };\n };\n const lookup = name => get$a(annotations, name).map(a => a.settings);\n const getNames = () => keys(annotations);\n return {\n register,\n lookup,\n getNames\n };\n };\n\n let unique = 0;\n const generate$1 = prefix => {\n const date = new Date();\n const time = date.getTime();\n const random = Math.floor(Math.random() * 1000000000);\n unique++;\n return prefix + '_' + random + unique + String(time);\n };\n\n const add = (element, classes) => {\n each$e(classes, x => {\n add$2(element, x);\n });\n };\n const remove$4 = (element, classes) => {\n each$e(classes, x => {\n remove$7(element, x);\n });\n };\n\n const clone$2 = (original, isDeep) => SugarElement.fromDom(original.dom.cloneNode(isDeep));\n const shallow$1 = original => clone$2(original, false);\n const deep$1 = original => clone$2(original, true);\n const shallowAs = (original, tag) => {\n const nu = SugarElement.fromTag(tag);\n const attributes = clone$4(original);\n setAll$1(nu, attributes);\n return nu;\n };\n const mutate = (original, tag) => {\n const nu = shallowAs(original, tag);\n after$4(original, nu);\n const children = children$1(original);\n append(nu, children);\n remove$5(original);\n return nu;\n };\n\n const TextWalker = (startNode, rootNode, isBoundary = never) => {\n const walker = new DomTreeWalker(startNode, rootNode);\n const walk = direction => {\n let next;\n do {\n next = walker[direction]();\n } while (next && !isText$a(next) && !isBoundary(next));\n return Optional.from(next).filter(isText$a);\n };\n return {\n current: () => Optional.from(walker.current()).filter(isText$a),\n next: () => walk('next'),\n prev: () => walk('prev'),\n prev2: () => walk('prev2')\n };\n };\n\n const TextSeeker = (dom, isBoundary) => {\n const isBlockBoundary = isBoundary ? isBoundary : node => dom.isBlock(node) || isBr$6(node) || isContentEditableFalse$b(node);\n const walk = (node, offset, walker, process) => {\n if (isText$a(node)) {\n const newOffset = process(node, offset, node.data);\n if (newOffset !== -1) {\n return Optional.some({\n container: node,\n offset: newOffset\n });\n }\n }\n return walker().bind(next => walk(next.container, next.offset, walker, process));\n };\n const backwards = (node, offset, process, root) => {\n const walker = TextWalker(node, root !== null && root !== void 0 ? root : dom.getRoot(), isBlockBoundary);\n return walk(node, offset, () => walker.prev().map(prev => ({\n container: prev,\n offset: prev.length\n })), process).getOrNull();\n };\n const forwards = (node, offset, process, root) => {\n const walker = TextWalker(node, root !== null && root !== void 0 ? root : dom.getRoot(), isBlockBoundary);\n return walk(node, offset, () => walker.next().map(next => ({\n container: next,\n offset: 0\n })), process).getOrNull();\n };\n return {\n backwards,\n forwards\n };\n };\n\n const round$2 = Math.round;\n const clone$1 = rect => {\n if (!rect) {\n return {\n left: 0,\n top: 0,\n bottom: 0,\n right: 0,\n width: 0,\n height: 0\n };\n }\n return {\n left: round$2(rect.left),\n top: round$2(rect.top),\n bottom: round$2(rect.bottom),\n right: round$2(rect.right),\n width: round$2(rect.width),\n height: round$2(rect.height)\n };\n };\n const collapse = (rect, toStart) => {\n rect = clone$1(rect);\n if (toStart) {\n rect.right = rect.left;\n } else {\n rect.left = rect.left + rect.width;\n rect.right = rect.left;\n }\n rect.width = 0;\n return rect;\n };\n const isEqual = (rect1, rect2) => rect1.left === rect2.left && rect1.top === rect2.top && rect1.bottom === rect2.bottom && rect1.right === rect2.right;\n const isValidOverflow = (overflowY, rect1, rect2) => overflowY >= 0 && overflowY <= Math.min(rect1.height, rect2.height) / 2;\n const isAbove$1 = (rect1, rect2) => {\n const halfHeight = Math.min(rect2.height / 2, rect1.height / 2);\n if (rect1.bottom - halfHeight < rect2.top) {\n return true;\n }\n if (rect1.top > rect2.bottom) {\n return false;\n }\n return isValidOverflow(rect2.top - rect1.bottom, rect1, rect2);\n };\n const isBelow$1 = (rect1, rect2) => {\n if (rect1.top > rect2.bottom) {\n return true;\n }\n if (rect1.bottom < rect2.top) {\n return false;\n }\n return isValidOverflow(rect2.bottom - rect1.top, rect1, rect2);\n };\n const containsXY = (rect, clientX, clientY) => clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom;\n const boundingClientRectFromRects = rects => {\n return foldl(rects, (acc, rect) => {\n return acc.fold(() => Optional.some(rect), prevRect => {\n const left = Math.min(rect.left, prevRect.left);\n const top = Math.min(rect.top, prevRect.top);\n const right = Math.max(rect.right, prevRect.right);\n const bottom = Math.max(rect.bottom, prevRect.bottom);\n return Optional.some({\n top,\n right,\n bottom,\n left,\n width: right - left,\n height: bottom - top\n });\n });\n }, Optional.none());\n };\n const distanceToRectEdgeFromXY = (rect, x, y) => {\n const cx = Math.max(Math.min(x, rect.left + rect.width), rect.left);\n const cy = Math.max(Math.min(y, rect.top + rect.height), rect.top);\n return Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy));\n };\n const overlapY = (r1, r2) => Math.max(0, Math.min(r1.bottom, r2.bottom) - Math.max(r1.top, r2.top));\n\n const clamp$2 = (value, min, max) => Math.min(Math.max(value, min), max);\n\n const getSelectedNode = range => {\n const startContainer = range.startContainer, startOffset = range.startOffset;\n if (startContainer === range.endContainer && startContainer.hasChildNodes() && range.endOffset === startOffset + 1) {\n return startContainer.childNodes[startOffset];\n }\n return null;\n };\n const getNode$1 = (container, offset) => {\n if (isElement$6(container) && container.hasChildNodes()) {\n const childNodes = container.childNodes;\n const safeOffset = clamp$2(offset, 0, childNodes.length - 1);\n return childNodes[safeOffset];\n } else {\n return container;\n }\n };\n const getNodeUnsafe = (container, offset) => {\n if (offset < 0 && isElement$6(container) && container.hasChildNodes()) {\n return undefined;\n } else {\n return getNode$1(container, offset);\n }\n };\n\n const extendingChars = new RegExp('[\\u0300-\\u036f\\u0483-\\u0487\\u0488-\\u0489\\u0591-\\u05bd\\u05bf\\u05c1-\\u05c2\\u05c4-\\u05c5\\u05c7\\u0610-\\u061a' + '\\u064b-\\u065f\\u0670\\u06d6-\\u06dc\\u06df-\\u06e4\\u06e7-\\u06e8\\u06ea-\\u06ed\\u0711\\u0730-\\u074a\\u07a6-\\u07b0' + '\\u07eb-\\u07f3\\u0816-\\u0819\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0859-\\u085b\\u08e3-\\u0902\\u093a\\u093c' + '\\u0941-\\u0948\\u094d\\u0951-\\u0957\\u0962-\\u0963\\u0981\\u09bc\\u09be\\u09c1-\\u09c4\\u09cd\\u09d7\\u09e2-\\u09e3' + '\\u0a01-\\u0a02\\u0a3c\\u0a41-\\u0a42\\u0a47-\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a70-\\u0a71\\u0a75\\u0a81-\\u0a82\\u0abc' + '\\u0ac1-\\u0ac5\\u0ac7-\\u0ac8\\u0acd\\u0ae2-\\u0ae3\\u0b01\\u0b3c\\u0b3e\\u0b3f\\u0b41-\\u0b44\\u0b4d\\u0b56\\u0b57' + '\\u0b62-\\u0b63\\u0b82\\u0bbe\\u0bc0\\u0bcd\\u0bd7\\u0c00\\u0c3e-\\u0c40\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55-\\u0c56' + '\\u0c62-\\u0c63\\u0c81\\u0cbc\\u0cbf\\u0cc2\\u0cc6\\u0ccc-\\u0ccd\\u0cd5-\\u0cd6\\u0ce2-\\u0ce3\\u0d01\\u0d3e\\u0d41-\\u0d44' + '\\u0d4d\\u0d57\\u0d62-\\u0d63\\u0dca\\u0dcf\\u0dd2-\\u0dd4\\u0dd6\\u0ddf\\u0e31\\u0e34-\\u0e3a\\u0e47-\\u0e4e\\u0eb1\\u0eb4-\\u0eb9' + '\\u0ebb-\\u0ebc\\u0ec8-\\u0ecd\\u0f18-\\u0f19\\u0f35\\u0f37\\u0f39\\u0f71-\\u0f7e\\u0f80-\\u0f84\\u0f86-\\u0f87\\u0f8d-\\u0f97' + '\\u0f99-\\u0fbc\\u0fc6\\u102d-\\u1030\\u1032-\\u1037\\u1039-\\u103a\\u103d-\\u103e\\u1058-\\u1059\\u105e-\\u1060\\u1071-\\u1074' + '\\u1082\\u1085-\\u1086\\u108d\\u109d\\u135d-\\u135f\\u1712-\\u1714\\u1732-\\u1734\\u1752-\\u1753\\u1772-\\u1773\\u17b4-\\u17b5' + '\\u17b7-\\u17bd\\u17c6\\u17c9-\\u17d3\\u17dd\\u180b-\\u180d\\u18a9\\u1920-\\u1922\\u1927-\\u1928\\u1932\\u1939-\\u193b\\u1a17-\\u1a18' + '\\u1a1b\\u1a56\\u1a58-\\u1a5e\\u1a60\\u1a62\\u1a65-\\u1a6c\\u1a73-\\u1a7c\\u1a7f\\u1ab0-\\u1abd\\u1ABE\\u1b00-\\u1b03\\u1b34' + '\\u1b36-\\u1b3a\\u1b3c\\u1b42\\u1b6b-\\u1b73\\u1b80-\\u1b81\\u1ba2-\\u1ba5\\u1ba8-\\u1ba9\\u1bab-\\u1bad\\u1be6\\u1be8-\\u1be9' + '\\u1bed\\u1bef-\\u1bf1\\u1c2c-\\u1c33\\u1c36-\\u1c37\\u1cd0-\\u1cd2\\u1cd4-\\u1ce0\\u1ce2-\\u1ce8\\u1ced\\u1cf4\\u1cf8-\\u1cf9' + '\\u1dc0-\\u1df5\\u1dfc-\\u1dff\\u200c-\\u200d\\u20d0-\\u20dc\\u20DD-\\u20E0\\u20e1\\u20E2-\\u20E4\\u20e5-\\u20f0\\u2cef-\\u2cf1' + '\\u2d7f\\u2de0-\\u2dff\\u302a-\\u302d\\u302e-\\u302f\\u3099-\\u309a\\ua66f\\uA670-\\uA672\\ua674-\\ua67d\\ua69e-\\ua69f\\ua6f0-\\ua6f1' + '\\ua802\\ua806\\ua80b\\ua825-\\ua826\\ua8c4\\ua8e0-\\ua8f1\\ua926-\\ua92d\\ua947-\\ua951\\ua980-\\ua982\\ua9b3\\ua9b6-\\ua9b9\\ua9bc' + '\\ua9e5\\uaa29-\\uaa2e\\uaa31-\\uaa32\\uaa35-\\uaa36\\uaa43\\uaa4c\\uaa7c\\uaab0\\uaab2-\\uaab4\\uaab7-\\uaab8\\uaabe-\\uaabf\\uaac1' + '\\uaaec-\\uaaed\\uaaf6\\uabe5\\uabe8\\uabed\\ufb1e\\ufe00-\\ufe0f\\ufe20-\\ufe2f\\uff9e-\\uff9f]');\n const isExtendingChar = ch => isString(ch) && ch.charCodeAt(0) >= 768 && extendingChars.test(ch);\n\n const or = (...args) => {\n return x => {\n for (let i = 0; i < args.length; i++) {\n if (args[i](x)) {\n return true;\n }\n }\n return false;\n };\n };\n const and = (...args) => {\n return x => {\n for (let i = 0; i < args.length; i++) {\n if (!args[i](x)) {\n return false;\n }\n }\n return true;\n };\n };\n\n const isElement$4 = isElement$6;\n const isCaretCandidate$2 = isCaretCandidate$3;\n const isBlock$2 = matchStyleValues('display', 'block table');\n const isFloated = matchStyleValues('float', 'left right');\n const isValidElementCaretCandidate = and(isElement$4, isCaretCandidate$2, not(isFloated));\n const isNotPre = not(matchStyleValues('white-space', 'pre pre-line pre-wrap'));\n const isText$7 = isText$a;\n const isBr$3 = isBr$6;\n const nodeIndex$1 = DOMUtils.nodeIndex;\n const resolveIndex$1 = getNodeUnsafe;\n const createRange$1 = doc => doc ? doc.createRange() : DOMUtils.DOM.createRng();\n const isWhiteSpace$1 = chr => isString(chr) && /[\\r\\n\\t ]/.test(chr);\n const isRange = rng => !!rng.setStart && !!rng.setEnd;\n const isHiddenWhiteSpaceRange = range => {\n const container = range.startContainer;\n const offset = range.startOffset;\n if (isWhiteSpace$1(range.toString()) && isNotPre(container.parentNode) && isText$a(container)) {\n const text = container.data;\n if (isWhiteSpace$1(text[offset - 1]) || isWhiteSpace$1(text[offset + 1])) {\n return true;\n }\n }\n return false;\n };\n const getBrClientRect = brNode => {\n const doc = brNode.ownerDocument;\n const rng = createRange$1(doc);\n const nbsp$1 = doc.createTextNode(nbsp);\n const parentNode = brNode.parentNode;\n parentNode.insertBefore(nbsp$1, brNode);\n rng.setStart(nbsp$1, 0);\n rng.setEnd(nbsp$1, 1);\n const clientRect = clone$1(rng.getBoundingClientRect());\n parentNode.removeChild(nbsp$1);\n return clientRect;\n };\n const getBoundingClientRectWebKitText = rng => {\n const sc = rng.startContainer;\n const ec = rng.endContainer;\n const so = rng.startOffset;\n const eo = rng.endOffset;\n if (sc === ec && isText$a(ec) && so === 0 && eo === 1) {\n const newRng = rng.cloneRange();\n newRng.setEndAfter(ec);\n return getBoundingClientRect$1(newRng);\n } else {\n return null;\n }\n };\n const isZeroRect = r => r.left === 0 && r.right === 0 && r.top === 0 && r.bottom === 0;\n const getBoundingClientRect$1 = item => {\n var _a;\n let clientRect;\n const clientRects = item.getClientRects();\n if (clientRects.length > 0) {\n clientRect = clone$1(clientRects[0]);\n } else {\n clientRect = clone$1(item.getBoundingClientRect());\n }\n if (!isRange(item) && isBr$3(item) && isZeroRect(clientRect)) {\n return getBrClientRect(item);\n }\n if (isZeroRect(clientRect) && isRange(item)) {\n return (_a = getBoundingClientRectWebKitText(item)) !== null && _a !== void 0 ? _a : clientRect;\n }\n return clientRect;\n };\n const collapseAndInflateWidth = (clientRect, toStart) => {\n const newClientRect = collapse(clientRect, toStart);\n newClientRect.width = 1;\n newClientRect.right = newClientRect.left + 1;\n return newClientRect;\n };\n const getCaretPositionClientRects = caretPosition => {\n const clientRects = [];\n const addUniqueAndValidRect = clientRect => {\n if (clientRect.height === 0) {\n return;\n }\n if (clientRects.length > 0) {\n if (isEqual(clientRect, clientRects[clientRects.length - 1])) {\n return;\n }\n }\n clientRects.push(clientRect);\n };\n const addCharacterOffset = (container, offset) => {\n const range = createRange$1(container.ownerDocument);\n if (offset < container.data.length) {\n if (isExtendingChar(container.data[offset])) {\n return;\n }\n if (isExtendingChar(container.data[offset - 1])) {\n range.setStart(container, offset);\n range.setEnd(container, offset + 1);\n if (!isHiddenWhiteSpaceRange(range)) {\n addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(range), false));\n return;\n }\n }\n }\n if (offset > 0) {\n range.setStart(container, offset - 1);\n range.setEnd(container, offset);\n if (!isHiddenWhiteSpaceRange(range)) {\n addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(range), false));\n }\n }\n if (offset < container.data.length) {\n range.setStart(container, offset);\n range.setEnd(container, offset + 1);\n if (!isHiddenWhiteSpaceRange(range)) {\n addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(range), true));\n }\n }\n };\n const container = caretPosition.container();\n const offset = caretPosition.offset();\n if (isText$7(container)) {\n addCharacterOffset(container, offset);\n return clientRects;\n }\n if (isElement$4(container)) {\n if (caretPosition.isAtEnd()) {\n const node = resolveIndex$1(container, offset);\n if (isText$7(node)) {\n addCharacterOffset(node, node.data.length);\n }\n if (isValidElementCaretCandidate(node) && !isBr$3(node)) {\n addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(node), false));\n }\n } else {\n const node = resolveIndex$1(container, offset);\n if (isText$7(node)) {\n addCharacterOffset(node, 0);\n }\n if (isValidElementCaretCandidate(node) && caretPosition.isAtEnd()) {\n addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(node), false));\n return clientRects;\n }\n const beforeNode = resolveIndex$1(caretPosition.container(), caretPosition.offset() - 1);\n if (isValidElementCaretCandidate(beforeNode) && !isBr$3(beforeNode)) {\n if (isBlock$2(beforeNode) || isBlock$2(node) || !isValidElementCaretCandidate(node)) {\n addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(beforeNode), false));\n }\n }\n if (isValidElementCaretCandidate(node)) {\n addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect$1(node), true));\n }\n }\n }\n return clientRects;\n };\n const CaretPosition = (container, offset, clientRects) => {\n const isAtStart = () => {\n if (isText$7(container)) {\n return offset === 0;\n }\n return offset === 0;\n };\n const isAtEnd = () => {\n if (isText$7(container)) {\n return offset >= container.data.length;\n }\n return offset >= container.childNodes.length;\n };\n const toRange = () => {\n const range = createRange$1(container.ownerDocument);\n range.setStart(container, offset);\n range.setEnd(container, offset);\n return range;\n };\n const getClientRects = () => {\n if (!clientRects) {\n clientRects = getCaretPositionClientRects(CaretPosition(container, offset));\n }\n return clientRects;\n };\n const isVisible = () => getClientRects().length > 0;\n const isEqual = caretPosition => caretPosition && container === caretPosition.container() && offset === caretPosition.offset();\n const getNode = before => resolveIndex$1(container, before ? offset - 1 : offset);\n return {\n container: constant(container),\n offset: constant(offset),\n toRange,\n getClientRects,\n isVisible,\n isAtStart,\n isAtEnd,\n isEqual,\n getNode\n };\n };\n CaretPosition.fromRangeStart = range => CaretPosition(range.startContainer, range.startOffset);\n CaretPosition.fromRangeEnd = range => CaretPosition(range.endContainer, range.endOffset);\n CaretPosition.after = node => CaretPosition(node.parentNode, nodeIndex$1(node) + 1);\n CaretPosition.before = node => CaretPosition(node.parentNode, nodeIndex$1(node));\n CaretPosition.isAbove = (pos1, pos2) => lift2(head(pos2.getClientRects()), last$3(pos1.getClientRects()), isAbove$1).getOr(false);\n CaretPosition.isBelow = (pos1, pos2) => lift2(last$3(pos2.getClientRects()), head(pos1.getClientRects()), isBelow$1).getOr(false);\n CaretPosition.isAtStart = pos => pos ? pos.isAtStart() : false;\n CaretPosition.isAtEnd = pos => pos ? pos.isAtEnd() : false;\n CaretPosition.isTextPosition = pos => pos ? isText$a(pos.container()) : false;\n CaretPosition.isElementPosition = pos => !CaretPosition.isTextPosition(pos);\n\n const trimEmptyTextNode$1 = (dom, node) => {\n if (isText$a(node) && node.data.length === 0) {\n dom.remove(node);\n }\n };\n const insertNode = (dom, rng, node) => {\n rng.insertNode(node);\n trimEmptyTextNode$1(dom, node.previousSibling);\n trimEmptyTextNode$1(dom, node.nextSibling);\n };\n const insertFragment = (dom, rng, frag) => {\n const firstChild = Optional.from(frag.firstChild);\n const lastChild = Optional.from(frag.lastChild);\n rng.insertNode(frag);\n firstChild.each(child => trimEmptyTextNode$1(dom, child.previousSibling));\n lastChild.each(child => trimEmptyTextNode$1(dom, child.nextSibling));\n };\n const rangeInsertNode = (dom, rng, node) => {\n if (isDocumentFragment(node)) {\n insertFragment(dom, rng, node);\n } else {\n insertNode(dom, rng, node);\n }\n };\n\n const isText$6 = isText$a;\n const isBogus = isBogus$2;\n const nodeIndex = DOMUtils.nodeIndex;\n const normalizedParent = node => {\n const parentNode = node.parentNode;\n if (isBogus(parentNode)) {\n return normalizedParent(parentNode);\n }\n return parentNode;\n };\n const getChildNodes = node => {\n if (!node) {\n return [];\n }\n return reduce(node.childNodes, (result, node) => {\n if (isBogus(node) && node.nodeName !== 'BR') {\n result = result.concat(getChildNodes(node));\n } else {\n result.push(node);\n }\n return result;\n }, []);\n };\n const normalizedTextOffset = (node, offset) => {\n let tempNode = node;\n while (tempNode = tempNode.previousSibling) {\n if (!isText$6(tempNode)) {\n break;\n }\n offset += tempNode.data.length;\n }\n return offset;\n };\n const equal = a => b => a === b;\n const normalizedNodeIndex = node => {\n let nodes, index;\n nodes = getChildNodes(normalizedParent(node));\n index = findIndex$1(nodes, equal(node), node);\n nodes = nodes.slice(0, index + 1);\n const numTextFragments = reduce(nodes, (result, node, i) => {\n if (isText$6(node) && isText$6(nodes[i - 1])) {\n result++;\n }\n return result;\n }, 0);\n nodes = filter$3(nodes, matchNodeNames([node.nodeName]));\n index = findIndex$1(nodes, equal(node), node);\n return index - numTextFragments;\n };\n const createPathItem = node => {\n const name = isText$6(node) ? 'text()' : node.nodeName.toLowerCase();\n return name + '[' + normalizedNodeIndex(node) + ']';\n };\n const parentsUntil$1 = (root, node, predicate) => {\n const parents = [];\n for (let tempNode = node.parentNode; tempNode && tempNode !== root; tempNode = tempNode.parentNode) {\n if (predicate && predicate(tempNode)) {\n break;\n }\n parents.push(tempNode);\n }\n return parents;\n };\n const create$b = (root, caretPosition) => {\n let path = [];\n let container = caretPosition.container();\n let offset = caretPosition.offset();\n let outputOffset;\n if (isText$6(container)) {\n outputOffset = normalizedTextOffset(container, offset);\n } else {\n const childNodes = container.childNodes;\n if (offset >= childNodes.length) {\n outputOffset = 'after';\n offset = childNodes.length - 1;\n } else {\n outputOffset = 'before';\n }\n container = childNodes[offset];\n }\n path.push(createPathItem(container));\n let parents = parentsUntil$1(root, container);\n parents = filter$3(parents, not(isBogus$2));\n path = path.concat(map$1(parents, node => {\n return createPathItem(node);\n }));\n return path.reverse().join('/') + ',' + outputOffset;\n };\n const resolvePathItem = (node, name, index) => {\n let nodes = getChildNodes(node);\n nodes = filter$3(nodes, (node, index) => {\n return !isText$6(node) || !isText$6(nodes[index - 1]);\n });\n nodes = filter$3(nodes, matchNodeNames([name]));\n return nodes[index];\n };\n const findTextPosition = (container, offset) => {\n let node = container;\n let targetOffset = 0;\n while (isText$6(node)) {\n const dataLen = node.data.length;\n if (offset >= targetOffset && offset <= targetOffset + dataLen) {\n container = node;\n offset = offset - targetOffset;\n break;\n }\n if (!isText$6(node.nextSibling)) {\n container = node;\n offset = dataLen;\n break;\n }\n targetOffset += dataLen;\n node = node.nextSibling;\n }\n if (isText$6(container) && offset > container.data.length) {\n offset = container.data.length;\n }\n return CaretPosition(container, offset);\n };\n const resolve$1 = (root, path) => {\n if (!path) {\n return null;\n }\n const parts = path.split(',');\n const paths = parts[0].split('/');\n const offset = parts.length > 1 ? parts[1] : 'before';\n const container = reduce(paths, (result, value) => {\n const match = /([\\w\\-\\(\\)]+)\\[([0-9]+)\\]/.exec(value);\n if (!match) {\n return null;\n }\n if (match[1] === 'text()') {\n match[1] = '#text';\n }\n return resolvePathItem(result, match[1], parseInt(match[2], 10));\n }, root);\n if (!container) {\n return null;\n }\n if (!isText$6(container) && container.parentNode) {\n let nodeOffset;\n if (offset === 'after') {\n nodeOffset = nodeIndex(container) + 1;\n } else {\n nodeOffset = nodeIndex(container);\n }\n return CaretPosition(container.parentNode, nodeOffset);\n }\n return findTextPosition(container, parseInt(offset, 10));\n };\n\n const isContentEditableFalse$9 = isContentEditableFalse$b;\n const getNormalizedTextOffset$1 = (trim, container, offset) => {\n let trimmedOffset = trim(container.data.slice(0, offset)).length;\n for (let node = container.previousSibling; node && isText$a(node); node = node.previousSibling) {\n trimmedOffset += trim(node.data).length;\n }\n return trimmedOffset;\n };\n const getPoint = (dom, trim, normalized, rng, start) => {\n const container = start ? rng.startContainer : rng.endContainer;\n let offset = start ? rng.startOffset : rng.endOffset;\n const point = [];\n const root = dom.getRoot();\n if (isText$a(container)) {\n point.push(normalized ? getNormalizedTextOffset$1(trim, container, offset) : offset);\n } else {\n let after = 0;\n const childNodes = container.childNodes;\n if (offset >= childNodes.length && childNodes.length) {\n after = 1;\n offset = Math.max(0, childNodes.length - 1);\n }\n point.push(dom.nodeIndex(childNodes[offset], normalized) + after);\n }\n for (let node = container; node && node !== root; node = node.parentNode) {\n point.push(dom.nodeIndex(node, normalized));\n }\n return point;\n };\n const getLocation = (trim, selection, normalized, rng) => {\n const dom = selection.dom;\n const start = getPoint(dom, trim, normalized, rng, true);\n const forward = selection.isForward();\n const fakeCaret = isRangeInCaretContainerBlock(rng) ? { isFakeCaret: true } : {};\n if (!selection.isCollapsed()) {\n const end = getPoint(dom, trim, normalized, rng, false);\n return {\n start,\n end,\n forward,\n ...fakeCaret\n };\n } else {\n return {\n start,\n forward,\n ...fakeCaret\n };\n }\n };\n const findIndex = (dom, name, element) => {\n let count = 0;\n Tools.each(dom.select(name), node => {\n if (node.getAttribute('data-mce-bogus') === 'all') {\n return;\n } else if (node === element) {\n return false;\n } else {\n count++;\n return;\n }\n });\n return count;\n };\n const moveEndPoint$1 = (rng, start) => {\n let container = start ? rng.startContainer : rng.endContainer;\n let offset = start ? rng.startOffset : rng.endOffset;\n if (isElement$6(container) && container.nodeName === 'TR') {\n const childNodes = container.childNodes;\n container = childNodes[Math.min(start ? offset : offset - 1, childNodes.length - 1)];\n if (container) {\n offset = start ? 0 : container.childNodes.length;\n if (start) {\n rng.setStart(container, offset);\n } else {\n rng.setEnd(container, offset);\n }\n }\n }\n };\n const normalizeTableCellSelection = rng => {\n moveEndPoint$1(rng, true);\n moveEndPoint$1(rng, false);\n return rng;\n };\n const findSibling = (node, offset) => {\n if (isElement$6(node)) {\n node = getNode$1(node, offset);\n if (isContentEditableFalse$9(node)) {\n return node;\n }\n }\n if (isCaretContainer$2(node)) {\n if (isText$a(node) && isCaretContainerBlock$1(node)) {\n node = node.parentNode;\n }\n let sibling = node.previousSibling;\n if (isContentEditableFalse$9(sibling)) {\n return sibling;\n }\n sibling = node.nextSibling;\n if (isContentEditableFalse$9(sibling)) {\n return sibling;\n }\n }\n return undefined;\n };\n const findAdjacentContentEditableFalseElm = rng => {\n return findSibling(rng.startContainer, rng.startOffset) || findSibling(rng.endContainer, rng.endOffset);\n };\n const getOffsetBookmark = (trim, normalized, selection) => {\n const element = selection.getNode();\n const rng = selection.getRng();\n if (element.nodeName === 'IMG' || isContentEditableFalse$9(element)) {\n const name = element.nodeName;\n return {\n name,\n index: findIndex(selection.dom, name, element)\n };\n }\n const sibling = findAdjacentContentEditableFalseElm(rng);\n if (sibling) {\n const name = sibling.tagName;\n return {\n name,\n index: findIndex(selection.dom, name, sibling)\n };\n }\n return getLocation(trim, selection, normalized, rng);\n };\n const getCaretBookmark = selection => {\n const rng = selection.getRng();\n return {\n start: create$b(selection.dom.getRoot(), CaretPosition.fromRangeStart(rng)),\n end: create$b(selection.dom.getRoot(), CaretPosition.fromRangeEnd(rng)),\n forward: selection.isForward()\n };\n };\n const getRangeBookmark = selection => {\n return {\n rng: selection.getRng(),\n forward: selection.isForward()\n };\n };\n const createBookmarkSpan = (dom, id, filled) => {\n const args = {\n 'data-mce-type': 'bookmark',\n id,\n 'style': 'overflow:hidden;line-height:0px'\n };\n return filled ? dom.create('span', args, '') : dom.create('span', args);\n };\n const getPersistentBookmark = (selection, filled) => {\n const dom = selection.dom;\n let rng = selection.getRng();\n const id = dom.uniqueId();\n const collapsed = selection.isCollapsed();\n const element = selection.getNode();\n const name = element.nodeName;\n const forward = selection.isForward();\n if (name === 'IMG') {\n return {\n name,\n index: findIndex(dom, name, element)\n };\n }\n const rng2 = normalizeTableCellSelection(rng.cloneRange());\n if (!collapsed) {\n rng2.collapse(false);\n const endBookmarkNode = createBookmarkSpan(dom, id + '_end', filled);\n rangeInsertNode(dom, rng2, endBookmarkNode);\n }\n rng = normalizeTableCellSelection(rng);\n rng.collapse(true);\n const startBookmarkNode = createBookmarkSpan(dom, id + '_start', filled);\n rangeInsertNode(dom, rng, startBookmarkNode);\n selection.moveToBookmark({\n id,\n keep: true,\n forward\n });\n return {\n id,\n forward\n };\n };\n const getBookmark$2 = (selection, type, normalized = false) => {\n if (type === 2) {\n return getOffsetBookmark(trim$2, normalized, selection);\n } else if (type === 3) {\n return getCaretBookmark(selection);\n } else if (type) {\n return getRangeBookmark(selection);\n } else {\n return getPersistentBookmark(selection, false);\n }\n };\n const getUndoBookmark = curry(getOffsetBookmark, identity, true);\n\n const value$1 = value => {\n const applyHelper = fn => fn(value);\n const constHelper = constant(value);\n const outputHelper = () => output;\n const output = {\n tag: true,\n inner: value,\n fold: (_onError, onValue) => onValue(value),\n isValue: always,\n isError: never,\n map: mapper => Result.value(mapper(value)),\n mapError: outputHelper,\n bind: applyHelper,\n exists: applyHelper,\n forall: applyHelper,\n getOr: constHelper,\n or: outputHelper,\n getOrThunk: constHelper,\n orThunk: outputHelper,\n getOrDie: constHelper,\n each: fn => {\n fn(value);\n },\n toOptional: () => Optional.some(value)\n };\n return output;\n };\n const error = error => {\n const outputHelper = () => output;\n const output = {\n tag: false,\n inner: error,\n fold: (onError, _onValue) => onError(error),\n isValue: never,\n isError: always,\n map: outputHelper,\n mapError: mapper => Result.error(mapper(error)),\n bind: outputHelper,\n exists: never,\n forall: always,\n getOr: identity,\n or: identity,\n getOrThunk: apply$1,\n orThunk: apply$1,\n getOrDie: die(String(error)),\n each: noop,\n toOptional: Optional.none\n };\n return output;\n };\n const fromOption = (optional, err) => optional.fold(() => error(err), value$1);\n const Result = {\n value: value$1,\n error,\n fromOption\n };\n\n const generate = cases => {\n if (!isArray$1(cases)) {\n throw new Error('cases must be an array');\n }\n if (cases.length === 0) {\n throw new Error('there must be at least one case');\n }\n const constructors = [];\n const adt = {};\n each$e(cases, (acase, count) => {\n const keys$1 = keys(acase);\n if (keys$1.length !== 1) {\n throw new Error('one and only one name per case');\n }\n const key = keys$1[0];\n const value = acase[key];\n if (adt[key] !== undefined) {\n throw new Error('duplicate key detected:' + key);\n } else if (key === 'cata') {\n throw new Error('cannot have a case named cata (sorry)');\n } else if (!isArray$1(value)) {\n throw new Error('case arguments must be an array');\n }\n constructors.push(key);\n adt[key] = (...args) => {\n const argLength = args.length;\n if (argLength !== value.length) {\n throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength);\n }\n const match = branches => {\n const branchKeys = keys(branches);\n if (constructors.length !== branchKeys.length) {\n throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\\nActual: ' + branchKeys.join(','));\n }\n const allReqd = forall(constructors, reqKey => {\n return contains$2(branchKeys, reqKey);\n });\n if (!allReqd) {\n throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\\nRequired: ' + constructors.join(', '));\n }\n return branches[key].apply(null, args);\n };\n return {\n fold: (...foldArgs) => {\n if (foldArgs.length !== cases.length) {\n throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length);\n }\n const target = foldArgs[count];\n return target.apply(null, args);\n },\n match,\n log: label => {\n console.log(label, {\n constructors,\n constructor: key,\n params: args\n });\n }\n };\n };\n });\n return adt;\n };\n const Adt = { generate };\n\n Adt.generate([\n {\n bothErrors: [\n 'error1',\n 'error2'\n ]\n },\n {\n firstError: [\n 'error1',\n 'value2'\n ]\n },\n {\n secondError: [\n 'value1',\n 'error2'\n ]\n },\n {\n bothValues: [\n 'value1',\n 'value2'\n ]\n }\n ]);\n const partition$1 = results => {\n const errors = [];\n const values = [];\n each$e(results, result => {\n result.fold(err => {\n errors.push(err);\n }, value => {\n values.push(value);\n });\n });\n return {\n errors,\n values\n };\n };\n\n const isInlinePattern = pattern => pattern.type === 'inline-command' || pattern.type === 'inline-format';\n const isBlockPattern = pattern => pattern.type === 'block-command' || pattern.type === 'block-format';\n const normalizePattern = pattern => {\n const err = message => Result.error({\n message,\n pattern\n });\n const formatOrCmd = (name, onFormat, onCommand) => {\n if (pattern.format !== undefined) {\n let formats;\n if (isArray$1(pattern.format)) {\n if (!forall(pattern.format, isString)) {\n return err(name + ' pattern has non-string items in the `format` array');\n }\n formats = pattern.format;\n } else if (isString(pattern.format)) {\n formats = [pattern.format];\n } else {\n return err(name + ' pattern has non-string `format` parameter');\n }\n return Result.value(onFormat(formats));\n } else if (pattern.cmd !== undefined) {\n if (!isString(pattern.cmd)) {\n return err(name + ' pattern has non-string `cmd` parameter');\n }\n return Result.value(onCommand(pattern.cmd, pattern.value));\n } else {\n return err(name + ' pattern is missing both `format` and `cmd` parameters');\n }\n };\n if (!isObject(pattern)) {\n return err('Raw pattern is not an object');\n }\n if (!isString(pattern.start)) {\n return err('Raw pattern is missing `start` parameter');\n }\n if (pattern.end !== undefined) {\n if (!isString(pattern.end)) {\n return err('Inline pattern has non-string `end` parameter');\n }\n if (pattern.start.length === 0 && pattern.end.length === 0) {\n return err('Inline pattern has empty `start` and `end` parameters');\n }\n let start = pattern.start;\n let end = pattern.end;\n if (end.length === 0) {\n end = start;\n start = '';\n }\n return formatOrCmd('Inline', format => ({\n type: 'inline-format',\n start,\n end,\n format\n }), (cmd, value) => ({\n type: 'inline-command',\n start,\n end,\n cmd,\n value\n }));\n } else if (pattern.replacement !== undefined) {\n if (!isString(pattern.replacement)) {\n return err('Replacement pattern has non-string `replacement` parameter');\n }\n if (pattern.start.length === 0) {\n return err('Replacement pattern has empty `start` parameter');\n }\n return Result.value({\n type: 'inline-command',\n start: '',\n end: pattern.start,\n cmd: 'mceInsertContent',\n value: pattern.replacement\n });\n } else {\n if (pattern.start.length === 0) {\n return err('Block pattern has empty `start` parameter');\n }\n return formatOrCmd('Block', formats => ({\n type: 'block-format',\n start: pattern.start,\n format: formats[0]\n }), (command, commandValue) => ({\n type: 'block-command',\n start: pattern.start,\n cmd: command,\n value: commandValue\n }));\n }\n };\n const getBlockPatterns = patterns => filter$5(patterns, isBlockPattern);\n const getInlinePatterns = patterns => filter$5(patterns, isInlinePattern);\n const createPatternSet = (patterns, dynamicPatternsLookup) => ({\n inlinePatterns: getInlinePatterns(patterns),\n blockPatterns: getBlockPatterns(patterns),\n dynamicPatternsLookup\n });\n const fromRawPatterns = patterns => {\n const normalized = partition$1(map$3(patterns, normalizePattern));\n each$e(normalized.errors, err => console.error(err.message, err.pattern));\n return normalized.values;\n };\n const fromRawPatternsLookup = lookupFn => {\n return ctx => {\n const rawPatterns = lookupFn(ctx);\n return fromRawPatterns(rawPatterns);\n };\n };\n\n const deviceDetection$1 = detect$2().deviceType;\n const isTouch = deviceDetection$1.isTouch();\n const DOM$a = DOMUtils.DOM;\n const getHash = value => {\n const items = value.indexOf('=') > 0 ? value.split(/[;,](?![^=;,]*(?:[;,]|$))/) : value.split(',');\n return foldl(items, (output, item) => {\n const arr = item.split('=');\n const key = arr[0];\n const val = arr.length > 1 ? arr[1] : key;\n output[trim$4(key)] = trim$4(val);\n return output;\n }, {});\n };\n const isRegExp = x => is$4(x, RegExp);\n const option = name => editor => editor.options.get(name);\n const stringOrObjectProcessor = value => isString(value) || isObject(value);\n const bodyOptionProcessor = (editor, defaultValue = '') => value => {\n const valid = isString(value);\n if (valid) {\n if (value.indexOf('=') !== -1) {\n const bodyObj = getHash(value);\n return {\n value: get$a(bodyObj, editor.id).getOr(defaultValue),\n valid\n };\n } else {\n return {\n value,\n valid\n };\n }\n } else {\n return {\n valid: false,\n message: 'Must be a string.'\n };\n }\n };\n const register$7 = editor => {\n const registerOption = editor.options.register;\n registerOption('id', {\n processor: 'string',\n default: editor.id\n });\n registerOption('selector', { processor: 'string' });\n registerOption('target', { processor: 'object' });\n registerOption('suffix', { processor: 'string' });\n registerOption('cache_suffix', { processor: 'string' });\n registerOption('base_url', { processor: 'string' });\n registerOption('referrer_policy', {\n processor: 'string',\n default: ''\n });\n registerOption('language_load', {\n processor: 'boolean',\n default: true\n });\n registerOption('inline', {\n processor: 'boolean',\n default: false\n });\n registerOption('iframe_attrs', {\n processor: 'object',\n default: {}\n });\n registerOption('doctype', {\n processor: 'string',\n default: ''\n });\n registerOption('document_base_url', {\n processor: 'string',\n default: editor.documentBaseUrl\n });\n registerOption('body_id', {\n processor: bodyOptionProcessor(editor, 'tinymce'),\n default: 'tinymce'\n });\n registerOption('body_class', {\n processor: bodyOptionProcessor(editor),\n default: ''\n });\n registerOption('content_security_policy', {\n processor: 'string',\n default: ''\n });\n registerOption('br_in_pre', {\n processor: 'boolean',\n default: true\n });\n registerOption('forced_root_block', {\n processor: value => {\n const valid = isString(value) && isNotEmpty(value);\n if (valid) {\n return {\n value,\n valid\n };\n } else {\n return {\n valid: false,\n message: 'Must be a non-empty string.'\n };\n }\n },\n default: 'p'\n });\n registerOption('forced_root_block_attrs', {\n processor: 'object',\n default: {}\n });\n registerOption('newline_behavior', {\n processor: value => {\n const valid = contains$2([\n 'block',\n 'linebreak',\n 'invert',\n 'default'\n ], value);\n return valid ? {\n value,\n valid\n } : {\n valid: false,\n message: 'Must be one of: block, linebreak, invert or default.'\n };\n },\n default: 'default'\n });\n registerOption('br_newline_selector', {\n processor: 'string',\n default: '.mce-toc h2,figcaption,caption'\n });\n registerOption('no_newline_selector', {\n processor: 'string',\n default: ''\n });\n registerOption('keep_styles', {\n processor: 'boolean',\n default: true\n });\n registerOption('end_container_on_empty_block', {\n processor: value => {\n if (isBoolean(value)) {\n return {\n valid: true,\n value\n };\n } else if (isString(value)) {\n return {\n valid: true,\n value\n };\n } else {\n return {\n valid: false,\n message: 'Must be boolean or a string'\n };\n }\n },\n default: 'blockquote'\n });\n registerOption('font_size_style_values', {\n processor: 'string',\n default: 'xx-small,x-small,small,medium,large,x-large,xx-large'\n });\n registerOption('font_size_legacy_values', {\n processor: 'string',\n default: 'xx-small,small,medium,large,x-large,xx-large,300%'\n });\n registerOption('font_size_classes', {\n processor: 'string',\n default: ''\n });\n registerOption('automatic_uploads', {\n processor: 'boolean',\n default: true\n });\n registerOption('images_reuse_filename', {\n processor: 'boolean',\n default: false\n });\n registerOption('images_replace_blob_uris', {\n processor: 'boolean',\n default: true\n });\n registerOption('icons', {\n processor: 'string',\n default: ''\n });\n registerOption('icons_url', {\n processor: 'string',\n default: ''\n });\n registerOption('images_upload_url', {\n processor: 'string',\n default: ''\n });\n registerOption('images_upload_base_path', {\n processor: 'string',\n default: ''\n });\n registerOption('images_upload_credentials', {\n processor: 'boolean',\n default: false\n });\n registerOption('images_upload_handler', { processor: 'function' });\n registerOption('language', {\n processor: 'string',\n default: 'en'\n });\n registerOption('language_url', {\n processor: 'string',\n default: ''\n });\n registerOption('entity_encoding', {\n processor: 'string',\n default: 'named'\n });\n registerOption('indent', {\n processor: 'boolean',\n default: true\n });\n registerOption('indent_before', {\n processor: 'string',\n default: 'p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' + 'tfoot,tbody,tr,section,details,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist'\n });\n registerOption('indent_after', {\n processor: 'string',\n default: 'p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' + 'tfoot,tbody,tr,section,details,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist'\n });\n registerOption('indent_use_margin', {\n processor: 'boolean',\n default: false\n });\n registerOption('indentation', {\n processor: 'string',\n default: '40px'\n });\n registerOption('content_css', {\n processor: value => {\n const valid = value === false || isString(value) || isArrayOf(value, isString);\n if (valid) {\n if (isString(value)) {\n return {\n value: map$3(value.split(','), trim$4),\n valid\n };\n } else if (isArray$1(value)) {\n return {\n value,\n valid\n };\n } else if (value === false) {\n return {\n value: [],\n valid\n };\n } else {\n return {\n value,\n valid\n };\n }\n } else {\n return {\n valid: false,\n message: 'Must be false, a string or an array of strings.'\n };\n }\n },\n default: isInline$1(editor) ? [] : ['default']\n });\n registerOption('content_style', { processor: 'string' });\n registerOption('content_css_cors', {\n processor: 'boolean',\n default: false\n });\n registerOption('font_css', {\n processor: value => {\n const valid = isString(value) || isArrayOf(value, isString);\n if (valid) {\n const newValue = isArray$1(value) ? value : map$3(value.split(','), trim$4);\n return {\n value: newValue,\n valid\n };\n } else {\n return {\n valid: false,\n message: 'Must be a string or an array of strings.'\n };\n }\n },\n default: []\n });\n registerOption('inline_boundaries', {\n processor: 'boolean',\n default: true\n });\n registerOption('inline_boundaries_selector', {\n processor: 'string',\n default: 'a[href],code,span.mce-annotation'\n });\n registerOption('object_resizing', {\n processor: value => {\n const valid = isBoolean(value) || isString(value);\n if (valid) {\n if (value === false || deviceDetection$1.isiPhone() || deviceDetection$1.isiPad()) {\n return {\n value: '',\n valid\n };\n } else {\n return {\n value: value === true ? 'table,img,figure.image,div,video,iframe' : value,\n valid\n };\n }\n } else {\n return {\n valid: false,\n message: 'Must be boolean or a string'\n };\n }\n },\n default: !isTouch\n });\n registerOption('resize_img_proportional', {\n processor: 'boolean',\n default: true\n });\n registerOption('event_root', { processor: 'object' });\n registerOption('service_message', { processor: 'string' });\n registerOption('theme', {\n processor: value => value === false || isString(value) || isFunction(value),\n default: 'silver'\n });\n registerOption('theme_url', { processor: 'string' });\n registerOption('formats', { processor: 'object' });\n registerOption('format_empty_lines', {\n processor: 'boolean',\n default: false\n });\n registerOption('format_noneditable_selector', {\n processor: 'string',\n default: ''\n });\n registerOption('preview_styles', {\n processor: value => {\n const valid = value === false || isString(value);\n if (valid) {\n return {\n value: value === false ? '' : value,\n valid\n };\n } else {\n return {\n valid: false,\n message: 'Must be false or a string'\n };\n }\n },\n default: 'font-family font-size font-weight font-style text-decoration text-transform color background-color border border-radius outline text-shadow'\n });\n registerOption('custom_ui_selector', {\n processor: 'string',\n default: ''\n });\n registerOption('hidden_input', {\n processor: 'boolean',\n default: true\n });\n registerOption('submit_patch', {\n processor: 'boolean',\n default: true\n });\n registerOption('encoding', { processor: 'string' });\n registerOption('add_form_submit_trigger', {\n processor: 'boolean',\n default: true\n });\n registerOption('add_unload_trigger', {\n processor: 'boolean',\n default: true\n });\n registerOption('custom_undo_redo_levels', {\n processor: 'number',\n default: 0\n });\n registerOption('disable_nodechange', {\n processor: 'boolean',\n default: false\n });\n registerOption('readonly', {\n processor: 'boolean',\n default: false\n });\n registerOption('editable_root', {\n processor: 'boolean',\n default: true\n });\n registerOption('plugins', {\n processor: 'string[]',\n default: []\n });\n registerOption('external_plugins', { processor: 'object' });\n registerOption('forced_plugins', { processor: 'string[]' });\n registerOption('model', {\n processor: 'string',\n default: editor.hasPlugin('rtc') ? 'plugin' : 'dom'\n });\n registerOption('model_url', { processor: 'string' });\n registerOption('block_unsupported_drop', {\n processor: 'boolean',\n default: true\n });\n registerOption('visual', {\n processor: 'boolean',\n default: true\n });\n registerOption('visual_table_class', {\n processor: 'string',\n default: 'mce-item-table'\n });\n registerOption('visual_anchor_class', {\n processor: 'string',\n default: 'mce-item-anchor'\n });\n registerOption('iframe_aria_text', {\n processor: 'string',\n default: 'Rich Text Area. Press ALT-0 for help.'\n });\n registerOption('setup', { processor: 'function' });\n registerOption('init_instance_callback', { processor: 'function' });\n registerOption('url_converter', {\n processor: 'function',\n default: editor.convertURL\n });\n registerOption('url_converter_scope', {\n processor: 'object',\n default: editor\n });\n registerOption('urlconverter_callback', { processor: 'function' });\n registerOption('allow_conditional_comments', {\n processor: 'boolean',\n default: false\n });\n registerOption('allow_html_data_urls', {\n processor: 'boolean',\n default: false\n });\n registerOption('allow_svg_data_urls', { processor: 'boolean' });\n registerOption('allow_html_in_named_anchor', {\n processor: 'boolean',\n default: false\n });\n registerOption('allow_script_urls', {\n processor: 'boolean',\n default: false\n });\n registerOption('allow_unsafe_link_target', {\n processor: 'boolean',\n default: false\n });\n registerOption('convert_fonts_to_spans', {\n processor: 'boolean',\n default: true,\n deprecated: true\n });\n registerOption('fix_list_elements', {\n processor: 'boolean',\n default: false\n });\n registerOption('preserve_cdata', {\n processor: 'boolean',\n default: false\n });\n registerOption('remove_trailing_brs', {\n processor: 'boolean',\n default: true\n });\n registerOption('pad_empty_with_br', {\n processor: 'boolean',\n default: false\n });\n registerOption('inline_styles', {\n processor: 'boolean',\n default: true,\n deprecated: true\n });\n registerOption('element_format', {\n processor: 'string',\n default: 'html'\n });\n registerOption('entities', { processor: 'string' });\n registerOption('schema', {\n processor: 'string',\n default: 'html5'\n });\n registerOption('convert_urls', {\n processor: 'boolean',\n default: true\n });\n registerOption('relative_urls', {\n processor: 'boolean',\n default: true\n });\n registerOption('remove_script_host', {\n processor: 'boolean',\n default: true\n });\n registerOption('custom_elements', { processor: 'string' });\n registerOption('extended_valid_elements', { processor: 'string' });\n registerOption('invalid_elements', { processor: 'string' });\n registerOption('invalid_styles', { processor: stringOrObjectProcessor });\n registerOption('valid_children', { processor: 'string' });\n registerOption('valid_classes', { processor: stringOrObjectProcessor });\n registerOption('valid_elements', { processor: 'string' });\n registerOption('valid_styles', { processor: stringOrObjectProcessor });\n registerOption('verify_html', {\n processor: 'boolean',\n default: true\n });\n registerOption('auto_focus', { processor: value => isString(value) || value === true });\n registerOption('browser_spellcheck', {\n processor: 'boolean',\n default: false\n });\n registerOption('protect', { processor: 'array' });\n registerOption('images_file_types', {\n processor: 'string',\n default: 'jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp'\n });\n registerOption('deprecation_warnings', {\n processor: 'boolean',\n default: true\n });\n registerOption('a11y_advanced_options', {\n processor: 'boolean',\n default: false\n });\n registerOption('api_key', { processor: 'string' });\n registerOption('paste_block_drop', {\n processor: 'boolean',\n default: false\n });\n registerOption('paste_data_images', {\n processor: 'boolean',\n default: true\n });\n registerOption('paste_preprocess', { processor: 'function' });\n registerOption('paste_postprocess', { processor: 'function' });\n registerOption('paste_webkit_styles', {\n processor: 'string',\n default: 'none'\n });\n registerOption('paste_remove_styles_if_webkit', {\n processor: 'boolean',\n default: true\n });\n registerOption('paste_merge_formats', {\n processor: 'boolean',\n default: true\n });\n registerOption('smart_paste', {\n processor: 'boolean',\n default: true\n });\n registerOption('paste_as_text', {\n processor: 'boolean',\n default: false\n });\n registerOption('paste_tab_spaces', {\n processor: 'number',\n default: 4\n });\n registerOption('text_patterns', {\n processor: value => {\n if (isArrayOf(value, isObject) || value === false) {\n const patterns = value === false ? [] : value;\n return {\n value: fromRawPatterns(patterns),\n valid: true\n };\n } else {\n return {\n valid: false,\n message: 'Must be an array of objects or false.'\n };\n }\n },\n default: [\n {\n start: '*',\n end: '*',\n format: 'italic'\n },\n {\n start: '**',\n end: '**',\n format: 'bold'\n },\n {\n start: '#',\n format: 'h1'\n },\n {\n start: '##',\n format: 'h2'\n },\n {\n start: '###',\n format: 'h3'\n },\n {\n start: '####',\n format: 'h4'\n },\n {\n start: '#####',\n format: 'h5'\n },\n {\n start: '######',\n format: 'h6'\n },\n {\n start: '1. ',\n cmd: 'InsertOrderedList'\n },\n {\n start: '* ',\n cmd: 'InsertUnorderedList'\n },\n {\n start: '- ',\n cmd: 'InsertUnorderedList'\n }\n ]\n });\n registerOption('text_patterns_lookup', {\n processor: value => {\n if (isFunction(value)) {\n return {\n value: fromRawPatternsLookup(value),\n valid: true\n };\n } else {\n return {\n valid: false,\n message: 'Must be a single function'\n };\n }\n },\n default: _ctx => []\n });\n registerOption('noneditable_class', {\n processor: 'string',\n default: 'mceNonEditable'\n });\n registerOption('editable_class', {\n processor: 'string',\n default: 'mceEditable'\n });\n registerOption('noneditable_regexp', {\n processor: value => {\n if (isArrayOf(value, isRegExp)) {\n return {\n value,\n valid: true\n };\n } else if (isRegExp(value)) {\n return {\n value: [value],\n valid: true\n };\n } else {\n return {\n valid: false,\n message: 'Must be a RegExp or an array of RegExp.'\n };\n }\n },\n default: []\n });\n registerOption('table_tab_navigation', {\n processor: 'boolean',\n default: true\n });\n registerOption('highlight_on_focus', {\n processor: 'boolean',\n default: false\n });\n registerOption('xss_sanitization', {\n processor: 'boolean',\n default: true\n });\n registerOption('details_initial_state', {\n processor: value => {\n const valid = contains$2([\n 'inherited',\n 'collapsed',\n 'expanded'\n ], value);\n return valid ? {\n value,\n valid\n } : {\n valid: false,\n message: 'Must be one of: inherited, collapsed, or expanded.'\n };\n },\n default: 'inherited'\n });\n registerOption('details_serialized_state', {\n processor: value => {\n const valid = contains$2([\n 'inherited',\n 'collapsed',\n 'expanded'\n ], value);\n return valid ? {\n value,\n valid\n } : {\n valid: false,\n message: 'Must be one of: inherited, collapsed, or expanded.'\n };\n },\n default: 'inherited'\n });\n registerOption('init_content_sync', {\n processor: 'boolean',\n default: false\n });\n registerOption('newdocument_content', {\n processor: 'string',\n default: ''\n });\n registerOption('force_hex_color', {\n processor: value => {\n const options = [\n 'always',\n 'rgb_only',\n 'off'\n ];\n const valid = contains$2(options, value);\n return valid ? {\n value,\n valid\n } : {\n valid: false,\n message: `Must be one of: ${ options.join(', ') }.`\n };\n },\n default: 'off'\n });\n registerOption('sandbox_iframes', {\n processor: 'boolean',\n default: false\n });\n registerOption('convert_unsafe_embeds', {\n processor: 'boolean',\n default: false\n });\n editor.on('ScriptsLoaded', () => {\n registerOption('directionality', {\n processor: 'string',\n default: I18n.isRtl() ? 'rtl' : undefined\n });\n registerOption('placeholder', {\n processor: 'string',\n default: DOM$a.getAttrib(editor.getElement(), 'placeholder')\n });\n });\n };\n const getIframeAttrs = option('iframe_attrs');\n const getDocType = option('doctype');\n const getDocumentBaseUrl = option('document_base_url');\n const getBodyId = option('body_id');\n const getBodyClass = option('body_class');\n const getContentSecurityPolicy = option('content_security_policy');\n const shouldPutBrInPre$1 = option('br_in_pre');\n const getForcedRootBlock = option('forced_root_block');\n const getForcedRootBlockAttrs = option('forced_root_block_attrs');\n const getNewlineBehavior = option('newline_behavior');\n const getBrNewLineSelector = option('br_newline_selector');\n const getNoNewLineSelector = option('no_newline_selector');\n const shouldKeepStyles = option('keep_styles');\n const shouldEndContainerOnEmptyBlock = option('end_container_on_empty_block');\n const isAutomaticUploadsEnabled = option('automatic_uploads');\n const shouldReuseFileName = option('images_reuse_filename');\n const shouldReplaceBlobUris = option('images_replace_blob_uris');\n const getIconPackName = option('icons');\n const getIconsUrl = option('icons_url');\n const getImageUploadUrl = option('images_upload_url');\n const getImageUploadBasePath = option('images_upload_base_path');\n const getImagesUploadCredentials = option('images_upload_credentials');\n const getImagesUploadHandler = option('images_upload_handler');\n const shouldUseContentCssCors = option('content_css_cors');\n const getReferrerPolicy = option('referrer_policy');\n const getLanguageCode = option('language');\n const getLanguageUrl = option('language_url');\n const shouldIndentUseMargin = option('indent_use_margin');\n const getIndentation = option('indentation');\n const getContentCss = option('content_css');\n const getContentStyle = option('content_style');\n const getFontCss = option('font_css');\n const getDirectionality = option('directionality');\n const getInlineBoundarySelector = option('inline_boundaries_selector');\n const getObjectResizing = option('object_resizing');\n const getResizeImgProportional = option('resize_img_proportional');\n const getPlaceholder = option('placeholder');\n const getEventRoot = option('event_root');\n const getServiceMessage = option('service_message');\n const getTheme = option('theme');\n const getThemeUrl = option('theme_url');\n const getModel = option('model');\n const getModelUrl = option('model_url');\n const isInlineBoundariesEnabled = option('inline_boundaries');\n const getFormats = option('formats');\n const getPreviewStyles = option('preview_styles');\n const canFormatEmptyLines = option('format_empty_lines');\n const getFormatNoneditableSelector = option('format_noneditable_selector');\n const getCustomUiSelector = option('custom_ui_selector');\n const isInline$1 = option('inline');\n const hasHiddenInput = option('hidden_input');\n const shouldPatchSubmit = option('submit_patch');\n const shouldAddFormSubmitTrigger = option('add_form_submit_trigger');\n const shouldAddUnloadTrigger = option('add_unload_trigger');\n const getCustomUndoRedoLevels = option('custom_undo_redo_levels');\n const shouldDisableNodeChange = option('disable_nodechange');\n const isReadOnly$1 = option('readonly');\n const hasEditableRoot$1 = option('editable_root');\n const hasContentCssCors = option('content_css_cors');\n const getPlugins = option('plugins');\n const getExternalPlugins$1 = option('external_plugins');\n const shouldBlockUnsupportedDrop = option('block_unsupported_drop');\n const isVisualAidsEnabled = option('visual');\n const getVisualAidsTableClass = option('visual_table_class');\n const getVisualAidsAnchorClass = option('visual_anchor_class');\n const getIframeAriaText = option('iframe_aria_text');\n const getSetupCallback = option('setup');\n const getInitInstanceCallback = option('init_instance_callback');\n const getUrlConverterCallback = option('urlconverter_callback');\n const getAutoFocus = option('auto_focus');\n const shouldBrowserSpellcheck = option('browser_spellcheck');\n const getProtect = option('protect');\n const shouldPasteBlockDrop = option('paste_block_drop');\n const shouldPasteDataImages = option('paste_data_images');\n const getPastePreProcess = option('paste_preprocess');\n const getPastePostProcess = option('paste_postprocess');\n const getNewDocumentContent = option('newdocument_content');\n const getPasteWebkitStyles = option('paste_webkit_styles');\n const shouldPasteRemoveWebKitStyles = option('paste_remove_styles_if_webkit');\n const shouldPasteMergeFormats = option('paste_merge_formats');\n const isSmartPasteEnabled = option('smart_paste');\n const isPasteAsTextEnabled = option('paste_as_text');\n const getPasteTabSpaces = option('paste_tab_spaces');\n const shouldAllowHtmlDataUrls = option('allow_html_data_urls');\n const getTextPatterns = option('text_patterns');\n const getTextPatternsLookup = option('text_patterns_lookup');\n const getNonEditableClass = option('noneditable_class');\n const getEditableClass = option('editable_class');\n const getNonEditableRegExps = option('noneditable_regexp');\n const shouldPreserveCData = option('preserve_cdata');\n const shouldHighlightOnFocus = option('highlight_on_focus');\n const shouldSanitizeXss = option('xss_sanitization');\n const shouldUseDocumentWrite = option('init_content_sync');\n const hasTextPatternsLookup = editor => editor.options.isSet('text_patterns_lookup');\n const getFontStyleValues = editor => Tools.explode(editor.options.get('font_size_style_values'));\n const getFontSizeClasses = editor => Tools.explode(editor.options.get('font_size_classes'));\n const isEncodingXml = editor => editor.options.get('encoding') === 'xml';\n const getAllowedImageFileTypes = editor => Tools.explode(editor.options.get('images_file_types'));\n const hasTableTabNavigation = option('table_tab_navigation');\n const getDetailsInitialState = option('details_initial_state');\n const getDetailsSerializedState = option('details_serialized_state');\n const shouldForceHexColor = option('force_hex_color');\n const shouldSandboxIframes = option('sandbox_iframes');\n\n const isElement$3 = isElement$6;\n const isText$5 = isText$a;\n const removeNode$1 = node => {\n const parentNode = node.parentNode;\n if (parentNode) {\n parentNode.removeChild(node);\n }\n };\n const trimCount = text => {\n const trimmedText = trim$2(text);\n return {\n count: text.length - trimmedText.length,\n text: trimmedText\n };\n };\n const deleteZwspChars = caretContainer => {\n let idx;\n while ((idx = caretContainer.data.lastIndexOf(ZWSP$1)) !== -1) {\n caretContainer.deleteData(idx, 1);\n }\n };\n const removeUnchanged = (caretContainer, pos) => {\n remove$3(caretContainer);\n return pos;\n };\n const removeTextAndReposition = (caretContainer, pos) => {\n const before = trimCount(caretContainer.data.substr(0, pos.offset()));\n const after = trimCount(caretContainer.data.substr(pos.offset()));\n const text = before.text + after.text;\n if (text.length > 0) {\n deleteZwspChars(caretContainer);\n return CaretPosition(caretContainer, pos.offset() - before.count);\n } else {\n return pos;\n }\n };\n const removeElementAndReposition = (caretContainer, pos) => {\n const parentNode = pos.container();\n const newPosition = indexOf$1(from(parentNode.childNodes), caretContainer).map(index => {\n return index < pos.offset() ? CaretPosition(parentNode, pos.offset() - 1) : pos;\n }).getOr(pos);\n remove$3(caretContainer);\n return newPosition;\n };\n const removeTextCaretContainer = (caretContainer, pos) => isText$5(caretContainer) && pos.container() === caretContainer ? removeTextAndReposition(caretContainer, pos) : removeUnchanged(caretContainer, pos);\n const removeElementCaretContainer = (caretContainer, pos) => pos.container() === caretContainer.parentNode ? removeElementAndReposition(caretContainer, pos) : removeUnchanged(caretContainer, pos);\n const removeAndReposition = (container, pos) => CaretPosition.isTextPosition(pos) ? removeTextCaretContainer(container, pos) : removeElementCaretContainer(container, pos);\n const remove$3 = caretContainerNode => {\n if (isElement$3(caretContainerNode) && isCaretContainer$2(caretContainerNode)) {\n if (hasContent(caretContainerNode)) {\n caretContainerNode.removeAttribute('data-mce-caret');\n } else {\n removeNode$1(caretContainerNode);\n }\n }\n if (isText$5(caretContainerNode)) {\n deleteZwspChars(caretContainerNode);\n if (caretContainerNode.data.length === 0) {\n removeNode$1(caretContainerNode);\n }\n }\n };\n\n const isContentEditableFalse$8 = isContentEditableFalse$b;\n const isMedia$1 = isMedia$2;\n const isTableCell$1 = isTableCell$3;\n const inlineFakeCaretSelector = '*[contentEditable=false],video,audio,embed,object';\n const getAbsoluteClientRect = (root, element, before) => {\n const clientRect = collapse(element.getBoundingClientRect(), before);\n let scrollX;\n let scrollY;\n if (root.tagName === 'BODY') {\n const docElm = root.ownerDocument.documentElement;\n scrollX = root.scrollLeft || docElm.scrollLeft;\n scrollY = root.scrollTop || docElm.scrollTop;\n } else {\n const rootRect = root.getBoundingClientRect();\n scrollX = root.scrollLeft - rootRect.left;\n scrollY = root.scrollTop - rootRect.top;\n }\n clientRect.left += scrollX;\n clientRect.right += scrollX;\n clientRect.top += scrollY;\n clientRect.bottom += scrollY;\n clientRect.width = 1;\n let margin = element.offsetWidth - element.clientWidth;\n if (margin > 0) {\n if (before) {\n margin *= -1;\n }\n clientRect.left += margin;\n clientRect.right += margin;\n }\n return clientRect;\n };\n const trimInlineCaretContainers = root => {\n var _a, _b;\n const fakeCaretTargetNodes = descendants(SugarElement.fromDom(root), inlineFakeCaretSelector);\n for (let i = 0; i < fakeCaretTargetNodes.length; i++) {\n const node = fakeCaretTargetNodes[i].dom;\n let sibling = node.previousSibling;\n if (endsWithCaretContainer$1(sibling)) {\n const data = sibling.data;\n if (data.length === 1) {\n (_a = sibling.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(sibling);\n } else {\n sibling.deleteData(data.length - 1, 1);\n }\n }\n sibling = node.nextSibling;\n if (startsWithCaretContainer$1(sibling)) {\n const data = sibling.data;\n if (data.length === 1) {\n (_b = sibling.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(sibling);\n } else {\n sibling.deleteData(0, 1);\n }\n }\n }\n };\n const FakeCaret = (editor, root, isBlock, hasFocus) => {\n const lastVisualCaret = value$2();\n let cursorInterval;\n let caretContainerNode;\n const caretBlock = getForcedRootBlock(editor);\n const dom = editor.dom;\n const show = (before, element) => {\n let rng;\n hide();\n if (isTableCell$1(element)) {\n return null;\n }\n if (isBlock(element)) {\n const caretContainer = insertBlock(caretBlock, element, before);\n const clientRect = getAbsoluteClientRect(root, element, before);\n dom.setStyle(caretContainer, 'top', clientRect.top);\n caretContainerNode = caretContainer;\n const caret = dom.create('div', {\n 'class': 'mce-visual-caret',\n 'data-mce-bogus': 'all'\n });\n dom.setStyles(caret, { ...clientRect });\n dom.add(root, caret);\n lastVisualCaret.set({\n caret,\n element,\n before\n });\n if (before) {\n dom.addClass(caret, 'mce-visual-caret-before');\n }\n startBlink();\n rng = element.ownerDocument.createRange();\n rng.setStart(caretContainer, 0);\n rng.setEnd(caretContainer, 0);\n } else {\n caretContainerNode = insertInline$1(element, before);\n rng = element.ownerDocument.createRange();\n if (isInlineFakeCaretTarget(caretContainerNode.nextSibling)) {\n rng.setStart(caretContainerNode, 0);\n rng.setEnd(caretContainerNode, 0);\n } else {\n rng.setStart(caretContainerNode, 1);\n rng.setEnd(caretContainerNode, 1);\n }\n return rng;\n }\n return rng;\n };\n const hide = () => {\n trimInlineCaretContainers(root);\n if (caretContainerNode) {\n remove$3(caretContainerNode);\n caretContainerNode = null;\n }\n lastVisualCaret.on(caretState => {\n dom.remove(caretState.caret);\n lastVisualCaret.clear();\n });\n if (cursorInterval) {\n clearInterval(cursorInterval);\n cursorInterval = undefined;\n }\n };\n const startBlink = () => {\n cursorInterval = setInterval(() => {\n lastVisualCaret.on(caretState => {\n if (hasFocus()) {\n dom.toggleClass(caretState.caret, 'mce-visual-caret-hidden');\n } else {\n dom.addClass(caretState.caret, 'mce-visual-caret-hidden');\n }\n });\n }, 500);\n };\n const reposition = () => {\n lastVisualCaret.on(caretState => {\n const clientRect = getAbsoluteClientRect(root, caretState.element, caretState.before);\n dom.setStyles(caretState.caret, { ...clientRect });\n });\n };\n const destroy = () => clearInterval(cursorInterval);\n const getCss = () => '.mce-visual-caret {' + 'position: absolute;' + 'background-color: black;' + 'background-color: currentcolor;' + '}' + '.mce-visual-caret-hidden {' + 'display: none;' + '}' + '*[data-mce-caret] {' + 'position: absolute;' + 'left: -1000px;' + 'right: auto;' + 'top: 0;' + 'margin: 0;' + 'padding: 0;' + '}';\n return {\n show,\n hide,\n getCss,\n reposition,\n destroy\n };\n };\n const isFakeCaretTableBrowser = () => Env.browser.isFirefox();\n const isInlineFakeCaretTarget = node => isContentEditableFalse$8(node) || isMedia$1(node);\n const isFakeCaretTarget = node => {\n const isTarget = isInlineFakeCaretTarget(node) || isTable$2(node) && isFakeCaretTableBrowser();\n return isTarget && parentElement(SugarElement.fromDom(node)).exists(isEditable$2);\n };\n\n const isContentEditableTrue$1 = isContentEditableTrue$3;\n const isContentEditableFalse$7 = isContentEditableFalse$b;\n const isMedia = isMedia$2;\n const isBlockLike = matchStyleValues('display', 'block table table-cell table-caption list-item');\n const isCaretContainer = isCaretContainer$2;\n const isCaretContainerBlock = isCaretContainerBlock$1;\n const isElement$2 = isElement$6;\n const isText$4 = isText$a;\n const isCaretCandidate$1 = isCaretCandidate$3;\n const isForwards = direction => direction > 0;\n const isBackwards = direction => direction < 0;\n const skipCaretContainers = (walk, shallow) => {\n let node;\n while (node = walk(shallow)) {\n if (!isCaretContainerBlock(node)) {\n return node;\n }\n }\n return null;\n };\n const findNode = (node, direction, predicateFn, rootNode, shallow) => {\n const walker = new DomTreeWalker(node, rootNode);\n const isCefOrCaretContainer = isContentEditableFalse$7(node) || isCaretContainerBlock(node);\n let tempNode;\n if (isBackwards(direction)) {\n if (isCefOrCaretContainer) {\n tempNode = skipCaretContainers(walker.prev.bind(walker), true);\n if (predicateFn(tempNode)) {\n return tempNode;\n }\n }\n while (tempNode = skipCaretContainers(walker.prev.bind(walker), shallow)) {\n if (predicateFn(tempNode)) {\n return tempNode;\n }\n }\n }\n if (isForwards(direction)) {\n if (isCefOrCaretContainer) {\n tempNode = skipCaretContainers(walker.next.bind(walker), true);\n if (predicateFn(tempNode)) {\n return tempNode;\n }\n }\n while (tempNode = skipCaretContainers(walker.next.bind(walker), shallow)) {\n if (predicateFn(tempNode)) {\n return tempNode;\n }\n }\n }\n return null;\n };\n const getEditingHost = (node, rootNode) => {\n const isCETrue = node => isContentEditableTrue$1(node.dom);\n const isRoot = node => node.dom === rootNode;\n return ancestor$4(SugarElement.fromDom(node), isCETrue, isRoot).map(elm => elm.dom).getOr(rootNode);\n };\n const getParentBlock$3 = (node, rootNode) => {\n while (node && node !== rootNode) {\n if (isBlockLike(node)) {\n return node;\n }\n node = node.parentNode;\n }\n return null;\n };\n const isInSameBlock = (caretPosition1, caretPosition2, rootNode) => getParentBlock$3(caretPosition1.container(), rootNode) === getParentBlock$3(caretPosition2.container(), rootNode);\n const getChildNodeAtRelativeOffset = (relativeOffset, caretPosition) => {\n if (!caretPosition) {\n return Optional.none();\n }\n const container = caretPosition.container();\n const offset = caretPosition.offset();\n if (!isElement$2(container)) {\n return Optional.none();\n }\n return Optional.from(container.childNodes[offset + relativeOffset]);\n };\n const beforeAfter = (before, node) => {\n var _a;\n const doc = (_a = node.ownerDocument) !== null && _a !== void 0 ? _a : document;\n const range = doc.createRange();\n if (before) {\n range.setStartBefore(node);\n range.setEndBefore(node);\n } else {\n range.setStartAfter(node);\n range.setEndAfter(node);\n }\n return range;\n };\n const isNodesInSameBlock = (root, node1, node2) => getParentBlock$3(node1, root) === getParentBlock$3(node2, root);\n const lean = (left, root, node) => {\n const siblingName = left ? 'previousSibling' : 'nextSibling';\n let tempNode = node;\n while (tempNode && tempNode !== root) {\n let sibling = tempNode[siblingName];\n if (sibling && isCaretContainer(sibling)) {\n sibling = sibling[siblingName];\n }\n if (isContentEditableFalse$7(sibling) || isMedia(sibling)) {\n if (isNodesInSameBlock(root, sibling, tempNode)) {\n return sibling;\n }\n break;\n }\n if (isCaretCandidate$1(sibling)) {\n break;\n }\n tempNode = tempNode.parentNode;\n }\n return null;\n };\n const before$2 = curry(beforeAfter, true);\n const after$2 = curry(beforeAfter, false);\n const normalizeRange = (direction, root, range) => {\n let node;\n const leanLeft = curry(lean, true, root);\n const leanRight = curry(lean, false, root);\n const container = range.startContainer;\n const offset = range.startOffset;\n if (isCaretContainerBlock$1(container)) {\n const block = isText$4(container) ? container.parentNode : container;\n const location = block.getAttribute('data-mce-caret');\n if (location === 'before') {\n node = block.nextSibling;\n if (isFakeCaretTarget(node)) {\n return before$2(node);\n }\n }\n if (location === 'after') {\n node = block.previousSibling;\n if (isFakeCaretTarget(node)) {\n return after$2(node);\n }\n }\n }\n if (!range.collapsed) {\n return range;\n }\n if (isText$a(container)) {\n if (isCaretContainer(container)) {\n if (direction === 1) {\n node = leanRight(container);\n if (node) {\n return before$2(node);\n }\n node = leanLeft(container);\n if (node) {\n return after$2(node);\n }\n }\n if (direction === -1) {\n node = leanLeft(container);\n if (node) {\n return after$2(node);\n }\n node = leanRight(container);\n if (node) {\n return before$2(node);\n }\n }\n return range;\n }\n if (endsWithCaretContainer$1(container) && offset >= container.data.length - 1) {\n if (direction === 1) {\n node = leanRight(container);\n if (node) {\n return before$2(node);\n }\n }\n return range;\n }\n if (startsWithCaretContainer$1(container) && offset <= 1) {\n if (direction === -1) {\n node = leanLeft(container);\n if (node) {\n return after$2(node);\n }\n }\n return range;\n }\n if (offset === container.data.length) {\n node = leanRight(container);\n if (node) {\n return before$2(node);\n }\n return range;\n }\n if (offset === 0) {\n node = leanLeft(container);\n if (node) {\n return after$2(node);\n }\n return range;\n }\n }\n return range;\n };\n const getRelativeCefElm = (forward, caretPosition) => getChildNodeAtRelativeOffset(forward ? 0 : -1, caretPosition).filter(isContentEditableFalse$7);\n const getNormalizedRangeEndPoint = (direction, root, range) => {\n const normalizedRange = normalizeRange(direction, root, range);\n return direction === -1 ? CaretPosition.fromRangeStart(normalizedRange) : CaretPosition.fromRangeEnd(normalizedRange);\n };\n const getElementFromPosition = pos => Optional.from(pos.getNode()).map(SugarElement.fromDom);\n const getElementFromPrevPosition = pos => Optional.from(pos.getNode(true)).map(SugarElement.fromDom);\n const getVisualCaretPosition = (walkFn, caretPosition) => {\n let pos = caretPosition;\n while (pos = walkFn(pos)) {\n if (pos.isVisible()) {\n return pos;\n }\n }\n return pos;\n };\n const isMoveInsideSameBlock = (from, to) => {\n const inSameBlock = isInSameBlock(from, to);\n if (!inSameBlock && isBr$6(from.getNode())) {\n return true;\n }\n return inSameBlock;\n };\n\n var HDirection;\n (function (HDirection) {\n HDirection[HDirection['Backwards'] = -1] = 'Backwards';\n HDirection[HDirection['Forwards'] = 1] = 'Forwards';\n }(HDirection || (HDirection = {})));\n const isContentEditableFalse$6 = isContentEditableFalse$b;\n const isText$3 = isText$a;\n const isElement$1 = isElement$6;\n const isBr$2 = isBr$6;\n const isCaretCandidate = isCaretCandidate$3;\n const isAtomic = isAtomic$1;\n const isEditableCaretCandidate = isEditableCaretCandidate$1;\n const getParents$3 = (node, root) => {\n const parents = [];\n let tempNode = node;\n while (tempNode && tempNode !== root) {\n parents.push(tempNode);\n tempNode = tempNode.parentNode;\n }\n return parents;\n };\n const nodeAtIndex = (container, offset) => {\n if (container.hasChildNodes() && offset < container.childNodes.length) {\n return container.childNodes[offset];\n }\n return null;\n };\n const getCaretCandidatePosition = (direction, node) => {\n if (isForwards(direction)) {\n if (isCaretCandidate(node.previousSibling) && !isText$3(node.previousSibling)) {\n return CaretPosition.before(node);\n }\n if (isText$3(node)) {\n return CaretPosition(node, 0);\n }\n }\n if (isBackwards(direction)) {\n if (isCaretCandidate(node.nextSibling) && !isText$3(node.nextSibling)) {\n return CaretPosition.after(node);\n }\n if (isText$3(node)) {\n return CaretPosition(node, node.data.length);\n }\n }\n if (isBackwards(direction)) {\n if (isBr$2(node)) {\n return CaretPosition.before(node);\n }\n return CaretPosition.after(node);\n }\n return CaretPosition.before(node);\n };\n const moveForwardFromBr = (root, nextNode) => {\n const nextSibling = nextNode.nextSibling;\n if (nextSibling && isCaretCandidate(nextSibling)) {\n if (isText$3(nextSibling)) {\n return CaretPosition(nextSibling, 0);\n } else {\n return CaretPosition.before(nextSibling);\n }\n } else {\n return findCaretPosition$1(HDirection.Forwards, CaretPosition.after(nextNode), root);\n }\n };\n const findCaretPosition$1 = (direction, startPos, root) => {\n let node;\n let nextNode;\n let innerNode;\n let caretPosition;\n if (!isElement$1(root) || !startPos) {\n return null;\n }\n if (startPos.isEqual(CaretPosition.after(root)) && root.lastChild) {\n caretPosition = CaretPosition.after(root.lastChild);\n if (isBackwards(direction) && isCaretCandidate(root.lastChild) && isElement$1(root.lastChild)) {\n return isBr$2(root.lastChild) ? CaretPosition.before(root.lastChild) : caretPosition;\n }\n } else {\n caretPosition = startPos;\n }\n const container = caretPosition.container();\n let offset = caretPosition.offset();\n if (isText$3(container)) {\n if (isBackwards(direction) && offset > 0) {\n return CaretPosition(container, --offset);\n }\n if (isForwards(direction) && offset < container.length) {\n return CaretPosition(container, ++offset);\n }\n node = container;\n } else {\n if (isBackwards(direction) && offset > 0) {\n nextNode = nodeAtIndex(container, offset - 1);\n if (isCaretCandidate(nextNode)) {\n if (!isAtomic(nextNode)) {\n innerNode = findNode(nextNode, direction, isEditableCaretCandidate, nextNode);\n if (innerNode) {\n if (isText$3(innerNode)) {\n return CaretPosition(innerNode, innerNode.data.length);\n }\n return CaretPosition.after(innerNode);\n }\n }\n if (isText$3(nextNode)) {\n return CaretPosition(nextNode, nextNode.data.length);\n }\n return CaretPosition.before(nextNode);\n }\n }\n if (isForwards(direction) && offset < container.childNodes.length) {\n nextNode = nodeAtIndex(container, offset);\n if (isCaretCandidate(nextNode)) {\n if (isBr$2(nextNode)) {\n return moveForwardFromBr(root, nextNode);\n }\n if (!isAtomic(nextNode)) {\n innerNode = findNode(nextNode, direction, isEditableCaretCandidate, nextNode);\n if (innerNode) {\n if (isText$3(innerNode)) {\n return CaretPosition(innerNode, 0);\n }\n return CaretPosition.before(innerNode);\n }\n }\n if (isText$3(nextNode)) {\n return CaretPosition(nextNode, 0);\n }\n return CaretPosition.after(nextNode);\n }\n }\n node = nextNode ? nextNode : caretPosition.getNode();\n }\n if (node && (isForwards(direction) && caretPosition.isAtEnd() || isBackwards(direction) && caretPosition.isAtStart())) {\n node = findNode(node, direction, always, root, true);\n if (isEditableCaretCandidate(node, root)) {\n return getCaretCandidatePosition(direction, node);\n }\n }\n nextNode = node ? findNode(node, direction, isEditableCaretCandidate, root) : node;\n const rootContentEditableFalseElm = last$2(filter$5(getParents$3(container, root), isContentEditableFalse$6));\n if (rootContentEditableFalseElm && (!nextNode || !rootContentEditableFalseElm.contains(nextNode))) {\n if (isForwards(direction)) {\n caretPosition = CaretPosition.after(rootContentEditableFalseElm);\n } else {\n caretPosition = CaretPosition.before(rootContentEditableFalseElm);\n }\n return caretPosition;\n }\n if (nextNode) {\n return getCaretCandidatePosition(direction, nextNode);\n }\n return null;\n };\n const CaretWalker = root => ({\n next: caretPosition => {\n return findCaretPosition$1(HDirection.Forwards, caretPosition, root);\n },\n prev: caretPosition => {\n return findCaretPosition$1(HDirection.Backwards, caretPosition, root);\n }\n });\n\n const walkToPositionIn = (forward, root, start) => {\n const position = forward ? CaretPosition.before(start) : CaretPosition.after(start);\n return fromPosition(forward, root, position);\n };\n const afterElement = node => isBr$6(node) ? CaretPosition.before(node) : CaretPosition.after(node);\n const isBeforeOrStart = position => {\n if (CaretPosition.isTextPosition(position)) {\n return position.offset() === 0;\n } else {\n return isCaretCandidate$3(position.getNode());\n }\n };\n const isAfterOrEnd = position => {\n if (CaretPosition.isTextPosition(position)) {\n const container = position.container();\n return position.offset() === container.data.length;\n } else {\n return isCaretCandidate$3(position.getNode(true));\n }\n };\n const isBeforeAfterSameElement = (from, to) => !CaretPosition.isTextPosition(from) && !CaretPosition.isTextPosition(to) && from.getNode() === to.getNode(true);\n const isAtBr = position => !CaretPosition.isTextPosition(position) && isBr$6(position.getNode());\n const shouldSkipPosition = (forward, from, to) => {\n if (forward) {\n return !isBeforeAfterSameElement(from, to) && !isAtBr(from) && isAfterOrEnd(from) && isBeforeOrStart(to);\n } else {\n return !isBeforeAfterSameElement(to, from) && isBeforeOrStart(from) && isAfterOrEnd(to);\n }\n };\n const fromPosition = (forward, root, pos) => {\n const walker = CaretWalker(root);\n return Optional.from(forward ? walker.next(pos) : walker.prev(pos));\n };\n const navigate = (forward, root, from) => fromPosition(forward, root, from).bind(to => {\n if (isInSameBlock(from, to, root) && shouldSkipPosition(forward, from, to)) {\n return fromPosition(forward, root, to);\n } else {\n return Optional.some(to);\n }\n });\n const navigateIgnore = (forward, root, from, ignoreFilter) => navigate(forward, root, from).bind(pos => ignoreFilter(pos) ? navigateIgnore(forward, root, pos, ignoreFilter) : Optional.some(pos));\n const positionIn = (forward, element) => {\n const startNode = forward ? element.firstChild : element.lastChild;\n if (isText$a(startNode)) {\n return Optional.some(CaretPosition(startNode, forward ? 0 : startNode.data.length));\n } else if (startNode) {\n if (isCaretCandidate$3(startNode)) {\n return Optional.some(forward ? CaretPosition.before(startNode) : afterElement(startNode));\n } else {\n return walkToPositionIn(forward, element, startNode);\n }\n } else {\n return Optional.none();\n }\n };\n const nextPosition = curry(fromPosition, true);\n const prevPosition = curry(fromPosition, false);\n const firstPositionIn = curry(positionIn, true);\n const lastPositionIn = curry(positionIn, false);\n\n const CARET_ID = '_mce_caret';\n const isCaretNode = node => isElement$6(node) && node.id === CARET_ID;\n const getParentCaretContainer = (body, node) => {\n let currentNode = node;\n while (currentNode && currentNode !== body) {\n if (isCaretNode(currentNode)) {\n return currentNode;\n }\n currentNode = currentNode.parentNode;\n }\n return null;\n };\n\n const isStringPathBookmark = bookmark => isString(bookmark.start);\n const isRangeBookmark = bookmark => has$2(bookmark, 'rng');\n const isIdBookmark = bookmark => has$2(bookmark, 'id');\n const isIndexBookmark = bookmark => has$2(bookmark, 'name');\n const isPathBookmark = bookmark => Tools.isArray(bookmark.start);\n\n const isForwardBookmark = bookmark => !isIndexBookmark(bookmark) && isBoolean(bookmark.forward) ? bookmark.forward : true;\n const addBogus = (dom, node) => {\n if (isElement$6(node) && dom.isBlock(node) && !node.innerHTML) {\n node.innerHTML = '
';\n }\n return node;\n };\n const resolveCaretPositionBookmark = (dom, bookmark) => {\n const startPos = Optional.from(resolve$1(dom.getRoot(), bookmark.start));\n const endPos = Optional.from(resolve$1(dom.getRoot(), bookmark.end));\n return lift2(startPos, endPos, (start, end) => {\n const range = dom.createRng();\n range.setStart(start.container(), start.offset());\n range.setEnd(end.container(), end.offset());\n return {\n range,\n forward: isForwardBookmark(bookmark)\n };\n });\n };\n const insertZwsp = (node, rng) => {\n var _a;\n const doc = (_a = node.ownerDocument) !== null && _a !== void 0 ? _a : document;\n const textNode = doc.createTextNode(ZWSP$1);\n node.appendChild(textNode);\n rng.setStart(textNode, 0);\n rng.setEnd(textNode, 0);\n };\n const isEmpty$1 = node => !node.hasChildNodes();\n const tryFindRangePosition = (node, rng) => lastPositionIn(node).fold(never, pos => {\n rng.setStart(pos.container(), pos.offset());\n rng.setEnd(pos.container(), pos.offset());\n return true;\n });\n const padEmptyCaretContainer = (root, node, rng) => {\n if (isEmpty$1(node) && getParentCaretContainer(root, node)) {\n insertZwsp(node, rng);\n return true;\n } else {\n return false;\n }\n };\n const setEndPoint = (dom, start, bookmark, rng) => {\n const point = bookmark[start ? 'start' : 'end'];\n const root = dom.getRoot();\n if (point) {\n let node = root;\n let offset = point[0];\n for (let i = point.length - 1; node && i >= 1; i--) {\n const children = node.childNodes;\n if (padEmptyCaretContainer(root, node, rng)) {\n return true;\n }\n if (point[i] > children.length - 1) {\n if (padEmptyCaretContainer(root, node, rng)) {\n return true;\n }\n return tryFindRangePosition(node, rng);\n }\n node = children[point[i]];\n }\n if (isText$a(node)) {\n offset = Math.min(point[0], node.data.length);\n }\n if (isElement$6(node)) {\n offset = Math.min(point[0], node.childNodes.length);\n }\n if (start) {\n rng.setStart(node, offset);\n } else {\n rng.setEnd(node, offset);\n }\n }\n return true;\n };\n const isValidTextNode = node => isText$a(node) && node.data.length > 0;\n const restoreEndPoint = (dom, suffix, bookmark) => {\n const marker = dom.get(bookmark.id + '_' + suffix);\n const markerParent = marker === null || marker === void 0 ? void 0 : marker.parentNode;\n const keep = bookmark.keep;\n if (marker && markerParent) {\n let container;\n let offset;\n if (suffix === 'start') {\n if (!keep) {\n container = markerParent;\n offset = dom.nodeIndex(marker);\n } else {\n if (marker.hasChildNodes()) {\n container = marker.firstChild;\n offset = 1;\n } else if (isValidTextNode(marker.nextSibling)) {\n container = marker.nextSibling;\n offset = 0;\n } else if (isValidTextNode(marker.previousSibling)) {\n container = marker.previousSibling;\n offset = marker.previousSibling.data.length;\n } else {\n container = markerParent;\n offset = dom.nodeIndex(marker) + 1;\n }\n }\n } else {\n if (!keep) {\n container = markerParent;\n offset = dom.nodeIndex(marker);\n } else {\n if (marker.hasChildNodes()) {\n container = marker.firstChild;\n offset = 1;\n } else if (isValidTextNode(marker.previousSibling)) {\n container = marker.previousSibling;\n offset = marker.previousSibling.data.length;\n } else {\n container = markerParent;\n offset = dom.nodeIndex(marker);\n }\n }\n }\n if (!keep) {\n const prev = marker.previousSibling;\n const next = marker.nextSibling;\n Tools.each(Tools.grep(marker.childNodes), node => {\n if (isText$a(node)) {\n node.data = node.data.replace(/\\uFEFF/g, '');\n }\n });\n let otherMarker;\n while (otherMarker = dom.get(bookmark.id + '_' + suffix)) {\n dom.remove(otherMarker, true);\n }\n if (isText$a(next) && isText$a(prev) && !Env.browser.isOpera()) {\n const idx = prev.data.length;\n prev.appendData(next.data);\n dom.remove(next);\n container = prev;\n offset = idx;\n }\n }\n return Optional.some(CaretPosition(container, offset));\n } else {\n return Optional.none();\n }\n };\n const resolvePaths = (dom, bookmark) => {\n const range = dom.createRng();\n if (setEndPoint(dom, true, bookmark, range) && setEndPoint(dom, false, bookmark, range)) {\n return Optional.some({\n range,\n forward: isForwardBookmark(bookmark)\n });\n } else {\n return Optional.none();\n }\n };\n const resolveId = (dom, bookmark) => {\n const startPos = restoreEndPoint(dom, 'start', bookmark);\n const endPos = restoreEndPoint(dom, 'end', bookmark);\n return lift2(startPos, endPos.or(startPos), (spos, epos) => {\n const range = dom.createRng();\n range.setStart(addBogus(dom, spos.container()), spos.offset());\n range.setEnd(addBogus(dom, epos.container()), epos.offset());\n return {\n range,\n forward: isForwardBookmark(bookmark)\n };\n });\n };\n const resolveIndex = (dom, bookmark) => Optional.from(dom.select(bookmark.name)[bookmark.index]).map(elm => {\n const range = dom.createRng();\n range.selectNode(elm);\n return {\n range,\n forward: true\n };\n });\n const resolve = (selection, bookmark) => {\n const dom = selection.dom;\n if (bookmark) {\n if (isPathBookmark(bookmark)) {\n return resolvePaths(dom, bookmark);\n } else if (isStringPathBookmark(bookmark)) {\n return resolveCaretPositionBookmark(dom, bookmark);\n } else if (isIdBookmark(bookmark)) {\n return resolveId(dom, bookmark);\n } else if (isIndexBookmark(bookmark)) {\n return resolveIndex(dom, bookmark);\n } else if (isRangeBookmark(bookmark)) {\n return Optional.some({\n range: bookmark.rng,\n forward: isForwardBookmark(bookmark)\n });\n }\n }\n return Optional.none();\n };\n\n const getBookmark$1 = (selection, type, normalized) => {\n return getBookmark$2(selection, type, normalized);\n };\n const moveToBookmark = (selection, bookmark) => {\n resolve(selection, bookmark).each(({range, forward}) => {\n selection.setRng(range, forward);\n });\n };\n const isBookmarkNode$1 = node => {\n return isElement$6(node) && node.tagName === 'SPAN' && node.getAttribute('data-mce-type') === 'bookmark';\n };\n\n const is = expected => actual => expected === actual;\n const isNbsp = is(nbsp);\n const isWhiteSpace = chr => chr !== '' && ' \\f\\n\\r\\t\\x0B'.indexOf(chr) !== -1;\n const isContent = chr => !isWhiteSpace(chr) && !isNbsp(chr) && !isZwsp$2(chr);\n\n const getRanges$1 = selection => {\n const ranges = [];\n if (selection) {\n for (let i = 0; i < selection.rangeCount; i++) {\n ranges.push(selection.getRangeAt(i));\n }\n }\n return ranges;\n };\n const getSelectedNodes = ranges => {\n return bind$3(ranges, range => {\n const node = getSelectedNode(range);\n return node ? [SugarElement.fromDom(node)] : [];\n });\n };\n const hasMultipleRanges = selection => {\n return getRanges$1(selection).length > 1;\n };\n\n const getCellsFromRanges = ranges => filter$5(getSelectedNodes(ranges), isTableCell$2);\n const getCellsFromElement = elm => descendants(elm, 'td[data-mce-selected],th[data-mce-selected]');\n const getCellsFromElementOrRanges = (ranges, element) => {\n const selectedCells = getCellsFromElement(element);\n return selectedCells.length > 0 ? selectedCells : getCellsFromRanges(ranges);\n };\n const getCellsFromEditor = editor => getCellsFromElementOrRanges(getRanges$1(editor.selection.getSel()), SugarElement.fromDom(editor.getBody()));\n const getClosestTable = (cell, isRoot) => ancestor$3(cell, 'table', isRoot);\n\n const getStartNode = rng => {\n const sc = rng.startContainer, so = rng.startOffset;\n if (isText$a(sc)) {\n return so === 0 ? Optional.some(SugarElement.fromDom(sc)) : Optional.none();\n } else {\n return Optional.from(sc.childNodes[so]).map(SugarElement.fromDom);\n }\n };\n const getEndNode = rng => {\n const ec = rng.endContainer, eo = rng.endOffset;\n if (isText$a(ec)) {\n return eo === ec.data.length ? Optional.some(SugarElement.fromDom(ec)) : Optional.none();\n } else {\n return Optional.from(ec.childNodes[eo - 1]).map(SugarElement.fromDom);\n }\n };\n const getFirstChildren = node => {\n return firstChild(node).fold(constant([node]), child => {\n return [node].concat(getFirstChildren(child));\n });\n };\n const getLastChildren = node => {\n return lastChild(node).fold(constant([node]), child => {\n if (name(child) === 'br') {\n return prevSibling(child).map(sibling => {\n return [node].concat(getLastChildren(sibling));\n }).getOr([]);\n } else {\n return [node].concat(getLastChildren(child));\n }\n });\n };\n const hasAllContentsSelected = (elm, rng) => {\n return lift2(getStartNode(rng), getEndNode(rng), (startNode, endNode) => {\n const start = find$2(getFirstChildren(elm), curry(eq, startNode));\n const end = find$2(getLastChildren(elm), curry(eq, endNode));\n return start.isSome() && end.isSome();\n }).getOr(false);\n };\n const moveEndPoint = (dom, rng, node, start) => {\n const root = node;\n const walker = new DomTreeWalker(node, root);\n const moveCaretBeforeOnEnterElementsMap = filter$4(dom.schema.getMoveCaretBeforeOnEnterElements(), (_, name) => !contains$2([\n 'td',\n 'th',\n 'table'\n ], name.toLowerCase()));\n let currentNode = node;\n do {\n if (isText$a(currentNode) && Tools.trim(currentNode.data).length !== 0) {\n if (start) {\n rng.setStart(currentNode, 0);\n } else {\n rng.setEnd(currentNode, currentNode.data.length);\n }\n return;\n }\n if (moveCaretBeforeOnEnterElementsMap[currentNode.nodeName]) {\n if (start) {\n rng.setStartBefore(currentNode);\n } else {\n if (currentNode.nodeName === 'BR') {\n rng.setEndBefore(currentNode);\n } else {\n rng.setEndAfter(currentNode);\n }\n }\n return;\n }\n } while (currentNode = start ? walker.next() : walker.prev());\n if (root.nodeName === 'BODY') {\n if (start) {\n rng.setStart(root, 0);\n } else {\n rng.setEnd(root, root.childNodes.length);\n }\n }\n };\n const hasAnyRanges = editor => {\n const sel = editor.selection.getSel();\n return isNonNullable(sel) && sel.rangeCount > 0;\n };\n const runOnRanges = (editor, executor) => {\n const fakeSelectionNodes = getCellsFromEditor(editor);\n if (fakeSelectionNodes.length > 0) {\n each$e(fakeSelectionNodes, elem => {\n const node = elem.dom;\n const fakeNodeRng = editor.dom.createRng();\n fakeNodeRng.setStartBefore(node);\n fakeNodeRng.setEndAfter(node);\n executor(fakeNodeRng, true);\n });\n } else {\n executor(editor.selection.getRng(), false);\n }\n };\n const preserve = (selection, fillBookmark, executor) => {\n const bookmark = getPersistentBookmark(selection, fillBookmark);\n executor(bookmark);\n selection.moveToBookmark(bookmark);\n };\n\n const isNode = node => isNumber(node === null || node === void 0 ? void 0 : node.nodeType);\n const isElementNode$1 = node => isElement$6(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$2(node);\n const isElementDirectlySelected = (dom, node) => {\n if (isElementNode$1(node) && !/^(TD|TH)$/.test(node.nodeName)) {\n const selectedAttr = dom.getAttrib(node, 'data-mce-selected');\n const value = parseInt(selectedAttr, 10);\n return !isNaN(value) && value > 0;\n } else {\n return false;\n }\n };\n const preserveSelection = (editor, action, shouldMoveStart) => {\n const {selection, dom} = editor;\n const selectedNodeBeforeAction = selection.getNode();\n const isSelectedBeforeNodeNoneditable = isContentEditableFalse$b(selectedNodeBeforeAction);\n preserve(selection, true, () => {\n action();\n });\n const isBeforeNodeStillNoneditable = isSelectedBeforeNodeNoneditable && isContentEditableFalse$b(selectedNodeBeforeAction);\n if (isBeforeNodeStillNoneditable && dom.isChildOf(selectedNodeBeforeAction, editor.getBody())) {\n editor.selection.select(selectedNodeBeforeAction);\n } else if (shouldMoveStart(selection.getStart())) {\n moveStartToNearestText(dom, selection);\n }\n };\n const moveStartToNearestText = (dom, selection) => {\n var _a, _b;\n const rng = selection.getRng();\n const {startContainer, startOffset} = rng;\n const selectedNode = selection.getNode();\n if (isElementDirectlySelected(dom, selectedNode)) {\n return;\n }\n if (isElement$6(startContainer)) {\n const nodes = startContainer.childNodes;\n const root = dom.getRoot();\n let walker;\n if (startOffset < nodes.length) {\n const startNode = nodes[startOffset];\n walker = new DomTreeWalker(startNode, (_a = dom.getParent(startNode, dom.isBlock)) !== null && _a !== void 0 ? _a : root);\n } else {\n const startNode = nodes[nodes.length - 1];\n walker = new DomTreeWalker(startNode, (_b = dom.getParent(startNode, dom.isBlock)) !== null && _b !== void 0 ? _b : root);\n walker.next(true);\n }\n for (let node = walker.current(); node; node = walker.next()) {\n if (dom.getContentEditable(node) === 'false') {\n return;\n } else if (isText$a(node) && !isWhiteSpaceNode$1(node)) {\n rng.setStart(node, 0);\n selection.setRng(rng);\n return;\n }\n }\n }\n };\n const getNonWhiteSpaceSibling = (node, next, inc) => {\n if (node) {\n const nextName = next ? 'nextSibling' : 'previousSibling';\n for (node = inc ? node : node[nextName]; node; node = node[nextName]) {\n if (isElement$6(node) || !isWhiteSpaceNode$1(node)) {\n return node;\n }\n }\n }\n return undefined;\n };\n const isTextBlock$1 = (schema, node) => !!schema.getTextBlockElements()[node.nodeName.toLowerCase()] || isTransparentBlock(schema, node);\n const isValid = (ed, parent, child) => {\n return ed.schema.isValidChild(parent, child);\n };\n const isWhiteSpaceNode$1 = (node, allowSpaces = false) => {\n if (isNonNullable(node) && isText$a(node)) {\n const data = allowSpaces ? node.data.replace(/ /g, '\\xA0') : node.data;\n return isWhitespaceText(data);\n } else {\n return false;\n }\n };\n const isEmptyTextNode$1 = node => {\n return isNonNullable(node) && isText$a(node) && node.length === 0;\n };\n const isWrapNoneditableTarget = (editor, node) => {\n const baseDataSelector = '[data-mce-cef-wrappable]';\n const formatNoneditableSelector = getFormatNoneditableSelector(editor);\n const selector = isEmpty$3(formatNoneditableSelector) ? baseDataSelector : `${ baseDataSelector },${ formatNoneditableSelector }`;\n return is$1(SugarElement.fromDom(node), selector);\n };\n const isWrappableNoneditable = (editor, node) => {\n const dom = editor.dom;\n return isElementNode$1(node) && dom.getContentEditable(node) === 'false' && isWrapNoneditableTarget(editor, node) && dom.select('[contenteditable=\"true\"]', node).length === 0;\n };\n const replaceVars = (value, vars) => {\n if (isFunction(value)) {\n return value(vars);\n } else if (isNonNullable(vars)) {\n value = value.replace(/%(\\w+)/g, (str, name) => {\n return vars[name] || str;\n });\n }\n return value;\n };\n const isEq$5 = (str1, str2) => {\n str1 = str1 || '';\n str2 = str2 || '';\n str1 = '' + (str1.nodeName || str1);\n str2 = '' + (str2.nodeName || str2);\n return str1.toLowerCase() === str2.toLowerCase();\n };\n const normalizeStyleValue = (value, name) => {\n if (isNullable(value)) {\n return null;\n } else {\n let strValue = String(value);\n if (name === 'color' || name === 'backgroundColor') {\n strValue = rgbaToHexString(strValue);\n }\n if (name === 'fontWeight' && value === 700) {\n strValue = 'bold';\n }\n if (name === 'fontFamily') {\n strValue = strValue.replace(/[\\'\\\"]/g, '').replace(/,\\s+/g, ',');\n }\n return strValue;\n }\n };\n const getStyle = (dom, node, name) => {\n const style = dom.getStyle(node, name);\n return normalizeStyleValue(style, name);\n };\n const getTextDecoration = (dom, node) => {\n let decoration;\n dom.getParent(node, n => {\n if (isElement$6(n)) {\n decoration = dom.getStyle(n, 'text-decoration');\n return !!decoration && decoration !== 'none';\n } else {\n return false;\n }\n });\n return decoration;\n };\n const getParents$2 = (dom, node, selector) => {\n return dom.getParents(node, selector, dom.getRoot());\n };\n const isFormatPredicate = (editor, formatName, predicate) => {\n const formats = editor.formatter.get(formatName);\n return isNonNullable(formats) && exists(formats, predicate);\n };\n const isVariableFormatName = (editor, formatName) => {\n const hasVariableValues = format => {\n const isVariableValue = val => isFunction(val) || val.length > 1 && val.charAt(0) === '%';\n return exists([\n 'styles',\n 'attributes'\n ], key => get$a(format, key).exists(field => {\n const fieldValues = isArray$1(field) ? field : values(field);\n return exists(fieldValues, isVariableValue);\n }));\n };\n return isFormatPredicate(editor, formatName, hasVariableValues);\n };\n const areSimilarFormats = (editor, formatName, otherFormatName) => {\n const validKeys = [\n 'inline',\n 'block',\n 'selector',\n 'attributes',\n 'styles',\n 'classes'\n ];\n const filterObj = format => filter$4(format, (_, key) => exists(validKeys, validKey => validKey === key));\n return isFormatPredicate(editor, formatName, fmt1 => {\n const filteredFmt1 = filterObj(fmt1);\n return isFormatPredicate(editor, otherFormatName, fmt2 => {\n const filteredFmt2 = filterObj(fmt2);\n return equal$1(filteredFmt1, filteredFmt2);\n });\n });\n };\n const isBlockFormat = format => hasNonNullableKey(format, 'block');\n const isWrappingBlockFormat = format => isBlockFormat(format) && format.wrapper === true;\n const isNonWrappingBlockFormat = format => isBlockFormat(format) && format.wrapper !== true;\n const isSelectorFormat = format => hasNonNullableKey(format, 'selector');\n const isInlineFormat = format => hasNonNullableKey(format, 'inline');\n const isMixedFormat = format => isSelectorFormat(format) && isInlineFormat(format) && is$2(get$a(format, 'mixed'), true);\n const shouldExpandToSelector = format => isSelectorFormat(format) && format.expand !== false && !isInlineFormat(format);\n const getEmptyCaretContainers = node => {\n const nodes = [];\n let tempNode = node;\n while (tempNode) {\n if (isText$a(tempNode) && tempNode.data !== ZWSP$1 || tempNode.childNodes.length > 1) {\n return [];\n }\n if (isElement$6(tempNode)) {\n nodes.push(tempNode);\n }\n tempNode = tempNode.firstChild;\n }\n return nodes;\n };\n const isCaretContainerEmpty = node => {\n return getEmptyCaretContainers(node).length > 0;\n };\n const isEmptyCaretFormatElement = element => {\n return isCaretNode(element.dom) && isCaretContainerEmpty(element.dom);\n };\n\n const isBookmarkNode = isBookmarkNode$1;\n const getParents$1 = getParents$2;\n const isWhiteSpaceNode = isWhiteSpaceNode$1;\n const isTextBlock = isTextBlock$1;\n const isBogusBr = node => {\n return isBr$6(node) && node.getAttribute('data-mce-bogus') && !node.nextSibling;\n };\n const findParentContentEditable = (dom, node) => {\n let parent = node;\n while (parent) {\n if (isElement$6(parent) && dom.getContentEditable(parent)) {\n return dom.getContentEditable(parent) === 'false' ? parent : node;\n }\n parent = parent.parentNode;\n }\n return node;\n };\n const walkText = (start, node, offset, predicate) => {\n const str = node.data;\n if (start) {\n for (let i = offset; i > 0; i--) {\n if (predicate(str.charAt(i - 1))) {\n return i;\n }\n }\n } else {\n for (let i = offset; i < str.length; i++) {\n if (predicate(str.charAt(i))) {\n return i;\n }\n }\n }\n return -1;\n };\n const findSpace = (start, node, offset) => walkText(start, node, offset, c => isNbsp(c) || isWhiteSpace(c));\n const findContent = (start, node, offset) => walkText(start, node, offset, isContent);\n const findWordEndPoint = (dom, body, container, offset, start, includeTrailingSpaces) => {\n let lastTextNode;\n const rootNode = dom.getParent(container, dom.isBlock) || body;\n const walk = (container, offset, pred) => {\n const textSeeker = TextSeeker(dom);\n const walker = start ? textSeeker.backwards : textSeeker.forwards;\n return Optional.from(walker(container, offset, (text, textOffset) => {\n if (isBookmarkNode(text.parentNode)) {\n return -1;\n } else {\n lastTextNode = text;\n return pred(start, text, textOffset);\n }\n }, rootNode));\n };\n const spaceResult = walk(container, offset, findSpace);\n return spaceResult.bind(result => includeTrailingSpaces ? walk(result.container, result.offset + (start ? -1 : 0), findContent) : Optional.some(result)).orThunk(() => lastTextNode ? Optional.some({\n container: lastTextNode,\n offset: start ? 0 : lastTextNode.length\n }) : Optional.none());\n };\n const findSelectorEndPoint = (dom, formatList, rng, container, siblingName) => {\n const sibling = container[siblingName];\n if (isText$a(container) && isEmpty$3(container.data) && sibling) {\n container = sibling;\n }\n const parents = getParents$1(dom, container);\n for (let i = 0; i < parents.length; i++) {\n for (let y = 0; y < formatList.length; y++) {\n const curFormat = formatList[y];\n if (isNonNullable(curFormat.collapsed) && curFormat.collapsed !== rng.collapsed) {\n continue;\n }\n if (isSelectorFormat(curFormat) && dom.is(parents[i], curFormat.selector)) {\n return parents[i];\n }\n }\n }\n return container;\n };\n const findBlockEndPoint = (dom, formatList, container, siblingName) => {\n var _a;\n let node = container;\n const root = dom.getRoot();\n const format = formatList[0];\n if (isBlockFormat(format)) {\n node = format.wrapper ? null : dom.getParent(container, format.block, root);\n }\n if (!node) {\n const scopeRoot = (_a = dom.getParent(container, 'LI,TD,TH,SUMMARY')) !== null && _a !== void 0 ? _a : root;\n node = dom.getParent(isText$a(container) ? container.parentNode : container, node => node !== root && isTextBlock(dom.schema, node), scopeRoot);\n }\n if (node && isBlockFormat(format) && format.wrapper) {\n node = getParents$1(dom, node, 'ul,ol').reverse()[0] || node;\n }\n if (!node) {\n node = container;\n while (node && node[siblingName] && !dom.isBlock(node[siblingName])) {\n node = node[siblingName];\n if (isEq$5(node, 'br')) {\n break;\n }\n }\n }\n return node || container;\n };\n const isAtBlockBoundary$1 = (dom, root, container, siblingName) => {\n const parent = container.parentNode;\n if (isNonNullable(container[siblingName])) {\n return false;\n } else if (parent === root || isNullable(parent) || dom.isBlock(parent)) {\n return true;\n } else {\n return isAtBlockBoundary$1(dom, root, parent, siblingName);\n }\n };\n const findParentContainer = (dom, formatList, container, offset, start) => {\n let parent = container;\n const siblingName = start ? 'previousSibling' : 'nextSibling';\n const root = dom.getRoot();\n if (isText$a(container) && !isWhiteSpaceNode(container)) {\n if (start ? offset > 0 : offset < container.data.length) {\n return container;\n }\n }\n while (parent) {\n if (!formatList[0].block_expand && dom.isBlock(parent)) {\n return parent;\n }\n for (let sibling = parent[siblingName]; sibling; sibling = sibling[siblingName]) {\n const allowSpaces = isText$a(sibling) && !isAtBlockBoundary$1(dom, root, sibling, siblingName);\n if (!isBookmarkNode(sibling) && !isBogusBr(sibling) && !isWhiteSpaceNode(sibling, allowSpaces)) {\n return parent;\n }\n }\n if (parent === root || parent.parentNode === root) {\n container = parent;\n break;\n }\n parent = parent.parentNode;\n }\n return container;\n };\n const isSelfOrParentBookmark = container => isBookmarkNode(container.parentNode) || isBookmarkNode(container);\n const expandRng = (dom, rng, formatList, includeTrailingSpace = false) => {\n let {startContainer, startOffset, endContainer, endOffset} = rng;\n const format = formatList[0];\n if (isElement$6(startContainer) && startContainer.hasChildNodes()) {\n startContainer = getNode$1(startContainer, startOffset);\n if (isText$a(startContainer)) {\n startOffset = 0;\n }\n }\n if (isElement$6(endContainer) && endContainer.hasChildNodes()) {\n endContainer = getNode$1(endContainer, rng.collapsed ? endOffset : endOffset - 1);\n if (isText$a(endContainer)) {\n endOffset = endContainer.data.length;\n }\n }\n startContainer = findParentContentEditable(dom, startContainer);\n endContainer = findParentContentEditable(dom, endContainer);\n if (isSelfOrParentBookmark(startContainer)) {\n startContainer = isBookmarkNode(startContainer) ? startContainer : startContainer.parentNode;\n if (rng.collapsed) {\n startContainer = startContainer.previousSibling || startContainer;\n } else {\n startContainer = startContainer.nextSibling || startContainer;\n }\n if (isText$a(startContainer)) {\n startOffset = rng.collapsed ? startContainer.length : 0;\n }\n }\n if (isSelfOrParentBookmark(endContainer)) {\n endContainer = isBookmarkNode(endContainer) ? endContainer : endContainer.parentNode;\n if (rng.collapsed) {\n endContainer = endContainer.nextSibling || endContainer;\n } else {\n endContainer = endContainer.previousSibling || endContainer;\n }\n if (isText$a(endContainer)) {\n endOffset = rng.collapsed ? 0 : endContainer.length;\n }\n }\n if (rng.collapsed) {\n const startPoint = findWordEndPoint(dom, dom.getRoot(), startContainer, startOffset, true, includeTrailingSpace);\n startPoint.each(({container, offset}) => {\n startContainer = container;\n startOffset = offset;\n });\n const endPoint = findWordEndPoint(dom, dom.getRoot(), endContainer, endOffset, false, includeTrailingSpace);\n endPoint.each(({container, offset}) => {\n endContainer = container;\n endOffset = offset;\n });\n }\n if (isInlineFormat(format) || format.block_expand) {\n if (!isInlineFormat(format) || (!isText$a(startContainer) || startOffset === 0)) {\n startContainer = findParentContainer(dom, formatList, startContainer, startOffset, true);\n }\n if (!isInlineFormat(format) || (!isText$a(endContainer) || endOffset === endContainer.data.length)) {\n endContainer = findParentContainer(dom, formatList, endContainer, endOffset, false);\n }\n }\n if (shouldExpandToSelector(format)) {\n startContainer = findSelectorEndPoint(dom, formatList, rng, startContainer, 'previousSibling');\n endContainer = findSelectorEndPoint(dom, formatList, rng, endContainer, 'nextSibling');\n }\n if (isBlockFormat(format) || isSelectorFormat(format)) {\n startContainer = findBlockEndPoint(dom, formatList, startContainer, 'previousSibling');\n endContainer = findBlockEndPoint(dom, formatList, endContainer, 'nextSibling');\n if (isBlockFormat(format)) {\n if (!dom.isBlock(startContainer)) {\n startContainer = findParentContainer(dom, formatList, startContainer, startOffset, true);\n }\n if (!dom.isBlock(endContainer)) {\n endContainer = findParentContainer(dom, formatList, endContainer, endOffset, false);\n }\n }\n }\n if (isElement$6(startContainer) && startContainer.parentNode) {\n startOffset = dom.nodeIndex(startContainer);\n startContainer = startContainer.parentNode;\n }\n if (isElement$6(endContainer) && endContainer.parentNode) {\n endOffset = dom.nodeIndex(endContainer) + 1;\n endContainer = endContainer.parentNode;\n }\n return {\n startContainer,\n startOffset,\n endContainer,\n endOffset\n };\n };\n\n const walk$3 = (dom, rng, callback) => {\n var _a;\n const startOffset = rng.startOffset;\n const startContainer = getNode$1(rng.startContainer, startOffset);\n const endOffset = rng.endOffset;\n const endContainer = getNode$1(rng.endContainer, endOffset - 1);\n const exclude = nodes => {\n const firstNode = nodes[0];\n if (isText$a(firstNode) && firstNode === startContainer && startOffset >= firstNode.data.length) {\n nodes.splice(0, 1);\n }\n const lastNode = nodes[nodes.length - 1];\n if (endOffset === 0 && nodes.length > 0 && lastNode === endContainer && isText$a(lastNode)) {\n nodes.splice(nodes.length - 1, 1);\n }\n return nodes;\n };\n const collectSiblings = (node, name, endNode) => {\n const siblings = [];\n for (; node && node !== endNode; node = node[name]) {\n siblings.push(node);\n }\n return siblings;\n };\n const findEndPoint = (node, root) => dom.getParent(node, node => node.parentNode === root, root);\n const walkBoundary = (startNode, endNode, next) => {\n const siblingName = next ? 'nextSibling' : 'previousSibling';\n for (let node = startNode, parent = node.parentNode; node && node !== endNode; node = parent) {\n parent = node.parentNode;\n const siblings = collectSiblings(node === startNode ? node : node[siblingName], siblingName);\n if (siblings.length) {\n if (!next) {\n siblings.reverse();\n }\n callback(exclude(siblings));\n }\n }\n };\n if (startContainer === endContainer) {\n return callback(exclude([startContainer]));\n }\n const ancestor = (_a = dom.findCommonAncestor(startContainer, endContainer)) !== null && _a !== void 0 ? _a : dom.getRoot();\n if (dom.isChildOf(startContainer, endContainer)) {\n return walkBoundary(startContainer, ancestor, true);\n }\n if (dom.isChildOf(endContainer, startContainer)) {\n return walkBoundary(endContainer, ancestor);\n }\n const startPoint = findEndPoint(startContainer, ancestor) || startContainer;\n const endPoint = findEndPoint(endContainer, ancestor) || endContainer;\n walkBoundary(startContainer, startPoint, true);\n const siblings = collectSiblings(startPoint === startContainer ? startPoint : startPoint.nextSibling, 'nextSibling', endPoint === endContainer ? endPoint.nextSibling : endPoint);\n if (siblings.length) {\n callback(exclude(siblings));\n }\n walkBoundary(endContainer, endPoint);\n };\n\n const validBlocks = [\n 'pre[class*=language-][contenteditable=\"false\"]',\n 'figure.image',\n 'div[data-ephox-embed-iri]',\n 'div.tiny-pageembed',\n 'div.mce-toc',\n 'div[data-mce-toc]'\n ];\n const isZeroWidth = elem => isText$b(elem) && get$3(elem) === ZWSP$1;\n const context = (editor, elem, wrapName, nodeName) => parent(elem).fold(() => 'skipping', parent => {\n if (nodeName === 'br' || isZeroWidth(elem)) {\n return 'valid';\n } else if (isAnnotation(elem)) {\n return 'existing';\n } else if (isCaretNode(elem.dom)) {\n return 'caret';\n } else if (exists(validBlocks, selector => is$1(elem, selector))) {\n return 'valid-block';\n } else if (!isValid(editor, wrapName, nodeName) || !isValid(editor, name(parent), wrapName)) {\n return 'invalid-child';\n } else {\n return 'valid';\n }\n });\n\n const applyWordGrab = (editor, rng) => {\n const r = expandRng(editor.dom, rng, [{ inline: 'span' }]);\n rng.setStart(r.startContainer, r.startOffset);\n rng.setEnd(r.endContainer, r.endOffset);\n editor.selection.setRng(rng);\n };\n const applyAnnotation = (elem, masterUId, data, annotationName, decorate, directAnnotation) => {\n const {uid = masterUId, ...otherData} = data;\n add$2(elem, annotation());\n set$3(elem, `${ dataAnnotationId() }`, uid);\n set$3(elem, `${ dataAnnotation() }`, annotationName);\n const {attributes = {}, classes = []} = decorate(uid, otherData);\n setAll$1(elem, attributes);\n add(elem, classes);\n if (directAnnotation) {\n if (classes.length > 0) {\n set$3(elem, `${ dataAnnotationClasses() }`, classes.join(','));\n }\n const attributeNames = keys(attributes);\n if (attributeNames.length > 0) {\n set$3(elem, `${ dataAnnotationAttributes() }`, attributeNames.join(','));\n }\n }\n };\n const removeDirectAnnotation = elem => {\n remove$7(elem, annotation());\n remove$a(elem, `${ dataAnnotationId() }`);\n remove$a(elem, `${ dataAnnotation() }`);\n remove$a(elem, `${ dataAnnotationActive() }`);\n const customAttrNames = getOpt(elem, `${ dataAnnotationAttributes() }`).map(names => names.split(',')).getOr([]);\n const customClasses = getOpt(elem, `${ dataAnnotationClasses() }`).map(names => names.split(',')).getOr([]);\n each$e(customAttrNames, name => remove$a(elem, name));\n remove$4(elem, customClasses);\n remove$a(elem, `${ dataAnnotationClasses() }`);\n remove$a(elem, `${ dataAnnotationAttributes() }`);\n };\n const makeAnnotation = (eDoc, uid, data, annotationName, decorate) => {\n const master = SugarElement.fromTag('span', eDoc);\n applyAnnotation(master, uid, data, annotationName, decorate, false);\n return master;\n };\n const annotate = (editor, rng, uid, annotationName, decorate, data) => {\n const newWrappers = [];\n const master = makeAnnotation(editor.getDoc(), uid, data, annotationName, decorate);\n const wrapper = value$2();\n const finishWrapper = () => {\n wrapper.clear();\n };\n const getOrOpenWrapper = () => wrapper.get().getOrThunk(() => {\n const nu = shallow$1(master);\n newWrappers.push(nu);\n wrapper.set(nu);\n return nu;\n });\n const processElements = elems => {\n each$e(elems, processElement);\n };\n const processElement = elem => {\n const ctx = context(editor, elem, 'span', name(elem));\n switch (ctx) {\n case 'invalid-child': {\n finishWrapper();\n const children = children$1(elem);\n processElements(children);\n finishWrapper();\n break;\n }\n case 'valid-block': {\n finishWrapper();\n applyAnnotation(elem, uid, data, annotationName, decorate, true);\n break;\n }\n case 'valid': {\n const w = getOrOpenWrapper();\n wrap$2(elem, w);\n break;\n }\n }\n };\n const processNodes = nodes => {\n const elems = map$3(nodes, SugarElement.fromDom);\n processElements(elems);\n };\n walk$3(editor.dom, rng, nodes => {\n finishWrapper();\n processNodes(nodes);\n });\n return newWrappers;\n };\n const annotateWithBookmark = (editor, name, settings, data) => {\n editor.undoManager.transact(() => {\n const selection = editor.selection;\n const initialRng = selection.getRng();\n const hasFakeSelection = getCellsFromEditor(editor).length > 0;\n const masterUid = generate$1('mce-annotation');\n if (initialRng.collapsed && !hasFakeSelection) {\n applyWordGrab(editor, initialRng);\n }\n if (selection.getRng().collapsed && !hasFakeSelection) {\n const wrapper = makeAnnotation(editor.getDoc(), masterUid, data, name, settings.decorate);\n set$1(wrapper, nbsp);\n selection.getRng().insertNode(wrapper.dom);\n selection.select(wrapper.dom);\n } else {\n preserve(selection, false, () => {\n runOnRanges(editor, selectionRng => {\n annotate(editor, selectionRng, masterUid, name, settings.decorate, data);\n });\n });\n }\n });\n };\n\n const Annotator = editor => {\n const registry = create$c();\n setup$x(editor, registry);\n const changes = setup$y(editor, registry);\n const isSpan = isTag('span');\n const removeAnnotations = elements => {\n each$e(elements, element => {\n if (isSpan(element)) {\n unwrap(element);\n } else {\n removeDirectAnnotation(element);\n }\n });\n };\n return {\n register: (name, settings) => {\n registry.register(name, settings);\n },\n annotate: (name, data) => {\n registry.lookup(name).each(settings => {\n annotateWithBookmark(editor, name, settings, data);\n });\n },\n annotationChanged: (name, callback) => {\n changes.addListener(name, callback);\n },\n remove: name => {\n identify(editor, Optional.some(name)).each(({elements}) => {\n const bookmark = editor.selection.getBookmark();\n removeAnnotations(elements);\n editor.selection.moveToBookmark(bookmark);\n });\n },\n removeAll: name => {\n const bookmark = editor.selection.getBookmark();\n each$d(findAll(editor, name), (elements, _) => {\n removeAnnotations(elements);\n });\n editor.selection.moveToBookmark(bookmark);\n },\n getAll: name => {\n const directory = findAll(editor, name);\n return map$2(directory, elems => map$3(elems, elem => elem.dom));\n }\n };\n };\n\n const BookmarkManager = selection => {\n return {\n getBookmark: curry(getBookmark$1, selection),\n moveToBookmark: curry(moveToBookmark, selection)\n };\n };\n BookmarkManager.isBookmarkNode = isBookmarkNode$1;\n\n const isXYWithinRange = (clientX, clientY, range) => {\n if (range.collapsed) {\n return false;\n } else {\n return exists(range.getClientRects(), rect => containsXY(rect, clientX, clientY));\n }\n };\n\n const firePreProcess = (editor, args) => editor.dispatch('PreProcess', args);\n const firePostProcess = (editor, args) => editor.dispatch('PostProcess', args);\n const fireRemove = editor => {\n editor.dispatch('remove');\n };\n const fireDetach = editor => {\n editor.dispatch('detach');\n };\n const fireSwitchMode = (editor, mode) => {\n editor.dispatch('SwitchMode', { mode });\n };\n const fireObjectResizeStart = (editor, target, width, height, origin) => {\n editor.dispatch('ObjectResizeStart', {\n target,\n width,\n height,\n origin\n });\n };\n const fireObjectResized = (editor, target, width, height, origin) => {\n editor.dispatch('ObjectResized', {\n target,\n width,\n height,\n origin\n });\n };\n const firePreInit = editor => {\n editor.dispatch('PreInit');\n };\n const firePostRender = editor => {\n editor.dispatch('PostRender');\n };\n const fireInit = editor => {\n editor.dispatch('Init');\n };\n const firePlaceholderToggle = (editor, state) => {\n editor.dispatch('PlaceholderToggle', { state });\n };\n const fireError = (editor, errorType, error) => {\n editor.dispatch(errorType, error);\n };\n const fireFormatApply = (editor, format, node, vars) => {\n editor.dispatch('FormatApply', {\n format,\n node,\n vars\n });\n };\n const fireFormatRemove = (editor, format, node, vars) => {\n editor.dispatch('FormatRemove', {\n format,\n node,\n vars\n });\n };\n const fireBeforeSetContent = (editor, args) => editor.dispatch('BeforeSetContent', args);\n const fireSetContent = (editor, args) => editor.dispatch('SetContent', args);\n const fireBeforeGetContent = (editor, args) => editor.dispatch('BeforeGetContent', args);\n const fireGetContent = (editor, args) => editor.dispatch('GetContent', args);\n const fireAutocompleterStart = (editor, args) => {\n editor.dispatch('AutocompleterStart', args);\n };\n const fireAutocompleterUpdate = (editor, args) => {\n editor.dispatch('AutocompleterUpdate', args);\n };\n const fireAutocompleterEnd = editor => {\n editor.dispatch('AutocompleterEnd');\n };\n const firePastePreProcess = (editor, html, internal) => editor.dispatch('PastePreProcess', {\n content: html,\n internal\n });\n const firePastePostProcess = (editor, node, internal) => editor.dispatch('PastePostProcess', {\n node,\n internal\n });\n const firePastePlainTextToggle = (editor, state) => editor.dispatch('PastePlainTextToggle', { state });\n const fireEditableRootStateChange = (editor, state) => editor.dispatch('EditableRootStateChange', { state });\n\n const VK = {\n BACKSPACE: 8,\n DELETE: 46,\n DOWN: 40,\n ENTER: 13,\n ESC: 27,\n LEFT: 37,\n RIGHT: 39,\n SPACEBAR: 32,\n TAB: 9,\n UP: 38,\n PAGE_UP: 33,\n PAGE_DOWN: 34,\n END: 35,\n HOME: 36,\n modifierPressed: e => {\n return e.shiftKey || e.ctrlKey || e.altKey || VK.metaKeyPressed(e);\n },\n metaKeyPressed: e => {\n return Env.os.isMacOS() || Env.os.isiOS() ? e.metaKey : e.ctrlKey && !e.altKey;\n }\n };\n\n const elementSelectionAttr = 'data-mce-selected';\n const controlElmSelector = 'table,img,figure.image,hr,video,span.mce-preview-object,details';\n const abs = Math.abs;\n const round$1 = Math.round;\n const resizeHandles = {\n nw: [\n 0,\n 0,\n -1,\n -1\n ],\n ne: [\n 1,\n 0,\n 1,\n -1\n ],\n se: [\n 1,\n 1,\n 1,\n 1\n ],\n sw: [\n 0,\n 1,\n -1,\n 1\n ]\n };\n const isTouchEvent = evt => evt.type === 'longpress' || evt.type.indexOf('touch') === 0;\n const ControlSelection = (selection, editor) => {\n const dom = editor.dom;\n const editableDoc = editor.getDoc();\n const rootDocument = document;\n const rootElement = editor.getBody();\n let selectedElm, selectedElmGhost, resizeHelper, selectedHandle, resizeBackdrop;\n let startX, startY, selectedElmX, selectedElmY, startW, startH, ratio, resizeStarted;\n let width;\n let height;\n let startScrollWidth;\n let startScrollHeight;\n const isImage = elm => isNonNullable(elm) && (isImg(elm) || dom.is(elm, 'figure.image'));\n const isMedia = elm => isMedia$2(elm) || dom.hasClass(elm, 'mce-preview-object');\n const isEventOnImageOutsideRange = (evt, range) => {\n if (isTouchEvent(evt)) {\n const touch = evt.touches[0];\n return isImage(evt.target) && !isXYWithinRange(touch.clientX, touch.clientY, range);\n } else {\n return isImage(evt.target) && !isXYWithinRange(evt.clientX, evt.clientY, range);\n }\n };\n const contextMenuSelectImage = evt => {\n const target = evt.target;\n if (isEventOnImageOutsideRange(evt, editor.selection.getRng()) && !evt.isDefaultPrevented()) {\n editor.selection.select(target);\n }\n };\n const getResizeTargets = elm => {\n if (dom.hasClass(elm, 'mce-preview-object') && isNonNullable(elm.firstElementChild)) {\n return [\n elm,\n elm.firstElementChild\n ];\n } else if (dom.is(elm, 'figure.image')) {\n return [elm.querySelector('img')];\n } else {\n return [elm];\n }\n };\n const isResizable = elm => {\n const selector = getObjectResizing(editor);\n if (!selector) {\n return false;\n }\n if (elm.getAttribute('data-mce-resize') === 'false') {\n return false;\n }\n if (elm === editor.getBody()) {\n return false;\n }\n if (dom.hasClass(elm, 'mce-preview-object') && isNonNullable(elm.firstElementChild)) {\n return is$1(SugarElement.fromDom(elm.firstElementChild), selector);\n } else {\n return is$1(SugarElement.fromDom(elm), selector);\n }\n };\n const createGhostElement = elm => {\n if (isMedia(elm)) {\n return dom.create('img', { src: Env.transparentSrc });\n } else {\n return elm.cloneNode(true);\n }\n };\n const setSizeProp = (element, name, value) => {\n if (isNonNullable(value)) {\n const targets = getResizeTargets(element);\n each$e(targets, target => {\n if (target.style[name] || !editor.schema.isValid(target.nodeName.toLowerCase(), name)) {\n dom.setStyle(target, name, value);\n } else {\n dom.setAttrib(target, name, '' + value);\n }\n });\n }\n };\n const setGhostElmSize = (ghostElm, width, height) => {\n setSizeProp(ghostElm, 'width', width);\n setSizeProp(ghostElm, 'height', height);\n };\n const resizeGhostElement = e => {\n let deltaX, deltaY, proportional;\n let resizeHelperX, resizeHelperY;\n deltaX = e.screenX - startX;\n deltaY = e.screenY - startY;\n width = deltaX * selectedHandle[2] + startW;\n height = deltaY * selectedHandle[3] + startH;\n width = width < 5 ? 5 : width;\n height = height < 5 ? 5 : height;\n if ((isImage(selectedElm) || isMedia(selectedElm)) && getResizeImgProportional(editor) !== false) {\n proportional = !VK.modifierPressed(e);\n } else {\n proportional = VK.modifierPressed(e);\n }\n if (proportional) {\n if (abs(deltaX) > abs(deltaY)) {\n height = round$1(width * ratio);\n width = round$1(height / ratio);\n } else {\n width = round$1(height / ratio);\n height = round$1(width * ratio);\n }\n }\n setGhostElmSize(selectedElmGhost, width, height);\n resizeHelperX = selectedHandle.startPos.x + deltaX;\n resizeHelperY = selectedHandle.startPos.y + deltaY;\n resizeHelperX = resizeHelperX > 0 ? resizeHelperX : 0;\n resizeHelperY = resizeHelperY > 0 ? resizeHelperY : 0;\n dom.setStyles(resizeHelper, {\n left: resizeHelperX,\n top: resizeHelperY,\n display: 'block'\n });\n resizeHelper.innerHTML = width + ' × ' + height;\n if (selectedHandle[2] < 0 && selectedElmGhost.clientWidth <= width) {\n dom.setStyle(selectedElmGhost, 'left', selectedElmX + (startW - width));\n }\n if (selectedHandle[3] < 0 && selectedElmGhost.clientHeight <= height) {\n dom.setStyle(selectedElmGhost, 'top', selectedElmY + (startH - height));\n }\n deltaX = rootElement.scrollWidth - startScrollWidth;\n deltaY = rootElement.scrollHeight - startScrollHeight;\n if (deltaX + deltaY !== 0) {\n dom.setStyles(resizeHelper, {\n left: resizeHelperX - deltaX,\n top: resizeHelperY - deltaY\n });\n }\n if (!resizeStarted) {\n fireObjectResizeStart(editor, selectedElm, startW, startH, 'corner-' + selectedHandle.name);\n resizeStarted = true;\n }\n };\n const endGhostResize = () => {\n const wasResizeStarted = resizeStarted;\n resizeStarted = false;\n if (wasResizeStarted) {\n setSizeProp(selectedElm, 'width', width);\n setSizeProp(selectedElm, 'height', height);\n }\n dom.unbind(editableDoc, 'mousemove', resizeGhostElement);\n dom.unbind(editableDoc, 'mouseup', endGhostResize);\n if (rootDocument !== editableDoc) {\n dom.unbind(rootDocument, 'mousemove', resizeGhostElement);\n dom.unbind(rootDocument, 'mouseup', endGhostResize);\n }\n dom.remove(selectedElmGhost);\n dom.remove(resizeHelper);\n dom.remove(resizeBackdrop);\n showResizeRect(selectedElm);\n if (wasResizeStarted) {\n fireObjectResized(editor, selectedElm, width, height, 'corner-' + selectedHandle.name);\n dom.setAttrib(selectedElm, 'style', dom.getAttrib(selectedElm, 'style'));\n }\n editor.nodeChanged();\n };\n const showResizeRect = targetElm => {\n unbindResizeHandleEvents();\n const position = dom.getPos(targetElm, rootElement);\n const selectedElmX = position.x;\n const selectedElmY = position.y;\n const rect = targetElm.getBoundingClientRect();\n const targetWidth = rect.width || rect.right - rect.left;\n const targetHeight = rect.height || rect.bottom - rect.top;\n if (selectedElm !== targetElm) {\n hideResizeRect();\n selectedElm = targetElm;\n width = height = 0;\n }\n const e = editor.dispatch('ObjectSelected', { target: targetElm });\n if (isResizable(targetElm) && !e.isDefaultPrevented()) {\n each$d(resizeHandles, (handle, name) => {\n const startDrag = e => {\n const target = getResizeTargets(selectedElm)[0];\n startX = e.screenX;\n startY = e.screenY;\n startW = target.clientWidth;\n startH = target.clientHeight;\n ratio = startH / startW;\n selectedHandle = handle;\n selectedHandle.name = name;\n selectedHandle.startPos = {\n x: targetWidth * handle[0] + selectedElmX,\n y: targetHeight * handle[1] + selectedElmY\n };\n startScrollWidth = rootElement.scrollWidth;\n startScrollHeight = rootElement.scrollHeight;\n resizeBackdrop = dom.add(rootElement, 'div', {\n 'class': 'mce-resize-backdrop',\n 'data-mce-bogus': 'all'\n });\n dom.setStyles(resizeBackdrop, {\n position: 'fixed',\n left: '0',\n top: '0',\n width: '100%',\n height: '100%'\n });\n selectedElmGhost = createGhostElement(selectedElm);\n dom.addClass(selectedElmGhost, 'mce-clonedresizable');\n dom.setAttrib(selectedElmGhost, 'data-mce-bogus', 'all');\n selectedElmGhost.contentEditable = 'false';\n dom.setStyles(selectedElmGhost, {\n left: selectedElmX,\n top: selectedElmY,\n margin: 0\n });\n setGhostElmSize(selectedElmGhost, targetWidth, targetHeight);\n selectedElmGhost.removeAttribute(elementSelectionAttr);\n rootElement.appendChild(selectedElmGhost);\n dom.bind(editableDoc, 'mousemove', resizeGhostElement);\n dom.bind(editableDoc, 'mouseup', endGhostResize);\n if (rootDocument !== editableDoc) {\n dom.bind(rootDocument, 'mousemove', resizeGhostElement);\n dom.bind(rootDocument, 'mouseup', endGhostResize);\n }\n resizeHelper = dom.add(rootElement, 'div', {\n 'class': 'mce-resize-helper',\n 'data-mce-bogus': 'all'\n }, startW + ' × ' + startH);\n };\n let handleElm = dom.get('mceResizeHandle' + name);\n if (handleElm) {\n dom.remove(handleElm);\n }\n handleElm = dom.add(rootElement, 'div', {\n 'id': 'mceResizeHandle' + name,\n 'data-mce-bogus': 'all',\n 'class': 'mce-resizehandle',\n 'unselectable': true,\n 'style': 'cursor:' + name + '-resize; margin:0; padding:0'\n });\n dom.bind(handleElm, 'mousedown', e => {\n e.stopImmediatePropagation();\n e.preventDefault();\n startDrag(e);\n });\n handle.elm = handleElm;\n dom.setStyles(handleElm, {\n left: targetWidth * handle[0] + selectedElmX - handleElm.offsetWidth / 2,\n top: targetHeight * handle[1] + selectedElmY - handleElm.offsetHeight / 2\n });\n });\n } else {\n hideResizeRect(false);\n }\n };\n const throttledShowResizeRect = first$1(showResizeRect, 0);\n const hideResizeRect = (removeSelected = true) => {\n throttledShowResizeRect.cancel();\n unbindResizeHandleEvents();\n if (selectedElm && removeSelected) {\n selectedElm.removeAttribute(elementSelectionAttr);\n }\n each$d(resizeHandles, (value, name) => {\n const handleElm = dom.get('mceResizeHandle' + name);\n if (handleElm) {\n dom.unbind(handleElm);\n dom.remove(handleElm);\n }\n });\n };\n const isChildOrEqual = (node, parent) => dom.isChildOf(node, parent);\n const updateResizeRect = e => {\n if (resizeStarted || editor.removed || editor.composing) {\n return;\n }\n const targetElm = e.type === 'mousedown' ? e.target : selection.getNode();\n const controlElm = closest$3(SugarElement.fromDom(targetElm), controlElmSelector).map(e => e.dom).filter(e => dom.isEditable(e.parentElement) || e.nodeName === 'IMG' && dom.isEditable(e)).getOrUndefined();\n const selectedValue = isNonNullable(controlElm) ? dom.getAttrib(controlElm, elementSelectionAttr, '1') : '1';\n each$e(dom.select(`img[${ elementSelectionAttr }],hr[${ elementSelectionAttr }]`), img => {\n img.removeAttribute(elementSelectionAttr);\n });\n if (isNonNullable(controlElm) && isChildOrEqual(controlElm, rootElement) && editor.hasFocus()) {\n disableGeckoResize();\n const startElm = selection.getStart(true);\n if (isChildOrEqual(startElm, controlElm) && isChildOrEqual(selection.getEnd(true), controlElm)) {\n dom.setAttrib(controlElm, elementSelectionAttr, selectedValue);\n throttledShowResizeRect.throttle(controlElm);\n return;\n }\n }\n hideResizeRect();\n };\n const unbindResizeHandleEvents = () => {\n each$d(resizeHandles, handle => {\n if (handle.elm) {\n dom.unbind(handle.elm);\n delete handle.elm;\n }\n });\n };\n const disableGeckoResize = () => {\n try {\n editor.getDoc().execCommand('enableObjectResizing', false, 'false');\n } catch (ex) {\n }\n };\n editor.on('init', () => {\n disableGeckoResize();\n editor.on('NodeChange ResizeEditor ResizeWindow ResizeContent drop', updateResizeRect);\n editor.on('keyup compositionend', e => {\n if (selectedElm && selectedElm.nodeName === 'TABLE') {\n updateResizeRect(e);\n }\n });\n editor.on('hide blur', hideResizeRect);\n editor.on('contextmenu longpress', contextMenuSelectImage, true);\n });\n editor.on('remove', unbindResizeHandleEvents);\n const destroy = () => {\n throttledShowResizeRect.cancel();\n selectedElm = selectedElmGhost = resizeBackdrop = null;\n };\n return {\n isResizable,\n showResizeRect,\n hideResizeRect,\n updateResizeRect,\n destroy\n };\n };\n\n const setStart = (rng, situ) => {\n situ.fold(e => {\n rng.setStartBefore(e.dom);\n }, (e, o) => {\n rng.setStart(e.dom, o);\n }, e => {\n rng.setStartAfter(e.dom);\n });\n };\n const setFinish = (rng, situ) => {\n situ.fold(e => {\n rng.setEndBefore(e.dom);\n }, (e, o) => {\n rng.setEnd(e.dom, o);\n }, e => {\n rng.setEndAfter(e.dom);\n });\n };\n const relativeToNative = (win, startSitu, finishSitu) => {\n const range = win.document.createRange();\n setStart(range, startSitu);\n setFinish(range, finishSitu);\n return range;\n };\n const exactToNative = (win, start, soffset, finish, foffset) => {\n const rng = win.document.createRange();\n rng.setStart(start.dom, soffset);\n rng.setEnd(finish.dom, foffset);\n return rng;\n };\n\n const adt$3 = Adt.generate([\n {\n ltr: [\n 'start',\n 'soffset',\n 'finish',\n 'foffset'\n ]\n },\n {\n rtl: [\n 'start',\n 'soffset',\n 'finish',\n 'foffset'\n ]\n }\n ]);\n const fromRange = (win, type, range) => type(SugarElement.fromDom(range.startContainer), range.startOffset, SugarElement.fromDom(range.endContainer), range.endOffset);\n const getRanges = (win, selection) => selection.match({\n domRange: rng => {\n return {\n ltr: constant(rng),\n rtl: Optional.none\n };\n },\n relative: (startSitu, finishSitu) => {\n return {\n ltr: cached(() => relativeToNative(win, startSitu, finishSitu)),\n rtl: cached(() => Optional.some(relativeToNative(win, finishSitu, startSitu)))\n };\n },\n exact: (start, soffset, finish, foffset) => {\n return {\n ltr: cached(() => exactToNative(win, start, soffset, finish, foffset)),\n rtl: cached(() => Optional.some(exactToNative(win, finish, foffset, start, soffset)))\n };\n }\n });\n const doDiagnose = (win, ranges) => {\n const rng = ranges.ltr();\n if (rng.collapsed) {\n const reversed = ranges.rtl().filter(rev => rev.collapsed === false);\n return reversed.map(rev => adt$3.rtl(SugarElement.fromDom(rev.endContainer), rev.endOffset, SugarElement.fromDom(rev.startContainer), rev.startOffset)).getOrThunk(() => fromRange(win, adt$3.ltr, rng));\n } else {\n return fromRange(win, adt$3.ltr, rng);\n }\n };\n const diagnose = (win, selection) => {\n const ranges = getRanges(win, selection);\n return doDiagnose(win, ranges);\n };\n adt$3.ltr;\n adt$3.rtl;\n\n const create$a = (start, soffset, finish, foffset) => ({\n start,\n soffset,\n finish,\n foffset\n });\n const SimRange = { create: create$a };\n\n const caretPositionFromPoint = (doc, x, y) => {\n var _a, _b;\n return Optional.from((_b = (_a = doc.dom).caretPositionFromPoint) === null || _b === void 0 ? void 0 : _b.call(_a, x, y)).bind(pos => {\n if (pos.offsetNode === null) {\n return Optional.none();\n }\n const r = doc.dom.createRange();\n r.setStart(pos.offsetNode, pos.offset);\n r.collapse();\n return Optional.some(r);\n });\n };\n const caretRangeFromPoint = (doc, x, y) => {\n var _a, _b;\n return Optional.from((_b = (_a = doc.dom).caretRangeFromPoint) === null || _b === void 0 ? void 0 : _b.call(_a, x, y));\n };\n const availableSearch = (() => {\n if (document.caretPositionFromPoint) {\n return caretPositionFromPoint;\n } else if (document.caretRangeFromPoint) {\n return caretRangeFromPoint;\n } else {\n return Optional.none;\n }\n })();\n const fromPoint$1 = (win, x, y) => {\n const doc = SugarElement.fromDom(win.document);\n return availableSearch(doc, x, y).map(rng => SimRange.create(SugarElement.fromDom(rng.startContainer), rng.startOffset, SugarElement.fromDom(rng.endContainer), rng.endOffset));\n };\n\n const adt$2 = Adt.generate([\n { before: ['element'] },\n {\n on: [\n 'element',\n 'offset'\n ]\n },\n { after: ['element'] }\n ]);\n const cata = (subject, onBefore, onOn, onAfter) => subject.fold(onBefore, onOn, onAfter);\n const getStart$2 = situ => situ.fold(identity, identity, identity);\n const before$1 = adt$2.before;\n const on = adt$2.on;\n const after$1 = adt$2.after;\n const Situ = {\n before: before$1,\n on,\n after: after$1,\n cata,\n getStart: getStart$2\n };\n\n const adt$1 = Adt.generate([\n { domRange: ['rng'] },\n {\n relative: [\n 'startSitu',\n 'finishSitu'\n ]\n },\n {\n exact: [\n 'start',\n 'soffset',\n 'finish',\n 'foffset'\n ]\n }\n ]);\n const exactFromRange = simRange => adt$1.exact(simRange.start, simRange.soffset, simRange.finish, simRange.foffset);\n const getStart$1 = selection => selection.match({\n domRange: rng => SugarElement.fromDom(rng.startContainer),\n relative: (startSitu, _finishSitu) => Situ.getStart(startSitu),\n exact: (start, _soffset, _finish, _foffset) => start\n });\n const domRange = adt$1.domRange;\n const relative = adt$1.relative;\n const exact = adt$1.exact;\n const getWin = selection => {\n const start = getStart$1(selection);\n return defaultView(start);\n };\n const range = SimRange.create;\n const SimSelection = {\n domRange,\n relative,\n exact,\n exactFromRange,\n getWin,\n range\n };\n\n const beforeSpecial = (element, offset) => {\n const name$1 = name(element);\n if ('input' === name$1) {\n return Situ.after(element);\n } else if (!contains$2([\n 'br',\n 'img'\n ], name$1)) {\n return Situ.on(element, offset);\n } else {\n return offset === 0 ? Situ.before(element) : Situ.after(element);\n }\n };\n const preprocessRelative = (startSitu, finishSitu) => {\n const start = startSitu.fold(Situ.before, beforeSpecial, Situ.after);\n const finish = finishSitu.fold(Situ.before, beforeSpecial, Situ.after);\n return SimSelection.relative(start, finish);\n };\n const preprocessExact = (start, soffset, finish, foffset) => {\n const startSitu = beforeSpecial(start, soffset);\n const finishSitu = beforeSpecial(finish, foffset);\n return SimSelection.relative(startSitu, finishSitu);\n };\n const preprocess = selection => selection.match({\n domRange: rng => {\n const start = SugarElement.fromDom(rng.startContainer);\n const finish = SugarElement.fromDom(rng.endContainer);\n return preprocessExact(start, rng.startOffset, finish, rng.endOffset);\n },\n relative: preprocessRelative,\n exact: preprocessExact\n });\n\n const fromElements = (elements, scope) => {\n const doc = scope || document;\n const fragment = doc.createDocumentFragment();\n each$e(elements, element => {\n fragment.appendChild(element.dom);\n });\n return SugarElement.fromDom(fragment);\n };\n\n const toNative = selection => {\n const win = SimSelection.getWin(selection).dom;\n const getDomRange = (start, soffset, finish, foffset) => exactToNative(win, start, soffset, finish, foffset);\n const filtered = preprocess(selection);\n return diagnose(win, filtered).match({\n ltr: getDomRange,\n rtl: getDomRange\n });\n };\n const getAtPoint = (win, x, y) => fromPoint$1(win, x, y);\n\n const fromPoint = (clientX, clientY, doc) => {\n const win = defaultView(SugarElement.fromDom(doc));\n return getAtPoint(win.dom, clientX, clientY).map(simRange => {\n const rng = doc.createRange();\n rng.setStart(simRange.start.dom, simRange.soffset);\n rng.setEnd(simRange.finish.dom, simRange.foffset);\n return rng;\n }).getOrUndefined();\n };\n\n const isEq$4 = (rng1, rng2) => {\n return isNonNullable(rng1) && isNonNullable(rng2) && (rng1.startContainer === rng2.startContainer && rng1.startOffset === rng2.startOffset) && (rng1.endContainer === rng2.endContainer && rng1.endOffset === rng2.endOffset);\n };\n\n const findParent = (node, rootNode, predicate) => {\n let currentNode = node;\n while (currentNode && currentNode !== rootNode) {\n if (predicate(currentNode)) {\n return currentNode;\n }\n currentNode = currentNode.parentNode;\n }\n return null;\n };\n const hasParent$1 = (node, rootNode, predicate) => findParent(node, rootNode, predicate) !== null;\n const hasParentWithName = (node, rootNode, name) => hasParent$1(node, rootNode, node => node.nodeName === name);\n const isCeFalseCaretContainer = (node, rootNode) => isCaretContainer$2(node) && !hasParent$1(node, rootNode, isCaretNode);\n const hasBrBeforeAfter = (dom, node, left) => {\n const parentNode = node.parentNode;\n if (parentNode) {\n const walker = new DomTreeWalker(node, dom.getParent(parentNode, dom.isBlock) || dom.getRoot());\n let currentNode;\n while (currentNode = walker[left ? 'prev' : 'next']()) {\n if (isBr$6(currentNode)) {\n return true;\n }\n }\n }\n return false;\n };\n const isPrevNode = (node, name) => {\n var _a;\n return ((_a = node.previousSibling) === null || _a === void 0 ? void 0 : _a.nodeName) === name;\n };\n const hasContentEditableFalseParent = (root, node) => {\n let currentNode = node;\n while (currentNode && currentNode !== root) {\n if (isContentEditableFalse$b(currentNode)) {\n return true;\n }\n currentNode = currentNode.parentNode;\n }\n return false;\n };\n const findTextNodeRelative = (dom, isAfterNode, collapsed, left, startNode) => {\n const body = dom.getRoot();\n const nonEmptyElementsMap = dom.schema.getNonEmptyElements();\n const parentNode = startNode.parentNode;\n let lastInlineElement;\n let node;\n if (!parentNode) {\n return Optional.none();\n }\n const parentBlockContainer = dom.getParent(parentNode, dom.isBlock) || body;\n if (left && isBr$6(startNode) && isAfterNode && dom.isEmpty(parentBlockContainer)) {\n return Optional.some(CaretPosition(parentNode, dom.nodeIndex(startNode)));\n }\n const walker = new DomTreeWalker(startNode, parentBlockContainer);\n while (node = walker[left ? 'prev' : 'next']()) {\n if (dom.getContentEditableParent(node) === 'false' || isCeFalseCaretContainer(node, body)) {\n return Optional.none();\n }\n if (isText$a(node) && node.data.length > 0) {\n if (!hasParentWithName(node, body, 'A')) {\n return Optional.some(CaretPosition(node, left ? node.data.length : 0));\n }\n return Optional.none();\n }\n if (dom.isBlock(node) || nonEmptyElementsMap[node.nodeName.toLowerCase()]) {\n return Optional.none();\n }\n lastInlineElement = node;\n }\n if (isComment(lastInlineElement)) {\n return Optional.none();\n }\n if (collapsed && lastInlineElement) {\n return Optional.some(CaretPosition(lastInlineElement, 0));\n }\n return Optional.none();\n };\n const normalizeEndPoint = (dom, collapsed, start, rng) => {\n const body = dom.getRoot();\n let node;\n let normalized = false;\n let container = start ? rng.startContainer : rng.endContainer;\n let offset = start ? rng.startOffset : rng.endOffset;\n const isAfterNode = isElement$6(container) && offset === container.childNodes.length;\n const nonEmptyElementsMap = dom.schema.getNonEmptyElements();\n let directionLeft = start;\n if (isCaretContainer$2(container)) {\n return Optional.none();\n }\n if (isElement$6(container) && offset > container.childNodes.length - 1) {\n directionLeft = false;\n }\n if (isDocument$1(container)) {\n container = body;\n offset = 0;\n }\n if (container === body) {\n if (directionLeft) {\n node = container.childNodes[offset > 0 ? offset - 1 : 0];\n if (node) {\n if (isCaretContainer$2(node)) {\n return Optional.none();\n }\n if (nonEmptyElementsMap[node.nodeName] || isTable$2(node)) {\n return Optional.none();\n }\n }\n }\n if (container.hasChildNodes()) {\n offset = Math.min(!directionLeft && offset > 0 ? offset - 1 : offset, container.childNodes.length - 1);\n container = container.childNodes[offset];\n offset = isText$a(container) && isAfterNode ? container.data.length : 0;\n if (!collapsed && container === body.lastChild && isTable$2(container)) {\n return Optional.none();\n }\n if (hasContentEditableFalseParent(body, container) || isCaretContainer$2(container)) {\n return Optional.none();\n }\n if (isDetails(container)) {\n return Optional.none();\n }\n if (container.hasChildNodes() && !isTable$2(container)) {\n node = container;\n const walker = new DomTreeWalker(container, body);\n do {\n if (isContentEditableFalse$b(node) || isCaretContainer$2(node)) {\n normalized = false;\n break;\n }\n if (isText$a(node) && node.data.length > 0) {\n offset = directionLeft ? 0 : node.data.length;\n container = node;\n normalized = true;\n break;\n }\n if (nonEmptyElementsMap[node.nodeName.toLowerCase()] && !isTableCellOrCaption(node)) {\n offset = dom.nodeIndex(node);\n container = node.parentNode;\n if (!directionLeft) {\n offset++;\n }\n normalized = true;\n break;\n }\n } while (node = directionLeft ? walker.next() : walker.prev());\n }\n }\n }\n if (collapsed) {\n if (isText$a(container) && offset === 0) {\n findTextNodeRelative(dom, isAfterNode, collapsed, true, container).each(pos => {\n container = pos.container();\n offset = pos.offset();\n normalized = true;\n });\n }\n if (isElement$6(container)) {\n node = container.childNodes[offset];\n if (!node) {\n node = container.childNodes[offset - 1];\n }\n if (node && isBr$6(node) && !isPrevNode(node, 'A') && !hasBrBeforeAfter(dom, node, false) && !hasBrBeforeAfter(dom, node, true)) {\n findTextNodeRelative(dom, isAfterNode, collapsed, true, node).each(pos => {\n container = pos.container();\n offset = pos.offset();\n normalized = true;\n });\n }\n }\n }\n if (directionLeft && !collapsed && isText$a(container) && offset === container.data.length) {\n findTextNodeRelative(dom, isAfterNode, collapsed, false, container).each(pos => {\n container = pos.container();\n offset = pos.offset();\n normalized = true;\n });\n }\n return normalized && container ? Optional.some(CaretPosition(container, offset)) : Optional.none();\n };\n const normalize$2 = (dom, rng) => {\n const collapsed = rng.collapsed, normRng = rng.cloneRange();\n const startPos = CaretPosition.fromRangeStart(rng);\n normalizeEndPoint(dom, collapsed, true, normRng).each(pos => {\n if (!collapsed || !CaretPosition.isAbove(startPos, pos)) {\n normRng.setStart(pos.container(), pos.offset());\n }\n });\n if (!collapsed) {\n normalizeEndPoint(dom, collapsed, false, normRng).each(pos => {\n normRng.setEnd(pos.container(), pos.offset());\n });\n }\n if (collapsed) {\n normRng.collapse(true);\n }\n return isEq$4(rng, normRng) ? Optional.none() : Optional.some(normRng);\n };\n\n const splitText = (node, offset) => {\n return node.splitText(offset);\n };\n const split = rng => {\n let startContainer = rng.startContainer, startOffset = rng.startOffset, endContainer = rng.endContainer, endOffset = rng.endOffset;\n if (startContainer === endContainer && isText$a(startContainer)) {\n if (startOffset > 0 && startOffset < startContainer.data.length) {\n endContainer = splitText(startContainer, startOffset);\n startContainer = endContainer.previousSibling;\n if (endOffset > startOffset) {\n endOffset = endOffset - startOffset;\n const newContainer = splitText(endContainer, endOffset).previousSibling;\n startContainer = endContainer = newContainer;\n endOffset = newContainer.data.length;\n startOffset = 0;\n } else {\n endOffset = 0;\n }\n }\n } else {\n if (isText$a(startContainer) && startOffset > 0 && startOffset < startContainer.data.length) {\n startContainer = splitText(startContainer, startOffset);\n startOffset = 0;\n }\n if (isText$a(endContainer) && endOffset > 0 && endOffset < endContainer.data.length) {\n const newContainer = splitText(endContainer, endOffset).previousSibling;\n endContainer = newContainer;\n endOffset = newContainer.data.length;\n }\n }\n return {\n startContainer,\n startOffset,\n endContainer,\n endOffset\n };\n };\n\n const RangeUtils = dom => {\n const walk = (rng, callback) => {\n return walk$3(dom, rng, callback);\n };\n const split$1 = split;\n const normalize = rng => {\n return normalize$2(dom, rng).fold(never, normalizedRng => {\n rng.setStart(normalizedRng.startContainer, normalizedRng.startOffset);\n rng.setEnd(normalizedRng.endContainer, normalizedRng.endOffset);\n return true;\n });\n };\n const expand = (rng, options = { type: 'word' }) => {\n if (options.type === 'word') {\n const rangeLike = expandRng(dom, rng, [{ inline: 'span' }]);\n const newRange = dom.createRng();\n newRange.setStart(rangeLike.startContainer, rangeLike.startOffset);\n newRange.setEnd(rangeLike.endContainer, rangeLike.endOffset);\n return newRange;\n }\n return rng;\n };\n return {\n walk,\n split: split$1,\n expand,\n normalize\n };\n };\n RangeUtils.compareRanges = isEq$4;\n RangeUtils.getCaretRangeFromPoint = fromPoint;\n RangeUtils.getSelectedNode = getSelectedNode;\n RangeUtils.getNode = getNode$1;\n\n const Dimension = (name, getOffset) => {\n const set = (element, h) => {\n if (!isNumber(h) && !h.match(/^[0-9]+$/)) {\n throw new Error(name + '.set accepts only positive integer values. Value was ' + h);\n }\n const dom = element.dom;\n if (isSupported(dom)) {\n dom.style[name] = h + 'px';\n }\n };\n const get = element => {\n const r = getOffset(element);\n if (r <= 0 || r === null) {\n const css = get$7(element, name);\n return parseFloat(css) || 0;\n }\n return r;\n };\n const getOuter = get;\n const aggregate = (element, properties) => foldl(properties, (acc, property) => {\n const val = get$7(element, property);\n const value = val === undefined ? 0 : parseInt(val, 10);\n return isNaN(value) ? acc : acc + value;\n }, 0);\n const max = (element, value, properties) => {\n const cumulativeInclusions = aggregate(element, properties);\n const absoluteMax = value > cumulativeInclusions ? value - cumulativeInclusions : 0;\n return absoluteMax;\n };\n return {\n set,\n get,\n getOuter,\n aggregate,\n max\n };\n };\n\n const api = Dimension('height', element => {\n const dom = element.dom;\n return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight;\n });\n const get$2 = element => api.get(element);\n\n const getDocument = () => SugarElement.fromDom(document);\n\n const walkUp = (navigation, doc) => {\n const frame = navigation.view(doc);\n return frame.fold(constant([]), f => {\n const parent = navigation.owner(f);\n const rest = walkUp(navigation, parent);\n return [f].concat(rest);\n });\n };\n const pathTo = (element, navigation) => {\n const d = navigation.owner(element);\n return walkUp(navigation, d);\n };\n\n const view = doc => {\n var _a;\n const element = doc.dom === document ? Optional.none() : Optional.from((_a = doc.dom.defaultView) === null || _a === void 0 ? void 0 : _a.frameElement);\n return element.map(SugarElement.fromDom);\n };\n const owner = element => documentOrOwner(element);\n\n var Navigation = /*#__PURE__*/Object.freeze({\n __proto__: null,\n view: view,\n owner: owner\n });\n\n const find = element => {\n const doc = getDocument();\n const scroll = get$5(doc);\n const frames = pathTo(element, Navigation);\n const offset = viewport(element);\n const r = foldr(frames, (b, a) => {\n const loc = viewport(a);\n return {\n left: b.left + loc.left,\n top: b.top + loc.top\n };\n }, {\n left: 0,\n top: 0\n });\n return SugarPosition(r.left + offset.left + scroll.left, r.top + offset.top + scroll.top);\n };\n\n const excludeFromDescend = element => name(element) === 'textarea';\n const fireScrollIntoViewEvent = (editor, data) => {\n const scrollEvent = editor.dispatch('ScrollIntoView', data);\n return scrollEvent.isDefaultPrevented();\n };\n const fireAfterScrollIntoViewEvent = (editor, data) => {\n editor.dispatch('AfterScrollIntoView', data);\n };\n const descend = (element, offset) => {\n const children = children$1(element);\n if (children.length === 0 || excludeFromDescend(element)) {\n return {\n element,\n offset\n };\n } else if (offset < children.length && !excludeFromDescend(children[offset])) {\n return {\n element: children[offset],\n offset: 0\n };\n } else {\n const last = children[children.length - 1];\n if (excludeFromDescend(last)) {\n return {\n element,\n offset\n };\n } else {\n if (name(last) === 'img') {\n return {\n element: last,\n offset: 1\n };\n } else if (isText$b(last)) {\n return {\n element: last,\n offset: get$3(last).length\n };\n } else {\n return {\n element: last,\n offset: children$1(last).length\n };\n }\n }\n }\n };\n const markerInfo = (element, cleanupFun) => {\n const pos = absolute(element);\n const height = get$2(element);\n return {\n element,\n bottom: pos.top + height,\n height,\n pos,\n cleanup: cleanupFun\n };\n };\n const createMarker$1 = (element, offset) => {\n const startPoint = descend(element, offset);\n const span = SugarElement.fromHtml('' + ZWSP$1 + '');\n before$3(startPoint.element, span);\n return markerInfo(span, () => remove$5(span));\n };\n const elementMarker = element => markerInfo(SugarElement.fromDom(element), noop);\n const withMarker = (editor, f, rng, alignToTop) => {\n preserveWith(editor, (_s, _e) => applyWithMarker(editor, f, rng, alignToTop), rng);\n };\n const withScrollEvents = (editor, doc, f, marker, alignToTop) => {\n const data = {\n elm: marker.element.dom,\n alignToTop\n };\n if (fireScrollIntoViewEvent(editor, data)) {\n return;\n }\n const scrollTop = get$5(doc).top;\n f(editor, doc, scrollTop, marker, alignToTop);\n fireAfterScrollIntoViewEvent(editor, data);\n };\n const applyWithMarker = (editor, f, rng, alignToTop) => {\n const body = SugarElement.fromDom(editor.getBody());\n const doc = SugarElement.fromDom(editor.getDoc());\n reflow(body);\n const marker = createMarker$1(SugarElement.fromDom(rng.startContainer), rng.startOffset);\n withScrollEvents(editor, doc, f, marker, alignToTop);\n marker.cleanup();\n };\n const withElement = (editor, element, f, alignToTop) => {\n const doc = SugarElement.fromDom(editor.getDoc());\n withScrollEvents(editor, doc, f, elementMarker(element), alignToTop);\n };\n const preserveWith = (editor, f, rng) => {\n const startElement = rng.startContainer;\n const startOffset = rng.startOffset;\n const endElement = rng.endContainer;\n const endOffset = rng.endOffset;\n f(SugarElement.fromDom(startElement), SugarElement.fromDom(endElement));\n const newRng = editor.dom.createRng();\n newRng.setStart(startElement, startOffset);\n newRng.setEnd(endElement, endOffset);\n editor.selection.setRng(rng);\n };\n const scrollToMarker = (editor, marker, viewHeight, alignToTop, doc) => {\n const pos = marker.pos;\n if (alignToTop) {\n to(pos.left, pos.top, doc);\n } else {\n const y = pos.top - viewHeight + marker.height;\n to(-editor.getBody().getBoundingClientRect().left, y, doc);\n }\n };\n const intoWindowIfNeeded = (editor, doc, scrollTop, viewHeight, marker, alignToTop) => {\n const viewportBottom = viewHeight + scrollTop;\n const markerTop = marker.pos.top;\n const markerBottom = marker.bottom;\n const largerThanViewport = markerBottom - markerTop >= viewHeight;\n if (markerTop < scrollTop) {\n scrollToMarker(editor, marker, viewHeight, alignToTop !== false, doc);\n } else if (markerTop > viewportBottom) {\n const align = largerThanViewport ? alignToTop !== false : alignToTop === true;\n scrollToMarker(editor, marker, viewHeight, align, doc);\n } else if (markerBottom > viewportBottom && !largerThanViewport) {\n scrollToMarker(editor, marker, viewHeight, alignToTop === true, doc);\n }\n };\n const intoWindow = (editor, doc, scrollTop, marker, alignToTop) => {\n const viewHeight = defaultView(doc).dom.innerHeight;\n intoWindowIfNeeded(editor, doc, scrollTop, viewHeight, marker, alignToTop);\n };\n const intoFrame = (editor, doc, scrollTop, marker, alignToTop) => {\n const frameViewHeight = defaultView(doc).dom.innerHeight;\n intoWindowIfNeeded(editor, doc, scrollTop, frameViewHeight, marker, alignToTop);\n const op = find(marker.element);\n const viewportBounds = getBounds(window);\n if (op.top < viewportBounds.y) {\n intoView(marker.element, alignToTop !== false);\n } else if (op.top > viewportBounds.bottom) {\n intoView(marker.element, alignToTop === true);\n }\n };\n const rangeIntoWindow = (editor, rng, alignToTop) => withMarker(editor, intoWindow, rng, alignToTop);\n const elementIntoWindow = (editor, element, alignToTop) => withElement(editor, element, intoWindow, alignToTop);\n const rangeIntoFrame = (editor, rng, alignToTop) => withMarker(editor, intoFrame, rng, alignToTop);\n const elementIntoFrame = (editor, element, alignToTop) => withElement(editor, element, intoFrame, alignToTop);\n const scrollElementIntoView = (editor, element, alignToTop) => {\n const scroller = editor.inline ? elementIntoWindow : elementIntoFrame;\n scroller(editor, element, alignToTop);\n };\n const scrollRangeIntoView = (editor, rng, alignToTop) => {\n const scroller = editor.inline ? rangeIntoWindow : rangeIntoFrame;\n scroller(editor, rng, alignToTop);\n };\n\n const focus$1 = (element, preventScroll = false) => element.dom.focus({ preventScroll });\n const hasFocus$1 = element => {\n const root = getRootNode(element).dom;\n return element.dom === root.activeElement;\n };\n const active$1 = (root = getDocument()) => Optional.from(root.dom.activeElement).map(SugarElement.fromDom);\n const search = element => active$1(getRootNode(element)).filter(e => element.dom.contains(e.dom));\n\n const clamp$1 = (offset, element) => {\n const max = isText$b(element) ? get$3(element).length : children$1(element).length + 1;\n if (offset > max) {\n return max;\n } else if (offset < 0) {\n return 0;\n }\n return offset;\n };\n const normalizeRng = rng => SimSelection.range(rng.start, clamp$1(rng.soffset, rng.start), rng.finish, clamp$1(rng.foffset, rng.finish));\n const isOrContains = (root, elm) => !isRestrictedNode(elm.dom) && (contains(root, elm) || eq(root, elm));\n const isRngInRoot = root => rng => isOrContains(root, rng.start) && isOrContains(root, rng.finish);\n const shouldStore = editor => editor.inline || Env.browser.isFirefox();\n const nativeRangeToSelectionRange = r => SimSelection.range(SugarElement.fromDom(r.startContainer), r.startOffset, SugarElement.fromDom(r.endContainer), r.endOffset);\n const readRange = win => {\n const selection = win.getSelection();\n const rng = !selection || selection.rangeCount === 0 ? Optional.none() : Optional.from(selection.getRangeAt(0));\n return rng.map(nativeRangeToSelectionRange);\n };\n const getBookmark = root => {\n const win = defaultView(root);\n return readRange(win.dom).filter(isRngInRoot(root));\n };\n const validate = (root, bookmark) => Optional.from(bookmark).filter(isRngInRoot(root)).map(normalizeRng);\n const bookmarkToNativeRng = bookmark => {\n const rng = document.createRange();\n try {\n rng.setStart(bookmark.start.dom, bookmark.soffset);\n rng.setEnd(bookmark.finish.dom, bookmark.foffset);\n return Optional.some(rng);\n } catch (_) {\n return Optional.none();\n }\n };\n const store = editor => {\n const newBookmark = shouldStore(editor) ? getBookmark(SugarElement.fromDom(editor.getBody())) : Optional.none();\n editor.bookmark = newBookmark.isSome() ? newBookmark : editor.bookmark;\n };\n const getRng = editor => {\n const bookmark = editor.bookmark ? editor.bookmark : Optional.none();\n return bookmark.bind(x => validate(SugarElement.fromDom(editor.getBody()), x)).bind(bookmarkToNativeRng);\n };\n const restore = editor => {\n getRng(editor).each(rng => editor.selection.setRng(rng));\n };\n\n const isEditorUIElement$1 = elm => {\n const className = elm.className.toString();\n return className.indexOf('tox-') !== -1 || className.indexOf('mce-') !== -1;\n };\n const FocusManager = { isEditorUIElement: isEditorUIElement$1 };\n\n const wrappedSetTimeout = (callback, time) => {\n if (!isNumber(time)) {\n time = 0;\n }\n return setTimeout(callback, time);\n };\n const wrappedSetInterval = (callback, time) => {\n if (!isNumber(time)) {\n time = 0;\n }\n return setInterval(callback, time);\n };\n const Delay = {\n setEditorTimeout: (editor, callback, time) => {\n return wrappedSetTimeout(() => {\n if (!editor.removed) {\n callback();\n }\n }, time);\n },\n setEditorInterval: (editor, callback, time) => {\n const timer = wrappedSetInterval(() => {\n if (!editor.removed) {\n callback();\n } else {\n clearInterval(timer);\n }\n }, time);\n return timer;\n }\n };\n\n const isManualNodeChange = e => {\n return e.type === 'nodechange' && e.selectionChange;\n };\n const registerPageMouseUp = (editor, throttledStore) => {\n const mouseUpPage = () => {\n throttledStore.throttle();\n };\n DOMUtils.DOM.bind(document, 'mouseup', mouseUpPage);\n editor.on('remove', () => {\n DOMUtils.DOM.unbind(document, 'mouseup', mouseUpPage);\n });\n };\n const registerMouseUp = (editor, throttledStore) => {\n editor.on('mouseup touchend', _e => {\n throttledStore.throttle();\n });\n };\n const registerEditorEvents = (editor, throttledStore) => {\n registerMouseUp(editor, throttledStore);\n editor.on('keyup NodeChange AfterSetSelectionRange', e => {\n if (!isManualNodeChange(e)) {\n store(editor);\n }\n });\n };\n const register$6 = editor => {\n const throttledStore = first$1(() => {\n store(editor);\n }, 0);\n editor.on('init', () => {\n if (editor.inline) {\n registerPageMouseUp(editor, throttledStore);\n }\n registerEditorEvents(editor, throttledStore);\n });\n editor.on('remove', () => {\n throttledStore.cancel();\n });\n };\n\n let documentFocusInHandler;\n const DOM$9 = DOMUtils.DOM;\n const isEditorUIElement = elm => {\n return isElement$6(elm) && FocusManager.isEditorUIElement(elm);\n };\n const isEditorContentAreaElement = elm => {\n const classList = elm.classList;\n if (classList !== undefined) {\n return classList.contains('tox-edit-area') || classList.contains('tox-edit-area__iframe') || classList.contains('mce-content-body');\n } else {\n return false;\n }\n };\n const isUIElement = (editor, elm) => {\n const customSelector = getCustomUiSelector(editor);\n const parent = DOM$9.getParent(elm, elm => {\n return isEditorUIElement(elm) || (customSelector ? editor.dom.is(elm, customSelector) : false);\n });\n return parent !== null;\n };\n const getActiveElement = editor => {\n try {\n const root = getRootNode(SugarElement.fromDom(editor.getElement()));\n return active$1(root).fold(() => document.body, x => x.dom);\n } catch (ex) {\n return document.body;\n }\n };\n const registerEvents$1 = (editorManager, e) => {\n const editor = e.editor;\n register$6(editor);\n const toggleContentAreaOnFocus = (editor, fn) => {\n if (shouldHighlightOnFocus(editor) && editor.inline !== true) {\n const contentArea = SugarElement.fromDom(editor.getContainer());\n fn(contentArea, 'tox-edit-focus');\n }\n };\n editor.on('focusin', () => {\n const focusedEditor = editorManager.focusedEditor;\n if (isEditorContentAreaElement(getActiveElement(editor))) {\n toggleContentAreaOnFocus(editor, add$2);\n }\n if (focusedEditor !== editor) {\n if (focusedEditor) {\n focusedEditor.dispatch('blur', { focusedEditor: editor });\n }\n editorManager.setActive(editor);\n editorManager.focusedEditor = editor;\n editor.dispatch('focus', { blurredEditor: focusedEditor });\n editor.focus(true);\n }\n });\n editor.on('focusout', () => {\n Delay.setEditorTimeout(editor, () => {\n const focusedEditor = editorManager.focusedEditor;\n if (!isEditorContentAreaElement(getActiveElement(editor)) || focusedEditor !== editor) {\n toggleContentAreaOnFocus(editor, remove$7);\n }\n if (!isUIElement(editor, getActiveElement(editor)) && focusedEditor === editor) {\n editor.dispatch('blur', { focusedEditor: null });\n editorManager.focusedEditor = null;\n }\n });\n });\n if (!documentFocusInHandler) {\n documentFocusInHandler = e => {\n const activeEditor = editorManager.activeEditor;\n if (activeEditor) {\n getOriginalEventTarget(e).each(target => {\n const elem = target;\n if (elem.ownerDocument === document) {\n if (elem !== document.body && !isUIElement(activeEditor, elem) && editorManager.focusedEditor === activeEditor) {\n activeEditor.dispatch('blur', { focusedEditor: null });\n editorManager.focusedEditor = null;\n }\n }\n });\n }\n };\n DOM$9.bind(document, 'focusin', documentFocusInHandler);\n }\n };\n const unregisterDocumentEvents = (editorManager, e) => {\n if (editorManager.focusedEditor === e.editor) {\n editorManager.focusedEditor = null;\n }\n if (!editorManager.activeEditor && documentFocusInHandler) {\n DOM$9.unbind(document, 'focusin', documentFocusInHandler);\n documentFocusInHandler = null;\n }\n };\n const setup$w = editorManager => {\n editorManager.on('AddEditor', curry(registerEvents$1, editorManager));\n editorManager.on('RemoveEditor', curry(unregisterDocumentEvents, editorManager));\n };\n\n const getContentEditableHost = (editor, node) => editor.dom.getParent(node, node => editor.dom.getContentEditable(node) === 'true');\n const getCollapsedNode = rng => rng.collapsed ? Optional.from(getNode$1(rng.startContainer, rng.startOffset)).map(SugarElement.fromDom) : Optional.none();\n const getFocusInElement = (root, rng) => getCollapsedNode(rng).bind(node => {\n if (isTableSection(node)) {\n return Optional.some(node);\n } else if (!contains(root, node)) {\n return Optional.some(root);\n } else {\n return Optional.none();\n }\n });\n const normalizeSelection = (editor, rng) => {\n getFocusInElement(SugarElement.fromDom(editor.getBody()), rng).bind(elm => {\n return firstPositionIn(elm.dom);\n }).fold(() => {\n editor.selection.normalize();\n }, caretPos => editor.selection.setRng(caretPos.toRange()));\n };\n const focusBody = body => {\n if (body.setActive) {\n try {\n body.setActive();\n } catch (ex) {\n body.focus();\n }\n } else {\n body.focus();\n }\n };\n const hasElementFocus = elm => hasFocus$1(elm) || search(elm).isSome();\n const hasIframeFocus = editor => isNonNullable(editor.iframeElement) && hasFocus$1(SugarElement.fromDom(editor.iframeElement));\n const hasInlineFocus = editor => {\n const rawBody = editor.getBody();\n return rawBody && hasElementFocus(SugarElement.fromDom(rawBody));\n };\n const hasUiFocus = editor => {\n const dos = getRootNode(SugarElement.fromDom(editor.getElement()));\n return active$1(dos).filter(elem => !isEditorContentAreaElement(elem.dom) && isUIElement(editor, elem.dom)).isSome();\n };\n const hasFocus = editor => editor.inline ? hasInlineFocus(editor) : hasIframeFocus(editor);\n const hasEditorOrUiFocus = editor => hasFocus(editor) || hasUiFocus(editor);\n const focusEditor = editor => {\n const selection = editor.selection;\n const body = editor.getBody();\n let rng = selection.getRng();\n editor.quirks.refreshContentEditable();\n if (isNonNullable(editor.bookmark) && !hasFocus(editor)) {\n getRng(editor).each(bookmarkRng => {\n editor.selection.setRng(bookmarkRng);\n rng = bookmarkRng;\n });\n }\n const contentEditableHost = getContentEditableHost(editor, selection.getNode());\n if (contentEditableHost && editor.dom.isChildOf(contentEditableHost, body)) {\n focusBody(contentEditableHost);\n normalizeSelection(editor, rng);\n activateEditor(editor);\n return;\n }\n if (!editor.inline) {\n if (!Env.browser.isOpera()) {\n focusBody(body);\n }\n editor.getWin().focus();\n }\n if (Env.browser.isFirefox() || editor.inline) {\n focusBody(body);\n normalizeSelection(editor, rng);\n }\n activateEditor(editor);\n };\n const activateEditor = editor => editor.editorManager.setActive(editor);\n const focus = (editor, skipFocus) => {\n if (editor.removed) {\n return;\n }\n if (skipFocus) {\n activateEditor(editor);\n } else {\n focusEditor(editor);\n }\n };\n\n const isEditableRange = (dom, rng) => {\n if (rng.collapsed) {\n return dom.isEditable(rng.startContainer);\n } else {\n return dom.isEditable(rng.startContainer) && dom.isEditable(rng.endContainer);\n }\n };\n\n const getEndpointElement = (root, rng, start, real, resolve) => {\n const container = start ? rng.startContainer : rng.endContainer;\n const offset = start ? rng.startOffset : rng.endOffset;\n return Optional.from(container).map(SugarElement.fromDom).map(elm => !real || !rng.collapsed ? child$1(elm, resolve(elm, offset)).getOr(elm) : elm).bind(elm => isElement$7(elm) ? Optional.some(elm) : parent(elm).filter(isElement$7)).map(elm => elm.dom).getOr(root);\n };\n const getStart = (root, rng, real = false) => getEndpointElement(root, rng, true, real, (elm, offset) => Math.min(childNodesCount(elm), offset));\n const getEnd$1 = (root, rng, real = false) => getEndpointElement(root, rng, false, real, (elm, offset) => offset > 0 ? offset - 1 : offset);\n const skipEmptyTextNodes = (node, forwards) => {\n const orig = node;\n while (node && isText$a(node) && node.length === 0) {\n node = forwards ? node.nextSibling : node.previousSibling;\n }\n return node || orig;\n };\n const getNode = (root, rng) => {\n if (!rng) {\n return root;\n }\n let startContainer = rng.startContainer;\n let endContainer = rng.endContainer;\n const startOffset = rng.startOffset;\n const endOffset = rng.endOffset;\n let node = rng.commonAncestorContainer;\n if (!rng.collapsed) {\n if (startContainer === endContainer) {\n if (endOffset - startOffset < 2) {\n if (startContainer.hasChildNodes()) {\n node = startContainer.childNodes[startOffset];\n }\n }\n }\n if (isText$a(startContainer) && isText$a(endContainer)) {\n if (startContainer.length === startOffset) {\n startContainer = skipEmptyTextNodes(startContainer.nextSibling, true);\n } else {\n startContainer = startContainer.parentNode;\n }\n if (endOffset === 0) {\n endContainer = skipEmptyTextNodes(endContainer.previousSibling, false);\n } else {\n endContainer = endContainer.parentNode;\n }\n if (startContainer && startContainer === endContainer) {\n node = startContainer;\n }\n }\n }\n const elm = isText$a(node) ? node.parentNode : node;\n return isHTMLElement(elm) ? elm : root;\n };\n const getSelectedBlocks = (dom, rng, startElm, endElm) => {\n const selectedBlocks = [];\n const root = dom.getRoot();\n const start = dom.getParent(startElm || getStart(root, rng, rng.collapsed), dom.isBlock);\n const end = dom.getParent(endElm || getEnd$1(root, rng, rng.collapsed), dom.isBlock);\n if (start && start !== root) {\n selectedBlocks.push(start);\n }\n if (start && end && start !== end) {\n let node;\n const walker = new DomTreeWalker(start, root);\n while ((node = walker.next()) && node !== end) {\n if (dom.isBlock(node)) {\n selectedBlocks.push(node);\n }\n }\n }\n if (end && start !== end && end !== root) {\n selectedBlocks.push(end);\n }\n return selectedBlocks;\n };\n const select = (dom, node, content) => Optional.from(node).bind(node => Optional.from(node.parentNode).map(parent => {\n const idx = dom.nodeIndex(node);\n const rng = dom.createRng();\n rng.setStart(parent, idx);\n rng.setEnd(parent, idx + 1);\n if (content) {\n moveEndPoint(dom, rng, node, true);\n moveEndPoint(dom, rng, node, false);\n }\n return rng;\n }));\n\n const processRanges = (editor, ranges) => map$3(ranges, range => {\n const evt = editor.dispatch('GetSelectionRange', { range });\n return evt.range !== range ? evt.range : range;\n });\n\n const getEnd = element => name(element) === 'img' ? 1 : getOption(element).fold(() => children$1(element).length, v => v.length);\n const isTextNodeWithCursorPosition = el => getOption(el).filter(text => text.trim().length !== 0 || text.indexOf(nbsp) > -1).isSome();\n const isContentEditableFalse$5 = elem => isHTMLElement$1(elem) && get$9(elem, 'contenteditable') === 'false';\n const elementsWithCursorPosition = [\n 'img',\n 'br'\n ];\n const isCursorPosition = elem => {\n const hasCursorPosition = isTextNodeWithCursorPosition(elem);\n return hasCursorPosition || contains$2(elementsWithCursorPosition, name(elem)) || isContentEditableFalse$5(elem);\n };\n\n const first = element => descendant$2(element, isCursorPosition);\n const last = element => descendantRtl(element, isCursorPosition);\n const descendantRtl = (scope, predicate) => {\n const descend = element => {\n const children = children$1(element);\n for (let i = children.length - 1; i >= 0; i--) {\n const child = children[i];\n if (predicate(child)) {\n return Optional.some(child);\n }\n const res = descend(child);\n if (res.isSome()) {\n return res;\n }\n }\n return Optional.none();\n };\n return descend(scope);\n };\n\n const autocompleteSelector = '[data-mce-autocompleter]';\n const create$9 = (editor, range) => {\n if (findIn(SugarElement.fromDom(editor.getBody())).isNone()) {\n const wrapper = SugarElement.fromHtml('', editor.getDoc());\n append$1(wrapper, SugarElement.fromDom(range.extractContents()));\n range.insertNode(wrapper.dom);\n parent(wrapper).each(elm => elm.dom.normalize());\n last(wrapper).map(last => {\n editor.selection.setCursorLocation(last.dom, getEnd(last));\n });\n }\n };\n const detect$1 = elm => closest$3(elm, autocompleteSelector);\n const findIn = elm => descendant$1(elm, autocompleteSelector);\n const remove$2 = (editor, elm) => findIn(elm).each(wrapper => {\n const bookmark = editor.selection.getBookmark();\n unwrap(wrapper);\n editor.selection.moveToBookmark(bookmark);\n });\n\n const typeLookup = {\n '#text': 3,\n '#comment': 8,\n '#cdata': 4,\n '#pi': 7,\n '#doctype': 10,\n '#document-fragment': 11\n };\n const walk$2 = (node, root, prev) => {\n const startName = prev ? 'lastChild' : 'firstChild';\n const siblingName = prev ? 'prev' : 'next';\n if (node[startName]) {\n return node[startName];\n }\n if (node !== root) {\n let sibling = node[siblingName];\n if (sibling) {\n return sibling;\n }\n for (let parent = node.parent; parent && parent !== root; parent = parent.parent) {\n sibling = parent[siblingName];\n if (sibling) {\n return sibling;\n }\n }\n }\n return undefined;\n };\n const isEmptyTextNode = node => {\n var _a;\n const text = (_a = node.value) !== null && _a !== void 0 ? _a : '';\n if (!isWhitespaceText(text)) {\n return false;\n }\n const parentNode = node.parent;\n if (parentNode && (parentNode.name !== 'span' || parentNode.attr('style')) && /^[ ]+$/.test(text)) {\n return false;\n }\n return true;\n };\n const isNonEmptyElement = node => {\n const isNamedAnchor = node.name === 'a' && !node.attr('href') && node.attr('id');\n return node.attr('name') || node.attr('id') && !node.firstChild || node.attr('data-mce-bookmark') || isNamedAnchor;\n };\n class AstNode {\n static create(name, attrs) {\n const node = new AstNode(name, typeLookup[name] || 1);\n if (attrs) {\n each$d(attrs, (value, attrName) => {\n node.attr(attrName, value);\n });\n }\n return node;\n }\n constructor(name, type) {\n this.name = name;\n this.type = type;\n if (type === 1) {\n this.attributes = [];\n this.attributes.map = {};\n }\n }\n replace(node) {\n const self = this;\n if (node.parent) {\n node.remove();\n }\n self.insert(node, self);\n self.remove();\n return self;\n }\n attr(name, value) {\n const self = this;\n if (!isString(name)) {\n if (isNonNullable(name)) {\n each$d(name, (value, key) => {\n self.attr(key, value);\n });\n }\n return self;\n }\n const attrs = self.attributes;\n if (attrs) {\n if (value !== undefined) {\n if (value === null) {\n if (name in attrs.map) {\n delete attrs.map[name];\n let i = attrs.length;\n while (i--) {\n if (attrs[i].name === name) {\n attrs.splice(i, 1);\n return self;\n }\n }\n }\n return self;\n }\n if (name in attrs.map) {\n let i = attrs.length;\n while (i--) {\n if (attrs[i].name === name) {\n attrs[i].value = value;\n break;\n }\n }\n } else {\n attrs.push({\n name,\n value\n });\n }\n attrs.map[name] = value;\n return self;\n }\n return attrs.map[name];\n }\n return undefined;\n }\n clone() {\n const self = this;\n const clone = new AstNode(self.name, self.type);\n const selfAttrs = self.attributes;\n if (selfAttrs) {\n const cloneAttrs = [];\n cloneAttrs.map = {};\n for (let i = 0, l = selfAttrs.length; i < l; i++) {\n const selfAttr = selfAttrs[i];\n if (selfAttr.name !== 'id') {\n cloneAttrs[cloneAttrs.length] = {\n name: selfAttr.name,\n value: selfAttr.value\n };\n cloneAttrs.map[selfAttr.name] = selfAttr.value;\n }\n }\n clone.attributes = cloneAttrs;\n }\n clone.value = self.value;\n return clone;\n }\n wrap(wrapper) {\n const self = this;\n if (self.parent) {\n self.parent.insert(wrapper, self);\n wrapper.append(self);\n }\n return self;\n }\n unwrap() {\n const self = this;\n for (let node = self.firstChild; node;) {\n const next = node.next;\n self.insert(node, self, true);\n node = next;\n }\n self.remove();\n }\n remove() {\n const self = this, parent = self.parent, next = self.next, prev = self.prev;\n if (parent) {\n if (parent.firstChild === self) {\n parent.firstChild = next;\n if (next) {\n next.prev = null;\n }\n } else if (prev) {\n prev.next = next;\n }\n if (parent.lastChild === self) {\n parent.lastChild = prev;\n if (prev) {\n prev.next = null;\n }\n } else if (next) {\n next.prev = prev;\n }\n self.parent = self.next = self.prev = null;\n }\n return self;\n }\n append(node) {\n const self = this;\n if (node.parent) {\n node.remove();\n }\n const last = self.lastChild;\n if (last) {\n last.next = node;\n node.prev = last;\n self.lastChild = node;\n } else {\n self.lastChild = self.firstChild = node;\n }\n node.parent = self;\n return node;\n }\n insert(node, refNode, before) {\n if (node.parent) {\n node.remove();\n }\n const parent = refNode.parent || this;\n if (before) {\n if (refNode === parent.firstChild) {\n parent.firstChild = node;\n } else if (refNode.prev) {\n refNode.prev.next = node;\n }\n node.prev = refNode.prev;\n node.next = refNode;\n refNode.prev = node;\n } else {\n if (refNode === parent.lastChild) {\n parent.lastChild = node;\n } else if (refNode.next) {\n refNode.next.prev = node;\n }\n node.next = refNode.next;\n node.prev = refNode;\n refNode.next = node;\n }\n node.parent = parent;\n return node;\n }\n getAll(name) {\n const self = this;\n const collection = [];\n for (let node = self.firstChild; node; node = walk$2(node, self)) {\n if (node.name === name) {\n collection.push(node);\n }\n }\n return collection;\n }\n children() {\n const self = this;\n const collection = [];\n for (let node = self.firstChild; node; node = node.next) {\n collection.push(node);\n }\n return collection;\n }\n empty() {\n const self = this;\n if (self.firstChild) {\n const nodes = [];\n for (let node = self.firstChild; node; node = walk$2(node, self)) {\n nodes.push(node);\n }\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n node.parent = node.firstChild = node.lastChild = node.next = node.prev = null;\n }\n }\n self.firstChild = self.lastChild = null;\n return self;\n }\n isEmpty(elements, whitespace = {}, predicate) {\n var _a;\n const self = this;\n let node = self.firstChild;\n if (isNonEmptyElement(self)) {\n return false;\n }\n if (node) {\n do {\n if (node.type === 1) {\n if (node.attr('data-mce-bogus')) {\n continue;\n }\n if (elements[node.name]) {\n return false;\n }\n if (isNonEmptyElement(node)) {\n return false;\n }\n }\n if (node.type === 8) {\n return false;\n }\n if (node.type === 3 && !isEmptyTextNode(node)) {\n return false;\n }\n if (node.type === 3 && node.parent && whitespace[node.parent.name] && isWhitespaceText((_a = node.value) !== null && _a !== void 0 ? _a : '')) {\n return false;\n }\n if (predicate && predicate(node)) {\n return false;\n }\n } while (node = walk$2(node, self));\n }\n return true;\n }\n walk(prev) {\n return walk$2(this, null, prev);\n }\n }\n\n const unescapedTextParents = Tools.makeMap('NOSCRIPT STYLE SCRIPT XMP IFRAME NOEMBED NOFRAMES PLAINTEXT', ' ');\n const containsZwsp = node => isString(node.nodeValue) && node.nodeValue.includes(ZWSP$1);\n const getTemporaryNodeSelector = tempAttrs => `${ tempAttrs.length === 0 ? '' : `${ map$3(tempAttrs, attr => `[${ attr }]`).join(',') },` }[data-mce-bogus=\"all\"]`;\n const getTemporaryNodes = (tempAttrs, body) => body.querySelectorAll(getTemporaryNodeSelector(tempAttrs));\n const createZwspCommentWalker = body => document.createTreeWalker(body, NodeFilter.SHOW_COMMENT, node => containsZwsp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP);\n const createUnescapedZwspTextWalker = body => document.createTreeWalker(body, NodeFilter.SHOW_TEXT, node => {\n if (containsZwsp(node)) {\n const parent = node.parentNode;\n return parent && has$2(unescapedTextParents, parent.nodeName) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n } else {\n return NodeFilter.FILTER_SKIP;\n }\n });\n const hasZwspComment = body => createZwspCommentWalker(body).nextNode() !== null;\n const hasUnescapedZwspText = body => createUnescapedZwspTextWalker(body).nextNode() !== null;\n const hasTemporaryNode = (tempAttrs, body) => body.querySelector(getTemporaryNodeSelector(tempAttrs)) !== null;\n const trimTemporaryNodes = (tempAttrs, body) => {\n each$e(getTemporaryNodes(tempAttrs, body), elm => {\n const element = SugarElement.fromDom(elm);\n if (get$9(element, 'data-mce-bogus') === 'all') {\n remove$5(element);\n } else {\n each$e(tempAttrs, attr => {\n if (has$1(element, attr)) {\n remove$a(element, attr);\n }\n });\n }\n });\n };\n const emptyAllNodeValuesInWalker = walker => {\n let curr = walker.nextNode();\n while (curr !== null) {\n curr.nodeValue = null;\n curr = walker.nextNode();\n }\n };\n const emptyZwspComments = compose(emptyAllNodeValuesInWalker, createZwspCommentWalker);\n const emptyUnescapedZwspTexts = compose(emptyAllNodeValuesInWalker, createUnescapedZwspTextWalker);\n const trim$1 = (body, tempAttrs) => {\n const conditionalTrims = [\n {\n condition: curry(hasTemporaryNode, tempAttrs),\n action: curry(trimTemporaryNodes, tempAttrs)\n },\n {\n condition: hasZwspComment,\n action: emptyZwspComments\n },\n {\n condition: hasUnescapedZwspText,\n action: emptyUnescapedZwspTexts\n }\n ];\n let trimmed = body;\n let cloned = false;\n each$e(conditionalTrims, ({condition, action}) => {\n if (condition(trimmed)) {\n if (!cloned) {\n trimmed = body.cloneNode(true);\n cloned = true;\n }\n action(trimmed);\n }\n });\n return trimmed;\n };\n\n const cleanupBogusElements = parent => {\n const bogusElements = descendants(parent, '[data-mce-bogus]');\n each$e(bogusElements, elem => {\n const bogusValue = get$9(elem, 'data-mce-bogus');\n if (bogusValue === 'all') {\n remove$5(elem);\n } else if (isBr$5(elem)) {\n before$3(elem, SugarElement.fromText(zeroWidth));\n remove$5(elem);\n } else {\n unwrap(elem);\n }\n });\n };\n const cleanupInputNames = parent => {\n const inputs = descendants(parent, 'input');\n each$e(inputs, input => {\n remove$a(input, 'name');\n });\n };\n\n const trimEmptyContents = (editor, html) => {\n const blockName = getForcedRootBlock(editor);\n const emptyRegExp = new RegExp(`^(<${ blockName }[^>]*>( | |\\\\s|\\u00a0|
|)<\\\\/${ blockName }>[\\r\\n]*|
[\\r\\n]*)$`);\n return html.replace(emptyRegExp, '');\n };\n const getPlainTextContent = (editor, body) => {\n const doc = editor.getDoc();\n const dos = getRootNode(SugarElement.fromDom(editor.getBody()));\n const offscreenDiv = SugarElement.fromTag('div', doc);\n set$3(offscreenDiv, 'data-mce-bogus', 'all');\n setAll(offscreenDiv, {\n position: 'fixed',\n left: '-9999999px',\n top: '0'\n });\n set$1(offscreenDiv, body.innerHTML);\n cleanupBogusElements(offscreenDiv);\n cleanupInputNames(offscreenDiv);\n const root = getContentContainer(dos);\n append$1(root, offscreenDiv);\n const content = trim$2(offscreenDiv.dom.innerText);\n remove$5(offscreenDiv);\n return content;\n };\n const getContentFromBody = (editor, args, body) => {\n let content;\n if (args.format === 'raw') {\n content = Tools.trim(trim$2(trim$1(body, editor.serializer.getTempAttrs()).innerHTML));\n } else if (args.format === 'text') {\n content = getPlainTextContent(editor, body);\n } else if (args.format === 'tree') {\n content = editor.serializer.serialize(body, args);\n } else {\n content = trimEmptyContents(editor, editor.serializer.serialize(body, args));\n }\n const shouldTrim = args.format !== 'text' && !isWsPreserveElement(SugarElement.fromDom(body));\n return shouldTrim && isString(content) ? Tools.trim(content) : content;\n };\n const getContentInternal = (editor, args) => Optional.from(editor.getBody()).fold(constant(args.format === 'tree' ? new AstNode('body', 11) : ''), body => getContentFromBody(editor, args, body));\n\n const makeMap$1 = Tools.makeMap;\n const Writer = settings => {\n const html = [];\n settings = settings || {};\n const indent = settings.indent;\n const indentBefore = makeMap$1(settings.indent_before || '');\n const indentAfter = makeMap$1(settings.indent_after || '');\n const encode = Entities.getEncodeFunc(settings.entity_encoding || 'raw', settings.entities);\n const htmlOutput = settings.element_format !== 'xhtml';\n return {\n start: (name, attrs, empty) => {\n if (indent && indentBefore[name] && html.length > 0) {\n const value = html[html.length - 1];\n if (value.length > 0 && value !== '\\n') {\n html.push('\\n');\n }\n }\n html.push('<', name);\n if (attrs) {\n for (let i = 0, l = attrs.length; i < l; i++) {\n const attr = attrs[i];\n html.push(' ', attr.name, '=\"', encode(attr.value, true), '\"');\n }\n }\n if (!empty || htmlOutput) {\n html[html.length] = '>';\n } else {\n html[html.length] = ' />';\n }\n if (empty && indent && indentAfter[name] && html.length > 0) {\n const value = html[html.length - 1];\n if (value.length > 0 && value !== '\\n') {\n html.push('\\n');\n }\n }\n },\n end: name => {\n let value;\n html.push('');\n if (indent && indentAfter[name] && html.length > 0) {\n value = html[html.length - 1];\n if (value.length > 0 && value !== '\\n') {\n html.push('\\n');\n }\n }\n },\n text: (text, raw) => {\n if (text.length > 0) {\n html[html.length] = raw ? text : encode(text);\n }\n },\n cdata: text => {\n html.push('');\n },\n comment: text => {\n html.push('');\n },\n pi: (name, text) => {\n if (text) {\n html.push('');\n } else {\n html.push('');\n }\n if (indent) {\n html.push('\\n');\n }\n },\n doctype: text => {\n html.push('', indent ? '\\n' : '');\n },\n reset: () => {\n html.length = 0;\n },\n getContent: () => {\n return html.join('').replace(/\\n$/, '');\n }\n };\n };\n\n const HtmlSerializer = (settings = {}, schema = Schema()) => {\n const writer = Writer(settings);\n settings.validate = 'validate' in settings ? settings.validate : true;\n const serialize = node => {\n const validate = settings.validate;\n const handlers = {\n 3: node => {\n var _a;\n writer.text((_a = node.value) !== null && _a !== void 0 ? _a : '', node.raw);\n },\n 8: node => {\n var _a;\n writer.comment((_a = node.value) !== null && _a !== void 0 ? _a : '');\n },\n 7: node => {\n writer.pi(node.name, node.value);\n },\n 10: node => {\n var _a;\n writer.doctype((_a = node.value) !== null && _a !== void 0 ? _a : '');\n },\n 4: node => {\n var _a;\n writer.cdata((_a = node.value) !== null && _a !== void 0 ? _a : '');\n },\n 11: node => {\n let tempNode = node;\n if (tempNode = tempNode.firstChild) {\n do {\n walk(tempNode);\n } while (tempNode = tempNode.next);\n }\n }\n };\n writer.reset();\n const walk = node => {\n var _a;\n const handler = handlers[node.type];\n if (!handler) {\n const name = node.name;\n const isEmpty = name in schema.getVoidElements();\n let attrs = node.attributes;\n if (validate && attrs && attrs.length > 1) {\n const sortedAttrs = [];\n sortedAttrs.map = {};\n const elementRule = schema.getElementRule(node.name);\n if (elementRule) {\n for (let i = 0, l = elementRule.attributesOrder.length; i < l; i++) {\n const attrName = elementRule.attributesOrder[i];\n if (attrName in attrs.map) {\n const attrValue = attrs.map[attrName];\n sortedAttrs.map[attrName] = attrValue;\n sortedAttrs.push({\n name: attrName,\n value: attrValue\n });\n }\n }\n for (let i = 0, l = attrs.length; i < l; i++) {\n const attrName = attrs[i].name;\n if (!(attrName in sortedAttrs.map)) {\n const attrValue = attrs.map[attrName];\n sortedAttrs.map[attrName] = attrValue;\n sortedAttrs.push({\n name: attrName,\n value: attrValue\n });\n }\n }\n attrs = sortedAttrs;\n }\n }\n writer.start(name, attrs, isEmpty);\n if (isNonHtmlElementRootName(name)) {\n if (isString(node.value)) {\n writer.text(node.value, true);\n }\n writer.end(name);\n } else {\n if (!isEmpty) {\n let child = node.firstChild;\n if (child) {\n if ((name === 'pre' || name === 'textarea') && child.type === 3 && ((_a = child.value) === null || _a === void 0 ? void 0 : _a[0]) === '\\n') {\n writer.text('\\n', true);\n }\n do {\n walk(child);\n } while (child = child.next);\n }\n writer.end(name);\n }\n }\n } else {\n handler(node);\n }\n };\n if (node.type === 1 && !settings.inner) {\n walk(node);\n } else if (node.type === 3) {\n handlers[3](node);\n } else {\n handlers[11](node);\n }\n return writer.getContent();\n };\n return { serialize };\n };\n\n const nonInheritableStyles = new Set();\n (() => {\n const nonInheritableStylesArr = [\n 'margin',\n 'margin-left',\n 'margin-right',\n 'margin-top',\n 'margin-bottom',\n 'padding',\n 'padding-left',\n 'padding-right',\n 'padding-top',\n 'padding-bottom',\n 'border',\n 'border-width',\n 'border-style',\n 'border-color',\n 'background',\n 'background-attachment',\n 'background-clip',\n 'background-color',\n 'background-image',\n 'background-origin',\n 'background-position',\n 'background-repeat',\n 'background-size',\n 'float',\n 'position',\n 'left',\n 'right',\n 'top',\n 'bottom',\n 'z-index',\n 'display',\n 'transform',\n 'width',\n 'max-width',\n 'min-width',\n 'height',\n 'max-height',\n 'min-height',\n 'overflow',\n 'overflow-x',\n 'overflow-y',\n 'text-overflow',\n 'vertical-align',\n 'transition',\n 'transition-delay',\n 'transition-duration',\n 'transition-property',\n 'transition-timing-function'\n ];\n each$e(nonInheritableStylesArr, style => {\n nonInheritableStyles.add(style);\n });\n })();\n const shorthandStyleProps = [\n 'font',\n 'text-decoration',\n 'text-emphasis'\n ];\n const getStyleProps = (dom, node) => keys(dom.parseStyle(dom.getAttrib(node, 'style')));\n const isNonInheritableStyle = style => nonInheritableStyles.has(style);\n const hasInheritableStyles = (dom, node) => forall(getStyleProps(dom, node), style => !isNonInheritableStyle(style));\n const getLonghandStyleProps = styles => filter$5(styles, style => exists(shorthandStyleProps, prop => startsWith(style, prop)));\n const hasStyleConflict = (dom, node, parentNode) => {\n const nodeStyleProps = getStyleProps(dom, node);\n const parentNodeStyleProps = getStyleProps(dom, parentNode);\n const valueMismatch = prop => {\n var _a, _b;\n const nodeValue = (_a = dom.getStyle(node, prop)) !== null && _a !== void 0 ? _a : '';\n const parentValue = (_b = dom.getStyle(parentNode, prop)) !== null && _b !== void 0 ? _b : '';\n return isNotEmpty(nodeValue) && isNotEmpty(parentValue) && nodeValue !== parentValue;\n };\n return exists(nodeStyleProps, nodeStyleProp => {\n const propExists = props => exists(props, prop => prop === nodeStyleProp);\n if (!propExists(parentNodeStyleProps) && propExists(shorthandStyleProps)) {\n const longhandProps = getLonghandStyleProps(parentNodeStyleProps);\n return exists(longhandProps, valueMismatch);\n } else {\n return valueMismatch(nodeStyleProp);\n }\n });\n };\n\n const isChar = (forward, predicate, pos) => Optional.from(pos.container()).filter(isText$a).exists(text => {\n const delta = forward ? 0 : -1;\n return predicate(text.data.charAt(pos.offset() + delta));\n });\n const isBeforeSpace = curry(isChar, true, isWhiteSpace);\n const isAfterSpace = curry(isChar, false, isWhiteSpace);\n const isEmptyText = pos => {\n const container = pos.container();\n return isText$a(container) && (container.data.length === 0 || isZwsp$1(container.data) && BookmarkManager.isBookmarkNode(container.parentNode));\n };\n const matchesElementPosition = (before, predicate) => pos => getChildNodeAtRelativeOffset(before ? 0 : -1, pos).filter(predicate).isSome();\n const isImageBlock = node => isImg(node) && get$7(SugarElement.fromDom(node), 'display') === 'block';\n const isCefNode = node => isContentEditableFalse$b(node) && !isBogusAll$1(node);\n const isBeforeImageBlock = matchesElementPosition(true, isImageBlock);\n const isAfterImageBlock = matchesElementPosition(false, isImageBlock);\n const isBeforeMedia = matchesElementPosition(true, isMedia$2);\n const isAfterMedia = matchesElementPosition(false, isMedia$2);\n const isBeforeTable = matchesElementPosition(true, isTable$2);\n const isAfterTable = matchesElementPosition(false, isTable$2);\n const isBeforeContentEditableFalse = matchesElementPosition(true, isCefNode);\n const isAfterContentEditableFalse = matchesElementPosition(false, isCefNode);\n\n const dropLast = xs => xs.slice(0, -1);\n const parentsUntil = (start, root, predicate) => {\n if (contains(root, start)) {\n return dropLast(parents$1(start, elm => {\n return predicate(elm) || eq(elm, root);\n }));\n } else {\n return [];\n }\n };\n const parents = (start, root) => parentsUntil(start, root, never);\n const parentsAndSelf = (start, root) => [start].concat(parents(start, root));\n\n const navigateIgnoreEmptyTextNodes = (forward, root, from) => navigateIgnore(forward, root, from, isEmptyText);\n const isBlock$1 = schema => el => schema.isBlock(name(el));\n const getClosestBlock$1 = (root, pos, schema) => find$2(parentsAndSelf(SugarElement.fromDom(pos.container()), root), isBlock$1(schema));\n const isAtBeforeAfterBlockBoundary = (forward, root, pos, schema) => navigateIgnoreEmptyTextNodes(forward, root.dom, pos).forall(newPos => getClosestBlock$1(root, pos, schema).fold(() => !isInSameBlock(newPos, pos, root.dom), fromBlock => !isInSameBlock(newPos, pos, root.dom) && contains(fromBlock, SugarElement.fromDom(newPos.container()))));\n const isAtBlockBoundary = (forward, root, pos, schema) => getClosestBlock$1(root, pos, schema).fold(() => navigateIgnoreEmptyTextNodes(forward, root.dom, pos).forall(newPos => !isInSameBlock(newPos, pos, root.dom)), parent => navigateIgnoreEmptyTextNodes(forward, parent.dom, pos).isNone());\n const isAtStartOfBlock = curry(isAtBlockBoundary, false);\n const isAtEndOfBlock = curry(isAtBlockBoundary, true);\n const isBeforeBlock = curry(isAtBeforeAfterBlockBoundary, false);\n const isAfterBlock = curry(isAtBeforeAfterBlockBoundary, true);\n\n const isBr$1 = pos => getElementFromPosition(pos).exists(isBr$5);\n const findBr = (forward, root, pos, schema) => {\n const parentBlocks = filter$5(parentsAndSelf(SugarElement.fromDom(pos.container()), root), el => schema.isBlock(name(el)));\n const scope = head(parentBlocks).getOr(root);\n return fromPosition(forward, scope.dom, pos).filter(isBr$1);\n };\n const isBeforeBr$1 = (root, pos, schema) => getElementFromPosition(pos).exists(isBr$5) || findBr(true, root, pos, schema).isSome();\n const isAfterBr = (root, pos, schema) => getElementFromPrevPosition(pos).exists(isBr$5) || findBr(false, root, pos, schema).isSome();\n const findPreviousBr = curry(findBr, false);\n const findNextBr = curry(findBr, true);\n\n const isInMiddleOfText = pos => CaretPosition.isTextPosition(pos) && !pos.isAtStart() && !pos.isAtEnd();\n const getClosestBlock = (root, pos, schema) => {\n const parentBlocks = filter$5(parentsAndSelf(SugarElement.fromDom(pos.container()), root), el => schema.isBlock(name(el)));\n return head(parentBlocks).getOr(root);\n };\n const hasSpaceBefore = (root, pos, schema) => {\n if (isInMiddleOfText(pos)) {\n return isAfterSpace(pos);\n } else {\n return isAfterSpace(pos) || prevPosition(getClosestBlock(root, pos, schema).dom, pos).exists(isAfterSpace);\n }\n };\n const hasSpaceAfter = (root, pos, schema) => {\n if (isInMiddleOfText(pos)) {\n return isBeforeSpace(pos);\n } else {\n return isBeforeSpace(pos) || nextPosition(getClosestBlock(root, pos, schema).dom, pos).exists(isBeforeSpace);\n }\n };\n const isPreValue = value => contains$2([\n 'pre',\n 'pre-wrap'\n ], value);\n const isInPre = pos => getElementFromPosition(pos).bind(elm => closest$4(elm, isElement$7)).exists(elm => isPreValue(get$7(elm, 'white-space')));\n const isAtBeginningOfBody = (root, pos) => prevPosition(root.dom, pos).isNone();\n const isAtEndOfBody = (root, pos) => nextPosition(root.dom, pos).isNone();\n const isAtLineBoundary = (root, pos, schema) => isAtBeginningOfBody(root, pos) || isAtEndOfBody(root, pos) || isAtStartOfBlock(root, pos, schema) || isAtEndOfBlock(root, pos, schema) || isAfterBr(root, pos, schema) || isBeforeBr$1(root, pos, schema);\n const isCefBlock = node => isNonNullable(node) && isContentEditableFalse$b(node) && isBlockLike(node);\n const isSiblingCefBlock = (root, direction) => container => {\n return isCefBlock(new DomTreeWalker(container, root)[direction]());\n };\n const isBeforeCefBlock = (root, pos) => {\n const nextPos = nextPosition(root.dom, pos).getOr(pos);\n const isNextCefBlock = isSiblingCefBlock(root.dom, 'next');\n return pos.isAtEnd() && (isNextCefBlock(pos.container()) || isNextCefBlock(nextPos.container()));\n };\n const isAfterCefBlock = (root, pos) => {\n const prevPos = prevPosition(root.dom, pos).getOr(pos);\n const isPrevCefBlock = isSiblingCefBlock(root.dom, 'prev');\n return pos.isAtStart() && (isPrevCefBlock(pos.container()) || isPrevCefBlock(prevPos.container()));\n };\n const needsToHaveNbsp = (root, pos, schema) => {\n if (isInPre(pos)) {\n return false;\n } else {\n return isAtLineBoundary(root, pos, schema) || hasSpaceBefore(root, pos, schema) || hasSpaceAfter(root, pos, schema);\n }\n };\n const needsToBeNbspLeft = (root, pos, schema) => {\n if (isInPre(pos)) {\n return false;\n } else {\n return isAtStartOfBlock(root, pos, schema) || isBeforeBlock(root, pos, schema) || isAfterBr(root, pos, schema) || hasSpaceBefore(root, pos, schema) || isAfterCefBlock(root, pos);\n }\n };\n const leanRight = pos => {\n const container = pos.container();\n const offset = pos.offset();\n if (isText$a(container) && offset < container.data.length) {\n return CaretPosition(container, offset + 1);\n } else {\n return pos;\n }\n };\n const needsToBeNbspRight = (root, pos, schema) => {\n if (isInPre(pos)) {\n return false;\n } else {\n return isAtEndOfBlock(root, pos, schema) || isAfterBlock(root, pos, schema) || isBeforeBr$1(root, pos, schema) || hasSpaceAfter(root, pos, schema) || isBeforeCefBlock(root, pos);\n }\n };\n const needsToBeNbsp = (root, pos, schema) => needsToBeNbspLeft(root, pos, schema) || needsToBeNbspRight(root, leanRight(pos), schema);\n const isNbspAt = (text, offset) => isNbsp(text.charAt(offset));\n const isWhiteSpaceAt = (text, offset) => isWhiteSpace(text.charAt(offset));\n const hasNbsp = pos => {\n const container = pos.container();\n return isText$a(container) && contains$1(container.data, nbsp);\n };\n const normalizeNbspMiddle = text => {\n const chars = text.split('');\n return map$3(chars, (chr, i) => {\n if (isNbsp(chr) && i > 0 && i < chars.length - 1 && isContent(chars[i - 1]) && isContent(chars[i + 1])) {\n return ' ';\n } else {\n return chr;\n }\n }).join('');\n };\n const normalizeNbspAtStart = (root, node, makeNbsp, schema) => {\n const text = node.data;\n const firstPos = CaretPosition(node, 0);\n if (!makeNbsp && isNbspAt(text, 0) && !needsToBeNbsp(root, firstPos, schema)) {\n node.data = ' ' + text.slice(1);\n return true;\n } else if (makeNbsp && isWhiteSpaceAt(text, 0) && needsToBeNbspLeft(root, firstPos, schema)) {\n node.data = nbsp + text.slice(1);\n return true;\n } else {\n return false;\n }\n };\n const normalizeNbspInMiddleOfTextNode = node => {\n const text = node.data;\n const newText = normalizeNbspMiddle(text);\n if (newText !== text) {\n node.data = newText;\n return true;\n } else {\n return false;\n }\n };\n const normalizeNbspAtEnd = (root, node, makeNbsp, schema) => {\n const text = node.data;\n const lastPos = CaretPosition(node, text.length - 1);\n if (!makeNbsp && isNbspAt(text, text.length - 1) && !needsToBeNbsp(root, lastPos, schema)) {\n node.data = text.slice(0, -1) + ' ';\n return true;\n } else if (makeNbsp && isWhiteSpaceAt(text, text.length - 1) && needsToBeNbspRight(root, lastPos, schema)) {\n node.data = text.slice(0, -1) + nbsp;\n return true;\n } else {\n return false;\n }\n };\n const normalizeNbsps = (root, pos, schema) => {\n const container = pos.container();\n if (!isText$a(container)) {\n return Optional.none();\n }\n if (hasNbsp(pos)) {\n const normalized = normalizeNbspAtStart(root, container, false, schema) || normalizeNbspInMiddleOfTextNode(container) || normalizeNbspAtEnd(root, container, false, schema);\n return someIf(normalized, pos);\n } else if (needsToBeNbsp(root, pos, schema)) {\n const normalized = normalizeNbspAtStart(root, container, true, schema) || normalizeNbspAtEnd(root, container, true, schema);\n return someIf(normalized, pos);\n } else {\n return Optional.none();\n }\n };\n const normalizeNbspsInEditor = editor => {\n const root = SugarElement.fromDom(editor.getBody());\n if (editor.selection.isCollapsed()) {\n normalizeNbsps(root, CaretPosition.fromRangeStart(editor.selection.getRng()), editor.schema).each(pos => {\n editor.selection.setRng(pos.toRange());\n });\n }\n };\n\n const normalize$1 = (node, offset, count, schema) => {\n if (count === 0) {\n return;\n }\n const elm = SugarElement.fromDom(node);\n const root = ancestor$4(elm, el => schema.isBlock(name(el))).getOr(elm);\n const whitespace = node.data.slice(offset, offset + count);\n const isEndOfContent = offset + count >= node.data.length && needsToBeNbspRight(root, CaretPosition(node, node.data.length), schema);\n const isStartOfContent = offset === 0 && needsToBeNbspLeft(root, CaretPosition(node, 0), schema);\n node.replaceData(offset, count, normalize$4(whitespace, 4, isStartOfContent, isEndOfContent));\n };\n const normalizeWhitespaceAfter = (node, offset, schema) => {\n const content = node.data.slice(offset);\n const whitespaceCount = content.length - lTrim(content).length;\n normalize$1(node, offset, whitespaceCount, schema);\n };\n const normalizeWhitespaceBefore = (node, offset, schema) => {\n const content = node.data.slice(0, offset);\n const whitespaceCount = content.length - rTrim(content).length;\n normalize$1(node, offset - whitespaceCount, whitespaceCount, schema);\n };\n const mergeTextNodes = (prevNode, nextNode, schema, normalizeWhitespace, mergeToPrev = true) => {\n const whitespaceOffset = rTrim(prevNode.data).length;\n const newNode = mergeToPrev ? prevNode : nextNode;\n const removeNode = mergeToPrev ? nextNode : prevNode;\n if (mergeToPrev) {\n newNode.appendData(removeNode.data);\n } else {\n newNode.insertData(0, removeNode.data);\n }\n remove$5(SugarElement.fromDom(removeNode));\n if (normalizeWhitespace) {\n normalizeWhitespaceAfter(newNode, whitespaceOffset, schema);\n }\n return newNode;\n };\n\n const needsReposition = (pos, elm) => {\n const container = pos.container();\n const offset = pos.offset();\n return !CaretPosition.isTextPosition(pos) && container === elm.parentNode && offset > CaretPosition.before(elm).offset();\n };\n const reposition = (elm, pos) => needsReposition(pos, elm) ? CaretPosition(pos.container(), pos.offset() - 1) : pos;\n const beforeOrStartOf = node => isText$a(node) ? CaretPosition(node, 0) : CaretPosition.before(node);\n const afterOrEndOf = node => isText$a(node) ? CaretPosition(node, node.data.length) : CaretPosition.after(node);\n const getPreviousSiblingCaretPosition = elm => {\n if (isCaretCandidate$3(elm.previousSibling)) {\n return Optional.some(afterOrEndOf(elm.previousSibling));\n } else {\n return elm.previousSibling ? lastPositionIn(elm.previousSibling) : Optional.none();\n }\n };\n const getNextSiblingCaretPosition = elm => {\n if (isCaretCandidate$3(elm.nextSibling)) {\n return Optional.some(beforeOrStartOf(elm.nextSibling));\n } else {\n return elm.nextSibling ? firstPositionIn(elm.nextSibling) : Optional.none();\n }\n };\n const findCaretPositionBackwardsFromElm = (rootElement, elm) => {\n return Optional.from(elm.previousSibling ? elm.previousSibling : elm.parentNode).bind(node => prevPosition(rootElement, CaretPosition.before(node))).orThunk(() => nextPosition(rootElement, CaretPosition.after(elm)));\n };\n const findCaretPositionForwardsFromElm = (rootElement, elm) => nextPosition(rootElement, CaretPosition.after(elm)).orThunk(() => prevPosition(rootElement, CaretPosition.before(elm)));\n const findCaretPositionBackwards = (rootElement, elm) => getPreviousSiblingCaretPosition(elm).orThunk(() => getNextSiblingCaretPosition(elm)).orThunk(() => findCaretPositionBackwardsFromElm(rootElement, elm));\n const findCaretPositionForward = (rootElement, elm) => getNextSiblingCaretPosition(elm).orThunk(() => getPreviousSiblingCaretPosition(elm)).orThunk(() => findCaretPositionForwardsFromElm(rootElement, elm));\n const findCaretPosition = (forward, rootElement, elm) => forward ? findCaretPositionForward(rootElement, elm) : findCaretPositionBackwards(rootElement, elm);\n const findCaretPosOutsideElmAfterDelete = (forward, rootElement, elm) => findCaretPosition(forward, rootElement, elm).map(curry(reposition, elm));\n const setSelection$1 = (editor, forward, pos) => {\n pos.fold(() => {\n editor.focus();\n }, pos => {\n editor.selection.setRng(pos.toRange(), forward);\n });\n };\n const eqRawNode = rawNode => elm => elm.dom === rawNode;\n const isBlock = (editor, elm) => elm && has$2(editor.schema.getBlockElements(), name(elm));\n const paddEmptyBlock = (elm, preserveEmptyCaret) => {\n if (isEmpty$2(elm)) {\n const br = SugarElement.fromHtml('
');\n if (preserveEmptyCaret) {\n each$e(children$1(elm), node => {\n if (!isEmptyCaretFormatElement(node)) {\n remove$5(node);\n }\n });\n } else {\n empty(elm);\n }\n append$1(elm, br);\n return Optional.some(CaretPosition.before(br.dom));\n } else {\n return Optional.none();\n }\n };\n const deleteNormalized = (elm, afterDeletePosOpt, schema, normalizeWhitespace) => {\n const prevTextOpt = prevSibling(elm).filter(isText$b);\n const nextTextOpt = nextSibling(elm).filter(isText$b);\n remove$5(elm);\n return lift3(prevTextOpt, nextTextOpt, afterDeletePosOpt, (prev, next, pos) => {\n const prevNode = prev.dom, nextNode = next.dom;\n const offset = prevNode.data.length;\n mergeTextNodes(prevNode, nextNode, schema, normalizeWhitespace);\n return pos.container() === nextNode ? CaretPosition(prevNode, offset) : pos;\n }).orThunk(() => {\n if (normalizeWhitespace) {\n prevTextOpt.each(elm => normalizeWhitespaceBefore(elm.dom, elm.dom.length, schema));\n nextTextOpt.each(elm => normalizeWhitespaceAfter(elm.dom, 0, schema));\n }\n return afterDeletePosOpt;\n });\n };\n const isInlineElement = (editor, element) => has$2(editor.schema.getTextInlineElements(), name(element));\n const deleteElement$2 = (editor, forward, elm, moveCaret = true, preserveEmptyCaret = false) => {\n const afterDeletePos = findCaretPosOutsideElmAfterDelete(forward, editor.getBody(), elm.dom);\n const parentBlock = ancestor$4(elm, curry(isBlock, editor), eqRawNode(editor.getBody()));\n const normalizedAfterDeletePos = deleteNormalized(elm, afterDeletePos, editor.schema, isInlineElement(editor, elm));\n if (editor.dom.isEmpty(editor.getBody())) {\n editor.setContent('');\n editor.selection.setCursorLocation();\n } else {\n parentBlock.bind(elm => paddEmptyBlock(elm, preserveEmptyCaret)).fold(() => {\n if (moveCaret) {\n setSelection$1(editor, forward, normalizedAfterDeletePos);\n }\n }, paddPos => {\n if (moveCaret) {\n setSelection$1(editor, forward, Optional.some(paddPos));\n }\n });\n }\n };\n\n const strongRtl = /[\\u0591-\\u07FF\\uFB1D-\\uFDFF\\uFE70-\\uFEFC]/;\n const hasStrongRtl = text => strongRtl.test(text);\n\n const isInlineTarget = (editor, elm) => is$1(SugarElement.fromDom(elm), getInlineBoundarySelector(editor)) && !isTransparentBlock(editor.schema, elm) && editor.dom.isEditable(elm);\n const isRtl = element => {\n var _a;\n return DOMUtils.DOM.getStyle(element, 'direction', true) === 'rtl' || hasStrongRtl((_a = element.textContent) !== null && _a !== void 0 ? _a : '');\n };\n const findInlineParents = (isInlineTarget, rootNode, pos) => filter$5(DOMUtils.DOM.getParents(pos.container(), '*', rootNode), isInlineTarget);\n const findRootInline = (isInlineTarget, rootNode, pos) => {\n const parents = findInlineParents(isInlineTarget, rootNode, pos);\n return Optional.from(parents[parents.length - 1]);\n };\n const hasSameParentBlock = (rootNode, node1, node2) => {\n const block1 = getParentBlock$3(node1, rootNode);\n const block2 = getParentBlock$3(node2, rootNode);\n return isNonNullable(block1) && block1 === block2;\n };\n const isAtZwsp = pos => isBeforeInline(pos) || isAfterInline(pos);\n const normalizePosition = (forward, pos) => {\n const container = pos.container(), offset = pos.offset();\n if (forward) {\n if (isCaretContainerInline(container)) {\n if (isText$a(container.nextSibling)) {\n return CaretPosition(container.nextSibling, 0);\n } else {\n return CaretPosition.after(container);\n }\n } else {\n return isBeforeInline(pos) ? CaretPosition(container, offset + 1) : pos;\n }\n } else {\n if (isCaretContainerInline(container)) {\n if (isText$a(container.previousSibling)) {\n return CaretPosition(container.previousSibling, container.previousSibling.data.length);\n } else {\n return CaretPosition.before(container);\n }\n } else {\n return isAfterInline(pos) ? CaretPosition(container, offset - 1) : pos;\n }\n }\n };\n const normalizeForwards = curry(normalizePosition, true);\n const normalizeBackwards = curry(normalizePosition, false);\n\n const execCommandIgnoreInputEvents = (editor, command) => {\n const inputBlocker = e => e.stopImmediatePropagation();\n editor.on('beforeinput input', inputBlocker, true);\n editor.getDoc().execCommand(command);\n editor.off('beforeinput input', inputBlocker);\n };\n const execEditorDeleteCommand = editor => {\n editor.execCommand('delete');\n };\n const execNativeDeleteCommand = editor => execCommandIgnoreInputEvents(editor, 'Delete');\n const execNativeForwardDeleteCommand = editor => execCommandIgnoreInputEvents(editor, 'ForwardDelete');\n const isBeforeRoot = rootNode => elm => is$2(parent(elm), rootNode, eq);\n const isTextBlockOrListItem = element => isTextBlock$2(element) || isListItem$1(element);\n const getParentBlock$2 = (rootNode, elm) => {\n if (contains(rootNode, elm)) {\n return closest$4(elm, isTextBlockOrListItem, isBeforeRoot(rootNode));\n } else {\n return Optional.none();\n }\n };\n const paddEmptyBody = (editor, moveSelection = true) => {\n if (editor.dom.isEmpty(editor.getBody())) {\n editor.setContent('', { no_selection: !moveSelection });\n }\n };\n const willDeleteLastPositionInElement = (forward, fromPos, elm) => lift2(firstPositionIn(elm), lastPositionIn(elm), (firstPos, lastPos) => {\n const normalizedFirstPos = normalizePosition(true, firstPos);\n const normalizedLastPos = normalizePosition(false, lastPos);\n const normalizedFromPos = normalizePosition(false, fromPos);\n if (forward) {\n return nextPosition(elm, normalizedFromPos).exists(nextPos => nextPos.isEqual(normalizedLastPos) && fromPos.isEqual(normalizedFirstPos));\n } else {\n return prevPosition(elm, normalizedFromPos).exists(prevPos => prevPos.isEqual(normalizedFirstPos) && fromPos.isEqual(normalizedLastPos));\n }\n }).getOr(true);\n const freefallRtl = root => {\n const child = isComment$1(root) ? prevSibling(root) : lastChild(root);\n return child.bind(freefallRtl).orThunk(() => Optional.some(root));\n };\n const deleteRangeContents = (editor, rng, root, moveSelection = true) => {\n var _a;\n rng.deleteContents();\n const lastNode = freefallRtl(root).getOr(root);\n const lastBlock = SugarElement.fromDom((_a = editor.dom.getParent(lastNode.dom, editor.dom.isBlock)) !== null && _a !== void 0 ? _a : root.dom);\n if (lastBlock.dom === editor.getBody()) {\n paddEmptyBody(editor, moveSelection);\n } else if (isEmpty$2(lastBlock)) {\n fillWithPaddingBr(lastBlock);\n if (moveSelection) {\n editor.selection.setCursorLocation(lastBlock.dom, 0);\n }\n }\n if (!eq(root, lastBlock)) {\n const additionalCleanupNodes = is$2(parent(lastBlock), root) ? [] : siblings(lastBlock);\n each$e(additionalCleanupNodes.concat(children$1(root)), node => {\n if (!eq(node, lastBlock) && !contains(node, lastBlock) && isEmpty$2(node)) {\n remove$5(node);\n }\n });\n }\n };\n\n const ancestor$1 = (scope, predicate, isRoot) => ancestor$4(scope, predicate, isRoot).isSome();\n const sibling = (scope, predicate) => sibling$1(scope, predicate).isSome();\n const descendant = (scope, predicate) => descendant$2(scope, predicate).isSome();\n\n const isRootFromElement = root => cur => eq(root, cur);\n const getTableCells = table => descendants(table, 'td,th');\n const getTable$1 = (node, isRoot) => getClosestTable(SugarElement.fromDom(node), isRoot);\n const selectionInTableWithNestedTable = details => {\n return lift2(details.startTable, details.endTable, (startTable, endTable) => {\n const isStartTableParentOfEndTable = descendant(startTable, t => eq(t, endTable));\n const isEndTableParentOfStartTable = descendant(endTable, t => eq(t, startTable));\n return !isStartTableParentOfEndTable && !isEndTableParentOfStartTable ? details : {\n ...details,\n startTable: isStartTableParentOfEndTable ? Optional.none() : details.startTable,\n endTable: isEndTableParentOfStartTable ? Optional.none() : details.endTable,\n isSameTable: false,\n isMultiTable: false\n };\n }).getOr(details);\n };\n const adjustQuirksInDetails = details => {\n return selectionInTableWithNestedTable(details);\n };\n const getTableDetailsFromRange = (rng, isRoot) => {\n const startTable = getTable$1(rng.startContainer, isRoot);\n const endTable = getTable$1(rng.endContainer, isRoot);\n const isStartInTable = startTable.isSome();\n const isEndInTable = endTable.isSome();\n const isSameTable = lift2(startTable, endTable, eq).getOr(false);\n const isMultiTable = !isSameTable && isStartInTable && isEndInTable;\n return adjustQuirksInDetails({\n startTable,\n endTable,\n isStartInTable,\n isEndInTable,\n isSameTable,\n isMultiTable\n });\n };\n\n const tableCellRng = (start, end) => ({\n start,\n end\n });\n const tableSelection = (rng, table, cells) => ({\n rng,\n table,\n cells\n });\n const deleteAction = Adt.generate([\n {\n singleCellTable: [\n 'rng',\n 'cell'\n ]\n },\n { fullTable: ['table'] },\n {\n partialTable: [\n 'cells',\n 'outsideDetails'\n ]\n },\n {\n multiTable: [\n 'startTableCells',\n 'endTableCells',\n 'betweenRng'\n ]\n }\n ]);\n const getClosestCell$1 = (container, isRoot) => closest$3(SugarElement.fromDom(container), 'td,th', isRoot);\n const isExpandedCellRng = cellRng => !eq(cellRng.start, cellRng.end);\n const getTableFromCellRng = (cellRng, isRoot) => getClosestTable(cellRng.start, isRoot).bind(startParentTable => getClosestTable(cellRng.end, isRoot).bind(endParentTable => someIf(eq(startParentTable, endParentTable), startParentTable)));\n const isSingleCellTable = (cellRng, isRoot) => !isExpandedCellRng(cellRng) && getTableFromCellRng(cellRng, isRoot).exists(table => {\n const rows = table.dom.rows;\n return rows.length === 1 && rows[0].cells.length === 1;\n });\n const getCellRng = (rng, isRoot) => {\n const startCell = getClosestCell$1(rng.startContainer, isRoot);\n const endCell = getClosestCell$1(rng.endContainer, isRoot);\n return lift2(startCell, endCell, tableCellRng);\n };\n const getCellRangeFromStartTable = isRoot => startCell => getClosestTable(startCell, isRoot).bind(table => last$3(getTableCells(table)).map(endCell => tableCellRng(startCell, endCell)));\n const getCellRangeFromEndTable = isRoot => endCell => getClosestTable(endCell, isRoot).bind(table => head(getTableCells(table)).map(startCell => tableCellRng(startCell, endCell)));\n const getTableSelectionFromCellRng = isRoot => cellRng => getTableFromCellRng(cellRng, isRoot).map(table => tableSelection(cellRng, table, getTableCells(table)));\n const getTableSelections = (cellRng, selectionDetails, rng, isRoot) => {\n if (rng.collapsed || !cellRng.forall(isExpandedCellRng)) {\n return Optional.none();\n } else if (selectionDetails.isSameTable) {\n const sameTableSelection = cellRng.bind(getTableSelectionFromCellRng(isRoot));\n return Optional.some({\n start: sameTableSelection,\n end: sameTableSelection\n });\n } else {\n const startCell = getClosestCell$1(rng.startContainer, isRoot);\n const endCell = getClosestCell$1(rng.endContainer, isRoot);\n const startTableSelection = startCell.bind(getCellRangeFromStartTable(isRoot)).bind(getTableSelectionFromCellRng(isRoot));\n const endTableSelection = endCell.bind(getCellRangeFromEndTable(isRoot)).bind(getTableSelectionFromCellRng(isRoot));\n return Optional.some({\n start: startTableSelection,\n end: endTableSelection\n });\n }\n };\n const getCellIndex = (cells, cell) => findIndex$2(cells, x => eq(x, cell));\n const getSelectedCells = tableSelection => lift2(getCellIndex(tableSelection.cells, tableSelection.rng.start), getCellIndex(tableSelection.cells, tableSelection.rng.end), (startIndex, endIndex) => tableSelection.cells.slice(startIndex, endIndex + 1));\n const isSingleCellTableContentSelected = (optCellRng, rng, isRoot) => optCellRng.exists(cellRng => isSingleCellTable(cellRng, isRoot) && hasAllContentsSelected(cellRng.start, rng));\n const unselectCells = (rng, selectionDetails) => {\n const {startTable, endTable} = selectionDetails;\n const otherContentRng = rng.cloneRange();\n startTable.each(table => otherContentRng.setStartAfter(table.dom));\n endTable.each(table => otherContentRng.setEndBefore(table.dom));\n return otherContentRng;\n };\n const handleSingleTable = (cellRng, selectionDetails, rng, isRoot) => getTableSelections(cellRng, selectionDetails, rng, isRoot).bind(({start, end}) => start.or(end)).bind(tableSelection => {\n const {isSameTable} = selectionDetails;\n const selectedCells = getSelectedCells(tableSelection).getOr([]);\n if (isSameTable && tableSelection.cells.length === selectedCells.length) {\n return Optional.some(deleteAction.fullTable(tableSelection.table));\n } else if (selectedCells.length > 0) {\n if (isSameTable) {\n return Optional.some(deleteAction.partialTable(selectedCells, Optional.none()));\n } else {\n const otherContentRng = unselectCells(rng, selectionDetails);\n return Optional.some(deleteAction.partialTable(selectedCells, Optional.some({\n ...selectionDetails,\n rng: otherContentRng\n })));\n }\n } else {\n return Optional.none();\n }\n });\n const handleMultiTable = (cellRng, selectionDetails, rng, isRoot) => getTableSelections(cellRng, selectionDetails, rng, isRoot).bind(({start, end}) => {\n const startTableSelectedCells = start.bind(getSelectedCells).getOr([]);\n const endTableSelectedCells = end.bind(getSelectedCells).getOr([]);\n if (startTableSelectedCells.length > 0 && endTableSelectedCells.length > 0) {\n const otherContentRng = unselectCells(rng, selectionDetails);\n return Optional.some(deleteAction.multiTable(startTableSelectedCells, endTableSelectedCells, otherContentRng));\n } else {\n return Optional.none();\n }\n });\n const getActionFromRange = (root, rng) => {\n const isRoot = isRootFromElement(root);\n const optCellRng = getCellRng(rng, isRoot);\n const selectionDetails = getTableDetailsFromRange(rng, isRoot);\n if (isSingleCellTableContentSelected(optCellRng, rng, isRoot)) {\n return optCellRng.map(cellRng => deleteAction.singleCellTable(rng, cellRng.start));\n } else if (selectionDetails.isMultiTable) {\n return handleMultiTable(optCellRng, selectionDetails, rng, isRoot);\n } else {\n return handleSingleTable(optCellRng, selectionDetails, rng, isRoot);\n }\n };\n\n const cleanCells = cells => each$e(cells, cell => {\n remove$a(cell, 'contenteditable');\n fillWithPaddingBr(cell);\n });\n const getOutsideBlock = (editor, container) => Optional.from(editor.dom.getParent(container, editor.dom.isBlock)).map(SugarElement.fromDom);\n const handleEmptyBlock = (editor, startInTable, emptyBlock) => {\n emptyBlock.each(block => {\n if (startInTable) {\n remove$5(block);\n } else {\n fillWithPaddingBr(block);\n editor.selection.setCursorLocation(block.dom, 0);\n }\n });\n };\n const deleteContentInsideCell = (editor, cell, rng, isFirstCellInSelection) => {\n const insideTableRng = rng.cloneRange();\n if (isFirstCellInSelection) {\n insideTableRng.setStart(rng.startContainer, rng.startOffset);\n insideTableRng.setEndAfter(cell.dom.lastChild);\n } else {\n insideTableRng.setStartBefore(cell.dom.firstChild);\n insideTableRng.setEnd(rng.endContainer, rng.endOffset);\n }\n deleteCellContents(editor, insideTableRng, cell, false).each(action => action());\n };\n const collapseAndRestoreCellSelection = editor => {\n const selectedCells = getCellsFromEditor(editor);\n const selectedNode = SugarElement.fromDom(editor.selection.getNode());\n if (isTableCell$3(selectedNode.dom) && isEmpty$2(selectedNode)) {\n editor.selection.setCursorLocation(selectedNode.dom, 0);\n } else {\n editor.selection.collapse(true);\n }\n if (selectedCells.length > 1 && exists(selectedCells, cell => eq(cell, selectedNode))) {\n set$3(selectedNode, 'data-mce-selected', '1');\n }\n };\n const emptySingleTableCells = (editor, cells, outsideDetails) => Optional.some(() => {\n const editorRng = editor.selection.getRng();\n const cellsToClean = outsideDetails.bind(({rng, isStartInTable}) => {\n const outsideBlock = getOutsideBlock(editor, isStartInTable ? rng.endContainer : rng.startContainer);\n rng.deleteContents();\n handleEmptyBlock(editor, isStartInTable, outsideBlock.filter(isEmpty$2));\n const endPointCell = isStartInTable ? cells[0] : cells[cells.length - 1];\n deleteContentInsideCell(editor, endPointCell, editorRng, isStartInTable);\n if (!isEmpty$2(endPointCell)) {\n return Optional.some(isStartInTable ? cells.slice(1) : cells.slice(0, -1));\n } else {\n return Optional.none();\n }\n }).getOr(cells);\n cleanCells(cellsToClean);\n collapseAndRestoreCellSelection(editor);\n });\n const emptyMultiTableCells = (editor, startTableCells, endTableCells, betweenRng) => Optional.some(() => {\n const rng = editor.selection.getRng();\n const startCell = startTableCells[0];\n const endCell = endTableCells[endTableCells.length - 1];\n deleteContentInsideCell(editor, startCell, rng, true);\n deleteContentInsideCell(editor, endCell, rng, false);\n const startTableCellsToClean = isEmpty$2(startCell) ? startTableCells : startTableCells.slice(1);\n const endTableCellsToClean = isEmpty$2(endCell) ? endTableCells : endTableCells.slice(0, -1);\n cleanCells(startTableCellsToClean.concat(endTableCellsToClean));\n betweenRng.deleteContents();\n collapseAndRestoreCellSelection(editor);\n });\n const deleteCellContents = (editor, rng, cell, moveSelection = true) => Optional.some(() => {\n deleteRangeContents(editor, rng, cell, moveSelection);\n });\n const deleteTableElement = (editor, table) => Optional.some(() => deleteElement$2(editor, false, table));\n const deleteCellRange = (editor, rootElm, rng) => getActionFromRange(rootElm, rng).bind(action => action.fold(curry(deleteCellContents, editor), curry(deleteTableElement, editor), curry(emptySingleTableCells, editor), curry(emptyMultiTableCells, editor)));\n const deleteCaptionRange = (editor, caption) => emptyElement(editor, caption);\n const deleteTableRange = (editor, rootElm, rng, startElm) => getParentCaption(rootElm, startElm).fold(() => deleteCellRange(editor, rootElm, rng), caption => deleteCaptionRange(editor, caption));\n const deleteRange$3 = (editor, startElm, selectedCells) => {\n const rootNode = SugarElement.fromDom(editor.getBody());\n const rng = editor.selection.getRng();\n return selectedCells.length !== 0 ? emptySingleTableCells(editor, selectedCells, Optional.none()) : deleteTableRange(editor, rootNode, rng, startElm);\n };\n const getParentCell = (rootElm, elm) => find$2(parentsAndSelf(elm, rootElm), isTableCell$2);\n const getParentCaption = (rootElm, elm) => find$2(parentsAndSelf(elm, rootElm), isTag('caption'));\n const deleteBetweenCells = (editor, rootElm, forward, fromCell, from) => navigate(forward, editor.getBody(), from).bind(to => getParentCell(rootElm, SugarElement.fromDom(to.getNode())).bind(toCell => eq(toCell, fromCell) ? Optional.none() : Optional.some(noop)));\n const emptyElement = (editor, elm) => Optional.some(() => {\n fillWithPaddingBr(elm);\n editor.selection.setCursorLocation(elm.dom, 0);\n });\n const isDeleteOfLastCharPos = (fromCaption, forward, from, to) => firstPositionIn(fromCaption.dom).bind(first => lastPositionIn(fromCaption.dom).map(last => forward ? from.isEqual(first) && to.isEqual(last) : from.isEqual(last) && to.isEqual(first))).getOr(true);\n const emptyCaretCaption = (editor, elm) => emptyElement(editor, elm);\n const validateCaretCaption = (rootElm, fromCaption, to) => getParentCaption(rootElm, SugarElement.fromDom(to.getNode())).fold(() => Optional.some(noop), toCaption => someIf(!eq(toCaption, fromCaption), noop));\n const deleteCaretInsideCaption = (editor, rootElm, forward, fromCaption, from) => navigate(forward, editor.getBody(), from).fold(() => Optional.some(noop), to => isDeleteOfLastCharPos(fromCaption, forward, from, to) ? emptyCaretCaption(editor, fromCaption) : validateCaretCaption(rootElm, fromCaption, to));\n const deleteCaretCells = (editor, forward, rootElm, startElm) => {\n const from = CaretPosition.fromRangeStart(editor.selection.getRng());\n return getParentCell(rootElm, startElm).bind(fromCell => isEmpty$2(fromCell) ? emptyElement(editor, fromCell) : deleteBetweenCells(editor, rootElm, forward, fromCell, from));\n };\n const deleteCaretCaption = (editor, forward, rootElm, fromCaption) => {\n const from = CaretPosition.fromRangeStart(editor.selection.getRng());\n return isEmpty$2(fromCaption) ? emptyElement(editor, fromCaption) : deleteCaretInsideCaption(editor, rootElm, forward, fromCaption, from);\n };\n const isNearTable = (forward, pos) => forward ? isBeforeTable(pos) : isAfterTable(pos);\n const isBeforeOrAfterTable = (editor, forward) => {\n const fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());\n return isNearTable(forward, fromPos) || fromPosition(forward, editor.getBody(), fromPos).exists(pos => isNearTable(forward, pos));\n };\n const deleteCaret$3 = (editor, forward, startElm) => {\n const rootElm = SugarElement.fromDom(editor.getBody());\n return getParentCaption(rootElm, startElm).fold(() => deleteCaretCells(editor, forward, rootElm, startElm).orThunk(() => someIf(isBeforeOrAfterTable(editor, forward), noop)), fromCaption => deleteCaretCaption(editor, forward, rootElm, fromCaption));\n };\n const backspaceDelete$a = (editor, forward) => {\n const startElm = SugarElement.fromDom(editor.selection.getStart(true));\n const cells = getCellsFromEditor(editor);\n return editor.selection.isCollapsed() && cells.length === 0 ? deleteCaret$3(editor, forward, startElm) : deleteRange$3(editor, startElm, cells);\n };\n\n const getContentEditableRoot$1 = (root, node) => {\n let tempNode = node;\n while (tempNode && tempNode !== root) {\n if (isContentEditableTrue$3(tempNode) || isContentEditableFalse$b(tempNode)) {\n return tempNode;\n }\n tempNode = tempNode.parentNode;\n }\n return null;\n };\n\n const internalAttributesPrefixes = [\n 'data-ephox-',\n 'data-mce-',\n 'data-alloy-',\n 'data-snooker-',\n '_'\n ];\n const each$9 = Tools.each;\n const ElementUtils = editor => {\n const dom = editor.dom;\n const internalAttributes = new Set(editor.serializer.getTempAttrs());\n const compare = (node1, node2) => {\n if (node1.nodeName !== node2.nodeName || node1.nodeType !== node2.nodeType) {\n return false;\n }\n const getAttribs = node => {\n const attribs = {};\n each$9(dom.getAttribs(node), attr => {\n const name = attr.nodeName.toLowerCase();\n if (name !== 'style' && !isAttributeInternal(name)) {\n attribs[name] = dom.getAttrib(node, name);\n }\n });\n return attribs;\n };\n const compareObjects = (obj1, obj2) => {\n for (const name in obj1) {\n if (has$2(obj1, name)) {\n const value = obj2[name];\n if (isUndefined(value)) {\n return false;\n }\n if (obj1[name] !== value) {\n return false;\n }\n delete obj2[name];\n }\n }\n for (const name in obj2) {\n if (has$2(obj2, name)) {\n return false;\n }\n }\n return true;\n };\n if (isElement$6(node1) && isElement$6(node2)) {\n if (!compareObjects(getAttribs(node1), getAttribs(node2))) {\n return false;\n }\n if (!compareObjects(dom.parseStyle(dom.getAttrib(node1, 'style')), dom.parseStyle(dom.getAttrib(node2, 'style')))) {\n return false;\n }\n }\n return !isBookmarkNode$1(node1) && !isBookmarkNode$1(node2);\n };\n const isAttributeInternal = attributeName => exists(internalAttributesPrefixes, value => startsWith(attributeName, value)) || internalAttributes.has(attributeName);\n return {\n compare,\n isAttributeInternal\n };\n };\n\n const isHeading = node => [\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6'\n ].includes(node.name);\n const isSummary = node => node.name === 'summary';\n\n const traverse = (root, fn) => {\n let node = root;\n while (node = node.walk()) {\n fn(node);\n }\n };\n const matchNode$1 = (nodeFilters, attributeFilters, node, matches) => {\n const name = node.name;\n for (let ni = 0, nl = nodeFilters.length; ni < nl; ni++) {\n const filter = nodeFilters[ni];\n if (filter.name === name) {\n const match = matches.nodes[name];\n if (match) {\n match.nodes.push(node);\n } else {\n matches.nodes[name] = {\n filter,\n nodes: [node]\n };\n }\n }\n }\n if (node.attributes) {\n for (let ai = 0, al = attributeFilters.length; ai < al; ai++) {\n const filter = attributeFilters[ai];\n const attrName = filter.name;\n if (attrName in node.attributes.map) {\n const match = matches.attributes[attrName];\n if (match) {\n match.nodes.push(node);\n } else {\n matches.attributes[attrName] = {\n filter,\n nodes: [node]\n };\n }\n }\n }\n }\n };\n const findMatchingNodes = (nodeFilters, attributeFilters, node) => {\n const matches = {\n nodes: {},\n attributes: {}\n };\n if (node.firstChild) {\n traverse(node, childNode => {\n matchNode$1(nodeFilters, attributeFilters, childNode, matches);\n });\n }\n return matches;\n };\n const runFilters = (matches, args) => {\n const run = (matchRecord, filteringAttributes) => {\n each$d(matchRecord, match => {\n const nodes = from(match.nodes);\n each$e(match.filter.callbacks, callback => {\n for (let i = nodes.length - 1; i >= 0; i--) {\n const node = nodes[i];\n const valueMatches = filteringAttributes ? node.attr(match.filter.name) !== undefined : node.name === match.filter.name;\n if (!valueMatches || isNullable(node.parent)) {\n nodes.splice(i, 1);\n }\n }\n if (nodes.length > 0) {\n callback(nodes, match.filter.name, args);\n }\n });\n });\n };\n run(matches.nodes, false);\n run(matches.attributes, true);\n };\n const filter$2 = (nodeFilters, attributeFilters, node, args = {}) => {\n const matches = findMatchingNodes(nodeFilters, attributeFilters, node);\n runFilters(matches, args);\n };\n\n const paddEmptyNode = (settings, args, isBlock, node) => {\n const brPreferred = settings.pad_empty_with_br || args.insert;\n if (brPreferred && isBlock(node)) {\n const astNode = new AstNode('br', 1);\n if (args.insert) {\n astNode.attr('data-mce-bogus', '1');\n }\n node.empty().append(astNode);\n } else {\n node.empty().append(new AstNode('#text', 3)).value = nbsp;\n }\n };\n const isPaddedWithNbsp = node => {\n var _a;\n return hasOnlyChild(node, '#text') && ((_a = node === null || node === void 0 ? void 0 : node.firstChild) === null || _a === void 0 ? void 0 : _a.value) === nbsp;\n };\n const hasOnlyChild = (node, name) => {\n const firstChild = node === null || node === void 0 ? void 0 : node.firstChild;\n return isNonNullable(firstChild) && firstChild === node.lastChild && firstChild.name === name;\n };\n const isPadded = (schema, node) => {\n const rule = schema.getElementRule(node.name);\n return (rule === null || rule === void 0 ? void 0 : rule.paddEmpty) === true;\n };\n const isEmpty = (schema, nonEmptyElements, whitespaceElements, node) => node.isEmpty(nonEmptyElements, whitespaceElements, node => isPadded(schema, node));\n const isLineBreakNode = (node, isBlock) => isNonNullable(node) && (isBlock(node) || node.name === 'br');\n const findClosestEditingHost = scope => {\n let editableNode;\n for (let node = scope; node; node = node.parent) {\n const contentEditable = node.attr('contenteditable');\n if (contentEditable === 'false') {\n break;\n } else if (contentEditable === 'true') {\n editableNode = node;\n }\n }\n return Optional.from(editableNode);\n };\n\n const removeOrUnwrapInvalidNode = (node, schema, originalNodeParent = node.parent) => {\n if (schema.getSpecialElements()[node.name]) {\n node.empty().remove();\n } else {\n const children = node.children();\n for (const childNode of children) {\n if (originalNodeParent && !schema.isValidChild(originalNodeParent.name, childNode.name)) {\n removeOrUnwrapInvalidNode(childNode, schema, originalNodeParent);\n }\n }\n node.unwrap();\n }\n };\n const cleanInvalidNodes = (nodes, schema, rootNode, onCreate = noop) => {\n const textBlockElements = schema.getTextBlockElements();\n const nonEmptyElements = schema.getNonEmptyElements();\n const whitespaceElements = schema.getWhitespaceElements();\n const nonSplittableElements = Tools.makeMap('tr,td,th,tbody,thead,tfoot,table,summary');\n const fixed = new Set();\n const isSplittableElement = node => node !== rootNode && !nonSplittableElements[node.name];\n for (let ni = 0; ni < nodes.length; ni++) {\n const node = nodes[ni];\n let parent;\n let newParent;\n let tempNode;\n if (!node.parent || fixed.has(node)) {\n continue;\n }\n if (textBlockElements[node.name] && node.parent.name === 'li') {\n let sibling = node.next;\n while (sibling) {\n if (textBlockElements[sibling.name]) {\n sibling.name = 'li';\n fixed.add(sibling);\n node.parent.insert(sibling, node.parent);\n } else {\n break;\n }\n sibling = sibling.next;\n }\n node.unwrap();\n continue;\n }\n const parents = [node];\n for (parent = node.parent; parent && !schema.isValidChild(parent.name, node.name) && isSplittableElement(parent); parent = parent.parent) {\n parents.push(parent);\n }\n if (parent && parents.length > 1) {\n if (!isInvalid(schema, node, parent)) {\n parents.reverse();\n newParent = parents[0].clone();\n onCreate(newParent);\n let currentNode = newParent;\n for (let i = 0; i < parents.length - 1; i++) {\n if (schema.isValidChild(currentNode.name, parents[i].name) && i > 0) {\n tempNode = parents[i].clone();\n onCreate(tempNode);\n currentNode.append(tempNode);\n } else {\n tempNode = currentNode;\n }\n for (let childNode = parents[i].firstChild; childNode && childNode !== parents[i + 1];) {\n const nextNode = childNode.next;\n tempNode.append(childNode);\n childNode = nextNode;\n }\n currentNode = tempNode;\n }\n if (!isEmpty(schema, nonEmptyElements, whitespaceElements, newParent)) {\n parent.insert(newParent, parents[0], true);\n parent.insert(node, newParent);\n } else {\n parent.insert(node, parents[0], true);\n }\n parent = parents[0];\n if (isEmpty(schema, nonEmptyElements, whitespaceElements, parent) || hasOnlyChild(parent, 'br')) {\n parent.empty().remove();\n }\n } else {\n removeOrUnwrapInvalidNode(node, schema);\n }\n } else if (node.parent) {\n if (node.name === 'li') {\n let sibling = node.prev;\n if (sibling && (sibling.name === 'ul' || sibling.name === 'ol')) {\n sibling.append(node);\n continue;\n }\n sibling = node.next;\n if (sibling && (sibling.name === 'ul' || sibling.name === 'ol') && sibling.firstChild) {\n sibling.insert(node, sibling.firstChild, true);\n continue;\n }\n const wrapper = new AstNode('ul', 1);\n onCreate(wrapper);\n node.wrap(wrapper);\n continue;\n }\n if (schema.isValidChild(node.parent.name, 'div') && schema.isValidChild('div', node.name)) {\n const wrapper = new AstNode('div', 1);\n onCreate(wrapper);\n node.wrap(wrapper);\n } else {\n removeOrUnwrapInvalidNode(node, schema);\n }\n }\n }\n };\n const hasClosest = (node, parentName) => {\n let tempNode = node;\n while (tempNode) {\n if (tempNode.name === parentName) {\n return true;\n }\n tempNode = tempNode.parent;\n }\n return false;\n };\n const isInvalid = (schema, node, parent = node.parent) => {\n if (!parent) {\n return false;\n }\n if (schema.children[node.name] && !schema.isValidChild(parent.name, node.name)) {\n return true;\n }\n if (node.name === 'a' && hasClosest(parent, 'a')) {\n return true;\n }\n if (isSummary(parent) && isHeading(node)) {\n return !((parent === null || parent === void 0 ? void 0 : parent.firstChild) === node && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node);\n }\n return false;\n };\n\n const createRange = (sc, so, ec, eo) => {\n const rng = document.createRange();\n rng.setStart(sc, so);\n rng.setEnd(ec, eo);\n return rng;\n };\n const normalizeBlockSelectionRange = rng => {\n const startPos = CaretPosition.fromRangeStart(rng);\n const endPos = CaretPosition.fromRangeEnd(rng);\n const rootNode = rng.commonAncestorContainer;\n return fromPosition(false, rootNode, endPos).map(newEndPos => {\n if (!isInSameBlock(startPos, endPos, rootNode) && isInSameBlock(startPos, newEndPos, rootNode)) {\n return createRange(startPos.container(), startPos.offset(), newEndPos.container(), newEndPos.offset());\n } else {\n return rng;\n }\n }).getOr(rng);\n };\n const normalize = rng => rng.collapsed ? rng : normalizeBlockSelectionRange(rng);\n\n const hasOnlyOneChild$1 = node => {\n return isNonNullable(node.firstChild) && node.firstChild === node.lastChild;\n };\n const isPaddingNode = node => {\n return node.name === 'br' || node.value === nbsp;\n };\n const isPaddedEmptyBlock = (schema, node) => {\n const blockElements = schema.getBlockElements();\n return blockElements[node.name] && hasOnlyOneChild$1(node) && isPaddingNode(node.firstChild);\n };\n const isEmptyFragmentElement = (schema, node) => {\n const nonEmptyElements = schema.getNonEmptyElements();\n return isNonNullable(node) && (node.isEmpty(nonEmptyElements) || isPaddedEmptyBlock(schema, node));\n };\n const isListFragment = (schema, fragment) => {\n let firstChild = fragment.firstChild;\n let lastChild = fragment.lastChild;\n if (firstChild && firstChild.name === 'meta') {\n firstChild = firstChild.next;\n }\n if (lastChild && lastChild.attr('id') === 'mce_marker') {\n lastChild = lastChild.prev;\n }\n if (isEmptyFragmentElement(schema, lastChild)) {\n lastChild = lastChild === null || lastChild === void 0 ? void 0 : lastChild.prev;\n }\n if (!firstChild || firstChild !== lastChild) {\n return false;\n }\n return firstChild.name === 'ul' || firstChild.name === 'ol';\n };\n const cleanupDomFragment = domFragment => {\n var _a, _b;\n const firstChild = domFragment.firstChild;\n const lastChild = domFragment.lastChild;\n if (firstChild && firstChild.nodeName === 'META') {\n (_a = firstChild.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(firstChild);\n }\n if (lastChild && lastChild.id === 'mce_marker') {\n (_b = lastChild.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(lastChild);\n }\n return domFragment;\n };\n const toDomFragment = (dom, serializer, fragment) => {\n const html = serializer.serialize(fragment);\n const domFragment = dom.createFragment(html);\n return cleanupDomFragment(domFragment);\n };\n const listItems = elm => {\n var _a;\n return filter$5((_a = elm === null || elm === void 0 ? void 0 : elm.childNodes) !== null && _a !== void 0 ? _a : [], child => {\n return child.nodeName === 'LI';\n });\n };\n const isPadding = node => {\n return node.data === nbsp || isBr$6(node);\n };\n const isListItemPadded = node => {\n return isNonNullable(node === null || node === void 0 ? void 0 : node.firstChild) && node.firstChild === node.lastChild && isPadding(node.firstChild);\n };\n const isEmptyOrPadded = elm => {\n return !elm.firstChild || isListItemPadded(elm);\n };\n const trimListItems = elms => {\n return elms.length > 0 && isEmptyOrPadded(elms[elms.length - 1]) ? elms.slice(0, -1) : elms;\n };\n const getParentLi = (dom, node) => {\n const parentBlock = dom.getParent(node, dom.isBlock);\n return parentBlock && parentBlock.nodeName === 'LI' ? parentBlock : null;\n };\n const isParentBlockLi = (dom, node) => {\n return !!getParentLi(dom, node);\n };\n const getSplit = (parentNode, rng) => {\n const beforeRng = rng.cloneRange();\n const afterRng = rng.cloneRange();\n beforeRng.setStartBefore(parentNode);\n afterRng.setEndAfter(parentNode);\n return [\n beforeRng.cloneContents(),\n afterRng.cloneContents()\n ];\n };\n const findFirstIn = (node, rootNode) => {\n const caretPos = CaretPosition.before(node);\n const caretWalker = CaretWalker(rootNode);\n const newCaretPos = caretWalker.next(caretPos);\n return newCaretPos ? newCaretPos.toRange() : null;\n };\n const findLastOf = (node, rootNode) => {\n const caretPos = CaretPosition.after(node);\n const caretWalker = CaretWalker(rootNode);\n const newCaretPos = caretWalker.prev(caretPos);\n return newCaretPos ? newCaretPos.toRange() : null;\n };\n const insertMiddle = (target, elms, rootNode, rng) => {\n const parts = getSplit(target, rng);\n const parentElm = target.parentNode;\n if (parentElm) {\n parentElm.insertBefore(parts[0], target);\n Tools.each(elms, li => {\n parentElm.insertBefore(li, target);\n });\n parentElm.insertBefore(parts[1], target);\n parentElm.removeChild(target);\n }\n return findLastOf(elms[elms.length - 1], rootNode);\n };\n const insertBefore$2 = (target, elms, rootNode) => {\n const parentElm = target.parentNode;\n if (parentElm) {\n Tools.each(elms, elm => {\n parentElm.insertBefore(elm, target);\n });\n }\n return findFirstIn(target, rootNode);\n };\n const insertAfter$2 = (target, elms, rootNode, dom) => {\n dom.insertAfter(elms.reverse(), target);\n return findLastOf(elms[0], rootNode);\n };\n const insertAtCaret$1 = (serializer, dom, rng, fragment) => {\n const domFragment = toDomFragment(dom, serializer, fragment);\n const liTarget = getParentLi(dom, rng.startContainer);\n const liElms = trimListItems(listItems(domFragment.firstChild));\n const BEGINNING = 1, END = 2;\n const rootNode = dom.getRoot();\n const isAt = location => {\n const caretPos = CaretPosition.fromRangeStart(rng);\n const caretWalker = CaretWalker(dom.getRoot());\n const newPos = location === BEGINNING ? caretWalker.prev(caretPos) : caretWalker.next(caretPos);\n const newPosNode = newPos === null || newPos === void 0 ? void 0 : newPos.getNode();\n return newPosNode ? getParentLi(dom, newPosNode) !== liTarget : true;\n };\n if (!liTarget) {\n return null;\n } else if (isAt(BEGINNING)) {\n return insertBefore$2(liTarget, liElms, rootNode);\n } else if (isAt(END)) {\n return insertAfter$2(liTarget, liElms, rootNode, dom);\n } else {\n return insertMiddle(liTarget, liElms, rootNode, rng);\n }\n };\n\n const mergeableWrappedElements = ['pre'];\n const shouldPasteContentOnly = (dom, fragment, parentNode, root) => {\n var _a;\n const firstNode = fragment.firstChild;\n const lastNode = fragment.lastChild;\n const last = lastNode.attr('data-mce-type') === 'bookmark' ? lastNode.prev : lastNode;\n const isPastingSingleElement = firstNode === last;\n const isWrappedElement = contains$2(mergeableWrappedElements, firstNode.name);\n if (isPastingSingleElement && isWrappedElement) {\n const isContentEditable = firstNode.attr('contenteditable') !== 'false';\n const isPastingInTheSameBlockTag = ((_a = dom.getParent(parentNode, dom.isBlock)) === null || _a === void 0 ? void 0 : _a.nodeName.toLowerCase()) === firstNode.name;\n const isPastingInContentEditable = Optional.from(getContentEditableRoot$1(root, parentNode)).forall(isContentEditableTrue$3);\n return isContentEditable && isPastingInTheSameBlockTag && isPastingInContentEditable;\n } else {\n return false;\n }\n };\n const isTableCell = isTableCell$3;\n const isTableCellContentSelected = (dom, rng, cell) => {\n if (isNonNullable(cell)) {\n const endCell = dom.getParent(rng.endContainer, isTableCell);\n return cell === endCell && hasAllContentsSelected(SugarElement.fromDom(cell), rng);\n } else {\n return false;\n }\n };\n const validInsertion = (editor, value, parentNode) => {\n var _a;\n if (parentNode.getAttribute('data-mce-bogus') === 'all') {\n (_a = parentNode.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(editor.dom.createFragment(value), parentNode);\n } else {\n const node = parentNode.firstChild;\n const node2 = parentNode.lastChild;\n if (!node || node === node2 && node.nodeName === 'BR') {\n editor.dom.setHTML(parentNode, value);\n } else {\n editor.selection.setContent(value, { no_events: true });\n }\n }\n };\n const trimBrsFromTableCell = (dom, elm, schema) => {\n Optional.from(dom.getParent(elm, 'td,th')).map(SugarElement.fromDom).each(el => trimBlockTrailingBr(el, schema));\n };\n const reduceInlineTextElements = (editor, merge) => {\n const textInlineElements = editor.schema.getTextInlineElements();\n const dom = editor.dom;\n if (merge) {\n const root = editor.getBody();\n const elementUtils = ElementUtils(editor);\n Tools.each(dom.select('*[data-mce-fragment]'), node => {\n const isInline = isNonNullable(textInlineElements[node.nodeName.toLowerCase()]);\n if (isInline && hasInheritableStyles(dom, node)) {\n for (let parentNode = node.parentElement; isNonNullable(parentNode) && parentNode !== root; parentNode = parentNode.parentElement) {\n const styleConflict = hasStyleConflict(dom, node, parentNode);\n if (styleConflict) {\n break;\n }\n if (elementUtils.compare(parentNode, node)) {\n dom.remove(node, true);\n break;\n }\n }\n }\n });\n }\n };\n const markFragmentElements = fragment => {\n let node = fragment;\n while (node = node.walk()) {\n if (node.type === 1) {\n node.attr('data-mce-fragment', '1');\n }\n }\n };\n const unmarkFragmentElements = elm => {\n Tools.each(elm.getElementsByTagName('*'), elm => {\n elm.removeAttribute('data-mce-fragment');\n });\n };\n const isPartOfFragment = node => {\n return !!node.getAttribute('data-mce-fragment');\n };\n const canHaveChildren = (editor, node) => {\n return isNonNullable(node) && !editor.schema.getVoidElements()[node.nodeName];\n };\n const moveSelectionToMarker = (editor, marker) => {\n var _a, _b, _c;\n let nextRng;\n const dom = editor.dom;\n const selection = editor.selection;\n if (!marker) {\n return;\n }\n selection.scrollIntoView(marker);\n const parentEditableElm = getContentEditableRoot$1(editor.getBody(), marker);\n if (parentEditableElm && dom.getContentEditable(parentEditableElm) === 'false') {\n dom.remove(marker);\n selection.select(parentEditableElm);\n return;\n }\n let rng = dom.createRng();\n const node = marker.previousSibling;\n if (isText$a(node)) {\n rng.setStart(node, (_b = (_a = node.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0);\n const node2 = marker.nextSibling;\n if (isText$a(node2)) {\n node.appendData(node2.data);\n (_c = node2.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(node2);\n }\n } else {\n rng.setStartBefore(marker);\n rng.setEndBefore(marker);\n }\n const findNextCaretRng = rng => {\n let caretPos = CaretPosition.fromRangeStart(rng);\n const caretWalker = CaretWalker(editor.getBody());\n caretPos = caretWalker.next(caretPos);\n return caretPos === null || caretPos === void 0 ? void 0 : caretPos.toRange();\n };\n const parentBlock = dom.getParent(marker, dom.isBlock);\n dom.remove(marker);\n if (parentBlock && dom.isEmpty(parentBlock)) {\n const isCell = isTableCell(parentBlock);\n empty(SugarElement.fromDom(parentBlock));\n rng.setStart(parentBlock, 0);\n rng.setEnd(parentBlock, 0);\n if (!isCell && !isPartOfFragment(parentBlock) && (nextRng = findNextCaretRng(rng))) {\n rng = nextRng;\n dom.remove(parentBlock);\n } else {\n dom.add(parentBlock, dom.create('br', isCell ? {} : { 'data-mce-bogus': '1' }));\n }\n }\n selection.setRng(rng);\n };\n const deleteSelectedContent = editor => {\n const dom = editor.dom;\n const rng = normalize(editor.selection.getRng());\n editor.selection.setRng(rng);\n const startCell = dom.getParent(rng.startContainer, isTableCell);\n if (isTableCellContentSelected(dom, rng, startCell)) {\n deleteCellContents(editor, rng, SugarElement.fromDom(startCell));\n } else if (rng.startContainer === rng.endContainer && rng.endOffset - rng.startOffset === 1 && isText$a(rng.startContainer.childNodes[rng.startOffset])) {\n rng.deleteContents();\n } else {\n editor.getDoc().execCommand('Delete', false);\n }\n };\n const findMarkerNode = scope => {\n for (let markerNode = scope; markerNode; markerNode = markerNode.walk()) {\n if (markerNode.attr('id') === 'mce_marker') {\n return Optional.some(markerNode);\n }\n }\n return Optional.none();\n };\n const notHeadingsInSummary = (dom, node, fragment) => {\n var _a;\n return exists(fragment.children(), isHeading) && ((_a = dom.getParent(node, dom.isBlock)) === null || _a === void 0 ? void 0 : _a.nodeName) === 'SUMMARY';\n };\n const insertHtmlAtCaret = (editor, value, details) => {\n var _a, _b;\n const selection = editor.selection;\n const dom = editor.dom;\n const parser = editor.parser;\n const merge = details.merge;\n const serializer = HtmlSerializer({ validate: true }, editor.schema);\n const bookmarkHtml = '';\n if (!details.preserve_zwsp) {\n value = trim$2(value);\n }\n if (value.indexOf('{$caret}') === -1) {\n value += '{$caret}';\n }\n value = value.replace(/\\{\\$caret\\}/, bookmarkHtml);\n let rng = selection.getRng();\n const caretElement = rng.startContainer;\n const body = editor.getBody();\n if (caretElement === body && selection.isCollapsed()) {\n if (dom.isBlock(body.firstChild) && canHaveChildren(editor, body.firstChild) && dom.isEmpty(body.firstChild)) {\n rng = dom.createRng();\n rng.setStart(body.firstChild, 0);\n rng.setEnd(body.firstChild, 0);\n selection.setRng(rng);\n }\n }\n if (!selection.isCollapsed()) {\n deleteSelectedContent(editor);\n }\n const parentNode = selection.getNode();\n const parserArgs = {\n context: parentNode.nodeName.toLowerCase(),\n data: details.data,\n insert: true\n };\n const fragment = parser.parse(value, parserArgs);\n if (details.paste === true && isListFragment(editor.schema, fragment) && isParentBlockLi(dom, parentNode)) {\n rng = insertAtCaret$1(serializer, dom, selection.getRng(), fragment);\n if (rng) {\n selection.setRng(rng);\n }\n return value;\n }\n if (details.paste === true && shouldPasteContentOnly(dom, fragment, parentNode, editor.getBody())) {\n (_a = fragment.firstChild) === null || _a === void 0 ? void 0 : _a.unwrap();\n }\n markFragmentElements(fragment);\n let node = fragment.lastChild;\n if (node && node.attr('id') === 'mce_marker') {\n const marker = node;\n for (node = node.prev; node; node = node.walk(true)) {\n if (node.type === 3 || !dom.isBlock(node.name)) {\n if (node.parent && editor.schema.isValidChild(node.parent.name, 'span')) {\n node.parent.insert(marker, node, node.name === 'br');\n }\n break;\n }\n }\n }\n editor._selectionOverrides.showBlockCaretContainer(parentNode);\n if (!parserArgs.invalid && !notHeadingsInSummary(dom, parentNode, fragment)) {\n value = serializer.serialize(fragment);\n validInsertion(editor, value, parentNode);\n } else {\n editor.selection.setContent(bookmarkHtml);\n let parentNode = selection.getNode();\n let tempNode;\n const rootNode = editor.getBody();\n if (isDocument$1(parentNode)) {\n parentNode = tempNode = rootNode;\n } else {\n tempNode = parentNode;\n }\n while (tempNode && tempNode !== rootNode) {\n parentNode = tempNode;\n tempNode = tempNode.parentNode;\n }\n value = parentNode === rootNode ? rootNode.innerHTML : dom.getOuterHTML(parentNode);\n const root = parser.parse(value);\n const markerNode = findMarkerNode(root);\n const editingHost = markerNode.bind(findClosestEditingHost).getOr(root);\n markerNode.each(marker => marker.replace(fragment));\n const toExtract = fragment.children();\n const parent = (_b = fragment.parent) !== null && _b !== void 0 ? _b : root;\n fragment.unwrap();\n const invalidChildren = filter$5(toExtract, node => isInvalid(editor.schema, node, parent));\n cleanInvalidNodes(invalidChildren, editor.schema, editingHost);\n filter$2(parser.getNodeFilters(), parser.getAttributeFilters(), root);\n value = serializer.serialize(root);\n if (parentNode === rootNode) {\n dom.setHTML(rootNode, value);\n } else {\n dom.setOuterHTML(parentNode, value);\n }\n }\n reduceInlineTextElements(editor, merge);\n moveSelectionToMarker(editor, dom.get('mce_marker'));\n unmarkFragmentElements(editor.getBody());\n trimBrsFromTableCell(dom, selection.getStart(), editor.schema);\n updateCaret(editor.schema, editor.getBody(), selection.getStart());\n return value;\n };\n\n const isTreeNode = content => content instanceof AstNode;\n\n const moveSelection = editor => {\n if (hasFocus(editor)) {\n firstPositionIn(editor.getBody()).each(pos => {\n const node = pos.getNode();\n const caretPos = isTable$2(node) ? firstPositionIn(node).getOr(pos) : pos;\n editor.selection.setRng(caretPos.toRange());\n });\n }\n };\n const setEditorHtml = (editor, html, noSelection) => {\n editor.dom.setHTML(editor.getBody(), html);\n if (noSelection !== true) {\n moveSelection(editor);\n }\n };\n const setContentString = (editor, body, content, args) => {\n content = trim$2(content);\n if (content.length === 0 || /^\\s+$/.test(content)) {\n const padd = '
';\n if (body.nodeName === 'TABLE') {\n content = '' + padd + '';\n } else if (/^(UL|OL)$/.test(body.nodeName)) {\n content = '
  • ' + padd + '
  • ';\n }\n const forcedRootBlockName = getForcedRootBlock(editor);\n if (editor.schema.isValidChild(body.nodeName.toLowerCase(), forcedRootBlockName.toLowerCase())) {\n content = padd;\n content = editor.dom.createHTML(forcedRootBlockName, getForcedRootBlockAttrs(editor), content);\n } else if (!content) {\n content = padd;\n }\n setEditorHtml(editor, content, args.no_selection);\n return {\n content,\n html: content\n };\n } else {\n if (args.format !== 'raw') {\n content = HtmlSerializer({ validate: false }, editor.schema).serialize(editor.parser.parse(content, {\n isRootContent: true,\n insert: true\n }));\n }\n const trimmedHtml = isWsPreserveElement(SugarElement.fromDom(body)) ? content : Tools.trim(content);\n setEditorHtml(editor, trimmedHtml, args.no_selection);\n return {\n content: trimmedHtml,\n html: trimmedHtml\n };\n }\n };\n const setContentTree = (editor, body, content, args) => {\n filter$2(editor.parser.getNodeFilters(), editor.parser.getAttributeFilters(), content);\n const html = HtmlSerializer({ validate: false }, editor.schema).serialize(content);\n const trimmedHtml = trim$2(isWsPreserveElement(SugarElement.fromDom(body)) ? html : Tools.trim(html));\n setEditorHtml(editor, trimmedHtml, args.no_selection);\n return {\n content,\n html: trimmedHtml\n };\n };\n const setContentInternal = (editor, content, args) => {\n return Optional.from(editor.getBody()).map(body => {\n if (isTreeNode(content)) {\n return setContentTree(editor, body, content, args);\n } else {\n return setContentString(editor, body, content, args);\n }\n }).getOr({\n content,\n html: isTreeNode(args.content) ? '' : args.content\n });\n };\n\n const ensureIsRoot = isRoot => isFunction(isRoot) ? isRoot : never;\n const ancestor = (scope, transform, isRoot) => {\n let element = scope.dom;\n const stop = ensureIsRoot(isRoot);\n while (element.parentNode) {\n element = element.parentNode;\n const el = SugarElement.fromDom(element);\n const transformed = transform(el);\n if (transformed.isSome()) {\n return transformed;\n } else if (stop(el)) {\n break;\n }\n }\n return Optional.none();\n };\n const closest$1 = (scope, transform, isRoot) => {\n const current = transform(scope);\n const stop = ensureIsRoot(isRoot);\n return current.orThunk(() => stop(scope) ? Optional.none() : ancestor(scope, transform, stop));\n };\n\n const isEq$3 = isEq$5;\n const matchesUnInheritedFormatSelector = (ed, node, name) => {\n const formatList = ed.formatter.get(name);\n if (formatList) {\n for (let i = 0; i < formatList.length; i++) {\n const format = formatList[i];\n if (isSelectorFormat(format) && format.inherit === false && ed.dom.is(node, format.selector)) {\n return true;\n }\n }\n }\n return false;\n };\n const matchParents = (editor, node, name, vars, similar) => {\n const root = editor.dom.getRoot();\n if (node === root) {\n return false;\n }\n const matchedNode = editor.dom.getParent(node, elm => {\n if (matchesUnInheritedFormatSelector(editor, elm, name)) {\n return true;\n }\n return elm.parentNode === root || !!matchNode(editor, elm, name, vars, true);\n });\n return !!matchNode(editor, matchedNode, name, vars, similar);\n };\n const matchName = (dom, node, format) => {\n if (isInlineFormat(format) && isEq$3(node, format.inline)) {\n return true;\n }\n if (isBlockFormat(format) && isEq$3(node, format.block)) {\n return true;\n }\n if (isSelectorFormat(format)) {\n return isElement$6(node) && dom.is(node, format.selector);\n }\n return false;\n };\n const matchItems = (dom, node, format, itemName, similar, vars) => {\n const items = format[itemName];\n const matchAttributes = itemName === 'attributes';\n if (isFunction(format.onmatch)) {\n return format.onmatch(node, format, itemName);\n }\n if (items) {\n if (!isArrayLike(items)) {\n for (const key in items) {\n if (has$2(items, key)) {\n const value = matchAttributes ? dom.getAttrib(node, key) : getStyle(dom, node, key);\n const expectedValue = replaceVars(items[key], vars);\n const isEmptyValue = isNullable(value) || isEmpty$3(value);\n if (isEmptyValue && isNullable(expectedValue)) {\n continue;\n }\n if (similar && isEmptyValue && !format.exact) {\n return false;\n }\n if ((!similar || format.exact) && !isEq$3(value, normalizeStyleValue(expectedValue, key))) {\n return false;\n }\n }\n }\n } else {\n for (let i = 0; i < items.length; i++) {\n if (matchAttributes ? dom.getAttrib(node, items[i]) : getStyle(dom, node, items[i])) {\n return true;\n }\n }\n }\n }\n return true;\n };\n const matchNode = (ed, node, name, vars, similar) => {\n const formatList = ed.formatter.get(name);\n const dom = ed.dom;\n if (formatList && isElement$6(node)) {\n for (let i = 0; i < formatList.length; i++) {\n const format = formatList[i];\n if (matchName(ed.dom, node, format) && matchItems(dom, node, format, 'attributes', similar, vars) && matchItems(dom, node, format, 'styles', similar, vars)) {\n const classes = format.classes;\n if (classes) {\n for (let x = 0; x < classes.length; x++) {\n if (!ed.dom.hasClass(node, replaceVars(classes[x], vars))) {\n return;\n }\n }\n }\n return format;\n }\n }\n }\n return undefined;\n };\n const match$2 = (editor, name, vars, node, similar) => {\n if (node) {\n return matchParents(editor, node, name, vars, similar);\n }\n node = editor.selection.getNode();\n if (matchParents(editor, node, name, vars, similar)) {\n return true;\n }\n const startNode = editor.selection.getStart();\n if (startNode !== node) {\n if (matchParents(editor, startNode, name, vars, similar)) {\n return true;\n }\n }\n return false;\n };\n const matchAll = (editor, names, vars) => {\n const matchedFormatNames = [];\n const checkedMap = {};\n const startElement = editor.selection.getStart();\n editor.dom.getParent(startElement, node => {\n for (let i = 0; i < names.length; i++) {\n const name = names[i];\n if (!checkedMap[name] && matchNode(editor, node, name, vars)) {\n checkedMap[name] = true;\n matchedFormatNames.push(name);\n }\n }\n }, editor.dom.getRoot());\n return matchedFormatNames;\n };\n const closest = (editor, names) => {\n const isRoot = elm => eq(elm, SugarElement.fromDom(editor.getBody()));\n const match = (elm, name) => matchNode(editor, elm.dom, name) ? Optional.some(name) : Optional.none();\n return Optional.from(editor.selection.getStart(true)).bind(rawElm => closest$1(SugarElement.fromDom(rawElm), elm => findMap(names, name => match(elm, name)), isRoot)).getOrNull();\n };\n const canApply = (editor, name) => {\n const formatList = editor.formatter.get(name);\n const dom = editor.dom;\n if (formatList && editor.selection.isEditable()) {\n const startNode = editor.selection.getStart();\n const parents = getParents$2(dom, startNode);\n for (let x = formatList.length - 1; x >= 0; x--) {\n const format = formatList[x];\n if (!isSelectorFormat(format)) {\n return true;\n }\n for (let i = parents.length - 1; i >= 0; i--) {\n if (dom.is(parents[i], format.selector)) {\n return true;\n }\n }\n }\n }\n return false;\n };\n const matchAllOnNode = (editor, node, formatNames) => foldl(formatNames, (acc, name) => {\n const matchSimilar = isVariableFormatName(editor, name);\n if (editor.formatter.matchNode(node, name, {}, matchSimilar)) {\n return acc.concat([name]);\n } else {\n return acc;\n }\n }, []);\n\n const ZWSP = ZWSP$1;\n const importNode = (ownerDocument, node) => {\n return ownerDocument.importNode(node, true);\n };\n const findFirstTextNode = node => {\n if (node) {\n const walker = new DomTreeWalker(node, node);\n for (let tempNode = walker.current(); tempNode; tempNode = walker.next()) {\n if (isText$a(tempNode)) {\n return tempNode;\n }\n }\n }\n return null;\n };\n const createCaretContainer = fill => {\n const caretContainer = SugarElement.fromTag('span');\n setAll$1(caretContainer, {\n 'id': CARET_ID,\n 'data-mce-bogus': '1',\n 'data-mce-type': 'format-caret'\n });\n if (fill) {\n append$1(caretContainer, SugarElement.fromText(ZWSP));\n }\n return caretContainer;\n };\n const trimZwspFromCaretContainer = caretContainerNode => {\n const textNode = findFirstTextNode(caretContainerNode);\n if (textNode && textNode.data.charAt(0) === ZWSP) {\n textNode.deleteData(0, 1);\n }\n return textNode;\n };\n const removeCaretContainerNode = (editor, node, moveCaret) => {\n const dom = editor.dom, selection = editor.selection;\n if (isCaretContainerEmpty(node)) {\n deleteElement$2(editor, false, SugarElement.fromDom(node), moveCaret, true);\n } else {\n const rng = selection.getRng();\n const block = dom.getParent(node, dom.isBlock);\n const startContainer = rng.startContainer;\n const startOffset = rng.startOffset;\n const endContainer = rng.endContainer;\n const endOffset = rng.endOffset;\n const textNode = trimZwspFromCaretContainer(node);\n dom.remove(node, true);\n if (startContainer === textNode && startOffset > 0) {\n rng.setStart(textNode, startOffset - 1);\n }\n if (endContainer === textNode && endOffset > 0) {\n rng.setEnd(textNode, endOffset - 1);\n }\n if (block && dom.isEmpty(block)) {\n fillWithPaddingBr(SugarElement.fromDom(block));\n }\n selection.setRng(rng);\n }\n };\n const removeCaretContainer = (editor, node, moveCaret) => {\n const dom = editor.dom, selection = editor.selection;\n if (!node) {\n node = getParentCaretContainer(editor.getBody(), selection.getStart());\n if (!node) {\n while (node = dom.get(CARET_ID)) {\n removeCaretContainerNode(editor, node, moveCaret);\n }\n }\n } else {\n removeCaretContainerNode(editor, node, moveCaret);\n }\n };\n const insertCaretContainerNode = (editor, caretContainer, formatNode) => {\n var _a, _b;\n const dom = editor.dom;\n const block = dom.getParent(formatNode, curry(isTextBlock$1, editor.schema));\n if (block && dom.isEmpty(block)) {\n (_a = formatNode.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(caretContainer, formatNode);\n } else {\n removeTrailingBr(SugarElement.fromDom(formatNode));\n if (dom.isEmpty(formatNode)) {\n (_b = formatNode.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(caretContainer, formatNode);\n } else {\n dom.insertAfter(caretContainer, formatNode);\n }\n }\n };\n const appendNode = (parentNode, node) => {\n parentNode.appendChild(node);\n return node;\n };\n const insertFormatNodesIntoCaretContainer = (formatNodes, caretContainer) => {\n var _a;\n const innerMostFormatNode = foldr(formatNodes, (parentNode, formatNode) => {\n return appendNode(parentNode, formatNode.cloneNode(false));\n }, caretContainer);\n const doc = (_a = innerMostFormatNode.ownerDocument) !== null && _a !== void 0 ? _a : document;\n return appendNode(innerMostFormatNode, doc.createTextNode(ZWSP));\n };\n const cleanFormatNode = (editor, caretContainer, formatNode, name, vars, similar) => {\n const formatter = editor.formatter;\n const dom = editor.dom;\n const validFormats = filter$5(keys(formatter.get()), formatName => formatName !== name && !contains$1(formatName, 'removeformat'));\n const matchedFormats = matchAllOnNode(editor, formatNode, validFormats);\n const uniqueFormats = filter$5(matchedFormats, fmtName => !areSimilarFormats(editor, fmtName, name));\n if (uniqueFormats.length > 0) {\n const clonedFormatNode = formatNode.cloneNode(false);\n dom.add(caretContainer, clonedFormatNode);\n formatter.remove(name, vars, clonedFormatNode, similar);\n dom.remove(clonedFormatNode);\n return Optional.some(clonedFormatNode);\n } else {\n return Optional.none();\n }\n };\n const applyCaretFormat = (editor, name, vars) => {\n let caretContainer;\n const selection = editor.selection;\n const formatList = editor.formatter.get(name);\n if (!formatList) {\n return;\n }\n const selectionRng = selection.getRng();\n let offset = selectionRng.startOffset;\n const container = selectionRng.startContainer;\n const text = container.nodeValue;\n caretContainer = getParentCaretContainer(editor.getBody(), selection.getStart());\n const wordcharRegex = /[^\\s\\u00a0\\u00ad\\u200b\\ufeff]/;\n if (text && offset > 0 && offset < text.length && wordcharRegex.test(text.charAt(offset)) && wordcharRegex.test(text.charAt(offset - 1))) {\n const bookmark = selection.getBookmark();\n selectionRng.collapse(true);\n let rng = expandRng(editor.dom, selectionRng, formatList);\n rng = split(rng);\n editor.formatter.apply(name, vars, rng);\n selection.moveToBookmark(bookmark);\n } else {\n let textNode = caretContainer ? findFirstTextNode(caretContainer) : null;\n if (!caretContainer || (textNode === null || textNode === void 0 ? void 0 : textNode.data) !== ZWSP) {\n caretContainer = importNode(editor.getDoc(), createCaretContainer(true).dom);\n textNode = caretContainer.firstChild;\n selectionRng.insertNode(caretContainer);\n offset = 1;\n editor.formatter.apply(name, vars, caretContainer);\n } else {\n editor.formatter.apply(name, vars, caretContainer);\n }\n selection.setCursorLocation(textNode, offset);\n }\n };\n const removeCaretFormat = (editor, name, vars, similar) => {\n const dom = editor.dom;\n const selection = editor.selection;\n let hasContentAfter = false;\n const formatList = editor.formatter.get(name);\n if (!formatList) {\n return;\n }\n const rng = selection.getRng();\n const container = rng.startContainer;\n const offset = rng.startOffset;\n let node = container;\n if (isText$a(container)) {\n if (offset !== container.data.length) {\n hasContentAfter = true;\n }\n node = node.parentNode;\n }\n const parents = [];\n let formatNode;\n while (node) {\n if (matchNode(editor, node, name, vars, similar)) {\n formatNode = node;\n break;\n }\n if (node.nextSibling) {\n hasContentAfter = true;\n }\n parents.push(node);\n node = node.parentNode;\n }\n if (!formatNode) {\n return;\n }\n if (hasContentAfter) {\n const bookmark = selection.getBookmark();\n rng.collapse(true);\n let expandedRng = expandRng(dom, rng, formatList, true);\n expandedRng = split(expandedRng);\n editor.formatter.remove(name, vars, expandedRng, similar);\n selection.moveToBookmark(bookmark);\n } else {\n const caretContainer = getParentCaretContainer(editor.getBody(), formatNode);\n const parentsAfter = isNonNullable(caretContainer) ? dom.getParents(formatNode.parentNode, always, caretContainer) : [];\n const newCaretContainer = createCaretContainer(false).dom;\n insertCaretContainerNode(editor, newCaretContainer, caretContainer !== null && caretContainer !== void 0 ? caretContainer : formatNode);\n const cleanedFormatNode = cleanFormatNode(editor, newCaretContainer, formatNode, name, vars, similar);\n const caretTextNode = insertFormatNodesIntoCaretContainer([\n ...parents,\n ...cleanedFormatNode.toArray(),\n ...parentsAfter\n ], newCaretContainer);\n if (caretContainer) {\n removeCaretContainerNode(editor, caretContainer, isNonNullable(caretContainer));\n }\n selection.setCursorLocation(caretTextNode, 1);\n if (dom.isEmpty(formatNode)) {\n dom.remove(formatNode);\n }\n }\n };\n const disableCaretContainer = (editor, keyCode, moveCaret) => {\n const selection = editor.selection, body = editor.getBody();\n removeCaretContainer(editor, null, moveCaret);\n if ((keyCode === 8 || keyCode === 46) && selection.isCollapsed() && selection.getStart().innerHTML === ZWSP) {\n removeCaretContainer(editor, getParentCaretContainer(body, selection.getStart()), true);\n }\n if (keyCode === 37 || keyCode === 39) {\n removeCaretContainer(editor, getParentCaretContainer(body, selection.getStart()), true);\n }\n };\n const endsWithNbsp = element => isText$a(element) && endsWith(element.data, nbsp);\n const setup$v = editor => {\n editor.on('mouseup keydown', e => {\n disableCaretContainer(editor, e.keyCode, endsWithNbsp(editor.selection.getRng().endContainer));\n });\n };\n const createCaretFormat = formatNodes => {\n const caretContainer = createCaretContainer(false);\n const innerMost = insertFormatNodesIntoCaretContainer(formatNodes, caretContainer.dom);\n return {\n caretContainer,\n caretPosition: CaretPosition(innerMost, 0)\n };\n };\n const replaceWithCaretFormat = (targetNode, formatNodes) => {\n const {caretContainer, caretPosition} = createCaretFormat(formatNodes);\n before$3(SugarElement.fromDom(targetNode), caretContainer);\n remove$5(SugarElement.fromDom(targetNode));\n return caretPosition;\n };\n const createCaretFormatAtStart$1 = (rng, formatNodes) => {\n const {caretContainer, caretPosition} = createCaretFormat(formatNodes);\n rng.insertNode(caretContainer.dom);\n return caretPosition;\n };\n const isFormatElement = (editor, element) => {\n if (isCaretNode(element.dom)) {\n return false;\n }\n const inlineElements = editor.schema.getTextInlineElements();\n return has$2(inlineElements, name(element)) && !isCaretNode(element.dom) && !isBogus$2(element.dom);\n };\n\n const postProcessHooks = {};\n const isPre = matchNodeNames(['pre']);\n const addPostProcessHook = (name, hook) => {\n const hooks = postProcessHooks[name];\n if (!hooks) {\n postProcessHooks[name] = [];\n }\n postProcessHooks[name].push(hook);\n };\n const postProcess$1 = (name, editor) => {\n if (has$2(postProcessHooks, name)) {\n each$e(postProcessHooks[name], hook => {\n hook(editor);\n });\n }\n };\n addPostProcessHook('pre', editor => {\n const rng = editor.selection.getRng();\n const hasPreSibling = blocks => pre => {\n const prev = pre.previousSibling;\n return isPre(prev) && contains$2(blocks, prev);\n };\n const joinPre = (pre1, pre2) => {\n const sPre2 = SugarElement.fromDom(pre2);\n const doc = documentOrOwner(sPre2).dom;\n remove$5(sPre2);\n append(SugarElement.fromDom(pre1), [\n SugarElement.fromTag('br', doc),\n SugarElement.fromTag('br', doc),\n ...children$1(sPre2)\n ]);\n };\n if (!rng.collapsed) {\n const blocks = editor.selection.getSelectedBlocks();\n const preBlocks = filter$5(filter$5(blocks, isPre), hasPreSibling(blocks));\n each$e(preBlocks, pre => {\n joinPre(pre.previousSibling, pre);\n });\n }\n });\n\n const listItemStyles = [\n 'fontWeight',\n 'fontStyle',\n 'color',\n 'fontSize',\n 'fontFamily'\n ];\n const hasListStyles = fmt => isObject(fmt.styles) && exists(keys(fmt.styles), name => contains$2(listItemStyles, name));\n const findExpandedListItemFormat = formats => find$2(formats, fmt => isInlineFormat(fmt) && fmt.inline === 'span' && hasListStyles(fmt));\n const getExpandedListItemFormat = (formatter, format) => {\n const formatList = formatter.get(format);\n return isArray$1(formatList) ? findExpandedListItemFormat(formatList) : Optional.none();\n };\n const isRngStartAtStartOfElement = (rng, elm) => prevPosition(elm, CaretPosition.fromRangeStart(rng)).isNone();\n const isRngEndAtEndOfElement = (rng, elm) => {\n return nextPosition(elm, CaretPosition.fromRangeEnd(rng)).exists(pos => !isBr$6(pos.getNode()) || nextPosition(elm, pos).isSome()) === false;\n };\n const isEditableListItem = dom => elm => isListItem$2(elm) && dom.isEditable(elm);\n const getFullySelectedBlocks = selection => {\n const blocks = selection.getSelectedBlocks();\n const rng = selection.getRng();\n if (selection.isCollapsed()) {\n return [];\n }\n if (blocks.length === 1) {\n return isRngStartAtStartOfElement(rng, blocks[0]) && isRngEndAtEndOfElement(rng, blocks[0]) ? blocks : [];\n } else {\n const first = head(blocks).filter(elm => isRngStartAtStartOfElement(rng, elm)).toArray();\n const last = last$3(blocks).filter(elm => isRngEndAtEndOfElement(rng, elm)).toArray();\n const middle = blocks.slice(1, -1);\n return first.concat(middle).concat(last);\n }\n };\n const getFullySelectedListItems = selection => filter$5(getFullySelectedBlocks(selection), isEditableListItem(selection.dom));\n const getPartiallySelectedListItems = selection => filter$5(selection.getSelectedBlocks(), isEditableListItem(selection.dom));\n\n const each$8 = Tools.each;\n const isElementNode = node => isElement$6(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$2(node);\n const findElementSibling = (node, siblingName) => {\n for (let sibling = node; sibling; sibling = sibling[siblingName]) {\n if (isText$a(sibling) && isNotEmpty(sibling.data)) {\n return node;\n }\n if (isElement$6(sibling) && !isBookmarkNode$1(sibling)) {\n return sibling;\n }\n }\n return node;\n };\n const mergeSiblingsNodes = (editor, prev, next) => {\n const elementUtils = ElementUtils(editor);\n const isPrevEditable = isHTMLElement(prev) && editor.dom.isEditable(prev);\n const isNextEditable = isHTMLElement(next) && editor.dom.isEditable(next);\n if (isPrevEditable && isNextEditable) {\n const prevSibling = findElementSibling(prev, 'previousSibling');\n const nextSibling = findElementSibling(next, 'nextSibling');\n if (elementUtils.compare(prevSibling, nextSibling)) {\n for (let sibling = prevSibling.nextSibling; sibling && sibling !== nextSibling;) {\n const tmpSibling = sibling;\n sibling = sibling.nextSibling;\n prevSibling.appendChild(tmpSibling);\n }\n editor.dom.remove(nextSibling);\n Tools.each(Tools.grep(nextSibling.childNodes), node => {\n prevSibling.appendChild(node);\n });\n return prevSibling;\n }\n }\n return next;\n };\n const mergeSiblings = (editor, format, vars, node) => {\n var _a;\n if (node && format.merge_siblings !== false) {\n const newNode = (_a = mergeSiblingsNodes(editor, getNonWhiteSpaceSibling(node), node)) !== null && _a !== void 0 ? _a : node;\n mergeSiblingsNodes(editor, newNode, getNonWhiteSpaceSibling(newNode, true));\n }\n };\n const clearChildStyles = (dom, format, node) => {\n if (format.clear_child_styles) {\n const selector = format.links ? '*:not(a)' : '*';\n each$8(dom.select(selector, node), childNode => {\n if (isElementNode(childNode) && dom.isEditable(childNode)) {\n each$8(format.styles, (_value, name) => {\n dom.setStyle(childNode, name, '');\n });\n }\n });\n }\n };\n const processChildElements = (node, filter, process) => {\n each$8(node.childNodes, node => {\n if (isElementNode(node)) {\n if (filter(node)) {\n process(node);\n }\n if (node.hasChildNodes()) {\n processChildElements(node, filter, process);\n }\n }\n });\n };\n const unwrapEmptySpan = (dom, node) => {\n if (node.nodeName === 'SPAN' && dom.getAttribs(node).length === 0) {\n dom.remove(node, true);\n }\n };\n const hasStyle = (dom, name) => node => !!(node && getStyle(dom, node, name));\n const applyStyle = (dom, name, value) => node => {\n dom.setStyle(node, name, value);\n if (node.getAttribute('style') === '') {\n node.removeAttribute('style');\n }\n unwrapEmptySpan(dom, node);\n };\n\n const removeResult = Adt.generate([\n { keep: [] },\n { rename: ['name'] },\n { removed: [] }\n ]);\n const MCE_ATTR_RE = /^(src|href|style)$/;\n const each$7 = Tools.each;\n const isEq$2 = isEq$5;\n const isTableCellOrRow = node => /^(TR|TH|TD)$/.test(node.nodeName);\n const isChildOfInlineParent = (dom, node, parent) => dom.isChildOf(node, parent) && node !== parent && !dom.isBlock(parent);\n const getContainer = (ed, rng, start) => {\n let container = rng[start ? 'startContainer' : 'endContainer'];\n let offset = rng[start ? 'startOffset' : 'endOffset'];\n if (isElement$6(container)) {\n const lastIdx = container.childNodes.length - 1;\n if (!start && offset) {\n offset--;\n }\n container = container.childNodes[offset > lastIdx ? lastIdx : offset];\n }\n if (isText$a(container) && start && offset >= container.data.length) {\n container = new DomTreeWalker(container, ed.getBody()).next() || container;\n }\n if (isText$a(container) && !start && offset === 0) {\n container = new DomTreeWalker(container, ed.getBody()).prev() || container;\n }\n return container;\n };\n const normalizeTableSelection = (node, start) => {\n const prop = start ? 'firstChild' : 'lastChild';\n const childNode = node[prop];\n if (isTableCellOrRow(node) && childNode) {\n if (node.nodeName === 'TR') {\n return childNode[prop] || childNode;\n } else {\n return childNode;\n }\n }\n return node;\n };\n const wrap$1 = (dom, node, name, attrs) => {\n var _a;\n const wrapper = dom.create(name, attrs);\n (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(wrapper, node);\n wrapper.appendChild(node);\n return wrapper;\n };\n const wrapWithSiblings = (dom, node, next, name, attrs) => {\n const start = SugarElement.fromDom(node);\n const wrapper = SugarElement.fromDom(dom.create(name, attrs));\n const siblings = next ? nextSiblings(start) : prevSiblings(start);\n append(wrapper, siblings);\n if (next) {\n before$3(start, wrapper);\n prepend(wrapper, start);\n } else {\n after$4(start, wrapper);\n append$1(wrapper, start);\n }\n return wrapper.dom;\n };\n const isColorFormatAndAnchor = (node, format) => format.links && node.nodeName === 'A';\n const removeNode = (ed, node, format) => {\n const parentNode = node.parentNode;\n let rootBlockElm;\n const dom = ed.dom;\n const forcedRootBlock = getForcedRootBlock(ed);\n if (isBlockFormat(format)) {\n if (parentNode === dom.getRoot()) {\n if (!format.list_block || !isEq$2(node, format.list_block)) {\n each$e(from(node.childNodes), node => {\n if (isValid(ed, forcedRootBlock, node.nodeName.toLowerCase())) {\n if (!rootBlockElm) {\n rootBlockElm = wrap$1(dom, node, forcedRootBlock);\n dom.setAttribs(rootBlockElm, getForcedRootBlockAttrs(ed));\n } else {\n rootBlockElm.appendChild(node);\n }\n } else {\n rootBlockElm = null;\n }\n });\n }\n }\n }\n if (isMixedFormat(format) && !isEq$2(format.inline, node)) {\n return;\n }\n dom.remove(node, true);\n };\n const processFormatAttrOrStyle = (name, value, vars) => {\n if (isNumber(name)) {\n return {\n name: value,\n value: null\n };\n } else {\n return {\n name,\n value: replaceVars(value, vars)\n };\n }\n };\n const removeEmptyStyleAttributeIfNeeded = (dom, elm) => {\n if (dom.getAttrib(elm, 'style') === '') {\n elm.removeAttribute('style');\n elm.removeAttribute('data-mce-style');\n }\n };\n const removeStyles = (dom, elm, format, vars, compareNode) => {\n let stylesModified = false;\n each$7(format.styles, (value, name) => {\n const {\n name: styleName,\n value: styleValue\n } = processFormatAttrOrStyle(name, value, vars);\n const normalizedStyleValue = normalizeStyleValue(styleValue, styleName);\n if (format.remove_similar || isNull(styleValue) || !isElement$6(compareNode) || isEq$2(getStyle(dom, compareNode, styleName), normalizedStyleValue)) {\n dom.setStyle(elm, styleName, '');\n }\n stylesModified = true;\n });\n if (stylesModified) {\n removeEmptyStyleAttributeIfNeeded(dom, elm);\n }\n };\n const removeListStyleFormats = (editor, name, vars) => {\n if (name === 'removeformat') {\n each$e(getPartiallySelectedListItems(editor.selection), li => {\n each$e(listItemStyles, name => editor.dom.setStyle(li, name, ''));\n removeEmptyStyleAttributeIfNeeded(editor.dom, li);\n });\n } else {\n getExpandedListItemFormat(editor.formatter, name).each(liFmt => {\n each$e(getPartiallySelectedListItems(editor.selection), li => removeStyles(editor.dom, li, liFmt, vars, null));\n });\n }\n };\n const removeNodeFormatInternal = (ed, format, vars, node, compareNode) => {\n const dom = ed.dom;\n const elementUtils = ElementUtils(ed);\n const schema = ed.schema;\n if (isInlineFormat(format) && isTransparentElementName(schema, format.inline) && isTransparentBlock(schema, node) && node.parentElement === ed.getBody()) {\n removeNode(ed, node, format);\n return removeResult.removed();\n }\n if (!format.ceFalseOverride && node && dom.getContentEditableParent(node) === 'false') {\n return removeResult.keep();\n }\n if (node && !matchName(dom, node, format) && !isColorFormatAndAnchor(node, format)) {\n return removeResult.keep();\n }\n const elm = node;\n const preserveAttributes = format.preserve_attributes;\n if (isInlineFormat(format) && format.remove === 'all' && isArray$1(preserveAttributes)) {\n const attrsToPreserve = filter$5(dom.getAttribs(elm), attr => contains$2(preserveAttributes, attr.name.toLowerCase()));\n dom.removeAllAttribs(elm);\n each$e(attrsToPreserve, attr => dom.setAttrib(elm, attr.name, attr.value));\n if (attrsToPreserve.length > 0) {\n return removeResult.rename('span');\n }\n }\n if (format.remove !== 'all') {\n removeStyles(dom, elm, format, vars, compareNode);\n each$7(format.attributes, (value, name) => {\n const {\n name: attrName,\n value: attrValue\n } = processFormatAttrOrStyle(name, value, vars);\n if (format.remove_similar || isNull(attrValue) || !isElement$6(compareNode) || isEq$2(dom.getAttrib(compareNode, attrName), attrValue)) {\n if (attrName === 'class') {\n const currentValue = dom.getAttrib(elm, attrName);\n if (currentValue) {\n let valueOut = '';\n each$e(currentValue.split(/\\s+/), cls => {\n if (/mce\\-\\w+/.test(cls)) {\n valueOut += (valueOut ? ' ' : '') + cls;\n }\n });\n if (valueOut) {\n dom.setAttrib(elm, attrName, valueOut);\n return;\n }\n }\n }\n if (MCE_ATTR_RE.test(attrName)) {\n elm.removeAttribute('data-mce-' + attrName);\n }\n if (attrName === 'style' && matchNodeNames(['li'])(elm) && dom.getStyle(elm, 'list-style-type') === 'none') {\n elm.removeAttribute(attrName);\n dom.setStyle(elm, 'list-style-type', 'none');\n return;\n }\n if (attrName === 'class') {\n elm.removeAttribute('className');\n }\n elm.removeAttribute(attrName);\n }\n });\n each$7(format.classes, value => {\n value = replaceVars(value, vars);\n if (!isElement$6(compareNode) || dom.hasClass(compareNode, value)) {\n dom.removeClass(elm, value);\n }\n });\n const attrs = dom.getAttribs(elm);\n for (let i = 0; i < attrs.length; i++) {\n const attrName = attrs[i].nodeName;\n if (!elementUtils.isAttributeInternal(attrName)) {\n return removeResult.keep();\n }\n }\n }\n if (format.remove !== 'none') {\n removeNode(ed, elm, format);\n return removeResult.removed();\n }\n return removeResult.keep();\n };\n const findFormatRoot = (editor, container, name, vars, similar) => {\n let formatRoot;\n if (container.parentNode) {\n each$e(getParents$2(editor.dom, container.parentNode).reverse(), parent => {\n if (!formatRoot && isElement$6(parent) && parent.id !== '_start' && parent.id !== '_end') {\n const format = matchNode(editor, parent, name, vars, similar);\n if (format && format.split !== false) {\n formatRoot = parent;\n }\n }\n });\n }\n return formatRoot;\n };\n const removeNodeFormatFromClone = (editor, format, vars, clone) => removeNodeFormatInternal(editor, format, vars, clone, clone).fold(constant(clone), newName => {\n const fragment = editor.dom.createFragment();\n fragment.appendChild(clone);\n return editor.dom.rename(clone, newName);\n }, constant(null));\n const wrapAndSplit = (editor, formatList, formatRoot, container, target, split, format, vars) => {\n var _a, _b;\n let lastClone;\n let firstClone;\n const dom = editor.dom;\n if (formatRoot) {\n const formatRootParent = formatRoot.parentNode;\n for (let parent = container.parentNode; parent && parent !== formatRootParent; parent = parent.parentNode) {\n let clone = dom.clone(parent, false);\n for (let i = 0; i < formatList.length; i++) {\n clone = removeNodeFormatFromClone(editor, formatList[i], vars, clone);\n if (clone === null) {\n break;\n }\n }\n if (clone) {\n if (lastClone) {\n clone.appendChild(lastClone);\n }\n if (!firstClone) {\n firstClone = clone;\n }\n lastClone = clone;\n }\n }\n if (split && (!format.mixed || !dom.isBlock(formatRoot))) {\n container = (_a = dom.split(formatRoot, container)) !== null && _a !== void 0 ? _a : container;\n }\n if (lastClone && firstClone) {\n (_b = target.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(lastClone, target);\n firstClone.appendChild(target);\n if (isInlineFormat(format)) {\n mergeSiblings(editor, format, vars, lastClone);\n }\n }\n }\n return container;\n };\n const removeFormatInternal = (ed, name, vars, node, similar) => {\n const formatList = ed.formatter.get(name);\n const format = formatList[0];\n const dom = ed.dom;\n const selection = ed.selection;\n const splitToFormatRoot = container => {\n const formatRoot = findFormatRoot(ed, container, name, vars, similar);\n return wrapAndSplit(ed, formatList, formatRoot, container, container, true, format, vars);\n };\n const isRemoveBookmarkNode = node => isBookmarkNode$1(node) && isElement$6(node) && (node.id === '_start' || node.id === '_end');\n const removeFormatOnNode = node => exists(formatList, fmt => removeNodeFormat(ed, fmt, vars, node, node));\n const process = node => {\n const children = from(node.childNodes);\n const removed = removeFormatOnNode(node);\n const currentNodeMatches = removed || exists(formatList, f => matchName(dom, node, f));\n const parentNode = node.parentNode;\n if (!currentNodeMatches && isNonNullable(parentNode) && shouldExpandToSelector(format)) {\n removeFormatOnNode(parentNode);\n }\n if (format.deep) {\n if (children.length) {\n for (let i = 0; i < children.length; i++) {\n process(children[i]);\n }\n }\n }\n const textDecorations = [\n 'underline',\n 'line-through',\n 'overline'\n ];\n each$e(textDecorations, decoration => {\n if (isElement$6(node) && ed.dom.getStyle(node, 'text-decoration') === decoration && node.parentNode && getTextDecoration(dom, node.parentNode) === decoration) {\n removeNodeFormat(ed, {\n deep: false,\n exact: true,\n inline: 'span',\n styles: { textDecoration: decoration }\n }, undefined, node);\n }\n });\n };\n const unwrap = start => {\n const node = dom.get(start ? '_start' : '_end');\n if (node) {\n let out = node[start ? 'firstChild' : 'lastChild'];\n if (isRemoveBookmarkNode(out)) {\n out = out[start ? 'firstChild' : 'lastChild'];\n }\n if (isText$a(out) && out.data.length === 0) {\n out = start ? node.previousSibling || node.nextSibling : node.nextSibling || node.previousSibling;\n }\n dom.remove(node, true);\n return out;\n } else {\n return null;\n }\n };\n const removeRngStyle = rng => {\n let startContainer;\n let endContainer;\n let expandedRng = expandRng(dom, rng, formatList, rng.collapsed);\n if (format.split) {\n expandedRng = split(expandedRng);\n startContainer = getContainer(ed, expandedRng, true);\n endContainer = getContainer(ed, expandedRng);\n if (startContainer !== endContainer) {\n startContainer = normalizeTableSelection(startContainer, true);\n endContainer = normalizeTableSelection(endContainer, false);\n if (isChildOfInlineParent(dom, startContainer, endContainer)) {\n const marker = Optional.from(startContainer.firstChild).getOr(startContainer);\n splitToFormatRoot(wrapWithSiblings(dom, marker, true, 'span', {\n 'id': '_start',\n 'data-mce-type': 'bookmark'\n }));\n unwrap(true);\n return;\n }\n if (isChildOfInlineParent(dom, endContainer, startContainer)) {\n const marker = Optional.from(endContainer.lastChild).getOr(endContainer);\n splitToFormatRoot(wrapWithSiblings(dom, marker, false, 'span', {\n 'id': '_end',\n 'data-mce-type': 'bookmark'\n }));\n unwrap(false);\n return;\n }\n startContainer = wrap$1(dom, startContainer, 'span', {\n 'id': '_start',\n 'data-mce-type': 'bookmark'\n });\n endContainer = wrap$1(dom, endContainer, 'span', {\n 'id': '_end',\n 'data-mce-type': 'bookmark'\n });\n const newRng = dom.createRng();\n newRng.setStartAfter(startContainer);\n newRng.setEndBefore(endContainer);\n walk$3(dom, newRng, nodes => {\n each$e(nodes, n => {\n if (!isBookmarkNode$1(n) && !isBookmarkNode$1(n.parentNode)) {\n splitToFormatRoot(n);\n }\n });\n });\n splitToFormatRoot(startContainer);\n splitToFormatRoot(endContainer);\n startContainer = unwrap(true);\n endContainer = unwrap();\n } else {\n startContainer = endContainer = splitToFormatRoot(startContainer);\n }\n expandedRng.startContainer = startContainer.parentNode ? startContainer.parentNode : startContainer;\n expandedRng.startOffset = dom.nodeIndex(startContainer);\n expandedRng.endContainer = endContainer.parentNode ? endContainer.parentNode : endContainer;\n expandedRng.endOffset = dom.nodeIndex(endContainer) + 1;\n }\n walk$3(dom, expandedRng, nodes => {\n each$e(nodes, process);\n });\n };\n if (node) {\n if (isNode(node)) {\n const rng = dom.createRng();\n rng.setStartBefore(node);\n rng.setEndAfter(node);\n removeRngStyle(rng);\n } else {\n removeRngStyle(node);\n }\n fireFormatRemove(ed, name, node, vars);\n return;\n }\n if (!selection.isCollapsed() || !isInlineFormat(format) || getCellsFromEditor(ed).length) {\n preserveSelection(ed, () => runOnRanges(ed, removeRngStyle), startNode => isInlineFormat(format) && match$2(ed, name, vars, startNode));\n ed.nodeChanged();\n } else {\n removeCaretFormat(ed, name, vars, similar);\n }\n removeListStyleFormats(ed, name, vars);\n fireFormatRemove(ed, name, node, vars);\n };\n const removeFormat$1 = (ed, name, vars, node, similar) => {\n if (node || ed.selection.isEditable()) {\n removeFormatInternal(ed, name, vars, node, similar);\n }\n };\n const removeNodeFormat = (editor, format, vars, node, compareNode) => {\n return removeNodeFormatInternal(editor, format, vars, node, compareNode).fold(never, newName => {\n editor.dom.rename(node, newName);\n return true;\n }, always);\n };\n\n const each$6 = Tools.each;\n const mergeTextDecorationsAndColor = (dom, format, vars, node) => {\n const processTextDecorationsAndColor = n => {\n if (isHTMLElement(n) && isElement$6(n.parentNode) && dom.isEditable(n)) {\n const parentTextDecoration = getTextDecoration(dom, n.parentNode);\n if (dom.getStyle(n, 'color') && parentTextDecoration) {\n dom.setStyle(n, 'text-decoration', parentTextDecoration);\n } else if (dom.getStyle(n, 'text-decoration') === parentTextDecoration) {\n dom.setStyle(n, 'text-decoration', null);\n }\n }\n };\n if (format.styles && (format.styles.color || format.styles.textDecoration)) {\n Tools.walk(node, processTextDecorationsAndColor, 'childNodes');\n processTextDecorationsAndColor(node);\n }\n };\n const mergeBackgroundColorAndFontSize = (dom, format, vars, node) => {\n if (format.styles && format.styles.backgroundColor) {\n const hasFontSize = hasStyle(dom, 'fontSize');\n processChildElements(node, elm => hasFontSize(elm) && dom.isEditable(elm), applyStyle(dom, 'backgroundColor', replaceVars(format.styles.backgroundColor, vars)));\n }\n };\n const mergeSubSup = (dom, format, vars, node) => {\n if (isInlineFormat(format) && (format.inline === 'sub' || format.inline === 'sup')) {\n const hasFontSize = hasStyle(dom, 'fontSize');\n processChildElements(node, elm => hasFontSize(elm) && dom.isEditable(elm), applyStyle(dom, 'fontSize', ''));\n const inverseTagDescendants = filter$5(dom.select(format.inline === 'sup' ? 'sub' : 'sup', node), dom.isEditable);\n dom.remove(inverseTagDescendants, true);\n }\n };\n const mergeWithChildren = (editor, formatList, vars, node) => {\n each$6(formatList, format => {\n if (isInlineFormat(format)) {\n each$6(editor.dom.select(format.inline, node), child => {\n if (isElementNode(child)) {\n removeNodeFormat(editor, format, vars, child, format.exact ? child : null);\n }\n });\n }\n clearChildStyles(editor.dom, format, node);\n });\n };\n const mergeWithParents = (editor, format, name, vars, node) => {\n const parentNode = node.parentNode;\n if (matchNode(editor, parentNode, name, vars)) {\n if (removeNodeFormat(editor, format, vars, node)) {\n return;\n }\n }\n if (format.merge_with_parents && parentNode) {\n editor.dom.getParent(parentNode, parent => {\n if (matchNode(editor, parent, name, vars)) {\n removeNodeFormat(editor, format, vars, node);\n return true;\n } else {\n return false;\n }\n });\n }\n };\n\n const each$5 = Tools.each;\n const canFormatBR = (editor, format, node, parentName) => {\n if (canFormatEmptyLines(editor) && isInlineFormat(format) && node.parentNode) {\n const validBRParentElements = getTextRootBlockElements(editor.schema);\n const hasCaretNodeSibling = sibling(SugarElement.fromDom(node), sibling => isCaretNode(sibling.dom));\n return hasNonNullableKey(validBRParentElements, parentName) && isEmpty$2(SugarElement.fromDom(node.parentNode), false) && !hasCaretNodeSibling;\n } else {\n return false;\n }\n };\n const applyStyles = (dom, elm, format, vars) => {\n each$5(format.styles, (value, name) => {\n dom.setStyle(elm, name, replaceVars(value, vars));\n });\n if (format.styles) {\n const styleVal = dom.getAttrib(elm, 'style');\n if (styleVal) {\n dom.setAttrib(elm, 'data-mce-style', styleVal);\n }\n }\n };\n const applyFormatAction = (ed, name, vars, node) => {\n const formatList = ed.formatter.get(name);\n const format = formatList[0];\n const isCollapsed = !node && ed.selection.isCollapsed();\n const dom = ed.dom;\n const selection = ed.selection;\n const setElementFormat = (elm, fmt = format) => {\n if (isFunction(fmt.onformat)) {\n fmt.onformat(elm, fmt, vars, node);\n }\n applyStyles(dom, elm, fmt, vars);\n each$5(fmt.attributes, (value, name) => {\n dom.setAttrib(elm, name, replaceVars(value, vars));\n });\n each$5(fmt.classes, value => {\n const newValue = replaceVars(value, vars);\n if (!dom.hasClass(elm, newValue)) {\n dom.addClass(elm, newValue);\n }\n });\n };\n const applyNodeStyle = (formatList, node) => {\n let found = false;\n each$5(formatList, format => {\n if (!isSelectorFormat(format)) {\n return false;\n }\n if (dom.getContentEditable(node) === 'false' && !format.ceFalseOverride) {\n return true;\n }\n if (isNonNullable(format.collapsed) && format.collapsed !== isCollapsed) {\n return true;\n }\n if (dom.is(node, format.selector) && !isCaretNode(node)) {\n setElementFormat(node, format);\n found = true;\n return false;\n }\n return true;\n });\n return found;\n };\n const createWrapElement = wrapName => {\n if (isString(wrapName)) {\n const wrapElm = dom.create(wrapName);\n setElementFormat(wrapElm);\n return wrapElm;\n } else {\n return null;\n }\n };\n const applyRngStyle = (dom, rng, nodeSpecific) => {\n const newWrappers = [];\n let contentEditable = true;\n const wrapName = format.inline || format.block;\n const wrapElm = createWrapElement(wrapName);\n const isMatchingWrappingBlock = node => isWrappingBlockFormat(format) && matchNode(ed, node, name, vars);\n const canRenameBlock = (node, parentName, isEditableDescendant) => {\n const isValidBlockFormatForNode = isNonWrappingBlockFormat(format) && isTextBlock$1(ed.schema, node) && isValid(ed, parentName, wrapName);\n return isEditableDescendant && isValidBlockFormatForNode;\n };\n const canWrapNode = (node, parentName, isEditableDescendant, isWrappableNoneditableElm) => {\n const nodeName = node.nodeName.toLowerCase();\n const isValidWrapNode = isValid(ed, wrapName, nodeName) && isValid(ed, parentName, wrapName);\n const isZwsp = !nodeSpecific && isText$a(node) && isZwsp$1(node.data);\n const isCaret = isCaretNode(node);\n const isCorrectFormatForNode = !isInlineFormat(format) || !dom.isBlock(node);\n return (isEditableDescendant || isWrappableNoneditableElm) && isValidWrapNode && !isZwsp && !isCaret && isCorrectFormatForNode;\n };\n walk$3(dom, rng, nodes => {\n let currentWrapElm;\n const process = node => {\n let hasContentEditableState = false;\n let lastContentEditable = contentEditable;\n let isWrappableNoneditableElm = false;\n const parentNode = node.parentNode;\n const parentName = parentNode.nodeName.toLowerCase();\n const contentEditableValue = dom.getContentEditable(node);\n if (isNonNullable(contentEditableValue)) {\n lastContentEditable = contentEditable;\n contentEditable = contentEditableValue === 'true';\n hasContentEditableState = true;\n isWrappableNoneditableElm = isWrappableNoneditable(ed, node);\n }\n const isEditableDescendant = contentEditable && !hasContentEditableState;\n if (isBr$6(node) && !canFormatBR(ed, format, node, parentName)) {\n currentWrapElm = null;\n if (isBlockFormat(format)) {\n dom.remove(node);\n }\n return;\n }\n if (isMatchingWrappingBlock(node)) {\n currentWrapElm = null;\n return;\n }\n if (canRenameBlock(node, parentName, isEditableDescendant)) {\n const elm = dom.rename(node, wrapName);\n setElementFormat(elm);\n newWrappers.push(elm);\n currentWrapElm = null;\n return;\n }\n if (isSelectorFormat(format)) {\n let found = applyNodeStyle(formatList, node);\n if (!found && isNonNullable(parentNode) && shouldExpandToSelector(format)) {\n found = applyNodeStyle(formatList, parentNode);\n }\n if (!isInlineFormat(format) || found) {\n currentWrapElm = null;\n return;\n }\n }\n if (isNonNullable(wrapElm) && canWrapNode(node, parentName, isEditableDescendant, isWrappableNoneditableElm)) {\n if (!currentWrapElm) {\n currentWrapElm = dom.clone(wrapElm, false);\n parentNode.insertBefore(currentWrapElm, node);\n newWrappers.push(currentWrapElm);\n }\n if (isWrappableNoneditableElm && hasContentEditableState) {\n contentEditable = lastContentEditable;\n }\n currentWrapElm.appendChild(node);\n } else {\n currentWrapElm = null;\n each$e(from(node.childNodes), process);\n if (hasContentEditableState) {\n contentEditable = lastContentEditable;\n }\n currentWrapElm = null;\n }\n };\n each$e(nodes, process);\n });\n if (format.links === true) {\n each$e(newWrappers, node => {\n const process = node => {\n if (node.nodeName === 'A') {\n setElementFormat(node, format);\n }\n each$e(from(node.childNodes), process);\n };\n process(node);\n });\n }\n each$e(newWrappers, node => {\n const getChildCount = node => {\n let count = 0;\n each$e(node.childNodes, node => {\n if (!isEmptyTextNode$1(node) && !isBookmarkNode$1(node)) {\n count++;\n }\n });\n return count;\n };\n const mergeStyles = node => {\n const childElement = find$2(node.childNodes, isElementNode$1).filter(child => dom.getContentEditable(child) !== 'false' && matchName(dom, child, format));\n return childElement.map(child => {\n const clone = dom.clone(child, false);\n setElementFormat(clone);\n dom.replace(clone, node, true);\n dom.remove(child, true);\n return clone;\n }).getOr(node);\n };\n const childCount = getChildCount(node);\n if ((newWrappers.length > 1 || !dom.isBlock(node)) && childCount === 0) {\n dom.remove(node, true);\n return;\n }\n if (isInlineFormat(format) || isBlockFormat(format) && format.wrapper) {\n if (!format.exact && childCount === 1) {\n node = mergeStyles(node);\n }\n mergeWithChildren(ed, formatList, vars, node);\n mergeWithParents(ed, format, name, vars, node);\n mergeBackgroundColorAndFontSize(dom, format, vars, node);\n mergeTextDecorationsAndColor(dom, format, vars, node);\n mergeSubSup(dom, format, vars, node);\n mergeSiblings(ed, format, vars, node);\n }\n });\n };\n const targetNode = isNode(node) ? node : selection.getNode();\n if (dom.getContentEditable(targetNode) === 'false' && !isWrappableNoneditable(ed, targetNode)) {\n node = targetNode;\n applyNodeStyle(formatList, node);\n fireFormatApply(ed, name, node, vars);\n return;\n }\n if (format) {\n if (node) {\n if (isNode(node)) {\n if (!applyNodeStyle(formatList, node)) {\n const rng = dom.createRng();\n rng.setStartBefore(node);\n rng.setEndAfter(node);\n applyRngStyle(dom, expandRng(dom, rng, formatList), true);\n }\n } else {\n applyRngStyle(dom, node, true);\n }\n } else {\n if (!isCollapsed || !isInlineFormat(format) || getCellsFromEditor(ed).length) {\n selection.setRng(normalize(selection.getRng()));\n preserveSelection(ed, () => {\n runOnRanges(ed, (selectionRng, fake) => {\n const expandedRng = fake ? selectionRng : expandRng(dom, selectionRng, formatList);\n applyRngStyle(dom, expandedRng, false);\n });\n }, always);\n ed.nodeChanged();\n } else {\n applyCaretFormat(ed, name, vars);\n }\n getExpandedListItemFormat(ed.formatter, name).each(liFmt => {\n each$e(getFullySelectedListItems(ed.selection), li => applyStyles(dom, li, liFmt, vars));\n });\n }\n postProcess$1(name, ed);\n }\n fireFormatApply(ed, name, node, vars);\n };\n const applyFormat$1 = (editor, name, vars, node) => {\n if (node || editor.selection.isEditable()) {\n applyFormatAction(editor, name, vars, node);\n }\n };\n\n const hasVars = value => has$2(value, 'vars');\n const setup$u = (registeredFormatListeners, editor) => {\n registeredFormatListeners.set({});\n editor.on('NodeChange', e => {\n updateAndFireChangeCallbacks(editor, e.element, registeredFormatListeners.get());\n });\n editor.on('FormatApply FormatRemove', e => {\n const element = Optional.from(e.node).map(nodeOrRange => isNode(nodeOrRange) ? nodeOrRange : nodeOrRange.startContainer).bind(node => isElement$6(node) ? Optional.some(node) : Optional.from(node.parentElement)).getOrThunk(() => fallbackElement(editor));\n updateAndFireChangeCallbacks(editor, element, registeredFormatListeners.get());\n });\n };\n const fallbackElement = editor => editor.selection.getStart();\n const matchingNode = (editor, parents, format, similar, vars) => {\n const isMatchingNode = node => {\n const matchingFormat = editor.formatter.matchNode(node, format, vars !== null && vars !== void 0 ? vars : {}, similar);\n return !isUndefined(matchingFormat);\n };\n const isUnableToMatch = node => {\n if (matchesUnInheritedFormatSelector(editor, node, format)) {\n return true;\n } else {\n if (!similar) {\n return isNonNullable(editor.formatter.matchNode(node, format, vars, true));\n } else {\n return false;\n }\n }\n };\n return findUntil$1(parents, isMatchingNode, isUnableToMatch);\n };\n const getParents = (editor, elm) => {\n const element = elm !== null && elm !== void 0 ? elm : fallbackElement(editor);\n return filter$5(getParents$2(editor.dom, element), node => isElement$6(node) && !isBogus$2(node));\n };\n const updateAndFireChangeCallbacks = (editor, elm, registeredCallbacks) => {\n const parents = getParents(editor, elm);\n each$d(registeredCallbacks, (data, format) => {\n const runIfChanged = spec => {\n const match = matchingNode(editor, parents, format, spec.similar, hasVars(spec) ? spec.vars : undefined);\n const isSet = match.isSome();\n if (spec.state.get() !== isSet) {\n spec.state.set(isSet);\n const node = match.getOr(elm);\n if (hasVars(spec)) {\n spec.callback(isSet, {\n node,\n format,\n parents\n });\n } else {\n each$e(spec.callbacks, callback => callback(isSet, {\n node,\n format,\n parents\n }));\n }\n }\n };\n each$e([\n data.withSimilar,\n data.withoutSimilar\n ], runIfChanged);\n each$e(data.withVars, runIfChanged);\n });\n };\n const addListeners = (editor, registeredFormatListeners, formats, callback, similar, vars) => {\n const formatChangeItems = registeredFormatListeners.get();\n each$e(formats.split(','), format => {\n const group = get$a(formatChangeItems, format).getOrThunk(() => {\n const base = {\n withSimilar: {\n state: Cell(false),\n similar: true,\n callbacks: []\n },\n withoutSimilar: {\n state: Cell(false),\n similar: false,\n callbacks: []\n },\n withVars: []\n };\n formatChangeItems[format] = base;\n return base;\n });\n const getCurrent = () => {\n const parents = getParents(editor);\n return matchingNode(editor, parents, format, similar, vars).isSome();\n };\n if (isUndefined(vars)) {\n const toAppendTo = similar ? group.withSimilar : group.withoutSimilar;\n toAppendTo.callbacks.push(callback);\n if (toAppendTo.callbacks.length === 1) {\n toAppendTo.state.set(getCurrent());\n }\n } else {\n group.withVars.push({\n state: Cell(getCurrent()),\n similar,\n vars,\n callback\n });\n }\n });\n registeredFormatListeners.set(formatChangeItems);\n };\n const removeListeners = (registeredFormatListeners, formats, callback) => {\n const formatChangeItems = registeredFormatListeners.get();\n each$e(formats.split(','), format => get$a(formatChangeItems, format).each(group => {\n formatChangeItems[format] = {\n withSimilar: {\n ...group.withSimilar,\n callbacks: filter$5(group.withSimilar.callbacks, cb => cb !== callback)\n },\n withoutSimilar: {\n ...group.withoutSimilar,\n callbacks: filter$5(group.withoutSimilar.callbacks, cb => cb !== callback)\n },\n withVars: filter$5(group.withVars, item => item.callback !== callback)\n };\n }));\n registeredFormatListeners.set(formatChangeItems);\n };\n const formatChangedInternal = (editor, registeredFormatListeners, formats, callback, similar, vars) => {\n addListeners(editor, registeredFormatListeners, formats, callback, similar, vars);\n return { unbind: () => removeListeners(registeredFormatListeners, formats, callback) };\n };\n\n const toggle = (editor, name, vars, node) => {\n const fmt = editor.formatter.get(name);\n if (fmt) {\n if (match$2(editor, name, vars, node) && (!('toggle' in fmt[0]) || fmt[0].toggle)) {\n removeFormat$1(editor, name, vars, node);\n } else {\n applyFormat$1(editor, name, vars, node);\n }\n }\n };\n\n const explode$1 = Tools.explode;\n const create$8 = () => {\n const filters = {};\n const addFilter = (name, callback) => {\n each$e(explode$1(name), name => {\n if (!has$2(filters, name)) {\n filters[name] = {\n name,\n callbacks: []\n };\n }\n filters[name].callbacks.push(callback);\n });\n };\n const getFilters = () => values(filters);\n const removeFilter = (name, callback) => {\n each$e(explode$1(name), name => {\n if (has$2(filters, name)) {\n if (isNonNullable(callback)) {\n const filter = filters[name];\n const newCallbacks = filter$5(filter.callbacks, c => c !== callback);\n if (newCallbacks.length > 0) {\n filter.callbacks = newCallbacks;\n } else {\n delete filters[name];\n }\n } else {\n delete filters[name];\n }\n }\n });\n };\n return {\n addFilter,\n getFilters,\n removeFilter\n };\n };\n\n const removeAttrs = (node, names) => {\n each$e(names, name => {\n node.attr(name, null);\n });\n };\n const addFontToSpansFilter = (domParser, styles, fontSizes) => {\n domParser.addNodeFilter('font', nodes => {\n each$e(nodes, node => {\n const props = styles.parse(node.attr('style'));\n const color = node.attr('color');\n const face = node.attr('face');\n const size = node.attr('size');\n if (color) {\n props.color = color;\n }\n if (face) {\n props['font-family'] = face;\n }\n if (size) {\n toInt(size).each(num => {\n props['font-size'] = fontSizes[num - 1];\n });\n }\n node.name = 'span';\n node.attr('style', styles.serialize(props));\n removeAttrs(node, [\n 'color',\n 'face',\n 'size'\n ]);\n });\n });\n };\n const addStrikeFilter = (domParser, schema, styles) => {\n domParser.addNodeFilter('strike', nodes => {\n const convertToSTag = schema.type !== 'html4';\n each$e(nodes, node => {\n if (convertToSTag) {\n node.name = 's';\n } else {\n const props = styles.parse(node.attr('style'));\n props['text-decoration'] = 'line-through';\n node.name = 'span';\n node.attr('style', styles.serialize(props));\n }\n });\n });\n };\n const addFilters = (domParser, settings, schema) => {\n var _a;\n const styles = Styles();\n if (settings.convert_fonts_to_spans) {\n addFontToSpansFilter(domParser, styles, Tools.explode((_a = settings.font_size_legacy_values) !== null && _a !== void 0 ? _a : ''));\n }\n addStrikeFilter(domParser, schema, styles);\n };\n const register$5 = (domParser, settings, schema) => {\n if (settings.inline_styles) {\n addFilters(domParser, settings, schema);\n }\n };\n\n const addNodeFilter = (settings, htmlParser, schema) => {\n htmlParser.addNodeFilter('br', (nodes, _, args) => {\n const blockElements = Tools.extend({}, schema.getBlockElements());\n const nonEmptyElements = schema.getNonEmptyElements();\n const whitespaceElements = schema.getWhitespaceElements();\n blockElements.body = 1;\n const isBlock = node => node.name in blockElements || isTransparentAstBlock(schema, node);\n for (let i = 0, l = nodes.length; i < l; i++) {\n let node = nodes[i];\n let parent = node.parent;\n if (parent && isBlock(parent) && node === parent.lastChild) {\n let prev = node.prev;\n while (prev) {\n const prevName = prev.name;\n if (prevName !== 'span' || prev.attr('data-mce-type') !== 'bookmark') {\n if (prevName === 'br') {\n node = null;\n }\n break;\n }\n prev = prev.prev;\n }\n if (node) {\n node.remove();\n if (isEmpty(schema, nonEmptyElements, whitespaceElements, parent)) {\n const elementRule = schema.getElementRule(parent.name);\n if (elementRule) {\n if (elementRule.removeEmpty) {\n parent.remove();\n } else if (elementRule.paddEmpty) {\n paddEmptyNode(settings, args, isBlock, parent);\n }\n }\n }\n }\n } else {\n let lastParent = node;\n while (parent && parent.firstChild === lastParent && parent.lastChild === lastParent) {\n lastParent = parent;\n if (blockElements[parent.name]) {\n break;\n }\n parent = parent.parent;\n }\n if (lastParent === parent) {\n const textNode = new AstNode('#text', 3);\n textNode.value = nbsp;\n node.replace(textNode);\n }\n }\n }\n });\n };\n\n const blobUriToBlob = url => fetch(url).then(res => res.ok ? res.blob() : Promise.reject()).catch(() => Promise.reject({\n message: `Cannot convert ${ url } to Blob. Resource might not exist or is inaccessible.`,\n uriType: 'blob'\n }));\n const extractBase64Data = data => {\n const matches = /([a-z0-9+\\/=\\s]+)/i.exec(data);\n return matches ? matches[1] : '';\n };\n const parseDataUri = uri => {\n const [type, ...rest] = uri.split(',');\n const data = rest.join(',');\n const matches = /data:([^/]+\\/[^;]+)(;.+)?/.exec(type);\n if (matches) {\n const base64Encoded = matches[2] === ';base64';\n const extractedData = base64Encoded ? extractBase64Data(data) : decodeURIComponent(data);\n return Optional.some({\n type: matches[1],\n data: extractedData,\n base64Encoded\n });\n } else {\n return Optional.none();\n }\n };\n const buildBlob = (type, data, base64Encoded = true) => {\n let str = data;\n if (base64Encoded) {\n try {\n str = atob(data);\n } catch (e) {\n return Optional.none();\n }\n }\n const arr = new Uint8Array(str.length);\n for (let i = 0; i < arr.length; i++) {\n arr[i] = str.charCodeAt(i);\n }\n return Optional.some(new Blob([arr], { type }));\n };\n const dataUriToBlob = uri => {\n return new Promise((resolve, reject) => {\n parseDataUri(uri).bind(({type, data, base64Encoded}) => buildBlob(type, data, base64Encoded)).fold(() => reject('Invalid data URI'), resolve);\n });\n };\n const uriToBlob = url => {\n if (startsWith(url, 'blob:')) {\n return blobUriToBlob(url);\n } else if (startsWith(url, 'data:')) {\n return dataUriToBlob(url);\n } else {\n return Promise.reject('Unknown URI format');\n }\n };\n const blobToDataUri = blob => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => {\n resolve(reader.result);\n };\n reader.onerror = () => {\n var _a;\n reject((_a = reader.error) === null || _a === void 0 ? void 0 : _a.message);\n };\n reader.readAsDataURL(blob);\n });\n };\n\n let count$1 = 0;\n const uniqueId$1 = prefix => {\n return (prefix || 'blobid') + count$1++;\n };\n const processDataUri = (dataUri, base64Only, generateBlobInfo) => {\n return parseDataUri(dataUri).bind(({data, type, base64Encoded}) => {\n if (base64Only && !base64Encoded) {\n return Optional.none();\n } else {\n const base64 = base64Encoded ? data : btoa(data);\n return generateBlobInfo(base64, type);\n }\n });\n };\n const createBlobInfo$1 = (blobCache, blob, base64) => {\n const blobInfo = blobCache.create(uniqueId$1(), blob, base64);\n blobCache.add(blobInfo);\n return blobInfo;\n };\n const dataUriToBlobInfo = (blobCache, dataUri, base64Only = false) => {\n return processDataUri(dataUri, base64Only, (base64, type) => Optional.from(blobCache.getByData(base64, type)).orThunk(() => buildBlob(type, base64).map(blob => createBlobInfo$1(blobCache, blob, base64))));\n };\n const imageToBlobInfo = (blobCache, imageSrc) => {\n const invalidDataUri = () => Promise.reject('Invalid data URI');\n if (startsWith(imageSrc, 'blob:')) {\n const blobInfo = blobCache.getByUri(imageSrc);\n if (isNonNullable(blobInfo)) {\n return Promise.resolve(blobInfo);\n } else {\n return uriToBlob(imageSrc).then(blob => {\n return blobToDataUri(blob).then(dataUri => {\n return processDataUri(dataUri, false, base64 => {\n return Optional.some(createBlobInfo$1(blobCache, blob, base64));\n }).getOrThunk(invalidDataUri);\n });\n });\n }\n } else if (startsWith(imageSrc, 'data:')) {\n return dataUriToBlobInfo(blobCache, imageSrc).fold(invalidDataUri, blobInfo => Promise.resolve(blobInfo));\n } else {\n return Promise.reject('Unknown image data format');\n }\n };\n\n const isBogusImage = img => isNonNullable(img.attr('data-mce-bogus'));\n const isInternalImageSource = img => img.attr('src') === Env.transparentSrc || isNonNullable(img.attr('data-mce-placeholder'));\n const registerBase64ImageFilter = (parser, settings) => {\n const {blob_cache: blobCache} = settings;\n if (blobCache) {\n const processImage = img => {\n const inputSrc = img.attr('src');\n if (isInternalImageSource(img) || isBogusImage(img) || isNullable(inputSrc)) {\n return;\n }\n dataUriToBlobInfo(blobCache, inputSrc, true).each(blobInfo => {\n img.attr('src', blobInfo.blobUri());\n });\n };\n parser.addAttributeFilter('src', nodes => each$e(nodes, processImage));\n }\n };\n const isMimeType = (mime, type) => startsWith(mime, `${ type }/`);\n const createSafeEmbed = (mime, src, width, height, sandboxIframes) => {\n let name;\n if (isUndefined(mime)) {\n name = 'iframe';\n } else if (isMimeType(mime, 'image')) {\n name = 'img';\n } else if (isMimeType(mime, 'video')) {\n name = 'video';\n } else if (isMimeType(mime, 'audio')) {\n name = 'audio';\n } else {\n name = 'iframe';\n }\n const embed = new AstNode(name, 1);\n embed.attr(name === 'audio' ? { src } : {\n src,\n width,\n height\n });\n if (name === 'audio' || name === 'video') {\n embed.attr('controls', '');\n }\n if (name === 'iframe' && sandboxIframes) {\n embed.attr('sandbox', '');\n }\n return embed;\n };\n const register$4 = (parser, settings) => {\n const schema = parser.schema;\n if (settings.remove_trailing_brs) {\n addNodeFilter(settings, parser, schema);\n }\n parser.addAttributeFilter('href', nodes => {\n let i = nodes.length;\n const appendRel = rel => {\n const parts = rel.split(' ').filter(p => p.length > 0);\n return parts.concat(['noopener']).sort().join(' ');\n };\n const addNoOpener = rel => {\n const newRel = rel ? Tools.trim(rel) : '';\n if (!/\\b(noopener)\\b/g.test(newRel)) {\n return appendRel(newRel);\n } else {\n return newRel;\n }\n };\n if (!settings.allow_unsafe_link_target) {\n while (i--) {\n const node = nodes[i];\n if (node.name === 'a' && node.attr('target') === '_blank') {\n node.attr('rel', addNoOpener(node.attr('rel')));\n }\n }\n }\n });\n if (!settings.allow_html_in_named_anchor) {\n parser.addAttributeFilter('id,name', nodes => {\n let i = nodes.length, sibling, prevSibling, parent, node;\n while (i--) {\n node = nodes[i];\n if (node.name === 'a' && node.firstChild && !node.attr('href')) {\n parent = node.parent;\n sibling = node.lastChild;\n while (sibling && parent) {\n prevSibling = sibling.prev;\n parent.insert(sibling, node);\n sibling = prevSibling;\n }\n }\n }\n });\n }\n if (settings.fix_list_elements) {\n parser.addNodeFilter('ul,ol', nodes => {\n let i = nodes.length, node, parentNode;\n while (i--) {\n node = nodes[i];\n parentNode = node.parent;\n if (parentNode && (parentNode.name === 'ul' || parentNode.name === 'ol')) {\n if (node.prev && node.prev.name === 'li') {\n node.prev.append(node);\n } else {\n const li = new AstNode('li', 1);\n li.attr('style', 'list-style-type: none');\n node.wrap(li);\n }\n }\n }\n });\n }\n const validClasses = schema.getValidClasses();\n if (settings.validate && validClasses) {\n parser.addAttributeFilter('class', nodes => {\n var _a;\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n const clazz = (_a = node.attr('class')) !== null && _a !== void 0 ? _a : '';\n const classList = Tools.explode(clazz, ' ');\n let classValue = '';\n for (let ci = 0; ci < classList.length; ci++) {\n const className = classList[ci];\n let valid = false;\n let validClassesMap = validClasses['*'];\n if (validClassesMap && validClassesMap[className]) {\n valid = true;\n }\n validClassesMap = validClasses[node.name];\n if (!valid && validClassesMap && validClassesMap[className]) {\n valid = true;\n }\n if (valid) {\n if (classValue) {\n classValue += ' ';\n }\n classValue += className;\n }\n }\n if (!classValue.length) {\n classValue = null;\n }\n node.attr('class', classValue);\n }\n });\n }\n registerBase64ImageFilter(parser, settings);\n if (settings.convert_unsafe_embeds) {\n parser.addNodeFilter('object,embed', nodes => each$e(nodes, node => {\n node.replace(createSafeEmbed(node.attr('type'), node.name === 'object' ? node.attr('data') : node.attr('src'), node.attr('width'), node.attr('height'), settings.sandbox_iframes));\n }));\n }\n if (settings.sandbox_iframes) {\n parser.addNodeFilter('iframe', nodes => each$e(nodes, node => node.attr('sandbox', '')));\n }\n };\n\n const {entries, setPrototypeOf, isFrozen, getPrototypeOf, getOwnPropertyDescriptor} = Object;\n let {freeze, seal, create: create$7} = Object;\n let {apply, construct} = typeof Reflect !== 'undefined' && Reflect;\n if (!apply) {\n apply = function apply(fun, thisValue, args) {\n return fun.apply(thisValue, args);\n };\n }\n if (!freeze) {\n freeze = function freeze(x) {\n return x;\n };\n }\n if (!seal) {\n seal = function seal(x) {\n return x;\n };\n }\n if (!construct) {\n construct = function construct(Func, args) {\n return new Func(...args);\n };\n }\n const arrayForEach = unapply(Array.prototype.forEach);\n const arrayPop = unapply(Array.prototype.pop);\n const arrayPush = unapply(Array.prototype.push);\n const stringToLowerCase = unapply(String.prototype.toLowerCase);\n const stringToString = unapply(String.prototype.toString);\n const stringMatch = unapply(String.prototype.match);\n const stringReplace = unapply(String.prototype.replace);\n const stringIndexOf = unapply(String.prototype.indexOf);\n const stringTrim = unapply(String.prototype.trim);\n const regExpTest = unapply(RegExp.prototype.test);\n const typeErrorCreate = unconstruct(TypeError);\n function unapply(func) {\n return function (thisArg) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n return apply(func, thisArg, args);\n };\n }\n function unconstruct(func) {\n return function () {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n return construct(func, args);\n };\n }\n function addToSet(set, array, transformCaseFunc) {\n var _transformCaseFunc;\n transformCaseFunc = (_transformCaseFunc = transformCaseFunc) !== null && _transformCaseFunc !== void 0 ? _transformCaseFunc : stringToLowerCase;\n if (setPrototypeOf) {\n setPrototypeOf(set, null);\n }\n let l = array.length;\n while (l--) {\n let element = array[l];\n if (typeof element === 'string') {\n const lcElement = transformCaseFunc(element);\n if (lcElement !== element) {\n if (!isFrozen(array)) {\n array[l] = lcElement;\n }\n element = lcElement;\n }\n }\n set[element] = true;\n }\n return set;\n }\n function clone(object) {\n const newObject = create$7(null);\n for (const [property, value] of entries(object)) {\n newObject[property] = value;\n }\n return newObject;\n }\n function lookupGetter(object, prop) {\n while (object !== null) {\n const desc = getOwnPropertyDescriptor(object, prop);\n if (desc) {\n if (desc.get) {\n return unapply(desc.get);\n }\n if (typeof desc.value === 'function') {\n return unapply(desc.value);\n }\n }\n object = getPrototypeOf(object);\n }\n function fallbackValue(element) {\n console.warn('fallback value for', element);\n return null;\n }\n return fallbackValue;\n }\n const html$1 = freeze([\n 'a',\n 'abbr',\n 'acronym',\n 'address',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blink',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'content',\n 'data',\n 'datalist',\n 'dd',\n 'decorator',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n 'dir',\n 'div',\n 'dl',\n 'dt',\n 'element',\n 'em',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'font',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hgroup',\n 'hr',\n 'html',\n 'i',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'main',\n 'map',\n 'mark',\n 'marquee',\n 'menu',\n 'menuitem',\n 'meter',\n 'nav',\n 'nobr',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'section',\n 'select',\n 'shadow',\n 'small',\n 'source',\n 'spacer',\n 'span',\n 'strike',\n 'strong',\n 'style',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'track',\n 'tt',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr'\n ]);\n const svg$1 = freeze([\n 'svg',\n 'a',\n 'altglyph',\n 'altglyphdef',\n 'altglyphitem',\n 'animatecolor',\n 'animatemotion',\n 'animatetransform',\n 'circle',\n 'clippath',\n 'defs',\n 'desc',\n 'ellipse',\n 'filter',\n 'font',\n 'g',\n 'glyph',\n 'glyphref',\n 'hkern',\n 'image',\n 'line',\n 'lineargradient',\n 'marker',\n 'mask',\n 'metadata',\n 'mpath',\n 'path',\n 'pattern',\n 'polygon',\n 'polyline',\n 'radialgradient',\n 'rect',\n 'stop',\n 'style',\n 'switch',\n 'symbol',\n 'text',\n 'textpath',\n 'title',\n 'tref',\n 'tspan',\n 'view',\n 'vkern'\n ]);\n const svgFilters = freeze([\n 'feBlend',\n 'feColorMatrix',\n 'feComponentTransfer',\n 'feComposite',\n 'feConvolveMatrix',\n 'feDiffuseLighting',\n 'feDisplacementMap',\n 'feDistantLight',\n 'feDropShadow',\n 'feFlood',\n 'feFuncA',\n 'feFuncB',\n 'feFuncG',\n 'feFuncR',\n 'feGaussianBlur',\n 'feImage',\n 'feMerge',\n 'feMergeNode',\n 'feMorphology',\n 'feOffset',\n 'fePointLight',\n 'feSpecularLighting',\n 'feSpotLight',\n 'feTile',\n 'feTurbulence'\n ]);\n const svgDisallowed = freeze([\n 'animate',\n 'color-profile',\n 'cursor',\n 'discard',\n 'font-face',\n 'font-face-format',\n 'font-face-name',\n 'font-face-src',\n 'font-face-uri',\n 'foreignobject',\n 'hatch',\n 'hatchpath',\n 'mesh',\n 'meshgradient',\n 'meshpatch',\n 'meshrow',\n 'missing-glyph',\n 'script',\n 'set',\n 'solidcolor',\n 'unknown',\n 'use'\n ]);\n const mathMl$1 = freeze([\n 'math',\n 'menclose',\n 'merror',\n 'mfenced',\n 'mfrac',\n 'mglyph',\n 'mi',\n 'mlabeledtr',\n 'mmultiscripts',\n 'mn',\n 'mo',\n 'mover',\n 'mpadded',\n 'mphantom',\n 'mroot',\n 'mrow',\n 'ms',\n 'mspace',\n 'msqrt',\n 'mstyle',\n 'msub',\n 'msup',\n 'msubsup',\n 'mtable',\n 'mtd',\n 'mtext',\n 'mtr',\n 'munder',\n 'munderover',\n 'mprescripts'\n ]);\n const mathMlDisallowed = freeze([\n 'maction',\n 'maligngroup',\n 'malignmark',\n 'mlongdiv',\n 'mscarries',\n 'mscarry',\n 'msgroup',\n 'mstack',\n 'msline',\n 'msrow',\n 'semantics',\n 'annotation',\n 'annotation-xml',\n 'mprescripts',\n 'none'\n ]);\n const text = freeze(['#text']);\n const html = freeze([\n 'accept',\n 'action',\n 'align',\n 'alt',\n 'autocapitalize',\n 'autocomplete',\n 'autopictureinpicture',\n 'autoplay',\n 'background',\n 'bgcolor',\n 'border',\n 'capture',\n 'cellpadding',\n 'cellspacing',\n 'checked',\n 'cite',\n 'class',\n 'clear',\n 'color',\n 'cols',\n 'colspan',\n 'controls',\n 'controlslist',\n 'coords',\n 'crossorigin',\n 'datetime',\n 'decoding',\n 'default',\n 'dir',\n 'disabled',\n 'disablepictureinpicture',\n 'disableremoteplayback',\n 'download',\n 'draggable',\n 'enctype',\n 'enterkeyhint',\n 'face',\n 'for',\n 'headers',\n 'height',\n 'hidden',\n 'high',\n 'href',\n 'hreflang',\n 'id',\n 'inputmode',\n 'integrity',\n 'ismap',\n 'kind',\n 'label',\n 'lang',\n 'list',\n 'loading',\n 'loop',\n 'low',\n 'max',\n 'maxlength',\n 'media',\n 'method',\n 'min',\n 'minlength',\n 'multiple',\n 'muted',\n 'name',\n 'nonce',\n 'noshade',\n 'novalidate',\n 'nowrap',\n 'open',\n 'optimum',\n 'pattern',\n 'placeholder',\n 'playsinline',\n 'poster',\n 'preload',\n 'pubdate',\n 'radiogroup',\n 'readonly',\n 'rel',\n 'required',\n 'rev',\n 'reversed',\n 'role',\n 'rows',\n 'rowspan',\n 'spellcheck',\n 'scope',\n 'selected',\n 'shape',\n 'size',\n 'sizes',\n 'span',\n 'srclang',\n 'start',\n 'src',\n 'srcset',\n 'step',\n 'style',\n 'summary',\n 'tabindex',\n 'title',\n 'translate',\n 'type',\n 'usemap',\n 'valign',\n 'value',\n 'width',\n 'xmlns',\n 'slot'\n ]);\n const svg = freeze([\n 'accent-height',\n 'accumulate',\n 'additive',\n 'alignment-baseline',\n 'ascent',\n 'attributename',\n 'attributetype',\n 'azimuth',\n 'basefrequency',\n 'baseline-shift',\n 'begin',\n 'bias',\n 'by',\n 'class',\n 'clip',\n 'clippathunits',\n 'clip-path',\n 'clip-rule',\n 'color',\n 'color-interpolation',\n 'color-interpolation-filters',\n 'color-profile',\n 'color-rendering',\n 'cx',\n 'cy',\n 'd',\n 'dx',\n 'dy',\n 'diffuseconstant',\n 'direction',\n 'display',\n 'divisor',\n 'dur',\n 'edgemode',\n 'elevation',\n 'end',\n 'fill',\n 'fill-opacity',\n 'fill-rule',\n 'filter',\n 'filterunits',\n 'flood-color',\n 'flood-opacity',\n 'font-family',\n 'font-size',\n 'font-size-adjust',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'fx',\n 'fy',\n 'g1',\n 'g2',\n 'glyph-name',\n 'glyphref',\n 'gradientunits',\n 'gradienttransform',\n 'height',\n 'href',\n 'id',\n 'image-rendering',\n 'in',\n 'in2',\n 'k',\n 'k1',\n 'k2',\n 'k3',\n 'k4',\n 'kerning',\n 'keypoints',\n 'keysplines',\n 'keytimes',\n 'lang',\n 'lengthadjust',\n 'letter-spacing',\n 'kernelmatrix',\n 'kernelunitlength',\n 'lighting-color',\n 'local',\n 'marker-end',\n 'marker-mid',\n 'marker-start',\n 'markerheight',\n 'markerunits',\n 'markerwidth',\n 'maskcontentunits',\n 'maskunits',\n 'max',\n 'mask',\n 'media',\n 'method',\n 'mode',\n 'min',\n 'name',\n 'numoctaves',\n 'offset',\n 'operator',\n 'opacity',\n 'order',\n 'orient',\n 'orientation',\n 'origin',\n 'overflow',\n 'paint-order',\n 'path',\n 'pathlength',\n 'patterncontentunits',\n 'patterntransform',\n 'patternunits',\n 'points',\n 'preservealpha',\n 'preserveaspectratio',\n 'primitiveunits',\n 'r',\n 'rx',\n 'ry',\n 'radius',\n 'refx',\n 'refy',\n 'repeatcount',\n 'repeatdur',\n 'restart',\n 'result',\n 'rotate',\n 'scale',\n 'seed',\n 'shape-rendering',\n 'specularconstant',\n 'specularexponent',\n 'spreadmethod',\n 'startoffset',\n 'stddeviation',\n 'stitchtiles',\n 'stop-color',\n 'stop-opacity',\n 'stroke-dasharray',\n 'stroke-dashoffset',\n 'stroke-linecap',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke',\n 'stroke-width',\n 'style',\n 'surfacescale',\n 'systemlanguage',\n 'tabindex',\n 'targetx',\n 'targety',\n 'transform',\n 'transform-origin',\n 'text-anchor',\n 'text-decoration',\n 'text-rendering',\n 'textlength',\n 'type',\n 'u1',\n 'u2',\n 'unicode',\n 'values',\n 'viewbox',\n 'visibility',\n 'version',\n 'vert-adv-y',\n 'vert-origin-x',\n 'vert-origin-y',\n 'width',\n 'word-spacing',\n 'wrap',\n 'writing-mode',\n 'xchannelselector',\n 'ychannelselector',\n 'x',\n 'x1',\n 'x2',\n 'xmlns',\n 'y',\n 'y1',\n 'y2',\n 'z',\n 'zoomandpan'\n ]);\n const mathMl = freeze([\n 'accent',\n 'accentunder',\n 'align',\n 'bevelled',\n 'close',\n 'columnsalign',\n 'columnlines',\n 'columnspan',\n 'denomalign',\n 'depth',\n 'dir',\n 'display',\n 'displaystyle',\n 'encoding',\n 'fence',\n 'frame',\n 'height',\n 'href',\n 'id',\n 'largeop',\n 'length',\n 'linethickness',\n 'lspace',\n 'lquote',\n 'mathbackground',\n 'mathcolor',\n 'mathsize',\n 'mathvariant',\n 'maxsize',\n 'minsize',\n 'movablelimits',\n 'notation',\n 'numalign',\n 'open',\n 'rowalign',\n 'rowlines',\n 'rowspacing',\n 'rowspan',\n 'rspace',\n 'rquote',\n 'scriptlevel',\n 'scriptminsize',\n 'scriptsizemultiplier',\n 'selection',\n 'separator',\n 'separators',\n 'stretchy',\n 'subscriptshift',\n 'supscriptshift',\n 'symmetric',\n 'voffset',\n 'width',\n 'xmlns'\n ]);\n const xml = freeze([\n 'xlink:href',\n 'xml:id',\n 'xlink:title',\n 'xml:space',\n 'xmlns:xlink'\n ]);\n const MUSTACHE_EXPR = seal(/\\{\\{[\\w\\W]*|[\\w\\W]*\\}\\}/gm);\n const ERB_EXPR = seal(/<%[\\w\\W]*|[\\w\\W]*%>/gm);\n const TMPLIT_EXPR = seal(/\\${[\\w\\W]*}/gm);\n const DATA_ATTR = seal(/^data-[\\-\\w.\\u00B7-\\uFFFF]/);\n const ARIA_ATTR = seal(/^aria-[\\-\\w]+$/);\n const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i);\n const IS_SCRIPT_OR_DATA = seal(/^(?:\\w+script|data):/i);\n const ATTR_WHITESPACE = seal(/[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g);\n const DOCTYPE_NAME = seal(/^html$/i);\n var EXPRESSIONS = Object.freeze({\n __proto__: null,\n MUSTACHE_EXPR: MUSTACHE_EXPR,\n ERB_EXPR: ERB_EXPR,\n TMPLIT_EXPR: TMPLIT_EXPR,\n DATA_ATTR: DATA_ATTR,\n ARIA_ATTR: ARIA_ATTR,\n IS_ALLOWED_URI: IS_ALLOWED_URI,\n IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,\n ATTR_WHITESPACE: ATTR_WHITESPACE,\n DOCTYPE_NAME: DOCTYPE_NAME\n });\n const getGlobal = () => typeof window === 'undefined' ? null : window;\n const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {\n if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {\n return null;\n }\n let suffix = null;\n const ATTR_NAME = 'data-tt-policy-suffix';\n if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {\n suffix = purifyHostElement.getAttribute(ATTR_NAME);\n }\n const policyName = 'dompurify' + (suffix ? '#' + suffix : '');\n try {\n return trustedTypes.createPolicy(policyName, {\n createHTML(html) {\n return html;\n },\n createScriptURL(scriptUrl) {\n return scriptUrl;\n }\n });\n } catch (_) {\n console.warn('TrustedTypes policy ' + policyName + ' could not be created.');\n return null;\n }\n };\n function createDOMPurify() {\n let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();\n const DOMPurify = root => createDOMPurify(root);\n DOMPurify.version = '3.0.5';\n DOMPurify.removed = [];\n if (!window || !window.document || window.document.nodeType !== 9) {\n DOMPurify.isSupported = false;\n return DOMPurify;\n }\n const originalDocument = window.document;\n const currentScript = originalDocument.currentScript;\n let {document} = window;\n const {DocumentFragment, HTMLTemplateElement, Node, Element, NodeFilter, NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap, HTMLFormElement, DOMParser, trustedTypes} = window;\n const ElementPrototype = Element.prototype;\n const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');\n const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');\n const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');\n const getParentNode = lookupGetter(ElementPrototype, 'parentNode');\n if (typeof HTMLTemplateElement === 'function') {\n const template = document.createElement('template');\n if (template.content && template.content.ownerDocument) {\n document = template.content.ownerDocument;\n }\n }\n let trustedTypesPolicy;\n let emptyHTML = '';\n const {implementation, createNodeIterator, createDocumentFragment, getElementsByTagName} = document;\n const {importNode} = originalDocument;\n let hooks = {};\n DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;\n const {MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR, DATA_ATTR, ARIA_ATTR, IS_SCRIPT_OR_DATA, ATTR_WHITESPACE} = EXPRESSIONS;\n let {IS_ALLOWED_URI: IS_ALLOWED_URI$1} = EXPRESSIONS;\n let ALLOWED_TAGS = null;\n const DEFAULT_ALLOWED_TAGS = addToSet({}, [\n ...html$1,\n ...svg$1,\n ...svgFilters,\n ...mathMl$1,\n ...text\n ]);\n let ALLOWED_ATTR = null;\n const DEFAULT_ALLOWED_ATTR = addToSet({}, [\n ...html,\n ...svg,\n ...mathMl,\n ...xml\n ]);\n let CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {\n tagNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n attributeNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n allowCustomizedBuiltInElements: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: false\n }\n }));\n let FORBID_TAGS = null;\n let FORBID_ATTR = null;\n let ALLOW_ARIA_ATTR = true;\n let ALLOW_DATA_ATTR = true;\n let ALLOW_UNKNOWN_PROTOCOLS = false;\n let ALLOW_SELF_CLOSE_IN_ATTR = true;\n let SAFE_FOR_TEMPLATES = false;\n let WHOLE_DOCUMENT = false;\n let SET_CONFIG = false;\n let FORCE_BODY = false;\n let RETURN_DOM = false;\n let RETURN_DOM_FRAGMENT = false;\n let RETURN_TRUSTED_TYPE = false;\n let SANITIZE_DOM = true;\n let SANITIZE_NAMED_PROPS = false;\n const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';\n let KEEP_CONTENT = true;\n let IN_PLACE = false;\n let USE_PROFILES = {};\n let FORBID_CONTENTS = null;\n const DEFAULT_FORBID_CONTENTS = addToSet({}, [\n 'annotation-xml',\n 'audio',\n 'colgroup',\n 'desc',\n 'foreignobject',\n 'head',\n 'iframe',\n 'math',\n 'mi',\n 'mn',\n 'mo',\n 'ms',\n 'mtext',\n 'noembed',\n 'noframes',\n 'noscript',\n 'plaintext',\n 'script',\n 'style',\n 'svg',\n 'template',\n 'thead',\n 'title',\n 'video',\n 'xmp'\n ]);\n let DATA_URI_TAGS = null;\n const DEFAULT_DATA_URI_TAGS = addToSet({}, [\n 'audio',\n 'video',\n 'img',\n 'source',\n 'image',\n 'track'\n ]);\n let URI_SAFE_ATTRIBUTES = null;\n const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [\n 'alt',\n 'class',\n 'for',\n 'id',\n 'label',\n 'name',\n 'pattern',\n 'placeholder',\n 'role',\n 'summary',\n 'title',\n 'value',\n 'style',\n 'xmlns'\n ]);\n const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n let NAMESPACE = HTML_NAMESPACE;\n let IS_EMPTY_INPUT = false;\n let ALLOWED_NAMESPACES = null;\n const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [\n MATHML_NAMESPACE,\n SVG_NAMESPACE,\n HTML_NAMESPACE\n ], stringToString);\n let PARSER_MEDIA_TYPE;\n const SUPPORTED_PARSER_MEDIA_TYPES = [\n 'application/xhtml+xml',\n 'text/html'\n ];\n const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';\n let transformCaseFunc;\n let CONFIG = null;\n const formElement = document.createElement('form');\n const isRegexOrFunction = function isRegexOrFunction(testValue) {\n return testValue instanceof RegExp || testValue instanceof Function;\n };\n const _parseConfig = function _parseConfig(cfg) {\n if (CONFIG && CONFIG === cfg) {\n return;\n }\n if (!cfg || typeof cfg !== 'object') {\n cfg = {};\n }\n cfg = clone(cfg);\n PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE;\n transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;\n ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;\n ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;\n ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;\n URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;\n DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;\n FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;\n FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};\n FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};\n USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;\n ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;\n ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;\n ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;\n ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;\n SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;\n WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;\n RETURN_DOM = cfg.RETURN_DOM || false;\n RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;\n RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;\n FORCE_BODY = cfg.FORCE_BODY || false;\n SANITIZE_DOM = cfg.SANITIZE_DOM !== false;\n SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;\n KEEP_CONTENT = cfg.KEEP_CONTENT !== false;\n IN_PLACE = cfg.IN_PLACE || false;\n IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;\n NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;\n CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};\n if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {\n CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;\n }\n if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;\n }\n if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;\n }\n if (SAFE_FOR_TEMPLATES) {\n ALLOW_DATA_ATTR = false;\n }\n if (RETURN_DOM_FRAGMENT) {\n RETURN_DOM = true;\n }\n if (USE_PROFILES) {\n ALLOWED_TAGS = addToSet({}, [...text]);\n ALLOWED_ATTR = [];\n if (USE_PROFILES.html === true) {\n addToSet(ALLOWED_TAGS, html$1);\n addToSet(ALLOWED_ATTR, html);\n }\n if (USE_PROFILES.svg === true) {\n addToSet(ALLOWED_TAGS, svg$1);\n addToSet(ALLOWED_ATTR, svg);\n addToSet(ALLOWED_ATTR, xml);\n }\n if (USE_PROFILES.svgFilters === true) {\n addToSet(ALLOWED_TAGS, svgFilters);\n addToSet(ALLOWED_ATTR, svg);\n addToSet(ALLOWED_ATTR, xml);\n }\n if (USE_PROFILES.mathMl === true) {\n addToSet(ALLOWED_TAGS, mathMl$1);\n addToSet(ALLOWED_ATTR, mathMl);\n addToSet(ALLOWED_ATTR, xml);\n }\n }\n if (cfg.ADD_TAGS) {\n if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {\n ALLOWED_TAGS = clone(ALLOWED_TAGS);\n }\n addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);\n }\n if (cfg.ADD_ATTR) {\n if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {\n ALLOWED_ATTR = clone(ALLOWED_ATTR);\n }\n addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);\n }\n if (cfg.ADD_URI_SAFE_ATTR) {\n addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);\n }\n if (cfg.FORBID_CONTENTS) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);\n }\n if (KEEP_CONTENT) {\n ALLOWED_TAGS['#text'] = true;\n }\n if (WHOLE_DOCUMENT) {\n addToSet(ALLOWED_TAGS, [\n 'html',\n 'head',\n 'body'\n ]);\n }\n if (ALLOWED_TAGS.table) {\n addToSet(ALLOWED_TAGS, ['tbody']);\n delete FORBID_TAGS.tbody;\n }\n if (cfg.TRUSTED_TYPES_POLICY) {\n if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {\n throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.');\n }\n if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {\n throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.');\n }\n trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;\n emptyHTML = trustedTypesPolicy.createHTML('');\n } else {\n if (trustedTypesPolicy === undefined) {\n trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);\n }\n if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {\n emptyHTML = trustedTypesPolicy.createHTML('');\n }\n }\n if (freeze) {\n freeze(cfg);\n }\n CONFIG = cfg;\n };\n const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, [\n 'mi',\n 'mo',\n 'mn',\n 'ms',\n 'mtext'\n ]);\n const HTML_INTEGRATION_POINTS = addToSet({}, [\n 'foreignobject',\n 'desc',\n 'title',\n 'annotation-xml'\n ]);\n const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [\n 'title',\n 'style',\n 'font',\n 'a',\n 'script'\n ]);\n const ALL_SVG_TAGS = addToSet({}, svg$1);\n addToSet(ALL_SVG_TAGS, svgFilters);\n addToSet(ALL_SVG_TAGS, svgDisallowed);\n const ALL_MATHML_TAGS = addToSet({}, mathMl$1);\n addToSet(ALL_MATHML_TAGS, mathMlDisallowed);\n const _checkValidNamespace = function _checkValidNamespace(element) {\n let parent = getParentNode(element);\n if (!parent || !parent.tagName) {\n parent = {\n namespaceURI: NAMESPACE,\n tagName: 'template'\n };\n }\n const tagName = stringToLowerCase(element.tagName);\n const parentTagName = stringToLowerCase(parent.tagName);\n if (!ALLOWED_NAMESPACES[element.namespaceURI]) {\n return false;\n }\n if (element.namespaceURI === SVG_NAMESPACE) {\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'svg';\n }\n if (parent.namespaceURI === MATHML_NAMESPACE) {\n return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);\n }\n return Boolean(ALL_SVG_TAGS[tagName]);\n }\n if (element.namespaceURI === MATHML_NAMESPACE) {\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'math';\n }\n if (parent.namespaceURI === SVG_NAMESPACE) {\n return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];\n }\n return Boolean(ALL_MATHML_TAGS[tagName]);\n }\n if (element.namespaceURI === HTML_NAMESPACE) {\n if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {\n return false;\n }\n if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {\n return false;\n }\n return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);\n }\n if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {\n return true;\n }\n return false;\n };\n const _forceRemove = function _forceRemove(node) {\n arrayPush(DOMPurify.removed, { element: node });\n try {\n node.parentNode.removeChild(node);\n } catch (_) {\n node.remove();\n }\n };\n const _removeAttribute = function _removeAttribute(name, node) {\n try {\n arrayPush(DOMPurify.removed, {\n attribute: node.getAttributeNode(name),\n from: node\n });\n } catch (_) {\n arrayPush(DOMPurify.removed, {\n attribute: null,\n from: node\n });\n }\n node.removeAttribute(name);\n if (name === 'is' && !ALLOWED_ATTR[name]) {\n if (RETURN_DOM || RETURN_DOM_FRAGMENT) {\n try {\n _forceRemove(node);\n } catch (_) {\n }\n } else {\n try {\n node.setAttribute(name, '');\n } catch (_) {\n }\n }\n }\n };\n const _initDocument = function _initDocument(dirty) {\n let doc;\n let leadingWhitespace;\n if (FORCE_BODY) {\n dirty = '' + dirty;\n } else {\n const matches = stringMatch(dirty, /^[\\r\\n\\t ]+/);\n leadingWhitespace = matches && matches[0];\n }\n if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {\n dirty = '' + dirty + '';\n }\n const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;\n if (NAMESPACE === HTML_NAMESPACE) {\n try {\n doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);\n } catch (_) {\n }\n }\n if (!doc || !doc.documentElement) {\n doc = implementation.createDocument(NAMESPACE, 'template', null);\n try {\n doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;\n } catch (_) {\n }\n }\n const body = doc.body || doc.documentElement;\n if (dirty && leadingWhitespace) {\n body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);\n }\n if (NAMESPACE === HTML_NAMESPACE) {\n return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];\n }\n return WHOLE_DOCUMENT ? doc.documentElement : body;\n };\n const _createIterator = function _createIterator(root) {\n return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);\n };\n const _isClobbered = function _isClobbered(elm) {\n return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');\n };\n const _isNode = function _isNode(object) {\n return typeof Node === 'object' ? object instanceof Node : object && typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';\n };\n const _executeHook = function _executeHook(entryPoint, currentNode, data) {\n if (!hooks[entryPoint]) {\n return;\n }\n arrayForEach(hooks[entryPoint], hook => {\n hook.call(DOMPurify, currentNode, data, CONFIG);\n });\n };\n const _sanitizeElements = function _sanitizeElements(currentNode) {\n let content;\n _executeHook('beforeSanitizeElements', currentNode, null);\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n const tagName = transformCaseFunc(currentNode.nodeName);\n _executeHook('uponSanitizeElement', currentNode, {\n tagName,\n allowedTags: ALLOWED_TAGS\n });\n if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\\w]/g, currentNode.innerHTML) && regExpTest(/<[/\\w]/g, currentNode.textContent)) {\n _forceRemove(currentNode);\n return true;\n }\n if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {\n if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {\n if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName))\n return false;\n if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName))\n return false;\n }\n if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {\n const parentNode = getParentNode(currentNode) || currentNode.parentNode;\n const childNodes = getChildNodes(currentNode) || currentNode.childNodes;\n if (childNodes && parentNode) {\n const childCount = childNodes.length;\n for (let i = childCount - 1; i >= 0; --i) {\n parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));\n }\n }\n }\n _forceRemove(currentNode);\n return true;\n }\n if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\\/no(script|embed|frames)/i, currentNode.innerHTML)) {\n _forceRemove(currentNode);\n return true;\n }\n if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {\n content = currentNode.textContent;\n content = stringReplace(content, MUSTACHE_EXPR, ' ');\n content = stringReplace(content, ERB_EXPR, ' ');\n content = stringReplace(content, TMPLIT_EXPR, ' ');\n if (currentNode.textContent !== content) {\n arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });\n currentNode.textContent = content;\n }\n }\n _executeHook('afterSanitizeElements', currentNode, null);\n return false;\n };\n const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {\n if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {\n return false;\n }\n if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName));\n else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName));\n else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {\n if (_basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value)));\n else {\n return false;\n }\n } else if (URI_SAFE_ATTRIBUTES[lcName]);\n else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, '')));\n else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]);\n else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, '')));\n else if (value) {\n return false;\n } else ;\n return true;\n };\n const _basicCustomElementTest = function _basicCustomElementTest(tagName) {\n return tagName.indexOf('-') > 0;\n };\n const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {\n let attr;\n let value;\n let lcName;\n let l;\n _executeHook('beforeSanitizeAttributes', currentNode, null);\n const {attributes} = currentNode;\n if (!attributes) {\n return;\n }\n const hookEvent = {\n attrName: '',\n attrValue: '',\n keepAttr: true,\n allowedAttributes: ALLOWED_ATTR\n };\n l = attributes.length;\n while (l--) {\n attr = attributes[l];\n const {name, namespaceURI} = attr;\n value = name === 'value' ? attr.value : stringTrim(attr.value);\n const initValue = value;\n lcName = transformCaseFunc(name);\n hookEvent.attrName = lcName;\n hookEvent.attrValue = value;\n hookEvent.keepAttr = true;\n hookEvent.forceKeepAttr = undefined;\n _executeHook('uponSanitizeAttribute', currentNode, hookEvent);\n value = hookEvent.attrValue;\n if (hookEvent.forceKeepAttr) {\n continue;\n }\n if (!hookEvent.keepAttr) {\n _removeAttribute(name, currentNode);\n continue;\n }\n if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\\/>/i, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n if (SAFE_FOR_TEMPLATES) {\n value = stringReplace(value, MUSTACHE_EXPR, ' ');\n value = stringReplace(value, ERB_EXPR, ' ');\n value = stringReplace(value, TMPLIT_EXPR, ' ');\n }\n const lcTag = transformCaseFunc(currentNode.nodeName);\n if (!_isValidAttribute(lcTag, lcName, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {\n _removeAttribute(name, currentNode);\n value = SANITIZE_NAMED_PROPS_PREFIX + value;\n }\n if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {\n if (namespaceURI);\n else {\n switch (trustedTypes.getAttributeType(lcTag, lcName)) {\n case 'TrustedHTML': {\n value = trustedTypesPolicy.createHTML(value);\n break;\n }\n case 'TrustedScriptURL': {\n value = trustedTypesPolicy.createScriptURL(value);\n break;\n }\n }\n }\n }\n if (value !== initValue) {\n try {\n if (namespaceURI) {\n currentNode.setAttributeNS(namespaceURI, name, value);\n } else {\n currentNode.setAttribute(name, value);\n }\n } catch (_) {\n _removeAttribute(name, currentNode);\n }\n }\n }\n _executeHook('afterSanitizeAttributes', currentNode, null);\n };\n const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {\n let shadowNode;\n const shadowIterator = _createIterator(fragment);\n _executeHook('beforeSanitizeShadowDOM', fragment, null);\n while (shadowNode = shadowIterator.nextNode()) {\n _executeHook('uponSanitizeShadowNode', shadowNode, null);\n if (_sanitizeElements(shadowNode)) {\n continue;\n }\n if (shadowNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(shadowNode.content);\n }\n _sanitizeAttributes(shadowNode);\n }\n _executeHook('afterSanitizeShadowDOM', fragment, null);\n };\n DOMPurify.sanitize = function (dirty) {\n let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n let body;\n let importedNode;\n let currentNode;\n let returnNode;\n IS_EMPTY_INPUT = !dirty;\n if (IS_EMPTY_INPUT) {\n dirty = '';\n }\n if (typeof dirty !== 'string' && !_isNode(dirty)) {\n if (typeof dirty.toString === 'function') {\n dirty = dirty.toString();\n if (typeof dirty !== 'string') {\n throw typeErrorCreate('dirty is not a string, aborting');\n }\n } else {\n throw typeErrorCreate('toString is not a function');\n }\n }\n if (!DOMPurify.isSupported) {\n return dirty;\n }\n if (!SET_CONFIG) {\n _parseConfig(cfg);\n }\n DOMPurify.removed = [];\n if (typeof dirty === 'string') {\n IN_PLACE = false;\n }\n if (IN_PLACE) {\n if (dirty.nodeName) {\n const tagName = transformCaseFunc(dirty.nodeName);\n if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {\n throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');\n }\n }\n } else if (dirty instanceof Node) {\n body = _initDocument('');\n importedNode = body.ownerDocument.importNode(dirty, true);\n if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {\n body = importedNode;\n } else if (importedNode.nodeName === 'HTML') {\n body = importedNode;\n } else {\n body.appendChild(importedNode);\n }\n } else {\n if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf('<') === -1) {\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;\n }\n body = _initDocument(dirty);\n if (!body) {\n return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';\n }\n }\n if (body && FORCE_BODY) {\n _forceRemove(body.firstChild);\n }\n const nodeIterator = _createIterator(IN_PLACE ? dirty : body);\n while (currentNode = nodeIterator.nextNode()) {\n if (_sanitizeElements(currentNode)) {\n continue;\n }\n if (currentNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(currentNode.content);\n }\n _sanitizeAttributes(currentNode);\n }\n if (IN_PLACE) {\n return dirty;\n }\n if (RETURN_DOM) {\n if (RETURN_DOM_FRAGMENT) {\n returnNode = createDocumentFragment.call(body.ownerDocument);\n while (body.firstChild) {\n returnNode.appendChild(body.firstChild);\n }\n } else {\n returnNode = body;\n }\n if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {\n returnNode = importNode.call(originalDocument, returnNode, true);\n }\n return returnNode;\n }\n let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;\n if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {\n serializedHTML = '\\n' + serializedHTML;\n }\n if (SAFE_FOR_TEMPLATES) {\n serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR, ' ');\n serializedHTML = stringReplace(serializedHTML, ERB_EXPR, ' ');\n serializedHTML = stringReplace(serializedHTML, TMPLIT_EXPR, ' ');\n }\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;\n };\n DOMPurify.setConfig = function (cfg) {\n _parseConfig(cfg);\n SET_CONFIG = true;\n };\n DOMPurify.clearConfig = function () {\n CONFIG = null;\n SET_CONFIG = false;\n };\n DOMPurify.isValidAttribute = function (tag, attr, value) {\n if (!CONFIG) {\n _parseConfig({});\n }\n const lcTag = transformCaseFunc(tag);\n const lcName = transformCaseFunc(attr);\n return _isValidAttribute(lcTag, lcName, value);\n };\n DOMPurify.addHook = function (entryPoint, hookFunction) {\n if (typeof hookFunction !== 'function') {\n return;\n }\n hooks[entryPoint] = hooks[entryPoint] || [];\n arrayPush(hooks[entryPoint], hookFunction);\n };\n DOMPurify.removeHook = function (entryPoint) {\n if (hooks[entryPoint]) {\n return arrayPop(hooks[entryPoint]);\n }\n };\n DOMPurify.removeHooks = function (entryPoint) {\n if (hooks[entryPoint]) {\n hooks[entryPoint] = [];\n }\n };\n DOMPurify.removeAllHooks = function () {\n hooks = {};\n };\n return DOMPurify;\n }\n var purify = createDOMPurify();\n\n const each$4 = Tools.each, trim = Tools.trim;\n const queryParts = [\n 'source',\n 'protocol',\n 'authority',\n 'userInfo',\n 'user',\n 'password',\n 'host',\n 'port',\n 'relative',\n 'path',\n 'directory',\n 'file',\n 'query',\n 'anchor'\n ];\n const DEFAULT_PORTS = {\n ftp: 21,\n http: 80,\n https: 443,\n mailto: 25\n };\n const safeSvgDataUrlElements = [\n 'img',\n 'video'\n ];\n const blockSvgDataUris = (allowSvgDataUrls, tagName) => {\n if (isNonNullable(allowSvgDataUrls)) {\n return !allowSvgDataUrls;\n } else {\n return isNonNullable(tagName) ? !contains$2(safeSvgDataUrlElements, tagName) : true;\n }\n };\n const decodeUri = encodedUri => {\n try {\n return decodeURIComponent(encodedUri);\n } catch (ex) {\n return unescape(encodedUri);\n }\n };\n const isInvalidUri = (settings, uri, tagName) => {\n const decodedUri = decodeUri(uri).replace(/\\s/g, '');\n if (settings.allow_script_urls) {\n return false;\n } else if (/((java|vb)script|mhtml):/i.test(decodedUri)) {\n return true;\n } else if (settings.allow_html_data_urls) {\n return false;\n } else if (/^data:image\\//i.test(decodedUri)) {\n return blockSvgDataUris(settings.allow_svg_data_urls, tagName) && /^data:image\\/svg\\+xml/i.test(decodedUri);\n } else {\n return /^data:/i.test(decodedUri);\n }\n };\n class URI {\n static parseDataUri(uri) {\n let type;\n const uriComponents = decodeURIComponent(uri).split(',');\n const matches = /data:([^;]+)/.exec(uriComponents[0]);\n if (matches) {\n type = matches[1];\n }\n return {\n type,\n data: uriComponents[1]\n };\n }\n static isDomSafe(uri, context, options = {}) {\n if (options.allow_script_urls) {\n return true;\n } else {\n const decodedUri = Entities.decode(uri).replace(/[\\s\\u0000-\\u001F]+/g, '');\n return !isInvalidUri(options, decodedUri, context);\n }\n }\n static getDocumentBaseUrl(loc) {\n var _a;\n let baseUrl;\n if (loc.protocol.indexOf('http') !== 0 && loc.protocol !== 'file:') {\n baseUrl = (_a = loc.href) !== null && _a !== void 0 ? _a : '';\n } else {\n baseUrl = loc.protocol + '//' + loc.host + loc.pathname;\n }\n if (/^[^:]+:\\/\\/\\/?[^\\/]+\\//.test(baseUrl)) {\n baseUrl = baseUrl.replace(/[\\?#].*$/, '').replace(/[\\/\\\\][^\\/]+$/, '');\n if (!/[\\/\\\\]$/.test(baseUrl)) {\n baseUrl += '/';\n }\n }\n return baseUrl;\n }\n constructor(url, settings = {}) {\n this.path = '';\n this.directory = '';\n url = trim(url);\n this.settings = settings;\n const baseUri = settings.base_uri;\n const self = this;\n if (/^([\\w\\-]+):([^\\/]{2})/i.test(url) || /^\\s*#/.test(url)) {\n self.source = url;\n return;\n }\n const isProtocolRelative = url.indexOf('//') === 0;\n if (url.indexOf('/') === 0 && !isProtocolRelative) {\n url = (baseUri ? baseUri.protocol || 'http' : 'http') + '://mce_host' + url;\n }\n if (!/^[\\w\\-]*:?\\/\\//.test(url)) {\n const baseUrl = baseUri ? baseUri.path : new URI(document.location.href).directory;\n if ((baseUri === null || baseUri === void 0 ? void 0 : baseUri.protocol) === '') {\n url = '//mce_host' + self.toAbsPath(baseUrl, url);\n } else {\n const match = /([^#?]*)([#?]?.*)/.exec(url);\n if (match) {\n url = (baseUri && baseUri.protocol || 'http') + '://mce_host' + self.toAbsPath(baseUrl, match[1]) + match[2];\n }\n }\n }\n url = url.replace(/@@/g, '(mce_at)');\n const urlMatch = /^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@\\/]*):?([^:@\\/]*))?@)?(\\[[a-zA-Z0-9:.%]+\\]|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/.exec(url);\n if (urlMatch) {\n each$4(queryParts, (v, i) => {\n let part = urlMatch[i];\n if (part) {\n part = part.replace(/\\(mce_at\\)/g, '@@');\n }\n self[v] = part;\n });\n }\n if (baseUri) {\n if (!self.protocol) {\n self.protocol = baseUri.protocol;\n }\n if (!self.userInfo) {\n self.userInfo = baseUri.userInfo;\n }\n if (!self.port && self.host === 'mce_host') {\n self.port = baseUri.port;\n }\n if (!self.host || self.host === 'mce_host') {\n self.host = baseUri.host;\n }\n self.source = '';\n }\n if (isProtocolRelative) {\n self.protocol = '';\n }\n }\n setPath(path) {\n const pathMatch = /^(.*?)\\/?(\\w+)?$/.exec(path);\n if (pathMatch) {\n this.path = pathMatch[0];\n this.directory = pathMatch[1];\n this.file = pathMatch[2];\n }\n this.source = '';\n this.getURI();\n }\n toRelative(uri) {\n if (uri === './') {\n return uri;\n }\n const relativeUri = new URI(uri, { base_uri: this });\n if (relativeUri.host !== 'mce_host' && this.host !== relativeUri.host && relativeUri.host || this.port !== relativeUri.port || this.protocol !== relativeUri.protocol && relativeUri.protocol !== '') {\n return relativeUri.getURI();\n }\n const tu = this.getURI(), uu = relativeUri.getURI();\n if (tu === uu || tu.charAt(tu.length - 1) === '/' && tu.substr(0, tu.length - 1) === uu) {\n return tu;\n }\n let output = this.toRelPath(this.path, relativeUri.path);\n if (relativeUri.query) {\n output += '?' + relativeUri.query;\n }\n if (relativeUri.anchor) {\n output += '#' + relativeUri.anchor;\n }\n return output;\n }\n toAbsolute(uri, noHost) {\n const absoluteUri = new URI(uri, { base_uri: this });\n return absoluteUri.getURI(noHost && this.isSameOrigin(absoluteUri));\n }\n isSameOrigin(uri) {\n if (this.host == uri.host && this.protocol == uri.protocol) {\n if (this.port == uri.port) {\n return true;\n }\n const defaultPort = this.protocol ? DEFAULT_PORTS[this.protocol] : null;\n if (defaultPort && (this.port || defaultPort) == (uri.port || defaultPort)) {\n return true;\n }\n }\n return false;\n }\n toRelPath(base, path) {\n let breakPoint = 0, out = '', i, l;\n const normalizedBase = base.substring(0, base.lastIndexOf('/')).split('/');\n const items = path.split('/');\n if (normalizedBase.length >= items.length) {\n for (i = 0, l = normalizedBase.length; i < l; i++) {\n if (i >= items.length || normalizedBase[i] !== items[i]) {\n breakPoint = i + 1;\n break;\n }\n }\n }\n if (normalizedBase.length < items.length) {\n for (i = 0, l = items.length; i < l; i++) {\n if (i >= normalizedBase.length || normalizedBase[i] !== items[i]) {\n breakPoint = i + 1;\n break;\n }\n }\n }\n if (breakPoint === 1) {\n return path;\n }\n for (i = 0, l = normalizedBase.length - (breakPoint - 1); i < l; i++) {\n out += '../';\n }\n for (i = breakPoint - 1, l = items.length; i < l; i++) {\n if (i !== breakPoint - 1) {\n out += '/' + items[i];\n } else {\n out += items[i];\n }\n }\n return out;\n }\n toAbsPath(base, path) {\n let nb = 0;\n const tr = /\\/$/.test(path) ? '/' : '';\n const normalizedBase = base.split('/');\n const normalizedPath = path.split('/');\n const baseParts = [];\n each$4(normalizedBase, k => {\n if (k) {\n baseParts.push(k);\n }\n });\n const pathParts = [];\n for (let i = normalizedPath.length - 1; i >= 0; i--) {\n if (normalizedPath[i].length === 0 || normalizedPath[i] === '.') {\n continue;\n }\n if (normalizedPath[i] === '..') {\n nb++;\n continue;\n }\n if (nb > 0) {\n nb--;\n continue;\n }\n pathParts.push(normalizedPath[i]);\n }\n const i = baseParts.length - nb;\n let outPath;\n if (i <= 0) {\n outPath = reverse(pathParts).join('/');\n } else {\n outPath = baseParts.slice(0, i).join('/') + '/' + reverse(pathParts).join('/');\n }\n if (outPath.indexOf('/') !== 0) {\n outPath = '/' + outPath;\n }\n if (tr && outPath.lastIndexOf('/') !== outPath.length - 1) {\n outPath += tr;\n }\n return outPath;\n }\n getURI(noProtoHost = false) {\n let s;\n if (!this.source || noProtoHost) {\n s = '';\n if (!noProtoHost) {\n if (this.protocol) {\n s += this.protocol + '://';\n } else {\n s += '//';\n }\n if (this.userInfo) {\n s += this.userInfo + '@';\n }\n if (this.host) {\n s += this.host;\n }\n if (this.port) {\n s += ':' + this.port;\n }\n }\n if (this.path) {\n s += this.path;\n }\n if (this.query) {\n s += '?' + this.query;\n }\n if (this.anchor) {\n s += '#' + this.anchor;\n }\n this.source = s;\n }\n return this.source;\n }\n }\n\n const filteredUrlAttrs = Tools.makeMap('src,href,data,background,action,formaction,poster,xlink:href');\n const internalElementAttr = 'data-mce-type';\n let uid = 0;\n const processNode = (node, settings, schema, scope, evt) => {\n var _a, _b, _c, _d;\n const validate = settings.validate;\n const specialElements = schema.getSpecialElements();\n if (node.nodeType === COMMENT && !settings.allow_conditional_comments && /^\\[if/i.test((_a = node.nodeValue) !== null && _a !== void 0 ? _a : '')) {\n node.nodeValue = ' ' + node.nodeValue;\n }\n const lcTagName = (_b = evt === null || evt === void 0 ? void 0 : evt.tagName) !== null && _b !== void 0 ? _b : node.nodeName.toLowerCase();\n if (scope !== 'html' && schema.isValid(scope)) {\n if (isNonNullable(evt)) {\n evt.allowedTags[lcTagName] = true;\n }\n return;\n }\n if (node.nodeType !== ELEMENT || lcTagName === 'body') {\n return;\n }\n const element = SugarElement.fromDom(node);\n const isInternalElement = has$1(element, internalElementAttr);\n const bogus = get$9(element, 'data-mce-bogus');\n if (!isInternalElement && isString(bogus)) {\n if (bogus === 'all') {\n remove$5(element);\n } else {\n unwrap(element);\n }\n return;\n }\n const rule = schema.getElementRule(lcTagName);\n if (validate && !rule) {\n if (has$2(specialElements, lcTagName)) {\n remove$5(element);\n } else {\n unwrap(element);\n }\n return;\n } else {\n if (isNonNullable(evt)) {\n evt.allowedTags[lcTagName] = true;\n }\n }\n if (validate && rule && !isInternalElement) {\n each$e((_c = rule.attributesForced) !== null && _c !== void 0 ? _c : [], attr => {\n set$3(element, attr.name, attr.value === '{$uid}' ? `mce_${ uid++ }` : attr.value);\n });\n each$e((_d = rule.attributesDefault) !== null && _d !== void 0 ? _d : [], attr => {\n if (!has$1(element, attr.name)) {\n set$3(element, attr.name, attr.value === '{$uid}' ? `mce_${ uid++ }` : attr.value);\n }\n });\n if (rule.attributesRequired && !exists(rule.attributesRequired, attr => has$1(element, attr))) {\n unwrap(element);\n return;\n }\n if (rule.removeEmptyAttrs && hasNone(element)) {\n unwrap(element);\n return;\n }\n if (rule.outputName && rule.outputName !== lcTagName) {\n mutate(element, rule.outputName);\n }\n }\n };\n const processAttr = (ele, settings, schema, scope, evt) => {\n const tagName = ele.tagName.toLowerCase();\n const {attrName, attrValue} = evt;\n evt.keepAttr = shouldKeepAttribute(settings, schema, scope, tagName, attrName, attrValue);\n if (evt.keepAttr) {\n evt.allowedAttributes[attrName] = true;\n if (isBooleanAttribute(attrName, schema)) {\n evt.attrValue = attrName;\n }\n if (settings.allow_svg_data_urls && startsWith(attrValue, 'data:image/svg+xml')) {\n evt.forceKeepAttr = true;\n }\n } else if (isRequiredAttributeOfInternalElement(ele, attrName)) {\n evt.forceKeepAttr = true;\n }\n };\n const shouldKeepAttribute = (settings, schema, scope, tagName, attrName, attrValue) => {\n if (scope !== 'html' && !isNonHtmlElementRootName(tagName)) {\n return true;\n }\n return !(attrName in filteredUrlAttrs && isInvalidUri(settings, attrValue, tagName)) && (!settings.validate || schema.isValid(tagName, attrName) || startsWith(attrName, 'data-') || startsWith(attrName, 'aria-'));\n };\n const isRequiredAttributeOfInternalElement = (ele, attrName) => ele.hasAttribute(internalElementAttr) && (attrName === 'id' || attrName === 'class' || attrName === 'style');\n const isBooleanAttribute = (attrName, schema) => attrName in schema.getBoolAttrs();\n const filterAttributes = (ele, settings, schema, scope) => {\n const {attributes} = ele;\n for (let i = attributes.length - 1; i >= 0; i--) {\n const attr = attributes[i];\n const attrName = attr.name;\n const attrValue = attr.value;\n if (!shouldKeepAttribute(settings, schema, scope, ele.tagName.toLowerCase(), attrName, attrValue) && !isRequiredAttributeOfInternalElement(ele, attrName)) {\n ele.removeAttribute(attrName);\n } else if (isBooleanAttribute(attrName, schema)) {\n ele.setAttribute(attrName, attrName);\n }\n }\n };\n const setupPurify = (settings, schema, namespaceTracker) => {\n const purify$1 = purify();\n purify$1.addHook('uponSanitizeElement', (ele, evt) => {\n processNode(ele, settings, schema, namespaceTracker.track(ele), evt);\n });\n purify$1.addHook('uponSanitizeAttribute', (ele, evt) => {\n processAttr(ele, settings, schema, namespaceTracker.current(), evt);\n });\n return purify$1;\n };\n const getPurifyConfig = (settings, mimeType) => {\n const basePurifyConfig = {\n IN_PLACE: true,\n ALLOW_UNKNOWN_PROTOCOLS: true,\n ALLOWED_TAGS: [\n '#comment',\n '#cdata-section',\n 'body'\n ],\n ALLOWED_ATTR: []\n };\n const config = { ...basePurifyConfig };\n config.PARSER_MEDIA_TYPE = mimeType;\n if (settings.allow_script_urls) {\n config.ALLOWED_URI_REGEXP = /.*/;\n } else if (settings.allow_html_data_urls) {\n config.ALLOWED_URI_REGEXP = /^(?!(\\w+script|mhtml):)/i;\n }\n return config;\n };\n const sanitizeNamespaceElement = ele => {\n const xlinkAttrs = [\n 'type',\n 'href',\n 'role',\n 'arcrole',\n 'title',\n 'show',\n 'actuate',\n 'label',\n 'from',\n 'to'\n ].map(name => `xlink:${ name }`);\n const config = {\n IN_PLACE: true,\n USE_PROFILES: {\n html: true,\n svg: true,\n svgFilters: true\n },\n ALLOWED_ATTR: xlinkAttrs\n };\n purify().sanitize(ele, config);\n return ele.innerHTML;\n };\n const getSanitizer = (settings, schema) => {\n const namespaceTracker = createNamespaceTracker();\n if (settings.sanitize) {\n const purify = setupPurify(settings, schema, namespaceTracker);\n const sanitizeHtmlElement = (body, mimeType) => {\n purify.sanitize(body, getPurifyConfig(settings, mimeType));\n purify.removed = [];\n namespaceTracker.reset();\n };\n return {\n sanitizeHtmlElement,\n sanitizeNamespaceElement\n };\n } else {\n const sanitizeHtmlElement = (body, _mimeType) => {\n const nodeIterator = document.createNodeIterator(body, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT);\n let node;\n while (node = nodeIterator.nextNode()) {\n const currentScope = namespaceTracker.track(node);\n processNode(node, settings, schema, currentScope);\n if (isElement$6(node)) {\n filterAttributes(node, settings, schema, currentScope);\n }\n }\n namespaceTracker.reset();\n };\n const sanitizeNamespaceElement = noop;\n return {\n sanitizeHtmlElement,\n sanitizeNamespaceElement\n };\n }\n };\n\n const makeMap = Tools.makeMap, extend$1 = Tools.extend;\n const transferChildren = (parent, nativeParent, specialElements, nsSanitizer) => {\n const parentName = parent.name;\n const isSpecial = parentName in specialElements && parentName !== 'title' && parentName !== 'textarea';\n const childNodes = nativeParent.childNodes;\n for (let ni = 0, nl = childNodes.length; ni < nl; ni++) {\n const nativeChild = childNodes[ni];\n const child = new AstNode(nativeChild.nodeName.toLowerCase(), nativeChild.nodeType);\n if (isElement$6(nativeChild)) {\n const attributes = nativeChild.attributes;\n for (let ai = 0, al = attributes.length; ai < al; ai++) {\n const attr = attributes[ai];\n child.attr(attr.name, attr.value);\n }\n if (isNonHtmlElementRootName(child.name)) {\n nsSanitizer(nativeChild);\n child.value = nativeChild.innerHTML;\n }\n } else if (isText$a(nativeChild)) {\n child.value = nativeChild.data;\n if (isSpecial) {\n child.raw = true;\n }\n } else if (isComment(nativeChild) || isCData(nativeChild) || isPi(nativeChild)) {\n child.value = nativeChild.data;\n }\n if (!isNonHtmlElementRootName(child.name)) {\n transferChildren(child, nativeChild, specialElements, nsSanitizer);\n }\n parent.append(child);\n }\n };\n const walkTree = (root, preprocessors, postprocessors) => {\n const traverseOrder = [];\n for (let node = root, lastNode = node; node; lastNode = node, node = node.walk()) {\n const tempNode = node;\n each$e(preprocessors, preprocess => preprocess(tempNode));\n if (isNullable(tempNode.parent) && tempNode !== root) {\n node = lastNode;\n } else {\n traverseOrder.push(tempNode);\n }\n }\n for (let i = traverseOrder.length - 1; i >= 0; i--) {\n const node = traverseOrder[i];\n each$e(postprocessors, postprocess => postprocess(node));\n }\n };\n const whitespaceCleaner = (root, schema, settings, args) => {\n const validate = settings.validate;\n const nonEmptyElements = schema.getNonEmptyElements();\n const whitespaceElements = schema.getWhitespaceElements();\n const blockElements = extend$1(makeMap('script,style,head,html,body,title,meta,param'), schema.getBlockElements());\n const textRootBlockElements = getTextRootBlockElements(schema);\n const allWhiteSpaceRegExp = /[ \\t\\r\\n]+/g;\n const startWhiteSpaceRegExp = /^[ \\t\\r\\n]+/;\n const endWhiteSpaceRegExp = /[ \\t\\r\\n]+$/;\n const hasWhitespaceParent = node => {\n let tempNode = node.parent;\n while (isNonNullable(tempNode)) {\n if (tempNode.name in whitespaceElements) {\n return true;\n } else {\n tempNode = tempNode.parent;\n }\n }\n return false;\n };\n const isTextRootBlockEmpty = node => {\n let tempNode = node;\n while (isNonNullable(tempNode)) {\n if (tempNode.name in textRootBlockElements) {\n return isEmpty(schema, nonEmptyElements, whitespaceElements, tempNode);\n } else {\n tempNode = tempNode.parent;\n }\n }\n return false;\n };\n const isBlock = node => node.name in blockElements || isTransparentAstBlock(schema, node) || isNonHtmlElementRootName(node.name) && node.parent === root;\n const isAtEdgeOfBlock = (node, start) => {\n const neighbour = start ? node.prev : node.next;\n if (isNonNullable(neighbour) || isNullable(node.parent)) {\n return false;\n }\n return isBlock(node.parent) && (node.parent !== root || args.isRootContent === true);\n };\n const preprocess = node => {\n var _a;\n if (node.type === 3) {\n if (!hasWhitespaceParent(node)) {\n let text = (_a = node.value) !== null && _a !== void 0 ? _a : '';\n text = text.replace(allWhiteSpaceRegExp, ' ');\n if (isLineBreakNode(node.prev, isBlock) || isAtEdgeOfBlock(node, true)) {\n text = text.replace(startWhiteSpaceRegExp, '');\n }\n if (text.length === 0) {\n node.remove();\n } else {\n node.value = text;\n }\n }\n }\n };\n const postprocess = node => {\n var _a;\n if (node.type === 1) {\n const elementRule = schema.getElementRule(node.name);\n if (validate && elementRule) {\n const isNodeEmpty = isEmpty(schema, nonEmptyElements, whitespaceElements, node);\n if (elementRule.paddInEmptyBlock && isNodeEmpty && isTextRootBlockEmpty(node)) {\n paddEmptyNode(settings, args, isBlock, node);\n } else if (elementRule.removeEmpty && isNodeEmpty) {\n if (isBlock(node)) {\n node.remove();\n } else {\n node.unwrap();\n }\n } else if (elementRule.paddEmpty && (isNodeEmpty || isPaddedWithNbsp(node))) {\n paddEmptyNode(settings, args, isBlock, node);\n }\n }\n } else if (node.type === 3) {\n if (!hasWhitespaceParent(node)) {\n let text = (_a = node.value) !== null && _a !== void 0 ? _a : '';\n if (node.next && isBlock(node.next) || isAtEdgeOfBlock(node, false)) {\n text = text.replace(endWhiteSpaceRegExp, '');\n }\n if (text.length === 0) {\n node.remove();\n } else {\n node.value = text;\n }\n }\n }\n };\n return [\n preprocess,\n postprocess\n ];\n };\n const getRootBlockName = (settings, args) => {\n var _a;\n const name = (_a = args.forced_root_block) !== null && _a !== void 0 ? _a : settings.forced_root_block;\n if (name === false) {\n return '';\n } else if (name === true) {\n return 'p';\n } else {\n return name;\n }\n };\n const DomParser = (settings = {}, schema = Schema()) => {\n const nodeFilterRegistry = create$8();\n const attributeFilterRegistry = create$8();\n const defaultedSettings = {\n validate: true,\n root_name: 'body',\n sanitize: true,\n ...settings\n };\n const parser = new DOMParser();\n const sanitizer = getSanitizer(defaultedSettings, schema);\n const parseAndSanitizeWithContext = (html, rootName, format = 'html') => {\n const mimeType = format === 'xhtml' ? 'application/xhtml+xml' : 'text/html';\n const isSpecialRoot = has$2(schema.getSpecialElements(), rootName.toLowerCase());\n const content = isSpecialRoot ? `<${ rootName }>${ html }` : html;\n const wrappedHtml = format === 'xhtml' ? `${ content }` : `${ content }`;\n const body = parser.parseFromString(wrappedHtml, mimeType).body;\n sanitizer.sanitizeHtmlElement(body, mimeType);\n return isSpecialRoot ? body.firstChild : body;\n };\n const addNodeFilter = nodeFilterRegistry.addFilter;\n const getNodeFilters = nodeFilterRegistry.getFilters;\n const removeNodeFilter = nodeFilterRegistry.removeFilter;\n const addAttributeFilter = attributeFilterRegistry.addFilter;\n const getAttributeFilters = attributeFilterRegistry.getFilters;\n const removeAttributeFilter = attributeFilterRegistry.removeFilter;\n const findInvalidChildren = (node, invalidChildren) => {\n if (isInvalid(schema, node)) {\n invalidChildren.push(node);\n }\n };\n const isWrappableNode = (blockElements, node) => {\n const isInternalElement = isString(node.attr(internalElementAttr));\n const isInlineElement = node.type === 1 && (!has$2(blockElements, node.name) && !isTransparentAstBlock(schema, node)) && !isNonHtmlElementRootName(node.name);\n return node.type === 3 || isInlineElement && !isInternalElement;\n };\n const addRootBlocks = (rootNode, rootBlockName) => {\n const blockElements = extend$1(makeMap('script,style,head,html,body,title,meta,param'), schema.getBlockElements());\n const startWhiteSpaceRegExp = /^[ \\t\\r\\n]+/;\n const endWhiteSpaceRegExp = /[ \\t\\r\\n]+$/;\n let node = rootNode.firstChild, rootBlockNode = null;\n const trim = rootBlock => {\n var _a, _b;\n if (rootBlock) {\n node = rootBlock.firstChild;\n if (node && node.type === 3) {\n node.value = (_a = node.value) === null || _a === void 0 ? void 0 : _a.replace(startWhiteSpaceRegExp, '');\n }\n node = rootBlock.lastChild;\n if (node && node.type === 3) {\n node.value = (_b = node.value) === null || _b === void 0 ? void 0 : _b.replace(endWhiteSpaceRegExp, '');\n }\n }\n };\n if (!schema.isValidChild(rootNode.name, rootBlockName.toLowerCase())) {\n return;\n }\n while (node) {\n const next = node.next;\n if (isWrappableNode(blockElements, node)) {\n if (!rootBlockNode) {\n rootBlockNode = new AstNode(rootBlockName, 1);\n rootBlockNode.attr(defaultedSettings.forced_root_block_attrs);\n rootNode.insert(rootBlockNode, node);\n rootBlockNode.append(node);\n } else {\n rootBlockNode.append(node);\n }\n } else {\n trim(rootBlockNode);\n rootBlockNode = null;\n }\n node = next;\n }\n trim(rootBlockNode);\n };\n const parse = (html, args = {}) => {\n var _a;\n const validate = defaultedSettings.validate;\n const rootName = (_a = args.context) !== null && _a !== void 0 ? _a : defaultedSettings.root_name;\n const element = parseAndSanitizeWithContext(html, rootName, args.format);\n updateChildren(schema, element);\n const rootNode = new AstNode(rootName, 11);\n transferChildren(rootNode, element, schema.getSpecialElements(), sanitizer.sanitizeNamespaceElement);\n element.innerHTML = '';\n const [whitespacePre, whitespacePost] = whitespaceCleaner(rootNode, schema, defaultedSettings, args);\n const invalidChildren = [];\n const invalidFinder = validate ? node => findInvalidChildren(node, invalidChildren) : noop;\n const matches = {\n nodes: {},\n attributes: {}\n };\n const matchFinder = node => matchNode$1(getNodeFilters(), getAttributeFilters(), node, matches);\n walkTree(rootNode, [\n whitespacePre,\n matchFinder\n ], [\n whitespacePost,\n invalidFinder\n ]);\n invalidChildren.reverse();\n if (validate && invalidChildren.length > 0) {\n if (args.context) {\n const {\n pass: topLevelChildren,\n fail: otherChildren\n } = partition$2(invalidChildren, child => child.parent === rootNode);\n cleanInvalidNodes(otherChildren, schema, rootNode, matchFinder);\n args.invalid = topLevelChildren.length > 0;\n } else {\n cleanInvalidNodes(invalidChildren, schema, rootNode, matchFinder);\n }\n }\n const rootBlockName = getRootBlockName(defaultedSettings, args);\n if (rootBlockName && (rootNode.name === 'body' || args.isRootContent)) {\n addRootBlocks(rootNode, rootBlockName);\n }\n if (!args.invalid) {\n runFilters(matches, args);\n }\n return rootNode;\n };\n const exports = {\n schema,\n addAttributeFilter,\n getAttributeFilters,\n removeAttributeFilter,\n addNodeFilter,\n getNodeFilters,\n removeNodeFilter,\n parse\n };\n register$4(exports, defaultedSettings);\n register$5(exports, defaultedSettings, schema);\n return exports;\n };\n\n const serializeContent = content => isTreeNode(content) ? HtmlSerializer({ validate: false }).serialize(content) : content;\n const withSerializedContent = (content, fireEvent, parserSettings) => {\n const serializedContent = serializeContent(content);\n const eventArgs = fireEvent(serializedContent);\n if (eventArgs.isDefaultPrevented()) {\n return eventArgs;\n } else if (isTreeNode(content)) {\n if (eventArgs.content !== serializedContent) {\n const rootNode = DomParser({\n validate: false,\n forced_root_block: false,\n ...parserSettings\n }).parse(eventArgs.content, { context: content.name });\n return {\n ...eventArgs,\n content: rootNode\n };\n } else {\n return {\n ...eventArgs,\n content\n };\n }\n } else {\n return eventArgs;\n }\n };\n const preProcessGetContent = (editor, args) => {\n if (args.no_events) {\n return Result.value(args);\n } else {\n const eventArgs = fireBeforeGetContent(editor, args);\n if (eventArgs.isDefaultPrevented()) {\n return Result.error(fireGetContent(editor, {\n content: '',\n ...eventArgs\n }).content);\n } else {\n return Result.value(eventArgs);\n }\n }\n };\n const postProcessGetContent = (editor, content, args) => {\n if (args.no_events) {\n return content;\n } else {\n const processedEventArgs = withSerializedContent(content, content => fireGetContent(editor, {\n ...args,\n content\n }), {\n sanitize: shouldSanitizeXss(editor),\n sandbox_iframes: shouldSandboxIframes(editor)\n });\n return processedEventArgs.content;\n }\n };\n const preProcessSetContent = (editor, args) => {\n if (args.no_events) {\n return Result.value(args);\n } else {\n const processedEventArgs = withSerializedContent(args.content, content => fireBeforeSetContent(editor, {\n ...args,\n content\n }), {\n sanitize: shouldSanitizeXss(editor),\n sandbox_iframes: shouldSandboxIframes(editor)\n });\n if (processedEventArgs.isDefaultPrevented()) {\n fireSetContent(editor, processedEventArgs);\n return Result.error(undefined);\n } else {\n return Result.value(processedEventArgs);\n }\n }\n };\n const postProcessSetContent = (editor, content, args) => {\n if (!args.no_events) {\n fireSetContent(editor, {\n ...args,\n content\n });\n }\n };\n\n const tableModel = (element, width, rows) => ({\n element,\n width,\n rows\n });\n const tableRow = (element, cells) => ({\n element,\n cells\n });\n const cellPosition = (x, y) => ({\n x,\n y\n });\n const getSpan = (td, key) => {\n return getOpt(td, key).bind(toInt).getOr(1);\n };\n const fillout = (table, x, y, tr, td) => {\n const rowspan = getSpan(td, 'rowspan');\n const colspan = getSpan(td, 'colspan');\n const rows = table.rows;\n for (let y2 = y; y2 < y + rowspan; y2++) {\n if (!rows[y2]) {\n rows[y2] = tableRow(deep$1(tr), []);\n }\n for (let x2 = x; x2 < x + colspan; x2++) {\n const cells = rows[y2].cells;\n cells[x2] = y2 === y && x2 === x ? td : shallow$1(td);\n }\n }\n };\n const cellExists = (table, x, y) => {\n const rows = table.rows;\n const cells = rows[y] ? rows[y].cells : [];\n return !!cells[x];\n };\n const skipCellsX = (table, x, y) => {\n while (cellExists(table, x, y)) {\n x++;\n }\n return x;\n };\n const getWidth = rows => {\n return foldl(rows, (acc, row) => {\n return row.cells.length > acc ? row.cells.length : acc;\n }, 0);\n };\n const findElementPos = (table, element) => {\n const rows = table.rows;\n for (let y = 0; y < rows.length; y++) {\n const cells = rows[y].cells;\n for (let x = 0; x < cells.length; x++) {\n if (eq(cells[x], element)) {\n return Optional.some(cellPosition(x, y));\n }\n }\n }\n return Optional.none();\n };\n const extractRows = (table, sx, sy, ex, ey) => {\n const newRows = [];\n const rows = table.rows;\n for (let y = sy; y <= ey; y++) {\n const cells = rows[y].cells;\n const slice = sx < ex ? cells.slice(sx, ex + 1) : cells.slice(ex, sx + 1);\n newRows.push(tableRow(rows[y].element, slice));\n }\n return newRows;\n };\n const subTable = (table, startPos, endPos) => {\n const sx = startPos.x, sy = startPos.y;\n const ex = endPos.x, ey = endPos.y;\n const newRows = sy < ey ? extractRows(table, sx, sy, ex, ey) : extractRows(table, sx, ey, ex, sy);\n return tableModel(table.element, getWidth(newRows), newRows);\n };\n const createDomTable = (table, rows) => {\n const tableElement = shallow$1(table.element);\n const tableBody = SugarElement.fromTag('tbody');\n append(tableBody, rows);\n append$1(tableElement, tableBody);\n return tableElement;\n };\n const modelRowsToDomRows = table => {\n return map$3(table.rows, row => {\n const cells = map$3(row.cells, cell => {\n const td = deep$1(cell);\n remove$a(td, 'colspan');\n remove$a(td, 'rowspan');\n return td;\n });\n const tr = shallow$1(row.element);\n append(tr, cells);\n return tr;\n });\n };\n const fromDom = tableElm => {\n const table = tableModel(shallow$1(tableElm), 0, []);\n each$e(descendants(tableElm, 'tr'), (tr, y) => {\n each$e(descendants(tr, 'td,th'), (td, x) => {\n fillout(table, skipCellsX(table, x, y), y, tr, td);\n });\n });\n return tableModel(table.element, getWidth(table.rows), table.rows);\n };\n const toDom = table => {\n return createDomTable(table, modelRowsToDomRows(table));\n };\n const subsection = (table, startElement, endElement) => {\n return findElementPos(table, startElement).bind(startPos => {\n return findElementPos(table, endElement).map(endPos => {\n return subTable(table, startPos, endPos);\n });\n });\n };\n\n const findParentListContainer = parents => find$2(parents, elm => name(elm) === 'ul' || name(elm) === 'ol');\n const getFullySelectedListWrappers = (parents, rng) => find$2(parents, elm => name(elm) === 'li' && hasAllContentsSelected(elm, rng)).fold(constant([]), _li => findParentListContainer(parents).map(listCont => {\n const listElm = SugarElement.fromTag(name(listCont));\n const listStyles = filter$4(getAllRaw(listCont), (_style, name) => startsWith(name, 'list-style'));\n setAll(listElm, listStyles);\n return [\n SugarElement.fromTag('li'),\n listElm\n ];\n }).getOr([]));\n const wrap = (innerElm, elms) => {\n const wrapped = foldl(elms, (acc, elm) => {\n append$1(elm, acc);\n return elm;\n }, innerElm);\n return elms.length > 0 ? fromElements([wrapped]) : wrapped;\n };\n const directListWrappers = commonAnchorContainer => {\n if (isListItem$1(commonAnchorContainer)) {\n return parent(commonAnchorContainer).filter(isList).fold(constant([]), listElm => [\n commonAnchorContainer,\n listElm\n ]);\n } else {\n return isList(commonAnchorContainer) ? [commonAnchorContainer] : [];\n }\n };\n const getWrapElements = (rootNode, rng, schema) => {\n const commonAnchorContainer = SugarElement.fromDom(rng.commonAncestorContainer);\n const parents = parentsAndSelf(commonAnchorContainer, rootNode);\n const wrapElements = filter$5(parents, el => schema.isWrapper(name(el)));\n const listWrappers = getFullySelectedListWrappers(parents, rng);\n const allWrappers = wrapElements.concat(listWrappers.length ? listWrappers : directListWrappers(commonAnchorContainer));\n return map$3(allWrappers, shallow$1);\n };\n const emptyFragment = () => fromElements([]);\n const getFragmentFromRange = (rootNode, rng, schema) => wrap(SugarElement.fromDom(rng.cloneContents()), getWrapElements(rootNode, rng, schema));\n const getParentTable = (rootElm, cell) => ancestor$3(cell, 'table', curry(eq, rootElm));\n const getTableFragment = (rootNode, selectedTableCells) => getParentTable(rootNode, selectedTableCells[0]).bind(tableElm => {\n const firstCell = selectedTableCells[0];\n const lastCell = selectedTableCells[selectedTableCells.length - 1];\n const fullTableModel = fromDom(tableElm);\n return subsection(fullTableModel, firstCell, lastCell).map(sectionedTableModel => fromElements([toDom(sectionedTableModel)]));\n }).getOrThunk(emptyFragment);\n const getSelectionFragment = (rootNode, ranges, schema) => ranges.length > 0 && ranges[0].collapsed ? emptyFragment() : getFragmentFromRange(rootNode, ranges[0], schema);\n const read$3 = (rootNode, ranges, schema) => {\n const selectedCells = getCellsFromElementOrRanges(ranges, rootNode);\n return selectedCells.length > 0 ? getTableFragment(rootNode, selectedCells) : getSelectionFragment(rootNode, ranges, schema);\n };\n\n const isCollapsibleWhitespace = (text, index) => index >= 0 && index < text.length && isWhiteSpace(text.charAt(index));\n const getInnerText = bin => {\n return trim$2(bin.innerText);\n };\n const getContextNodeName = parentBlockOpt => parentBlockOpt.map(block => block.nodeName).getOr('div').toLowerCase();\n const getTextContent = editor => Optional.from(editor.selection.getRng()).map(rng => {\n var _a;\n const parentBlockOpt = Optional.from(editor.dom.getParent(rng.commonAncestorContainer, editor.dom.isBlock));\n const body = editor.getBody();\n const contextNodeName = getContextNodeName(parentBlockOpt);\n const rangeContentClone = SugarElement.fromDom(rng.cloneContents());\n cleanupBogusElements(rangeContentClone);\n cleanupInputNames(rangeContentClone);\n const bin = editor.dom.add(body, contextNodeName, {\n 'data-mce-bogus': 'all',\n 'style': 'overflow: hidden; opacity: 0;'\n }, rangeContentClone.dom);\n const text = getInnerText(bin);\n const nonRenderedText = trim$2((_a = bin.textContent) !== null && _a !== void 0 ? _a : '');\n editor.dom.remove(bin);\n if (isCollapsibleWhitespace(nonRenderedText, 0) || isCollapsibleWhitespace(nonRenderedText, nonRenderedText.length - 1)) {\n const parentBlock = parentBlockOpt.getOr(body);\n const parentBlockText = getInnerText(parentBlock);\n const textIndex = parentBlockText.indexOf(text);\n if (textIndex === -1) {\n return text;\n } else {\n const hasProceedingSpace = isCollapsibleWhitespace(parentBlockText, textIndex - 1);\n const hasTrailingSpace = isCollapsibleWhitespace(parentBlockText, textIndex + text.length);\n return (hasProceedingSpace ? ' ' : '') + text + (hasTrailingSpace ? ' ' : '');\n }\n } else {\n return text;\n }\n }).getOr('');\n const getSerializedContent = (editor, args) => {\n const rng = editor.selection.getRng(), tmpElm = editor.dom.create('body');\n const sel = editor.selection.getSel();\n const ranges = processRanges(editor, getRanges$1(sel));\n const fragment = args.contextual ? read$3(SugarElement.fromDom(editor.getBody()), ranges, editor.schema).dom : rng.cloneContents();\n if (fragment) {\n tmpElm.appendChild(fragment);\n }\n return editor.selection.serializer.serialize(tmpElm, args);\n };\n const extractSelectedContent = (editor, args) => {\n if (args.format === 'text') {\n return getTextContent(editor);\n } else {\n const content = getSerializedContent(editor, args);\n if (args.format === 'tree') {\n return content;\n } else {\n return editor.selection.isCollapsed() ? '' : content;\n }\n }\n };\n const setupArgs$3 = (args, format) => ({\n ...args,\n format,\n get: true,\n selection: true,\n getInner: true\n });\n const getSelectedContentInternal = (editor, format, args = {}) => {\n const defaultedArgs = setupArgs$3(args, format);\n return preProcessGetContent(editor, defaultedArgs).fold(identity, updatedArgs => {\n const content = extractSelectedContent(editor, updatedArgs);\n return postProcessGetContent(editor, content, updatedArgs);\n });\n };\n\n const KEEP = 0, INSERT = 1, DELETE = 2;\n const diff = (left, right) => {\n const size = left.length + right.length + 2;\n const vDown = new Array(size);\n const vUp = new Array(size);\n const snake = (start, end, diag) => {\n return {\n start,\n end,\n diag\n };\n };\n const buildScript = (start1, end1, start2, end2, script) => {\n const middle = getMiddleSnake(start1, end1, start2, end2);\n if (middle === null || middle.start === end1 && middle.diag === end1 - end2 || middle.end === start1 && middle.diag === start1 - start2) {\n let i = start1;\n let j = start2;\n while (i < end1 || j < end2) {\n if (i < end1 && j < end2 && left[i] === right[j]) {\n script.push([\n KEEP,\n left[i]\n ]);\n ++i;\n ++j;\n } else {\n if (end1 - start1 > end2 - start2) {\n script.push([\n DELETE,\n left[i]\n ]);\n ++i;\n } else {\n script.push([\n INSERT,\n right[j]\n ]);\n ++j;\n }\n }\n }\n } else {\n buildScript(start1, middle.start, start2, middle.start - middle.diag, script);\n for (let i2 = middle.start; i2 < middle.end; ++i2) {\n script.push([\n KEEP,\n left[i2]\n ]);\n }\n buildScript(middle.end, end1, middle.end - middle.diag, end2, script);\n }\n };\n const buildSnake = (start, diag, end1, end2) => {\n let end = start;\n while (end - diag < end2 && end < end1 && left[end] === right[end - diag]) {\n ++end;\n }\n return snake(start, end, diag);\n };\n const getMiddleSnake = (start1, end1, start2, end2) => {\n const m = end1 - start1;\n const n = end2 - start2;\n if (m === 0 || n === 0) {\n return null;\n }\n const delta = m - n;\n const sum = n + m;\n const offset = (sum % 2 === 0 ? sum : sum + 1) / 2;\n vDown[1 + offset] = start1;\n vUp[1 + offset] = end1 + 1;\n let d, k, i, x, y;\n for (d = 0; d <= offset; ++d) {\n for (k = -d; k <= d; k += 2) {\n i = k + offset;\n if (k === -d || k !== d && vDown[i - 1] < vDown[i + 1]) {\n vDown[i] = vDown[i + 1];\n } else {\n vDown[i] = vDown[i - 1] + 1;\n }\n x = vDown[i];\n y = x - start1 + start2 - k;\n while (x < end1 && y < end2 && left[x] === right[y]) {\n vDown[i] = ++x;\n ++y;\n }\n if (delta % 2 !== 0 && delta - d <= k && k <= delta + d) {\n if (vUp[i - delta] <= vDown[i]) {\n return buildSnake(vUp[i - delta], k + start1 - start2, end1, end2);\n }\n }\n }\n for (k = delta - d; k <= delta + d; k += 2) {\n i = k + offset - delta;\n if (k === delta - d || k !== delta + d && vUp[i + 1] <= vUp[i - 1]) {\n vUp[i] = vUp[i + 1] - 1;\n } else {\n vUp[i] = vUp[i - 1];\n }\n x = vUp[i] - 1;\n y = x - start1 + start2 - k;\n while (x >= start1 && y >= start2 && left[x] === right[y]) {\n vUp[i] = x--;\n y--;\n }\n if (delta % 2 === 0 && -d <= k && k <= d) {\n if (vUp[i] <= vDown[i + delta]) {\n return buildSnake(vUp[i], k + start1 - start2, end1, end2);\n }\n }\n }\n }\n return null;\n };\n const script = [];\n buildScript(0, left.length, 0, right.length, script);\n return script;\n };\n\n const getOuterHtml = elm => {\n if (isElement$6(elm)) {\n return elm.outerHTML;\n } else if (isText$a(elm)) {\n return Entities.encodeRaw(elm.data, false);\n } else if (isComment(elm)) {\n return '';\n }\n return '';\n };\n const createFragment = html => {\n let node;\n const container = document.createElement('div');\n const frag = document.createDocumentFragment();\n if (html) {\n container.innerHTML = html;\n }\n while (node = container.firstChild) {\n frag.appendChild(node);\n }\n return frag;\n };\n const insertAt = (elm, html, index) => {\n const fragment = createFragment(html);\n if (elm.hasChildNodes() && index < elm.childNodes.length) {\n const target = elm.childNodes[index];\n elm.insertBefore(fragment, target);\n } else {\n elm.appendChild(fragment);\n }\n };\n const removeAt = (elm, index) => {\n if (elm.hasChildNodes() && index < elm.childNodes.length) {\n const target = elm.childNodes[index];\n elm.removeChild(target);\n }\n };\n const applyDiff = (diff, elm) => {\n let index = 0;\n each$e(diff, action => {\n if (action[0] === KEEP) {\n index++;\n } else if (action[0] === INSERT) {\n insertAt(elm, action[1], index);\n index++;\n } else if (action[0] === DELETE) {\n removeAt(elm, index);\n }\n });\n };\n const read$2 = (elm, trimZwsp) => filter$5(map$3(from(elm.childNodes), trimZwsp ? compose(trim$2, getOuterHtml) : getOuterHtml), item => {\n return item.length > 0;\n });\n const write = (fragments, elm) => {\n const currentFragments = map$3(from(elm.childNodes), getOuterHtml);\n applyDiff(diff(currentFragments, fragments), elm);\n return elm;\n };\n\n const lazyTempDocument = cached(() => document.implementation.createHTMLDocument('undo'));\n const hasIframes = body => body.querySelector('iframe') !== null;\n const createFragmentedLevel = fragments => {\n return {\n type: 'fragmented',\n fragments,\n content: '',\n bookmark: null,\n beforeBookmark: null\n };\n };\n const createCompleteLevel = content => {\n return {\n type: 'complete',\n fragments: null,\n content,\n bookmark: null,\n beforeBookmark: null\n };\n };\n const createFromEditor = editor => {\n const tempAttrs = editor.serializer.getTempAttrs();\n const body = trim$1(editor.getBody(), tempAttrs);\n return hasIframes(body) ? createFragmentedLevel(read$2(body, true)) : createCompleteLevel(trim$2(body.innerHTML));\n };\n const applyToEditor = (editor, level, before) => {\n const bookmark = before ? level.beforeBookmark : level.bookmark;\n if (level.type === 'fragmented') {\n write(level.fragments, editor.getBody());\n } else {\n editor.setContent(level.content, {\n format: 'raw',\n no_selection: isNonNullable(bookmark) && isPathBookmark(bookmark) ? !bookmark.isFakeCaret : true\n });\n }\n if (bookmark) {\n editor.selection.moveToBookmark(bookmark);\n editor.selection.scrollIntoView();\n }\n };\n const getLevelContent = level => {\n return level.type === 'fragmented' ? level.fragments.join('') : level.content;\n };\n const getCleanLevelContent = level => {\n const elm = SugarElement.fromTag('body', lazyTempDocument());\n set$1(elm, getLevelContent(level));\n each$e(descendants(elm, '*[data-mce-bogus]'), unwrap);\n return get$6(elm);\n };\n const hasEqualContent = (level1, level2) => getLevelContent(level1) === getLevelContent(level2);\n const hasEqualCleanedContent = (level1, level2) => getCleanLevelContent(level1) === getCleanLevelContent(level2);\n const isEq$1 = (level1, level2) => {\n if (!level1 || !level2) {\n return false;\n } else if (hasEqualContent(level1, level2)) {\n return true;\n } else {\n return hasEqualCleanedContent(level1, level2);\n }\n };\n\n const isUnlocked = locks => locks.get() === 0;\n\n const setTyping = (undoManager, typing, locks) => {\n if (isUnlocked(locks)) {\n undoManager.typing = typing;\n }\n };\n const endTyping = (undoManager, locks) => {\n if (undoManager.typing) {\n setTyping(undoManager, false, locks);\n undoManager.add();\n }\n };\n const endTypingLevelIgnoreLocks = undoManager => {\n if (undoManager.typing) {\n undoManager.typing = false;\n undoManager.add();\n }\n };\n\n const beforeChange$1 = (editor, locks, beforeBookmark) => {\n if (isUnlocked(locks)) {\n beforeBookmark.set(getUndoBookmark(editor.selection));\n }\n };\n const addUndoLevel$1 = (editor, undoManager, index, locks, beforeBookmark, level, event) => {\n const currentLevel = createFromEditor(editor);\n const newLevel = Tools.extend(level || {}, currentLevel);\n if (!isUnlocked(locks) || editor.removed) {\n return null;\n }\n const lastLevel = undoManager.data[index.get()];\n if (editor.dispatch('BeforeAddUndo', {\n level: newLevel,\n lastLevel,\n originalEvent: event\n }).isDefaultPrevented()) {\n return null;\n }\n if (lastLevel && isEq$1(lastLevel, newLevel)) {\n return null;\n }\n if (undoManager.data[index.get()]) {\n beforeBookmark.get().each(bm => {\n undoManager.data[index.get()].beforeBookmark = bm;\n });\n }\n const customUndoRedoLevels = getCustomUndoRedoLevels(editor);\n if (customUndoRedoLevels) {\n if (undoManager.data.length > customUndoRedoLevels) {\n for (let i = 0; i < undoManager.data.length - 1; i++) {\n undoManager.data[i] = undoManager.data[i + 1];\n }\n undoManager.data.length--;\n index.set(undoManager.data.length);\n }\n }\n newLevel.bookmark = getUndoBookmark(editor.selection);\n if (index.get() < undoManager.data.length - 1) {\n undoManager.data.length = index.get() + 1;\n }\n undoManager.data.push(newLevel);\n index.set(undoManager.data.length - 1);\n const args = {\n level: newLevel,\n lastLevel,\n originalEvent: event\n };\n if (index.get() > 0) {\n editor.setDirty(true);\n editor.dispatch('AddUndo', args);\n editor.dispatch('change', args);\n } else {\n editor.dispatch('AddUndo', args);\n }\n return newLevel;\n };\n const clear$1 = (editor, undoManager, index) => {\n undoManager.data = [];\n index.set(0);\n undoManager.typing = false;\n editor.dispatch('ClearUndos');\n };\n const extra$1 = (editor, undoManager, index, callback1, callback2) => {\n if (undoManager.transact(callback1)) {\n const bookmark = undoManager.data[index.get()].bookmark;\n const lastLevel = undoManager.data[index.get() - 1];\n applyToEditor(editor, lastLevel, true);\n if (undoManager.transact(callback2)) {\n undoManager.data[index.get() - 1].beforeBookmark = bookmark;\n }\n }\n };\n const redo$1 = (editor, index, data) => {\n let level;\n if (index.get() < data.length - 1) {\n index.set(index.get() + 1);\n level = data[index.get()];\n applyToEditor(editor, level, false);\n editor.setDirty(true);\n editor.dispatch('Redo', { level });\n }\n return level;\n };\n const undo$1 = (editor, undoManager, locks, index) => {\n let level;\n if (undoManager.typing) {\n undoManager.add();\n undoManager.typing = false;\n setTyping(undoManager, false, locks);\n }\n if (index.get() > 0) {\n index.set(index.get() - 1);\n level = undoManager.data[index.get()];\n applyToEditor(editor, level, true);\n editor.setDirty(true);\n editor.dispatch('Undo', { level });\n }\n return level;\n };\n const reset$1 = undoManager => {\n undoManager.clear();\n undoManager.add();\n };\n const hasUndo$1 = (editor, undoManager, index) => index.get() > 0 || undoManager.typing && undoManager.data[0] && !isEq$1(createFromEditor(editor), undoManager.data[0]);\n const hasRedo$1 = (undoManager, index) => index.get() < undoManager.data.length - 1 && !undoManager.typing;\n const transact$1 = (undoManager, locks, callback) => {\n endTyping(undoManager, locks);\n undoManager.beforeChange();\n undoManager.ignore(callback);\n return undoManager.add();\n };\n const ignore$1 = (locks, callback) => {\n try {\n locks.set(locks.get() + 1);\n callback();\n } finally {\n locks.set(locks.get() - 1);\n }\n };\n\n const addVisualInternal = (editor, elm) => {\n const dom = editor.dom;\n const scope = isNonNullable(elm) ? elm : editor.getBody();\n each$e(dom.select('table,a', scope), matchedElm => {\n switch (matchedElm.nodeName) {\n case 'TABLE':\n const cls = getVisualAidsTableClass(editor);\n const value = dom.getAttrib(matchedElm, 'border');\n if ((!value || value === '0') && editor.hasVisual) {\n dom.addClass(matchedElm, cls);\n } else {\n dom.removeClass(matchedElm, cls);\n }\n break;\n case 'A':\n if (!dom.getAttrib(matchedElm, 'href')) {\n const value = dom.getAttrib(matchedElm, 'name') || matchedElm.id;\n const cls = getVisualAidsAnchorClass(editor);\n if (value && editor.hasVisual) {\n dom.addClass(matchedElm, cls);\n } else {\n dom.removeClass(matchedElm, cls);\n }\n }\n break;\n }\n });\n editor.dispatch('VisualAid', {\n element: elm,\n hasVisual: editor.hasVisual\n });\n };\n\n const makePlainAdaptor = editor => ({\n init: { bindEvents: noop },\n undoManager: {\n beforeChange: (locks, beforeBookmark) => beforeChange$1(editor, locks, beforeBookmark),\n add: (undoManager, index, locks, beforeBookmark, level, event) => addUndoLevel$1(editor, undoManager, index, locks, beforeBookmark, level, event),\n undo: (undoManager, locks, index) => undo$1(editor, undoManager, locks, index),\n redo: (index, data) => redo$1(editor, index, data),\n clear: (undoManager, index) => clear$1(editor, undoManager, index),\n reset: undoManager => reset$1(undoManager),\n hasUndo: (undoManager, index) => hasUndo$1(editor, undoManager, index),\n hasRedo: (undoManager, index) => hasRedo$1(undoManager, index),\n transact: (undoManager, locks, callback) => transact$1(undoManager, locks, callback),\n ignore: (locks, callback) => ignore$1(locks, callback),\n extra: (undoManager, index, callback1, callback2) => extra$1(editor, undoManager, index, callback1, callback2)\n },\n formatter: {\n match: (name, vars, node, similar) => match$2(editor, name, vars, node, similar),\n matchAll: (names, vars) => matchAll(editor, names, vars),\n matchNode: (node, name, vars, similar) => matchNode(editor, node, name, vars, similar),\n canApply: name => canApply(editor, name),\n closest: names => closest(editor, names),\n apply: (name, vars, node) => applyFormat$1(editor, name, vars, node),\n remove: (name, vars, node, similar) => removeFormat$1(editor, name, vars, node, similar),\n toggle: (name, vars, node) => toggle(editor, name, vars, node),\n formatChanged: (registeredFormatListeners, formats, callback, similar, vars) => formatChangedInternal(editor, registeredFormatListeners, formats, callback, similar, vars)\n },\n editor: {\n getContent: args => getContentInternal(editor, args),\n setContent: (content, args) => setContentInternal(editor, content, args),\n insertContent: (value, details) => insertHtmlAtCaret(editor, value, details),\n addVisual: elm => addVisualInternal(editor, elm)\n },\n selection: { getContent: (format, args) => getSelectedContentInternal(editor, format, args) },\n autocompleter: {\n addDecoration: range => create$9(editor, range),\n removeDecoration: () => remove$2(editor, SugarElement.fromDom(editor.getBody()))\n },\n raw: { getModel: () => Optional.none() }\n });\n const makeRtcAdaptor = rtcEditor => {\n const defaultVars = vars => isObject(vars) ? vars : {};\n const {init, undoManager, formatter, editor, selection, autocompleter, raw} = rtcEditor;\n return {\n init: { bindEvents: init.bindEvents },\n undoManager: {\n beforeChange: undoManager.beforeChange,\n add: undoManager.add,\n undo: undoManager.undo,\n redo: undoManager.redo,\n clear: undoManager.clear,\n reset: undoManager.reset,\n hasUndo: undoManager.hasUndo,\n hasRedo: undoManager.hasRedo,\n transact: (_undoManager, _locks, fn) => undoManager.transact(fn),\n ignore: (_locks, callback) => undoManager.ignore(callback),\n extra: (_undoManager, _index, callback1, callback2) => undoManager.extra(callback1, callback2)\n },\n formatter: {\n match: (name, vars, _node, similar) => formatter.match(name, defaultVars(vars), similar),\n matchAll: formatter.matchAll,\n matchNode: formatter.matchNode,\n canApply: name => formatter.canApply(name),\n closest: names => formatter.closest(names),\n apply: (name, vars, _node) => formatter.apply(name, defaultVars(vars)),\n remove: (name, vars, _node, _similar) => formatter.remove(name, defaultVars(vars)),\n toggle: (name, vars, _node) => formatter.toggle(name, defaultVars(vars)),\n formatChanged: (_rfl, formats, callback, similar, vars) => formatter.formatChanged(formats, callback, similar, vars)\n },\n editor: {\n getContent: args => editor.getContent(args),\n setContent: (content, args) => {\n return {\n content: editor.setContent(content, args),\n html: ''\n };\n },\n insertContent: (content, _details) => {\n editor.insertContent(content);\n return '';\n },\n addVisual: editor.addVisual\n },\n selection: { getContent: (_format, args) => selection.getContent(args) },\n autocompleter: {\n addDecoration: autocompleter.addDecoration,\n removeDecoration: autocompleter.removeDecoration\n },\n raw: { getModel: () => Optional.some(raw.getRawModel()) }\n };\n };\n const makeNoopAdaptor = () => {\n const nul = constant(null);\n const empty = constant('');\n return {\n init: { bindEvents: noop },\n undoManager: {\n beforeChange: noop,\n add: nul,\n undo: nul,\n redo: nul,\n clear: noop,\n reset: noop,\n hasUndo: never,\n hasRedo: never,\n transact: nul,\n ignore: noop,\n extra: noop\n },\n formatter: {\n match: never,\n matchAll: constant([]),\n matchNode: constant(undefined),\n canApply: never,\n closest: empty,\n apply: noop,\n remove: noop,\n toggle: noop,\n formatChanged: constant({ unbind: noop })\n },\n editor: {\n getContent: empty,\n setContent: constant({\n content: '',\n html: ''\n }),\n insertContent: constant(''),\n addVisual: noop\n },\n selection: { getContent: empty },\n autocompleter: {\n addDecoration: noop,\n removeDecoration: noop\n },\n raw: { getModel: constant(Optional.none()) }\n };\n };\n const isRtc = editor => has$2(editor.plugins, 'rtc');\n const getRtcSetup = editor => get$a(editor.plugins, 'rtc').bind(rtcPlugin => Optional.from(rtcPlugin.setup));\n const setup$t = editor => {\n const editorCast = editor;\n return getRtcSetup(editor).fold(() => {\n editorCast.rtcInstance = makePlainAdaptor(editor);\n return Optional.none();\n }, setup => {\n editorCast.rtcInstance = makeNoopAdaptor();\n return Optional.some(() => setup().then(rtcEditor => {\n editorCast.rtcInstance = makeRtcAdaptor(rtcEditor);\n return rtcEditor.rtc.isRemote;\n }));\n });\n };\n const getRtcInstanceWithFallback = editor => editor.rtcInstance ? editor.rtcInstance : makePlainAdaptor(editor);\n const getRtcInstanceWithError = editor => {\n const rtcInstance = editor.rtcInstance;\n if (!rtcInstance) {\n throw new Error('Failed to get RTC instance not yet initialized.');\n } else {\n return rtcInstance;\n }\n };\n const beforeChange = (editor, locks, beforeBookmark) => {\n getRtcInstanceWithError(editor).undoManager.beforeChange(locks, beforeBookmark);\n };\n const addUndoLevel = (editor, undoManager, index, locks, beforeBookmark, level, event) => getRtcInstanceWithError(editor).undoManager.add(undoManager, index, locks, beforeBookmark, level, event);\n const undo = (editor, undoManager, locks, index) => getRtcInstanceWithError(editor).undoManager.undo(undoManager, locks, index);\n const redo = (editor, index, data) => getRtcInstanceWithError(editor).undoManager.redo(index, data);\n const clear = (editor, undoManager, index) => {\n getRtcInstanceWithError(editor).undoManager.clear(undoManager, index);\n };\n const reset = (editor, undoManager) => {\n getRtcInstanceWithError(editor).undoManager.reset(undoManager);\n };\n const hasUndo = (editor, undoManager, index) => getRtcInstanceWithError(editor).undoManager.hasUndo(undoManager, index);\n const hasRedo = (editor, undoManager, index) => getRtcInstanceWithError(editor).undoManager.hasRedo(undoManager, index);\n const transact = (editor, undoManager, locks, callback) => getRtcInstanceWithError(editor).undoManager.transact(undoManager, locks, callback);\n const ignore = (editor, locks, callback) => {\n getRtcInstanceWithError(editor).undoManager.ignore(locks, callback);\n };\n const extra = (editor, undoManager, index, callback1, callback2) => {\n getRtcInstanceWithError(editor).undoManager.extra(undoManager, index, callback1, callback2);\n };\n const matchFormat = (editor, name, vars, node, similar) => getRtcInstanceWithError(editor).formatter.match(name, vars, node, similar);\n const matchAllFormats = (editor, names, vars) => getRtcInstanceWithError(editor).formatter.matchAll(names, vars);\n const matchNodeFormat = (editor, node, name, vars, similar) => getRtcInstanceWithError(editor).formatter.matchNode(node, name, vars, similar);\n const canApplyFormat = (editor, name) => getRtcInstanceWithError(editor).formatter.canApply(name);\n const closestFormat = (editor, names) => getRtcInstanceWithError(editor).formatter.closest(names);\n const applyFormat = (editor, name, vars, node) => {\n getRtcInstanceWithError(editor).formatter.apply(name, vars, node);\n };\n const removeFormat = (editor, name, vars, node, similar) => {\n getRtcInstanceWithError(editor).formatter.remove(name, vars, node, similar);\n };\n const toggleFormat = (editor, name, vars, node) => {\n getRtcInstanceWithError(editor).formatter.toggle(name, vars, node);\n };\n const formatChanged = (editor, registeredFormatListeners, formats, callback, similar, vars) => getRtcInstanceWithError(editor).formatter.formatChanged(registeredFormatListeners, formats, callback, similar, vars);\n const getContent$2 = (editor, args) => getRtcInstanceWithFallback(editor).editor.getContent(args);\n const setContent$2 = (editor, content, args) => getRtcInstanceWithFallback(editor).editor.setContent(content, args);\n const insertContent$1 = (editor, value, details) => getRtcInstanceWithFallback(editor).editor.insertContent(value, details);\n const getSelectedContent = (editor, format, args) => getRtcInstanceWithError(editor).selection.getContent(format, args);\n const addVisual$1 = (editor, elm) => getRtcInstanceWithError(editor).editor.addVisual(elm);\n const bindEvents = editor => getRtcInstanceWithError(editor).init.bindEvents();\n const addAutocompleterDecoration = (editor, range) => getRtcInstanceWithError(editor).autocompleter.addDecoration(range);\n const removeAutocompleterDecoration = editor => getRtcInstanceWithError(editor).autocompleter.removeDecoration();\n\n const getContent$1 = (editor, args = {}) => {\n const format = args.format ? args.format : 'html';\n return getSelectedContent(editor, format, args);\n };\n\n const removeEmpty = text => {\n if (text.dom.length === 0) {\n remove$5(text);\n return Optional.none();\n } else {\n return Optional.some(text);\n }\n };\n const walkPastBookmark = (node, start) => node.filter(elm => BookmarkManager.isBookmarkNode(elm.dom)).bind(start ? nextSibling : prevSibling);\n const merge$1 = (outer, inner, rng, start, schema) => {\n const outerElm = outer.dom;\n const innerElm = inner.dom;\n const oldLength = start ? outerElm.length : innerElm.length;\n if (start) {\n mergeTextNodes(outerElm, innerElm, schema, false, !start);\n rng.setStart(innerElm, oldLength);\n } else {\n mergeTextNodes(innerElm, outerElm, schema, false, !start);\n rng.setEnd(innerElm, oldLength);\n }\n };\n const normalizeTextIfRequired = (inner, start, schema) => {\n parent(inner).each(root => {\n const text = inner.dom;\n if (start && needsToBeNbspLeft(root, CaretPosition(text, 0), schema)) {\n normalizeWhitespaceAfter(text, 0, schema);\n } else if (!start && needsToBeNbspRight(root, CaretPosition(text, text.length), schema)) {\n normalizeWhitespaceBefore(text, text.length, schema);\n }\n });\n };\n const mergeAndNormalizeText = (outerNode, innerNode, rng, start, schema) => {\n outerNode.bind(outer => {\n const normalizer = start ? normalizeWhitespaceBefore : normalizeWhitespaceAfter;\n normalizer(outer.dom, start ? outer.dom.length : 0, schema);\n return innerNode.filter(isText$b).map(inner => merge$1(outer, inner, rng, start, schema));\n }).orThunk(() => {\n const innerTextNode = walkPastBookmark(innerNode, start).or(innerNode).filter(isText$b);\n return innerTextNode.map(inner => normalizeTextIfRequired(inner, start, schema));\n });\n };\n const rngSetContent = (rng, fragment, schema) => {\n const firstChild = Optional.from(fragment.firstChild).map(SugarElement.fromDom);\n const lastChild = Optional.from(fragment.lastChild).map(SugarElement.fromDom);\n rng.deleteContents();\n rng.insertNode(fragment);\n const prevText = firstChild.bind(prevSibling).filter(isText$b).bind(removeEmpty);\n const nextText = lastChild.bind(nextSibling).filter(isText$b).bind(removeEmpty);\n mergeAndNormalizeText(prevText, firstChild, rng, true, schema);\n mergeAndNormalizeText(nextText, lastChild, rng, false, schema);\n rng.collapse(false);\n };\n const setupArgs$2 = (args, content) => ({\n format: 'html',\n ...args,\n set: true,\n selection: true,\n content\n });\n const cleanContent = (editor, args) => {\n if (args.format !== 'raw') {\n const rng = editor.selection.getRng();\n const contextBlock = editor.dom.getParent(rng.commonAncestorContainer, editor.dom.isBlock);\n const contextArgs = contextBlock ? { context: contextBlock.nodeName.toLowerCase() } : {};\n const node = editor.parser.parse(args.content, {\n forced_root_block: false,\n ...contextArgs,\n ...args\n });\n return HtmlSerializer({ validate: false }, editor.schema).serialize(node);\n } else {\n return args.content;\n }\n };\n const setContent$1 = (editor, content, args = {}) => {\n const defaultedArgs = setupArgs$2(args, content);\n preProcessSetContent(editor, defaultedArgs).each(updatedArgs => {\n const cleanedContent = cleanContent(editor, updatedArgs);\n const rng = editor.selection.getRng();\n rngSetContent(rng, rng.createContextualFragment(cleanedContent), editor.schema);\n editor.selection.setRng(rng);\n scrollRangeIntoView(editor, rng);\n postProcessSetContent(editor, cleanedContent, updatedArgs);\n });\n };\n\n const deleteFromCallbackMap = (callbackMap, selector, callback) => {\n if (has$2(callbackMap, selector)) {\n const newCallbacks = filter$5(callbackMap[selector], cb => cb !== callback);\n if (newCallbacks.length === 0) {\n delete callbackMap[selector];\n } else {\n callbackMap[selector] = newCallbacks;\n }\n }\n };\n var SelectorChanged = (dom, editor) => {\n let selectorChangedData;\n let currentSelectors;\n const findMatchingNode = (selector, nodes) => find$2(nodes, node => dom.is(node, selector));\n const getParents = elem => dom.getParents(elem, undefined, dom.getRoot());\n const setup = () => {\n selectorChangedData = {};\n currentSelectors = {};\n editor.on('NodeChange', e => {\n const node = e.element;\n const parents = getParents(node);\n const matchedSelectors = {};\n each$d(selectorChangedData, (callbacks, selector) => {\n findMatchingNode(selector, parents).each(node => {\n if (!currentSelectors[selector]) {\n each$e(callbacks, callback => {\n callback(true, {\n node,\n selector,\n parents\n });\n });\n currentSelectors[selector] = callbacks;\n }\n matchedSelectors[selector] = callbacks;\n });\n });\n each$d(currentSelectors, (callbacks, selector) => {\n if (!matchedSelectors[selector]) {\n delete currentSelectors[selector];\n each$e(callbacks, callback => {\n callback(false, {\n node,\n selector,\n parents\n });\n });\n }\n });\n });\n };\n return {\n selectorChangedWithUnbind: (selector, callback) => {\n if (!selectorChangedData) {\n setup();\n }\n if (!selectorChangedData[selector]) {\n selectorChangedData[selector] = [];\n }\n selectorChangedData[selector].push(callback);\n findMatchingNode(selector, getParents(editor.selection.getStart())).each(() => {\n currentSelectors[selector] = selectorChangedData[selector];\n });\n return {\n unbind: () => {\n deleteFromCallbackMap(selectorChangedData, selector, callback);\n deleteFromCallbackMap(currentSelectors, selector, callback);\n }\n };\n }\n };\n };\n\n const isAttachedToDom = node => {\n return !!(node && node.ownerDocument) && contains(SugarElement.fromDom(node.ownerDocument), SugarElement.fromDom(node));\n };\n const isValidRange = rng => {\n if (!rng) {\n return false;\n } else {\n return isAttachedToDom(rng.startContainer) && isAttachedToDom(rng.endContainer);\n }\n };\n const EditorSelection = (dom, win, serializer, editor) => {\n let selectedRange;\n let explicitRange;\n const {selectorChangedWithUnbind} = SelectorChanged(dom, editor);\n const setCursorLocation = (node, offset) => {\n const rng = dom.createRng();\n if (isNonNullable(node) && isNonNullable(offset)) {\n rng.setStart(node, offset);\n rng.setEnd(node, offset);\n setRng(rng);\n collapse(false);\n } else {\n moveEndPoint(dom, rng, editor.getBody(), true);\n setRng(rng);\n }\n };\n const getContent = args => getContent$1(editor, args);\n const setContent = (content, args) => setContent$1(editor, content, args);\n const getStart$1 = real => getStart(editor.getBody(), getRng$1(), real);\n const getEnd = real => getEnd$1(editor.getBody(), getRng$1(), real);\n const getBookmark = (type, normalized) => bookmarkManager.getBookmark(type, normalized);\n const moveToBookmark = bookmark => bookmarkManager.moveToBookmark(bookmark);\n const select$1 = (node, content) => {\n select(dom, node, content).each(setRng);\n return node;\n };\n const isCollapsed = () => {\n const rng = getRng$1(), sel = getSel();\n if (!rng || rng.item) {\n return false;\n }\n if (rng.compareEndPoints) {\n return rng.compareEndPoints('StartToEnd', rng) === 0;\n }\n return !sel || rng.collapsed;\n };\n const isEditable = () => {\n const rng = getRng$1();\n const fakeSelectedElements = editor.getBody().querySelectorAll('[data-mce-selected=\"1\"]');\n if (fakeSelectedElements.length > 0) {\n return forall(fakeSelectedElements, el => dom.isEditable(el.parentElement));\n } else {\n return isEditableRange(dom, rng);\n }\n };\n const collapse = toStart => {\n const rng = getRng$1();\n rng.collapse(!!toStart);\n setRng(rng);\n };\n const getSel = () => win.getSelection ? win.getSelection() : win.document.selection;\n const getRng$1 = () => {\n let rng;\n const tryCompareBoundaryPoints = (how, sourceRange, destinationRange) => {\n try {\n return sourceRange.compareBoundaryPoints(how, destinationRange);\n } catch (ex) {\n return -1;\n }\n };\n const doc = win.document;\n if (isNonNullable(editor.bookmark) && !hasFocus(editor)) {\n const bookmark = getRng(editor);\n if (bookmark.isSome()) {\n return bookmark.map(r => processRanges(editor, [r])[0]).getOr(doc.createRange());\n }\n }\n try {\n const selection = getSel();\n if (selection && !isRestrictedNode(selection.anchorNode)) {\n if (selection.rangeCount > 0) {\n rng = selection.getRangeAt(0);\n } else {\n rng = doc.createRange();\n }\n rng = processRanges(editor, [rng])[0];\n }\n } catch (ex) {\n }\n if (!rng) {\n rng = doc.createRange();\n }\n if (isDocument$1(rng.startContainer) && rng.collapsed) {\n const elm = dom.getRoot();\n rng.setStart(elm, 0);\n rng.setEnd(elm, 0);\n }\n if (selectedRange && explicitRange) {\n if (tryCompareBoundaryPoints(rng.START_TO_START, rng, selectedRange) === 0 && tryCompareBoundaryPoints(rng.END_TO_END, rng, selectedRange) === 0) {\n rng = explicitRange;\n } else {\n selectedRange = null;\n explicitRange = null;\n }\n }\n return rng;\n };\n const setRng = (rng, forward) => {\n if (!isValidRange(rng)) {\n return;\n }\n const sel = getSel();\n const evt = editor.dispatch('SetSelectionRange', {\n range: rng,\n forward\n });\n rng = evt.range;\n if (sel) {\n explicitRange = rng;\n try {\n sel.removeAllRanges();\n sel.addRange(rng);\n } catch (ex) {\n }\n if (forward === false && sel.extend) {\n sel.collapse(rng.endContainer, rng.endOffset);\n sel.extend(rng.startContainer, rng.startOffset);\n }\n selectedRange = sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n }\n if (!rng.collapsed && rng.startContainer === rng.endContainer && (sel === null || sel === void 0 ? void 0 : sel.setBaseAndExtent)) {\n if (rng.endOffset - rng.startOffset < 2) {\n if (rng.startContainer.hasChildNodes()) {\n const node = rng.startContainer.childNodes[rng.startOffset];\n if (node && node.nodeName === 'IMG') {\n sel.setBaseAndExtent(rng.startContainer, rng.startOffset, rng.endContainer, rng.endOffset);\n if (sel.anchorNode !== rng.startContainer || sel.focusNode !== rng.endContainer) {\n sel.setBaseAndExtent(node, 0, node, 1);\n }\n }\n }\n }\n }\n editor.dispatch('AfterSetSelectionRange', {\n range: rng,\n forward\n });\n };\n const setNode = elm => {\n setContent(dom.getOuterHTML(elm));\n return elm;\n };\n const getNode$1 = () => getNode(editor.getBody(), getRng$1());\n const getSelectedBlocks$1 = (startElm, endElm) => getSelectedBlocks(dom, getRng$1(), startElm, endElm);\n const isForward = () => {\n const sel = getSel();\n const anchorNode = sel === null || sel === void 0 ? void 0 : sel.anchorNode;\n const focusNode = sel === null || sel === void 0 ? void 0 : sel.focusNode;\n if (!sel || !anchorNode || !focusNode || isRestrictedNode(anchorNode) || isRestrictedNode(focusNode)) {\n return true;\n }\n const anchorRange = dom.createRng();\n const focusRange = dom.createRng();\n try {\n anchorRange.setStart(anchorNode, sel.anchorOffset);\n anchorRange.collapse(true);\n focusRange.setStart(focusNode, sel.focusOffset);\n focusRange.collapse(true);\n } catch (e) {\n return true;\n }\n return anchorRange.compareBoundaryPoints(anchorRange.START_TO_START, focusRange) <= 0;\n };\n const normalize = () => {\n const rng = getRng$1();\n const sel = getSel();\n if (!hasMultipleRanges(sel) && hasAnyRanges(editor)) {\n const normRng = normalize$2(dom, rng);\n normRng.each(normRng => {\n setRng(normRng, isForward());\n });\n return normRng.getOr(rng);\n }\n return rng;\n };\n const selectorChanged = (selector, callback) => {\n selectorChangedWithUnbind(selector, callback);\n return exports;\n };\n const getScrollContainer = () => {\n let scrollContainer;\n let node = dom.getRoot();\n while (node && node.nodeName !== 'BODY') {\n if (node.scrollHeight > node.clientHeight) {\n scrollContainer = node;\n break;\n }\n node = node.parentNode;\n }\n return scrollContainer;\n };\n const scrollIntoView = (elm, alignToTop) => {\n if (isNonNullable(elm)) {\n scrollElementIntoView(editor, elm, alignToTop);\n } else {\n scrollRangeIntoView(editor, getRng$1(), alignToTop);\n }\n };\n const placeCaretAt = (clientX, clientY) => setRng(fromPoint(clientX, clientY, editor.getDoc()));\n const getBoundingClientRect = () => {\n const rng = getRng$1();\n return rng.collapsed ? CaretPosition.fromRangeStart(rng).getClientRects()[0] : rng.getBoundingClientRect();\n };\n const destroy = () => {\n win = selectedRange = explicitRange = null;\n controlSelection.destroy();\n };\n const expand = (options = { type: 'word' }) => setRng(RangeUtils(dom).expand(getRng$1(), options));\n const exports = {\n dom,\n win,\n serializer,\n editor,\n expand,\n collapse,\n setCursorLocation,\n getContent,\n setContent,\n getBookmark,\n moveToBookmark,\n select: select$1,\n isCollapsed,\n isEditable,\n isForward,\n setNode,\n getNode: getNode$1,\n getSel,\n setRng,\n getRng: getRng$1,\n getStart: getStart$1,\n getEnd,\n getSelectedBlocks: getSelectedBlocks$1,\n normalize,\n selectorChanged,\n selectorChangedWithUnbind,\n getScrollContainer,\n scrollIntoView,\n placeCaretAt,\n getBoundingClientRect,\n destroy\n };\n const bookmarkManager = BookmarkManager(exports);\n const controlSelection = ControlSelection(exports, editor);\n exports.bookmarkManager = bookmarkManager;\n exports.controlSelection = controlSelection;\n return exports;\n };\n\n const register$3 = (htmlParser, settings, dom) => {\n htmlParser.addAttributeFilter('data-mce-tabindex', (nodes, name) => {\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n node.attr('tabindex', node.attr('data-mce-tabindex'));\n node.attr(name, null);\n }\n });\n htmlParser.addAttributeFilter('src,href,style', (nodes, name) => {\n const internalName = 'data-mce-' + name;\n const urlConverter = settings.url_converter;\n const urlConverterScope = settings.url_converter_scope;\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n let value = node.attr(internalName);\n if (value !== undefined) {\n node.attr(name, value.length > 0 ? value : null);\n node.attr(internalName, null);\n } else {\n value = node.attr(name);\n if (name === 'style') {\n value = dom.serializeStyle(dom.parseStyle(value), node.name);\n } else if (urlConverter) {\n value = urlConverter.call(urlConverterScope, value, name, node.name);\n }\n node.attr(name, value.length > 0 ? value : null);\n }\n }\n });\n htmlParser.addAttributeFilter('class', nodes => {\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n let value = node.attr('class');\n if (value) {\n value = value.replace(/(?:^|\\s)mce-item-\\w+(?!\\S)/g, '');\n node.attr('class', value.length > 0 ? value : null);\n }\n }\n });\n htmlParser.addAttributeFilter('data-mce-type', (nodes, name, args) => {\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n if (node.attr('data-mce-type') === 'bookmark' && !args.cleanup) {\n const hasChildren = Optional.from(node.firstChild).exists(firstChild => {\n var _a;\n return !isZwsp$1((_a = firstChild.value) !== null && _a !== void 0 ? _a : '');\n });\n if (hasChildren) {\n node.unwrap();\n } else {\n node.remove();\n }\n }\n }\n });\n htmlParser.addNodeFilter('noscript', nodes => {\n var _a;\n let i = nodes.length;\n while (i--) {\n const node = nodes[i].firstChild;\n if (node) {\n node.value = Entities.decode((_a = node.value) !== null && _a !== void 0 ? _a : '');\n }\n }\n });\n htmlParser.addNodeFilter('script,style', (nodes, name) => {\n var _a;\n const trim = value => {\n return value.replace(/()/g, '\\n').replace(/^[\\r\\n]*|[\\r\\n]*$/g, '').replace(/^\\s*(()?|\\s*\\/\\/\\s*\\]\\]>(-->)?|\\/\\/\\s*(-->)?|\\]\\]>|\\/\\*\\s*-->\\s*\\*\\/|\\s*-->\\s*)\\s*$/g, '');\n };\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n const firstChild = node.firstChild;\n const value = (_a = firstChild === null || firstChild === void 0 ? void 0 : firstChild.value) !== null && _a !== void 0 ? _a : '';\n if (name === 'script') {\n const type = node.attr('type');\n if (type) {\n node.attr('type', type === 'mce-no/type' ? null : type.replace(/^mce\\-/, ''));\n }\n if (settings.element_format === 'xhtml' && firstChild && value.length > 0) {\n firstChild.value = '// ';\n }\n } else {\n if (settings.element_format === 'xhtml' && firstChild && value.length > 0) {\n firstChild.value = '';\n }\n }\n }\n });\n htmlParser.addNodeFilter('#comment', nodes => {\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n const value = node.value;\n if (settings.preserve_cdata && (value === null || value === void 0 ? void 0 : value.indexOf('[CDATA[')) === 0) {\n node.name = '#cdata';\n node.type = 4;\n node.value = dom.decode(value.replace(/^\\[CDATA\\[|\\]\\]$/g, ''));\n } else if ((value === null || value === void 0 ? void 0 : value.indexOf('mce:protected ')) === 0) {\n node.name = '#text';\n node.type = 3;\n node.raw = true;\n node.value = unescape(value).substr(14);\n }\n }\n });\n htmlParser.addNodeFilter('xml:namespace,input', (nodes, name) => {\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n if (node.type === 7) {\n node.remove();\n } else if (node.type === 1) {\n if (name === 'input' && !node.attr('type')) {\n node.attr('type', 'text');\n }\n }\n }\n });\n htmlParser.addAttributeFilter('data-mce-type', nodes => {\n each$e(nodes, node => {\n if (node.attr('data-mce-type') === 'format-caret') {\n if (node.isEmpty(htmlParser.schema.getNonEmptyElements())) {\n node.remove();\n } else {\n node.unwrap();\n }\n }\n });\n });\n htmlParser.addAttributeFilter('data-mce-src,data-mce-href,data-mce-style,' + 'data-mce-selected,data-mce-expando,data-mce-block,' + 'data-mce-type,data-mce-resize,data-mce-placeholder', (nodes, name) => {\n let i = nodes.length;\n while (i--) {\n nodes[i].attr(name, null);\n }\n });\n if (settings.remove_trailing_brs) {\n addNodeFilter(settings, htmlParser, htmlParser.schema);\n }\n };\n const trimTrailingBr = rootNode => {\n const isBr = node => {\n return (node === null || node === void 0 ? void 0 : node.name) === 'br';\n };\n const brNode1 = rootNode.lastChild;\n if (isBr(brNode1)) {\n const brNode2 = brNode1.prev;\n if (isBr(brNode2)) {\n brNode1.remove();\n brNode2.remove();\n }\n }\n };\n\n const preProcess$1 = (editor, node, args) => {\n let oldDoc;\n const dom = editor.dom;\n let clonedNode = node.cloneNode(true);\n const impl = document.implementation;\n if (impl.createHTMLDocument) {\n const doc = impl.createHTMLDocument('');\n Tools.each(clonedNode.nodeName === 'BODY' ? clonedNode.childNodes : [clonedNode], node => {\n doc.body.appendChild(doc.importNode(node, true));\n });\n if (clonedNode.nodeName !== 'BODY') {\n clonedNode = doc.body.firstChild;\n } else {\n clonedNode = doc.body;\n }\n oldDoc = dom.doc;\n dom.doc = doc;\n }\n firePreProcess(editor, {\n ...args,\n node: clonedNode\n });\n if (oldDoc) {\n dom.doc = oldDoc;\n }\n return clonedNode;\n };\n const shouldFireEvent = (editor, args) => {\n return isNonNullable(editor) && editor.hasEventListeners('PreProcess') && !args.no_events;\n };\n const process$1 = (editor, node, args) => {\n return shouldFireEvent(editor, args) ? preProcess$1(editor, node, args) : node;\n };\n\n const addTempAttr = (htmlParser, tempAttrs, name) => {\n if (Tools.inArray(tempAttrs, name) === -1) {\n htmlParser.addAttributeFilter(name, (nodes, name) => {\n let i = nodes.length;\n while (i--) {\n nodes[i].attr(name, null);\n }\n });\n tempAttrs.push(name);\n }\n };\n const postProcess = (editor, args, content) => {\n if (!args.no_events && editor) {\n const outArgs = firePostProcess(editor, {\n ...args,\n content\n });\n return outArgs.content;\n } else {\n return content;\n }\n };\n const getHtmlFromNode = (dom, node, args) => {\n const html = trim$2(args.getInner ? node.innerHTML : dom.getOuterHTML(node));\n return args.selection || isWsPreserveElement(SugarElement.fromDom(node)) ? html : Tools.trim(html);\n };\n const parseHtml = (htmlParser, html, args) => {\n const parserArgs = args.selection ? {\n forced_root_block: false,\n ...args\n } : args;\n const rootNode = htmlParser.parse(html, parserArgs);\n trimTrailingBr(rootNode);\n return rootNode;\n };\n const serializeNode = (settings, schema, node) => {\n const htmlSerializer = HtmlSerializer(settings, schema);\n return htmlSerializer.serialize(node);\n };\n const toHtml = (editor, settings, schema, rootNode, args) => {\n const content = serializeNode(settings, schema, rootNode);\n return postProcess(editor, args, content);\n };\n const DomSerializerImpl = (settings, editor) => {\n const tempAttrs = ['data-mce-selected'];\n const defaultedSettings = {\n entity_encoding: 'named',\n remove_trailing_brs: true,\n pad_empty_with_br: false,\n ...settings\n };\n const dom = editor && editor.dom ? editor.dom : DOMUtils.DOM;\n const schema = editor && editor.schema ? editor.schema : Schema(defaultedSettings);\n const htmlParser = DomParser(defaultedSettings, schema);\n register$3(htmlParser, defaultedSettings, dom);\n const serialize = (node, parserArgs = {}) => {\n const args = {\n format: 'html',\n ...parserArgs\n };\n const targetNode = process$1(editor, node, args);\n const html = getHtmlFromNode(dom, targetNode, args);\n const rootNode = parseHtml(htmlParser, html, args);\n return args.format === 'tree' ? rootNode : toHtml(editor, defaultedSettings, schema, rootNode, args);\n };\n return {\n schema,\n addNodeFilter: htmlParser.addNodeFilter,\n addAttributeFilter: htmlParser.addAttributeFilter,\n serialize: serialize,\n addRules: schema.addValidElements,\n setRules: schema.setValidElements,\n addTempAttr: curry(addTempAttr, htmlParser, tempAttrs),\n getTempAttrs: constant(tempAttrs),\n getNodeFilters: htmlParser.getNodeFilters,\n getAttributeFilters: htmlParser.getAttributeFilters,\n removeNodeFilter: htmlParser.removeNodeFilter,\n removeAttributeFilter: htmlParser.removeAttributeFilter\n };\n };\n\n const DomSerializer = (settings, editor) => {\n const domSerializer = DomSerializerImpl(settings, editor);\n return {\n schema: domSerializer.schema,\n addNodeFilter: domSerializer.addNodeFilter,\n addAttributeFilter: domSerializer.addAttributeFilter,\n serialize: domSerializer.serialize,\n addRules: domSerializer.addRules,\n setRules: domSerializer.setRules,\n addTempAttr: domSerializer.addTempAttr,\n getTempAttrs: domSerializer.getTempAttrs,\n getNodeFilters: domSerializer.getNodeFilters,\n getAttributeFilters: domSerializer.getAttributeFilters,\n removeNodeFilter: domSerializer.removeNodeFilter,\n removeAttributeFilter: domSerializer.removeAttributeFilter\n };\n };\n\n const defaultFormat$1 = 'html';\n const setupArgs$1 = (args, format) => ({\n ...args,\n format,\n get: true,\n getInner: true\n });\n const getContent = (editor, args = {}) => {\n const format = args.format ? args.format : defaultFormat$1;\n const defaultedArgs = setupArgs$1(args, format);\n return preProcessGetContent(editor, defaultedArgs).fold(identity, updatedArgs => {\n const content = getContent$2(editor, updatedArgs);\n return postProcessGetContent(editor, content, updatedArgs);\n });\n };\n\n const defaultFormat = 'html';\n const setupArgs = (args, content) => ({\n format: defaultFormat,\n ...args,\n set: true,\n content\n });\n const setContent = (editor, content, args = {}) => {\n const defaultedArgs = setupArgs(args, content);\n return preProcessSetContent(editor, defaultedArgs).map(updatedArgs => {\n const result = setContent$2(editor, updatedArgs.content, updatedArgs);\n postProcessSetContent(editor, result.html, updatedArgs);\n return result.content;\n }).getOr(content);\n };\n\n const removedOptions = ('autoresize_on_init,content_editable_state,padd_empty_with_br,block_elements,' + 'boolean_attributes,editor_deselector,editor_selector,elements,file_browser_callback_types,filepicker_validator_handler,' + 'force_hex_style_colors,force_p_newlines,gecko_spellcheck,images_dataimg_filter,media_scripts,mode,move_caret_before_on_enter_elements,' + 'non_empty_elements,self_closing_elements,short_ended_elements,special,spellchecker_select_languages,spellchecker_whitelist,' + 'tab_focus,tabfocus_elements,table_responsive_width,text_block_elements,text_inline_elements,toolbar_drawer,types,validate,whitespace_elements,' + 'paste_enable_default_filters,paste_filter_drop,paste_word_valid_elements,paste_retain_style_properties,paste_convert_word_fake_lists').split(',');\n const deprecatedOptions = 'template_cdate_classes,template_mdate_classes,template_selected_content_classes,template_preview_replace_values,template_replace_values,templates,template_cdate_format,template_mdate_format'.split(',');\n const removedPlugins = 'bbcode,colorpicker,contextmenu,fullpage,legacyoutput,spellchecker,textcolor'.split(',');\n const deprecatedPlugins = [\n {\n name: 'template',\n replacedWith: 'Advanced Template'\n },\n { name: 'rtc' }\n ];\n const getMatchingOptions = (options, searchingFor) => {\n const settingNames = filter$5(searchingFor, setting => has$2(options, setting));\n return sort(settingNames);\n };\n const getRemovedOptions = options => {\n const settingNames = getMatchingOptions(options, removedOptions);\n const forcedRootBlock = options.forced_root_block;\n if (forcedRootBlock === false || forcedRootBlock === '') {\n settingNames.push('forced_root_block (false only)');\n }\n return sort(settingNames);\n };\n const getDeprecatedOptions = options => getMatchingOptions(options, deprecatedOptions);\n const getMatchingPlugins = (options, searchingFor) => {\n const plugins = Tools.makeMap(options.plugins, ' ');\n const hasPlugin = plugin => has$2(plugins, plugin);\n const pluginNames = filter$5(searchingFor, hasPlugin);\n return sort(pluginNames);\n };\n const getRemovedPlugins = options => getMatchingPlugins(options, removedPlugins);\n const getDeprecatedPlugins = options => getMatchingPlugins(options, deprecatedPlugins.map(entry => entry.name));\n const logRemovedWarnings = (rawOptions, normalizedOptions) => {\n const removedOptions = getRemovedOptions(rawOptions);\n const removedPlugins = getRemovedPlugins(normalizedOptions);\n const hasRemovedPlugins = removedPlugins.length > 0;\n const hasRemovedOptions = removedOptions.length > 0;\n const isLegacyMobileTheme = normalizedOptions.theme === 'mobile';\n if (hasRemovedPlugins || hasRemovedOptions || isLegacyMobileTheme) {\n const listJoiner = '\\n- ';\n const themesMessage = isLegacyMobileTheme ? `\\n\\nThemes:${ listJoiner }mobile` : '';\n const pluginsMessage = hasRemovedPlugins ? `\\n\\nPlugins:${ listJoiner }${ removedPlugins.join(listJoiner) }` : '';\n const optionsMessage = hasRemovedOptions ? `\\n\\nOptions:${ listJoiner }${ removedOptions.join(listJoiner) }` : '';\n console.warn('The following deprecated features are currently enabled and have been removed in TinyMCE 6.0. These features will no longer work and should be removed from the TinyMCE configuration. ' + 'See https://www.tiny.cloud/docs/tinymce/6/migration-from-5x/ for more information.' + themesMessage + pluginsMessage + optionsMessage);\n }\n };\n const getPluginDescription = name => find$2(deprecatedPlugins, entry => entry.name === name).fold(() => name, entry => {\n if (entry.replacedWith) {\n return `${ name }, replaced by ${ entry.replacedWith }`;\n } else {\n return name;\n }\n });\n const logDeprecatedWarnings = (rawOptions, normalizedOptions) => {\n const deprecatedOptions = getDeprecatedOptions(rawOptions);\n const deprecatedPlugins = getDeprecatedPlugins(normalizedOptions);\n const hasDeprecatedPlugins = deprecatedPlugins.length > 0;\n const hasDeprecatedOptions = deprecatedOptions.length > 0;\n if (hasDeprecatedPlugins || hasDeprecatedOptions) {\n const listJoiner = '\\n- ';\n const pluginsMessage = hasDeprecatedPlugins ? `\\n\\nPlugins:${ listJoiner }${ deprecatedPlugins.map(getPluginDescription).join(listJoiner) }` : '';\n const optionsMessage = hasDeprecatedOptions ? `\\n\\nOptions:${ listJoiner }${ deprecatedOptions.join(listJoiner) }` : '';\n console.warn('The following deprecated features are currently enabled but will be removed soon.' + pluginsMessage + optionsMessage);\n }\n };\n const logWarnings = (rawOptions, normalizedOptions) => {\n logRemovedWarnings(rawOptions, normalizedOptions);\n logDeprecatedWarnings(rawOptions, normalizedOptions);\n };\n\n const DOM$8 = DOMUtils.DOM;\n const restoreOriginalStyles = editor => {\n DOM$8.setStyle(editor.id, 'display', editor.orgDisplay);\n };\n const safeDestroy = x => Optional.from(x).each(x => x.destroy());\n const clearDomReferences = editor => {\n const ed = editor;\n ed.contentAreaContainer = ed.formElement = ed.container = ed.editorContainer = null;\n ed.bodyElement = ed.contentDocument = ed.contentWindow = null;\n ed.iframeElement = ed.targetElm = null;\n const selection = editor.selection;\n if (selection) {\n const dom = selection.dom;\n ed.selection = selection.win = selection.dom = dom.doc = null;\n }\n };\n const restoreForm = editor => {\n const form = editor.formElement;\n if (form) {\n if (form._mceOldSubmit) {\n form.submit = form._mceOldSubmit;\n delete form._mceOldSubmit;\n }\n DOM$8.unbind(form, 'submit reset', editor.formEventDelegate);\n }\n };\n const remove$1 = editor => {\n if (!editor.removed) {\n const {_selectionOverrides, editorUpload} = editor;\n const body = editor.getBody();\n const element = editor.getElement();\n if (body) {\n editor.save({ is_removing: true });\n }\n editor.removed = true;\n editor.unbindAllNativeEvents();\n if (editor.hasHiddenInput && isNonNullable(element === null || element === void 0 ? void 0 : element.nextSibling)) {\n DOM$8.remove(element.nextSibling);\n }\n fireRemove(editor);\n editor.editorManager.remove(editor);\n if (!editor.inline && body) {\n restoreOriginalStyles(editor);\n }\n fireDetach(editor);\n DOM$8.remove(editor.getContainer());\n safeDestroy(_selectionOverrides);\n safeDestroy(editorUpload);\n editor.destroy();\n }\n };\n const destroy = (editor, automatic) => {\n const {selection, dom} = editor;\n if (editor.destroyed) {\n return;\n }\n if (!automatic && !editor.removed) {\n editor.remove();\n return;\n }\n if (!automatic) {\n editor.editorManager.off('beforeunload', editor._beforeUnload);\n if (editor.theme && editor.theme.destroy) {\n editor.theme.destroy();\n }\n safeDestroy(selection);\n safeDestroy(dom);\n }\n restoreForm(editor);\n clearDomReferences(editor);\n editor.destroyed = true;\n };\n\n const CreateIconManager = () => {\n const lookup = {};\n const add = (id, iconPack) => {\n lookup[id] = iconPack;\n };\n const get = id => {\n if (lookup[id]) {\n return lookup[id];\n } else {\n return { icons: {} };\n }\n };\n const has = id => has$2(lookup, id);\n return {\n add,\n get,\n has\n };\n };\n const IconManager = CreateIconManager();\n\n const ModelManager = AddOnManager.ModelManager;\n\n const getProp = (propName, elm) => {\n const rawElm = elm.dom;\n return rawElm[propName];\n };\n const getComputedSizeProp = (propName, elm) => parseInt(get$7(elm, propName), 10);\n const getClientWidth = curry(getProp, 'clientWidth');\n const getClientHeight = curry(getProp, 'clientHeight');\n const getMarginTop = curry(getComputedSizeProp, 'margin-top');\n const getMarginLeft = curry(getComputedSizeProp, 'margin-left');\n const getBoundingClientRect = elm => elm.dom.getBoundingClientRect();\n const isInsideElementContentArea = (bodyElm, clientX, clientY) => {\n const clientWidth = getClientWidth(bodyElm);\n const clientHeight = getClientHeight(bodyElm);\n return clientX >= 0 && clientY >= 0 && clientX <= clientWidth && clientY <= clientHeight;\n };\n const transpose = (inline, elm, clientX, clientY) => {\n const clientRect = getBoundingClientRect(elm);\n const deltaX = inline ? clientRect.left + elm.dom.clientLeft + getMarginLeft(elm) : 0;\n const deltaY = inline ? clientRect.top + elm.dom.clientTop + getMarginTop(elm) : 0;\n const x = clientX - deltaX;\n const y = clientY - deltaY;\n return {\n x,\n y\n };\n };\n const isXYInContentArea = (editor, clientX, clientY) => {\n const bodyElm = SugarElement.fromDom(editor.getBody());\n const targetElm = editor.inline ? bodyElm : documentElement(bodyElm);\n const transposedPoint = transpose(editor.inline, targetElm, clientX, clientY);\n return isInsideElementContentArea(targetElm, transposedPoint.x, transposedPoint.y);\n };\n const fromDomSafe = node => Optional.from(node).map(SugarElement.fromDom);\n const isEditorAttachedToDom = editor => {\n const rawContainer = editor.inline ? editor.getBody() : editor.getContentAreaContainer();\n return fromDomSafe(rawContainer).map(inBody).getOr(false);\n };\n\n var NotificationManagerImpl = () => {\n const unimplemented = () => {\n throw new Error('Theme did not provide a NotificationManager implementation.');\n };\n return {\n open: unimplemented,\n close: unimplemented,\n getArgs: unimplemented\n };\n };\n\n const NotificationManager = editor => {\n const notifications = [];\n const getImplementation = () => {\n const theme = editor.theme;\n return theme && theme.getNotificationManagerImpl ? theme.getNotificationManagerImpl() : NotificationManagerImpl();\n };\n const getTopNotification = () => {\n return Optional.from(notifications[0]);\n };\n const isEqual = (a, b) => {\n return a.type === b.type && a.text === b.text && !a.progressBar && !a.timeout && !b.progressBar && !b.timeout;\n };\n const reposition = () => {\n each$e(notifications, notification => {\n notification.reposition();\n });\n };\n const addNotification = notification => {\n notifications.push(notification);\n };\n const closeNotification = notification => {\n findIndex$2(notifications, otherNotification => {\n return otherNotification === notification;\n }).each(index => {\n notifications.splice(index, 1);\n });\n };\n const open = (spec, fireEvent = true) => {\n if (editor.removed || !isEditorAttachedToDom(editor)) {\n return {};\n }\n if (fireEvent) {\n editor.dispatch('BeforeOpenNotification', { notification: spec });\n }\n return find$2(notifications, notification => {\n return isEqual(getImplementation().getArgs(notification), spec);\n }).getOrThunk(() => {\n editor.editorManager.setActive(editor);\n const notification = getImplementation().open(spec, () => {\n closeNotification(notification);\n reposition();\n if (hasEditorOrUiFocus(editor)) {\n getTopNotification().fold(() => editor.focus(), top => focus$1(SugarElement.fromDom(top.getEl())));\n }\n });\n addNotification(notification);\n reposition();\n editor.dispatch('OpenNotification', { notification: { ...notification } });\n return notification;\n });\n };\n const close = () => {\n getTopNotification().each(notification => {\n getImplementation().close(notification);\n closeNotification(notification);\n reposition();\n });\n };\n const getNotifications = constant(notifications);\n const registerEvents = editor => {\n editor.on('SkinLoaded', () => {\n const serviceMessage = getServiceMessage(editor);\n if (serviceMessage) {\n open({\n text: serviceMessage,\n type: 'warning',\n timeout: 0\n }, false);\n }\n reposition();\n });\n editor.on('show ResizeEditor ResizeWindow NodeChange', () => {\n requestAnimationFrame(reposition);\n });\n editor.on('remove', () => {\n each$e(notifications.slice(), notification => {\n getImplementation().close(notification);\n });\n });\n };\n registerEvents(editor);\n return {\n open,\n close,\n getNotifications\n };\n };\n\n const PluginManager = AddOnManager.PluginManager;\n\n const ThemeManager = AddOnManager.ThemeManager;\n\n var WindowManagerImpl = () => {\n const unimplemented = () => {\n throw new Error('Theme did not provide a WindowManager implementation.');\n };\n return {\n open: unimplemented,\n openUrl: unimplemented,\n alert: unimplemented,\n confirm: unimplemented,\n close: unimplemented\n };\n };\n\n const WindowManager = editor => {\n let dialogs = [];\n const getImplementation = () => {\n const theme = editor.theme;\n return theme && theme.getWindowManagerImpl ? theme.getWindowManagerImpl() : WindowManagerImpl();\n };\n const funcBind = (scope, f) => {\n return (...args) => {\n return f ? f.apply(scope, args) : undefined;\n };\n };\n const fireOpenEvent = dialog => {\n editor.dispatch('OpenWindow', { dialog });\n };\n const fireCloseEvent = dialog => {\n editor.dispatch('CloseWindow', { dialog });\n };\n const addDialog = dialog => {\n dialogs.push(dialog);\n fireOpenEvent(dialog);\n };\n const closeDialog = dialog => {\n fireCloseEvent(dialog);\n dialogs = filter$5(dialogs, otherDialog => {\n return otherDialog !== dialog;\n });\n if (dialogs.length === 0) {\n editor.focus();\n }\n };\n const getTopDialog = () => {\n return Optional.from(dialogs[dialogs.length - 1]);\n };\n const storeSelectionAndOpenDialog = openDialog => {\n editor.editorManager.setActive(editor);\n store(editor);\n editor.ui.show();\n const dialog = openDialog();\n addDialog(dialog);\n return dialog;\n };\n const open = (args, params) => {\n return storeSelectionAndOpenDialog(() => getImplementation().open(args, params, closeDialog));\n };\n const openUrl = args => {\n return storeSelectionAndOpenDialog(() => getImplementation().openUrl(args, closeDialog));\n };\n const alert = (message, callback, scope) => {\n const windowManagerImpl = getImplementation();\n windowManagerImpl.alert(message, funcBind(scope ? scope : windowManagerImpl, callback));\n };\n const confirm = (message, callback, scope) => {\n const windowManagerImpl = getImplementation();\n windowManagerImpl.confirm(message, funcBind(scope ? scope : windowManagerImpl, callback));\n };\n const close = () => {\n getTopDialog().each(dialog => {\n getImplementation().close(dialog);\n closeDialog(dialog);\n });\n };\n editor.on('remove', () => {\n each$e(dialogs, dialog => {\n getImplementation().close(dialog);\n });\n });\n return {\n open,\n openUrl,\n alert,\n confirm,\n close\n };\n };\n\n const displayNotification = (editor, message) => {\n editor.notificationManager.open({\n type: 'error',\n text: message\n });\n };\n const displayError = (editor, message) => {\n if (editor._skinLoaded) {\n displayNotification(editor, message);\n } else {\n editor.on('SkinLoaded', () => {\n displayNotification(editor, message);\n });\n }\n };\n const uploadError = (editor, message) => {\n displayError(editor, I18n.translate([\n 'Failed to upload image: {0}',\n message\n ]));\n };\n const logError = (editor, errorType, msg) => {\n fireError(editor, errorType, { message: msg });\n console.error(msg);\n };\n const createLoadError = (type, url, name) => name ? `Failed to load ${ type }: ${ name } from url ${ url }` : `Failed to load ${ type } url: ${ url }`;\n const pluginLoadError = (editor, url, name) => {\n logError(editor, 'PluginLoadError', createLoadError('plugin', url, name));\n };\n const iconsLoadError = (editor, url, name) => {\n logError(editor, 'IconsLoadError', createLoadError('icons', url, name));\n };\n const languageLoadError = (editor, url, name) => {\n logError(editor, 'LanguageLoadError', createLoadError('language', url, name));\n };\n const themeLoadError = (editor, url, name) => {\n logError(editor, 'ThemeLoadError', createLoadError('theme', url, name));\n };\n const modelLoadError = (editor, url, name) => {\n logError(editor, 'ModelLoadError', createLoadError('model', url, name));\n };\n const pluginInitError = (editor, name, err) => {\n const message = I18n.translate([\n 'Failed to initialize plugin: {0}',\n name\n ]);\n fireError(editor, 'PluginLoadError', { message });\n initError(message, err);\n displayError(editor, message);\n };\n const initError = (message, ...x) => {\n const console = window.console;\n if (console) {\n if (console.error) {\n console.error(message, ...x);\n } else {\n console.log(message, ...x);\n }\n }\n };\n\n const isContentCssSkinName = url => /^[a-z0-9\\-]+$/i.test(url);\n const toContentSkinResourceName = url => 'content/' + url + '/content.css';\n const isBundledCssSkinName = url => tinymce.Resource.has(toContentSkinResourceName(url));\n const getContentCssUrls = editor => {\n return transformToUrls(editor, getContentCss(editor));\n };\n const getFontCssUrls = editor => {\n return transformToUrls(editor, getFontCss(editor));\n };\n const transformToUrls = (editor, cssLinks) => {\n const skinUrl = editor.editorManager.baseURL + '/skins/content';\n const suffix = editor.editorManager.suffix;\n const contentCssFile = `content${ suffix }.css`;\n return map$3(cssLinks, url => {\n if (isBundledCssSkinName(url)) {\n return url;\n } else if (isContentCssSkinName(url) && !editor.inline) {\n return `${ skinUrl }/${ url }/${ contentCssFile }`;\n } else {\n return editor.documentBaseURI.toAbsolute(url);\n }\n });\n };\n const appendContentCssFromSettings = editor => {\n editor.contentCSS = editor.contentCSS.concat(getContentCssUrls(editor), getFontCssUrls(editor));\n };\n\n const getAllImages = elm => {\n return elm ? from(elm.getElementsByTagName('img')) : [];\n };\n const ImageScanner = (uploadStatus, blobCache) => {\n const cachedPromises = {};\n const findAll = (elm, predicate = always) => {\n const images = filter$5(getAllImages(elm), img => {\n const src = img.src;\n if (img.hasAttribute('data-mce-bogus')) {\n return false;\n }\n if (img.hasAttribute('data-mce-placeholder')) {\n return false;\n }\n if (!src || src === Env.transparentSrc) {\n return false;\n }\n if (startsWith(src, 'blob:')) {\n return !uploadStatus.isUploaded(src) && predicate(img);\n }\n if (startsWith(src, 'data:')) {\n return predicate(img);\n }\n return false;\n });\n const promises = map$3(images, img => {\n const imageSrc = img.src;\n if (has$2(cachedPromises, imageSrc)) {\n return cachedPromises[imageSrc].then(imageInfo => {\n if (isString(imageInfo)) {\n return imageInfo;\n } else {\n return {\n image: img,\n blobInfo: imageInfo.blobInfo\n };\n }\n });\n } else {\n const newPromise = imageToBlobInfo(blobCache, imageSrc).then(blobInfo => {\n delete cachedPromises[imageSrc];\n return {\n image: img,\n blobInfo\n };\n }).catch(error => {\n delete cachedPromises[imageSrc];\n return error;\n });\n cachedPromises[imageSrc] = newPromise;\n return newPromise;\n }\n });\n return Promise.all(promises);\n };\n return { findAll };\n };\n\n const UploadStatus = () => {\n const PENDING = 1, UPLOADED = 2;\n let blobUriStatuses = {};\n const createStatus = (status, resultUri) => {\n return {\n status,\n resultUri\n };\n };\n const hasBlobUri = blobUri => {\n return blobUri in blobUriStatuses;\n };\n const getResultUri = blobUri => {\n const result = blobUriStatuses[blobUri];\n return result ? result.resultUri : null;\n };\n const isPending = blobUri => {\n return hasBlobUri(blobUri) ? blobUriStatuses[blobUri].status === PENDING : false;\n };\n const isUploaded = blobUri => {\n return hasBlobUri(blobUri) ? blobUriStatuses[blobUri].status === UPLOADED : false;\n };\n const markPending = blobUri => {\n blobUriStatuses[blobUri] = createStatus(PENDING, null);\n };\n const markUploaded = (blobUri, resultUri) => {\n blobUriStatuses[blobUri] = createStatus(UPLOADED, resultUri);\n };\n const removeFailed = blobUri => {\n delete blobUriStatuses[blobUri];\n };\n const destroy = () => {\n blobUriStatuses = {};\n };\n return {\n hasBlobUri,\n getResultUri,\n isPending,\n isUploaded,\n markPending,\n markUploaded,\n removeFailed,\n destroy\n };\n };\n\n let count = 0;\n const seed = () => {\n const rnd = () => {\n return Math.round(Math.random() * 4294967295).toString(36);\n };\n const now = new Date().getTime();\n return 's' + now.toString(36) + rnd() + rnd() + rnd();\n };\n const uuid = prefix => {\n return prefix + count++ + seed();\n };\n\n const BlobCache = () => {\n let cache = [];\n const mimeToExt = mime => {\n const mimes = {\n 'image/jpeg': 'jpg',\n 'image/jpg': 'jpg',\n 'image/gif': 'gif',\n 'image/png': 'png',\n 'image/apng': 'apng',\n 'image/avif': 'avif',\n 'image/svg+xml': 'svg',\n 'image/webp': 'webp',\n 'image/bmp': 'bmp',\n 'image/tiff': 'tiff'\n };\n return mimes[mime.toLowerCase()] || 'dat';\n };\n const create = (o, blob, base64, name, filename) => {\n if (isString(o)) {\n const id = o;\n return toBlobInfo({\n id,\n name,\n filename,\n blob: blob,\n base64: base64\n });\n } else if (isObject(o)) {\n return toBlobInfo(o);\n } else {\n throw new Error('Unknown input type');\n }\n };\n const toBlobInfo = o => {\n if (!o.blob || !o.base64) {\n throw new Error('blob and base64 representations of the image are required for BlobInfo to be created');\n }\n const id = o.id || uuid('blobid');\n const name = o.name || id;\n const blob = o.blob;\n return {\n id: constant(id),\n name: constant(name),\n filename: constant(o.filename || name + '.' + mimeToExt(blob.type)),\n blob: constant(blob),\n base64: constant(o.base64),\n blobUri: constant(o.blobUri || URL.createObjectURL(blob)),\n uri: constant(o.uri)\n };\n };\n const add = blobInfo => {\n if (!get(blobInfo.id())) {\n cache.push(blobInfo);\n }\n };\n const findFirst = predicate => find$2(cache, predicate).getOrUndefined();\n const get = id => findFirst(cachedBlobInfo => cachedBlobInfo.id() === id);\n const getByUri = blobUri => findFirst(blobInfo => blobInfo.blobUri() === blobUri);\n const getByData = (base64, type) => findFirst(blobInfo => blobInfo.base64() === base64 && blobInfo.blob().type === type);\n const removeByUri = blobUri => {\n cache = filter$5(cache, blobInfo => {\n if (blobInfo.blobUri() === blobUri) {\n URL.revokeObjectURL(blobInfo.blobUri());\n return false;\n }\n return true;\n });\n };\n const destroy = () => {\n each$e(cache, cachedBlobInfo => {\n URL.revokeObjectURL(cachedBlobInfo.blobUri());\n });\n cache = [];\n };\n return {\n create,\n add,\n get,\n getByUri,\n getByData,\n findFirst,\n removeByUri,\n destroy\n };\n };\n\n const Uploader = (uploadStatus, settings) => {\n const pendingPromises = {};\n const pathJoin = (path1, path2) => {\n if (path1) {\n return path1.replace(/\\/$/, '') + '/' + path2.replace(/^\\//, '');\n }\n return path2;\n };\n const defaultHandler = (blobInfo, progress) => new Promise((success, failure) => {\n const xhr = new XMLHttpRequest();\n xhr.open('POST', settings.url);\n xhr.withCredentials = settings.credentials;\n xhr.upload.onprogress = e => {\n progress(e.loaded / e.total * 100);\n };\n xhr.onerror = () => {\n failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status);\n };\n xhr.onload = () => {\n if (xhr.status < 200 || xhr.status >= 300) {\n failure('HTTP Error: ' + xhr.status);\n return;\n }\n const json = JSON.parse(xhr.responseText);\n if (!json || !isString(json.location)) {\n failure('Invalid JSON: ' + xhr.responseText);\n return;\n }\n success(pathJoin(settings.basePath, json.location));\n };\n const formData = new FormData();\n formData.append('file', blobInfo.blob(), blobInfo.filename());\n xhr.send(formData);\n });\n const uploadHandler = isFunction(settings.handler) ? settings.handler : defaultHandler;\n const noUpload = () => new Promise(resolve => {\n resolve([]);\n });\n const handlerSuccess = (blobInfo, url) => ({\n url,\n blobInfo,\n status: true\n });\n const handlerFailure = (blobInfo, error) => ({\n url: '',\n blobInfo,\n status: false,\n error\n });\n const resolvePending = (blobUri, result) => {\n Tools.each(pendingPromises[blobUri], resolve => {\n resolve(result);\n });\n delete pendingPromises[blobUri];\n };\n const uploadBlobInfo = (blobInfo, handler, openNotification) => {\n uploadStatus.markPending(blobInfo.blobUri());\n return new Promise(resolve => {\n let notification;\n let progress;\n try {\n const closeNotification = () => {\n if (notification) {\n notification.close();\n progress = noop;\n }\n };\n const success = url => {\n closeNotification();\n uploadStatus.markUploaded(blobInfo.blobUri(), url);\n resolvePending(blobInfo.blobUri(), handlerSuccess(blobInfo, url));\n resolve(handlerSuccess(blobInfo, url));\n };\n const failure = error => {\n closeNotification();\n uploadStatus.removeFailed(blobInfo.blobUri());\n resolvePending(blobInfo.blobUri(), handlerFailure(blobInfo, error));\n resolve(handlerFailure(blobInfo, error));\n };\n progress = percent => {\n if (percent < 0 || percent > 100) {\n return;\n }\n Optional.from(notification).orThunk(() => Optional.from(openNotification).map(apply$1)).each(n => {\n notification = n;\n n.progressBar.value(percent);\n });\n };\n handler(blobInfo, progress).then(success, err => {\n failure(isString(err) ? { message: err } : err);\n });\n } catch (ex) {\n resolve(handlerFailure(blobInfo, ex));\n }\n });\n };\n const isDefaultHandler = handler => handler === defaultHandler;\n const pendingUploadBlobInfo = blobInfo => {\n const blobUri = blobInfo.blobUri();\n return new Promise(resolve => {\n pendingPromises[blobUri] = pendingPromises[blobUri] || [];\n pendingPromises[blobUri].push(resolve);\n });\n };\n const uploadBlobs = (blobInfos, openNotification) => {\n blobInfos = Tools.grep(blobInfos, blobInfo => !uploadStatus.isUploaded(blobInfo.blobUri()));\n return Promise.all(Tools.map(blobInfos, blobInfo => uploadStatus.isPending(blobInfo.blobUri()) ? pendingUploadBlobInfo(blobInfo) : uploadBlobInfo(blobInfo, uploadHandler, openNotification)));\n };\n const upload = (blobInfos, openNotification) => !settings.url && isDefaultHandler(uploadHandler) ? noUpload() : uploadBlobs(blobInfos, openNotification);\n return { upload };\n };\n\n const openNotification = editor => () => editor.notificationManager.open({\n text: editor.translate('Image uploading...'),\n type: 'info',\n timeout: -1,\n progressBar: true\n });\n const createUploader = (editor, uploadStatus) => Uploader(uploadStatus, {\n url: getImageUploadUrl(editor),\n basePath: getImageUploadBasePath(editor),\n credentials: getImagesUploadCredentials(editor),\n handler: getImagesUploadHandler(editor)\n });\n const ImageUploader = editor => {\n const uploadStatus = UploadStatus();\n const uploader = createUploader(editor, uploadStatus);\n return { upload: (blobInfos, showNotification = true) => uploader.upload(blobInfos, showNotification ? openNotification(editor) : undefined) };\n };\n\n const isEmptyForPadding = (editor, element) => editor.dom.isEmpty(element.dom) && isNonNullable(editor.schema.getTextBlockElements()[name(element)]);\n const addPaddingToEmpty = editor => element => {\n if (isEmptyForPadding(editor, element)) {\n append$1(element, SugarElement.fromHtml('
    '));\n }\n };\n const EditorUpload = editor => {\n const blobCache = BlobCache();\n let uploader, imageScanner;\n const uploadStatus = UploadStatus();\n const urlFilters = [];\n const aliveGuard = callback => {\n return result => {\n if (editor.selection) {\n return callback(result);\n }\n return [];\n };\n };\n const cacheInvalidator = url => url + (url.indexOf('?') === -1 ? '?' : '&') + new Date().getTime();\n const replaceString = (content, search, replace) => {\n let index = 0;\n do {\n index = content.indexOf(search, index);\n if (index !== -1) {\n content = content.substring(0, index) + replace + content.substr(index + search.length);\n index += replace.length - search.length + 1;\n }\n } while (index !== -1);\n return content;\n };\n const replaceImageUrl = (content, targetUrl, replacementUrl) => {\n const replacementString = `src=\"${ replacementUrl }\"${ replacementUrl === Env.transparentSrc ? ' data-mce-placeholder=\"1\"' : '' }`;\n content = replaceString(content, `src=\"${ targetUrl }\"`, replacementString);\n content = replaceString(content, 'data-mce-src=\"' + targetUrl + '\"', 'data-mce-src=\"' + replacementUrl + '\"');\n return content;\n };\n const replaceUrlInUndoStack = (targetUrl, replacementUrl) => {\n each$e(editor.undoManager.data, level => {\n if (level.type === 'fragmented') {\n level.fragments = map$3(level.fragments, fragment => replaceImageUrl(fragment, targetUrl, replacementUrl));\n } else {\n level.content = replaceImageUrl(level.content, targetUrl, replacementUrl);\n }\n });\n };\n const replaceImageUriInView = (image, resultUri) => {\n const src = editor.convertURL(resultUri, 'src');\n replaceUrlInUndoStack(image.src, resultUri);\n setAll$1(SugarElement.fromDom(image), {\n 'src': shouldReuseFileName(editor) ? cacheInvalidator(resultUri) : resultUri,\n 'data-mce-src': src\n });\n };\n const uploadImages = () => {\n if (!uploader) {\n uploader = createUploader(editor, uploadStatus);\n }\n return scanForImages().then(aliveGuard(imageInfos => {\n const blobInfos = map$3(imageInfos, imageInfo => imageInfo.blobInfo);\n return uploader.upload(blobInfos, openNotification(editor)).then(aliveGuard(result => {\n const imagesToRemove = [];\n let shouldDispatchChange = false;\n const filteredResult = map$3(result, (uploadInfo, index) => {\n const {blobInfo, image} = imageInfos[index];\n let removed = false;\n if (uploadInfo.status && shouldReplaceBlobUris(editor)) {\n if (uploadInfo.url && !contains$1(image.src, uploadInfo.url)) {\n shouldDispatchChange = true;\n }\n blobCache.removeByUri(image.src);\n if (isRtc(editor)) ; else {\n replaceImageUriInView(image, uploadInfo.url);\n }\n } else if (uploadInfo.error) {\n if (uploadInfo.error.remove) {\n replaceUrlInUndoStack(image.src, Env.transparentSrc);\n imagesToRemove.push(image);\n removed = true;\n }\n uploadError(editor, uploadInfo.error.message);\n }\n return {\n element: image,\n status: uploadInfo.status,\n uploadUri: uploadInfo.url,\n blobInfo,\n removed\n };\n });\n if (imagesToRemove.length > 0 && !isRtc(editor)) {\n editor.undoManager.transact(() => {\n each$e(fromDom$1(imagesToRemove), sugarElement => {\n const parentOpt = parent(sugarElement);\n remove$5(sugarElement);\n parentOpt.each(addPaddingToEmpty(editor));\n blobCache.removeByUri(sugarElement.dom.src);\n });\n });\n } else if (shouldDispatchChange) {\n editor.undoManager.dispatchChange();\n }\n return filteredResult;\n }));\n }));\n };\n const uploadImagesAuto = () => isAutomaticUploadsEnabled(editor) ? uploadImages() : Promise.resolve([]);\n const isValidDataUriImage = imgElm => forall(urlFilters, filter => filter(imgElm));\n const addFilter = filter => {\n urlFilters.push(filter);\n };\n const scanForImages = () => {\n if (!imageScanner) {\n imageScanner = ImageScanner(uploadStatus, blobCache);\n }\n return imageScanner.findAll(editor.getBody(), isValidDataUriImage).then(aliveGuard(result => {\n const filteredResult = filter$5(result, resultItem => {\n if (isString(resultItem)) {\n displayError(editor, resultItem);\n return false;\n } else if (resultItem.uriType === 'blob') {\n return false;\n } else {\n return true;\n }\n });\n if (isRtc(editor)) ; else {\n each$e(filteredResult, resultItem => {\n replaceUrlInUndoStack(resultItem.image.src, resultItem.blobInfo.blobUri());\n resultItem.image.src = resultItem.blobInfo.blobUri();\n resultItem.image.removeAttribute('data-mce-src');\n });\n }\n return filteredResult;\n }));\n };\n const destroy = () => {\n blobCache.destroy();\n uploadStatus.destroy();\n imageScanner = uploader = null;\n };\n const replaceBlobUris = content => {\n return content.replace(/src=\"(blob:[^\"]+)\"/g, (match, blobUri) => {\n const resultUri = uploadStatus.getResultUri(blobUri);\n if (resultUri) {\n return 'src=\"' + resultUri + '\"';\n }\n let blobInfo = blobCache.getByUri(blobUri);\n if (!blobInfo) {\n blobInfo = foldl(editor.editorManager.get(), (result, editor) => {\n return result || editor.editorUpload && editor.editorUpload.blobCache.getByUri(blobUri);\n }, undefined);\n }\n if (blobInfo) {\n const blob = blobInfo.blob();\n return 'src=\"data:' + blob.type + ';base64,' + blobInfo.base64() + '\"';\n }\n return match;\n });\n };\n editor.on('SetContent', () => {\n if (isAutomaticUploadsEnabled(editor)) {\n uploadImagesAuto();\n } else {\n scanForImages();\n }\n });\n editor.on('RawSaveContent', e => {\n e.content = replaceBlobUris(e.content);\n });\n editor.on('GetContent', e => {\n if (e.source_view || e.format === 'raw' || e.format === 'tree') {\n return;\n }\n e.content = replaceBlobUris(e.content);\n });\n editor.on('PostRender', () => {\n editor.parser.addNodeFilter('img', images => {\n each$e(images, img => {\n const src = img.attr('src');\n if (!src || blobCache.getByUri(src)) {\n return;\n }\n const resultUri = uploadStatus.getResultUri(src);\n if (resultUri) {\n img.attr('src', resultUri);\n }\n });\n });\n });\n return {\n blobCache,\n addFilter,\n uploadImages,\n uploadImagesAuto,\n scanForImages,\n destroy\n };\n };\n\n const get$1 = editor => {\n const dom = editor.dom;\n const schemaType = editor.schema.type;\n const formats = {\n valigntop: [{\n selector: 'td,th',\n styles: { verticalAlign: 'top' }\n }],\n valignmiddle: [{\n selector: 'td,th',\n styles: { verticalAlign: 'middle' }\n }],\n valignbottom: [{\n selector: 'td,th',\n styles: { verticalAlign: 'bottom' }\n }],\n alignleft: [\n {\n selector: 'figure.image',\n collapsed: false,\n classes: 'align-left',\n ceFalseOverride: true,\n preview: 'font-family font-size'\n },\n {\n selector: 'figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre',\n styles: { textAlign: 'left' },\n inherit: false,\n preview: false\n },\n {\n selector: 'img,audio,video',\n collapsed: false,\n styles: { float: 'left' },\n preview: 'font-family font-size'\n },\n {\n selector: 'table',\n collapsed: false,\n styles: {\n marginLeft: '0px',\n marginRight: 'auto'\n },\n onformat: table => {\n dom.setStyle(table, 'float', null);\n },\n preview: 'font-family font-size'\n },\n {\n selector: '.mce-preview-object,[data-ephox-embed-iri]',\n ceFalseOverride: true,\n styles: { float: 'left' }\n }\n ],\n aligncenter: [\n {\n selector: 'figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre',\n styles: { textAlign: 'center' },\n inherit: false,\n preview: 'font-family font-size'\n },\n {\n selector: 'figure.image',\n collapsed: false,\n classes: 'align-center',\n ceFalseOverride: true,\n preview: 'font-family font-size'\n },\n {\n selector: 'img,audio,video',\n collapsed: false,\n styles: {\n display: 'block',\n marginLeft: 'auto',\n marginRight: 'auto'\n },\n preview: false\n },\n {\n selector: 'table',\n collapsed: false,\n styles: {\n marginLeft: 'auto',\n marginRight: 'auto'\n },\n preview: 'font-family font-size'\n },\n {\n selector: '.mce-preview-object',\n ceFalseOverride: true,\n styles: {\n display: 'table',\n marginLeft: 'auto',\n marginRight: 'auto'\n },\n preview: false\n },\n {\n selector: '[data-ephox-embed-iri]',\n ceFalseOverride: true,\n styles: {\n marginLeft: 'auto',\n marginRight: 'auto'\n },\n preview: false\n }\n ],\n alignright: [\n {\n selector: 'figure.image',\n collapsed: false,\n classes: 'align-right',\n ceFalseOverride: true,\n preview: 'font-family font-size'\n },\n {\n selector: 'figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre',\n styles: { textAlign: 'right' },\n inherit: false,\n preview: 'font-family font-size'\n },\n {\n selector: 'img,audio,video',\n collapsed: false,\n styles: { float: 'right' },\n preview: 'font-family font-size'\n },\n {\n selector: 'table',\n collapsed: false,\n styles: {\n marginRight: '0px',\n marginLeft: 'auto'\n },\n onformat: table => {\n dom.setStyle(table, 'float', null);\n },\n preview: 'font-family font-size'\n },\n {\n selector: '.mce-preview-object,[data-ephox-embed-iri]',\n ceFalseOverride: true,\n styles: { float: 'right' },\n preview: false\n }\n ],\n alignjustify: [{\n selector: 'figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre',\n styles: { textAlign: 'justify' },\n inherit: false,\n preview: 'font-family font-size'\n }],\n bold: [\n {\n inline: 'strong',\n remove: 'all',\n preserve_attributes: [\n 'class',\n 'style'\n ]\n },\n {\n inline: 'span',\n styles: { fontWeight: 'bold' }\n },\n {\n inline: 'b',\n remove: 'all',\n preserve_attributes: [\n 'class',\n 'style'\n ]\n }\n ],\n italic: [\n {\n inline: 'em',\n remove: 'all',\n preserve_attributes: [\n 'class',\n 'style'\n ]\n },\n {\n inline: 'span',\n styles: { fontStyle: 'italic' }\n },\n {\n inline: 'i',\n remove: 'all',\n preserve_attributes: [\n 'class',\n 'style'\n ]\n }\n ],\n underline: [\n {\n inline: 'span',\n styles: { textDecoration: 'underline' },\n exact: true\n },\n {\n inline: 'u',\n remove: 'all',\n preserve_attributes: [\n 'class',\n 'style'\n ]\n }\n ],\n strikethrough: (() => {\n const span = {\n inline: 'span',\n styles: { textDecoration: 'line-through' },\n exact: true\n };\n const strike = {\n inline: 'strike',\n remove: 'all',\n preserve_attributes: [\n 'class',\n 'style'\n ]\n };\n const s = {\n inline: 's',\n remove: 'all',\n preserve_attributes: [\n 'class',\n 'style'\n ]\n };\n return schemaType !== 'html4' ? [\n s,\n span,\n strike\n ] : [\n span,\n s,\n strike\n ];\n })(),\n forecolor: {\n inline: 'span',\n styles: { color: '%value' },\n links: true,\n remove_similar: true,\n clear_child_styles: true\n },\n hilitecolor: {\n inline: 'span',\n styles: { backgroundColor: '%value' },\n links: true,\n remove_similar: true,\n clear_child_styles: true\n },\n fontname: {\n inline: 'span',\n toggle: false,\n styles: { fontFamily: '%value' },\n clear_child_styles: true\n },\n fontsize: {\n inline: 'span',\n toggle: false,\n styles: { fontSize: '%value' },\n clear_child_styles: true\n },\n lineheight: {\n selector: 'h1,h2,h3,h4,h5,h6,p,li,td,th,div',\n styles: { lineHeight: '%value' }\n },\n fontsize_class: {\n inline: 'span',\n attributes: { class: '%value' }\n },\n blockquote: {\n block: 'blockquote',\n wrapper: true,\n remove: 'all'\n },\n subscript: { inline: 'sub' },\n superscript: { inline: 'sup' },\n code: { inline: 'code' },\n link: {\n inline: 'a',\n selector: 'a',\n remove: 'all',\n split: true,\n deep: true,\n onmatch: (node, _fmt, _itemName) => {\n return isElement$6(node) && node.hasAttribute('href');\n },\n onformat: (elm, _fmt, vars) => {\n Tools.each(vars, (value, key) => {\n dom.setAttrib(elm, key, value);\n });\n }\n },\n lang: {\n inline: 'span',\n clear_child_styles: true,\n remove_similar: true,\n attributes: {\n 'lang': '%value',\n 'data-mce-lang': vars => {\n var _a;\n return (_a = vars === null || vars === void 0 ? void 0 : vars.customValue) !== null && _a !== void 0 ? _a : null;\n }\n }\n },\n removeformat: [\n {\n selector: 'b,strong,em,i,font,u,strike,s,sub,sup,dfn,code,samp,kbd,var,cite,mark,q,del,ins,small',\n remove: 'all',\n split: true,\n expand: false,\n block_expand: true,\n deep: true\n },\n {\n selector: 'span',\n attributes: [\n 'style',\n 'class'\n ],\n remove: 'empty',\n split: true,\n expand: false,\n deep: true\n },\n {\n selector: '*',\n attributes: [\n 'style',\n 'class'\n ],\n split: false,\n expand: false,\n deep: true\n }\n ]\n };\n Tools.each('p h1 h2 h3 h4 h5 h6 div address pre dt dd samp'.split(/\\s/), name => {\n formats[name] = {\n block: name,\n remove: 'all'\n };\n });\n return formats;\n };\n\n const genericBase = {\n remove_similar: true,\n inherit: false\n };\n const cellBase = {\n selector: 'td,th',\n ...genericBase\n };\n const cellFormats = {\n tablecellbackgroundcolor: {\n styles: { backgroundColor: '%value' },\n ...cellBase\n },\n tablecellverticalalign: {\n styles: { 'vertical-align': '%value' },\n ...cellBase\n },\n tablecellbordercolor: {\n styles: { borderColor: '%value' },\n ...cellBase\n },\n tablecellclass: {\n classes: ['%value'],\n ...cellBase\n },\n tableclass: {\n selector: 'table',\n classes: ['%value'],\n ...genericBase\n },\n tablecellborderstyle: {\n styles: { borderStyle: '%value' },\n ...cellBase\n },\n tablecellborderwidth: {\n styles: { borderWidth: '%value' },\n ...cellBase\n }\n };\n const get = constant(cellFormats);\n\n const FormatRegistry = editor => {\n const formats = {};\n const get$2 = name => isNonNullable(name) ? formats[name] : formats;\n const has = name => has$2(formats, name);\n const register = (name, format) => {\n if (name) {\n if (!isString(name)) {\n each$d(name, (format, name) => {\n register(name, format);\n });\n } else {\n if (!isArray$1(format)) {\n format = [format];\n }\n each$e(format, format => {\n if (isUndefined(format.deep)) {\n format.deep = !isSelectorFormat(format);\n }\n if (isUndefined(format.split)) {\n format.split = !isSelectorFormat(format) || isInlineFormat(format);\n }\n if (isUndefined(format.remove) && isSelectorFormat(format) && !isInlineFormat(format)) {\n format.remove = 'none';\n }\n if (isSelectorFormat(format) && isInlineFormat(format)) {\n format.mixed = true;\n format.block_expand = true;\n }\n if (isString(format.classes)) {\n format.classes = format.classes.split(/\\s+/);\n }\n });\n formats[name] = format;\n }\n }\n };\n const unregister = name => {\n if (name && formats[name]) {\n delete formats[name];\n }\n return formats;\n };\n register(get$1(editor));\n register(get());\n register(getFormats(editor));\n return {\n get: get$2,\n has,\n register,\n unregister\n };\n };\n\n const each$3 = Tools.each;\n const dom = DOMUtils.DOM;\n const isPreviewItem = item => isNonNullable(item) && isObject(item);\n const parsedSelectorToHtml = (ancestry, editor) => {\n const schema = editor && editor.schema || Schema({});\n const decorate = (elm, item) => {\n if (item.classes.length > 0) {\n dom.addClass(elm, item.classes.join(' '));\n }\n dom.setAttribs(elm, item.attrs);\n };\n const createElement = sItem => {\n const item = isString(sItem) ? {\n name: sItem,\n classes: [],\n attrs: {}\n } : sItem;\n const elm = dom.create(item.name);\n decorate(elm, item);\n return elm;\n };\n const getRequiredParent = (elm, candidate) => {\n const elmRule = schema.getElementRule(elm.nodeName.toLowerCase());\n const parentsRequired = elmRule === null || elmRule === void 0 ? void 0 : elmRule.parentsRequired;\n if (parentsRequired && parentsRequired.length) {\n return candidate && contains$2(parentsRequired, candidate) ? candidate : parentsRequired[0];\n } else {\n return false;\n }\n };\n const wrapInHtml = (elm, ancestors, siblings) => {\n let parentCandidate;\n const ancestor = ancestors[0];\n const ancestorName = isPreviewItem(ancestor) ? ancestor.name : undefined;\n const parentRequired = getRequiredParent(elm, ancestorName);\n if (parentRequired) {\n if (ancestorName === parentRequired) {\n parentCandidate = ancestor;\n ancestors = ancestors.slice(1);\n } else {\n parentCandidate = parentRequired;\n }\n } else if (ancestor) {\n parentCandidate = ancestor;\n ancestors = ancestors.slice(1);\n } else if (!siblings) {\n return elm;\n }\n const parent = parentCandidate ? createElement(parentCandidate) : dom.create('div');\n parent.appendChild(elm);\n if (siblings) {\n Tools.each(siblings, sibling => {\n const siblingElm = createElement(sibling);\n parent.insertBefore(siblingElm, elm);\n });\n }\n const parentSiblings = isPreviewItem(parentCandidate) ? parentCandidate.siblings : undefined;\n return wrapInHtml(parent, ancestors, parentSiblings);\n };\n const fragment = dom.create('div');\n if (ancestry.length > 0) {\n const item = ancestry[0];\n const elm = createElement(item);\n const siblings = isPreviewItem(item) ? item.siblings : undefined;\n fragment.appendChild(wrapInHtml(elm, ancestry.slice(1), siblings));\n }\n return fragment;\n };\n const parseSelectorItem = item => {\n item = Tools.trim(item);\n let tagName = 'div';\n const obj = {\n name: tagName,\n classes: [],\n attrs: {},\n selector: item\n };\n if (item !== '*') {\n tagName = item.replace(/(?:([#\\.]|::?)([\\w\\-]+)|(\\[)([^\\]]+)\\]?)/g, ($0, $1, $2, $3, $4) => {\n switch ($1) {\n case '#':\n obj.attrs.id = $2;\n break;\n case '.':\n obj.classes.push($2);\n break;\n case ':':\n if (Tools.inArray('checked disabled enabled read-only required'.split(' '), $2) !== -1) {\n obj.attrs[$2] = $2;\n }\n break;\n }\n if ($3 === '[') {\n const m = $4.match(/([\\w\\-]+)(?:\\=\\\"([^\\\"]+))?/);\n if (m) {\n obj.attrs[m[1]] = m[2];\n }\n }\n return '';\n });\n }\n obj.name = tagName || 'div';\n return obj;\n };\n const parseSelector = selector => {\n if (!isString(selector)) {\n return [];\n }\n selector = selector.split(/\\s*,\\s*/)[0];\n selector = selector.replace(/\\s*(~\\+|~|\\+|>)\\s*/g, '$1');\n return Tools.map(selector.split(/(?:>|\\s+(?![^\\[\\]]+\\]))/), item => {\n const siblings = Tools.map(item.split(/(?:~\\+|~|\\+)/), parseSelectorItem);\n const obj = siblings.pop();\n if (siblings.length) {\n obj.siblings = siblings;\n }\n return obj;\n }).reverse();\n };\n const getCssText = (editor, format) => {\n let previewCss = '';\n let previewStyles = getPreviewStyles(editor);\n if (previewStyles === '') {\n return '';\n }\n const removeVars = val => {\n return isString(val) ? val.replace(/%(\\w+)/g, '') : '';\n };\n const getComputedStyle = (name, elm) => {\n return dom.getStyle(elm !== null && elm !== void 0 ? elm : editor.getBody(), name, true);\n };\n if (isString(format)) {\n const formats = editor.formatter.get(format);\n if (!formats) {\n return '';\n }\n format = formats[0];\n }\n if ('preview' in format) {\n const preview = format.preview;\n if (preview === false) {\n return '';\n } else {\n previewStyles = preview || previewStyles;\n }\n }\n let name = format.block || format.inline || 'span';\n let previewFrag;\n const items = parseSelector(format.selector);\n if (items.length > 0) {\n if (!items[0].name) {\n items[0].name = name;\n }\n name = format.selector;\n previewFrag = parsedSelectorToHtml(items, editor);\n } else {\n previewFrag = parsedSelectorToHtml([name], editor);\n }\n const previewElm = dom.select(name, previewFrag)[0] || previewFrag.firstChild;\n each$3(format.styles, (value, name) => {\n const newValue = removeVars(value);\n if (newValue) {\n dom.setStyle(previewElm, name, newValue);\n }\n });\n each$3(format.attributes, (value, name) => {\n const newValue = removeVars(value);\n if (newValue) {\n dom.setAttrib(previewElm, name, newValue);\n }\n });\n each$3(format.classes, value => {\n const newValue = removeVars(value);\n if (!dom.hasClass(previewElm, newValue)) {\n dom.addClass(previewElm, newValue);\n }\n });\n editor.dispatch('PreviewFormats');\n dom.setStyles(previewFrag, {\n position: 'absolute',\n left: -65535\n });\n editor.getBody().appendChild(previewFrag);\n const rawParentFontSize = getComputedStyle('fontSize');\n const parentFontSize = /px$/.test(rawParentFontSize) ? parseInt(rawParentFontSize, 10) : 0;\n each$3(previewStyles.split(' '), name => {\n let value = getComputedStyle(name, previewElm);\n if (name === 'background-color' && /transparent|rgba\\s*\\([^)]+,\\s*0\\)/.test(value)) {\n value = getComputedStyle(name);\n if (rgbaToHexString(value).toLowerCase() === '#ffffff') {\n return;\n }\n }\n if (name === 'color') {\n if (rgbaToHexString(value).toLowerCase() === '#000000') {\n return;\n }\n }\n if (name === 'font-size') {\n if (/em|%$/.test(value)) {\n if (parentFontSize === 0) {\n return;\n }\n const numValue = parseFloat(value) / (/%$/.test(value) ? 100 : 1);\n value = numValue * parentFontSize + 'px';\n }\n }\n if (name === 'border' && value) {\n previewCss += 'padding:0 2px;';\n }\n previewCss += name + ':' + value + ';';\n });\n editor.dispatch('AfterPreviewFormats');\n dom.remove(previewFrag);\n return previewCss;\n };\n\n const setup$s = editor => {\n editor.addShortcut('meta+b', '', 'Bold');\n editor.addShortcut('meta+i', '', 'Italic');\n editor.addShortcut('meta+u', '', 'Underline');\n for (let i = 1; i <= 6; i++) {\n editor.addShortcut('access+' + i, '', [\n 'FormatBlock',\n false,\n 'h' + i\n ]);\n }\n editor.addShortcut('access+7', '', [\n 'FormatBlock',\n false,\n 'p'\n ]);\n editor.addShortcut('access+8', '', [\n 'FormatBlock',\n false,\n 'div'\n ]);\n editor.addShortcut('access+9', '', [\n 'FormatBlock',\n false,\n 'address'\n ]);\n };\n\n const Formatter = editor => {\n const formats = FormatRegistry(editor);\n const formatChangeState = Cell({});\n setup$s(editor);\n setup$v(editor);\n if (!isRtc(editor)) {\n setup$u(formatChangeState, editor);\n }\n return {\n get: formats.get,\n has: formats.has,\n register: formats.register,\n unregister: formats.unregister,\n apply: (name, vars, node) => {\n applyFormat(editor, name, vars, node);\n },\n remove: (name, vars, node, similar) => {\n removeFormat(editor, name, vars, node, similar);\n },\n toggle: (name, vars, node) => {\n toggleFormat(editor, name, vars, node);\n },\n match: (name, vars, node, similar) => matchFormat(editor, name, vars, node, similar),\n closest: names => closestFormat(editor, names),\n matchAll: (names, vars) => matchAllFormats(editor, names, vars),\n matchNode: (node, name, vars, similar) => matchNodeFormat(editor, node, name, vars, similar),\n canApply: name => canApplyFormat(editor, name),\n formatChanged: (formats, callback, similar, vars) => formatChanged(editor, formatChangeState, formats, callback, similar, vars),\n getCssText: curry(getCssText, editor)\n };\n };\n\n const shouldIgnoreCommand = cmd => {\n switch (cmd.toLowerCase()) {\n case 'undo':\n case 'redo':\n case 'mcefocus':\n return true;\n default:\n return false;\n }\n };\n const registerEvents = (editor, undoManager, locks) => {\n const isFirstTypedCharacter = Cell(false);\n const addNonTypingUndoLevel = e => {\n setTyping(undoManager, false, locks);\n undoManager.add({}, e);\n };\n editor.on('init', () => {\n undoManager.add();\n });\n editor.on('BeforeExecCommand', e => {\n const cmd = e.command;\n if (!shouldIgnoreCommand(cmd)) {\n endTyping(undoManager, locks);\n undoManager.beforeChange();\n }\n });\n editor.on('ExecCommand', e => {\n const cmd = e.command;\n if (!shouldIgnoreCommand(cmd)) {\n addNonTypingUndoLevel(e);\n }\n });\n editor.on('ObjectResizeStart cut', () => {\n undoManager.beforeChange();\n });\n editor.on('SaveContent ObjectResized blur', addNonTypingUndoLevel);\n editor.on('dragend', addNonTypingUndoLevel);\n editor.on('keyup', e => {\n const keyCode = e.keyCode;\n if (e.isDefaultPrevented()) {\n return;\n }\n const isMeta = Env.os.isMacOS() && e.key === 'Meta';\n if (keyCode >= 33 && keyCode <= 36 || keyCode >= 37 && keyCode <= 40 || keyCode === 45 || e.ctrlKey || isMeta) {\n addNonTypingUndoLevel();\n editor.nodeChanged();\n }\n if (keyCode === 46 || keyCode === 8) {\n editor.nodeChanged();\n }\n if (isFirstTypedCharacter.get() && undoManager.typing && !isEq$1(createFromEditor(editor), undoManager.data[0])) {\n if (!editor.isDirty()) {\n editor.setDirty(true);\n }\n editor.dispatch('TypingUndo');\n isFirstTypedCharacter.set(false);\n editor.nodeChanged();\n }\n });\n editor.on('keydown', e => {\n const keyCode = e.keyCode;\n if (e.isDefaultPrevented()) {\n return;\n }\n if (keyCode >= 33 && keyCode <= 36 || keyCode >= 37 && keyCode <= 40 || keyCode === 45) {\n if (undoManager.typing) {\n addNonTypingUndoLevel(e);\n }\n return;\n }\n const modKey = e.ctrlKey && !e.altKey || e.metaKey;\n if ((keyCode < 16 || keyCode > 20) && keyCode !== 224 && keyCode !== 91 && !undoManager.typing && !modKey) {\n undoManager.beforeChange();\n setTyping(undoManager, true, locks);\n undoManager.add({}, e);\n isFirstTypedCharacter.set(true);\n return;\n }\n const hasOnlyMetaOrCtrlModifier = Env.os.isMacOS() ? e.metaKey : e.ctrlKey && !e.altKey;\n if (hasOnlyMetaOrCtrlModifier) {\n undoManager.beforeChange();\n }\n });\n editor.on('mousedown', e => {\n if (undoManager.typing) {\n addNonTypingUndoLevel(e);\n }\n });\n const isInsertReplacementText = event => event.inputType === 'insertReplacementText';\n const isInsertTextDataNull = event => event.inputType === 'insertText' && event.data === null;\n const isInsertFromPasteOrDrop = event => event.inputType === 'insertFromPaste' || event.inputType === 'insertFromDrop';\n editor.on('input', e => {\n if (e.inputType && (isInsertReplacementText(e) || isInsertTextDataNull(e) || isInsertFromPasteOrDrop(e))) {\n addNonTypingUndoLevel(e);\n }\n });\n editor.on('AddUndo Undo Redo ClearUndos', e => {\n if (!e.isDefaultPrevented()) {\n editor.nodeChanged();\n }\n });\n };\n const addKeyboardShortcuts = editor => {\n editor.addShortcut('meta+z', '', 'Undo');\n editor.addShortcut('meta+y,meta+shift+z', '', 'Redo');\n };\n\n const UndoManager = editor => {\n const beforeBookmark = value$2();\n const locks = Cell(0);\n const index = Cell(0);\n const undoManager = {\n data: [],\n typing: false,\n beforeChange: () => {\n beforeChange(editor, locks, beforeBookmark);\n },\n add: (level, event) => {\n return addUndoLevel(editor, undoManager, index, locks, beforeBookmark, level, event);\n },\n dispatchChange: () => {\n editor.setDirty(true);\n const level = createFromEditor(editor);\n level.bookmark = getUndoBookmark(editor.selection);\n editor.dispatch('change', {\n level,\n lastLevel: get$b(undoManager.data, index.get()).getOrUndefined()\n });\n },\n undo: () => {\n return undo(editor, undoManager, locks, index);\n },\n redo: () => {\n return redo(editor, index, undoManager.data);\n },\n clear: () => {\n clear(editor, undoManager, index);\n },\n reset: () => {\n reset(editor, undoManager);\n },\n hasUndo: () => {\n return hasUndo(editor, undoManager, index);\n },\n hasRedo: () => {\n return hasRedo(editor, undoManager, index);\n },\n transact: callback => {\n return transact(editor, undoManager, locks, callback);\n },\n ignore: callback => {\n ignore(editor, locks, callback);\n },\n extra: (callback1, callback2) => {\n extra(editor, undoManager, index, callback1, callback2);\n }\n };\n if (!isRtc(editor)) {\n registerEvents(editor, undoManager, locks);\n }\n addKeyboardShortcuts(editor);\n return undoManager;\n };\n\n const nonTypingKeycodes = [\n 9,\n 27,\n VK.HOME,\n VK.END,\n 19,\n 20,\n 44,\n 144,\n 145,\n 33,\n 34,\n 45,\n 16,\n 17,\n 18,\n 91,\n 92,\n 93,\n VK.DOWN,\n VK.UP,\n VK.LEFT,\n VK.RIGHT\n ].concat(Env.browser.isFirefox() ? [224] : []);\n const placeholderAttr = 'data-mce-placeholder';\n const isKeyboardEvent = e => e.type === 'keydown' || e.type === 'keyup';\n const isDeleteEvent = e => {\n const keyCode = e.keyCode;\n return keyCode === VK.BACKSPACE || keyCode === VK.DELETE;\n };\n const isNonTypingKeyboardEvent = e => {\n if (isKeyboardEvent(e)) {\n const keyCode = e.keyCode;\n return !isDeleteEvent(e) && (VK.metaKeyPressed(e) || e.altKey || keyCode >= 112 && keyCode <= 123 || contains$2(nonTypingKeycodes, keyCode));\n } else {\n return false;\n }\n };\n const isTypingKeyboardEvent = e => isKeyboardEvent(e) && !(isDeleteEvent(e) || e.type === 'keyup' && e.keyCode === 229);\n const isVisuallyEmpty = (dom, rootElm, forcedRootBlock) => {\n if (isEmpty$2(SugarElement.fromDom(rootElm), false)) {\n const firstElement = rootElm.firstElementChild;\n if (!firstElement) {\n return true;\n } else if (dom.getStyle(rootElm.firstElementChild, 'padding-left') || dom.getStyle(rootElm.firstElementChild, 'padding-right')) {\n return false;\n } else {\n return forcedRootBlock === firstElement.nodeName.toLowerCase();\n }\n } else {\n return false;\n }\n };\n const setup$r = editor => {\n var _a;\n const dom = editor.dom;\n const rootBlock = getForcedRootBlock(editor);\n const placeholder = (_a = getPlaceholder(editor)) !== null && _a !== void 0 ? _a : '';\n const updatePlaceholder = (e, initial) => {\n if (isNonTypingKeyboardEvent(e)) {\n return;\n }\n const body = editor.getBody();\n const showPlaceholder = isTypingKeyboardEvent(e) ? false : isVisuallyEmpty(dom, body, rootBlock);\n const isPlaceholderShown = dom.getAttrib(body, placeholderAttr) !== '';\n if (isPlaceholderShown !== showPlaceholder || initial) {\n dom.setAttrib(body, placeholderAttr, showPlaceholder ? placeholder : null);\n dom.setAttrib(body, 'aria-placeholder', showPlaceholder ? placeholder : null);\n firePlaceholderToggle(editor, showPlaceholder);\n editor.on(showPlaceholder ? 'keydown' : 'keyup', updatePlaceholder);\n editor.off(showPlaceholder ? 'keyup' : 'keydown', updatePlaceholder);\n }\n };\n if (isNotEmpty(placeholder)) {\n editor.on('init', e => {\n updatePlaceholder(e, true);\n editor.on('change SetContent ExecCommand', updatePlaceholder);\n editor.on('paste', e => Delay.setEditorTimeout(editor, () => updatePlaceholder(e)));\n });\n }\n };\n\n const blockPosition = (block, position) => ({\n block,\n position\n });\n const blockBoundary = (from, to) => ({\n from,\n to\n });\n const getBlockPosition = (rootNode, pos) => {\n const rootElm = SugarElement.fromDom(rootNode);\n const containerElm = SugarElement.fromDom(pos.container());\n return getParentBlock$2(rootElm, containerElm).map(block => blockPosition(block, pos));\n };\n const isDifferentBlocks = blockBoundary => !eq(blockBoundary.from.block, blockBoundary.to.block);\n const getClosestHost = (root, scope) => {\n const isRoot = node => eq(node, root);\n const isHost = node => isTableCell$2(node) || isContentEditableTrue$3(node.dom);\n return closest$4(scope, isHost, isRoot).filter(isElement$7).getOr(root);\n };\n const hasSameHost = (rootNode, blockBoundary) => {\n const root = SugarElement.fromDom(rootNode);\n return eq(getClosestHost(root, blockBoundary.from.block), getClosestHost(root, blockBoundary.to.block));\n };\n const isEditable$1 = blockBoundary => isContentEditableFalse$b(blockBoundary.from.block.dom) === false && isContentEditableFalse$b(blockBoundary.to.block.dom) === false;\n const hasValidBlocks = blockBoundary => {\n const isValidBlock = block => isTextBlock$2(block) || hasBlockAttr(block.dom);\n return isValidBlock(blockBoundary.from.block) && isValidBlock(blockBoundary.to.block);\n };\n const skipLastBr = (rootNode, forward, blockPosition) => {\n if (isBr$6(blockPosition.position.getNode()) && !isEmpty$2(blockPosition.block)) {\n return positionIn(false, blockPosition.block.dom).bind(lastPositionInBlock => {\n if (lastPositionInBlock.isEqual(blockPosition.position)) {\n return fromPosition(forward, rootNode, lastPositionInBlock).bind(to => getBlockPosition(rootNode, to));\n } else {\n return Optional.some(blockPosition);\n }\n }).getOr(blockPosition);\n } else {\n return blockPosition;\n }\n };\n const readFromRange = (rootNode, forward, rng) => {\n const fromBlockPos = getBlockPosition(rootNode, CaretPosition.fromRangeStart(rng));\n const toBlockPos = fromBlockPos.bind(blockPos => fromPosition(forward, rootNode, blockPos.position).bind(to => getBlockPosition(rootNode, to).map(blockPos => skipLastBr(rootNode, forward, blockPos))));\n return lift2(fromBlockPos, toBlockPos, blockBoundary).filter(blockBoundary => isDifferentBlocks(blockBoundary) && hasSameHost(rootNode, blockBoundary) && isEditable$1(blockBoundary) && hasValidBlocks(blockBoundary));\n };\n const read$1 = (rootNode, forward, rng) => rng.collapsed ? readFromRange(rootNode, forward, rng) : Optional.none();\n\n const getChildrenUntilBlockBoundary = (block, schema) => {\n const children = children$1(block);\n return findIndex$2(children, el => schema.isBlock(name(el))).fold(constant(children), index => children.slice(0, index));\n };\n const extractChildren = (block, schema) => {\n const children = getChildrenUntilBlockBoundary(block, schema);\n each$e(children, remove$5);\n return children;\n };\n const removeEmptyRoot = (rootNode, block) => {\n const parents = parentsAndSelf(block, rootNode);\n return find$2(parents.reverse(), element => isEmpty$2(element)).each(remove$5);\n };\n const isEmptyBefore = el => filter$5(prevSiblings(el), el => !isEmpty$2(el)).length === 0;\n const nestedBlockMerge = (rootNode, fromBlock, toBlock, schema, insertionPoint) => {\n if (isEmpty$2(toBlock)) {\n fillWithPaddingBr(toBlock);\n return firstPositionIn(toBlock.dom);\n }\n if (isEmptyBefore(insertionPoint) && isEmpty$2(fromBlock)) {\n before$3(insertionPoint, SugarElement.fromTag('br'));\n }\n const position = prevPosition(toBlock.dom, CaretPosition.before(insertionPoint.dom));\n each$e(extractChildren(fromBlock, schema), child => {\n before$3(insertionPoint, child);\n });\n removeEmptyRoot(rootNode, fromBlock);\n return position;\n };\n const isInline = (schema, node) => schema.isInline(name(node));\n const sidelongBlockMerge = (rootNode, fromBlock, toBlock, schema) => {\n if (isEmpty$2(toBlock)) {\n if (isEmpty$2(fromBlock)) {\n const getInlineToBlockDescendants = el => {\n const helper = (node, elements) => firstChild(node).fold(() => elements, child => isInline(schema, child) ? helper(child, elements.concat(shallow$1(child))) : elements);\n return helper(el, []);\n };\n const newFromBlockDescendants = foldr(getInlineToBlockDescendants(toBlock), (element, descendant) => {\n wrap$2(element, descendant);\n return descendant;\n }, createPaddingBr());\n empty(fromBlock);\n append$1(fromBlock, newFromBlockDescendants);\n }\n remove$5(toBlock);\n return firstPositionIn(fromBlock.dom);\n }\n const position = lastPositionIn(toBlock.dom);\n each$e(extractChildren(fromBlock, schema), child => {\n append$1(toBlock, child);\n });\n removeEmptyRoot(rootNode, fromBlock);\n return position;\n };\n const findInsertionPoint = (toBlock, block) => {\n const parentsAndSelf$1 = parentsAndSelf(block, toBlock);\n return Optional.from(parentsAndSelf$1[parentsAndSelf$1.length - 1]);\n };\n const getInsertionPoint = (fromBlock, toBlock) => contains(toBlock, fromBlock) ? findInsertionPoint(toBlock, fromBlock) : Optional.none();\n const trimBr = (first, block) => {\n positionIn(first, block.dom).bind(position => Optional.from(position.getNode())).map(SugarElement.fromDom).filter(isBr$5).each(remove$5);\n };\n const mergeBlockInto = (rootNode, fromBlock, toBlock, schema) => {\n trimBr(true, fromBlock);\n trimBr(false, toBlock);\n return getInsertionPoint(fromBlock, toBlock).fold(curry(sidelongBlockMerge, rootNode, fromBlock, toBlock, schema), curry(nestedBlockMerge, rootNode, fromBlock, toBlock, schema));\n };\n const mergeBlocks = (rootNode, forward, block1, block2, schema) => forward ? mergeBlockInto(rootNode, block2, block1, schema) : mergeBlockInto(rootNode, block1, block2, schema);\n\n const backspaceDelete$9 = (editor, forward) => {\n const rootNode = SugarElement.fromDom(editor.getBody());\n const position = read$1(rootNode.dom, forward, editor.selection.getRng()).map(blockBoundary => () => {\n mergeBlocks(rootNode, forward, blockBoundary.from.block, blockBoundary.to.block, editor.schema).each(pos => {\n editor.selection.setRng(pos.toRange());\n });\n });\n return position;\n };\n\n const deleteRangeMergeBlocks = (rootNode, selection, schema) => {\n const rng = selection.getRng();\n return lift2(getParentBlock$2(rootNode, SugarElement.fromDom(rng.startContainer)), getParentBlock$2(rootNode, SugarElement.fromDom(rng.endContainer)), (block1, block2) => {\n if (!eq(block1, block2)) {\n return Optional.some(() => {\n rng.deleteContents();\n mergeBlocks(rootNode, true, block1, block2, schema).each(pos => {\n selection.setRng(pos.toRange());\n });\n });\n } else {\n return Optional.none();\n }\n }).getOr(Optional.none());\n };\n const isRawNodeInTable = (root, rawNode) => {\n const node = SugarElement.fromDom(rawNode);\n const isRoot = curry(eq, root);\n return ancestor$4(node, isTableCell$2, isRoot).isSome();\n };\n const isSelectionInTable = (root, rng) => isRawNodeInTable(root, rng.startContainer) || isRawNodeInTable(root, rng.endContainer);\n const isEverythingSelected = (root, rng) => {\n const noPrevious = prevPosition(root.dom, CaretPosition.fromRangeStart(rng)).isNone();\n const noNext = nextPosition(root.dom, CaretPosition.fromRangeEnd(rng)).isNone();\n return !isSelectionInTable(root, rng) && noPrevious && noNext;\n };\n const emptyEditor = editor => {\n return Optional.some(() => {\n editor.setContent('');\n editor.selection.setCursorLocation();\n });\n };\n const deleteRange$2 = editor => {\n const rootNode = SugarElement.fromDom(editor.getBody());\n const rng = editor.selection.getRng();\n return isEverythingSelected(rootNode, rng) ? emptyEditor(editor) : deleteRangeMergeBlocks(rootNode, editor.selection, editor.schema);\n };\n const backspaceDelete$8 = (editor, _forward) => editor.selection.isCollapsed() ? Optional.none() : deleteRange$2(editor);\n\n const showCaret = (direction, editor, node, before, scrollIntoView) => Optional.from(editor._selectionOverrides.showCaret(direction, node, before, scrollIntoView));\n const getNodeRange = node => {\n const rng = node.ownerDocument.createRange();\n rng.selectNode(node);\n return rng;\n };\n const selectNode = (editor, node) => {\n const e = editor.dispatch('BeforeObjectSelected', { target: node });\n if (e.isDefaultPrevented()) {\n return Optional.none();\n }\n return Optional.some(getNodeRange(node));\n };\n const renderCaretAtRange = (editor, range, scrollIntoView) => {\n const normalizedRange = normalizeRange(1, editor.getBody(), range);\n const caretPosition = CaretPosition.fromRangeStart(normalizedRange);\n const caretPositionNode = caretPosition.getNode();\n if (isInlineFakeCaretTarget(caretPositionNode)) {\n return showCaret(1, editor, caretPositionNode, !caretPosition.isAtEnd(), false);\n }\n const caretPositionBeforeNode = caretPosition.getNode(true);\n if (isInlineFakeCaretTarget(caretPositionBeforeNode)) {\n return showCaret(1, editor, caretPositionBeforeNode, false, false);\n }\n const ceRoot = getContentEditableRoot$1(editor.dom.getRoot(), caretPosition.getNode());\n if (isInlineFakeCaretTarget(ceRoot)) {\n return showCaret(1, editor, ceRoot, false, scrollIntoView);\n }\n return Optional.none();\n };\n const renderRangeCaret = (editor, range, scrollIntoView) => range.collapsed ? renderCaretAtRange(editor, range, scrollIntoView).getOr(range) : range;\n\n const isBeforeBoundary = pos => isBeforeContentEditableFalse(pos) || isBeforeMedia(pos);\n const isAfterBoundary = pos => isAfterContentEditableFalse(pos) || isAfterMedia(pos);\n const trimEmptyTextNode = (dom, node) => {\n if (isText$a(node) && node.data.length === 0) {\n dom.remove(node);\n }\n };\n const deleteContentAndShowCaret = (editor, range, node, direction, forward, peekCaretPosition) => {\n showCaret(direction, editor, peekCaretPosition.getNode(!forward), forward, true).each(caretRange => {\n if (range.collapsed) {\n const deleteRange = range.cloneRange();\n if (forward) {\n deleteRange.setEnd(caretRange.startContainer, caretRange.startOffset);\n } else {\n deleteRange.setStart(caretRange.endContainer, caretRange.endOffset);\n }\n deleteRange.deleteContents();\n } else {\n range.deleteContents();\n }\n editor.selection.setRng(caretRange);\n });\n trimEmptyTextNode(editor.dom, node);\n };\n const deleteBoundaryText = (editor, forward) => {\n const range = editor.selection.getRng();\n if (!isText$a(range.commonAncestorContainer)) {\n return Optional.none();\n }\n const direction = forward ? HDirection.Forwards : HDirection.Backwards;\n const caretWalker = CaretWalker(editor.getBody());\n const getNextPosFn = curry(getVisualCaretPosition, forward ? caretWalker.next : caretWalker.prev);\n const isBeforeFn = forward ? isBeforeBoundary : isAfterBoundary;\n const caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);\n const nextCaretPosition = getNextPosFn(caretPosition);\n const normalizedNextCaretPosition = nextCaretPosition ? normalizePosition(forward, nextCaretPosition) : nextCaretPosition;\n if (!normalizedNextCaretPosition || !isMoveInsideSameBlock(caretPosition, normalizedNextCaretPosition)) {\n return Optional.none();\n } else if (isBeforeFn(normalizedNextCaretPosition)) {\n return Optional.some(() => deleteContentAndShowCaret(editor, range, caretPosition.getNode(), direction, forward, normalizedNextCaretPosition));\n }\n const peekCaretPosition = getNextPosFn(normalizedNextCaretPosition);\n if (peekCaretPosition && isBeforeFn(peekCaretPosition)) {\n if (isMoveInsideSameBlock(normalizedNextCaretPosition, peekCaretPosition)) {\n return Optional.some(() => deleteContentAndShowCaret(editor, range, caretPosition.getNode(), direction, forward, peekCaretPosition));\n }\n }\n return Optional.none();\n };\n const backspaceDelete$7 = (editor, forward) => deleteBoundaryText(editor, forward);\n\n const getEdgeCefPosition = (editor, atStart) => {\n const root = editor.getBody();\n return atStart ? firstPositionIn(root).filter(isBeforeContentEditableFalse) : lastPositionIn(root).filter(isAfterContentEditableFalse);\n };\n const isCefAtEdgeSelected = editor => {\n const rng = editor.selection.getRng();\n return !rng.collapsed && (getEdgeCefPosition(editor, true).exists(pos => pos.isEqual(CaretPosition.fromRangeStart(rng))) || getEdgeCefPosition(editor, false).exists(pos => pos.isEqual(CaretPosition.fromRangeEnd(rng))));\n };\n\n const isCompoundElement = node => isNonNullable(node) && (isTableCell$2(SugarElement.fromDom(node)) || isListItem$1(SugarElement.fromDom(node)));\n const DeleteAction = Adt.generate([\n { remove: ['element'] },\n { moveToElement: ['element'] },\n { moveToPosition: ['position'] }\n ]);\n const isAtContentEditableBlockCaret = (forward, from) => {\n const elm = from.getNode(!forward);\n const caretLocation = forward ? 'after' : 'before';\n return isElement$6(elm) && elm.getAttribute('data-mce-caret') === caretLocation;\n };\n const isDeleteFromCefDifferentBlocks = (root, forward, from, to, schema) => {\n const inSameBlock = elm => schema.isInline(elm.nodeName.toLowerCase()) && !isInSameBlock(from, to, root);\n return getRelativeCefElm(!forward, from).fold(() => getRelativeCefElm(forward, to).fold(never, inSameBlock), inSameBlock);\n };\n const deleteEmptyBlockOrMoveToCef = (root, forward, from, to) => {\n const toCefElm = to.getNode(!forward);\n return getParentBlock$2(SugarElement.fromDom(root), SugarElement.fromDom(from.getNode())).map(blockElm => isEmpty$2(blockElm) ? DeleteAction.remove(blockElm.dom) : DeleteAction.moveToElement(toCefElm)).orThunk(() => Optional.some(DeleteAction.moveToElement(toCefElm)));\n };\n const findCefPosition = (root, forward, from, schema) => fromPosition(forward, root, from).bind(to => {\n if (isCompoundElement(to.getNode())) {\n return Optional.none();\n } else if (isDeleteFromCefDifferentBlocks(root, forward, from, to, schema)) {\n return Optional.none();\n } else if (forward && isContentEditableFalse$b(to.getNode())) {\n return deleteEmptyBlockOrMoveToCef(root, forward, from, to);\n } else if (!forward && isContentEditableFalse$b(to.getNode(true))) {\n return deleteEmptyBlockOrMoveToCef(root, forward, from, to);\n } else if (forward && isAfterContentEditableFalse(from)) {\n return Optional.some(DeleteAction.moveToPosition(to));\n } else if (!forward && isBeforeContentEditableFalse(from)) {\n return Optional.some(DeleteAction.moveToPosition(to));\n } else {\n return Optional.none();\n }\n });\n const getContentEditableBlockAction = (forward, elm) => {\n if (isNullable(elm)) {\n return Optional.none();\n } else if (forward && isContentEditableFalse$b(elm.nextSibling)) {\n return Optional.some(DeleteAction.moveToElement(elm.nextSibling));\n } else if (!forward && isContentEditableFalse$b(elm.previousSibling)) {\n return Optional.some(DeleteAction.moveToElement(elm.previousSibling));\n } else {\n return Optional.none();\n }\n };\n const skipMoveToActionFromInlineCefToContent = (root, from, deleteAction) => deleteAction.fold(elm => Optional.some(DeleteAction.remove(elm)), elm => Optional.some(DeleteAction.moveToElement(elm)), to => {\n if (isInSameBlock(from, to, root)) {\n return Optional.none();\n } else {\n return Optional.some(DeleteAction.moveToPosition(to));\n }\n });\n const getContentEditableAction = (root, forward, from, schema) => {\n if (isAtContentEditableBlockCaret(forward, from)) {\n return getContentEditableBlockAction(forward, from.getNode(!forward)).orThunk(() => findCefPosition(root, forward, from, schema));\n } else {\n return findCefPosition(root, forward, from, schema).bind(deleteAction => skipMoveToActionFromInlineCefToContent(root, from, deleteAction));\n }\n };\n const read = (root, forward, rng, schema) => {\n const normalizedRange = normalizeRange(forward ? 1 : -1, root, rng);\n const from = CaretPosition.fromRangeStart(normalizedRange);\n const rootElement = SugarElement.fromDom(root);\n if (!forward && isAfterContentEditableFalse(from)) {\n return Optional.some(DeleteAction.remove(from.getNode(true)));\n } else if (forward && isBeforeContentEditableFalse(from)) {\n return Optional.some(DeleteAction.remove(from.getNode()));\n } else if (!forward && isBeforeContentEditableFalse(from) && isAfterBr(rootElement, from, schema)) {\n return findPreviousBr(rootElement, from, schema).map(br => DeleteAction.remove(br.getNode()));\n } else if (forward && isAfterContentEditableFalse(from) && isBeforeBr$1(rootElement, from, schema)) {\n return findNextBr(rootElement, from, schema).map(br => DeleteAction.remove(br.getNode()));\n } else {\n return getContentEditableAction(root, forward, from, schema);\n }\n };\n\n const deleteElement$1 = (editor, forward) => element => {\n editor._selectionOverrides.hideFakeCaret();\n deleteElement$2(editor, forward, SugarElement.fromDom(element));\n return true;\n };\n const moveToElement = (editor, forward) => element => {\n const pos = forward ? CaretPosition.before(element) : CaretPosition.after(element);\n editor.selection.setRng(pos.toRange());\n return true;\n };\n const moveToPosition = editor => pos => {\n editor.selection.setRng(pos.toRange());\n return true;\n };\n const getAncestorCe = (editor, node) => Optional.from(getContentEditableRoot$1(editor.getBody(), node));\n const backspaceDeleteCaret = (editor, forward) => {\n const selectedNode = editor.selection.getNode();\n return getAncestorCe(editor, selectedNode).filter(isContentEditableFalse$b).fold(() => read(editor.getBody(), forward, editor.selection.getRng(), editor.schema).map(deleteAction => () => deleteAction.fold(deleteElement$1(editor, forward), moveToElement(editor, forward), moveToPosition(editor))), () => Optional.some(noop));\n };\n const deleteOffscreenSelection = rootElement => {\n each$e(descendants(rootElement, '.mce-offscreen-selection'), remove$5);\n };\n const backspaceDeleteRange = (editor, forward) => {\n const selectedNode = editor.selection.getNode();\n if (isContentEditableFalse$b(selectedNode) && !isTableCell$3(selectedNode)) {\n const hasCefAncestor = getAncestorCe(editor, selectedNode.parentNode).filter(isContentEditableFalse$b);\n return hasCefAncestor.fold(() => Optional.some(() => {\n deleteOffscreenSelection(SugarElement.fromDom(editor.getBody()));\n deleteElement$2(editor, forward, SugarElement.fromDom(editor.selection.getNode()));\n paddEmptyBody(editor);\n }), () => Optional.some(noop));\n }\n if (isCefAtEdgeSelected(editor)) {\n return Optional.some(() => {\n deleteRangeContents(editor, editor.selection.getRng(), SugarElement.fromDom(editor.getBody()));\n });\n }\n return Optional.none();\n };\n const paddEmptyElement = editor => {\n const dom = editor.dom, selection = editor.selection;\n const ceRoot = getContentEditableRoot$1(editor.getBody(), selection.getNode());\n if (isContentEditableTrue$3(ceRoot) && dom.isBlock(ceRoot) && dom.isEmpty(ceRoot)) {\n const br = dom.create('br', { 'data-mce-bogus': '1' });\n dom.setHTML(ceRoot, '');\n ceRoot.appendChild(br);\n selection.setRng(CaretPosition.before(br).toRange());\n }\n return true;\n };\n const backspaceDelete$6 = (editor, forward) => {\n if (editor.selection.isCollapsed()) {\n return backspaceDeleteCaret(editor, forward);\n } else {\n return backspaceDeleteRange(editor, forward);\n }\n };\n\n const deleteCaret$2 = (editor, forward) => {\n const fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());\n return fromPosition(forward, editor.getBody(), fromPos).filter(pos => forward ? isBeforeImageBlock(pos) : isAfterImageBlock(pos)).bind(pos => getChildNodeAtRelativeOffset(forward ? 0 : -1, pos)).map(elm => () => editor.selection.select(elm));\n };\n const backspaceDelete$5 = (editor, forward) => editor.selection.isCollapsed() ? deleteCaret$2(editor, forward) : Optional.none();\n\n const isText$2 = isText$a;\n const startsWithCaretContainer = node => isText$2(node) && node.data[0] === ZWSP$1;\n const endsWithCaretContainer = node => isText$2(node) && node.data[node.data.length - 1] === ZWSP$1;\n const createZwsp = node => {\n var _a;\n const doc = (_a = node.ownerDocument) !== null && _a !== void 0 ? _a : document;\n return doc.createTextNode(ZWSP$1);\n };\n const insertBefore$1 = node => {\n var _a;\n if (isText$2(node.previousSibling)) {\n if (endsWithCaretContainer(node.previousSibling)) {\n return node.previousSibling;\n } else {\n node.previousSibling.appendData(ZWSP$1);\n return node.previousSibling;\n }\n } else if (isText$2(node)) {\n if (startsWithCaretContainer(node)) {\n return node;\n } else {\n node.insertData(0, ZWSP$1);\n return node;\n }\n } else {\n const newNode = createZwsp(node);\n (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(newNode, node);\n return newNode;\n }\n };\n const insertAfter$1 = node => {\n var _a, _b;\n if (isText$2(node.nextSibling)) {\n if (startsWithCaretContainer(node.nextSibling)) {\n return node.nextSibling;\n } else {\n node.nextSibling.insertData(0, ZWSP$1);\n return node.nextSibling;\n }\n } else if (isText$2(node)) {\n if (endsWithCaretContainer(node)) {\n return node;\n } else {\n node.appendData(ZWSP$1);\n return node;\n }\n } else {\n const newNode = createZwsp(node);\n if (node.nextSibling) {\n (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(newNode, node.nextSibling);\n } else {\n (_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.appendChild(newNode);\n }\n return newNode;\n }\n };\n const insertInline = (before, node) => before ? insertBefore$1(node) : insertAfter$1(node);\n const insertInlineBefore = curry(insertInline, true);\n const insertInlineAfter = curry(insertInline, false);\n\n const insertInlinePos = (pos, before) => {\n if (isText$a(pos.container())) {\n return insertInline(before, pos.container());\n } else {\n return insertInline(before, pos.getNode());\n }\n };\n const isPosCaretContainer = (pos, caret) => {\n const caretNode = caret.get();\n return caretNode && pos.container() === caretNode && isCaretContainerInline(caretNode);\n };\n const renderCaret = (caret, location) => location.fold(element => {\n remove$3(caret.get());\n const text = insertInlineBefore(element);\n caret.set(text);\n return Optional.some(CaretPosition(text, text.length - 1));\n }, element => firstPositionIn(element).map(pos => {\n if (!isPosCaretContainer(pos, caret)) {\n remove$3(caret.get());\n const text = insertInlinePos(pos, true);\n caret.set(text);\n return CaretPosition(text, 1);\n } else {\n const node = caret.get();\n return CaretPosition(node, 1);\n }\n }), element => lastPositionIn(element).map(pos => {\n if (!isPosCaretContainer(pos, caret)) {\n remove$3(caret.get());\n const text = insertInlinePos(pos, false);\n caret.set(text);\n return CaretPosition(text, text.length - 1);\n } else {\n const node = caret.get();\n return CaretPosition(node, node.length - 1);\n }\n }), element => {\n remove$3(caret.get());\n const text = insertInlineAfter(element);\n caret.set(text);\n return Optional.some(CaretPosition(text, 1));\n });\n\n const evaluateUntil = (fns, args) => {\n for (let i = 0; i < fns.length; i++) {\n const result = fns[i].apply(null, args);\n if (result.isSome()) {\n return result;\n }\n }\n return Optional.none();\n };\n\n const Location = Adt.generate([\n { before: ['element'] },\n { start: ['element'] },\n { end: ['element'] },\n { after: ['element'] }\n ]);\n const rescope$1 = (rootNode, node) => {\n const parentBlock = getParentBlock$3(node, rootNode);\n return parentBlock ? parentBlock : rootNode;\n };\n const before = (isInlineTarget, rootNode, pos) => {\n const nPos = normalizeForwards(pos);\n const scope = rescope$1(rootNode, nPos.container());\n return findRootInline(isInlineTarget, scope, nPos).fold(() => nextPosition(scope, nPos).bind(curry(findRootInline, isInlineTarget, scope)).map(inline => Location.before(inline)), Optional.none);\n };\n const isNotInsideFormatCaretContainer = (rootNode, elm) => getParentCaretContainer(rootNode, elm) === null;\n const findInsideRootInline = (isInlineTarget, rootNode, pos) => findRootInline(isInlineTarget, rootNode, pos).filter(curry(isNotInsideFormatCaretContainer, rootNode));\n const start$1 = (isInlineTarget, rootNode, pos) => {\n const nPos = normalizeBackwards(pos);\n return findInsideRootInline(isInlineTarget, rootNode, nPos).bind(inline => {\n const prevPos = prevPosition(inline, nPos);\n return prevPos.isNone() ? Optional.some(Location.start(inline)) : Optional.none();\n });\n };\n const end = (isInlineTarget, rootNode, pos) => {\n const nPos = normalizeForwards(pos);\n return findInsideRootInline(isInlineTarget, rootNode, nPos).bind(inline => {\n const nextPos = nextPosition(inline, nPos);\n return nextPos.isNone() ? Optional.some(Location.end(inline)) : Optional.none();\n });\n };\n const after = (isInlineTarget, rootNode, pos) => {\n const nPos = normalizeBackwards(pos);\n const scope = rescope$1(rootNode, nPos.container());\n return findRootInline(isInlineTarget, scope, nPos).fold(() => prevPosition(scope, nPos).bind(curry(findRootInline, isInlineTarget, scope)).map(inline => Location.after(inline)), Optional.none);\n };\n const isValidLocation = location => !isRtl(getElement(location));\n const readLocation = (isInlineTarget, rootNode, pos) => {\n const location = evaluateUntil([\n before,\n start$1,\n end,\n after\n ], [\n isInlineTarget,\n rootNode,\n pos\n ]);\n return location.filter(isValidLocation);\n };\n const getElement = location => location.fold(identity, identity, identity, identity);\n const getName = location => location.fold(constant('before'), constant('start'), constant('end'), constant('after'));\n const outside = location => location.fold(Location.before, Location.before, Location.after, Location.after);\n const inside = location => location.fold(Location.start, Location.start, Location.end, Location.end);\n const isEq = (location1, location2) => getName(location1) === getName(location2) && getElement(location1) === getElement(location2);\n const betweenInlines = (forward, isInlineTarget, rootNode, from, to, location) => lift2(findRootInline(isInlineTarget, rootNode, from), findRootInline(isInlineTarget, rootNode, to), (fromInline, toInline) => {\n if (fromInline !== toInline && hasSameParentBlock(rootNode, fromInline, toInline)) {\n return Location.after(forward ? fromInline : toInline);\n } else {\n return location;\n }\n }).getOr(location);\n const skipNoMovement = (fromLocation, toLocation) => fromLocation.fold(always, fromLocation => !isEq(fromLocation, toLocation));\n const findLocationTraverse = (forward, isInlineTarget, rootNode, fromLocation, pos) => {\n const from = normalizePosition(forward, pos);\n const to = fromPosition(forward, rootNode, from).map(curry(normalizePosition, forward));\n const location = to.fold(() => fromLocation.map(outside), to => readLocation(isInlineTarget, rootNode, to).map(curry(betweenInlines, forward, isInlineTarget, rootNode, from, to)).filter(curry(skipNoMovement, fromLocation)));\n return location.filter(isValidLocation);\n };\n const findLocationSimple = (forward, location) => {\n if (forward) {\n return location.fold(compose(Optional.some, Location.start), Optional.none, compose(Optional.some, Location.after), Optional.none);\n } else {\n return location.fold(Optional.none, compose(Optional.some, Location.before), Optional.none, compose(Optional.some, Location.end));\n }\n };\n const findLocation$1 = (forward, isInlineTarget, rootNode, pos) => {\n const from = normalizePosition(forward, pos);\n const fromLocation = readLocation(isInlineTarget, rootNode, from);\n return readLocation(isInlineTarget, rootNode, from).bind(curry(findLocationSimple, forward)).orThunk(() => findLocationTraverse(forward, isInlineTarget, rootNode, fromLocation, pos));\n };\n\n const hasSelectionModifyApi = editor => {\n return isFunction(editor.selection.getSel().modify);\n };\n const moveRel = (forward, selection, pos) => {\n const delta = forward ? 1 : -1;\n selection.setRng(CaretPosition(pos.container(), pos.offset() + delta).toRange());\n selection.getSel().modify('move', forward ? 'forward' : 'backward', 'word');\n return true;\n };\n const moveByWord = (forward, editor) => {\n const rng = editor.selection.getRng();\n const pos = forward ? CaretPosition.fromRangeEnd(rng) : CaretPosition.fromRangeStart(rng);\n if (!hasSelectionModifyApi(editor)) {\n return false;\n } else if (forward && isBeforeInline(pos)) {\n return moveRel(true, editor.selection, pos);\n } else if (!forward && isAfterInline(pos)) {\n return moveRel(false, editor.selection, pos);\n } else {\n return false;\n }\n };\n\n var BreakType;\n (function (BreakType) {\n BreakType[BreakType['Br'] = 0] = 'Br';\n BreakType[BreakType['Block'] = 1] = 'Block';\n BreakType[BreakType['Wrap'] = 2] = 'Wrap';\n BreakType[BreakType['Eol'] = 3] = 'Eol';\n }(BreakType || (BreakType = {})));\n const flip = (direction, positions) => direction === HDirection.Backwards ? reverse(positions) : positions;\n const walk$1 = (direction, caretWalker, pos) => direction === HDirection.Forwards ? caretWalker.next(pos) : caretWalker.prev(pos);\n const getBreakType = (scope, direction, currentPos, nextPos) => {\n if (isBr$6(nextPos.getNode(direction === HDirection.Forwards))) {\n return BreakType.Br;\n } else if (isInSameBlock(currentPos, nextPos) === false) {\n return BreakType.Block;\n } else {\n return BreakType.Wrap;\n }\n };\n const getPositionsUntil = (predicate, direction, scope, start) => {\n const caretWalker = CaretWalker(scope);\n let currentPos = start;\n const positions = [];\n while (currentPos) {\n const nextPos = walk$1(direction, caretWalker, currentPos);\n if (!nextPos) {\n break;\n }\n if (isBr$6(nextPos.getNode(false))) {\n if (direction === HDirection.Forwards) {\n return {\n positions: flip(direction, positions).concat([nextPos]),\n breakType: BreakType.Br,\n breakAt: Optional.some(nextPos)\n };\n } else {\n return {\n positions: flip(direction, positions),\n breakType: BreakType.Br,\n breakAt: Optional.some(nextPos)\n };\n }\n }\n if (!nextPos.isVisible()) {\n currentPos = nextPos;\n continue;\n }\n if (predicate(currentPos, nextPos)) {\n const breakType = getBreakType(scope, direction, currentPos, nextPos);\n return {\n positions: flip(direction, positions),\n breakType,\n breakAt: Optional.some(nextPos)\n };\n }\n positions.push(nextPos);\n currentPos = nextPos;\n }\n return {\n positions: flip(direction, positions),\n breakType: BreakType.Eol,\n breakAt: Optional.none()\n };\n };\n const getAdjacentLinePositions = (direction, getPositionsUntilBreak, scope, start) => getPositionsUntilBreak(scope, start).breakAt.map(pos => {\n const positions = getPositionsUntilBreak(scope, pos).positions;\n return direction === HDirection.Backwards ? positions.concat(pos) : [pos].concat(positions);\n }).getOr([]);\n const findClosestHorizontalPositionFromPoint = (positions, x) => foldl(positions, (acc, newPos) => acc.fold(() => Optional.some(newPos), lastPos => lift2(head(lastPos.getClientRects()), head(newPos.getClientRects()), (lastRect, newRect) => {\n const lastDist = Math.abs(x - lastRect.left);\n const newDist = Math.abs(x - newRect.left);\n return newDist <= lastDist ? newPos : lastPos;\n }).or(acc)), Optional.none());\n const findClosestHorizontalPosition = (positions, pos) => head(pos.getClientRects()).bind(targetRect => findClosestHorizontalPositionFromPoint(positions, targetRect.left));\n const getPositionsUntilPreviousLine = curry(getPositionsUntil, CaretPosition.isAbove, -1);\n const getPositionsUntilNextLine = curry(getPositionsUntil, CaretPosition.isBelow, 1);\n const getPositionsAbove = curry(getAdjacentLinePositions, -1, getPositionsUntilPreviousLine);\n const getPositionsBelow = curry(getAdjacentLinePositions, 1, getPositionsUntilNextLine);\n const isAtFirstLine = (scope, pos) => getPositionsUntilPreviousLine(scope, pos).breakAt.isNone();\n const isAtLastLine = (scope, pos) => getPositionsUntilNextLine(scope, pos).breakAt.isNone();\n const getFirstLinePositions = scope => firstPositionIn(scope).map(pos => [pos].concat(getPositionsUntilNextLine(scope, pos).positions)).getOr([]);\n const getLastLinePositions = scope => lastPositionIn(scope).map(pos => getPositionsUntilPreviousLine(scope, pos).positions.concat(pos)).getOr([]);\n const getClosestPositionAbove = (scope, pos) => findClosestHorizontalPosition(getPositionsAbove(scope, pos), pos);\n const getClosestPositionBelow = (scope, pos) => findClosestHorizontalPosition(getPositionsBelow(scope, pos), pos);\n\n const isContentEditableFalse$4 = isContentEditableFalse$b;\n const distanceToRectLeft$1 = (clientRect, clientX) => Math.abs(clientRect.left - clientX);\n const distanceToRectRight$1 = (clientRect, clientX) => Math.abs(clientRect.right - clientX);\n const isNodeClientRect = rect => hasNonNullableKey(rect, 'node');\n const findClosestClientRect = (clientRects, clientX) => reduce(clientRects, (oldClientRect, clientRect) => {\n const oldDistance = Math.min(distanceToRectLeft$1(oldClientRect, clientX), distanceToRectRight$1(oldClientRect, clientX));\n const newDistance = Math.min(distanceToRectLeft$1(clientRect, clientX), distanceToRectRight$1(clientRect, clientX));\n if (newDistance === oldDistance && isNodeClientRect(clientRect) && isContentEditableFalse$4(clientRect.node)) {\n return clientRect;\n }\n if (newDistance < oldDistance) {\n return clientRect;\n }\n return oldClientRect;\n });\n\n const getNodeClientRects = node => {\n const toArrayWithNode = clientRects => {\n return map$3(clientRects, rect => {\n const clientRect = clone$1(rect);\n clientRect.node = node;\n return clientRect;\n });\n };\n if (isElement$6(node)) {\n return toArrayWithNode(node.getClientRects());\n } else if (isText$a(node)) {\n const rng = node.ownerDocument.createRange();\n rng.setStart(node, 0);\n rng.setEnd(node, node.data.length);\n return toArrayWithNode(rng.getClientRects());\n } else {\n return [];\n }\n };\n const getClientRects = nodes => bind$3(nodes, getNodeClientRects);\n\n var VDirection;\n (function (VDirection) {\n VDirection[VDirection['Up'] = -1] = 'Up';\n VDirection[VDirection['Down'] = 1] = 'Down';\n }(VDirection || (VDirection = {})));\n const findUntil = (direction, root, predicateFn, node) => {\n let currentNode = node;\n while (currentNode = findNode(currentNode, direction, isEditableCaretCandidate$1, root)) {\n if (predicateFn(currentNode)) {\n return;\n }\n }\n };\n const walkUntil = (direction, isAboveFn, isBeflowFn, root, predicateFn, caretPosition) => {\n let line = 0;\n const result = [];\n const add = node => {\n let clientRects = getClientRects([node]);\n if (direction === -1) {\n clientRects = clientRects.reverse();\n }\n for (let i = 0; i < clientRects.length; i++) {\n const clientRect = clientRects[i];\n if (isBeflowFn(clientRect, targetClientRect)) {\n continue;\n }\n if (result.length > 0 && isAboveFn(clientRect, last$2(result))) {\n line++;\n }\n clientRect.line = line;\n if (predicateFn(clientRect)) {\n return true;\n }\n result.push(clientRect);\n }\n return false;\n };\n const targetClientRect = last$2(caretPosition.getClientRects());\n if (!targetClientRect) {\n return result;\n }\n const node = caretPosition.getNode();\n if (node) {\n add(node);\n findUntil(direction, root, add, node);\n }\n return result;\n };\n const aboveLineNumber = (lineNumber, clientRect) => clientRect.line > lineNumber;\n const isLineNumber = (lineNumber, clientRect) => clientRect.line === lineNumber;\n const upUntil = curry(walkUntil, VDirection.Up, isAbove$1, isBelow$1);\n const downUntil = curry(walkUntil, VDirection.Down, isBelow$1, isAbove$1);\n const getLastClientRect = caretPosition => {\n return last$2(caretPosition.getClientRects());\n };\n const positionsUntil = (direction, root, predicateFn, node) => {\n const caretWalker = CaretWalker(root);\n let walkFn;\n let isBelowFn;\n let isAboveFn;\n let caretPosition;\n const result = [];\n let line = 0;\n if (direction === 1) {\n walkFn = caretWalker.next;\n isBelowFn = isBelow$1;\n isAboveFn = isAbove$1;\n caretPosition = CaretPosition.after(node);\n } else {\n walkFn = caretWalker.prev;\n isBelowFn = isAbove$1;\n isAboveFn = isBelow$1;\n caretPosition = CaretPosition.before(node);\n }\n const targetClientRect = getLastClientRect(caretPosition);\n do {\n if (!caretPosition.isVisible()) {\n continue;\n }\n const rect = getLastClientRect(caretPosition);\n if (isAboveFn(rect, targetClientRect)) {\n continue;\n }\n if (result.length > 0 && isBelowFn(rect, last$2(result))) {\n line++;\n }\n const clientRect = clone$1(rect);\n clientRect.position = caretPosition;\n clientRect.line = line;\n if (predicateFn(clientRect)) {\n return result;\n }\n result.push(clientRect);\n } while (caretPosition = walkFn(caretPosition));\n return result;\n };\n const isAboveLine = lineNumber => clientRect => aboveLineNumber(lineNumber, clientRect);\n const isLine = lineNumber => clientRect => isLineNumber(lineNumber, clientRect);\n\n const moveToRange = (editor, rng) => {\n editor.selection.setRng(rng);\n scrollRangeIntoView(editor, editor.selection.getRng());\n };\n const renderRangeCaretOpt = (editor, range, scrollIntoView) => Optional.some(renderRangeCaret(editor, range, scrollIntoView));\n const moveHorizontally = (editor, direction, range, isBefore, isAfter, isElement) => {\n const forwards = direction === HDirection.Forwards;\n const caretWalker = CaretWalker(editor.getBody());\n const getNextPosFn = curry(getVisualCaretPosition, forwards ? caretWalker.next : caretWalker.prev);\n const isBeforeFn = forwards ? isBefore : isAfter;\n if (!range.collapsed) {\n const node = getSelectedNode(range);\n if (isElement(node)) {\n return showCaret(direction, editor, node, direction === HDirection.Backwards, false);\n } else if (isCefAtEdgeSelected(editor)) {\n const newRange = range.cloneRange();\n newRange.collapse(direction === HDirection.Backwards);\n return Optional.from(newRange);\n }\n }\n const caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);\n if (isBeforeFn(caretPosition)) {\n return selectNode(editor, caretPosition.getNode(!forwards));\n }\n let nextCaretPosition = getNextPosFn(caretPosition);\n const rangeIsInContainerBlock = isRangeInCaretContainerBlock(range);\n if (!nextCaretPosition) {\n return rangeIsInContainerBlock ? Optional.some(range) : Optional.none();\n } else {\n nextCaretPosition = normalizePosition(forwards, nextCaretPosition);\n }\n if (isBeforeFn(nextCaretPosition)) {\n return showCaret(direction, editor, nextCaretPosition.getNode(!forwards), forwards, false);\n }\n const peekCaretPosition = getNextPosFn(nextCaretPosition);\n if (peekCaretPosition && isBeforeFn(peekCaretPosition)) {\n if (isMoveInsideSameBlock(nextCaretPosition, peekCaretPosition)) {\n return showCaret(direction, editor, peekCaretPosition.getNode(!forwards), forwards, false);\n }\n }\n if (rangeIsInContainerBlock) {\n return renderRangeCaretOpt(editor, nextCaretPosition.toRange(), false);\n }\n return Optional.none();\n };\n const moveVertically = (editor, direction, range, isBefore, isAfter, isElement) => {\n const caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);\n const caretClientRect = last$2(caretPosition.getClientRects());\n const forwards = direction === VDirection.Down;\n const root = editor.getBody();\n if (!caretClientRect) {\n return Optional.none();\n }\n if (isCefAtEdgeSelected(editor)) {\n const caretPosition = forwards ? CaretPosition.fromRangeEnd(range) : CaretPosition.fromRangeStart(range);\n const getClosestFn = !forwards ? getClosestPositionAbove : getClosestPositionBelow;\n return getClosestFn(root, caretPosition).orThunk(() => Optional.from(caretPosition)).map(pos => pos.toRange());\n }\n const walkerFn = forwards ? downUntil : upUntil;\n const linePositions = walkerFn(root, isAboveLine(1), caretPosition);\n const nextLinePositions = filter$5(linePositions, isLine(1));\n const clientX = caretClientRect.left;\n const nextLineRect = findClosestClientRect(nextLinePositions, clientX);\n if (nextLineRect && isElement(nextLineRect.node)) {\n const dist1 = Math.abs(clientX - nextLineRect.left);\n const dist2 = Math.abs(clientX - nextLineRect.right);\n return showCaret(direction, editor, nextLineRect.node, dist1 < dist2, false);\n }\n let currentNode;\n if (isBefore(caretPosition)) {\n currentNode = caretPosition.getNode();\n } else if (isAfter(caretPosition)) {\n currentNode = caretPosition.getNode(true);\n } else {\n currentNode = getSelectedNode(range);\n }\n if (currentNode) {\n const caretPositions = positionsUntil(direction, root, isAboveLine(1), currentNode);\n let closestNextLineRect = findClosestClientRect(filter$5(caretPositions, isLine(1)), clientX);\n if (closestNextLineRect) {\n return renderRangeCaretOpt(editor, closestNextLineRect.position.toRange(), false);\n }\n closestNextLineRect = last$2(filter$5(caretPositions, isLine(0)));\n if (closestNextLineRect) {\n return renderRangeCaretOpt(editor, closestNextLineRect.position.toRange(), false);\n }\n }\n if (nextLinePositions.length === 0) {\n return getLineEndPoint(editor, forwards).filter(forwards ? isAfter : isBefore).map(pos => renderRangeCaret(editor, pos.toRange(), false));\n }\n return Optional.none();\n };\n const getLineEndPoint = (editor, forward) => {\n const rng = editor.selection.getRng();\n const from = forward ? CaretPosition.fromRangeEnd(rng) : CaretPosition.fromRangeStart(rng);\n const host = getEditingHost(from.container(), editor.getBody());\n if (forward) {\n const lineInfo = getPositionsUntilNextLine(host, from);\n return last$3(lineInfo.positions);\n } else {\n const lineInfo = getPositionsUntilPreviousLine(host, from);\n return head(lineInfo.positions);\n }\n };\n const moveToLineEndPoint$3 = (editor, forward, isElementPosition) => getLineEndPoint(editor, forward).filter(isElementPosition).exists(pos => {\n editor.selection.setRng(pos.toRange());\n return true;\n });\n\n const setCaretPosition = (editor, pos) => {\n const rng = editor.dom.createRng();\n rng.setStart(pos.container(), pos.offset());\n rng.setEnd(pos.container(), pos.offset());\n editor.selection.setRng(rng);\n };\n const setSelected = (state, elm) => {\n if (state) {\n elm.setAttribute('data-mce-selected', 'inline-boundary');\n } else {\n elm.removeAttribute('data-mce-selected');\n }\n };\n const renderCaretLocation = (editor, caret, location) => renderCaret(caret, location).map(pos => {\n setCaretPosition(editor, pos);\n return location;\n });\n const getPositionFromRange = (range, root, forward) => {\n const start = CaretPosition.fromRangeStart(range);\n if (range.collapsed) {\n return start;\n } else {\n const end = CaretPosition.fromRangeEnd(range);\n return forward ? prevPosition(root, end).getOr(end) : nextPosition(root, start).getOr(start);\n }\n };\n const findLocation = (editor, caret, forward) => {\n const rootNode = editor.getBody();\n const from = getPositionFromRange(editor.selection.getRng(), rootNode, forward);\n const isInlineTarget$1 = curry(isInlineTarget, editor);\n const location = findLocation$1(forward, isInlineTarget$1, rootNode, from);\n return location.bind(location => renderCaretLocation(editor, caret, location));\n };\n const toggleInlines = (isInlineTarget, dom, elms) => {\n const inlineBoundaries = map$3(descendants(SugarElement.fromDom(dom.getRoot()), '*[data-mce-selected=\"inline-boundary\"]'), e => e.dom);\n const selectedInlines = filter$5(inlineBoundaries, isInlineTarget);\n const targetInlines = filter$5(elms, isInlineTarget);\n each$e(difference(selectedInlines, targetInlines), curry(setSelected, false));\n each$e(difference(targetInlines, selectedInlines), curry(setSelected, true));\n };\n const safeRemoveCaretContainer = (editor, caret) => {\n const caretValue = caret.get();\n if (editor.selection.isCollapsed() && !editor.composing && caretValue) {\n const pos = CaretPosition.fromRangeStart(editor.selection.getRng());\n if (CaretPosition.isTextPosition(pos) && !isAtZwsp(pos)) {\n setCaretPosition(editor, removeAndReposition(caretValue, pos));\n caret.set(null);\n }\n }\n };\n const renderInsideInlineCaret = (isInlineTarget, editor, caret, elms) => {\n if (editor.selection.isCollapsed()) {\n const inlines = filter$5(elms, isInlineTarget);\n each$e(inlines, _inline => {\n const pos = CaretPosition.fromRangeStart(editor.selection.getRng());\n readLocation(isInlineTarget, editor.getBody(), pos).bind(location => renderCaretLocation(editor, caret, location));\n });\n }\n };\n const move$3 = (editor, caret, forward) => isInlineBoundariesEnabled(editor) ? findLocation(editor, caret, forward).isSome() : false;\n const moveWord = (forward, editor, _caret) => isInlineBoundariesEnabled(editor) ? moveByWord(forward, editor) : false;\n const setupSelectedState = editor => {\n const caret = Cell(null);\n const isInlineTarget$1 = curry(isInlineTarget, editor);\n editor.on('NodeChange', e => {\n if (isInlineBoundariesEnabled(editor)) {\n toggleInlines(isInlineTarget$1, editor.dom, e.parents);\n safeRemoveCaretContainer(editor, caret);\n renderInsideInlineCaret(isInlineTarget$1, editor, caret, e.parents);\n }\n });\n return caret;\n };\n const moveNextWord = curry(moveWord, true);\n const movePrevWord = curry(moveWord, false);\n const moveToLineEndPoint$2 = (editor, forward, caret) => {\n if (isInlineBoundariesEnabled(editor)) {\n const linePoint = getLineEndPoint(editor, forward).getOrThunk(() => {\n const rng = editor.selection.getRng();\n return forward ? CaretPosition.fromRangeEnd(rng) : CaretPosition.fromRangeStart(rng);\n });\n return readLocation(curry(isInlineTarget, editor), editor.getBody(), linePoint).exists(loc => {\n const outsideLoc = outside(loc);\n return renderCaret(caret, outsideLoc).exists(pos => {\n setCaretPosition(editor, pos);\n return true;\n });\n });\n } else {\n return false;\n }\n };\n\n const rangeFromPositions = (from, to) => {\n const range = document.createRange();\n range.setStart(from.container(), from.offset());\n range.setEnd(to.container(), to.offset());\n return range;\n };\n const hasOnlyTwoOrLessPositionsLeft = elm => lift2(firstPositionIn(elm), lastPositionIn(elm), (firstPos, lastPos) => {\n const normalizedFirstPos = normalizePosition(true, firstPos);\n const normalizedLastPos = normalizePosition(false, lastPos);\n return nextPosition(elm, normalizedFirstPos).forall(pos => pos.isEqual(normalizedLastPos));\n }).getOr(true);\n const setCaretLocation = (editor, caret) => location => renderCaret(caret, location).map(pos => () => setCaretPosition(editor, pos));\n const deleteFromTo = (editor, caret, from, to) => {\n const rootNode = editor.getBody();\n const isInlineTarget$1 = curry(isInlineTarget, editor);\n editor.undoManager.ignore(() => {\n editor.selection.setRng(rangeFromPositions(from, to));\n execNativeDeleteCommand(editor);\n readLocation(isInlineTarget$1, rootNode, CaretPosition.fromRangeStart(editor.selection.getRng())).map(inside).bind(setCaretLocation(editor, caret)).each(call);\n });\n editor.nodeChanged();\n };\n const rescope = (rootNode, node) => {\n const parentBlock = getParentBlock$3(node, rootNode);\n return parentBlock ? parentBlock : rootNode;\n };\n const backspaceDeleteCollapsed = (editor, caret, forward, from) => {\n const rootNode = rescope(editor.getBody(), from.container());\n const isInlineTarget$1 = curry(isInlineTarget, editor);\n const fromLocation = readLocation(isInlineTarget$1, rootNode, from);\n const location = fromLocation.bind(location => {\n if (forward) {\n return location.fold(constant(Optional.some(inside(location))), Optional.none, constant(Optional.some(outside(location))), Optional.none);\n } else {\n return location.fold(Optional.none, constant(Optional.some(outside(location))), Optional.none, constant(Optional.some(inside(location))));\n }\n });\n return location.map(setCaretLocation(editor, caret)).getOrThunk(() => {\n const toPosition = navigate(forward, rootNode, from);\n const toLocation = toPosition.bind(pos => readLocation(isInlineTarget$1, rootNode, pos));\n return lift2(fromLocation, toLocation, () => findRootInline(isInlineTarget$1, rootNode, from).bind(elm => {\n if (hasOnlyTwoOrLessPositionsLeft(elm)) {\n return Optional.some(() => {\n deleteElement$2(editor, forward, SugarElement.fromDom(elm));\n });\n } else {\n return Optional.none();\n }\n })).getOrThunk(() => toLocation.bind(() => toPosition.map(to => {\n return () => {\n if (forward) {\n deleteFromTo(editor, caret, from, to);\n } else {\n deleteFromTo(editor, caret, to, from);\n }\n };\n })));\n });\n };\n const backspaceDelete$4 = (editor, caret, forward) => {\n if (editor.selection.isCollapsed() && isInlineBoundariesEnabled(editor)) {\n const from = CaretPosition.fromRangeStart(editor.selection.getRng());\n return backspaceDeleteCollapsed(editor, caret, forward, from);\n }\n return Optional.none();\n };\n\n const hasMultipleChildren = elm => childNodesCount(elm) > 1;\n const getParentsUntil = (editor, pred) => {\n const rootElm = SugarElement.fromDom(editor.getBody());\n const startElm = SugarElement.fromDom(editor.selection.getStart());\n const parents = parentsAndSelf(startElm, rootElm);\n return findIndex$2(parents, pred).fold(constant(parents), index => parents.slice(0, index));\n };\n const hasOnlyOneChild = elm => childNodesCount(elm) === 1;\n const getParentInlinesUntilMultichildInline = editor => getParentsUntil(editor, elm => editor.schema.isBlock(name(elm)) || hasMultipleChildren(elm));\n const getParentInlines = editor => getParentsUntil(editor, el => editor.schema.isBlock(name(el)));\n const getFormatNodes = (editor, parentInlines) => {\n const isFormatElement$1 = curry(isFormatElement, editor);\n return bind$3(parentInlines, elm => isFormatElement$1(elm) ? [elm.dom] : []);\n };\n const getFormatNodesAtStart = editor => {\n const parentInlines = getParentInlines(editor);\n return getFormatNodes(editor, parentInlines);\n };\n const deleteLastPosition = (forward, editor, target, parentInlines) => {\n const formatNodes = getFormatNodes(editor, parentInlines);\n if (formatNodes.length === 0) {\n deleteElement$2(editor, forward, target);\n } else {\n const pos = replaceWithCaretFormat(target.dom, formatNodes);\n editor.selection.setRng(pos.toRange());\n }\n };\n const deleteCaret$1 = (editor, forward) => {\n const parentInlines = filter$5(getParentInlinesUntilMultichildInline(editor), hasOnlyOneChild);\n return last$3(parentInlines).bind(target => {\n const fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());\n if (willDeleteLastPositionInElement(forward, fromPos, target.dom) && !isEmptyCaretFormatElement(target)) {\n return Optional.some(() => deleteLastPosition(forward, editor, target, parentInlines));\n } else {\n return Optional.none();\n }\n });\n };\n const isBrInEmptyElement = (editor, elm) => {\n const parentElm = elm.parentElement;\n return isBr$6(elm) && !isNull(parentElm) && editor.dom.isEmpty(parentElm);\n };\n const isEmptyCaret = elm => isEmptyCaretFormatElement(SugarElement.fromDom(elm));\n const createCaretFormatAtStart = (editor, formatNodes) => {\n const startElm = editor.selection.getStart();\n const pos = isBrInEmptyElement(editor, startElm) || isEmptyCaret(startElm) ? replaceWithCaretFormat(startElm, formatNodes) : createCaretFormatAtStart$1(editor.selection.getRng(), formatNodes);\n editor.selection.setRng(pos.toRange());\n };\n const updateCaretFormat = (editor, updateFormats) => {\n const missingFormats = difference(updateFormats, getFormatNodesAtStart(editor));\n if (missingFormats.length > 0) {\n createCaretFormatAtStart(editor, missingFormats);\n }\n };\n const rangeStartsAtTextContainer = rng => isText$a(rng.startContainer);\n const rangeStartsAtStartOfTextContainer = rng => rng.startOffset === 0 && rangeStartsAtTextContainer(rng);\n const rangeStartParentIsFormatElement = (editor, rng) => {\n const startParent = rng.startContainer.parentElement;\n return !isNull(startParent) && isFormatElement(editor, SugarElement.fromDom(startParent));\n };\n const rangeStartAndEndHaveSameParent = rng => {\n const startParent = rng.startContainer.parentNode;\n const endParent = rng.endContainer.parentNode;\n return !isNull(startParent) && !isNull(endParent) && startParent.isEqualNode(endParent);\n };\n const rangeEndsAtEndOfEndContainer = rng => {\n const endContainer = rng.endContainer;\n return rng.endOffset === (isText$a(endContainer) ? endContainer.length : endContainer.childNodes.length);\n };\n const rangeEndsAtEndOfStartContainer = rng => rangeStartAndEndHaveSameParent(rng) && rangeEndsAtEndOfEndContainer(rng);\n const rangeEndsAfterEndOfStartContainer = rng => !rng.endContainer.isEqualNode(rng.commonAncestorContainer);\n const rangeEndsAtOrAfterEndOfStartContainer = rng => rangeEndsAtEndOfStartContainer(rng) || rangeEndsAfterEndOfStartContainer(rng);\n const requiresDeleteRangeOverride = editor => {\n const rng = editor.selection.getRng();\n return rangeStartsAtStartOfTextContainer(rng) && rangeStartParentIsFormatElement(editor, rng) && rangeEndsAtOrAfterEndOfStartContainer(rng);\n };\n const deleteRange$1 = editor => {\n if (requiresDeleteRangeOverride(editor)) {\n const formatNodes = getFormatNodesAtStart(editor);\n return Optional.some(() => {\n execNativeDeleteCommand(editor);\n updateCaretFormat(editor, formatNodes);\n });\n } else {\n return Optional.none();\n }\n };\n const backspaceDelete$3 = (editor, forward) => editor.selection.isCollapsed() ? deleteCaret$1(editor, forward) : deleteRange$1(editor);\n const hasAncestorInlineCaret = (elm, schema) => ancestor$1(elm, node => isCaretNode(node.dom), el => schema.isBlock(name(el)));\n const hasAncestorInlineCaretAtStart = editor => hasAncestorInlineCaret(SugarElement.fromDom(editor.selection.getStart()), editor.schema);\n const requiresRefreshCaretOverride = editor => {\n const rng = editor.selection.getRng();\n return rng.collapsed && (rangeStartsAtTextContainer(rng) || editor.dom.isEmpty(rng.startContainer)) && !hasAncestorInlineCaretAtStart(editor);\n };\n const refreshCaret = editor => {\n if (requiresRefreshCaretOverride(editor)) {\n createCaretFormatAtStart(editor, []);\n }\n return true;\n };\n\n const deleteElement = (editor, forward, element) => {\n if (isNonNullable(element)) {\n return Optional.some(() => {\n editor._selectionOverrides.hideFakeCaret();\n deleteElement$2(editor, forward, SugarElement.fromDom(element));\n });\n } else {\n return Optional.none();\n }\n };\n const deleteCaret = (editor, forward) => {\n const isNearMedia = forward ? isBeforeMedia : isAfterMedia;\n const direction = forward ? HDirection.Forwards : HDirection.Backwards;\n const fromPos = getNormalizedRangeEndPoint(direction, editor.getBody(), editor.selection.getRng());\n if (isNearMedia(fromPos)) {\n return deleteElement(editor, forward, fromPos.getNode(!forward));\n } else {\n return Optional.from(normalizePosition(forward, fromPos)).filter(pos => isNearMedia(pos) && isMoveInsideSameBlock(fromPos, pos)).bind(pos => deleteElement(editor, forward, pos.getNode(!forward)));\n }\n };\n const deleteRange = (editor, forward) => {\n const selectedNode = editor.selection.getNode();\n return isMedia$2(selectedNode) ? deleteElement(editor, forward, selectedNode) : Optional.none();\n };\n const backspaceDelete$2 = (editor, forward) => editor.selection.isCollapsed() ? deleteCaret(editor, forward) : deleteRange(editor, forward);\n\n const isEditable = target => closest$4(target, elm => isContentEditableTrue$3(elm.dom) || isContentEditableFalse$b(elm.dom)).exists(elm => isContentEditableTrue$3(elm.dom));\n const parseIndentValue = value => toInt(value !== null && value !== void 0 ? value : '').getOr(0);\n const getIndentStyleName = (useMargin, element) => {\n const indentStyleName = useMargin || isTable$1(element) ? 'margin' : 'padding';\n const suffix = get$7(element, 'direction') === 'rtl' ? '-right' : '-left';\n return indentStyleName + suffix;\n };\n const indentElement = (dom, command, useMargin, value, unit, element) => {\n const indentStyleName = getIndentStyleName(useMargin, SugarElement.fromDom(element));\n const parsedValue = parseIndentValue(dom.getStyle(element, indentStyleName));\n if (command === 'outdent') {\n const styleValue = Math.max(0, parsedValue - value);\n dom.setStyle(element, indentStyleName, styleValue ? styleValue + unit : '');\n } else {\n const styleValue = parsedValue + value + unit;\n dom.setStyle(element, indentStyleName, styleValue);\n }\n };\n const validateBlocks = (editor, blocks) => forall(blocks, block => {\n const indentStyleName = getIndentStyleName(shouldIndentUseMargin(editor), block);\n const intentValue = getRaw(block, indentStyleName).map(parseIndentValue).getOr(0);\n const contentEditable = editor.dom.getContentEditable(block.dom);\n return contentEditable !== 'false' && intentValue > 0;\n });\n const canOutdent = editor => {\n const blocks = getBlocksToIndent(editor);\n return !editor.mode.isReadOnly() && (blocks.length > 1 || validateBlocks(editor, blocks));\n };\n const isListComponent = el => isList(el) || isListItem$1(el);\n const parentIsListComponent = el => parent(el).exists(isListComponent);\n const getBlocksToIndent = editor => filter$5(fromDom$1(editor.selection.getSelectedBlocks()), el => !isListComponent(el) && !parentIsListComponent(el) && isEditable(el));\n const handle = (editor, command) => {\n var _a, _b;\n const {dom} = editor;\n const indentation = getIndentation(editor);\n const indentUnit = (_b = (_a = /[a-z%]+$/i.exec(indentation)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 'px';\n const indentValue = parseIndentValue(indentation);\n const useMargin = shouldIndentUseMargin(editor);\n each$e(getBlocksToIndent(editor), block => {\n indentElement(dom, command, useMargin, indentValue, indentUnit, block.dom);\n });\n };\n const indent = editor => handle(editor, 'indent');\n const outdent = editor => handle(editor, 'outdent');\n\n const backspaceDelete$1 = editor => {\n if (editor.selection.isCollapsed() && canOutdent(editor)) {\n const dom = editor.dom;\n const rng = editor.selection.getRng();\n const pos = CaretPosition.fromRangeStart(rng);\n const block = dom.getParent(rng.startContainer, dom.isBlock);\n if (block !== null && isAtStartOfBlock(SugarElement.fromDom(block), pos, editor.schema)) {\n return Optional.some(() => outdent(editor));\n }\n }\n return Optional.none();\n };\n\n const findAction = (editor, caret, forward) => findMap([\n backspaceDelete$1,\n backspaceDelete$6,\n backspaceDelete$7,\n (editor, forward) => backspaceDelete$4(editor, caret, forward),\n backspaceDelete$9,\n backspaceDelete$a,\n backspaceDelete$5,\n backspaceDelete$2,\n backspaceDelete$8,\n backspaceDelete$3\n ], item => item(editor, forward)).filter(_ => editor.selection.isEditable());\n const deleteCommand = (editor, caret) => {\n const result = findAction(editor, caret, false);\n result.fold(() => {\n if (editor.selection.isEditable()) {\n execNativeDeleteCommand(editor);\n paddEmptyBody(editor);\n }\n }, call);\n };\n const forwardDeleteCommand = (editor, caret) => {\n const result = findAction(editor, caret, true);\n result.fold(() => {\n if (editor.selection.isEditable()) {\n execNativeForwardDeleteCommand(editor);\n }\n }, call);\n };\n const setup$q = (editor, caret) => {\n editor.addCommand('delete', () => {\n deleteCommand(editor, caret);\n });\n editor.addCommand('forwardDelete', () => {\n forwardDeleteCommand(editor, caret);\n });\n };\n\n const SIGNIFICANT_MOVE = 5;\n const LONGPRESS_DELAY = 400;\n const getTouch = event => {\n if (event.touches === undefined || event.touches.length !== 1) {\n return Optional.none();\n }\n return Optional.some(event.touches[0]);\n };\n const isFarEnough = (touch, data) => {\n const distX = Math.abs(touch.clientX - data.x);\n const distY = Math.abs(touch.clientY - data.y);\n return distX > SIGNIFICANT_MOVE || distY > SIGNIFICANT_MOVE;\n };\n const setup$p = editor => {\n const startData = value$2();\n const longpressFired = Cell(false);\n const debounceLongpress = last$1(e => {\n editor.dispatch('longpress', {\n ...e,\n type: 'longpress'\n });\n longpressFired.set(true);\n }, LONGPRESS_DELAY);\n editor.on('touchstart', e => {\n getTouch(e).each(touch => {\n debounceLongpress.cancel();\n const data = {\n x: touch.clientX,\n y: touch.clientY,\n target: e.target\n };\n debounceLongpress.throttle(e);\n longpressFired.set(false);\n startData.set(data);\n });\n }, true);\n editor.on('touchmove', e => {\n debounceLongpress.cancel();\n getTouch(e).each(touch => {\n startData.on(data => {\n if (isFarEnough(touch, data)) {\n startData.clear();\n longpressFired.set(false);\n editor.dispatch('longpresscancel');\n }\n });\n });\n }, true);\n editor.on('touchend touchcancel', e => {\n debounceLongpress.cancel();\n if (e.type === 'touchcancel') {\n return;\n }\n startData.get().filter(data => data.target.isEqualNode(e.target)).each(() => {\n if (longpressFired.get()) {\n e.preventDefault();\n } else {\n editor.dispatch('tap', {\n ...e,\n type: 'tap'\n });\n }\n });\n }, true);\n };\n\n const isBlockElement = (blockElements, node) => has$2(blockElements, node.nodeName);\n const isValidTarget = (schema, node) => {\n if (isText$a(node)) {\n return true;\n } else if (isElement$6(node)) {\n return !isBlockElement(schema.getBlockElements(), node) && !isBookmarkNode$1(node) && !isTransparentBlock(schema, node) && !isNonHtmlElementRoot(node);\n } else {\n return false;\n }\n };\n const hasBlockParent = (blockElements, root, node) => {\n return exists(parents(SugarElement.fromDom(node), SugarElement.fromDom(root)), elm => {\n return isBlockElement(blockElements, elm.dom);\n });\n };\n const shouldRemoveTextNode = (blockElements, node) => {\n if (isText$a(node)) {\n if (node.data.length === 0) {\n return true;\n } else if (/^\\s+$/.test(node.data)) {\n return !node.nextSibling || isBlockElement(blockElements, node.nextSibling) || isNonHtmlElementRoot(node.nextSibling);\n }\n }\n return false;\n };\n const createRootBlock = editor => editor.dom.create(getForcedRootBlock(editor), getForcedRootBlockAttrs(editor));\n const addRootBlocks = editor => {\n const dom = editor.dom, selection = editor.selection;\n const schema = editor.schema;\n const blockElements = schema.getBlockElements();\n const startNode = selection.getStart();\n const rootNode = editor.getBody();\n let rootBlockNode;\n let tempNode;\n let wrapped = false;\n const forcedRootBlock = getForcedRootBlock(editor);\n if (!startNode || !isElement$6(startNode)) {\n return;\n }\n const rootNodeName = rootNode.nodeName.toLowerCase();\n if (!schema.isValidChild(rootNodeName, forcedRootBlock.toLowerCase()) || hasBlockParent(blockElements, rootNode, startNode)) {\n return;\n }\n const rng = selection.getRng();\n const {startContainer, startOffset, endContainer, endOffset} = rng;\n const restoreSelection = hasFocus(editor);\n let node = rootNode.firstChild;\n while (node) {\n if (isElement$6(node)) {\n updateElement(schema, node);\n }\n if (isValidTarget(schema, node)) {\n if (shouldRemoveTextNode(blockElements, node)) {\n tempNode = node;\n node = node.nextSibling;\n dom.remove(tempNode);\n continue;\n }\n if (!rootBlockNode) {\n rootBlockNode = createRootBlock(editor);\n rootNode.insertBefore(rootBlockNode, node);\n wrapped = true;\n }\n tempNode = node;\n node = node.nextSibling;\n rootBlockNode.appendChild(tempNode);\n } else {\n rootBlockNode = null;\n node = node.nextSibling;\n }\n }\n if (wrapped && restoreSelection) {\n rng.setStart(startContainer, startOffset);\n rng.setEnd(endContainer, endOffset);\n selection.setRng(rng);\n editor.nodeChanged();\n }\n };\n const insertEmptyLine = (editor, root, insertBlock) => {\n const block = SugarElement.fromDom(createRootBlock(editor));\n const br = createPaddingBr();\n append$1(block, br);\n insertBlock(root, block);\n const rng = document.createRange();\n rng.setStartBefore(br.dom);\n rng.setEndBefore(br.dom);\n return rng;\n };\n const setup$o = editor => {\n editor.on('NodeChange', curry(addRootBlocks, editor));\n };\n\n const hasClass = checkClassName => node => (' ' + node.attr('class') + ' ').indexOf(checkClassName) !== -1;\n const replaceMatchWithSpan = (editor, content, cls) => {\n return function (match) {\n const args = arguments, index = args[args.length - 2];\n const prevChar = index > 0 ? content.charAt(index - 1) : '';\n if (prevChar === '\"') {\n return match;\n }\n if (prevChar === '>') {\n const findStartTagIndex = content.lastIndexOf('<', index);\n if (findStartTagIndex !== -1) {\n const tagHtml = content.substring(findStartTagIndex, index);\n if (tagHtml.indexOf('contenteditable=\"false\"') !== -1) {\n return match;\n }\n }\n }\n return '' + editor.dom.encode(typeof args[1] === 'string' ? args[1] : args[0]) + '';\n };\n };\n const convertRegExpsToNonEditable = (editor, nonEditableRegExps, e) => {\n let i = nonEditableRegExps.length, content = e.content;\n if (e.format === 'raw') {\n return;\n }\n while (i--) {\n content = content.replace(nonEditableRegExps[i], replaceMatchWithSpan(editor, content, getNonEditableClass(editor)));\n }\n e.content = content;\n };\n const setup$n = editor => {\n const contentEditableAttrName = 'contenteditable';\n const editClass = ' ' + Tools.trim(getEditableClass(editor)) + ' ';\n const nonEditClass = ' ' + Tools.trim(getNonEditableClass(editor)) + ' ';\n const hasEditClass = hasClass(editClass);\n const hasNonEditClass = hasClass(nonEditClass);\n const nonEditableRegExps = getNonEditableRegExps(editor);\n if (nonEditableRegExps.length > 0) {\n editor.on('BeforeSetContent', e => {\n convertRegExpsToNonEditable(editor, nonEditableRegExps, e);\n });\n }\n editor.parser.addAttributeFilter('class', nodes => {\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n if (hasEditClass(node)) {\n node.attr(contentEditableAttrName, 'true');\n } else if (hasNonEditClass(node)) {\n node.attr(contentEditableAttrName, 'false');\n }\n }\n });\n editor.serializer.addAttributeFilter(contentEditableAttrName, nodes => {\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n if (!hasEditClass(node) && !hasNonEditClass(node)) {\n continue;\n }\n if (nonEditableRegExps.length > 0 && node.attr('data-mce-content')) {\n node.name = '#text';\n node.type = 3;\n node.raw = true;\n node.value = node.attr('data-mce-content');\n } else {\n node.attr(contentEditableAttrName, null);\n }\n }\n });\n };\n\n const findBlockCaretContainer = editor => descendant$1(SugarElement.fromDom(editor.getBody()), '*[data-mce-caret]').map(elm => elm.dom).getOrNull();\n const showBlockCaretContainer = (editor, blockCaretContainer) => {\n if (blockCaretContainer.hasAttribute('data-mce-caret')) {\n showCaretContainerBlock(blockCaretContainer);\n editor.selection.setRng(editor.selection.getRng());\n editor.selection.scrollIntoView(blockCaretContainer);\n }\n };\n const handleBlockContainer = (editor, e) => {\n const blockCaretContainer = findBlockCaretContainer(editor);\n if (!blockCaretContainer) {\n return;\n }\n if (e.type === 'compositionstart') {\n e.preventDefault();\n e.stopPropagation();\n showBlockCaretContainer(editor, blockCaretContainer);\n return;\n }\n if (hasContent(blockCaretContainer)) {\n showBlockCaretContainer(editor, blockCaretContainer);\n editor.undoManager.add();\n }\n };\n const setup$m = editor => {\n editor.on('keyup compositionstart', curry(handleBlockContainer, editor));\n };\n\n const isContentEditableFalse$3 = isContentEditableFalse$b;\n const moveToCeFalseHorizontally = (direction, editor, range) => moveHorizontally(editor, direction, range, isBeforeContentEditableFalse, isAfterContentEditableFalse, isContentEditableFalse$3);\n const moveToCeFalseVertically = (direction, editor, range) => {\n const isBefore = caretPosition => isBeforeContentEditableFalse(caretPosition) || isBeforeTable(caretPosition);\n const isAfter = caretPosition => isAfterContentEditableFalse(caretPosition) || isAfterTable(caretPosition);\n return moveVertically(editor, direction, range, isBefore, isAfter, isContentEditableFalse$3);\n };\n const createTextBlock = editor => {\n const textBlock = editor.dom.create(getForcedRootBlock(editor));\n textBlock.innerHTML = '
    ';\n return textBlock;\n };\n const exitPreBlock = (editor, direction, range) => {\n const caretWalker = CaretWalker(editor.getBody());\n const getVisualCaretPosition$1 = curry(getVisualCaretPosition, direction === 1 ? caretWalker.next : caretWalker.prev);\n if (range.collapsed) {\n const pre = editor.dom.getParent(range.startContainer, 'PRE');\n if (!pre) {\n return;\n }\n const caretPos = getVisualCaretPosition$1(CaretPosition.fromRangeStart(range));\n if (!caretPos) {\n const newBlock = SugarElement.fromDom(createTextBlock(editor));\n if (direction === 1) {\n after$4(SugarElement.fromDom(pre), newBlock);\n } else {\n before$3(SugarElement.fromDom(pre), newBlock);\n }\n editor.selection.select(newBlock.dom, true);\n editor.selection.collapse();\n }\n }\n };\n const getHorizontalRange = (editor, forward) => {\n const direction = forward ? HDirection.Forwards : HDirection.Backwards;\n const range = editor.selection.getRng();\n return moveToCeFalseHorizontally(direction, editor, range).orThunk(() => {\n exitPreBlock(editor, direction, range);\n return Optional.none();\n });\n };\n const getVerticalRange = (editor, down) => {\n const direction = down ? 1 : -1;\n const range = editor.selection.getRng();\n return moveToCeFalseVertically(direction, editor, range).orThunk(() => {\n exitPreBlock(editor, direction, range);\n return Optional.none();\n });\n };\n const flipDirection = (selection, forward) => {\n const elm = forward ? selection.getEnd(true) : selection.getStart(true);\n return isRtl(elm) ? !forward : forward;\n };\n const moveH$2 = (editor, forward) => getHorizontalRange(editor, flipDirection(editor.selection, forward)).exists(newRange => {\n moveToRange(editor, newRange);\n return true;\n });\n const moveV$4 = (editor, down) => getVerticalRange(editor, down).exists(newRange => {\n moveToRange(editor, newRange);\n return true;\n });\n const moveToLineEndPoint$1 = (editor, forward) => {\n const isCefPosition = forward ? isAfterContentEditableFalse : isBeforeContentEditableFalse;\n return moveToLineEndPoint$3(editor, forward, isCefPosition);\n };\n const selectToEndPoint = (editor, forward) => getEdgeCefPosition(editor, !forward).map(pos => {\n const rng = pos.toRange();\n const curRng = editor.selection.getRng();\n if (forward) {\n rng.setStart(curRng.startContainer, curRng.startOffset);\n } else {\n rng.setEnd(curRng.endContainer, curRng.endOffset);\n }\n return rng;\n }).exists(rng => {\n moveToRange(editor, rng);\n return true;\n });\n\n const isTarget = node => contains$2(['figcaption'], name(node));\n const getClosestTargetBlock = (pos, root, schema) => {\n const isRoot = curry(eq, root);\n return closest$4(SugarElement.fromDom(pos.container()), el => schema.isBlock(name(el)), isRoot).filter(isTarget);\n };\n const isAtFirstOrLastLine = (root, forward, pos) => forward ? isAtLastLine(root.dom, pos) : isAtFirstLine(root.dom, pos);\n const moveCaretToNewEmptyLine = (editor, forward) => {\n const root = SugarElement.fromDom(editor.getBody());\n const pos = CaretPosition.fromRangeStart(editor.selection.getRng());\n return getClosestTargetBlock(pos, root, editor.schema).exists(() => {\n if (isAtFirstOrLastLine(root, forward, pos)) {\n const insertFn = forward ? append$1 : prepend;\n const rng = insertEmptyLine(editor, root, insertFn);\n editor.selection.setRng(rng);\n return true;\n } else {\n return false;\n }\n });\n };\n const moveV$3 = (editor, forward) => {\n if (editor.selection.isCollapsed()) {\n return moveCaretToNewEmptyLine(editor, forward);\n } else {\n return false;\n }\n };\n\n const moveUp = (editor, details, summary) => {\n const rng = editor.selection.getRng();\n const pos = CaretPosition.fromRangeStart(rng);\n const root = editor.getBody();\n if (root.firstChild === details && isAtFirstLine(summary, pos)) {\n editor.execCommand('InsertNewBlockBefore');\n return true;\n } else {\n return false;\n }\n };\n const moveDown = (editor, details) => {\n const rng = editor.selection.getRng();\n const pos = CaretPosition.fromRangeStart(rng);\n const root = editor.getBody();\n if (root.lastChild === details && isAtLastLine(details, pos)) {\n editor.execCommand('InsertNewBlockAfter');\n return true;\n } else {\n return false;\n }\n };\n const move$2 = (editor, forward) => {\n if (forward) {\n return Optional.from(editor.dom.getParent(editor.selection.getNode(), 'details')).map(details => moveDown(editor, details)).getOr(false);\n } else {\n return Optional.from(editor.dom.getParent(editor.selection.getNode(), 'summary')).bind(summary => Optional.from(editor.dom.getParent(summary, 'details')).map(details => moveUp(editor, details, summary))).getOr(false);\n }\n };\n const moveV$2 = (editor, forward) => move$2(editor, forward);\n\n const baseKeyPattern = {\n shiftKey: false,\n altKey: false,\n ctrlKey: false,\n metaKey: false,\n keyCode: 0\n };\n const defaultPatterns = patterns => map$3(patterns, pattern => ({\n ...baseKeyPattern,\n ...pattern\n }));\n const defaultDelayedPatterns = patterns => map$3(patterns, pattern => ({\n ...baseKeyPattern,\n ...pattern\n }));\n const matchesEvent = (pattern, evt) => evt.keyCode === pattern.keyCode && evt.shiftKey === pattern.shiftKey && evt.altKey === pattern.altKey && evt.ctrlKey === pattern.ctrlKey && evt.metaKey === pattern.metaKey;\n const match$1 = (patterns, evt) => bind$3(defaultPatterns(patterns), pattern => matchesEvent(pattern, evt) ? [pattern] : []);\n const matchDelayed = (patterns, evt) => bind$3(defaultDelayedPatterns(patterns), pattern => matchesEvent(pattern, evt) ? [pattern] : []);\n const action = (f, ...x) => () => f.apply(null, x);\n const execute = (patterns, evt) => find$2(match$1(patterns, evt), pattern => pattern.action());\n const executeWithDelayedAction = (patterns, evt) => findMap(matchDelayed(patterns, evt), pattern => pattern.action());\n\n const moveH$1 = (editor, forward) => {\n const direction = forward ? HDirection.Forwards : HDirection.Backwards;\n const range = editor.selection.getRng();\n return moveHorizontally(editor, direction, range, isBeforeMedia, isAfterMedia, isMedia$2).exists(newRange => {\n moveToRange(editor, newRange);\n return true;\n });\n };\n const moveV$1 = (editor, down) => {\n const direction = down ? 1 : -1;\n const range = editor.selection.getRng();\n return moveVertically(editor, direction, range, isBeforeMedia, isAfterMedia, isMedia$2).exists(newRange => {\n moveToRange(editor, newRange);\n return true;\n });\n };\n const moveToLineEndPoint = (editor, forward) => {\n const isNearMedia = forward ? isAfterMedia : isBeforeMedia;\n return moveToLineEndPoint$3(editor, forward, isNearMedia);\n };\n\n const adt = Adt.generate([\n { none: ['current'] },\n { first: ['current'] },\n {\n middle: [\n 'current',\n 'target'\n ]\n },\n { last: ['current'] }\n ]);\n const none = current => adt.none(current);\n const CellLocation = {\n ...adt,\n none\n };\n\n const firstLayer = (scope, selector) => {\n return filterFirstLayer(scope, selector, always);\n };\n const filterFirstLayer = (scope, selector, predicate) => {\n return bind$3(children$1(scope), x => {\n if (is$1(x, selector)) {\n return predicate(x) ? [x] : [];\n } else {\n return filterFirstLayer(x, selector, predicate);\n }\n });\n };\n\n const lookup$1 = (tags, element, isRoot = never) => {\n if (isRoot(element)) {\n return Optional.none();\n }\n if (contains$2(tags, name(element))) {\n return Optional.some(element);\n }\n const isRootOrUpperTable = elm => is$1(elm, 'table') || isRoot(elm);\n return ancestor$3(element, tags.join(','), isRootOrUpperTable);\n };\n const cell = (element, isRoot) => lookup$1([\n 'td',\n 'th'\n ], element, isRoot);\n const cells = ancestor => firstLayer(ancestor, 'th,td');\n const table = (element, isRoot) => closest$3(element, 'table', isRoot);\n\n const walk = (all, current, index, direction, isEligible = always) => {\n const forwards = direction === 1;\n if (!forwards && index <= 0) {\n return CellLocation.first(all[0]);\n } else if (forwards && index >= all.length - 1) {\n return CellLocation.last(all[all.length - 1]);\n } else {\n const newIndex = index + direction;\n const elem = all[newIndex];\n return isEligible(elem) ? CellLocation.middle(current, elem) : walk(all, current, newIndex, direction, isEligible);\n }\n };\n const detect = (current, isRoot) => {\n return table(current, isRoot).bind(table => {\n const all = cells(table);\n const index = findIndex$2(all, x => eq(current, x));\n return index.map(index => ({\n index,\n all\n }));\n });\n };\n const next = (current, isEligible, isRoot) => {\n const detection = detect(current, isRoot);\n return detection.fold(() => {\n return CellLocation.none(current);\n }, info => {\n return walk(info.all, current, info.index, 1, isEligible);\n });\n };\n const prev = (current, isEligible, isRoot) => {\n const detection = detect(current, isRoot);\n return detection.fold(() => {\n return CellLocation.none();\n }, info => {\n return walk(info.all, current, info.index, -1, isEligible);\n });\n };\n\n const deflate = (rect, delta) => ({\n left: rect.left - delta,\n top: rect.top - delta,\n right: rect.right + delta * 2,\n bottom: rect.bottom + delta * 2,\n width: rect.width + delta,\n height: rect.height + delta\n });\n const getCorners = (getYAxisValue, tds) => bind$3(tds, td => {\n const rect = deflate(clone$1(td.getBoundingClientRect()), -1);\n return [\n {\n x: rect.left,\n y: getYAxisValue(rect),\n cell: td\n },\n {\n x: rect.right,\n y: getYAxisValue(rect),\n cell: td\n }\n ];\n });\n const findClosestCorner = (corners, x, y) => foldl(corners, (acc, newCorner) => acc.fold(() => Optional.some(newCorner), oldCorner => {\n const oldDist = Math.sqrt(Math.abs(oldCorner.x - x) + Math.abs(oldCorner.y - y));\n const newDist = Math.sqrt(Math.abs(newCorner.x - x) + Math.abs(newCorner.y - y));\n return Optional.some(newDist < oldDist ? newCorner : oldCorner);\n }), Optional.none());\n const getClosestCell = (getYAxisValue, isTargetCorner, table, x, y) => {\n const cells = descendants(SugarElement.fromDom(table), 'td,th,caption').map(e => e.dom);\n const corners = filter$5(getCorners(getYAxisValue, cells), corner => isTargetCorner(corner, y));\n return findClosestCorner(corners, x, y).map(corner => corner.cell);\n };\n const getBottomValue = rect => rect.bottom;\n const getTopValue = rect => rect.top;\n const isAbove = (corner, y) => corner.y < y;\n const isBelow = (corner, y) => corner.y > y;\n const getClosestCellAbove = curry(getClosestCell, getBottomValue, isAbove);\n const getClosestCellBelow = curry(getClosestCell, getTopValue, isBelow);\n const findClosestPositionInAboveCell = (table, pos) => head(pos.getClientRects()).bind(rect => getClosestCellAbove(table, rect.left, rect.top)).bind(cell => findClosestHorizontalPosition(getLastLinePositions(cell), pos));\n const findClosestPositionInBelowCell = (table, pos) => last$3(pos.getClientRects()).bind(rect => getClosestCellBelow(table, rect.left, rect.top)).bind(cell => findClosestHorizontalPosition(getFirstLinePositions(cell), pos));\n\n const hasNextBreak = (getPositionsUntil, scope, lineInfo) => lineInfo.breakAt.exists(breakPos => getPositionsUntil(scope, breakPos).breakAt.isSome());\n const startsWithWrapBreak = lineInfo => lineInfo.breakType === BreakType.Wrap && lineInfo.positions.length === 0;\n const startsWithBrBreak = lineInfo => lineInfo.breakType === BreakType.Br && lineInfo.positions.length === 1;\n const isAtTableCellLine = (getPositionsUntil, scope, pos) => {\n const lineInfo = getPositionsUntil(scope, pos);\n if (startsWithWrapBreak(lineInfo) || !isBr$6(pos.getNode()) && startsWithBrBreak(lineInfo)) {\n return !hasNextBreak(getPositionsUntil, scope, lineInfo);\n } else {\n return lineInfo.breakAt.isNone();\n }\n };\n const isAtFirstTableCellLine = curry(isAtTableCellLine, getPositionsUntilPreviousLine);\n const isAtLastTableCellLine = curry(isAtTableCellLine, getPositionsUntilNextLine);\n const isCaretAtStartOrEndOfTable = (forward, rng, table) => {\n const caretPos = CaretPosition.fromRangeStart(rng);\n return positionIn(!forward, table).exists(pos => pos.isEqual(caretPos));\n };\n const navigateHorizontally = (editor, forward, table, _td) => {\n const rng = editor.selection.getRng();\n const direction = forward ? 1 : -1;\n if (isFakeCaretTableBrowser() && isCaretAtStartOrEndOfTable(forward, rng, table)) {\n showCaret(direction, editor, table, !forward, false).each(newRng => {\n moveToRange(editor, newRng);\n });\n return true;\n }\n return false;\n };\n const getClosestAbovePosition = (root, table, start) => findClosestPositionInAboveCell(table, start).orThunk(() => head(start.getClientRects()).bind(rect => findClosestHorizontalPositionFromPoint(getPositionsAbove(root, CaretPosition.before(table)), rect.left))).getOr(CaretPosition.before(table));\n const getClosestBelowPosition = (root, table, start) => findClosestPositionInBelowCell(table, start).orThunk(() => head(start.getClientRects()).bind(rect => findClosestHorizontalPositionFromPoint(getPositionsBelow(root, CaretPosition.after(table)), rect.left))).getOr(CaretPosition.after(table));\n const getTable = (previous, pos) => {\n const node = pos.getNode(previous);\n return isTable$2(node) ? Optional.some(node) : Optional.none();\n };\n const renderBlock = (down, editor, table) => {\n editor.undoManager.transact(() => {\n const insertFn = down ? after$4 : before$3;\n const rng = insertEmptyLine(editor, SugarElement.fromDom(table), insertFn);\n moveToRange(editor, rng);\n });\n };\n const moveCaret = (editor, down, pos) => {\n const table = down ? getTable(true, pos) : getTable(false, pos);\n const last = down === false;\n table.fold(() => moveToRange(editor, pos.toRange()), table => positionIn(last, editor.getBody()).filter(lastPos => lastPos.isEqual(pos)).fold(() => moveToRange(editor, pos.toRange()), _ => renderBlock(down, editor, table)));\n };\n const navigateVertically = (editor, down, table, td) => {\n const rng = editor.selection.getRng();\n const pos = CaretPosition.fromRangeStart(rng);\n const root = editor.getBody();\n if (!down && isAtFirstTableCellLine(td, pos)) {\n const newPos = getClosestAbovePosition(root, table, pos);\n moveCaret(editor, down, newPos);\n return true;\n } else if (down && isAtLastTableCellLine(td, pos)) {\n const newPos = getClosestBelowPosition(root, table, pos);\n moveCaret(editor, down, newPos);\n return true;\n } else {\n return false;\n }\n };\n const move$1 = (editor, forward, mover) => Optional.from(editor.dom.getParent(editor.selection.getNode(), 'td,th')).bind(td => Optional.from(editor.dom.getParent(td, 'table')).map(table => mover(editor, forward, table, td))).getOr(false);\n const moveH = (editor, forward) => move$1(editor, forward, navigateHorizontally);\n const moveV = (editor, forward) => move$1(editor, forward, navigateVertically);\n const getCellFirstCursorPosition = cell => {\n const selection = SimSelection.exact(cell, 0, cell, 0);\n return toNative(selection);\n };\n const tabGo = (editor, isRoot, cell) => {\n return cell.fold(Optional.none, Optional.none, (_current, next) => {\n return first(next).map(cell => {\n return getCellFirstCursorPosition(cell);\n });\n }, current => {\n editor.execCommand('mceTableInsertRowAfter');\n return tabForward(editor, isRoot, current);\n });\n };\n const tabForward = (editor, isRoot, cell) => tabGo(editor, isRoot, next(cell, isEditable$2));\n const tabBackward = (editor, isRoot, cell) => tabGo(editor, isRoot, prev(cell, isEditable$2));\n const handleTab = (editor, forward) => {\n const rootElements = [\n 'table',\n 'li',\n 'dl'\n ];\n const body = SugarElement.fromDom(editor.getBody());\n const isRoot = element => {\n const name$1 = name(element);\n return eq(element, body) || contains$2(rootElements, name$1);\n };\n const rng = editor.selection.getRng();\n const container = SugarElement.fromDom(!forward ? rng.startContainer : rng.endContainer);\n return cell(container, isRoot).map(cell => {\n table(cell, isRoot).each(table => {\n editor.model.table.clearSelectedCells(table.dom);\n });\n editor.selection.collapse(!forward);\n const navigation = !forward ? tabBackward : tabForward;\n const rng = navigation(editor, isRoot, cell);\n rng.each(range => {\n editor.selection.setRng(range);\n });\n return true;\n }).getOr(false);\n };\n\n const executeKeydownOverride$4 = (editor, caret, evt) => {\n const isMac = Env.os.isMacOS() || Env.os.isiOS();\n execute([\n {\n keyCode: VK.RIGHT,\n action: action(moveH$2, editor, true)\n },\n {\n keyCode: VK.LEFT,\n action: action(moveH$2, editor, false)\n },\n {\n keyCode: VK.UP,\n action: action(moveV$4, editor, false)\n },\n {\n keyCode: VK.DOWN,\n action: action(moveV$4, editor, true)\n },\n ...isMac ? [\n {\n keyCode: VK.UP,\n action: action(selectToEndPoint, editor, false),\n metaKey: true,\n shiftKey: true\n },\n {\n keyCode: VK.DOWN,\n action: action(selectToEndPoint, editor, true),\n metaKey: true,\n shiftKey: true\n }\n ] : [],\n {\n keyCode: VK.RIGHT,\n action: action(moveH, editor, true)\n },\n {\n keyCode: VK.LEFT,\n action: action(moveH, editor, false)\n },\n {\n keyCode: VK.UP,\n action: action(moveV, editor, false)\n },\n {\n keyCode: VK.DOWN,\n action: action(moveV, editor, true)\n },\n {\n keyCode: VK.UP,\n action: action(moveV, editor, false)\n },\n {\n keyCode: VK.UP,\n action: action(moveV$2, editor, false)\n },\n {\n keyCode: VK.DOWN,\n action: action(moveV$2, editor, true)\n },\n {\n keyCode: VK.RIGHT,\n action: action(moveH$1, editor, true)\n },\n {\n keyCode: VK.LEFT,\n action: action(moveH$1, editor, false)\n },\n {\n keyCode: VK.UP,\n action: action(moveV$1, editor, false)\n },\n {\n keyCode: VK.DOWN,\n action: action(moveV$1, editor, true)\n },\n {\n keyCode: VK.RIGHT,\n action: action(move$3, editor, caret, true)\n },\n {\n keyCode: VK.LEFT,\n action: action(move$3, editor, caret, false)\n },\n {\n keyCode: VK.RIGHT,\n ctrlKey: !isMac,\n altKey: isMac,\n action: action(moveNextWord, editor, caret)\n },\n {\n keyCode: VK.LEFT,\n ctrlKey: !isMac,\n altKey: isMac,\n action: action(movePrevWord, editor, caret)\n },\n {\n keyCode: VK.UP,\n action: action(moveV$3, editor, false)\n },\n {\n keyCode: VK.DOWN,\n action: action(moveV$3, editor, true)\n }\n ], evt).each(_ => {\n evt.preventDefault();\n });\n };\n const setup$l = (editor, caret) => {\n editor.on('keydown', evt => {\n if (!evt.isDefaultPrevented()) {\n executeKeydownOverride$4(editor, caret, evt);\n }\n });\n };\n\n const point = (container, offset) => ({\n container,\n offset\n });\n\n const DOM$7 = DOMUtils.DOM;\n const alwaysNext = startNode => node => startNode === node ? -1 : 0;\n const isBoundary = dom => node => dom.isBlock(node) || contains$2([\n 'BR',\n 'IMG',\n 'HR',\n 'INPUT'\n ], node.nodeName) || dom.getContentEditable(node) === 'false';\n const textBefore = (node, offset, rootNode) => {\n if (isText$a(node) && offset >= 0) {\n return Optional.some(point(node, offset));\n } else {\n const textSeeker = TextSeeker(DOM$7);\n return Optional.from(textSeeker.backwards(node, offset, alwaysNext(node), rootNode)).map(prev => point(prev.container, prev.container.data.length));\n }\n };\n const textAfter = (node, offset, rootNode) => {\n if (isText$a(node) && offset >= node.length) {\n return Optional.some(point(node, offset));\n } else {\n const textSeeker = TextSeeker(DOM$7);\n return Optional.from(textSeeker.forwards(node, offset, alwaysNext(node), rootNode)).map(prev => point(prev.container, 0));\n }\n };\n const scanLeft = (node, offset, rootNode) => {\n if (!isText$a(node)) {\n return Optional.none();\n }\n const text = node.data;\n if (offset >= 0 && offset <= text.length) {\n return Optional.some(point(node, offset));\n } else {\n const textSeeker = TextSeeker(DOM$7);\n return Optional.from(textSeeker.backwards(node, offset, alwaysNext(node), rootNode)).bind(prev => {\n const prevText = prev.container.data;\n return scanLeft(prev.container, offset + prevText.length, rootNode);\n });\n }\n };\n const scanRight = (node, offset, rootNode) => {\n if (!isText$a(node)) {\n return Optional.none();\n }\n const text = node.data;\n if (offset <= text.length) {\n return Optional.some(point(node, offset));\n } else {\n const textSeeker = TextSeeker(DOM$7);\n return Optional.from(textSeeker.forwards(node, offset, alwaysNext(node), rootNode)).bind(next => scanRight(next.container, offset - text.length, rootNode));\n }\n };\n const repeatLeft = (dom, node, offset, process, rootNode) => {\n const search = TextSeeker(dom, isBoundary(dom));\n return Optional.from(search.backwards(node, offset, process, rootNode));\n };\n\n const isValidTextRange = rng => rng.collapsed && isText$a(rng.startContainer);\n const getText = rng => trim$2(rng.toString().replace(/\\u00A0/g, ' '));\n const isWhitespace = chr => chr !== '' && ' \\xA0\\f\\n\\r\\t\\x0B'.indexOf(chr) !== -1;\n\n const stripTrigger = (text, trigger) => text.substring(trigger.length);\n const findTrigger = (text, index, trigger) => {\n let i;\n const firstChar = trigger.charAt(0);\n for (i = index - 1; i >= 0; i--) {\n const char = text.charAt(i);\n if (isWhitespace(char)) {\n return Optional.none();\n }\n if (firstChar === char && contains$1(text, trigger, i, index)) {\n break;\n }\n }\n return Optional.some(i);\n };\n const findStart = (dom, initRange, trigger, minChars = 0) => {\n if (!isValidTextRange(initRange)) {\n return Optional.none();\n }\n const buffer = {\n text: '',\n offset: 0\n };\n const findTriggerIndex = (element, offset, text) => {\n buffer.text = text + buffer.text;\n buffer.offset += offset;\n return findTrigger(buffer.text, buffer.offset, trigger).getOr(offset);\n };\n const root = dom.getParent(initRange.startContainer, dom.isBlock) || dom.getRoot();\n return repeatLeft(dom, initRange.startContainer, initRange.startOffset, findTriggerIndex, root).bind(spot => {\n const range = initRange.cloneRange();\n range.setStart(spot.container, spot.offset);\n range.setEnd(initRange.endContainer, initRange.endOffset);\n if (range.collapsed) {\n return Optional.none();\n }\n const text = getText(range);\n const triggerIndex = text.lastIndexOf(trigger);\n if (triggerIndex !== 0 || stripTrigger(text, trigger).length < minChars) {\n return Optional.none();\n } else {\n return Optional.some({\n text: stripTrigger(text, trigger),\n range,\n trigger\n });\n }\n });\n };\n const getContext = (dom, initRange, trigger, minChars = 0) => detect$1(SugarElement.fromDom(initRange.startContainer)).fold(() => findStart(dom, initRange, trigger, minChars), elm => {\n const range = dom.createRng();\n range.selectNode(elm.dom);\n const text = getText(range);\n return Optional.some({\n range,\n text: stripTrigger(text, trigger),\n trigger\n });\n });\n\n const isText$1 = node => node.nodeType === TEXT;\n const isElement = node => node.nodeType === ELEMENT;\n const toLast = node => {\n if (isText$1(node)) {\n return point(node, node.data.length);\n } else {\n const children = node.childNodes;\n return children.length > 0 ? toLast(children[children.length - 1]) : point(node, children.length);\n }\n };\n const toLeaf = (node, offset) => {\n const children = node.childNodes;\n if (children.length > 0 && offset < children.length) {\n return toLeaf(children[offset], 0);\n } else if (children.length > 0 && isElement(node) && children.length === offset) {\n return toLast(children[children.length - 1]);\n } else {\n return point(node, offset);\n }\n };\n\n const isPreviousCharContent = (dom, leaf) => {\n var _a;\n const root = (_a = dom.getParent(leaf.container, dom.isBlock)) !== null && _a !== void 0 ? _a : dom.getRoot();\n return repeatLeft(dom, leaf.container, leaf.offset, (_element, offset) => offset === 0 ? -1 : offset, root).filter(spot => {\n const char = spot.container.data.charAt(spot.offset - 1);\n return !isWhitespace(char);\n }).isSome();\n };\n const isStartOfWord = dom => rng => {\n const leaf = toLeaf(rng.startContainer, rng.startOffset);\n return !isPreviousCharContent(dom, leaf);\n };\n const getTriggerContext = (dom, initRange, database) => findMap(database.triggers, trigger => getContext(dom, initRange, trigger));\n const lookup = (editor, getDatabase) => {\n const database = getDatabase();\n const rng = editor.selection.getRng();\n return getTriggerContext(editor.dom, rng, database).bind(context => lookupWithContext(editor, getDatabase, context));\n };\n const lookupWithContext = (editor, getDatabase, context, fetchOptions = {}) => {\n var _a;\n const database = getDatabase();\n const rng = editor.selection.getRng();\n const startText = (_a = rng.startContainer.nodeValue) !== null && _a !== void 0 ? _a : '';\n const autocompleters = filter$5(database.lookupByTrigger(context.trigger), autocompleter => context.text.length >= autocompleter.minChars && autocompleter.matches.getOrThunk(() => isStartOfWord(editor.dom))(context.range, startText, context.text));\n if (autocompleters.length === 0) {\n return Optional.none();\n }\n const lookupData = Promise.all(map$3(autocompleters, ac => {\n const fetchResult = ac.fetch(context.text, ac.maxResults, fetchOptions);\n return fetchResult.then(results => ({\n matchText: context.text,\n items: results,\n columns: ac.columns,\n onAction: ac.onAction,\n highlightOn: ac.highlightOn\n }));\n }));\n return Optional.some({\n lookupData,\n context\n });\n };\n\n var SimpleResultType;\n (function (SimpleResultType) {\n SimpleResultType[SimpleResultType['Error'] = 0] = 'Error';\n SimpleResultType[SimpleResultType['Value'] = 1] = 'Value';\n }(SimpleResultType || (SimpleResultType = {})));\n const fold$1 = (res, onError, onValue) => res.stype === SimpleResultType.Error ? onError(res.serror) : onValue(res.svalue);\n const partition = results => {\n const values = [];\n const errors = [];\n each$e(results, obj => {\n fold$1(obj, err => errors.push(err), val => values.push(val));\n });\n return {\n values,\n errors\n };\n };\n const mapError = (res, f) => {\n if (res.stype === SimpleResultType.Error) {\n return {\n stype: SimpleResultType.Error,\n serror: f(res.serror)\n };\n } else {\n return res;\n }\n };\n const map = (res, f) => {\n if (res.stype === SimpleResultType.Value) {\n return {\n stype: SimpleResultType.Value,\n svalue: f(res.svalue)\n };\n } else {\n return res;\n }\n };\n const bind$1 = (res, f) => {\n if (res.stype === SimpleResultType.Value) {\n return f(res.svalue);\n } else {\n return res;\n }\n };\n const bindError = (res, f) => {\n if (res.stype === SimpleResultType.Error) {\n return f(res.serror);\n } else {\n return res;\n }\n };\n const svalue = v => ({\n stype: SimpleResultType.Value,\n svalue: v\n });\n const serror = e => ({\n stype: SimpleResultType.Error,\n serror: e\n });\n const toResult = res => fold$1(res, Result.error, Result.value);\n const fromResult = res => res.fold(serror, svalue);\n const SimpleResult = {\n fromResult,\n toResult,\n svalue,\n partition,\n serror,\n bind: bind$1,\n bindError,\n map,\n mapError,\n fold: fold$1\n };\n\n const formatObj = input => {\n return isObject(input) && keys(input).length > 100 ? ' removed due to size' : JSON.stringify(input, null, 2);\n };\n const formatErrors = errors => {\n const es = errors.length > 10 ? errors.slice(0, 10).concat([{\n path: [],\n getErrorInfo: constant('... (only showing first ten failures)')\n }]) : errors;\n return map$3(es, e => {\n return 'Failed path: (' + e.path.join(' > ') + ')\\n' + e.getErrorInfo();\n });\n };\n\n const nu = (path, getErrorInfo) => {\n return SimpleResult.serror([{\n path,\n getErrorInfo\n }]);\n };\n const missingRequired = (path, key, obj) => nu(path, () => 'Could not find valid *required* value for \"' + key + '\" in ' + formatObj(obj));\n const missingKey = (path, key) => nu(path, () => 'Choice schema did not contain choice key: \"' + key + '\"');\n const missingBranch = (path, branches, branch) => nu(path, () => 'The chosen schema: \"' + branch + '\" did not exist in branches: ' + formatObj(branches));\n const custom = (path, err) => nu(path, constant(err));\n\n const chooseFrom = (path, input, branches, ch) => {\n const fields = get$a(branches, ch);\n return fields.fold(() => missingBranch(path, branches, ch), vp => vp.extract(path.concat(['branch: ' + ch]), input));\n };\n const choose$1 = (key, branches) => {\n const extract = (path, input) => {\n const choice = get$a(input, key);\n return choice.fold(() => missingKey(path, key), chosen => chooseFrom(path, input, branches, chosen));\n };\n const toString = () => 'chooseOn(' + key + '). Possible values: ' + keys(branches);\n return {\n extract,\n toString\n };\n };\n\n const shallow = (old, nu) => {\n return nu;\n };\n const deep = (old, nu) => {\n const bothObjects = isPlainObject(old) && isPlainObject(nu);\n return bothObjects ? deepMerge(old, nu) : nu;\n };\n const baseMerge = merger => {\n return (...objects) => {\n if (objects.length === 0) {\n throw new Error(`Can't merge zero objects`);\n }\n const ret = {};\n for (let j = 0; j < objects.length; j++) {\n const curObject = objects[j];\n for (const key in curObject) {\n if (has$2(curObject, key)) {\n ret[key] = merger(ret[key], curObject[key]);\n }\n }\n }\n return ret;\n };\n };\n const deepMerge = baseMerge(deep);\n const merge = baseMerge(shallow);\n\n const required = () => ({\n tag: 'required',\n process: {}\n });\n const defaultedThunk = fallbackThunk => ({\n tag: 'defaultedThunk',\n process: fallbackThunk\n });\n const defaulted$1 = fallback => defaultedThunk(constant(fallback));\n const asOption = () => ({\n tag: 'option',\n process: {}\n });\n\n const mergeValues = (values, base) => values.length > 0 ? SimpleResult.svalue(deepMerge(base, merge.apply(undefined, values))) : SimpleResult.svalue(base);\n const mergeErrors = errors => compose(SimpleResult.serror, flatten)(errors);\n const consolidateObj = (objects, base) => {\n const partition = SimpleResult.partition(objects);\n return partition.errors.length > 0 ? mergeErrors(partition.errors) : mergeValues(partition.values, base);\n };\n const consolidateArr = objects => {\n const partitions = SimpleResult.partition(objects);\n return partitions.errors.length > 0 ? mergeErrors(partitions.errors) : SimpleResult.svalue(partitions.values);\n };\n const ResultCombine = {\n consolidateObj,\n consolidateArr\n };\n\n const field$1 = (key, newKey, presence, prop) => ({\n tag: 'field',\n key,\n newKey,\n presence,\n prop\n });\n const customField$1 = (newKey, instantiator) => ({\n tag: 'custom',\n newKey,\n instantiator\n });\n const fold = (value, ifField, ifCustom) => {\n switch (value.tag) {\n case 'field':\n return ifField(value.key, value.newKey, value.presence, value.prop);\n case 'custom':\n return ifCustom(value.newKey, value.instantiator);\n }\n };\n\n const value = validator => {\n const extract = (path, val) => {\n return SimpleResult.bindError(validator(val), err => custom(path, err));\n };\n const toString = constant('val');\n return {\n extract,\n toString\n };\n };\n const anyValue$1 = value(SimpleResult.svalue);\n\n const requiredAccess = (path, obj, key, bundle) => get$a(obj, key).fold(() => missingRequired(path, key, obj), bundle);\n const fallbackAccess = (obj, key, fallback, bundle) => {\n const v = get$a(obj, key).getOrThunk(() => fallback(obj));\n return bundle(v);\n };\n const optionAccess = (obj, key, bundle) => bundle(get$a(obj, key));\n const optionDefaultedAccess = (obj, key, fallback, bundle) => {\n const opt = get$a(obj, key).map(val => val === true ? fallback(obj) : val);\n return bundle(opt);\n };\n const extractField = (field, path, obj, key, prop) => {\n const bundle = av => prop.extract(path.concat([key]), av);\n const bundleAsOption = optValue => optValue.fold(() => SimpleResult.svalue(Optional.none()), ov => {\n const result = prop.extract(path.concat([key]), ov);\n return SimpleResult.map(result, Optional.some);\n });\n switch (field.tag) {\n case 'required':\n return requiredAccess(path, obj, key, bundle);\n case 'defaultedThunk':\n return fallbackAccess(obj, key, field.process, bundle);\n case 'option':\n return optionAccess(obj, key, bundleAsOption);\n case 'defaultedOptionThunk':\n return optionDefaultedAccess(obj, key, field.process, bundleAsOption);\n case 'mergeWithThunk': {\n return fallbackAccess(obj, key, constant({}), v => {\n const result = deepMerge(field.process(obj), v);\n return bundle(result);\n });\n }\n }\n };\n const extractFields = (path, obj, fields) => {\n const success = {};\n const errors = [];\n for (const field of fields) {\n fold(field, (key, newKey, presence, prop) => {\n const result = extractField(presence, path, obj, key, prop);\n SimpleResult.fold(result, err => {\n errors.push(...err);\n }, res => {\n success[newKey] = res;\n });\n }, (newKey, instantiator) => {\n success[newKey] = instantiator(obj);\n });\n }\n return errors.length > 0 ? SimpleResult.serror(errors) : SimpleResult.svalue(success);\n };\n const objOf = values => {\n const extract = (path, o) => extractFields(path, o, values);\n const toString = () => {\n const fieldStrings = map$3(values, value => fold(value, (key, _okey, _presence, prop) => key + ' -> ' + prop.toString(), (newKey, _instantiator) => 'state(' + newKey + ')'));\n return 'obj{\\n' + fieldStrings.join('\\n') + '}';\n };\n return {\n extract,\n toString\n };\n };\n const arrOf = prop => {\n const extract = (path, array) => {\n const results = map$3(array, (a, i) => prop.extract(path.concat(['[' + i + ']']), a));\n return ResultCombine.consolidateArr(results);\n };\n const toString = () => 'array(' + prop.toString() + ')';\n return {\n extract,\n toString\n };\n };\n\n const valueOf = validator => value(v => validator(v).fold(SimpleResult.serror, SimpleResult.svalue));\n const extractValue = (label, prop, obj) => {\n const res = prop.extract([label], obj);\n return SimpleResult.mapError(res, errs => ({\n input: obj,\n errors: errs\n }));\n };\n const asRaw = (label, prop, obj) => SimpleResult.toResult(extractValue(label, prop, obj));\n const formatError = errInfo => {\n return 'Errors: \\n' + formatErrors(errInfo.errors).join('\\n') + '\\n\\nInput object: ' + formatObj(errInfo.input);\n };\n const choose = (key, branches) => choose$1(key, map$2(branches, objOf));\n\n const anyValue = constant(anyValue$1);\n const typedValue = (validator, expectedType) => value(a => {\n const actualType = typeof a;\n return validator(a) ? SimpleResult.svalue(a) : SimpleResult.serror(`Expected type: ${ expectedType } but got: ${ actualType }`);\n });\n const number = typedValue(isNumber, 'number');\n const string = typedValue(isString, 'string');\n const boolean = typedValue(isBoolean, 'boolean');\n const functionProcessor = typedValue(isFunction, 'function');\n\n const field = field$1;\n const customField = customField$1;\n const validateEnum = values => valueOf(value => contains$2(values, value) ? Result.value(value) : Result.error(`Unsupported value: \"${ value }\", choose one of \"${ values.join(', ') }\".`));\n const requiredOf = (key, schema) => field(key, key, required(), schema);\n const requiredString = key => requiredOf(key, string);\n const requiredFunction = key => requiredOf(key, functionProcessor);\n const requiredArrayOf = (key, schema) => field(key, key, required(), arrOf(schema));\n const optionOf = (key, schema) => field(key, key, asOption(), schema);\n const optionString = key => optionOf(key, string);\n const optionFunction = key => optionOf(key, functionProcessor);\n const defaulted = (key, fallback) => field(key, key, defaulted$1(fallback), anyValue());\n const defaultedOf = (key, fallback, schema) => field(key, key, defaulted$1(fallback), schema);\n const defaultedNumber = (key, fallback) => defaultedOf(key, fallback, number);\n const defaultedString = (key, fallback) => defaultedOf(key, fallback, string);\n const defaultedStringEnum = (key, fallback, values) => defaultedOf(key, fallback, validateEnum(values));\n const defaultedBoolean = (key, fallback) => defaultedOf(key, fallback, boolean);\n const defaultedFunction = (key, fallback) => defaultedOf(key, fallback, functionProcessor);\n const defaultedArrayOf = (key, fallback, schema) => defaultedOf(key, fallback, arrOf(schema));\n\n const type = requiredString('type');\n const fetch$1 = requiredFunction('fetch');\n const onAction = requiredFunction('onAction');\n const onSetup = defaultedFunction('onSetup', () => noop);\n const optionalText = optionString('text');\n const optionalIcon = optionString('icon');\n const optionalTooltip = optionString('tooltip');\n const optionalLabel = optionString('label');\n const active = defaultedBoolean('active', false);\n const enabled = defaultedBoolean('enabled', true);\n const primary = defaultedBoolean('primary', false);\n const defaultedColumns = num => defaulted('columns', num);\n const defaultedType = type => defaultedString('type', type);\n\n const autocompleterSchema = objOf([\n type,\n requiredString('trigger'),\n defaultedNumber('minChars', 1),\n defaultedColumns(1),\n defaultedNumber('maxResults', 10),\n optionFunction('matches'),\n fetch$1,\n onAction,\n defaultedArrayOf('highlightOn', [], string)\n ]);\n const createAutocompleter = spec => asRaw('Autocompleter', autocompleterSchema, {\n trigger: spec.ch,\n ...spec\n });\n\n const baseToolbarButtonFields = [\n enabled,\n optionalTooltip,\n optionalIcon,\n optionalText,\n onSetup\n ];\n\n const baseToolbarToggleButtonFields = [active].concat(baseToolbarButtonFields);\n\n const contextBarFields = [\n defaultedFunction('predicate', never),\n defaultedStringEnum('scope', 'node', [\n 'node',\n 'editor'\n ]),\n defaultedStringEnum('position', 'selection', [\n 'node',\n 'selection',\n 'line'\n ])\n ];\n\n const contextButtonFields = baseToolbarButtonFields.concat([\n defaultedType('contextformbutton'),\n primary,\n onAction,\n customField('original', identity)\n ]);\n const contextToggleButtonFields = baseToolbarToggleButtonFields.concat([\n defaultedType('contextformbutton'),\n primary,\n onAction,\n customField('original', identity)\n ]);\n const launchButtonFields = baseToolbarButtonFields.concat([defaultedType('contextformbutton')]);\n const launchToggleButtonFields = baseToolbarToggleButtonFields.concat([defaultedType('contextformtogglebutton')]);\n const toggleOrNormal = choose('type', {\n contextformbutton: contextButtonFields,\n contextformtogglebutton: contextToggleButtonFields\n });\n objOf([\n defaultedType('contextform'),\n defaultedFunction('initValue', constant('')),\n optionalLabel,\n requiredArrayOf('commands', toggleOrNormal),\n optionOf('launch', choose('type', {\n contextformbutton: launchButtonFields,\n contextformtogglebutton: launchToggleButtonFields\n }))\n ].concat(contextBarFields));\n\n const register$2 = editor => {\n const popups = editor.ui.registry.getAll().popups;\n const dataset = map$2(popups, popup => createAutocompleter(popup).fold(err => {\n throw new Error(formatError(err));\n }, identity));\n const triggers = stringArray(mapToArray(dataset, v => v.trigger));\n const datasetValues = values(dataset);\n const lookupByTrigger = trigger => filter$5(datasetValues, dv => dv.trigger === trigger);\n return {\n dataset,\n triggers,\n lookupByTrigger\n };\n };\n\n const setupEditorInput = (editor, api) => {\n const update = last$1(api.load, 50);\n editor.on('keypress compositionend', e => {\n if (e.which === 27) {\n return;\n }\n update.throttle();\n });\n editor.on('keydown', e => {\n const keyCode = e.which;\n if (keyCode === 8) {\n update.throttle();\n } else if (keyCode === 27) {\n api.cancelIfNecessary();\n }\n });\n editor.on('remove', update.cancel);\n };\n const setup$k = editor => {\n const activeAutocompleter = value$2();\n const uiActive = Cell(false);\n const isActive = activeAutocompleter.isSet;\n const cancelIfNecessary = () => {\n if (isActive()) {\n removeAutocompleterDecoration(editor);\n fireAutocompleterEnd(editor);\n uiActive.set(false);\n activeAutocompleter.clear();\n }\n };\n const commenceIfNecessary = context => {\n if (!isActive()) {\n addAutocompleterDecoration(editor, context.range);\n activeAutocompleter.set({\n trigger: context.trigger,\n matchLength: context.text.length\n });\n }\n };\n const getAutocompleters = cached(() => register$2(editor));\n const doLookup = fetchOptions => activeAutocompleter.get().map(ac => getContext(editor.dom, editor.selection.getRng(), ac.trigger).bind(newContext => lookupWithContext(editor, getAutocompleters, newContext, fetchOptions))).getOrThunk(() => lookup(editor, getAutocompleters));\n const load = fetchOptions => {\n doLookup(fetchOptions).fold(cancelIfNecessary, lookupInfo => {\n commenceIfNecessary(lookupInfo.context);\n lookupInfo.lookupData.then(lookupData => {\n activeAutocompleter.get().map(ac => {\n const context = lookupInfo.context;\n if (ac.trigger === context.trigger) {\n if (context.text.length - ac.matchLength >= 10) {\n cancelIfNecessary();\n } else {\n activeAutocompleter.set({\n ...ac,\n matchLength: context.text.length\n });\n if (uiActive.get()) {\n fireAutocompleterUpdate(editor, { lookupData });\n } else {\n uiActive.set(true);\n fireAutocompleterStart(editor, { lookupData });\n }\n }\n }\n });\n });\n });\n };\n editor.addCommand('mceAutocompleterReload', (_ui, value) => {\n const fetchOptions = isObject(value) ? value.fetchOptions : {};\n load(fetchOptions);\n });\n editor.addCommand('mceAutocompleterClose', cancelIfNecessary);\n setupEditorInput(editor, {\n cancelIfNecessary,\n load\n });\n };\n\n const browser$1 = detect$2().browser;\n const isSafari = browser$1.isSafari();\n const emptyNodeContents = node => fillWithPaddingBr(SugarElement.fromDom(node));\n const isEntireNodeSelected = (rng, node) => {\n var _a;\n return rng.startOffset === 0 && rng.endOffset === ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.length);\n };\n const getParentDetailsElementAtPos = (dom, pos) => Optional.from(dom.getParent(pos.container(), 'details'));\n const isInDetailsElement = (dom, pos) => getParentDetailsElementAtPos(dom, pos).isSome();\n const getDetailsElements = (dom, rng) => {\n const startDetails = Optional.from(dom.getParent(rng.startContainer, 'details'));\n const endDetails = Optional.from(dom.getParent(rng.endContainer, 'details'));\n if (startDetails.isSome() || endDetails.isSome()) {\n const startSummary = startDetails.bind(details => Optional.from(dom.select('summary', details)[0]));\n return Optional.some({\n startSummary,\n startDetails,\n endDetails\n });\n } else {\n return Optional.none();\n }\n };\n const isCaretInTheBeginningOf = (caretPos, element) => firstPositionIn(element).exists(pos => pos.isEqual(caretPos));\n const isCaretInTheEndOf = (caretPos, element) => {\n return lastPositionIn(element).exists(pos => {\n if (isBr$6(pos.getNode())) {\n return prevPosition(element, pos).exists(pos2 => pos2.isEqual(caretPos)) || pos.isEqual(caretPos);\n } else {\n return pos.isEqual(caretPos);\n }\n });\n };\n const isCaretAtStartOfSummary = (caretPos, detailsElements) => detailsElements.startSummary.exists(summary => isCaretInTheBeginningOf(caretPos, summary));\n const isCaretAtEndOfSummary = (caretPos, detailsElements) => detailsElements.startSummary.exists(summary => isCaretInTheEndOf(caretPos, summary));\n const isCaretInFirstPositionInBody = (caretPos, detailsElements) => detailsElements.startDetails.exists(details => prevPosition(details, caretPos).forall(pos => detailsElements.startSummary.exists(summary => !summary.contains(caretPos.container()) && summary.contains(pos.container()))));\n const isCaretInLastPositionInBody = (root, caretPos, detailsElements) => detailsElements.startDetails.exists(details => nextPosition(root, caretPos).forall(pos => !details.contains(pos.container())));\n const setCaretToPosition = (editor, position) => {\n const node = position.getNode();\n if (!isUndefined(node)) {\n editor.selection.setCursorLocation(node, position.offset());\n }\n };\n const moveCaretToDetailsPos = (editor, pos, forward) => {\n const details = editor.dom.getParent(pos.container(), 'details');\n if (details && !details.open) {\n const summary = editor.dom.select('summary', details)[0];\n if (summary) {\n const newPos = forward ? firstPositionIn(summary) : lastPositionIn(summary);\n newPos.each(pos => setCaretToPosition(editor, pos));\n }\n } else {\n setCaretToPosition(editor, pos);\n }\n };\n const isPartialDelete = (rng, detailsElements) => {\n const containsStart = element => element.contains(rng.startContainer);\n const containsEnd = element => element.contains(rng.endContainer);\n const startInSummary = detailsElements.startSummary.exists(containsStart);\n const endInSummary = detailsElements.startSummary.exists(containsEnd);\n const isPartiallySelectedDetailsElements = detailsElements.startDetails.forall(startDetails => detailsElements.endDetails.forall(endDetails => startDetails !== endDetails));\n const isInPartiallySelectedSummary = (startInSummary || endInSummary) && !(startInSummary && endInSummary);\n return isInPartiallySelectedSummary || isPartiallySelectedDetailsElements;\n };\n const shouldPreventDeleteIntoDetails = (editor, forward, granularity) => {\n const {dom, selection} = editor;\n const root = editor.getBody();\n if (granularity === 'character') {\n const caretPos = CaretPosition.fromRangeStart(selection.getRng());\n const parentBlock = dom.getParent(caretPos.container(), dom.isBlock);\n const parentDetailsAtCaret = getParentDetailsElementAtPos(dom, caretPos);\n const inEmptyParentBlock = parentBlock && dom.isEmpty(parentBlock);\n const isFirstBlock = isNull(parentBlock === null || parentBlock === void 0 ? void 0 : parentBlock.previousSibling);\n const isLastBlock = isNull(parentBlock === null || parentBlock === void 0 ? void 0 : parentBlock.nextSibling);\n if (inEmptyParentBlock) {\n const firstOrLast = forward ? isLastBlock : isFirstBlock;\n if (firstOrLast) {\n const isBeforeAfterDetails = navigate(!forward, root, caretPos).exists(pos => {\n return isInDetailsElement(dom, pos) && !equals(parentDetailsAtCaret, getParentDetailsElementAtPos(dom, pos));\n });\n if (isBeforeAfterDetails) {\n return true;\n }\n }\n }\n return navigate(forward, root, caretPos).fold(never, pos => {\n const parentDetailsAtNewPos = getParentDetailsElementAtPos(dom, pos);\n if (isInDetailsElement(dom, pos) && !equals(parentDetailsAtCaret, parentDetailsAtNewPos)) {\n if (!forward) {\n moveCaretToDetailsPos(editor, pos, false);\n }\n if (parentBlock && inEmptyParentBlock) {\n if (forward && isFirstBlock) {\n return true;\n } else if (!forward && isLastBlock) {\n return true;\n }\n moveCaretToDetailsPos(editor, pos, forward);\n editor.dom.remove(parentBlock);\n }\n return true;\n } else {\n return false;\n }\n });\n } else {\n return false;\n }\n };\n const shouldPreventDeleteSummaryAction = (editor, detailElements, forward, granularity) => {\n const selection = editor.selection;\n const rng = selection.getRng();\n const caretPos = CaretPosition.fromRangeStart(rng);\n const root = editor.getBody();\n if (granularity === 'selection') {\n return isPartialDelete(rng, detailElements);\n } else if (forward) {\n return isCaretAtEndOfSummary(caretPos, detailElements) || isCaretInLastPositionInBody(root, caretPos, detailElements);\n } else {\n return isCaretAtStartOfSummary(caretPos, detailElements) || isCaretInFirstPositionInBody(caretPos, detailElements);\n }\n };\n const shouldPreventDeleteAction = (editor, forward, granularity) => getDetailsElements(editor.dom, editor.selection.getRng()).fold(() => shouldPreventDeleteIntoDetails(editor, forward, granularity), detailsElements => shouldPreventDeleteSummaryAction(editor, detailsElements, forward, granularity) || shouldPreventDeleteIntoDetails(editor, forward, granularity));\n const handleDeleteActionSafari = (editor, forward, granularity) => {\n const selection = editor.selection;\n const node = selection.getNode();\n const rng = selection.getRng();\n const caretPos = CaretPosition.fromRangeStart(rng);\n if (isSummary$1(node)) {\n if (granularity === 'selection' && isEntireNodeSelected(rng, node) || willDeleteLastPositionInElement(forward, caretPos, node)) {\n emptyNodeContents(node);\n } else {\n editor.undoManager.transact(() => {\n const sel = selection.getSel();\n let {anchorNode, anchorOffset, focusNode, focusOffset} = sel !== null && sel !== void 0 ? sel : {};\n const applySelection = () => {\n if (isNonNullable(anchorNode) && isNonNullable(anchorOffset) && isNonNullable(focusNode) && isNonNullable(focusOffset)) {\n sel === null || sel === void 0 ? void 0 : sel.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);\n }\n };\n const updateSelection = () => {\n anchorNode = sel === null || sel === void 0 ? void 0 : sel.anchorNode;\n anchorOffset = sel === null || sel === void 0 ? void 0 : sel.anchorOffset;\n focusNode = sel === null || sel === void 0 ? void 0 : sel.focusNode;\n focusOffset = sel === null || sel === void 0 ? void 0 : sel.focusOffset;\n };\n const appendAllChildNodes = (from, to) => {\n each$e(from.childNodes, child => {\n if (isNode(child)) {\n to.appendChild(child);\n }\n });\n };\n const container = editor.dom.create('span', { 'data-mce-bogus': '1' });\n appendAllChildNodes(node, container);\n node.appendChild(container);\n applySelection();\n if (granularity === 'word' || granularity === 'line') {\n sel === null || sel === void 0 ? void 0 : sel.modify('extend', forward ? 'right' : 'left', granularity);\n }\n if (!selection.isCollapsed() && isEntireNodeSelected(selection.getRng(), container)) {\n emptyNodeContents(node);\n } else {\n editor.execCommand(forward ? 'ForwardDelete' : 'Delete');\n updateSelection();\n appendAllChildNodes(container, node);\n applySelection();\n }\n editor.dom.remove(container);\n });\n }\n return true;\n } else {\n return false;\n }\n };\n const backspaceDelete = (editor, forward, granularity) => shouldPreventDeleteAction(editor, forward, granularity) || isSafari && handleDeleteActionSafari(editor, forward, granularity) ? Optional.some(noop) : Optional.none();\n\n const createAndFireInputEvent = eventType => (editor, inputType, specifics = {}) => {\n const target = editor.getBody();\n const overrides = {\n bubbles: true,\n composed: true,\n data: null,\n isComposing: false,\n detail: 0,\n view: null,\n target,\n currentTarget: target,\n eventPhase: Event.AT_TARGET,\n originalTarget: target,\n explicitOriginalTarget: target,\n isTrusted: false,\n srcElement: target,\n cancelable: false,\n preventDefault: noop,\n inputType\n };\n const input = clone$3(new InputEvent(eventType));\n return editor.dispatch(eventType, {\n ...input,\n ...overrides,\n ...specifics\n });\n };\n const fireInputEvent = createAndFireInputEvent('input');\n const fireBeforeInputEvent = createAndFireInputEvent('beforeinput');\n\n const platform$2 = detect$2();\n const os = platform$2.os;\n const isMacOSOriOS = os.isMacOS() || os.isiOS();\n const browser = platform$2.browser;\n const isFirefox = browser.isFirefox();\n const executeKeydownOverride$3 = (editor, caret, evt) => {\n const inputType = evt.keyCode === VK.BACKSPACE ? 'deleteContentBackward' : 'deleteContentForward';\n const isCollapsed = editor.selection.isCollapsed();\n const unmodifiedGranularity = isCollapsed ? 'character' : 'selection';\n const getModifiedGranularity = isWord => {\n if (isCollapsed) {\n return isWord ? 'word' : 'line';\n } else {\n return 'selection';\n }\n };\n executeWithDelayedAction([\n {\n keyCode: VK.BACKSPACE,\n action: action(backspaceDelete$1, editor)\n },\n {\n keyCode: VK.BACKSPACE,\n action: action(backspaceDelete$6, editor, false)\n },\n {\n keyCode: VK.DELETE,\n action: action(backspaceDelete$6, editor, true)\n },\n {\n keyCode: VK.BACKSPACE,\n action: action(backspaceDelete$7, editor, false)\n },\n {\n keyCode: VK.DELETE,\n action: action(backspaceDelete$7, editor, true)\n },\n {\n keyCode: VK.BACKSPACE,\n action: action(backspaceDelete$4, editor, caret, false)\n },\n {\n keyCode: VK.DELETE,\n action: action(backspaceDelete$4, editor, caret, true)\n },\n {\n keyCode: VK.BACKSPACE,\n action: action(backspaceDelete$a, editor, false)\n },\n {\n keyCode: VK.DELETE,\n action: action(backspaceDelete$a, editor, true)\n },\n {\n keyCode: VK.BACKSPACE,\n action: action(backspaceDelete, editor, false, unmodifiedGranularity)\n },\n {\n keyCode: VK.DELETE,\n action: action(backspaceDelete, editor, true, unmodifiedGranularity)\n },\n ...isMacOSOriOS ? [\n {\n keyCode: VK.BACKSPACE,\n altKey: true,\n action: action(backspaceDelete, editor, false, getModifiedGranularity(true))\n },\n {\n keyCode: VK.DELETE,\n altKey: true,\n action: action(backspaceDelete, editor, true, getModifiedGranularity(true))\n },\n {\n keyCode: VK.BACKSPACE,\n metaKey: true,\n action: action(backspaceDelete, editor, false, getModifiedGranularity(false))\n }\n ] : [\n {\n keyCode: VK.BACKSPACE,\n ctrlKey: true,\n action: action(backspaceDelete, editor, false, getModifiedGranularity(true))\n },\n {\n keyCode: VK.DELETE,\n ctrlKey: true,\n action: action(backspaceDelete, editor, true, getModifiedGranularity(true))\n }\n ],\n {\n keyCode: VK.BACKSPACE,\n action: action(backspaceDelete$5, editor, false)\n },\n {\n keyCode: VK.DELETE,\n action: action(backspaceDelete$5, editor, true)\n },\n {\n keyCode: VK.BACKSPACE,\n action: action(backspaceDelete$2, editor, false)\n },\n {\n keyCode: VK.DELETE,\n action: action(backspaceDelete$2, editor, true)\n },\n {\n keyCode: VK.BACKSPACE,\n action: action(backspaceDelete$8, editor, false)\n },\n {\n keyCode: VK.DELETE,\n action: action(backspaceDelete$8, editor, true)\n },\n {\n keyCode: VK.BACKSPACE,\n action: action(backspaceDelete$9, editor, false)\n },\n {\n keyCode: VK.DELETE,\n action: action(backspaceDelete$9, editor, true)\n },\n {\n keyCode: VK.BACKSPACE,\n action: action(backspaceDelete$3, editor, false)\n },\n {\n keyCode: VK.DELETE,\n action: action(backspaceDelete$3, editor, true)\n }\n ], evt).filter(_ => editor.selection.isEditable()).each(applyAction => {\n evt.preventDefault();\n const beforeInput = fireBeforeInputEvent(editor, inputType);\n if (!beforeInput.isDefaultPrevented()) {\n applyAction();\n fireInputEvent(editor, inputType);\n }\n });\n };\n const executeKeyupOverride = (editor, evt, isBackspaceKeydown) => execute([\n {\n keyCode: VK.BACKSPACE,\n action: action(paddEmptyElement, editor)\n },\n {\n keyCode: VK.DELETE,\n action: action(paddEmptyElement, editor)\n },\n ...isMacOSOriOS ? [\n {\n keyCode: VK.BACKSPACE,\n altKey: true,\n action: action(refreshCaret, editor)\n },\n {\n keyCode: VK.DELETE,\n altKey: true,\n action: action(refreshCaret, editor)\n },\n ...isBackspaceKeydown ? [{\n keyCode: isFirefox ? 224 : 91,\n action: action(refreshCaret, editor)\n }] : []\n ] : [\n {\n keyCode: VK.BACKSPACE,\n ctrlKey: true,\n action: action(refreshCaret, editor)\n },\n {\n keyCode: VK.DELETE,\n ctrlKey: true,\n action: action(refreshCaret, editor)\n }\n ]\n ], evt);\n const setup$j = (editor, caret) => {\n let isBackspaceKeydown = false;\n editor.on('keydown', evt => {\n isBackspaceKeydown = evt.keyCode === VK.BACKSPACE;\n if (!evt.isDefaultPrevented()) {\n executeKeydownOverride$3(editor, caret, evt);\n }\n });\n editor.on('keyup', evt => {\n if (!evt.isDefaultPrevented()) {\n executeKeyupOverride(editor, evt, isBackspaceKeydown);\n }\n isBackspaceKeydown = false;\n });\n };\n\n const firstNonWhiteSpaceNodeSibling = node => {\n while (node) {\n if (isElement$6(node) || isText$a(node) && node.data && /[\\r\\n\\s]/.test(node.data)) {\n return node;\n }\n node = node.nextSibling;\n }\n return null;\n };\n const moveToCaretPosition = (editor, root) => {\n const dom = editor.dom;\n const moveCaretBeforeOnEnterElementsMap = editor.schema.getMoveCaretBeforeOnEnterElements();\n if (!root) {\n return;\n }\n if (/^(LI|DT|DD)$/.test(root.nodeName)) {\n const firstChild = firstNonWhiteSpaceNodeSibling(root.firstChild);\n if (firstChild && /^(UL|OL|DL)$/.test(firstChild.nodeName)) {\n root.insertBefore(dom.doc.createTextNode(nbsp), root.firstChild);\n }\n }\n const rng = dom.createRng();\n root.normalize();\n if (root.hasChildNodes()) {\n const walker = new DomTreeWalker(root, root);\n let lastNode = root;\n let node;\n while (node = walker.current()) {\n if (isText$a(node)) {\n rng.setStart(node, 0);\n rng.setEnd(node, 0);\n break;\n }\n if (moveCaretBeforeOnEnterElementsMap[node.nodeName.toLowerCase()]) {\n rng.setStartBefore(node);\n rng.setEndBefore(node);\n break;\n }\n lastNode = node;\n node = walker.next();\n }\n if (!node) {\n rng.setStart(lastNode, 0);\n rng.setEnd(lastNode, 0);\n }\n } else {\n if (isBr$6(root)) {\n if (root.nextSibling && dom.isBlock(root.nextSibling)) {\n rng.setStartBefore(root);\n rng.setEndBefore(root);\n } else {\n rng.setStartAfter(root);\n rng.setEndAfter(root);\n }\n } else {\n rng.setStart(root, 0);\n rng.setEnd(root, 0);\n }\n }\n editor.selection.setRng(rng);\n scrollRangeIntoView(editor, rng);\n };\n const getEditableRoot = (dom, node) => {\n const root = dom.getRoot();\n let editableRoot;\n let parent = node;\n while (parent !== root && parent && dom.getContentEditable(parent) !== 'false') {\n if (dom.getContentEditable(parent) === 'true') {\n editableRoot = parent;\n break;\n }\n parent = parent.parentNode;\n }\n return parent !== root ? editableRoot : root;\n };\n const getParentBlock$1 = editor => {\n return Optional.from(editor.dom.getParent(editor.selection.getStart(true), editor.dom.isBlock));\n };\n const getParentBlockName = editor => {\n return getParentBlock$1(editor).fold(constant(''), parentBlock => {\n return parentBlock.nodeName.toUpperCase();\n });\n };\n const isListItemParentBlock = editor => {\n return getParentBlock$1(editor).filter(elm => {\n return isListItem$1(SugarElement.fromDom(elm));\n }).isSome();\n };\n const emptyBlock = elm => {\n elm.innerHTML = '
    ';\n };\n const applyAttributes = (editor, node, forcedRootBlockAttrs) => {\n const dom = editor.dom;\n Optional.from(forcedRootBlockAttrs.style).map(dom.parseStyle).each(attrStyles => {\n const currentStyles = getAllRaw(SugarElement.fromDom(node));\n const newStyles = {\n ...currentStyles,\n ...attrStyles\n };\n dom.setStyles(node, newStyles);\n });\n const attrClassesOpt = Optional.from(forcedRootBlockAttrs.class).map(attrClasses => attrClasses.split(/\\s+/));\n const currentClassesOpt = Optional.from(node.className).map(currentClasses => filter$5(currentClasses.split(/\\s+/), clazz => clazz !== ''));\n lift2(attrClassesOpt, currentClassesOpt, (attrClasses, currentClasses) => {\n const filteredClasses = filter$5(currentClasses, clazz => !contains$2(attrClasses, clazz));\n const newClasses = [\n ...attrClasses,\n ...filteredClasses\n ];\n dom.setAttrib(node, 'class', newClasses.join(' '));\n });\n const appliedAttrs = [\n 'style',\n 'class'\n ];\n const remainingAttrs = filter$4(forcedRootBlockAttrs, (_, attrs) => !contains$2(appliedAttrs, attrs));\n dom.setAttribs(node, remainingAttrs);\n };\n const setForcedBlockAttrs = (editor, node) => {\n const forcedRootBlockName = getForcedRootBlock(editor);\n if (forcedRootBlockName.toLowerCase() === node.tagName.toLowerCase()) {\n const forcedRootBlockAttrs = getForcedRootBlockAttrs(editor);\n applyAttributes(editor, node, forcedRootBlockAttrs);\n }\n };\n const createNewBlock = (editor, container, parentBlock, editableRoot, keepStyles = true, name, styles) => {\n const dom = editor.dom;\n const schema = editor.schema;\n const newBlockName = getForcedRootBlock(editor);\n const parentBlockName = parentBlock ? parentBlock.nodeName.toUpperCase() : '';\n let node = container;\n const textInlineElements = schema.getTextInlineElements();\n let block;\n if (name || parentBlockName === 'TABLE' || parentBlockName === 'HR') {\n block = dom.create(name || newBlockName, styles || {});\n } else {\n block = parentBlock.cloneNode(false);\n }\n let caretNode = block;\n if (!keepStyles) {\n dom.setAttrib(block, 'style', null);\n dom.setAttrib(block, 'class', null);\n } else {\n do {\n if (textInlineElements[node.nodeName]) {\n if (isCaretNode(node) || isBookmarkNode$1(node)) {\n continue;\n }\n const clonedNode = node.cloneNode(false);\n dom.setAttrib(clonedNode, 'id', '');\n if (block.hasChildNodes()) {\n clonedNode.appendChild(block.firstChild);\n block.appendChild(clonedNode);\n } else {\n caretNode = clonedNode;\n block.appendChild(clonedNode);\n }\n }\n } while ((node = node.parentNode) && node !== editableRoot);\n }\n setForcedBlockAttrs(editor, block);\n emptyBlock(caretNode);\n return block;\n };\n\n const getDetailsRoot = (editor, element) => editor.dom.getParent(element, isDetails);\n const isAtDetailsEdge = (root, element, isTextBlock) => {\n let node = element;\n while (node && node !== root && isNull(node.nextSibling)) {\n const parent = node.parentElement;\n if (!parent || !isTextBlock(parent)) {\n return isDetails(parent);\n }\n node = parent;\n }\n return false;\n };\n const isLastEmptyBlockInDetails = (editor, shiftKey, element) => !shiftKey && element.nodeName.toLowerCase() === getForcedRootBlock(editor) && editor.dom.isEmpty(element) && isAtDetailsEdge(editor.getBody(), element, el => has$2(editor.schema.getTextBlockElements(), el.nodeName.toLowerCase()));\n const insertNewLine = (editor, createNewBlock, parentBlock) => {\n var _a, _b, _c;\n const newBlock = createNewBlock(getForcedRootBlock(editor));\n const root = getDetailsRoot(editor, parentBlock);\n if (!root) {\n return;\n }\n editor.dom.insertAfter(newBlock, root);\n moveToCaretPosition(editor, newBlock);\n if (((_c = (_b = (_a = parentBlock.parentElement) === null || _a === void 0 ? void 0 : _a.childNodes) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 1) {\n editor.dom.remove(parentBlock);\n }\n };\n\n const hasFirstChild = (elm, name) => {\n return elm.firstChild && elm.firstChild.nodeName === name;\n };\n const isFirstChild = elm => {\n var _a;\n return ((_a = elm.parentNode) === null || _a === void 0 ? void 0 : _a.firstChild) === elm;\n };\n const hasParent = (elm, parentName) => {\n const parentNode = elm === null || elm === void 0 ? void 0 : elm.parentNode;\n return isNonNullable(parentNode) && parentNode.nodeName === parentName;\n };\n const isListBlock = elm => {\n return isNonNullable(elm) && /^(OL|UL|LI)$/.test(elm.nodeName);\n };\n const isListItem = elm => {\n return isNonNullable(elm) && /^(LI|DT|DD)$/.test(elm.nodeName);\n };\n const isNestedList = elm => {\n return isListBlock(elm) && isListBlock(elm.parentNode);\n };\n const getContainerBlock = containerBlock => {\n const containerBlockParent = containerBlock.parentNode;\n return isListItem(containerBlockParent) ? containerBlockParent : containerBlock;\n };\n const isFirstOrLastLi = (containerBlock, parentBlock, first) => {\n let node = containerBlock[first ? 'firstChild' : 'lastChild'];\n while (node) {\n if (isElement$6(node)) {\n break;\n }\n node = node[first ? 'nextSibling' : 'previousSibling'];\n }\n return node === parentBlock;\n };\n const getStyles = elm => foldl(mapToArray(getAllRaw(SugarElement.fromDom(elm)), (style, styleName) => `${ styleName }: ${ style };`), (acc, s) => acc + s, '');\n const insert$4 = (editor, createNewBlock, containerBlock, parentBlock, newBlockName) => {\n const dom = editor.dom;\n const rng = editor.selection.getRng();\n const containerParent = containerBlock.parentNode;\n if (containerBlock === editor.getBody() || !containerParent) {\n return;\n }\n if (isNestedList(containerBlock)) {\n newBlockName = 'LI';\n }\n const parentBlockStyles = isListItem(parentBlock) ? getStyles(parentBlock) : undefined;\n let newBlock = isListItem(parentBlock) && parentBlockStyles ? createNewBlock(newBlockName, { style: getStyles(parentBlock) }) : createNewBlock(newBlockName);\n if (isFirstOrLastLi(containerBlock, parentBlock, true) && isFirstOrLastLi(containerBlock, parentBlock, false)) {\n if (hasParent(containerBlock, 'LI')) {\n const containerBlockParent = getContainerBlock(containerBlock);\n dom.insertAfter(newBlock, containerBlockParent);\n if (isFirstChild(containerBlock)) {\n dom.remove(containerBlockParent);\n } else {\n dom.remove(containerBlock);\n }\n } else {\n dom.replace(newBlock, containerBlock);\n }\n } else if (isFirstOrLastLi(containerBlock, parentBlock, true)) {\n if (hasParent(containerBlock, 'LI')) {\n dom.insertAfter(newBlock, getContainerBlock(containerBlock));\n newBlock.appendChild(dom.doc.createTextNode(' '));\n newBlock.appendChild(containerBlock);\n } else {\n containerParent.insertBefore(newBlock, containerBlock);\n }\n dom.remove(parentBlock);\n } else if (isFirstOrLastLi(containerBlock, parentBlock, false)) {\n dom.insertAfter(newBlock, getContainerBlock(containerBlock));\n dom.remove(parentBlock);\n } else {\n containerBlock = getContainerBlock(containerBlock);\n const tmpRng = rng.cloneRange();\n tmpRng.setStartAfter(parentBlock);\n tmpRng.setEndAfter(containerBlock);\n const fragment = tmpRng.extractContents();\n if (newBlockName === 'LI' && hasFirstChild(fragment, 'LI')) {\n const previousChildren = filter$5(map$3(newBlock.children, SugarElement.fromDom), not(isTag('br')));\n newBlock = fragment.firstChild;\n dom.insertAfter(fragment, containerBlock);\n each$e(previousChildren, child => prepend(SugarElement.fromDom(newBlock), child));\n if (parentBlockStyles) {\n newBlock.setAttribute('style', parentBlockStyles);\n }\n } else {\n dom.insertAfter(fragment, containerBlock);\n dom.insertAfter(newBlock, containerBlock);\n }\n dom.remove(parentBlock);\n }\n moveToCaretPosition(editor, newBlock);\n };\n\n const trimZwsp = fragment => {\n each$e(descendants$1(SugarElement.fromDom(fragment), isText$b), text => {\n const rawNode = text.dom;\n rawNode.nodeValue = trim$2(rawNode.data);\n });\n };\n const isWithinNonEditableList = (editor, node) => {\n const parentList = editor.dom.getParent(node, 'ol,ul,dl');\n return parentList !== null && editor.dom.getContentEditableParent(parentList) === 'false';\n };\n const isEmptyAnchor = (dom, elm) => {\n return elm && elm.nodeName === 'A' && dom.isEmpty(elm);\n };\n const containerAndSiblingName = (container, nodeName) => {\n return container.nodeName === nodeName || container.previousSibling && container.previousSibling.nodeName === nodeName;\n };\n const canSplitBlock = (dom, node) => {\n return isNonNullable(node) && dom.isBlock(node) && !/^(TD|TH|CAPTION|FORM)$/.test(node.nodeName) && !/^(fixed|absolute)/i.test(node.style.position) && dom.isEditable(node.parentNode) && dom.getContentEditable(node) !== 'false';\n };\n const trimInlineElementsOnLeftSideOfBlock = (dom, nonEmptyElementsMap, block) => {\n var _a;\n const firstChilds = [];\n if (!block) {\n return;\n }\n let currentNode = block;\n while (currentNode = currentNode.firstChild) {\n if (dom.isBlock(currentNode)) {\n return;\n }\n if (isElement$6(currentNode) && !nonEmptyElementsMap[currentNode.nodeName.toLowerCase()]) {\n firstChilds.push(currentNode);\n }\n }\n let i = firstChilds.length;\n while (i--) {\n currentNode = firstChilds[i];\n if (!currentNode.hasChildNodes() || currentNode.firstChild === currentNode.lastChild && ((_a = currentNode.firstChild) === null || _a === void 0 ? void 0 : _a.nodeValue) === '') {\n dom.remove(currentNode);\n } else {\n if (isEmptyAnchor(dom, currentNode)) {\n dom.remove(currentNode);\n }\n }\n }\n };\n const normalizeZwspOffset = (start, container, offset) => {\n if (!isText$a(container)) {\n return offset;\n } else if (start) {\n return offset === 1 && container.data.charAt(offset - 1) === ZWSP$1 ? 0 : offset;\n } else {\n return offset === container.data.length - 1 && container.data.charAt(offset) === ZWSP$1 ? container.data.length : offset;\n }\n };\n const includeZwspInRange = rng => {\n const newRng = rng.cloneRange();\n newRng.setStart(rng.startContainer, normalizeZwspOffset(true, rng.startContainer, rng.startOffset));\n newRng.setEnd(rng.endContainer, normalizeZwspOffset(false, rng.endContainer, rng.endOffset));\n return newRng;\n };\n const trimLeadingLineBreaks = node => {\n let currentNode = node;\n do {\n if (isText$a(currentNode)) {\n currentNode.data = currentNode.data.replace(/^[\\r\\n]+/, '');\n }\n currentNode = currentNode.firstChild;\n } while (currentNode);\n };\n const wrapSelfAndSiblingsInDefaultBlock = (editor, newBlockName, rng, container, offset) => {\n var _a, _b;\n const dom = editor.dom;\n const editableRoot = (_a = getEditableRoot(dom, container)) !== null && _a !== void 0 ? _a : dom.getRoot();\n let parentBlock = dom.getParent(container, dom.isBlock);\n if (!parentBlock || !canSplitBlock(dom, parentBlock)) {\n parentBlock = parentBlock || editableRoot;\n if (!parentBlock.hasChildNodes()) {\n const newBlock = dom.create(newBlockName);\n setForcedBlockAttrs(editor, newBlock);\n parentBlock.appendChild(newBlock);\n rng.setStart(newBlock, 0);\n rng.setEnd(newBlock, 0);\n return newBlock;\n }\n let node = container;\n while (node && node.parentNode !== parentBlock) {\n node = node.parentNode;\n }\n let startNode;\n while (node && !dom.isBlock(node)) {\n startNode = node;\n node = node.previousSibling;\n }\n const startNodeName = (_b = startNode === null || startNode === void 0 ? void 0 : startNode.parentElement) === null || _b === void 0 ? void 0 : _b.nodeName;\n if (startNode && startNodeName && editor.schema.isValidChild(startNodeName, newBlockName.toLowerCase())) {\n const startNodeParent = startNode.parentNode;\n const newBlock = dom.create(newBlockName);\n setForcedBlockAttrs(editor, newBlock);\n startNodeParent.insertBefore(newBlock, startNode);\n node = startNode;\n while (node && !dom.isBlock(node)) {\n const next = node.nextSibling;\n newBlock.appendChild(node);\n node = next;\n }\n rng.setStart(container, offset);\n rng.setEnd(container, offset);\n }\n }\n return container;\n };\n const addBrToBlockIfNeeded = (dom, block) => {\n block.normalize();\n const lastChild = block.lastChild;\n if (!lastChild || isElement$6(lastChild) && /^(left|right)$/gi.test(dom.getStyle(lastChild, 'float', true))) {\n dom.add(block, 'br');\n }\n };\n const shouldEndContainer = (editor, container) => {\n const optionValue = shouldEndContainerOnEmptyBlock(editor);\n if (isNullable(container)) {\n return false;\n } else if (isString(optionValue)) {\n return contains$2(Tools.explode(optionValue), container.nodeName.toLowerCase());\n } else {\n return optionValue;\n }\n };\n const insert$3 = (editor, evt) => {\n let container;\n let offset;\n let parentBlockName;\n let containerBlock;\n let isAfterLastNodeInContainer = false;\n const dom = editor.dom;\n const schema = editor.schema, nonEmptyElementsMap = schema.getNonEmptyElements();\n const rng = editor.selection.getRng();\n const newBlockName = getForcedRootBlock(editor);\n const start = SugarElement.fromDom(rng.startContainer);\n const child = child$1(start, rng.startOffset);\n const isCef = child.exists(element => isHTMLElement$1(element) && !isEditable$2(element));\n const collapsedAndCef = rng.collapsed && isCef;\n const createNewBlock$1 = (name, styles) => {\n return createNewBlock(editor, container, parentBlock, editableRoot, shouldKeepStyles(editor), name, styles);\n };\n const isCaretAtStartOrEndOfBlock = start => {\n const normalizedOffset = normalizeZwspOffset(start, container, offset);\n if (isText$a(container) && (start ? normalizedOffset > 0 : normalizedOffset < container.data.length)) {\n return false;\n }\n if (container.parentNode === parentBlock && isAfterLastNodeInContainer && !start) {\n return true;\n }\n if (start && isElement$6(container) && container === parentBlock.firstChild) {\n return true;\n }\n if (containerAndSiblingName(container, 'TABLE') || containerAndSiblingName(container, 'HR')) {\n return isAfterLastNodeInContainer && !start || !isAfterLastNodeInContainer && start;\n }\n const walker = new DomTreeWalker(container, parentBlock);\n if (isText$a(container)) {\n if (start && normalizedOffset === 0) {\n walker.prev();\n } else if (!start && normalizedOffset === container.data.length) {\n walker.next();\n }\n }\n let node;\n while (node = walker.current()) {\n if (isElement$6(node)) {\n if (!node.getAttribute('data-mce-bogus')) {\n const name = node.nodeName.toLowerCase();\n if (nonEmptyElementsMap[name] && name !== 'br') {\n return false;\n }\n }\n } else if (isText$a(node) && !isWhitespaceText(node.data)) {\n return false;\n }\n if (start) {\n walker.prev();\n } else {\n walker.next();\n }\n }\n return true;\n };\n const insertNewBlockAfter = () => {\n let block;\n if (/^(H[1-6]|PRE|FIGURE)$/.test(parentBlockName) && containerBlockName !== 'HGROUP') {\n block = createNewBlock$1(newBlockName);\n } else {\n block = createNewBlock$1();\n }\n if (shouldEndContainer(editor, containerBlock) && canSplitBlock(dom, containerBlock) && dom.isEmpty(parentBlock, undefined, { includeZwsp: true })) {\n block = dom.split(containerBlock, parentBlock);\n } else {\n dom.insertAfter(block, parentBlock);\n }\n moveToCaretPosition(editor, block);\n return block;\n };\n normalize$2(dom, rng).each(normRng => {\n rng.setStart(normRng.startContainer, normRng.startOffset);\n rng.setEnd(normRng.endContainer, normRng.endOffset);\n });\n container = rng.startContainer;\n offset = rng.startOffset;\n const shiftKey = !!(evt && evt.shiftKey);\n const ctrlKey = !!(evt && evt.ctrlKey);\n if (isElement$6(container) && container.hasChildNodes() && !collapsedAndCef) {\n isAfterLastNodeInContainer = offset > container.childNodes.length - 1;\n container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;\n if (isAfterLastNodeInContainer && isText$a(container)) {\n offset = container.data.length;\n } else {\n offset = 0;\n }\n }\n const editableRoot = getEditableRoot(dom, container);\n if (!editableRoot || isWithinNonEditableList(editor, container)) {\n return;\n }\n if (!shiftKey) {\n container = wrapSelfAndSiblingsInDefaultBlock(editor, newBlockName, rng, container, offset);\n }\n let parentBlock = dom.getParent(container, dom.isBlock) || dom.getRoot();\n containerBlock = isNonNullable(parentBlock === null || parentBlock === void 0 ? void 0 : parentBlock.parentNode) ? dom.getParent(parentBlock.parentNode, dom.isBlock) : null;\n parentBlockName = parentBlock ? parentBlock.nodeName.toUpperCase() : '';\n const containerBlockName = containerBlock ? containerBlock.nodeName.toUpperCase() : '';\n if (containerBlockName === 'LI' && !ctrlKey) {\n const liBlock = containerBlock;\n parentBlock = liBlock;\n containerBlock = liBlock.parentNode;\n parentBlockName = containerBlockName;\n }\n if (isElement$6(containerBlock) && isLastEmptyBlockInDetails(editor, shiftKey, parentBlock)) {\n return insertNewLine(editor, createNewBlock$1, parentBlock);\n }\n if (/^(LI|DT|DD)$/.test(parentBlockName) && isElement$6(containerBlock)) {\n if (dom.isEmpty(parentBlock)) {\n insert$4(editor, createNewBlock$1, containerBlock, parentBlock, newBlockName);\n return;\n }\n }\n if (!collapsedAndCef && (parentBlock === editor.getBody() || !canSplitBlock(dom, parentBlock))) {\n return;\n }\n const parentBlockParent = parentBlock.parentNode;\n let newBlock;\n if (collapsedAndCef) {\n newBlock = createNewBlock$1(newBlockName);\n child.fold(() => {\n append$1(start, SugarElement.fromDom(newBlock));\n }, child => {\n before$3(child, SugarElement.fromDom(newBlock));\n });\n editor.selection.setCursorLocation(newBlock, 0);\n } else if (isCaretContainerBlock$1(parentBlock)) {\n newBlock = showCaretContainerBlock(parentBlock);\n if (dom.isEmpty(parentBlock)) {\n emptyBlock(parentBlock);\n }\n setForcedBlockAttrs(editor, newBlock);\n moveToCaretPosition(editor, newBlock);\n } else if (isCaretAtStartOrEndOfBlock(false)) {\n newBlock = insertNewBlockAfter();\n } else if (isCaretAtStartOrEndOfBlock(true) && parentBlockParent) {\n newBlock = parentBlockParent.insertBefore(createNewBlock$1(), parentBlock);\n const isNearChildren = hasChildNodes(SugarElement.fromDom(rng.startContainer)) && rng.collapsed;\n moveToCaretPosition(editor, containerAndSiblingName(parentBlock, 'HR') || isNearChildren ? newBlock : parentBlock);\n } else {\n const tmpRng = includeZwspInRange(rng).cloneRange();\n tmpRng.setEndAfter(parentBlock);\n const fragment = tmpRng.extractContents();\n trimZwsp(fragment);\n trimLeadingLineBreaks(fragment);\n newBlock = fragment.firstChild;\n dom.insertAfter(fragment, parentBlock);\n trimInlineElementsOnLeftSideOfBlock(dom, nonEmptyElementsMap, newBlock);\n addBrToBlockIfNeeded(dom, parentBlock);\n if (dom.isEmpty(parentBlock)) {\n emptyBlock(parentBlock);\n }\n newBlock.normalize();\n if (dom.isEmpty(newBlock)) {\n dom.remove(newBlock);\n insertNewBlockAfter();\n } else {\n setForcedBlockAttrs(editor, newBlock);\n moveToCaretPosition(editor, newBlock);\n }\n }\n dom.setAttrib(newBlock, 'id', '');\n editor.dispatch('NewBlock', { newBlock });\n };\n const fakeEventName$1 = 'insertParagraph';\n const blockbreak = {\n insert: insert$3,\n fakeEventName: fakeEventName$1\n };\n\n const hasRightSideContent = (schema, container, parentBlock) => {\n const walker = new DomTreeWalker(container, parentBlock);\n let node;\n const nonEmptyElementsMap = schema.getNonEmptyElements();\n while (node = walker.next()) {\n if (nonEmptyElementsMap[node.nodeName.toLowerCase()] || isText$a(node) && node.length > 0) {\n return true;\n }\n }\n return false;\n };\n const moveSelectionToBr = (editor, brElm, extraBr) => {\n const rng = editor.dom.createRng();\n if (!extraBr) {\n rng.setStartAfter(brElm);\n rng.setEndAfter(brElm);\n } else {\n rng.setStartBefore(brElm);\n rng.setEndBefore(brElm);\n }\n editor.selection.setRng(rng);\n scrollRangeIntoView(editor, rng);\n };\n const insertBrAtCaret = (editor, evt) => {\n const selection = editor.selection;\n const dom = editor.dom;\n const rng = selection.getRng();\n let brElm;\n let extraBr = false;\n normalize$2(dom, rng).each(normRng => {\n rng.setStart(normRng.startContainer, normRng.startOffset);\n rng.setEnd(normRng.endContainer, normRng.endOffset);\n });\n let offset = rng.startOffset;\n let container = rng.startContainer;\n if (isElement$6(container) && container.hasChildNodes()) {\n const isAfterLastNodeInContainer = offset > container.childNodes.length - 1;\n container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;\n if (isAfterLastNodeInContainer && isText$a(container)) {\n offset = container.data.length;\n } else {\n offset = 0;\n }\n }\n let parentBlock = dom.getParent(container, dom.isBlock);\n const containerBlock = parentBlock && parentBlock.parentNode ? dom.getParent(parentBlock.parentNode, dom.isBlock) : null;\n const containerBlockName = containerBlock ? containerBlock.nodeName.toUpperCase() : '';\n const isControlKey = !!(evt && evt.ctrlKey);\n if (containerBlockName === 'LI' && !isControlKey) {\n parentBlock = containerBlock;\n }\n if (isText$a(container) && offset >= container.data.length) {\n if (!hasRightSideContent(editor.schema, container, parentBlock || dom.getRoot())) {\n brElm = dom.create('br');\n rng.insertNode(brElm);\n rng.setStartAfter(brElm);\n rng.setEndAfter(brElm);\n extraBr = true;\n }\n }\n brElm = dom.create('br');\n rangeInsertNode(dom, rng, brElm);\n moveSelectionToBr(editor, brElm, extraBr);\n editor.undoManager.add();\n };\n const insertBrBefore = (editor, inline) => {\n const br = SugarElement.fromTag('br');\n before$3(SugarElement.fromDom(inline), br);\n editor.undoManager.add();\n };\n const insertBrAfter = (editor, inline) => {\n if (!hasBrAfter(editor.getBody(), inline)) {\n after$4(SugarElement.fromDom(inline), SugarElement.fromTag('br'));\n }\n const br = SugarElement.fromTag('br');\n after$4(SugarElement.fromDom(inline), br);\n moveSelectionToBr(editor, br.dom, false);\n editor.undoManager.add();\n };\n const isBeforeBr = pos => {\n return isBr$6(pos.getNode());\n };\n const hasBrAfter = (rootNode, startNode) => {\n if (isBeforeBr(CaretPosition.after(startNode))) {\n return true;\n } else {\n return nextPosition(rootNode, CaretPosition.after(startNode)).map(pos => {\n return isBr$6(pos.getNode());\n }).getOr(false);\n }\n };\n const isAnchorLink = elm => {\n return elm && elm.nodeName === 'A' && 'href' in elm;\n };\n const isInsideAnchor = location => {\n return location.fold(never, isAnchorLink, isAnchorLink, never);\n };\n const readInlineAnchorLocation = editor => {\n const isInlineTarget$1 = curry(isInlineTarget, editor);\n const position = CaretPosition.fromRangeStart(editor.selection.getRng());\n return readLocation(isInlineTarget$1, editor.getBody(), position).filter(isInsideAnchor);\n };\n const insertBrOutsideAnchor = (editor, location) => {\n location.fold(noop, curry(insertBrBefore, editor), curry(insertBrAfter, editor), noop);\n };\n const insert$2 = (editor, evt) => {\n const anchorLocation = readInlineAnchorLocation(editor);\n if (anchorLocation.isSome()) {\n anchorLocation.each(curry(insertBrOutsideAnchor, editor));\n } else {\n insertBrAtCaret(editor, evt);\n }\n };\n const fakeEventName = 'insertLineBreak';\n const linebreak = {\n insert: insert$2,\n fakeEventName\n };\n\n const matchesSelector = (editor, selector) => {\n return getParentBlock$1(editor).filter(parentBlock => {\n return selector.length > 0 && is$1(SugarElement.fromDom(parentBlock), selector);\n }).isSome();\n };\n const shouldInsertBr = editor => {\n return matchesSelector(editor, getBrNewLineSelector(editor));\n };\n const shouldBlockNewLine$1 = editor => {\n return matchesSelector(editor, getNoNewLineSelector(editor));\n };\n\n const newLineAction = Adt.generate([\n { br: [] },\n { block: [] },\n { none: [] }\n ]);\n const shouldBlockNewLine = (editor, _shiftKey) => {\n return shouldBlockNewLine$1(editor);\n };\n const inListBlock = requiredState => {\n return (editor, _shiftKey) => {\n return isListItemParentBlock(editor) === requiredState;\n };\n };\n const inBlock = (blockName, requiredState) => (editor, _shiftKey) => {\n const state = getParentBlockName(editor) === blockName.toUpperCase();\n return state === requiredState;\n };\n const inCefBlock = editor => {\n const editableRoot = getEditableRoot(editor.dom, editor.selection.getStart());\n return isNullable(editableRoot);\n };\n const inPreBlock = requiredState => inBlock('pre', requiredState);\n const inSummaryBlock = () => inBlock('summary', true);\n const shouldPutBrInPre = requiredState => {\n return (editor, _shiftKey) => {\n return shouldPutBrInPre$1(editor) === requiredState;\n };\n };\n const inBrContext = (editor, _shiftKey) => {\n return shouldInsertBr(editor);\n };\n const hasShiftKey = (_editor, shiftKey) => {\n return shiftKey;\n };\n const canInsertIntoEditableRoot = editor => {\n const forcedRootBlock = getForcedRootBlock(editor);\n const rootEditable = getEditableRoot(editor.dom, editor.selection.getStart());\n return isNonNullable(rootEditable) && editor.schema.isValidChild(rootEditable.nodeName, forcedRootBlock);\n };\n const isInRootWithEmptyOrCEF = editor => {\n const rng = editor.selection.getRng();\n const start = SugarElement.fromDom(rng.startContainer);\n const child = child$1(start, rng.startOffset);\n const isCefOpt = child.map(element => isHTMLElement$1(element) && !isEditable$2(element));\n return rng.collapsed && isCefOpt.getOr(true);\n };\n const match = (predicates, action) => {\n return (editor, shiftKey) => {\n const isMatch = foldl(predicates, (res, p) => {\n return res && p(editor, shiftKey);\n }, true);\n return isMatch ? Optional.some(action) : Optional.none();\n };\n };\n const getAction = (editor, evt) => {\n return evaluateUntil([\n match([shouldBlockNewLine], newLineAction.none()),\n match([\n inPreBlock(true),\n inCefBlock\n ], newLineAction.none()),\n match([inSummaryBlock()], newLineAction.br()),\n match([\n inPreBlock(true),\n shouldPutBrInPre(false),\n hasShiftKey\n ], newLineAction.br()),\n match([\n inPreBlock(true),\n shouldPutBrInPre(false)\n ], newLineAction.block()),\n match([\n inPreBlock(true),\n shouldPutBrInPre(true),\n hasShiftKey\n ], newLineAction.block()),\n match([\n inPreBlock(true),\n shouldPutBrInPre(true)\n ], newLineAction.br()),\n match([\n inListBlock(true),\n hasShiftKey\n ], newLineAction.br()),\n match([inListBlock(true)], newLineAction.block()),\n match([inBrContext], newLineAction.br()),\n match([hasShiftKey], newLineAction.br()),\n match([canInsertIntoEditableRoot], newLineAction.block()),\n match([isInRootWithEmptyOrCEF], newLineAction.block())\n ], [\n editor,\n !!(evt && evt.shiftKey)\n ]).getOr(newLineAction.none());\n };\n\n const insertBreak = (breakType, editor, evt) => {\n if (!editor.selection.isCollapsed()) {\n execEditorDeleteCommand(editor);\n }\n if (isNonNullable(evt)) {\n const event = fireBeforeInputEvent(editor, breakType.fakeEventName);\n if (event.isDefaultPrevented()) {\n return;\n }\n }\n breakType.insert(editor, evt);\n if (isNonNullable(evt)) {\n fireInputEvent(editor, breakType.fakeEventName);\n }\n };\n const insert$1 = (editor, evt) => {\n const br = () => insertBreak(linebreak, editor, evt);\n const block = () => insertBreak(blockbreak, editor, evt);\n const logicalAction = getAction(editor, evt);\n switch (getNewlineBehavior(editor)) {\n case 'linebreak':\n logicalAction.fold(br, br, noop);\n break;\n case 'block':\n logicalAction.fold(block, block, noop);\n break;\n case 'invert':\n logicalAction.fold(block, br, noop);\n break;\n default:\n logicalAction.fold(br, block, noop);\n break;\n }\n };\n\n const platform$1 = detect$2();\n const isIOSSafari = platform$1.os.isiOS() && platform$1.browser.isSafari();\n const handleEnterKeyEvent = (editor, event) => {\n if (event.isDefaultPrevented()) {\n return;\n }\n event.preventDefault();\n endTypingLevelIgnoreLocks(editor.undoManager);\n editor.undoManager.transact(() => {\n insert$1(editor, event);\n });\n };\n const isCaretAfterKoreanCharacter = rng => {\n if (!rng.collapsed) {\n return false;\n }\n const startContainer = rng.startContainer;\n if (isText$a(startContainer)) {\n const koreanCharRegex = /^[\\uAC00-\\uD7AF\\u1100-\\u11FF\\u3130-\\u318F\\uA960-\\uA97F\\uD7B0-\\uD7FF]$/;\n const char = startContainer.data.charAt(rng.startOffset - 1);\n return koreanCharRegex.test(char);\n } else {\n return false;\n }\n };\n const setup$i = editor => {\n let iOSSafariKeydownBookmark = Optional.none();\n const iOSSafariKeydownOverride = editor => {\n iOSSafariKeydownBookmark = Optional.some(editor.selection.getBookmark());\n editor.undoManager.add();\n };\n const iOSSafariKeyupOverride = (editor, event) => {\n editor.undoManager.undo();\n iOSSafariKeydownBookmark.fold(noop, b => editor.selection.moveToBookmark(b));\n handleEnterKeyEvent(editor, event);\n iOSSafariKeydownBookmark = Optional.none();\n };\n editor.on('keydown', event => {\n if (event.keyCode === VK.ENTER) {\n if (isIOSSafari && isCaretAfterKoreanCharacter(editor.selection.getRng())) {\n iOSSafariKeydownOverride(editor);\n } else {\n handleEnterKeyEvent(editor, event);\n }\n }\n });\n editor.on('keyup', event => {\n if (event.keyCode === VK.ENTER) {\n iOSSafariKeydownBookmark.each(() => iOSSafariKeyupOverride(editor, event));\n }\n });\n };\n\n const executeKeydownOverride$2 = (editor, caret, evt) => {\n const isMac = Env.os.isMacOS() || Env.os.isiOS();\n execute([\n {\n keyCode: VK.END,\n action: action(moveToLineEndPoint$1, editor, true)\n },\n {\n keyCode: VK.HOME,\n action: action(moveToLineEndPoint$1, editor, false)\n },\n ...!isMac ? [\n {\n keyCode: VK.HOME,\n action: action(selectToEndPoint, editor, false),\n ctrlKey: true,\n shiftKey: true\n },\n {\n keyCode: VK.END,\n action: action(selectToEndPoint, editor, true),\n ctrlKey: true,\n shiftKey: true\n }\n ] : [],\n {\n keyCode: VK.END,\n action: action(moveToLineEndPoint, editor, true)\n },\n {\n keyCode: VK.HOME,\n action: action(moveToLineEndPoint, editor, false)\n },\n {\n keyCode: VK.END,\n action: action(moveToLineEndPoint$2, editor, true, caret)\n },\n {\n keyCode: VK.HOME,\n action: action(moveToLineEndPoint$2, editor, false, caret)\n }\n ], evt).each(_ => {\n evt.preventDefault();\n });\n };\n const setup$h = (editor, caret) => {\n editor.on('keydown', evt => {\n if (!evt.isDefaultPrevented()) {\n executeKeydownOverride$2(editor, caret, evt);\n }\n });\n };\n\n const setup$g = editor => {\n editor.on('input', e => {\n if (!e.isComposing) {\n normalizeNbspsInEditor(editor);\n }\n });\n };\n\n const platform = detect$2();\n const executeKeyupAction = (editor, caret, evt) => {\n execute([\n {\n keyCode: VK.PAGE_UP,\n action: action(moveToLineEndPoint$2, editor, false, caret)\n },\n {\n keyCode: VK.PAGE_DOWN,\n action: action(moveToLineEndPoint$2, editor, true, caret)\n }\n ], evt);\n };\n const stopImmediatePropagation = e => e.stopImmediatePropagation();\n const isPageUpDown = evt => evt.keyCode === VK.PAGE_UP || evt.keyCode === VK.PAGE_DOWN;\n const setNodeChangeBlocker = (blocked, editor, block) => {\n if (block && !blocked.get()) {\n editor.on('NodeChange', stopImmediatePropagation, true);\n } else if (!block && blocked.get()) {\n editor.off('NodeChange', stopImmediatePropagation);\n }\n blocked.set(block);\n };\n const setup$f = (editor, caret) => {\n if (platform.os.isMacOS()) {\n return;\n }\n const blocked = Cell(false);\n editor.on('keydown', evt => {\n if (isPageUpDown(evt)) {\n setNodeChangeBlocker(blocked, editor, true);\n }\n });\n editor.on('keyup', evt => {\n if (!evt.isDefaultPrevented()) {\n executeKeyupAction(editor, caret, evt);\n }\n if (isPageUpDown(evt) && blocked.get()) {\n setNodeChangeBlocker(blocked, editor, false);\n editor.nodeChanged();\n }\n });\n };\n\n const setup$e = editor => {\n editor.on('beforeinput', e => {\n if (!editor.selection.isEditable() || exists(e.getTargetRanges(), rng => !isEditableRange(editor.dom, rng))) {\n e.preventDefault();\n }\n });\n };\n\n const insertTextAtPosition = (text, pos) => {\n const container = pos.container();\n const offset = pos.offset();\n if (isText$a(container)) {\n container.insertData(offset, text);\n return Optional.some(CaretPosition(container, offset + text.length));\n } else {\n return getElementFromPosition(pos).map(elm => {\n const textNode = SugarElement.fromText(text);\n if (pos.isAtEnd()) {\n after$4(elm, textNode);\n } else {\n before$3(elm, textNode);\n }\n return CaretPosition(textNode.dom, text.length);\n });\n }\n };\n const insertNbspAtPosition = curry(insertTextAtPosition, nbsp);\n const insertSpaceAtPosition = curry(insertTextAtPosition, ' ');\n\n const insertSpaceOrNbspAtPosition = (root, pos, schema) => needsToHaveNbsp(root, pos, schema) ? insertNbspAtPosition(pos) : insertSpaceAtPosition(pos);\n const locationToCaretPosition = root => location => location.fold(element => prevPosition(root.dom, CaretPosition.before(element)), element => firstPositionIn(element), element => lastPositionIn(element), element => nextPosition(root.dom, CaretPosition.after(element)));\n const insertInlineBoundarySpaceOrNbsp = (root, pos, schema) => checkPos => needsToHaveNbsp(root, checkPos, schema) ? insertNbspAtPosition(pos) : insertSpaceAtPosition(pos);\n const setSelection = editor => pos => {\n editor.selection.setRng(pos.toRange());\n editor.nodeChanged();\n };\n const isInsideSummary = (domUtils, node) => domUtils.isEditable(domUtils.getParent(node, 'summary'));\n const insertSpaceOrNbspAtSelection = editor => {\n const pos = CaretPosition.fromRangeStart(editor.selection.getRng());\n const root = SugarElement.fromDom(editor.getBody());\n if (editor.selection.isCollapsed()) {\n const isInlineTarget$1 = curry(isInlineTarget, editor);\n const caretPosition = CaretPosition.fromRangeStart(editor.selection.getRng());\n return readLocation(isInlineTarget$1, editor.getBody(), caretPosition).bind(locationToCaretPosition(root)).map(checkPos => () => insertInlineBoundarySpaceOrNbsp(root, pos, editor.schema)(checkPos).each(setSelection(editor)));\n } else {\n return Optional.none();\n }\n };\n const insertSpaceInSummaryAtSelectionOnFirefox = editor => {\n const insertSpaceThunk = () => {\n const root = SugarElement.fromDom(editor.getBody());\n if (!editor.selection.isCollapsed()) {\n editor.getDoc().execCommand('Delete');\n }\n const pos = CaretPosition.fromRangeStart(editor.selection.getRng());\n insertSpaceOrNbspAtPosition(root, pos, editor.schema).each(setSelection(editor));\n };\n return someIf(Env.browser.isFirefox() && editor.selection.isEditable() && isInsideSummary(editor.dom, editor.selection.getRng().startContainer), insertSpaceThunk);\n };\n\n const executeKeydownOverride$1 = (editor, evt) => {\n executeWithDelayedAction([\n {\n keyCode: VK.SPACEBAR,\n action: action(insertSpaceOrNbspAtSelection, editor)\n },\n {\n keyCode: VK.SPACEBAR,\n action: action(insertSpaceInSummaryAtSelectionOnFirefox, editor)\n }\n ], evt).each(applyAction => {\n evt.preventDefault();\n const event = fireBeforeInputEvent(editor, 'insertText', { data: ' ' });\n if (!event.isDefaultPrevented()) {\n applyAction();\n fireInputEvent(editor, 'insertText', { data: ' ' });\n }\n });\n };\n const setup$d = editor => {\n editor.on('keydown', evt => {\n if (!evt.isDefaultPrevented()) {\n executeKeydownOverride$1(editor, evt);\n }\n });\n };\n\n const tableTabNavigation = editor => {\n if (hasTableTabNavigation(editor)) {\n return [\n {\n keyCode: VK.TAB,\n action: action(handleTab, editor, true)\n },\n {\n keyCode: VK.TAB,\n shiftKey: true,\n action: action(handleTab, editor, false)\n }\n ];\n } else {\n return [];\n }\n };\n const executeKeydownOverride = (editor, evt) => {\n execute([...tableTabNavigation(editor)], evt).each(_ => {\n evt.preventDefault();\n });\n };\n const setup$c = editor => {\n editor.on('keydown', evt => {\n if (!evt.isDefaultPrevented()) {\n executeKeydownOverride(editor, evt);\n }\n });\n };\n\n const setup$b = editor => {\n editor.addShortcut('Meta+P', '', 'mcePrint');\n setup$k(editor);\n if (isRtc(editor)) {\n return Cell(null);\n } else {\n const caret = setupSelectedState(editor);\n setup$e(editor);\n setup$m(editor);\n setup$l(editor, caret);\n setup$j(editor, caret);\n setup$i(editor);\n setup$d(editor);\n setup$g(editor);\n setup$c(editor);\n setup$h(editor, caret);\n setup$f(editor, caret);\n return caret;\n }\n };\n\n class NodeChange {\n constructor(editor) {\n this.lastPath = [];\n this.editor = editor;\n let lastRng;\n const self = this;\n if (!('onselectionchange' in editor.getDoc())) {\n editor.on('NodeChange click mouseup keyup focus', e => {\n const nativeRng = editor.selection.getRng();\n const fakeRng = {\n startContainer: nativeRng.startContainer,\n startOffset: nativeRng.startOffset,\n endContainer: nativeRng.endContainer,\n endOffset: nativeRng.endOffset\n };\n if (e.type === 'nodechange' || !isEq$4(fakeRng, lastRng)) {\n editor.dispatch('SelectionChange');\n }\n lastRng = fakeRng;\n });\n }\n editor.on('contextmenu', () => {\n editor.dispatch('SelectionChange');\n });\n editor.on('SelectionChange', () => {\n const startElm = editor.selection.getStart(true);\n if (!startElm) {\n return;\n }\n if (hasAnyRanges(editor) && !self.isSameElementPath(startElm) && editor.dom.isChildOf(startElm, editor.getBody())) {\n editor.nodeChanged({ selectionChange: true });\n }\n });\n editor.on('mouseup', e => {\n if (!e.isDefaultPrevented() && hasAnyRanges(editor)) {\n if (editor.selection.getNode().nodeName === 'IMG') {\n Delay.setEditorTimeout(editor, () => {\n editor.nodeChanged();\n });\n } else {\n editor.nodeChanged();\n }\n }\n });\n }\n nodeChanged(args = {}) {\n const selection = this.editor.selection;\n let node;\n if (this.editor.initialized && selection && !shouldDisableNodeChange(this.editor) && !this.editor.mode.isReadOnly()) {\n const root = this.editor.getBody();\n node = selection.getStart(true) || root;\n if (node.ownerDocument !== this.editor.getDoc() || !this.editor.dom.isChildOf(node, root)) {\n node = root;\n }\n const parents = [];\n this.editor.dom.getParent(node, node => {\n if (node === root) {\n return true;\n } else {\n parents.push(node);\n return false;\n }\n });\n this.editor.dispatch('NodeChange', {\n ...args,\n element: node,\n parents\n });\n }\n }\n isSameElementPath(startElm) {\n let i;\n const editor = this.editor;\n const currentPath = reverse(editor.dom.getParents(startElm, always, editor.getBody()));\n if (currentPath.length === this.lastPath.length) {\n for (i = currentPath.length; i >= 0; i--) {\n if (currentPath[i] !== this.lastPath[i]) {\n break;\n }\n }\n if (i === -1) {\n this.lastPath = currentPath;\n return true;\n }\n }\n this.lastPath = currentPath;\n return false;\n }\n }\n\n const imageId = generate$1('image');\n const getDragImage = transfer => {\n const dt = transfer;\n return Optional.from(dt[imageId]);\n };\n const setDragImage = (transfer, imageData) => {\n const dt = transfer;\n dt[imageId] = imageData;\n };\n\n const eventId = generate$1('event');\n const getEvent = transfer => {\n const dt = transfer;\n return Optional.from(dt[eventId]);\n };\n const mkSetEventFn = type => transfer => {\n const dt = transfer;\n dt[eventId] = type;\n };\n const setEvent = (transfer, type) => mkSetEventFn(type)(transfer);\n const setDragstartEvent = mkSetEventFn(0);\n const setDropEvent = mkSetEventFn(2);\n const setDragendEvent = mkSetEventFn(1);\n const checkEvent = expectedType => transfer => {\n const dt = transfer;\n return Optional.from(dt[eventId]).exists(type => type === expectedType);\n };\n const isInDragStartEvent = checkEvent(0);\n\n const createEmptyFileList = () => Object.freeze({\n length: 0,\n item: _ => null\n });\n\n const modeId = generate$1('mode');\n const getMode = transfer => {\n const dt = transfer;\n return Optional.from(dt[modeId]);\n };\n const mkSetModeFn = mode => transfer => {\n const dt = transfer;\n dt[modeId] = mode;\n };\n const setMode$1 = (transfer, mode) => mkSetModeFn(mode)(transfer);\n const setReadWriteMode = mkSetModeFn(0);\n const setReadOnlyMode = mkSetModeFn(2);\n const setProtectedMode = mkSetModeFn(1);\n const checkMode = expectedMode => transfer => {\n const dt = transfer;\n return Optional.from(dt[modeId]).exists(mode => mode === expectedMode);\n };\n const isInReadWriteMode = checkMode(0);\n const isInProtectedMode = checkMode(1);\n\n const normalizeItems = (dataTransfer, itemsImpl) => ({\n ...itemsImpl,\n get length() {\n return itemsImpl.length;\n },\n add: (data, type) => {\n if (isInReadWriteMode(dataTransfer)) {\n if (isString(data)) {\n if (!isUndefined(type)) {\n return itemsImpl.add(data, type);\n }\n } else {\n return itemsImpl.add(data);\n }\n }\n return null;\n },\n remove: idx => {\n if (isInReadWriteMode(dataTransfer)) {\n itemsImpl.remove(idx);\n }\n },\n clear: () => {\n if (isInReadWriteMode(dataTransfer)) {\n itemsImpl.clear();\n }\n }\n });\n\n const validDropEffects = [\n 'none',\n 'copy',\n 'link',\n 'move'\n ];\n const validEffectAlloweds = [\n 'none',\n 'copy',\n 'copyLink',\n 'copyMove',\n 'link',\n 'linkMove',\n 'move',\n 'all',\n 'uninitialized'\n ];\n const createDataTransfer = () => {\n const dataTransferImpl = new window.DataTransfer();\n let dropEffect = 'move';\n let effectAllowed = 'all';\n const dataTransfer = {\n get dropEffect() {\n return dropEffect;\n },\n set dropEffect(effect) {\n if (contains$2(validDropEffects, effect)) {\n dropEffect = effect;\n }\n },\n get effectAllowed() {\n return effectAllowed;\n },\n set effectAllowed(allowed) {\n if (isInDragStartEvent(dataTransfer) && contains$2(validEffectAlloweds, allowed)) {\n effectAllowed = allowed;\n }\n },\n get items() {\n return normalizeItems(dataTransfer, dataTransferImpl.items);\n },\n get files() {\n if (isInProtectedMode(dataTransfer)) {\n return createEmptyFileList();\n } else {\n return dataTransferImpl.files;\n }\n },\n get types() {\n return dataTransferImpl.types;\n },\n setDragImage: (image, x, y) => {\n if (isInReadWriteMode(dataTransfer)) {\n setDragImage(dataTransfer, {\n image,\n x,\n y\n });\n dataTransferImpl.setDragImage(image, x, y);\n }\n },\n getData: format => {\n if (isInProtectedMode(dataTransfer)) {\n return '';\n } else {\n return dataTransferImpl.getData(format);\n }\n },\n setData: (format, data) => {\n if (isInReadWriteMode(dataTransfer)) {\n dataTransferImpl.setData(format, data);\n }\n },\n clearData: format => {\n if (isInReadWriteMode(dataTransfer)) {\n dataTransferImpl.clearData(format);\n }\n }\n };\n setReadWriteMode(dataTransfer);\n return dataTransfer;\n };\n const cloneDataTransfer = original => {\n const clone = createDataTransfer();\n const originalMode = getMode(original);\n setReadOnlyMode(original);\n setDragstartEvent(clone);\n clone.dropEffect = original.dropEffect;\n clone.effectAllowed = original.effectAllowed;\n getDragImage(original).each(imageData => clone.setDragImage(imageData.image, imageData.x, imageData.y));\n each$e(original.types, type => {\n if (type !== 'Files') {\n clone.setData(type, original.getData(type));\n }\n });\n each$e(original.files, file => clone.items.add(file));\n getEvent(original).each(type => {\n setEvent(clone, type);\n });\n originalMode.each(mode => {\n setMode$1(original, mode);\n setMode$1(clone, mode);\n });\n return clone;\n };\n\n const getHtmlData = dataTransfer => {\n const html = dataTransfer.getData('text/html');\n return html === '' ? Optional.none() : Optional.some(html);\n };\n const setHtmlData = (dataTransfer, html) => dataTransfer.setData('text/html', html);\n\n const internalMimeType = 'x-tinymce/html';\n const internalHtmlMime = constant(internalMimeType);\n const internalMark = '';\n const mark = html => internalMark + html;\n const unmark = html => html.replace(internalMark, '');\n const isMarked = html => html.indexOf(internalMark) !== -1;\n\n const isPlainText = text => {\n return !/<(?:\\/?(?!(?:div|p|br|span)>)\\w+|(?:(?!(?:span style=\"white-space:\\s?pre;?\">)|br\\s?\\/>))\\w+\\s[^>]+)>/i.test(text);\n };\n const openContainer = (rootTag, rootAttrs) => {\n let tag = '<' + rootTag;\n const attrs = mapToArray(rootAttrs, (value, key) => key + '=\"' + Entities.encodeAllRaw(value) + '\"');\n if (attrs.length) {\n tag += ' ' + attrs.join(' ');\n }\n return tag + '>';\n };\n const toBlockElements = (text, rootTag, rootAttrs) => {\n const blocks = text.split(/\\n\\n/);\n const tagOpen = openContainer(rootTag, rootAttrs);\n const tagClose = '';\n const paragraphs = map$3(blocks, p => {\n return p.split(/\\n/).join('
    ');\n });\n const stitch = p => {\n return tagOpen + p + tagClose;\n };\n return paragraphs.length === 1 ? paragraphs[0] : map$3(paragraphs, stitch).join('');\n };\n\n const pasteBinDefaultContent = '%MCEPASTEBIN%';\n const create$6 = (editor, lastRngCell) => {\n const {dom, selection} = editor;\n const body = editor.getBody();\n lastRngCell.set(selection.getRng());\n const pasteBinElm = dom.add(editor.getBody(), 'div', {\n 'id': 'mcepastebin',\n 'class': 'mce-pastebin',\n 'contentEditable': true,\n 'data-mce-bogus': 'all',\n 'style': 'position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0'\n }, pasteBinDefaultContent);\n if (Env.browser.isFirefox()) {\n dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) === 'rtl' ? 65535 : -65535);\n }\n dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', e => {\n e.stopPropagation();\n });\n pasteBinElm.focus();\n selection.select(pasteBinElm, true);\n };\n const remove = (editor, lastRngCell) => {\n const dom = editor.dom;\n if (getEl(editor)) {\n let pasteBinClone;\n const lastRng = lastRngCell.get();\n while (pasteBinClone = getEl(editor)) {\n dom.remove(pasteBinClone);\n dom.unbind(pasteBinClone);\n }\n if (lastRng) {\n editor.selection.setRng(lastRng);\n }\n }\n lastRngCell.set(null);\n };\n const getEl = editor => editor.dom.get('mcepastebin');\n const isPasteBin = elm => isNonNullable(elm) && elm.id === 'mcepastebin';\n const getHtml = editor => {\n const dom = editor.dom;\n const copyAndRemove = (toElm, fromElm) => {\n toElm.appendChild(fromElm);\n dom.remove(fromElm, true);\n };\n const [pasteBinElm, ...pasteBinClones] = filter$5(editor.getBody().childNodes, isPasteBin);\n each$e(pasteBinClones, pasteBinClone => {\n copyAndRemove(pasteBinElm, pasteBinClone);\n });\n const dirtyWrappers = dom.select('div[id=mcepastebin]', pasteBinElm);\n for (let i = dirtyWrappers.length - 1; i >= 0; i--) {\n const cleanWrapper = dom.create('div');\n pasteBinElm.insertBefore(cleanWrapper, dirtyWrappers[i]);\n copyAndRemove(cleanWrapper, dirtyWrappers[i]);\n }\n return pasteBinElm ? pasteBinElm.innerHTML : '';\n };\n const isDefaultPasteBinContent = content => content === pasteBinDefaultContent;\n const PasteBin = editor => {\n const lastRng = Cell(null);\n return {\n create: () => create$6(editor, lastRng),\n remove: () => remove(editor, lastRng),\n getEl: () => getEl(editor),\n getHtml: () => getHtml(editor),\n getLastRng: lastRng.get\n };\n };\n\n const filter$1 = (content, items) => {\n Tools.each(items, v => {\n if (is$4(v, RegExp)) {\n content = content.replace(v, '');\n } else {\n content = content.replace(v[0], v[1]);\n }\n });\n return content;\n };\n const innerText = html => {\n const schema = Schema();\n const domParser = DomParser({}, schema);\n let text = '';\n const voidElements = schema.getVoidElements();\n const ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');\n const blockElements = schema.getBlockElements();\n const walk = node => {\n const name = node.name, currentNode = node;\n if (name === 'br') {\n text += '\\n';\n return;\n }\n if (name === 'wbr') {\n return;\n }\n if (voidElements[name]) {\n text += ' ';\n }\n if (ignoreElements[name]) {\n text += ' ';\n return;\n }\n if (node.type === 3) {\n text += node.value;\n }\n if (!(node.name in schema.getVoidElements())) {\n let currentNode = node.firstChild;\n if (currentNode) {\n do {\n walk(currentNode);\n } while (currentNode = currentNode.next);\n }\n }\n if (blockElements[name] && currentNode.next) {\n text += '\\n';\n if (name === 'p') {\n text += '\\n';\n }\n }\n };\n html = filter$1(html, [//g]);\n walk(domParser.parse(html));\n return text;\n };\n const trimHtml = html => {\n const trimSpaces = (all, s1, s2) => {\n if (!s1 && !s2) {\n return ' ';\n }\n return nbsp;\n };\n html = filter$1(html, [\n /^[\\s\\S]*]*>\\s*|\\s*<\\/body[^>]*>[\\s\\S]*$/ig,\n /|/g,\n [\n /( ?)\\u00a0<\\/span>( ?)/g,\n trimSpaces\n ],\n /
    /g,\n /
    $/i\n ]);\n return html;\n };\n const createIdGenerator = prefix => {\n let count = 0;\n return () => {\n return prefix + count++;\n };\n };\n const getImageMimeType = ext => {\n const lowerExt = ext.toLowerCase();\n const mimeOverrides = {\n jpg: 'jpeg',\n jpe: 'jpeg',\n jfi: 'jpeg',\n jif: 'jpeg',\n jfif: 'jpeg',\n pjpeg: 'jpeg',\n pjp: 'jpeg',\n svg: 'svg+xml'\n };\n return Tools.hasOwn(mimeOverrides, lowerExt) ? 'image/' + mimeOverrides[lowerExt] : 'image/' + lowerExt;\n };\n\n const preProcess = (editor, html) => {\n const parser = DomParser({\n sanitize: shouldSanitizeXss(editor),\n sandbox_iframes: shouldSandboxIframes(editor)\n }, editor.schema);\n parser.addNodeFilter('meta', nodes => {\n Tools.each(nodes, node => {\n node.remove();\n });\n });\n const fragment = parser.parse(html, {\n forced_root_block: false,\n isRootContent: true\n });\n return HtmlSerializer({ validate: true }, editor.schema).serialize(fragment);\n };\n const processResult = (content, cancelled) => ({\n content,\n cancelled\n });\n const postProcessFilter = (editor, html, internal) => {\n const tempBody = editor.dom.create('div', { style: 'display:none' }, html);\n const postProcessArgs = firePastePostProcess(editor, tempBody, internal);\n return processResult(postProcessArgs.node.innerHTML, postProcessArgs.isDefaultPrevented());\n };\n const filterContent = (editor, content, internal) => {\n const preProcessArgs = firePastePreProcess(editor, content, internal);\n const filteredContent = preProcess(editor, preProcessArgs.content);\n if (editor.hasEventListeners('PastePostProcess') && !preProcessArgs.isDefaultPrevented()) {\n return postProcessFilter(editor, filteredContent, internal);\n } else {\n return processResult(filteredContent, preProcessArgs.isDefaultPrevented());\n }\n };\n const process = (editor, html, internal) => {\n return filterContent(editor, html, internal);\n };\n\n const pasteHtml$1 = (editor, html) => {\n editor.insertContent(html, {\n merge: shouldPasteMergeFormats(editor),\n paste: true\n });\n return true;\n };\n const isAbsoluteUrl = url => /^https?:\\/\\/[\\w\\-\\/+=.,!;:&%@^~(){}?#]+$/i.test(url);\n const isImageUrl = (editor, url) => {\n return isAbsoluteUrl(url) && exists(getAllowedImageFileTypes(editor), type => endsWith(url.toLowerCase(), `.${ type.toLowerCase() }`));\n };\n const createImage = (editor, url, pasteHtmlFn) => {\n editor.undoManager.extra(() => {\n pasteHtmlFn(editor, url);\n }, () => {\n editor.insertContent('');\n });\n return true;\n };\n const createLink = (editor, url, pasteHtmlFn) => {\n editor.undoManager.extra(() => {\n pasteHtmlFn(editor, url);\n }, () => {\n editor.execCommand('mceInsertLink', false, url);\n });\n return true;\n };\n const linkSelection = (editor, html, pasteHtmlFn) => !editor.selection.isCollapsed() && isAbsoluteUrl(html) ? createLink(editor, html, pasteHtmlFn) : false;\n const insertImage = (editor, html, pasteHtmlFn) => isImageUrl(editor, html) ? createImage(editor, html, pasteHtmlFn) : false;\n const smartInsertContent = (editor, html) => {\n Tools.each([\n linkSelection,\n insertImage,\n pasteHtml$1\n ], action => {\n return !action(editor, html, pasteHtml$1);\n });\n };\n const insertContent = (editor, html, pasteAsText) => {\n if (pasteAsText || !isSmartPasteEnabled(editor)) {\n pasteHtml$1(editor, html);\n } else {\n smartInsertContent(editor, html);\n }\n };\n\n const uniqueId = createIdGenerator('mceclip');\n const createPasteDataTransfer = html => {\n const dataTransfer = createDataTransfer();\n setHtmlData(dataTransfer, html);\n setReadOnlyMode(dataTransfer);\n return dataTransfer;\n };\n const doPaste = (editor, content, internal, pasteAsText, shouldSimulateInputEvent) => {\n const res = process(editor, content, internal);\n if (!res.cancelled) {\n const content = res.content;\n const doPasteAction = () => insertContent(editor, content, pasteAsText);\n if (shouldSimulateInputEvent) {\n const args = fireBeforeInputEvent(editor, 'insertFromPaste', { dataTransfer: createPasteDataTransfer(content) });\n if (!args.isDefaultPrevented()) {\n doPasteAction();\n fireInputEvent(editor, 'insertFromPaste');\n }\n } else {\n doPasteAction();\n }\n }\n };\n const pasteHtml = (editor, html, internalFlag, shouldSimulateInputEvent) => {\n const internal = internalFlag ? internalFlag : isMarked(html);\n doPaste(editor, unmark(html), internal, false, shouldSimulateInputEvent);\n };\n const pasteText = (editor, text, shouldSimulateInputEvent) => {\n const encodedText = editor.dom.encode(text).replace(/\\r\\n/g, '\\n');\n const normalizedText = normalize$4(encodedText, getPasteTabSpaces(editor));\n const html = toBlockElements(normalizedText, getForcedRootBlock(editor), getForcedRootBlockAttrs(editor));\n doPaste(editor, html, false, true, shouldSimulateInputEvent);\n };\n const getDataTransferItems = dataTransfer => {\n const items = {};\n if (dataTransfer && dataTransfer.types) {\n for (let i = 0; i < dataTransfer.types.length; i++) {\n const contentType = dataTransfer.types[i];\n try {\n items[contentType] = dataTransfer.getData(contentType);\n } catch (ex) {\n items[contentType] = '';\n }\n }\n }\n return items;\n };\n const hasContentType = (clipboardContent, mimeType) => mimeType in clipboardContent && clipboardContent[mimeType].length > 0;\n const hasHtmlOrText = content => hasContentType(content, 'text/html') || hasContentType(content, 'text/plain');\n const extractFilename = (editor, str) => {\n const m = str.match(/([\\s\\S]+?)(?:\\.[a-z0-9.]+)$/i);\n return isNonNullable(m) ? editor.dom.encode(m[1]) : undefined;\n };\n const createBlobInfo = (editor, blobCache, file, base64) => {\n const id = uniqueId();\n const useFileName = shouldReuseFileName(editor) && isNonNullable(file.name);\n const name = useFileName ? extractFilename(editor, file.name) : id;\n const filename = useFileName ? file.name : undefined;\n const blobInfo = blobCache.create(id, file, base64, name, filename);\n blobCache.add(blobInfo);\n return blobInfo;\n };\n const pasteImage = (editor, imageItem) => {\n parseDataUri(imageItem.uri).each(({data, type, base64Encoded}) => {\n const base64 = base64Encoded ? data : btoa(data);\n const file = imageItem.file;\n const blobCache = editor.editorUpload.blobCache;\n const existingBlobInfo = blobCache.getByData(base64, type);\n const blobInfo = existingBlobInfo !== null && existingBlobInfo !== void 0 ? existingBlobInfo : createBlobInfo(editor, blobCache, file, base64);\n pasteHtml(editor, ``, false, true);\n });\n };\n const isClipboardEvent = event => event.type === 'paste';\n const readFilesAsDataUris = items => Promise.all(map$3(items, file => {\n return blobToDataUri(file).then(uri => ({\n file,\n uri\n }));\n }));\n const isImage = editor => {\n const allowedExtensions = getAllowedImageFileTypes(editor);\n return file => startsWith(file.type, 'image/') && exists(allowedExtensions, extension => {\n return getImageMimeType(extension) === file.type;\n });\n };\n const getImagesFromDataTransfer = (editor, dataTransfer) => {\n const items = dataTransfer.items ? bind$3(from(dataTransfer.items), item => {\n return item.kind === 'file' ? [item.getAsFile()] : [];\n }) : [];\n const files = dataTransfer.files ? from(dataTransfer.files) : [];\n return filter$5(items.length > 0 ? items : files, isImage(editor));\n };\n const pasteImageData = (editor, e, rng) => {\n const dataTransfer = isClipboardEvent(e) ? e.clipboardData : e.dataTransfer;\n if (shouldPasteDataImages(editor) && dataTransfer) {\n const images = getImagesFromDataTransfer(editor, dataTransfer);\n if (images.length > 0) {\n e.preventDefault();\n readFilesAsDataUris(images).then(fileResults => {\n if (rng) {\n editor.selection.setRng(rng);\n }\n each$e(fileResults, result => {\n pasteImage(editor, result);\n });\n });\n return true;\n }\n }\n return false;\n };\n const isBrokenAndroidClipboardEvent = e => {\n var _a, _b;\n return Env.os.isAndroid() && ((_b = (_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length) === 0;\n };\n const isKeyboardPasteEvent = e => VK.metaKeyPressed(e) && e.keyCode === 86 || e.shiftKey && e.keyCode === 45;\n const insertClipboardContent = (editor, clipboardContent, html, plainTextMode, shouldSimulateInputEvent) => {\n let content = trimHtml(html);\n const isInternal = hasContentType(clipboardContent, internalHtmlMime()) || isMarked(html);\n const isPlainTextHtml = !isInternal && isPlainText(content);\n const isAbsoluteUrl$1 = isAbsoluteUrl(content);\n if (isDefaultPasteBinContent(content) || !content.length || isPlainTextHtml && !isAbsoluteUrl$1) {\n plainTextMode = true;\n }\n if (plainTextMode || isAbsoluteUrl$1) {\n if (hasContentType(clipboardContent, 'text/plain') && isPlainTextHtml) {\n content = clipboardContent['text/plain'];\n } else {\n content = innerText(content);\n }\n }\n if (isDefaultPasteBinContent(content)) {\n return;\n }\n if (plainTextMode) {\n pasteText(editor, content, shouldSimulateInputEvent);\n } else {\n pasteHtml(editor, content, isInternal, shouldSimulateInputEvent);\n }\n };\n const registerEventHandlers = (editor, pasteBin, pasteFormat) => {\n let keyboardPastePlainTextState;\n const getLastRng = () => pasteBin.getLastRng() || editor.selection.getRng();\n editor.on('keydown', e => {\n if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {\n keyboardPastePlainTextState = e.shiftKey && e.keyCode === 86;\n }\n });\n editor.on('paste', e => {\n if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) {\n return;\n }\n const plainTextMode = pasteFormat.get() === 'text' || keyboardPastePlainTextState;\n keyboardPastePlainTextState = false;\n const clipboardContent = getDataTransferItems(e.clipboardData);\n if (!hasHtmlOrText(clipboardContent) && pasteImageData(editor, e, getLastRng())) {\n return;\n }\n if (hasContentType(clipboardContent, 'text/html')) {\n e.preventDefault();\n insertClipboardContent(editor, clipboardContent, clipboardContent['text/html'], plainTextMode, true);\n } else if (hasContentType(clipboardContent, 'text/plain') && hasContentType(clipboardContent, 'text/uri-list')) {\n e.preventDefault();\n insertClipboardContent(editor, clipboardContent, clipboardContent['text/plain'], plainTextMode, true);\n } else {\n pasteBin.create();\n Delay.setEditorTimeout(editor, () => {\n const html = pasteBin.getHtml();\n pasteBin.remove();\n insertClipboardContent(editor, clipboardContent, html, plainTextMode, false);\n }, 0);\n }\n });\n };\n const registerDataImageFilter = editor => {\n const isWebKitFakeUrl = src => startsWith(src, 'webkit-fake-url');\n const isDataUri = src => startsWith(src, 'data:');\n const isPasteInsert = args => {\n var _a;\n return ((_a = args.data) === null || _a === void 0 ? void 0 : _a.paste) === true;\n };\n editor.parser.addNodeFilter('img', (nodes, name, args) => {\n if (!shouldPasteDataImages(editor) && isPasteInsert(args)) {\n for (const node of nodes) {\n const src = node.attr('src');\n if (isString(src) && !node.attr('data-mce-object') && src !== Env.transparentSrc) {\n if (isWebKitFakeUrl(src)) {\n node.remove();\n } else if (!shouldAllowHtmlDataUrls(editor) && isDataUri(src)) {\n node.remove();\n }\n }\n }\n }\n });\n };\n const registerEventsAndFilters = (editor, pasteBin, pasteFormat) => {\n registerEventHandlers(editor, pasteBin, pasteFormat);\n registerDataImageFilter(editor);\n };\n\n const togglePlainTextPaste = (editor, pasteFormat) => {\n if (pasteFormat.get() === 'text') {\n pasteFormat.set('html');\n firePastePlainTextToggle(editor, false);\n } else {\n pasteFormat.set('text');\n firePastePlainTextToggle(editor, true);\n }\n editor.focus();\n };\n const register$1 = (editor, pasteFormat) => {\n editor.addCommand('mceTogglePlainTextPaste', () => {\n togglePlainTextPaste(editor, pasteFormat);\n });\n editor.addCommand('mceInsertClipboardContent', (ui, value) => {\n if (value.html) {\n pasteHtml(editor, value.html, value.internal, false);\n }\n if (value.text) {\n pasteText(editor, value.text, false);\n }\n });\n };\n\n const setHtml5Clipboard = (clipboardData, html, text) => {\n if (clipboardData) {\n try {\n clipboardData.clearData();\n clipboardData.setData('text/html', html);\n clipboardData.setData('text/plain', text);\n clipboardData.setData(internalHtmlMime(), html);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n };\n const setClipboardData = (evt, data, fallback, done) => {\n if (setHtml5Clipboard(evt.clipboardData, data.html, data.text)) {\n evt.preventDefault();\n done();\n } else {\n fallback(data.html, done);\n }\n };\n const fallback = editor => (html, done) => {\n const {dom, selection} = editor;\n const outer = dom.create('div', {\n 'contenteditable': 'false',\n 'data-mce-bogus': 'all'\n });\n const inner = dom.create('div', { contenteditable: 'true' }, html);\n dom.setStyles(outer, {\n position: 'fixed',\n top: '0',\n left: '-3000px',\n width: '1000px',\n overflow: 'hidden'\n });\n outer.appendChild(inner);\n dom.add(editor.getBody(), outer);\n const range = selection.getRng();\n inner.focus();\n const offscreenRange = dom.createRng();\n offscreenRange.selectNodeContents(inner);\n selection.setRng(offscreenRange);\n Delay.setEditorTimeout(editor, () => {\n selection.setRng(range);\n dom.remove(outer);\n done();\n }, 0);\n };\n const getData = editor => ({\n html: mark(editor.selection.getContent({ contextual: true })),\n text: editor.selection.getContent({ format: 'text' })\n });\n const isTableSelection = editor => !!editor.dom.getParent(editor.selection.getStart(), 'td[data-mce-selected],th[data-mce-selected]', editor.getBody());\n const hasSelectedContent = editor => !editor.selection.isCollapsed() || isTableSelection(editor);\n const cut = editor => evt => {\n if (!evt.isDefaultPrevented() && hasSelectedContent(editor) && editor.selection.isEditable()) {\n setClipboardData(evt, getData(editor), fallback(editor), () => {\n if (Env.browser.isChromium() || Env.browser.isFirefox()) {\n const rng = editor.selection.getRng();\n Delay.setEditorTimeout(editor, () => {\n editor.selection.setRng(rng);\n editor.execCommand('Delete');\n }, 0);\n } else {\n editor.execCommand('Delete');\n }\n });\n }\n };\n const copy = editor => evt => {\n if (!evt.isDefaultPrevented() && hasSelectedContent(editor)) {\n setClipboardData(evt, getData(editor), fallback(editor), noop);\n }\n };\n const register = editor => {\n editor.on('cut', cut(editor));\n editor.on('copy', copy(editor));\n };\n\n const getCaretRangeFromEvent = (editor, e) => {\n var _a, _b;\n return RangeUtils.getCaretRangeFromPoint((_a = e.clientX) !== null && _a !== void 0 ? _a : 0, (_b = e.clientY) !== null && _b !== void 0 ? _b : 0, editor.getDoc());\n };\n const isPlainTextFileUrl = content => {\n const plainTextContent = content['text/plain'];\n return plainTextContent ? plainTextContent.indexOf('file://') === 0 : false;\n };\n const setFocusedRange = (editor, rng) => {\n editor.focus();\n if (rng) {\n editor.selection.setRng(rng);\n }\n };\n const hasImage = dataTransfer => exists(dataTransfer.files, file => /^image\\//.test(file.type));\n const needsCustomInternalDrop = (dom, schema, target, dropContent) => {\n const parentTransparent = dom.getParent(target, node => isTransparentBlock(schema, node));\n const inSummary = !isNull(dom.getParent(target, 'summary'));\n if (inSummary) {\n return true;\n } else if (parentTransparent && has$2(dropContent, 'text/html')) {\n const fragment = new DOMParser().parseFromString(dropContent['text/html'], 'text/html').body;\n return !isNull(fragment.querySelector(parentTransparent.nodeName.toLowerCase()));\n } else {\n return false;\n }\n };\n const setupSummaryDeleteByDragFix = editor => {\n editor.on('input', e => {\n const hasNoSummary = el => isNull(el.querySelector('summary'));\n if (e.inputType === 'deleteByDrag') {\n const brokenDetailElements = filter$5(editor.dom.select('details'), hasNoSummary);\n each$e(brokenDetailElements, details => {\n if (isBr$6(details.firstChild)) {\n details.firstChild.remove();\n }\n const summary = editor.dom.create('summary');\n summary.appendChild(createPaddingBr().dom);\n details.prepend(summary);\n });\n }\n });\n };\n const setup$a = (editor, draggingInternallyState) => {\n if (shouldPasteBlockDrop(editor)) {\n editor.on('dragend dragover draggesture dragdrop drop drag', e => {\n e.preventDefault();\n e.stopPropagation();\n });\n }\n if (!shouldPasteDataImages(editor)) {\n editor.on('drop', e => {\n const dataTransfer = e.dataTransfer;\n if (dataTransfer && hasImage(dataTransfer)) {\n e.preventDefault();\n }\n });\n }\n editor.on('drop', e => {\n if (e.isDefaultPrevented()) {\n return;\n }\n const rng = getCaretRangeFromEvent(editor, e);\n if (isNullable(rng)) {\n return;\n }\n const dropContent = getDataTransferItems(e.dataTransfer);\n const internal = hasContentType(dropContent, internalHtmlMime());\n if ((!hasHtmlOrText(dropContent) || isPlainTextFileUrl(dropContent)) && pasteImageData(editor, e, rng)) {\n return;\n }\n const internalContent = dropContent[internalHtmlMime()];\n const content = internalContent || dropContent['text/html'] || dropContent['text/plain'];\n const needsInternalDrop = needsCustomInternalDrop(editor.dom, editor.schema, rng.startContainer, dropContent);\n const isInternalDrop = draggingInternallyState.get();\n if (isInternalDrop && !needsInternalDrop) {\n return;\n }\n if (content) {\n e.preventDefault();\n Delay.setEditorTimeout(editor, () => {\n editor.undoManager.transact(() => {\n if (internalContent || isInternalDrop && needsInternalDrop) {\n editor.execCommand('Delete');\n }\n setFocusedRange(editor, rng);\n const trimmedContent = trimHtml(content);\n if (dropContent['text/html']) {\n pasteHtml(editor, trimmedContent, internal, true);\n } else {\n pasteText(editor, trimmedContent, true);\n }\n });\n });\n }\n });\n editor.on('dragstart', _e => {\n draggingInternallyState.set(true);\n });\n editor.on('dragover dragend', e => {\n if (shouldPasteDataImages(editor) && !draggingInternallyState.get()) {\n e.preventDefault();\n setFocusedRange(editor, getCaretRangeFromEvent(editor, e));\n }\n if (e.type === 'dragend') {\n draggingInternallyState.set(false);\n }\n });\n setupSummaryDeleteByDragFix(editor);\n };\n\n const setup$9 = editor => {\n const processEvent = f => e => {\n f(editor, e);\n };\n const preProcess = getPastePreProcess(editor);\n if (isFunction(preProcess)) {\n editor.on('PastePreProcess', processEvent(preProcess));\n }\n const postProcess = getPastePostProcess(editor);\n if (isFunction(postProcess)) {\n editor.on('PastePostProcess', processEvent(postProcess));\n }\n };\n\n const addPreProcessFilter = (editor, filterFunc) => {\n editor.on('PastePreProcess', e => {\n e.content = filterFunc(editor, e.content, e.internal);\n });\n };\n const rgbRegExp = /rgb\\s*\\(\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*\\)/gi;\n const rgbToHex = value => Tools.trim(value).replace(rgbRegExp, rgbaToHexString).toLowerCase();\n const removeWebKitStyles = (editor, content, internal) => {\n const webKitStylesOption = getPasteWebkitStyles(editor);\n if (internal || webKitStylesOption === 'all' || !shouldPasteRemoveWebKitStyles(editor)) {\n return content;\n }\n const webKitStyles = webKitStylesOption ? webKitStylesOption.split(/[, ]/) : [];\n if (webKitStyles && webKitStylesOption !== 'none') {\n const dom = editor.dom, node = editor.selection.getNode();\n content = content.replace(/(<[^>]+) style=\"([^\"]*)\"([^>]*>)/gi, (all, before, value, after) => {\n const inputStyles = dom.parseStyle(dom.decode(value));\n const outputStyles = {};\n for (let i = 0; i < webKitStyles.length; i++) {\n const inputValue = inputStyles[webKitStyles[i]];\n let compareInput = inputValue;\n let currentValue = dom.getStyle(node, webKitStyles[i], true);\n if (/color/.test(webKitStyles[i])) {\n compareInput = rgbToHex(compareInput);\n currentValue = rgbToHex(currentValue);\n }\n if (currentValue !== compareInput) {\n outputStyles[webKitStyles[i]] = inputValue;\n }\n }\n const outputStyle = dom.serializeStyle(outputStyles, 'span');\n if (outputStyle) {\n return before + ' style=\"' + outputStyle + '\"' + after;\n }\n return before + after;\n });\n } else {\n content = content.replace(/(<[^>]+) style=\"([^\"]*)\"([^>]*>)/gi, '$1$3');\n }\n content = content.replace(/(<[^>]+) data-mce-style=\"([^\"]+)\"([^>]*>)/gi, (all, before, value, after) => {\n return before + ' style=\"' + value + '\"' + after;\n });\n return content;\n };\n const setup$8 = editor => {\n if (Env.browser.isChromium() || Env.browser.isSafari()) {\n addPreProcessFilter(editor, removeWebKitStyles);\n }\n };\n\n const setup$7 = editor => {\n const draggingInternallyState = Cell(false);\n const pasteFormat = Cell(isPasteAsTextEnabled(editor) ? 'text' : 'html');\n const pasteBin = PasteBin(editor);\n setup$8(editor);\n register$1(editor, pasteFormat);\n setup$9(editor);\n editor.on('PreInit', () => {\n register(editor);\n setup$a(editor, draggingInternallyState);\n registerEventsAndFilters(editor, pasteBin, pasteFormat);\n });\n };\n\n const preventSummaryToggle = editor => {\n editor.on('click', e => {\n if (editor.dom.getParent(e.target, 'details')) {\n e.preventDefault();\n }\n });\n };\n const filterDetails = editor => {\n editor.parser.addNodeFilter('details', elms => {\n const initialStateOption = getDetailsInitialState(editor);\n each$e(elms, details => {\n if (initialStateOption === 'expanded') {\n details.attr('open', 'open');\n } else if (initialStateOption === 'collapsed') {\n details.attr('open', null);\n }\n });\n });\n editor.serializer.addNodeFilter('details', elms => {\n const serializedStateOption = getDetailsSerializedState(editor);\n each$e(elms, details => {\n if (serializedStateOption === 'expanded') {\n details.attr('open', 'open');\n } else if (serializedStateOption === 'collapsed') {\n details.attr('open', null);\n }\n });\n });\n };\n const setup$6 = editor => {\n preventSummaryToggle(editor);\n filterDetails(editor);\n };\n\n const isBr = isBr$6;\n const isText = isText$a;\n const isContentEditableFalse$2 = elm => isContentEditableFalse$b(elm.dom);\n const isContentEditableTrue = elm => isContentEditableTrue$3(elm.dom);\n const isRoot = rootNode => elm => eq(SugarElement.fromDom(rootNode), elm);\n const getClosestScope = (node, rootNode, schema) => closest$4(SugarElement.fromDom(node), elm => isContentEditableTrue(elm) || schema.isBlock(name(elm)), isRoot(rootNode)).getOr(SugarElement.fromDom(rootNode)).dom;\n const getClosestCef = (node, rootNode) => closest$4(SugarElement.fromDom(node), isContentEditableFalse$2, isRoot(rootNode));\n const findEdgeCaretCandidate = (startNode, scope, forward) => {\n const walker = new DomTreeWalker(startNode, scope);\n const next = forward ? walker.next.bind(walker) : walker.prev.bind(walker);\n let result = startNode;\n for (let current = forward ? startNode : next(); current && !isBr(current); current = next()) {\n if (isCaretCandidate$3(current)) {\n result = current;\n }\n }\n return result;\n };\n const findClosestBlockRange = (startRng, rootNode, schema) => {\n const startPos = CaretPosition.fromRangeStart(startRng);\n const clickNode = startPos.getNode();\n const scope = getClosestScope(clickNode, rootNode, schema);\n const startNode = findEdgeCaretCandidate(clickNode, scope, false);\n const endNode = findEdgeCaretCandidate(clickNode, scope, true);\n const rng = document.createRange();\n getClosestCef(startNode, scope).fold(() => {\n if (isText(startNode)) {\n rng.setStart(startNode, 0);\n } else {\n rng.setStartBefore(startNode);\n }\n }, cef => rng.setStartBefore(cef.dom));\n getClosestCef(endNode, scope).fold(() => {\n if (isText(endNode)) {\n rng.setEnd(endNode, endNode.data.length);\n } else {\n rng.setEndAfter(endNode);\n }\n }, cef => rng.setEndAfter(cef.dom));\n return rng;\n };\n const onTripleClickSelect = editor => {\n const rng = findClosestBlockRange(editor.selection.getRng(), editor.getBody(), editor.schema);\n editor.selection.setRng(normalize(rng));\n };\n const setup$5 = editor => {\n editor.on('mousedown', e => {\n if (e.detail >= 3) {\n e.preventDefault();\n onTripleClickSelect(editor);\n }\n });\n };\n\n var FakeCaretPosition;\n (function (FakeCaretPosition) {\n FakeCaretPosition['Before'] = 'before';\n FakeCaretPosition['After'] = 'after';\n }(FakeCaretPosition || (FakeCaretPosition = {})));\n const distanceToRectLeft = (clientRect, clientX) => Math.abs(clientRect.left - clientX);\n const distanceToRectRight = (clientRect, clientX) => Math.abs(clientRect.right - clientX);\n const isInsideY = (clientY, clientRect) => clientY >= clientRect.top && clientY <= clientRect.bottom;\n const collidesY = (r1, r2) => r1.top < r2.bottom && r1.bottom > r2.top;\n const isOverlapping = (r1, r2) => {\n const overlap = overlapY(r1, r2) / Math.min(r1.height, r2.height);\n return collidesY(r1, r2) && overlap > 0.5;\n };\n const splitRectsPerAxis = (rects, y) => {\n const intersectingRects = filter$5(rects, rect => isInsideY(y, rect));\n return boundingClientRectFromRects(intersectingRects).fold(() => [\n [],\n rects\n ], boundingRect => {\n const {\n pass: horizontal,\n fail: vertical\n } = partition$2(rects, rect => isOverlapping(rect, boundingRect));\n return [\n horizontal,\n vertical\n ];\n });\n };\n const clientInfo = (rect, clientX) => {\n return {\n node: rect.node,\n position: distanceToRectLeft(rect, clientX) < distanceToRectRight(rect, clientX) ? FakeCaretPosition.Before : FakeCaretPosition.After\n };\n };\n const horizontalDistance = (rect, x, _y) => x > rect.left && x < rect.right ? 0 : Math.min(Math.abs(rect.left - x), Math.abs(rect.right - x));\n const closestChildCaretCandidateNodeRect = (children, clientX, clientY, findCloserTextNode) => {\n const caretCandidateRect = rect => {\n if (isCaretCandidate$3(rect.node)) {\n return Optional.some(rect);\n } else if (isElement$6(rect.node)) {\n return closestChildCaretCandidateNodeRect(from(rect.node.childNodes), clientX, clientY, false);\n } else {\n return Optional.none();\n }\n };\n const tryFindSecondBestTextNode = (closest, sndClosest, distance) => {\n return caretCandidateRect(sndClosest).filter(rect => {\n const deltaDistance = Math.abs(distance(closest, clientX, clientY) - distance(rect, clientX, clientY));\n return deltaDistance < 2 && isText$a(rect.node);\n });\n };\n const findClosestCaretCandidateNodeRect = (rects, distance) => {\n const sortedRects = sort(rects, (r1, r2) => distance(r1, clientX, clientY) - distance(r2, clientX, clientY));\n return findMap(sortedRects, caretCandidateRect).map(closest => {\n if (findCloserTextNode && !isText$a(closest.node) && sortedRects.length > 1) {\n return tryFindSecondBestTextNode(closest, sortedRects[1], distance).getOr(closest);\n } else {\n return closest;\n }\n });\n };\n const [horizontalRects, verticalRects] = splitRectsPerAxis(getClientRects(children), clientY);\n const {\n pass: above,\n fail: below\n } = partition$2(verticalRects, rect => rect.top < clientY);\n return findClosestCaretCandidateNodeRect(horizontalRects, horizontalDistance).orThunk(() => findClosestCaretCandidateNodeRect(below, distanceToRectEdgeFromXY)).orThunk(() => findClosestCaretCandidateNodeRect(above, distanceToRectEdgeFromXY));\n };\n const traverseUp = (rootElm, scope, clientX, clientY) => {\n const helper = (scope, prevScope) => {\n const isDragGhostContainer = node => isElement$6(node) && node.classList.contains('mce-drag-container');\n const childNodesWithoutGhost = filter$5(scope.dom.childNodes, not(isDragGhostContainer));\n return prevScope.fold(() => closestChildCaretCandidateNodeRect(childNodesWithoutGhost, clientX, clientY, true), prevScope => {\n const uncheckedChildren = filter$5(childNodesWithoutGhost, node => node !== prevScope.dom);\n return closestChildCaretCandidateNodeRect(uncheckedChildren, clientX, clientY, true);\n }).orThunk(() => {\n const parent = eq(scope, rootElm) ? Optional.none() : parentElement(scope);\n return parent.bind(newScope => helper(newScope, Optional.some(scope)));\n });\n };\n return helper(scope, Optional.none());\n };\n const closestCaretCandidateNodeRect = (root, clientX, clientY) => {\n const rootElm = SugarElement.fromDom(root);\n const ownerDoc = documentOrOwner(rootElm);\n const elementAtPoint = SugarElement.fromPoint(ownerDoc, clientX, clientY).filter(elm => contains(rootElm, elm));\n const element = elementAtPoint.getOr(rootElm);\n return traverseUp(rootElm, element, clientX, clientY);\n };\n const closestFakeCaretCandidate = (root, clientX, clientY) => closestCaretCandidateNodeRect(root, clientX, clientY).filter(rect => isFakeCaretTarget(rect.node)).map(rect => clientInfo(rect, clientX));\n\n const getAbsolutePosition = elm => {\n var _a, _b;\n const clientRect = elm.getBoundingClientRect();\n const doc = elm.ownerDocument;\n const docElem = doc.documentElement;\n const win = doc.defaultView;\n return {\n top: clientRect.top + ((_a = win === null || win === void 0 ? void 0 : win.scrollY) !== null && _a !== void 0 ? _a : 0) - docElem.clientTop,\n left: clientRect.left + ((_b = win === null || win === void 0 ? void 0 : win.scrollX) !== null && _b !== void 0 ? _b : 0) - docElem.clientLeft\n };\n };\n const getBodyPosition = editor => editor.inline ? getAbsolutePosition(editor.getBody()) : {\n left: 0,\n top: 0\n };\n const getScrollPosition = editor => {\n const body = editor.getBody();\n return editor.inline ? {\n left: body.scrollLeft,\n top: body.scrollTop\n } : {\n left: 0,\n top: 0\n };\n };\n const getBodyScroll = editor => {\n const body = editor.getBody(), docElm = editor.getDoc().documentElement;\n const inlineScroll = {\n left: body.scrollLeft,\n top: body.scrollTop\n };\n const iframeScroll = {\n left: body.scrollLeft || docElm.scrollLeft,\n top: body.scrollTop || docElm.scrollTop\n };\n return editor.inline ? inlineScroll : iframeScroll;\n };\n const getMousePosition = (editor, event) => {\n if (event.target.ownerDocument !== editor.getDoc()) {\n const iframePosition = getAbsolutePosition(editor.getContentAreaContainer());\n const scrollPosition = getBodyScroll(editor);\n return {\n left: event.pageX - iframePosition.left + scrollPosition.left,\n top: event.pageY - iframePosition.top + scrollPosition.top\n };\n }\n return {\n left: event.pageX,\n top: event.pageY\n };\n };\n const calculatePosition = (bodyPosition, scrollPosition, mousePosition) => ({\n pageX: mousePosition.left - bodyPosition.left + scrollPosition.left,\n pageY: mousePosition.top - bodyPosition.top + scrollPosition.top\n });\n const calc = (editor, event) => calculatePosition(getBodyPosition(editor), getScrollPosition(editor), getMousePosition(editor, event));\n\n const getTargetProps = target => ({\n target,\n srcElement: target\n });\n const makeDndEventFromMouseEvent = (type, mouseEvent, target, dataTransfer) => ({\n ...mouseEvent,\n dataTransfer,\n type,\n ...getTargetProps(target)\n });\n const makeDndEvent = (type, target, dataTransfer) => {\n const fail = die('Function not supported on simulated event.');\n const event = {\n bubbles: true,\n cancelBubble: false,\n cancelable: true,\n composed: false,\n currentTarget: null,\n defaultPrevented: false,\n eventPhase: 0,\n isTrusted: true,\n returnValue: false,\n timeStamp: 0,\n type,\n composedPath: fail,\n initEvent: fail,\n preventDefault: noop,\n stopImmediatePropagation: noop,\n stopPropagation: noop,\n AT_TARGET: window.Event.AT_TARGET,\n BUBBLING_PHASE: window.Event.BUBBLING_PHASE,\n CAPTURING_PHASE: window.Event.CAPTURING_PHASE,\n NONE: window.Event.NONE,\n altKey: false,\n button: 0,\n buttons: 0,\n clientX: 0,\n clientY: 0,\n ctrlKey: false,\n metaKey: false,\n movementX: 0,\n movementY: 0,\n offsetX: 0,\n offsetY: 0,\n pageX: 0,\n pageY: 0,\n relatedTarget: null,\n screenX: 0,\n screenY: 0,\n shiftKey: false,\n x: 0,\n y: 0,\n detail: 0,\n view: null,\n which: 0,\n initUIEvent: fail,\n initMouseEvent: fail,\n getModifierState: fail,\n dataTransfer,\n ...getTargetProps(target)\n };\n return event;\n };\n const makeDataTransferCopyForDragEvent = (dataTransfer, eventType) => {\n const copy = cloneDataTransfer(dataTransfer);\n if (eventType === 'dragstart') {\n setDragstartEvent(copy);\n setReadWriteMode(copy);\n } else if (eventType === 'drop') {\n setDropEvent(copy);\n setReadOnlyMode(copy);\n } else {\n setDragendEvent(copy);\n setProtectedMode(copy);\n }\n return copy;\n };\n const makeDragEvent = (type, target, dataTransfer, mouseEvent) => {\n const dataTransferForDispatch = makeDataTransferCopyForDragEvent(dataTransfer, type);\n return isUndefined(mouseEvent) ? makeDndEvent(type, target, dataTransferForDispatch) : makeDndEventFromMouseEvent(type, mouseEvent, target, dataTransferForDispatch);\n };\n\n const scrollPixelsPerInterval = 32;\n const scrollIntervalValue = 100;\n const mouseRangeToTriggerScrollInsideEditor = 8;\n const mouseRangeToTriggerScrollOutsideEditor = 16;\n const isContentEditableFalse$1 = isContentEditableFalse$b;\n const isContentEditable = or(isContentEditableFalse$1, isContentEditableTrue$3);\n const isDraggable = (dom, rootElm, elm) => isContentEditableFalse$1(elm) && elm !== rootElm && dom.isEditable(elm.parentElement);\n const isValidDropTarget = (editor, targetElement, dragElement) => {\n if (isNullable(targetElement)) {\n return false;\n } else if (targetElement === dragElement || editor.dom.isChildOf(targetElement, dragElement)) {\n return false;\n } else {\n return editor.dom.isEditable(targetElement);\n }\n };\n const createGhost = (editor, elm, width, height) => {\n const dom = editor.dom;\n const clonedElm = elm.cloneNode(true);\n dom.setStyles(clonedElm, {\n width,\n height\n });\n dom.setAttrib(clonedElm, 'data-mce-selected', null);\n const ghostElm = dom.create('div', {\n 'class': 'mce-drag-container',\n 'data-mce-bogus': 'all',\n 'unselectable': 'on',\n 'contenteditable': 'false'\n });\n dom.setStyles(ghostElm, {\n position: 'absolute',\n opacity: 0.5,\n overflow: 'hidden',\n border: 0,\n padding: 0,\n margin: 0,\n width,\n height\n });\n dom.setStyles(clonedElm, {\n margin: 0,\n boxSizing: 'border-box'\n });\n ghostElm.appendChild(clonedElm);\n return ghostElm;\n };\n const appendGhostToBody = (ghostElm, bodyElm) => {\n if (ghostElm.parentNode !== bodyElm) {\n bodyElm.appendChild(ghostElm);\n }\n };\n const scrollEditor = (direction, amount) => win => () => {\n const current = direction === 'left' ? win.scrollX : win.scrollY;\n win.scroll({\n [direction]: current + amount,\n behavior: 'smooth'\n });\n };\n const scrollLeft = scrollEditor('left', -scrollPixelsPerInterval);\n const scrollRight = scrollEditor('left', scrollPixelsPerInterval);\n const scrollUp = scrollEditor('top', -scrollPixelsPerInterval);\n const scrollDown = scrollEditor('top', scrollPixelsPerInterval);\n const moveGhost = (ghostElm, position, width, height, maxX, maxY, mouseY, mouseX, contentAreaContainer, win, state, mouseEventOriginatedFromWithinTheEditor) => {\n let overflowX = 0, overflowY = 0;\n ghostElm.style.left = position.pageX + 'px';\n ghostElm.style.top = position.pageY + 'px';\n if (position.pageX + width > maxX) {\n overflowX = position.pageX + width - maxX;\n }\n if (position.pageY + height > maxY) {\n overflowY = position.pageY + height - maxY;\n }\n ghostElm.style.width = width - overflowX + 'px';\n ghostElm.style.height = height - overflowY + 'px';\n const clientHeight = contentAreaContainer.clientHeight;\n const clientWidth = contentAreaContainer.clientWidth;\n const outerMouseY = mouseY + contentAreaContainer.getBoundingClientRect().top;\n const outerMouseX = mouseX + contentAreaContainer.getBoundingClientRect().left;\n state.on(state => {\n state.intervalId.clear();\n if (state.dragging && mouseEventOriginatedFromWithinTheEditor) {\n if (mouseY + mouseRangeToTriggerScrollInsideEditor >= clientHeight) {\n state.intervalId.set(scrollDown(win));\n } else if (mouseY - mouseRangeToTriggerScrollInsideEditor <= 0) {\n state.intervalId.set(scrollUp(win));\n } else if (mouseX + mouseRangeToTriggerScrollInsideEditor >= clientWidth) {\n state.intervalId.set(scrollRight(win));\n } else if (mouseX - mouseRangeToTriggerScrollInsideEditor <= 0) {\n state.intervalId.set(scrollLeft(win));\n } else if (outerMouseY + mouseRangeToTriggerScrollOutsideEditor >= window.innerHeight) {\n state.intervalId.set(scrollDown(window));\n } else if (outerMouseY - mouseRangeToTriggerScrollOutsideEditor <= 0) {\n state.intervalId.set(scrollUp(window));\n } else if (outerMouseX + mouseRangeToTriggerScrollOutsideEditor >= window.innerWidth) {\n state.intervalId.set(scrollRight(window));\n } else if (outerMouseX - mouseRangeToTriggerScrollOutsideEditor <= 0) {\n state.intervalId.set(scrollLeft(window));\n }\n }\n });\n };\n const removeElement = elm => {\n if (elm && elm.parentNode) {\n elm.parentNode.removeChild(elm);\n }\n };\n const removeElementWithPadding = (dom, elm) => {\n const parentBlock = dom.getParent(elm.parentNode, dom.isBlock);\n removeElement(elm);\n if (parentBlock && parentBlock !== dom.getRoot() && dom.isEmpty(parentBlock)) {\n fillWithPaddingBr(SugarElement.fromDom(parentBlock));\n }\n };\n const isLeftMouseButtonPressed = e => e.button === 0;\n const applyRelPos = (state, position) => ({\n pageX: position.pageX - state.relX,\n pageY: position.pageY + 5\n });\n const start = (state, editor) => e => {\n if (isLeftMouseButtonPressed(e)) {\n const ceElm = find$2(editor.dom.getParents(e.target), isContentEditable).getOr(null);\n if (isNonNullable(ceElm) && isDraggable(editor.dom, editor.getBody(), ceElm)) {\n const elmPos = editor.dom.getPos(ceElm);\n const bodyElm = editor.getBody();\n const docElm = editor.getDoc().documentElement;\n state.set({\n element: ceElm,\n dataTransfer: createDataTransfer(),\n dragging: false,\n screenX: e.screenX,\n screenY: e.screenY,\n maxX: (editor.inline ? bodyElm.scrollWidth : docElm.offsetWidth) - 2,\n maxY: (editor.inline ? bodyElm.scrollHeight : docElm.offsetHeight) - 2,\n relX: e.pageX - elmPos.x,\n relY: e.pageY - elmPos.y,\n width: ceElm.offsetWidth,\n height: ceElm.offsetHeight,\n ghost: createGhost(editor, ceElm, ceElm.offsetWidth, ceElm.offsetHeight),\n intervalId: repeatable(scrollIntervalValue)\n });\n }\n }\n };\n const placeCaretAt = (editor, clientX, clientY) => {\n editor._selectionOverrides.hideFakeCaret();\n closestFakeCaretCandidate(editor.getBody(), clientX, clientY).fold(() => editor.selection.placeCaretAt(clientX, clientY), caretInfo => {\n const range = editor._selectionOverrides.showCaret(1, caretInfo.node, caretInfo.position === FakeCaretPosition.Before, false);\n if (range) {\n editor.selection.setRng(range);\n } else {\n editor.selection.placeCaretAt(clientX, clientY);\n }\n });\n };\n const dispatchDragEvent = (editor, type, target, dataTransfer, mouseEvent) => {\n if (type === 'dragstart') {\n setHtmlData(dataTransfer, editor.dom.getOuterHTML(target));\n }\n const event = makeDragEvent(type, target, dataTransfer, mouseEvent);\n const args = editor.dispatch(type, event);\n return args;\n };\n const move = (state, editor) => {\n const throttledPlaceCaretAt = first$1((clientX, clientY) => placeCaretAt(editor, clientX, clientY), 0);\n editor.on('remove', throttledPlaceCaretAt.cancel);\n const state_ = state;\n return e => state.on(state => {\n const movement = Math.max(Math.abs(e.screenX - state.screenX), Math.abs(e.screenY - state.screenY));\n if (!state.dragging && movement > 10) {\n const args = dispatchDragEvent(editor, 'dragstart', state.element, state.dataTransfer, e);\n if (isNonNullable(args.dataTransfer)) {\n state.dataTransfer = args.dataTransfer;\n }\n if (args.isDefaultPrevented()) {\n return;\n }\n state.dragging = true;\n editor.focus();\n }\n if (state.dragging) {\n const mouseEventOriginatedFromWithinTheEditor = e.currentTarget === editor.getDoc().documentElement;\n const targetPos = applyRelPos(state, calc(editor, e));\n appendGhostToBody(state.ghost, editor.getBody());\n moveGhost(state.ghost, targetPos, state.width, state.height, state.maxX, state.maxY, e.clientY, e.clientX, editor.getContentAreaContainer(), editor.getWin(), state_, mouseEventOriginatedFromWithinTheEditor);\n throttledPlaceCaretAt.throttle(e.clientX, e.clientY);\n }\n });\n };\n const getRawTarget = selection => {\n const sel = selection.getSel();\n if (isNonNullable(sel)) {\n const rng = sel.getRangeAt(0);\n const startContainer = rng.startContainer;\n return isText$a(startContainer) ? startContainer.parentNode : startContainer;\n } else {\n return null;\n }\n };\n const drop = (state, editor) => e => {\n state.on(state => {\n var _a;\n state.intervalId.clear();\n if (state.dragging) {\n if (isValidDropTarget(editor, getRawTarget(editor.selection), state.element)) {\n const dropTarget = (_a = editor.getDoc().elementFromPoint(e.clientX, e.clientY)) !== null && _a !== void 0 ? _a : editor.getBody();\n const args = dispatchDragEvent(editor, 'drop', dropTarget, state.dataTransfer, e);\n if (!args.isDefaultPrevented()) {\n editor.undoManager.transact(() => {\n removeElementWithPadding(editor.dom, state.element);\n getHtmlData(state.dataTransfer).each(content => editor.insertContent(content));\n editor._selectionOverrides.hideFakeCaret();\n });\n }\n }\n dispatchDragEvent(editor, 'dragend', editor.getBody(), state.dataTransfer, e);\n }\n });\n removeDragState(state);\n };\n const stopDragging = (state, editor, e) => {\n state.on(state => {\n state.intervalId.clear();\n if (state.dragging) {\n e.fold(() => dispatchDragEvent(editor, 'dragend', state.element, state.dataTransfer), mouseEvent => dispatchDragEvent(editor, 'dragend', state.element, state.dataTransfer, mouseEvent));\n }\n });\n removeDragState(state);\n };\n const stop = (state, editor) => e => stopDragging(state, editor, Optional.some(e));\n const removeDragState = state => {\n state.on(state => {\n state.intervalId.clear();\n removeElement(state.ghost);\n });\n state.clear();\n };\n const bindFakeDragEvents = editor => {\n const state = value$2();\n const pageDom = DOMUtils.DOM;\n const rootDocument = document;\n const dragStartHandler = start(state, editor);\n const dragHandler = move(state, editor);\n const dropHandler = drop(state, editor);\n const dragEndHandler = stop(state, editor);\n editor.on('mousedown', dragStartHandler);\n editor.on('mousemove', dragHandler);\n editor.on('mouseup', dropHandler);\n pageDom.bind(rootDocument, 'mousemove', dragHandler);\n pageDom.bind(rootDocument, 'mouseup', dragEndHandler);\n editor.on('remove', () => {\n pageDom.unbind(rootDocument, 'mousemove', dragHandler);\n pageDom.unbind(rootDocument, 'mouseup', dragEndHandler);\n });\n editor.on('keydown', e => {\n if (e.keyCode === VK.ESC) {\n stopDragging(state, editor, Optional.none());\n }\n });\n };\n const blockUnsupportedFileDrop = editor => {\n const preventFileDrop = e => {\n if (!e.isDefaultPrevented()) {\n const dataTransfer = e.dataTransfer;\n if (dataTransfer && (contains$2(dataTransfer.types, 'Files') || dataTransfer.files.length > 0)) {\n e.preventDefault();\n if (e.type === 'drop') {\n displayError(editor, 'Dropped file type is not supported');\n }\n }\n }\n };\n const preventFileDropIfUIElement = e => {\n if (isUIElement(editor, e.target)) {\n preventFileDrop(e);\n }\n };\n const setup = () => {\n const pageDom = DOMUtils.DOM;\n const dom = editor.dom;\n const doc = document;\n const editorRoot = editor.inline ? editor.getBody() : editor.getDoc();\n const eventNames = [\n 'drop',\n 'dragover'\n ];\n each$e(eventNames, name => {\n pageDom.bind(doc, name, preventFileDropIfUIElement);\n dom.bind(editorRoot, name, preventFileDrop);\n });\n editor.on('remove', () => {\n each$e(eventNames, name => {\n pageDom.unbind(doc, name, preventFileDropIfUIElement);\n dom.unbind(editorRoot, name, preventFileDrop);\n });\n });\n };\n editor.on('init', () => {\n Delay.setEditorTimeout(editor, setup, 0);\n });\n };\n const init$2 = editor => {\n bindFakeDragEvents(editor);\n if (shouldBlockUnsupportedDrop(editor)) {\n blockUnsupportedFileDrop(editor);\n }\n };\n\n const setup$4 = editor => {\n const renderFocusCaret = first$1(() => {\n if (!editor.removed && editor.getBody().contains(document.activeElement)) {\n const rng = editor.selection.getRng();\n if (rng.collapsed) {\n const caretRange = renderRangeCaret(editor, rng, false);\n editor.selection.setRng(caretRange);\n }\n }\n }, 0);\n editor.on('focus', () => {\n renderFocusCaret.throttle();\n });\n editor.on('blur', () => {\n renderFocusCaret.cancel();\n });\n };\n\n const setup$3 = editor => {\n editor.on('init', () => {\n editor.on('focusin', e => {\n const target = e.target;\n if (isMedia$2(target)) {\n const ceRoot = getContentEditableRoot$1(editor.getBody(), target);\n const node = isContentEditableFalse$b(ceRoot) ? ceRoot : target;\n if (editor.selection.getNode() !== node) {\n selectNode(editor, node).each(rng => editor.selection.setRng(rng));\n }\n }\n });\n });\n };\n\n const isContentEditableFalse = isContentEditableFalse$b;\n const getContentEditableRoot = (editor, node) => getContentEditableRoot$1(editor.getBody(), node);\n const SelectionOverrides = editor => {\n const selection = editor.selection, dom = editor.dom;\n const rootNode = editor.getBody();\n const fakeCaret = FakeCaret(editor, rootNode, dom.isBlock, () => hasFocus(editor));\n const realSelectionId = 'sel-' + dom.uniqueId();\n const elementSelectionAttr = 'data-mce-selected';\n let selectedElement;\n const isFakeSelectionElement = node => isNonNullable(node) && dom.hasClass(node, 'mce-offscreen-selection');\n const isFakeSelectionTargetElement = node => node !== rootNode && (isContentEditableFalse(node) || isMedia$2(node)) && dom.isChildOf(node, rootNode) && dom.isEditable(node.parentNode);\n const setRange = range => {\n if (range) {\n selection.setRng(range);\n }\n };\n const showCaret = (direction, node, before, scrollIntoView = true) => {\n const e = editor.dispatch('ShowCaret', {\n target: node,\n direction,\n before\n });\n if (e.isDefaultPrevented()) {\n return null;\n }\n if (scrollIntoView) {\n selection.scrollIntoView(node, direction === -1);\n }\n return fakeCaret.show(before, node);\n };\n const showBlockCaretContainer = blockCaretContainer => {\n if (blockCaretContainer.hasAttribute('data-mce-caret')) {\n showCaretContainerBlock(blockCaretContainer);\n selection.scrollIntoView(blockCaretContainer);\n }\n };\n const registerEvents = () => {\n editor.on('click', e => {\n if (!dom.isEditable(e.target)) {\n e.preventDefault();\n editor.focus();\n }\n });\n editor.on('blur NewBlock', removeElementSelection);\n editor.on('ResizeWindow FullscreenStateChanged', fakeCaret.reposition);\n editor.on('tap', e => {\n const targetElm = e.target;\n const contentEditableRoot = getContentEditableRoot(editor, targetElm);\n if (isContentEditableFalse(contentEditableRoot)) {\n e.preventDefault();\n selectNode(editor, contentEditableRoot).each(setElementSelection);\n } else if (isFakeSelectionTargetElement(targetElm)) {\n selectNode(editor, targetElm).each(setElementSelection);\n }\n }, true);\n editor.on('mousedown', e => {\n const targetElm = e.target;\n if (targetElm !== rootNode && targetElm.nodeName !== 'HTML' && !dom.isChildOf(targetElm, rootNode)) {\n return;\n }\n if (!isXYInContentArea(editor, e.clientX, e.clientY)) {\n return;\n }\n removeElementSelection();\n hideFakeCaret();\n const closestContentEditable = getContentEditableRoot(editor, targetElm);\n if (isContentEditableFalse(closestContentEditable)) {\n e.preventDefault();\n selectNode(editor, closestContentEditable).each(setElementSelection);\n } else {\n closestFakeCaretCandidate(rootNode, e.clientX, e.clientY).each(caretInfo => {\n e.preventDefault();\n const range = showCaret(1, caretInfo.node, caretInfo.position === FakeCaretPosition.Before, false);\n setRange(range);\n if (isHTMLElement(closestContentEditable)) {\n closestContentEditable.focus();\n } else {\n editor.getBody().focus();\n }\n });\n }\n });\n editor.on('keypress', e => {\n if (VK.modifierPressed(e)) {\n return;\n }\n if (isContentEditableFalse(selection.getNode())) {\n e.preventDefault();\n }\n });\n editor.on('GetSelectionRange', e => {\n let rng = e.range;\n if (selectedElement) {\n if (!selectedElement.parentNode) {\n selectedElement = null;\n return;\n }\n rng = rng.cloneRange();\n rng.selectNode(selectedElement);\n e.range = rng;\n }\n });\n editor.on('SetSelectionRange', e => {\n e.range = normalizeVoidElementSelection(e.range);\n const rng = setElementSelection(e.range, e.forward);\n if (rng) {\n e.range = rng;\n }\n });\n const isPasteBin = node => isElement$6(node) && node.id === 'mcepastebin';\n editor.on('AfterSetSelectionRange', e => {\n const rng = e.range;\n const parent = rng.startContainer.parentElement;\n if (!isRangeInCaretContainer(rng) && !isPasteBin(parent)) {\n hideFakeCaret();\n }\n if (!isFakeSelectionElement(parent)) {\n removeElementSelection();\n }\n });\n init$2(editor);\n setup$4(editor);\n setup$3(editor);\n };\n const isWithinCaretContainer = node => isCaretContainer$2(node) || startsWithCaretContainer$1(node) || endsWithCaretContainer$1(node);\n const isRangeInCaretContainer = rng => isWithinCaretContainer(rng.startContainer) || isWithinCaretContainer(rng.endContainer);\n const normalizeVoidElementSelection = rng => {\n const voidElements = editor.schema.getVoidElements();\n const newRng = dom.createRng();\n const startContainer = rng.startContainer;\n const startOffset = rng.startOffset;\n const endContainer = rng.endContainer;\n const endOffset = rng.endOffset;\n if (has$2(voidElements, startContainer.nodeName.toLowerCase())) {\n if (startOffset === 0) {\n newRng.setStartBefore(startContainer);\n } else {\n newRng.setStartAfter(startContainer);\n }\n } else {\n newRng.setStart(startContainer, startOffset);\n }\n if (has$2(voidElements, endContainer.nodeName.toLowerCase())) {\n if (endOffset === 0) {\n newRng.setEndBefore(endContainer);\n } else {\n newRng.setEndAfter(endContainer);\n }\n } else {\n newRng.setEnd(endContainer, endOffset);\n }\n return newRng;\n };\n const setupOffscreenSelection = (node, targetClone) => {\n const body = SugarElement.fromDom(editor.getBody());\n const doc = editor.getDoc();\n const realSelectionContainer = descendant$1(body, '#' + realSelectionId).getOrThunk(() => {\n const newContainer = SugarElement.fromHtml('
    ', doc);\n set$3(newContainer, 'id', realSelectionId);\n append$1(body, newContainer);\n return newContainer;\n });\n const newRange = dom.createRng();\n empty(realSelectionContainer);\n append(realSelectionContainer, [\n SugarElement.fromText(nbsp, doc),\n SugarElement.fromDom(targetClone),\n SugarElement.fromText(nbsp, doc)\n ]);\n newRange.setStart(realSelectionContainer.dom.firstChild, 1);\n newRange.setEnd(realSelectionContainer.dom.lastChild, 0);\n setAll(realSelectionContainer, { top: dom.getPos(node, editor.getBody()).y + 'px' });\n focus$1(realSelectionContainer);\n const sel = selection.getSel();\n if (sel) {\n sel.removeAllRanges();\n sel.addRange(newRange);\n }\n return newRange;\n };\n const selectElement = elm => {\n const targetClone = elm.cloneNode(true);\n const e = editor.dispatch('ObjectSelected', {\n target: elm,\n targetClone\n });\n if (e.isDefaultPrevented()) {\n return null;\n }\n const range = setupOffscreenSelection(elm, e.targetClone);\n const nodeElm = SugarElement.fromDom(elm);\n each$e(descendants(SugarElement.fromDom(editor.getBody()), `*[${ elementSelectionAttr }]`), elm => {\n if (!eq(nodeElm, elm)) {\n remove$a(elm, elementSelectionAttr);\n }\n });\n if (!dom.getAttrib(elm, elementSelectionAttr)) {\n elm.setAttribute(elementSelectionAttr, '1');\n }\n selectedElement = elm;\n hideFakeCaret();\n return range;\n };\n const setElementSelection = (range, forward) => {\n if (!range) {\n return null;\n }\n if (range.collapsed) {\n if (!isRangeInCaretContainer(range)) {\n const dir = forward ? 1 : -1;\n const caretPosition = getNormalizedRangeEndPoint(dir, rootNode, range);\n const beforeNode = caretPosition.getNode(!forward);\n if (isNonNullable(beforeNode)) {\n if (isFakeCaretTarget(beforeNode)) {\n return showCaret(dir, beforeNode, forward ? !caretPosition.isAtEnd() : false, false);\n }\n if (isCaretContainerInline(beforeNode) && isContentEditableFalse$b(beforeNode.nextSibling)) {\n const rng = dom.createRng();\n rng.setStart(beforeNode, 0);\n rng.setEnd(beforeNode, 0);\n return rng;\n }\n }\n const afterNode = caretPosition.getNode(forward);\n if (isNonNullable(afterNode)) {\n if (isFakeCaretTarget(afterNode)) {\n return showCaret(dir, afterNode, forward ? false : !caretPosition.isAtEnd(), false);\n }\n if (isCaretContainerInline(afterNode) && isContentEditableFalse$b(afterNode.previousSibling)) {\n const rng = dom.createRng();\n rng.setStart(afterNode, 1);\n rng.setEnd(afterNode, 1);\n return rng;\n }\n }\n }\n return null;\n }\n let startContainer = range.startContainer;\n let startOffset = range.startOffset;\n const endOffset = range.endOffset;\n if (isText$a(startContainer) && startOffset === 0 && isContentEditableFalse(startContainer.parentNode)) {\n startContainer = startContainer.parentNode;\n startOffset = dom.nodeIndex(startContainer);\n startContainer = startContainer.parentNode;\n }\n if (!isElement$6(startContainer)) {\n return null;\n }\n if (endOffset === startOffset + 1 && startContainer === range.endContainer) {\n const node = startContainer.childNodes[startOffset];\n if (isFakeSelectionTargetElement(node)) {\n return selectElement(node);\n }\n }\n return null;\n };\n const removeElementSelection = () => {\n if (selectedElement) {\n selectedElement.removeAttribute(elementSelectionAttr);\n }\n descendant$1(SugarElement.fromDom(editor.getBody()), '#' + realSelectionId).each(remove$5);\n selectedElement = null;\n };\n const destroy = () => {\n fakeCaret.destroy();\n selectedElement = null;\n };\n const hideFakeCaret = () => {\n fakeCaret.hide();\n };\n if (!isRtc(editor)) {\n registerEvents();\n }\n return {\n showCaret,\n showBlockCaretContainer,\n hideFakeCaret,\n destroy\n };\n };\n\n const getNormalizedTextOffset = (container, offset) => {\n let normalizedOffset = offset;\n for (let node = container.previousSibling; isText$a(node); node = node.previousSibling) {\n normalizedOffset += node.data.length;\n }\n return normalizedOffset;\n };\n const generatePath = (dom, root, node, offset, normalized) => {\n if (isText$a(node) && (offset < 0 || offset > node.data.length)) {\n return [];\n }\n const p = normalized && isText$a(node) ? [getNormalizedTextOffset(node, offset)] : [offset];\n let current = node;\n while (current !== root && current.parentNode) {\n p.push(dom.nodeIndex(current, normalized));\n current = current.parentNode;\n }\n return current === root ? p.reverse() : [];\n };\n const generatePathRange = (dom, root, startNode, startOffset, endNode, endOffset, normalized = false) => {\n const start = generatePath(dom, root, startNode, startOffset, normalized);\n const end = generatePath(dom, root, endNode, endOffset, normalized);\n return {\n start,\n end\n };\n };\n const resolvePath = (root, path) => {\n const nodePath = path.slice();\n const offset = nodePath.pop();\n if (!isNumber(offset)) {\n return Optional.none();\n } else {\n const resolvedNode = foldl(nodePath, (optNode, index) => optNode.bind(node => Optional.from(node.childNodes[index])), Optional.some(root));\n return resolvedNode.bind(node => {\n if (isText$a(node) && (offset < 0 || offset > node.data.length)) {\n return Optional.none();\n } else {\n return Optional.some({\n node,\n offset\n });\n }\n });\n }\n };\n const resolvePathRange = (root, range) => resolvePath(root, range.start).bind(({\n node: startNode,\n offset: startOffset\n }) => resolvePath(root, range.end).map(({\n node: endNode,\n offset: endOffset\n }) => {\n const rng = document.createRange();\n rng.setStart(startNode, startOffset);\n rng.setEnd(endNode, endOffset);\n return rng;\n }));\n const generatePathRangeFromRange = (dom, root, range, normalized = false) => generatePathRange(dom, root, range.startContainer, range.startOffset, range.endContainer, range.endOffset, normalized);\n\n const cleanEmptyNodes = (dom, node, isRoot) => {\n if (node && dom.isEmpty(node) && !isRoot(node)) {\n const parent = node.parentNode;\n dom.remove(node, isText$a(node.firstChild) && isWhitespaceText(node.firstChild.data));\n cleanEmptyNodes(dom, parent, isRoot);\n }\n };\n const deleteRng = (dom, rng, isRoot, clean = true) => {\n const startParent = rng.startContainer.parentNode;\n const endParent = rng.endContainer.parentNode;\n rng.deleteContents();\n if (clean && !isRoot(rng.startContainer)) {\n if (isText$a(rng.startContainer) && rng.startContainer.data.length === 0) {\n dom.remove(rng.startContainer);\n }\n if (isText$a(rng.endContainer) && rng.endContainer.data.length === 0) {\n dom.remove(rng.endContainer);\n }\n cleanEmptyNodes(dom, startParent, isRoot);\n if (startParent !== endParent) {\n cleanEmptyNodes(dom, endParent, isRoot);\n }\n }\n };\n const getParentBlock = (editor, rng) => Optional.from(editor.dom.getParent(rng.startContainer, editor.dom.isBlock));\n const resolveFromDynamicPatterns = (patternSet, block, beforeText) => {\n const dynamicPatterns = patternSet.dynamicPatternsLookup({\n text: beforeText,\n block\n });\n return {\n ...patternSet,\n blockPatterns: getBlockPatterns(dynamicPatterns).concat(patternSet.blockPatterns),\n inlinePatterns: getInlinePatterns(dynamicPatterns).concat(patternSet.inlinePatterns)\n };\n };\n const getBeforeText = (dom, block, node, offset) => {\n const rng = dom.createRng();\n rng.setStart(block, 0);\n rng.setEnd(node, offset);\n return rng.toString();\n };\n\n const startsWithSingleSpace = s => /^\\s[^\\s]/.test(s);\n const stripPattern = (dom, block, pattern) => {\n const firstTextNode = textAfter(block, 0, block);\n firstTextNode.each(spot => {\n const node = spot.container;\n scanRight(node, pattern.start.length, block).each(end => {\n const rng = dom.createRng();\n rng.setStart(node, 0);\n rng.setEnd(end.container, end.offset);\n deleteRng(dom, rng, e => e === block);\n });\n const text = SugarElement.fromDom(node);\n const textContent = get$3(text);\n if (startsWithSingleSpace(textContent)) {\n set(text, textContent.slice(1));\n }\n });\n };\n const applyPattern$1 = (editor, match) => {\n const dom = editor.dom;\n const pattern = match.pattern;\n const rng = resolvePathRange(dom.getRoot(), match.range).getOrDie('Unable to resolve path range');\n const isBlockFormatName = (name, formatter) => {\n const formatSet = formatter.get(name);\n return isArray$1(formatSet) && head(formatSet).exists(format => has$2(format, 'block'));\n };\n getParentBlock(editor, rng).each(block => {\n if (pattern.type === 'block-format') {\n if (isBlockFormatName(pattern.format, editor.formatter)) {\n editor.undoManager.transact(() => {\n stripPattern(editor.dom, block, pattern);\n editor.formatter.apply(pattern.format);\n });\n }\n } else if (pattern.type === 'block-command') {\n editor.undoManager.transact(() => {\n stripPattern(editor.dom, block, pattern);\n editor.execCommand(pattern.cmd, false, pattern.value);\n });\n }\n });\n return true;\n };\n const sortPatterns$1 = patterns => sort(patterns, (a, b) => b.start.length - a.start.length);\n const findPattern$1 = (patterns, text) => {\n const sortedPatterns = sortPatterns$1(patterns);\n const nuText = text.replace(nbsp, ' ');\n return find$2(sortedPatterns, pattern => text.indexOf(pattern.start) === 0 || nuText.indexOf(pattern.start) === 0);\n };\n const findPatterns$1 = (editor, block, patternSet, normalizedMatches) => {\n var _a;\n const dom = editor.dom;\n const forcedRootBlock = getForcedRootBlock(editor);\n if (!dom.is(block, forcedRootBlock)) {\n return [];\n }\n const blockText = (_a = block.textContent) !== null && _a !== void 0 ? _a : '';\n return findPattern$1(patternSet.blockPatterns, blockText).map(pattern => {\n if (Tools.trim(blockText).length === pattern.start.length) {\n return [];\n }\n return [{\n pattern,\n range: generatePathRange(dom, dom.getRoot(), block, 0, block, 0, normalizedMatches)\n }];\n }).getOr([]);\n };\n const applyMatches$1 = (editor, matches) => {\n if (matches.length === 0) {\n return;\n }\n const bookmark = editor.selection.getBookmark();\n each$e(matches, match => applyPattern$1(editor, match));\n editor.selection.moveToBookmark(bookmark);\n };\n\n const newMarker = (dom, id) => dom.create('span', {\n 'data-mce-type': 'bookmark',\n id\n });\n const rangeFromMarker = (dom, marker) => {\n const rng = dom.createRng();\n rng.setStartAfter(marker.start);\n rng.setEndBefore(marker.end);\n return rng;\n };\n const createMarker = (dom, markerPrefix, pathRange) => {\n const rng = resolvePathRange(dom.getRoot(), pathRange).getOrDie('Unable to resolve path range');\n const startNode = rng.startContainer;\n const endNode = rng.endContainer;\n const textEnd = rng.endOffset === 0 ? endNode : endNode.splitText(rng.endOffset);\n const textStart = rng.startOffset === 0 ? startNode : startNode.splitText(rng.startOffset);\n const startParentNode = textStart.parentNode;\n const endParentNode = textEnd.parentNode;\n return {\n prefix: markerPrefix,\n end: endParentNode.insertBefore(newMarker(dom, markerPrefix + '-end'), textEnd),\n start: startParentNode.insertBefore(newMarker(dom, markerPrefix + '-start'), textStart)\n };\n };\n const removeMarker = (dom, marker, isRoot) => {\n cleanEmptyNodes(dom, dom.get(marker.prefix + '-end'), isRoot);\n cleanEmptyNodes(dom, dom.get(marker.prefix + '-start'), isRoot);\n };\n\n const isReplacementPattern = pattern => pattern.start.length === 0;\n const matchesPattern = patternContent => (element, offset) => {\n const text = element.data;\n const searchText = text.substring(0, offset);\n const startEndIndex = searchText.lastIndexOf(patternContent.charAt(patternContent.length - 1));\n const startIndex = searchText.lastIndexOf(patternContent);\n if (startIndex !== -1) {\n return startIndex + patternContent.length;\n } else if (startEndIndex !== -1) {\n return startEndIndex + 1;\n } else {\n return -1;\n }\n };\n const findPatternStartFromSpot = (dom, pattern, block, spot) => {\n const startPattern = pattern.start;\n const startSpot = repeatLeft(dom, spot.container, spot.offset, matchesPattern(startPattern), block);\n return startSpot.bind(spot => {\n var _a, _b;\n const startPatternIndex = (_b = (_a = block.textContent) === null || _a === void 0 ? void 0 : _a.indexOf(startPattern)) !== null && _b !== void 0 ? _b : -1;\n const isCompleteMatch = startPatternIndex !== -1 && spot.offset >= startPatternIndex + startPattern.length;\n if (isCompleteMatch) {\n const rng = dom.createRng();\n rng.setStart(spot.container, spot.offset - startPattern.length);\n rng.setEnd(spot.container, spot.offset);\n return Optional.some(rng);\n } else {\n const offset = spot.offset - startPattern.length;\n return scanLeft(spot.container, offset, block).map(nextSpot => {\n const rng = dom.createRng();\n rng.setStart(nextSpot.container, nextSpot.offset);\n rng.setEnd(spot.container, spot.offset);\n return rng;\n }).filter(rng => rng.toString() === startPattern).orThunk(() => findPatternStartFromSpot(dom, pattern, block, point(spot.container, 0)));\n }\n });\n };\n const findPatternStart = (dom, pattern, node, offset, block, requireGap = false) => {\n if (pattern.start.length === 0 && !requireGap) {\n const rng = dom.createRng();\n rng.setStart(node, offset);\n rng.setEnd(node, offset);\n return Optional.some(rng);\n }\n return textBefore(node, offset, block).bind(spot => {\n const start = findPatternStartFromSpot(dom, pattern, block, spot);\n return start.bind(startRange => {\n var _a;\n if (requireGap) {\n if (startRange.endContainer === spot.container && startRange.endOffset === spot.offset) {\n return Optional.none();\n } else if (spot.offset === 0 && ((_a = startRange.endContainer.textContent) === null || _a === void 0 ? void 0 : _a.length) === startRange.endOffset) {\n return Optional.none();\n }\n }\n return Optional.some(startRange);\n });\n });\n };\n const findPattern = (editor, block, details, normalizedMatches) => {\n const dom = editor.dom;\n const root = dom.getRoot();\n const pattern = details.pattern;\n const endNode = details.position.container;\n const endOffset = details.position.offset;\n return scanLeft(endNode, endOffset - details.pattern.end.length, block).bind(spot => {\n const endPathRng = generatePathRange(dom, root, spot.container, spot.offset, endNode, endOffset, normalizedMatches);\n if (isReplacementPattern(pattern)) {\n return Optional.some({\n matches: [{\n pattern,\n startRng: endPathRng,\n endRng: endPathRng\n }],\n position: spot\n });\n } else {\n const resultsOpt = findPatternsRec(editor, details.remainingPatterns, spot.container, spot.offset, block, normalizedMatches);\n const results = resultsOpt.getOr({\n matches: [],\n position: spot\n });\n const pos = results.position;\n const start = findPatternStart(dom, pattern, pos.container, pos.offset, block, resultsOpt.isNone());\n return start.map(startRng => {\n const startPathRng = generatePathRangeFromRange(dom, root, startRng, normalizedMatches);\n return {\n matches: results.matches.concat([{\n pattern,\n startRng: startPathRng,\n endRng: endPathRng\n }]),\n position: point(startRng.startContainer, startRng.startOffset)\n };\n });\n }\n });\n };\n const findPatternsRec = (editor, patterns, node, offset, block, normalizedMatches) => {\n const dom = editor.dom;\n return textBefore(node, offset, dom.getRoot()).bind(endSpot => {\n const text = getBeforeText(dom, block, node, offset);\n for (let i = 0; i < patterns.length; i++) {\n const pattern = patterns[i];\n if (!endsWith(text, pattern.end)) {\n continue;\n }\n const patternsWithoutCurrent = patterns.slice();\n patternsWithoutCurrent.splice(i, 1);\n const result = findPattern(editor, block, {\n pattern,\n remainingPatterns: patternsWithoutCurrent,\n position: endSpot\n }, normalizedMatches);\n if (result.isNone() && offset > 0) {\n return findPatternsRec(editor, patterns, node, offset - 1, block, normalizedMatches);\n }\n if (result.isSome()) {\n return result;\n }\n }\n return Optional.none();\n });\n };\n const applyPattern = (editor, pattern, patternRange) => {\n editor.selection.setRng(patternRange);\n if (pattern.type === 'inline-format') {\n each$e(pattern.format, format => {\n editor.formatter.apply(format);\n });\n } else {\n editor.execCommand(pattern.cmd, false, pattern.value);\n }\n };\n const applyReplacementPattern = (editor, pattern, marker, isRoot) => {\n const markerRange = rangeFromMarker(editor.dom, marker);\n deleteRng(editor.dom, markerRange, isRoot);\n applyPattern(editor, pattern, markerRange);\n };\n const applyPatternWithContent = (editor, pattern, startMarker, endMarker, isRoot) => {\n const dom = editor.dom;\n const markerEndRange = rangeFromMarker(dom, endMarker);\n const markerStartRange = rangeFromMarker(dom, startMarker);\n deleteRng(dom, markerStartRange, isRoot);\n deleteRng(dom, markerEndRange, isRoot);\n const patternMarker = {\n prefix: startMarker.prefix,\n start: startMarker.end,\n end: endMarker.start\n };\n const patternRange = rangeFromMarker(dom, patternMarker);\n applyPattern(editor, pattern, patternRange);\n };\n const addMarkers = (dom, matches) => {\n const markerPrefix = generate$1('mce_textpattern');\n const matchesWithEnds = foldr(matches, (acc, match) => {\n const endMarker = createMarker(dom, markerPrefix + `_end${ acc.length }`, match.endRng);\n return acc.concat([{\n ...match,\n endMarker\n }]);\n }, []);\n return foldr(matchesWithEnds, (acc, match) => {\n const idx = matchesWithEnds.length - acc.length - 1;\n const startMarker = isReplacementPattern(match.pattern) ? match.endMarker : createMarker(dom, markerPrefix + `_start${ idx }`, match.startRng);\n return acc.concat([{\n ...match,\n startMarker\n }]);\n }, []);\n };\n const sortPatterns = patterns => sort(patterns, (a, b) => b.end.length - a.end.length);\n const getBestMatches = (matches, matchesWithSortedPatterns) => {\n const hasSameMatches = forall(matches, match => exists(matchesWithSortedPatterns, sortedMatch => match.pattern.start === sortedMatch.pattern.start && match.pattern.end === sortedMatch.pattern.end));\n if (matches.length === matchesWithSortedPatterns.length) {\n if (hasSameMatches) {\n return matches;\n } else {\n return matchesWithSortedPatterns;\n }\n }\n return matches.length > matchesWithSortedPatterns.length ? matches : matchesWithSortedPatterns;\n };\n const findPatterns = (editor, block, node, offset, patternSet, normalizedMatches) => {\n const matches = findPatternsRec(editor, patternSet.inlinePatterns, node, offset, block, normalizedMatches).fold(() => [], result => result.matches);\n const matchesWithSortedPatterns = findPatternsRec(editor, sortPatterns(patternSet.inlinePatterns), node, offset, block, normalizedMatches).fold(() => [], result => result.matches);\n return getBestMatches(matches, matchesWithSortedPatterns);\n };\n const applyMatches = (editor, matches) => {\n if (matches.length === 0) {\n return;\n }\n const dom = editor.dom;\n const bookmark = editor.selection.getBookmark();\n const matchesWithMarkers = addMarkers(dom, matches);\n each$e(matchesWithMarkers, match => {\n const block = dom.getParent(match.startMarker.start, dom.isBlock);\n const isRoot = node => node === block;\n if (isReplacementPattern(match.pattern)) {\n applyReplacementPattern(editor, match.pattern, match.endMarker, isRoot);\n } else {\n applyPatternWithContent(editor, match.pattern, match.startMarker, match.endMarker, isRoot);\n }\n removeMarker(dom, match.endMarker, isRoot);\n removeMarker(dom, match.startMarker, isRoot);\n });\n editor.selection.moveToBookmark(bookmark);\n };\n\n const handleEnter = (editor, patternSet) => {\n const rng = editor.selection.getRng();\n return getParentBlock(editor, rng).map(block => {\n var _a;\n const offset = Math.max(0, rng.startOffset);\n const dynamicPatternSet = resolveFromDynamicPatterns(patternSet, block, (_a = block.textContent) !== null && _a !== void 0 ? _a : '');\n const inlineMatches = findPatterns(editor, block, rng.startContainer, offset, dynamicPatternSet, true);\n const blockMatches = findPatterns$1(editor, block, dynamicPatternSet, true);\n if (blockMatches.length > 0 || inlineMatches.length > 0) {\n editor.undoManager.add();\n editor.undoManager.extra(() => {\n editor.execCommand('mceInsertNewLine');\n }, () => {\n insert$5(editor);\n applyMatches(editor, inlineMatches);\n applyMatches$1(editor, blockMatches);\n const range = editor.selection.getRng();\n const spot = textBefore(range.startContainer, range.startOffset, editor.dom.getRoot());\n editor.execCommand('mceInsertNewLine');\n spot.each(s => {\n const node = s.container;\n if (node.data.charAt(s.offset - 1) === zeroWidth) {\n node.deleteData(s.offset - 1, 1);\n cleanEmptyNodes(editor.dom, node.parentNode, e => e === editor.dom.getRoot());\n }\n });\n });\n return true;\n }\n return false;\n }).getOr(false);\n };\n const handleInlineKey = (editor, patternSet) => {\n const rng = editor.selection.getRng();\n getParentBlock(editor, rng).map(block => {\n const offset = Math.max(0, rng.startOffset - 1);\n const beforeText = getBeforeText(editor.dom, block, rng.startContainer, offset);\n const dynamicPatternSet = resolveFromDynamicPatterns(patternSet, block, beforeText);\n const inlineMatches = findPatterns(editor, block, rng.startContainer, offset, dynamicPatternSet, false);\n if (inlineMatches.length > 0) {\n editor.undoManager.transact(() => {\n applyMatches(editor, inlineMatches);\n });\n }\n });\n };\n const checkKeyEvent = (codes, event, predicate) => {\n for (let i = 0; i < codes.length; i++) {\n if (predicate(codes[i], event)) {\n return true;\n }\n }\n return false;\n };\n const checkKeyCode = (codes, event) => checkKeyEvent(codes, event, (code, event) => {\n return code === event.keyCode && !VK.modifierPressed(event);\n });\n const checkCharCode = (chars, event) => checkKeyEvent(chars, event, (chr, event) => {\n return chr.charCodeAt(0) === event.charCode;\n });\n\n const setup$2 = editor => {\n const charCodes = [\n ',',\n '.',\n ';',\n ':',\n '!',\n '?'\n ];\n const keyCodes = [32];\n const getPatternSet = () => createPatternSet(getTextPatterns(editor), getTextPatternsLookup(editor));\n const hasDynamicPatterns = () => hasTextPatternsLookup(editor);\n editor.on('keydown', e => {\n if (e.keyCode === 13 && !VK.modifierPressed(e) && editor.selection.isCollapsed()) {\n const patternSet = getPatternSet();\n const hasPatterns = patternSet.inlinePatterns.length > 0 || patternSet.blockPatterns.length > 0 || hasDynamicPatterns();\n if (hasPatterns && handleEnter(editor, patternSet)) {\n e.preventDefault();\n }\n }\n }, true);\n const handleInlineTrigger = () => {\n if (editor.selection.isCollapsed()) {\n const patternSet = getPatternSet();\n const hasPatterns = patternSet.inlinePatterns.length > 0 || hasDynamicPatterns();\n if (hasPatterns) {\n handleInlineKey(editor, patternSet);\n }\n }\n };\n editor.on('keyup', e => {\n if (checkKeyCode(keyCodes, e)) {\n handleInlineTrigger();\n }\n });\n editor.on('keypress', e => {\n if (checkCharCode(charCodes, e)) {\n Delay.setEditorTimeout(editor, handleInlineTrigger);\n }\n });\n };\n\n const setup$1 = editor => {\n setup$2(editor);\n };\n\n const Quirks = editor => {\n const each = Tools.each;\n const BACKSPACE = VK.BACKSPACE, DELETE = VK.DELETE, dom = editor.dom, selection = editor.selection, parser = editor.parser;\n const browser = Env.browser;\n const isGecko = browser.isFirefox();\n const isWebKit = browser.isChromium() || browser.isSafari();\n const isiOS = Env.deviceType.isiPhone() || Env.deviceType.isiPad();\n const isMac = Env.os.isMacOS() || Env.os.isiOS();\n const setEditorCommandState = (cmd, state) => {\n try {\n editor.getDoc().execCommand(cmd, false, String(state));\n } catch (ex) {\n }\n };\n const isDefaultPrevented = e => {\n return e.isDefaultPrevented();\n };\n const emptyEditorWhenDeleting = () => {\n const serializeRng = rng => {\n const body = dom.create('body');\n const contents = rng.cloneContents();\n body.appendChild(contents);\n return selection.serializer.serialize(body, { format: 'html' });\n };\n const allContentsSelected = rng => {\n const selection = serializeRng(rng);\n const allRng = dom.createRng();\n allRng.selectNode(editor.getBody());\n const allSelection = serializeRng(allRng);\n return selection === allSelection;\n };\n editor.on('keydown', e => {\n const keyCode = e.keyCode;\n if (!isDefaultPrevented(e) && (keyCode === DELETE || keyCode === BACKSPACE) && editor.selection.isEditable()) {\n const isCollapsed = editor.selection.isCollapsed();\n const body = editor.getBody();\n if (isCollapsed && !isEmpty$2(SugarElement.fromDom(body))) {\n return;\n }\n if (!isCollapsed && !allContentsSelected(editor.selection.getRng())) {\n return;\n }\n e.preventDefault();\n editor.setContent('');\n if (body.firstChild && dom.isBlock(body.firstChild)) {\n editor.selection.setCursorLocation(body.firstChild, 0);\n } else {\n editor.selection.setCursorLocation(body, 0);\n }\n editor.nodeChanged();\n }\n });\n };\n const selectAll = () => {\n editor.shortcuts.add('meta+a', null, 'SelectAll');\n };\n const documentElementEditingFocus = () => {\n if (!editor.inline) {\n dom.bind(editor.getDoc(), 'mousedown mouseup', e => {\n let rng;\n if (e.target === editor.getDoc().documentElement) {\n rng = selection.getRng();\n editor.getBody().focus();\n if (e.type === 'mousedown') {\n if (isCaretContainer$2(rng.startContainer)) {\n return;\n }\n selection.placeCaretAt(e.clientX, e.clientY);\n } else {\n selection.setRng(rng);\n }\n }\n });\n }\n };\n const removeHrOnBackspace = () => {\n editor.on('keydown', e => {\n if (!isDefaultPrevented(e) && e.keyCode === BACKSPACE) {\n if (!editor.getBody().getElementsByTagName('hr').length) {\n return;\n }\n if (selection.isCollapsed() && selection.getRng().startOffset === 0) {\n const node = selection.getNode();\n const previousSibling = node.previousSibling;\n if (node.nodeName === 'HR') {\n dom.remove(node);\n e.preventDefault();\n return;\n }\n if (previousSibling && previousSibling.nodeName && previousSibling.nodeName.toLowerCase() === 'hr') {\n dom.remove(previousSibling);\n e.preventDefault();\n }\n }\n }\n });\n };\n const focusBody = () => {\n if (!Range.prototype.getClientRects) {\n editor.on('mousedown', e => {\n if (!isDefaultPrevented(e) && e.target.nodeName === 'HTML') {\n const body = editor.getBody();\n body.blur();\n Delay.setEditorTimeout(editor, () => {\n body.focus();\n });\n }\n });\n }\n };\n const selectControlElements = () => {\n const visualAidsAnchorClass = getVisualAidsAnchorClass(editor);\n editor.on('click', e => {\n const target = e.target;\n if (/^(IMG|HR)$/.test(target.nodeName) && dom.isEditable(target)) {\n e.preventDefault();\n editor.selection.select(target);\n editor.nodeChanged();\n }\n if (target.nodeName === 'A' && dom.hasClass(target, visualAidsAnchorClass) && target.childNodes.length === 0 && dom.isEditable(target.parentNode)) {\n e.preventDefault();\n selection.select(target);\n }\n });\n };\n const removeStylesWhenDeletingAcrossBlockElements = () => {\n const getAttributeApplyFunction = () => {\n const template = dom.getAttribs(selection.getStart().cloneNode(false));\n return () => {\n const target = selection.getStart();\n if (target !== editor.getBody()) {\n dom.setAttrib(target, 'style', null);\n each(template, attr => {\n target.setAttributeNode(attr.cloneNode(true));\n });\n }\n };\n };\n const isSelectionAcrossElements = () => {\n return !selection.isCollapsed() && dom.getParent(selection.getStart(), dom.isBlock) !== dom.getParent(selection.getEnd(), dom.isBlock);\n };\n editor.on('keypress', e => {\n let applyAttributes;\n if (!isDefaultPrevented(e) && (e.keyCode === 8 || e.keyCode === 46) && isSelectionAcrossElements()) {\n applyAttributes = getAttributeApplyFunction();\n editor.getDoc().execCommand('delete', false);\n applyAttributes();\n e.preventDefault();\n return false;\n } else {\n return true;\n }\n });\n dom.bind(editor.getDoc(), 'cut', e => {\n if (!isDefaultPrevented(e) && isSelectionAcrossElements()) {\n const applyAttributes = getAttributeApplyFunction();\n Delay.setEditorTimeout(editor, () => {\n applyAttributes();\n });\n }\n });\n };\n const disableBackspaceIntoATable = () => {\n editor.on('keydown', e => {\n if (!isDefaultPrevented(e) && e.keyCode === BACKSPACE) {\n if (selection.isCollapsed() && selection.getRng().startOffset === 0) {\n const previousSibling = selection.getNode().previousSibling;\n if (previousSibling && previousSibling.nodeName && previousSibling.nodeName.toLowerCase() === 'table') {\n e.preventDefault();\n return false;\n }\n }\n }\n return true;\n });\n };\n const removeBlockQuoteOnBackSpace = () => {\n editor.on('keydown', e => {\n if (isDefaultPrevented(e) || e.keyCode !== VK.BACKSPACE) {\n return;\n }\n let rng = selection.getRng();\n const container = rng.startContainer;\n const offset = rng.startOffset;\n const root = dom.getRoot();\n let parent = container;\n if (!rng.collapsed || offset !== 0) {\n return;\n }\n while (parent.parentNode && parent.parentNode.firstChild === parent && parent.parentNode !== root) {\n parent = parent.parentNode;\n }\n if (parent.nodeName === 'BLOCKQUOTE') {\n editor.formatter.toggle('blockquote', undefined, parent);\n rng = dom.createRng();\n rng.setStart(container, 0);\n rng.setEnd(container, 0);\n selection.setRng(rng);\n }\n });\n };\n const setGeckoEditingOptions = () => {\n const setOpts = () => {\n setEditorCommandState('StyleWithCSS', false);\n setEditorCommandState('enableInlineTableEditing', false);\n if (!getObjectResizing(editor)) {\n setEditorCommandState('enableObjectResizing', false);\n }\n };\n if (!isReadOnly$1(editor)) {\n editor.on('BeforeExecCommand mousedown', setOpts);\n }\n };\n const addBrAfterLastLinks = () => {\n const fixLinks = () => {\n each(dom.select('a:not([data-mce-block])'), node => {\n var _a;\n let parentNode = node.parentNode;\n const root = dom.getRoot();\n if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.lastChild) === node) {\n while (parentNode && !dom.isBlock(parentNode)) {\n if (((_a = parentNode.parentNode) === null || _a === void 0 ? void 0 : _a.lastChild) !== parentNode || parentNode === root) {\n return;\n }\n parentNode = parentNode.parentNode;\n }\n dom.add(parentNode, 'br', { 'data-mce-bogus': 1 });\n }\n });\n };\n editor.on('SetContent ExecCommand', e => {\n if (e.type === 'setcontent' || e.command === 'mceInsertLink') {\n fixLinks();\n }\n });\n };\n const setDefaultBlockType = () => {\n editor.on('init', () => {\n setEditorCommandState('DefaultParagraphSeparator', getForcedRootBlock(editor));\n });\n };\n const isAllContentSelected = editor => {\n const body = editor.getBody();\n const rng = editor.selection.getRng();\n return rng.startContainer === rng.endContainer && rng.startContainer === body && rng.startOffset === 0 && rng.endOffset === body.childNodes.length;\n };\n const normalizeSelection = () => {\n editor.on('keyup focusin mouseup', e => {\n if (!VK.modifierPressed(e) && !isAllContentSelected(editor)) {\n selection.normalize();\n }\n }, true);\n };\n const showBrokenImageIcon = () => {\n editor.contentStyles.push('img:-moz-broken {' + '-moz-force-broken-image-icon:1;' + 'min-width:24px;' + 'min-height:24px' + '}');\n };\n const restoreFocusOnKeyDown = () => {\n if (!editor.inline) {\n editor.on('keydown', () => {\n if (document.activeElement === document.body) {\n editor.getWin().focus();\n }\n });\n }\n };\n const bodyHeight = () => {\n if (!editor.inline) {\n editor.contentStyles.push('body {min-height: 150px}');\n editor.on('click', e => {\n let rng;\n if (e.target.nodeName === 'HTML') {\n rng = editor.selection.getRng();\n editor.getBody().focus();\n editor.selection.setRng(rng);\n editor.selection.normalize();\n editor.nodeChanged();\n }\n });\n }\n };\n const blockCmdArrowNavigation = () => {\n if (isMac) {\n editor.on('keydown', e => {\n if (VK.metaKeyPressed(e) && !e.shiftKey && (e.keyCode === 37 || e.keyCode === 39)) {\n e.preventDefault();\n const selection = editor.selection.getSel();\n selection.modify('move', e.keyCode === 37 ? 'backward' : 'forward', 'lineboundary');\n }\n });\n }\n };\n const tapLinksAndImages = () => {\n editor.on('click', e => {\n let elm = e.target;\n do {\n if (elm.tagName === 'A') {\n e.preventDefault();\n return;\n }\n } while (elm = elm.parentNode);\n });\n editor.contentStyles.push('.mce-content-body {-webkit-touch-callout: none}');\n };\n const blockFormSubmitInsideEditor = () => {\n editor.on('init', () => {\n editor.dom.bind(editor.getBody(), 'submit', e => {\n e.preventDefault();\n });\n });\n };\n const removeAppleInterchangeBrs = () => {\n parser.addNodeFilter('br', nodes => {\n let i = nodes.length;\n while (i--) {\n if (nodes[i].attr('class') === 'Apple-interchange-newline') {\n nodes[i].remove();\n }\n }\n });\n };\n const refreshContentEditable = noop;\n const isHidden = () => {\n if (!isGecko || editor.removed) {\n return false;\n }\n const sel = editor.selection.getSel();\n return !sel || !sel.rangeCount || sel.rangeCount === 0;\n };\n const setupRtc = () => {\n if (isWebKit) {\n documentElementEditingFocus();\n selectControlElements();\n blockFormSubmitInsideEditor();\n selectAll();\n if (isiOS) {\n restoreFocusOnKeyDown();\n bodyHeight();\n tapLinksAndImages();\n }\n }\n if (isGecko) {\n focusBody();\n setGeckoEditingOptions();\n showBrokenImageIcon();\n blockCmdArrowNavigation();\n }\n };\n const dropDragEndEvent = () => {\n editor.on('drop', event => {\n var _a;\n const data = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData('text/html');\n if (isString(data) && /^]*>$/.test(data)) {\n editor.dispatch('dragend', new window.DragEvent('dragend', event));\n }\n });\n };\n const setup = () => {\n removeBlockQuoteOnBackSpace();\n emptyEditorWhenDeleting();\n if (!Env.windowsPhone) {\n normalizeSelection();\n }\n if (isWebKit) {\n documentElementEditingFocus();\n selectControlElements();\n setDefaultBlockType();\n blockFormSubmitInsideEditor();\n disableBackspaceIntoATable();\n removeAppleInterchangeBrs();\n if (isiOS) {\n restoreFocusOnKeyDown();\n bodyHeight();\n tapLinksAndImages();\n } else {\n selectAll();\n }\n }\n if (isGecko) {\n removeHrOnBackspace();\n focusBody();\n removeStylesWhenDeletingAcrossBlockElements();\n setGeckoEditingOptions();\n addBrAfterLastLinks();\n showBrokenImageIcon();\n blockCmdArrowNavigation();\n disableBackspaceIntoATable();\n dropDragEndEvent();\n }\n };\n if (isRtc(editor)) {\n setupRtc();\n } else {\n setup();\n }\n return {\n refreshContentEditable,\n isHidden\n };\n };\n\n const DOM$6 = DOMUtils.DOM;\n const appendStyle = (editor, text) => {\n const body = SugarElement.fromDom(editor.getBody());\n const container = getStyleContainer(getRootNode(body));\n const style = SugarElement.fromTag('style');\n set$3(style, 'type', 'text/css');\n append$1(style, SugarElement.fromText(text));\n append$1(container, style);\n editor.on('remove', () => {\n remove$5(style);\n });\n };\n const getRootName = editor => editor.inline ? editor.getElement().nodeName.toLowerCase() : undefined;\n const removeUndefined = obj => filter$4(obj, v => isUndefined(v) === false);\n const mkParserSettings = editor => {\n const getOption = editor.options.get;\n const blobCache = editor.editorUpload.blobCache;\n return removeUndefined({\n allow_conditional_comments: getOption('allow_conditional_comments'),\n allow_html_data_urls: getOption('allow_html_data_urls'),\n allow_svg_data_urls: getOption('allow_svg_data_urls'),\n allow_html_in_named_anchor: getOption('allow_html_in_named_anchor'),\n allow_script_urls: getOption('allow_script_urls'),\n allow_unsafe_link_target: getOption('allow_unsafe_link_target'),\n convert_unsafe_embeds: getOption('convert_unsafe_embeds'),\n convert_fonts_to_spans: getOption('convert_fonts_to_spans'),\n fix_list_elements: getOption('fix_list_elements'),\n font_size_legacy_values: getOption('font_size_legacy_values'),\n forced_root_block: getOption('forced_root_block'),\n forced_root_block_attrs: getOption('forced_root_block_attrs'),\n preserve_cdata: getOption('preserve_cdata'),\n inline_styles: getOption('inline_styles'),\n root_name: getRootName(editor),\n sandbox_iframes: getOption('sandbox_iframes'),\n sanitize: getOption('xss_sanitization'),\n validate: true,\n blob_cache: blobCache,\n document: editor.getDoc()\n });\n };\n const mkSchemaSettings = editor => {\n const getOption = editor.options.get;\n return removeUndefined({\n custom_elements: getOption('custom_elements'),\n extended_valid_elements: getOption('extended_valid_elements'),\n invalid_elements: getOption('invalid_elements'),\n invalid_styles: getOption('invalid_styles'),\n schema: getOption('schema'),\n valid_children: getOption('valid_children'),\n valid_classes: getOption('valid_classes'),\n valid_elements: getOption('valid_elements'),\n valid_styles: getOption('valid_styles'),\n verify_html: getOption('verify_html'),\n padd_empty_block_inline_children: getOption('format_empty_lines')\n });\n };\n const mkSerializerSettings = editor => {\n const getOption = editor.options.get;\n return {\n ...mkParserSettings(editor),\n ...mkSchemaSettings(editor),\n ...removeUndefined({\n remove_trailing_brs: getOption('remove_trailing_brs'),\n pad_empty_with_br: getOption('pad_empty_with_br'),\n url_converter: getOption('url_converter'),\n url_converter_scope: getOption('url_converter_scope'),\n element_format: getOption('element_format'),\n entities: getOption('entities'),\n entity_encoding: getOption('entity_encoding'),\n indent: getOption('indent'),\n indent_after: getOption('indent_after'),\n indent_before: getOption('indent_before')\n })\n };\n };\n const createParser = editor => {\n const parser = DomParser(mkParserSettings(editor), editor.schema);\n parser.addAttributeFilter('src,href,style,tabindex', (nodes, name) => {\n const dom = editor.dom;\n const internalName = 'data-mce-' + name;\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n let value = node.attr(name);\n if (value && !node.attr(internalName)) {\n if (value.indexOf('data:') === 0 || value.indexOf('blob:') === 0) {\n continue;\n }\n if (name === 'style') {\n value = dom.serializeStyle(dom.parseStyle(value), node.name);\n if (!value.length) {\n value = null;\n }\n node.attr(internalName, value);\n node.attr(name, value);\n } else if (name === 'tabindex') {\n node.attr(internalName, value);\n node.attr(name, null);\n } else {\n node.attr(internalName, editor.convertURL(value, name, node.name));\n }\n }\n }\n });\n parser.addNodeFilter('script', nodes => {\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n const type = node.attr('type') || 'no/type';\n if (type.indexOf('mce-') !== 0) {\n node.attr('type', 'mce-' + type);\n }\n }\n });\n if (shouldPreserveCData(editor)) {\n parser.addNodeFilter('#cdata', nodes => {\n var _a;\n let i = nodes.length;\n while (i--) {\n const node = nodes[i];\n node.type = 8;\n node.name = '#comment';\n node.value = '[CDATA[' + editor.dom.encode((_a = node.value) !== null && _a !== void 0 ? _a : '') + ']]';\n }\n });\n }\n parser.addNodeFilter('p,h1,h2,h3,h4,h5,h6,div', nodes => {\n let i = nodes.length;\n const nonEmptyElements = editor.schema.getNonEmptyElements();\n while (i--) {\n const node = nodes[i];\n if (node.isEmpty(nonEmptyElements) && node.getAll('br').length === 0) {\n node.append(new AstNode('br', 1));\n }\n }\n });\n return parser;\n };\n const autoFocus = editor => {\n const autoFocus = getAutoFocus(editor);\n if (autoFocus) {\n Delay.setEditorTimeout(editor, () => {\n let focusEditor;\n if (autoFocus === true) {\n focusEditor = editor;\n } else {\n focusEditor = editor.editorManager.get(autoFocus);\n }\n if (focusEditor && !focusEditor.destroyed) {\n focusEditor.focus();\n focusEditor.selection.scrollIntoView();\n }\n }, 100);\n }\n };\n const moveSelectionToFirstCaretPosition = editor => {\n const root = editor.dom.getRoot();\n if (!editor.inline && (!hasAnyRanges(editor) || editor.selection.getStart(true) === root)) {\n firstPositionIn(root).each(pos => {\n const node = pos.getNode();\n const caretPos = isTable$2(node) ? firstPositionIn(node).getOr(pos) : pos;\n editor.selection.setRng(caretPos.toRange());\n });\n }\n };\n const initEditor = editor => {\n editor.bindPendingEventDelegates();\n editor.initialized = true;\n fireInit(editor);\n editor.focus(true);\n moveSelectionToFirstCaretPosition(editor);\n editor.nodeChanged({ initial: true });\n const initInstanceCallback = getInitInstanceCallback(editor);\n if (isFunction(initInstanceCallback)) {\n initInstanceCallback.call(editor, editor);\n }\n autoFocus(editor);\n };\n const getStyleSheetLoader$1 = editor => editor.inline ? editor.ui.styleSheetLoader : editor.dom.styleSheetLoader;\n const makeStylesheetLoadingPromises = (editor, css, framedFonts) => {\n const {\n pass: bundledCss,\n fail: normalCss\n } = partition$2(css, name => tinymce.Resource.has(toContentSkinResourceName(name)));\n const bundledPromises = bundledCss.map(url => {\n const css = tinymce.Resource.get(toContentSkinResourceName(url));\n if (isString(css)) {\n return Promise.resolve(getStyleSheetLoader$1(editor).loadRawCss(url, css));\n }\n return Promise.resolve();\n });\n const promises = [\n ...bundledPromises,\n getStyleSheetLoader$1(editor).loadAll(normalCss)\n ];\n if (editor.inline) {\n return promises;\n } else {\n return promises.concat([editor.ui.styleSheetLoader.loadAll(framedFonts)]);\n }\n };\n const loadContentCss = editor => {\n const styleSheetLoader = getStyleSheetLoader$1(editor);\n const fontCss = getFontCss(editor);\n const css = editor.contentCSS;\n const removeCss = () => {\n styleSheetLoader.unloadAll(css);\n if (!editor.inline) {\n editor.ui.styleSheetLoader.unloadAll(fontCss);\n }\n };\n const loaded = () => {\n if (editor.removed) {\n removeCss();\n } else {\n editor.on('remove', removeCss);\n }\n };\n if (editor.contentStyles.length > 0) {\n let contentCssText = '';\n Tools.each(editor.contentStyles, style => {\n contentCssText += style + '\\r\\n';\n });\n editor.dom.addStyle(contentCssText);\n }\n const allStylesheets = Promise.all(makeStylesheetLoadingPromises(editor, css, fontCss)).then(loaded).catch(loaded);\n const contentStyle = getContentStyle(editor);\n if (contentStyle) {\n appendStyle(editor, contentStyle);\n }\n return allStylesheets;\n };\n const preInit = editor => {\n const doc = editor.getDoc(), body = editor.getBody();\n firePreInit(editor);\n if (!shouldBrowserSpellcheck(editor)) {\n doc.body.spellcheck = false;\n DOM$6.setAttrib(body, 'spellcheck', 'false');\n }\n editor.quirks = Quirks(editor);\n firePostRender(editor);\n const directionality = getDirectionality(editor);\n if (directionality !== undefined) {\n body.dir = directionality;\n }\n const protect = getProtect(editor);\n if (protect) {\n editor.on('BeforeSetContent', e => {\n Tools.each(protect, pattern => {\n e.content = e.content.replace(pattern, str => {\n return '';\n });\n });\n });\n }\n editor.on('SetContent', () => {\n editor.addVisual(editor.getBody());\n });\n editor.on('compositionstart compositionend', e => {\n editor.composing = e.type === 'compositionstart';\n });\n };\n const loadInitialContent = editor => {\n if (!isRtc(editor)) {\n editor.load({\n initial: true,\n format: 'html'\n });\n }\n editor.startContent = editor.getContent({ format: 'raw' });\n };\n const initEditorWithInitialContent = editor => {\n if (editor.removed !== true) {\n loadInitialContent(editor);\n initEditor(editor);\n }\n };\n const startProgress = editor => {\n let canceled = false;\n const progressTimeout = setTimeout(() => {\n if (!canceled) {\n editor.setProgressState(true);\n }\n }, 500);\n return () => {\n clearTimeout(progressTimeout);\n canceled = true;\n editor.setProgressState(false);\n };\n };\n const contentBodyLoaded = editor => {\n const targetElm = editor.getElement();\n let doc = editor.getDoc();\n if (editor.inline) {\n DOM$6.addClass(targetElm, 'mce-content-body');\n editor.contentDocument = doc = document;\n editor.contentWindow = window;\n editor.bodyElement = targetElm;\n editor.contentAreaContainer = targetElm;\n }\n const body = editor.getBody();\n body.disabled = true;\n editor.readonly = isReadOnly$1(editor);\n editor._editableRoot = hasEditableRoot$1(editor);\n if (!editor.readonly && editor.hasEditableRoot()) {\n if (editor.inline && DOM$6.getStyle(body, 'position', true) === 'static') {\n body.style.position = 'relative';\n }\n body.contentEditable = 'true';\n }\n body.disabled = false;\n editor.editorUpload = EditorUpload(editor);\n editor.schema = Schema(mkSchemaSettings(editor));\n editor.dom = DOMUtils(doc, {\n keep_values: true,\n url_converter: editor.convertURL,\n url_converter_scope: editor,\n update_styles: true,\n root_element: editor.inline ? editor.getBody() : null,\n collect: editor.inline,\n schema: editor.schema,\n contentCssCors: shouldUseContentCssCors(editor),\n referrerPolicy: getReferrerPolicy(editor),\n onSetAttrib: e => {\n editor.dispatch('SetAttrib', e);\n },\n force_hex_color: shouldForceHexColor(editor)\n });\n editor.parser = createParser(editor);\n editor.serializer = DomSerializer(mkSerializerSettings(editor), editor);\n editor.selection = EditorSelection(editor.dom, editor.getWin(), editor.serializer, editor);\n editor.annotator = Annotator(editor);\n editor.formatter = Formatter(editor);\n editor.undoManager = UndoManager(editor);\n editor._nodeChangeDispatcher = new NodeChange(editor);\n editor._selectionOverrides = SelectionOverrides(editor);\n setup$p(editor);\n setup$6(editor);\n setup$n(editor);\n if (!isRtc(editor)) {\n setup$5(editor);\n setup$1(editor);\n }\n const caret = setup$b(editor);\n setup$q(editor, caret);\n setup$o(editor);\n setup$r(editor);\n setup$7(editor);\n const setupRtcThunk = setup$t(editor);\n preInit(editor);\n setupRtcThunk.fold(() => {\n const cancelProgress = startProgress(editor);\n loadContentCss(editor).then(() => {\n initEditorWithInitialContent(editor);\n cancelProgress();\n });\n }, setupRtc => {\n editor.setProgressState(true);\n loadContentCss(editor).then(() => {\n setupRtc().then(_rtcMode => {\n editor.setProgressState(false);\n initEditorWithInitialContent(editor);\n bindEvents(editor);\n }, err => {\n editor.notificationManager.open({\n type: 'error',\n text: String(err)\n });\n initEditorWithInitialContent(editor);\n bindEvents(editor);\n });\n });\n });\n };\n\n const filter = always;\n const bind = (element, event, handler) => bind$2(element, event, filter, handler);\n\n const DOM$5 = DOMUtils.DOM;\n const createIframeElement = (id, title, customAttrs, tabindex) => {\n const iframe = SugarElement.fromTag('iframe');\n tabindex.each(t => set$3(iframe, 'tabindex', t));\n setAll$1(iframe, customAttrs);\n setAll$1(iframe, {\n id: id + '_ifr',\n frameBorder: '0',\n allowTransparency: 'true',\n title\n });\n add$2(iframe, 'tox-edit-area__iframe');\n return iframe;\n };\n const getIframeHtml = editor => {\n let iframeHTML = getDocType(editor) + '';\n if (getDocumentBaseUrl(editor) !== editor.documentBaseUrl) {\n iframeHTML += '';\n }\n iframeHTML += '';\n const bodyId = getBodyId(editor);\n const bodyClass = getBodyClass(editor);\n const translatedAriaText = editor.translate(getIframeAriaText(editor));\n if (getContentSecurityPolicy(editor)) {\n iframeHTML += '';\n }\n iframeHTML += '' + `` + '
    ' + '';\n return iframeHTML;\n };\n const createIframe = (editor, boxInfo) => {\n const iframeTitle = editor.translate('Rich Text Area');\n const tabindex = getOpt(SugarElement.fromDom(editor.getElement()), 'tabindex').bind(toInt);\n const ifr = createIframeElement(editor.id, iframeTitle, getIframeAttrs(editor), tabindex).dom;\n ifr.onload = () => {\n ifr.onload = null;\n editor.dispatch('load');\n };\n editor.contentAreaContainer = boxInfo.iframeContainer;\n editor.iframeElement = ifr;\n editor.iframeHTML = getIframeHtml(editor);\n DOM$5.add(boxInfo.iframeContainer, ifr);\n };\n const setupIframeBody = editor => {\n const iframe = editor.iframeElement;\n const ready = () => {\n editor.contentDocument = iframe.contentDocument;\n contentBodyLoaded(editor);\n };\n if (shouldUseDocumentWrite(editor) || Env.browser.isFirefox()) {\n const doc = editor.getDoc();\n doc.open();\n doc.write(editor.iframeHTML);\n doc.close();\n ready();\n } else {\n const binder = bind(SugarElement.fromDom(iframe), 'load', () => {\n binder.unbind();\n ready();\n });\n iframe.srcdoc = editor.iframeHTML;\n }\n };\n const init$1 = (editor, boxInfo) => {\n createIframe(editor, boxInfo);\n if (boxInfo.editorContainer) {\n boxInfo.editorContainer.style.display = editor.orgDisplay;\n editor.hidden = DOM$5.isHidden(boxInfo.editorContainer);\n }\n editor.getElement().style.display = 'none';\n DOM$5.setAttrib(editor.id, 'aria-hidden', 'true');\n editor.getElement().style.visibility = editor.orgVisibility;\n setupIframeBody(editor);\n };\n\n const DOM$4 = DOMUtils.DOM;\n const initPlugin = (editor, initializedPlugins, plugin) => {\n const Plugin = PluginManager.get(plugin);\n const pluginUrl = PluginManager.urls[plugin] || editor.documentBaseUrl.replace(/\\/$/, '');\n plugin = Tools.trim(plugin);\n if (Plugin && Tools.inArray(initializedPlugins, plugin) === -1) {\n if (editor.plugins[plugin]) {\n return;\n }\n try {\n const pluginInstance = Plugin(editor, pluginUrl) || {};\n editor.plugins[plugin] = pluginInstance;\n if (isFunction(pluginInstance.init)) {\n pluginInstance.init(editor, pluginUrl);\n initializedPlugins.push(plugin);\n }\n } catch (e) {\n pluginInitError(editor, plugin, e);\n }\n }\n };\n const trimLegacyPrefix = name => {\n return name.replace(/^\\-/, '');\n };\n const initPlugins = editor => {\n const initializedPlugins = [];\n each$e(getPlugins(editor), name => {\n initPlugin(editor, initializedPlugins, trimLegacyPrefix(name));\n });\n };\n const initIcons = editor => {\n const iconPackName = Tools.trim(getIconPackName(editor));\n const currentIcons = editor.ui.registry.getAll().icons;\n const loadIcons = {\n ...IconManager.get('default').icons,\n ...IconManager.get(iconPackName).icons\n };\n each$d(loadIcons, (svgData, icon) => {\n if (!has$2(currentIcons, icon)) {\n editor.ui.registry.addIcon(icon, svgData);\n }\n });\n };\n const initTheme = editor => {\n const theme = getTheme(editor);\n if (isString(theme)) {\n const Theme = ThemeManager.get(theme);\n editor.theme = Theme(editor, ThemeManager.urls[theme]) || {};\n if (isFunction(editor.theme.init)) {\n editor.theme.init(editor, ThemeManager.urls[theme] || editor.documentBaseUrl.replace(/\\/$/, ''));\n }\n } else {\n editor.theme = {};\n }\n };\n const initModel = editor => {\n const model = getModel(editor);\n const Model = ModelManager.get(model);\n editor.model = Model(editor, ModelManager.urls[model]);\n };\n const renderFromLoadedTheme = editor => {\n const render = editor.theme.renderUI;\n return render ? render() : renderThemeFalse(editor);\n };\n const renderFromThemeFunc = editor => {\n const elm = editor.getElement();\n const theme = getTheme(editor);\n const info = theme(editor, elm);\n if (info.editorContainer.nodeType) {\n info.editorContainer.id = info.editorContainer.id || editor.id + '_parent';\n }\n if (info.iframeContainer && info.iframeContainer.nodeType) {\n info.iframeContainer.id = info.iframeContainer.id || editor.id + '_iframecontainer';\n }\n info.height = info.iframeHeight ? info.iframeHeight : elm.offsetHeight;\n return info;\n };\n const createThemeFalseResult = (element, iframe) => {\n return {\n editorContainer: element,\n iframeContainer: iframe,\n api: {}\n };\n };\n const renderThemeFalseIframe = targetElement => {\n const iframeContainer = DOM$4.create('div');\n DOM$4.insertAfter(iframeContainer, targetElement);\n return createThemeFalseResult(iframeContainer, iframeContainer);\n };\n const renderThemeFalse = editor => {\n const targetElement = editor.getElement();\n return editor.inline ? createThemeFalseResult(null) : renderThemeFalseIframe(targetElement);\n };\n const renderThemeUi = editor => {\n const elm = editor.getElement();\n editor.orgDisplay = elm.style.display;\n if (isString(getTheme(editor))) {\n return renderFromLoadedTheme(editor);\n } else if (isFunction(getTheme(editor))) {\n return renderFromThemeFunc(editor);\n } else {\n return renderThemeFalse(editor);\n }\n };\n const augmentEditorUiApi = (editor, api) => {\n const uiApiFacade = {\n show: Optional.from(api.show).getOr(noop),\n hide: Optional.from(api.hide).getOr(noop),\n isEnabled: Optional.from(api.isEnabled).getOr(always),\n setEnabled: state => {\n if (!editor.mode.isReadOnly()) {\n Optional.from(api.setEnabled).each(f => f(state));\n }\n }\n };\n editor.ui = {\n ...editor.ui,\n ...uiApiFacade\n };\n };\n const init = async editor => {\n editor.dispatch('ScriptsLoaded');\n initIcons(editor);\n initTheme(editor);\n initModel(editor);\n initPlugins(editor);\n const renderInfo = await renderThemeUi(editor);\n augmentEditorUiApi(editor, Optional.from(renderInfo.api).getOr({}));\n editor.editorContainer = renderInfo.editorContainer;\n appendContentCssFromSettings(editor);\n if (editor.inline) {\n contentBodyLoaded(editor);\n } else {\n init$1(editor, {\n editorContainer: renderInfo.editorContainer,\n iframeContainer: renderInfo.iframeContainer\n });\n }\n };\n\n const DOM$3 = DOMUtils.DOM;\n const hasSkipLoadPrefix = name => name.charAt(0) === '-';\n const loadLanguage = (scriptLoader, editor) => {\n const languageCode = getLanguageCode(editor);\n const languageUrl = getLanguageUrl(editor);\n if (!I18n.hasCode(languageCode) && languageCode !== 'en') {\n const url = isNotEmpty(languageUrl) ? languageUrl : `${ editor.editorManager.baseURL }/langs/${ languageCode }.js`;\n scriptLoader.add(url).catch(() => {\n languageLoadError(editor, url, languageCode);\n });\n }\n };\n const loadTheme = (editor, suffix) => {\n const theme = getTheme(editor);\n if (isString(theme) && !hasSkipLoadPrefix(theme) && !has$2(ThemeManager.urls, theme)) {\n const themeUrl = getThemeUrl(editor);\n const url = themeUrl ? editor.documentBaseURI.toAbsolute(themeUrl) : `themes/${ theme }/theme${ suffix }.js`;\n ThemeManager.load(theme, url).catch(() => {\n themeLoadError(editor, url, theme);\n });\n }\n };\n const loadModel = (editor, suffix) => {\n const model = getModel(editor);\n if (model !== 'plugin' && !has$2(ModelManager.urls, model)) {\n const modelUrl = getModelUrl(editor);\n const url = isString(modelUrl) ? editor.documentBaseURI.toAbsolute(modelUrl) : `models/${ model }/model${ suffix }.js`;\n ModelManager.load(model, url).catch(() => {\n modelLoadError(editor, url, model);\n });\n }\n };\n const getIconsUrlMetaFromUrl = editor => Optional.from(getIconsUrl(editor)).filter(isNotEmpty).map(url => ({\n url,\n name: Optional.none()\n }));\n const getIconsUrlMetaFromName = (editor, name, suffix) => Optional.from(name).filter(name => isNotEmpty(name) && !IconManager.has(name)).map(name => ({\n url: `${ editor.editorManager.baseURL }/icons/${ name }/icons${ suffix }.js`,\n name: Optional.some(name)\n }));\n const loadIcons = (scriptLoader, editor, suffix) => {\n const defaultIconsUrl = getIconsUrlMetaFromName(editor, 'default', suffix);\n const customIconsUrl = getIconsUrlMetaFromUrl(editor).orThunk(() => getIconsUrlMetaFromName(editor, getIconPackName(editor), ''));\n each$e(cat([\n defaultIconsUrl,\n customIconsUrl\n ]), urlMeta => {\n scriptLoader.add(urlMeta.url).catch(() => {\n iconsLoadError(editor, urlMeta.url, urlMeta.name.getOrUndefined());\n });\n });\n };\n const loadPlugins = (editor, suffix) => {\n const loadPlugin = (name, url) => {\n PluginManager.load(name, url).catch(() => {\n pluginLoadError(editor, url, name);\n });\n };\n each$d(getExternalPlugins$1(editor), (url, name) => {\n loadPlugin(name, url);\n editor.options.set('plugins', getPlugins(editor).concat(name));\n });\n each$e(getPlugins(editor), plugin => {\n plugin = Tools.trim(plugin);\n if (plugin && !PluginManager.urls[plugin] && !hasSkipLoadPrefix(plugin)) {\n loadPlugin(plugin, `plugins/${ plugin }/plugin${ suffix }.js`);\n }\n });\n };\n const isThemeLoaded = editor => {\n const theme = getTheme(editor);\n return !isString(theme) || isNonNullable(ThemeManager.get(theme));\n };\n const isModelLoaded = editor => {\n const model = getModel(editor);\n return isNonNullable(ModelManager.get(model));\n };\n const loadScripts = (editor, suffix) => {\n const scriptLoader = ScriptLoader.ScriptLoader;\n const initEditor = () => {\n if (!editor.removed && isThemeLoaded(editor) && isModelLoaded(editor)) {\n init(editor);\n }\n };\n loadTheme(editor, suffix);\n loadModel(editor, suffix);\n loadLanguage(scriptLoader, editor);\n loadIcons(scriptLoader, editor, suffix);\n loadPlugins(editor, suffix);\n scriptLoader.loadQueue().then(initEditor, initEditor);\n };\n const getStyleSheetLoader = (element, editor) => instance.forElement(element, {\n contentCssCors: hasContentCssCors(editor),\n referrerPolicy: getReferrerPolicy(editor)\n });\n const render = editor => {\n const id = editor.id;\n I18n.setCode(getLanguageCode(editor));\n const readyHandler = () => {\n DOM$3.unbind(window, 'ready', readyHandler);\n editor.render();\n };\n if (!EventUtils.Event.domLoaded) {\n DOM$3.bind(window, 'ready', readyHandler);\n return;\n }\n if (!editor.getElement()) {\n return;\n }\n const element = SugarElement.fromDom(editor.getElement());\n const snapshot = clone$4(element);\n editor.on('remove', () => {\n eachr(element.dom.attributes, attr => remove$a(element, attr.name));\n setAll$1(element, snapshot);\n });\n editor.ui.styleSheetLoader = getStyleSheetLoader(element, editor);\n if (!isInline$1(editor)) {\n editor.orgVisibility = editor.getElement().style.visibility;\n editor.getElement().style.visibility = 'hidden';\n } else {\n editor.inline = true;\n }\n const form = editor.getElement().form || DOM$3.getParent(id, 'form');\n if (form) {\n editor.formElement = form;\n if (hasHiddenInput(editor) && !isTextareaOrInput(editor.getElement())) {\n DOM$3.insertAfter(DOM$3.create('input', {\n type: 'hidden',\n name: id\n }), id);\n editor.hasHiddenInput = true;\n }\n editor.formEventDelegate = e => {\n editor.dispatch(e.type, e);\n };\n DOM$3.bind(form, 'submit reset', editor.formEventDelegate);\n editor.on('reset', () => {\n editor.resetContent();\n });\n if (shouldPatchSubmit(editor) && !form.submit.nodeType && !form.submit.length && !form._mceOldSubmit) {\n form._mceOldSubmit = form.submit;\n form.submit = () => {\n editor.editorManager.triggerSave();\n editor.setDirty(false);\n return form._mceOldSubmit(form);\n };\n }\n }\n editor.windowManager = WindowManager(editor);\n editor.notificationManager = NotificationManager(editor);\n if (isEncodingXml(editor)) {\n editor.on('GetContent', e => {\n if (e.save) {\n e.content = DOM$3.encode(e.content);\n }\n });\n }\n if (shouldAddFormSubmitTrigger(editor)) {\n editor.on('submit', () => {\n if (editor.initialized) {\n editor.save();\n }\n });\n }\n if (shouldAddUnloadTrigger(editor)) {\n editor._beforeUnload = () => {\n if (editor.initialized && !editor.destroyed && !editor.isHidden()) {\n editor.save({\n format: 'raw',\n no_events: true,\n set_dirty: false\n });\n }\n };\n editor.editorManager.on('BeforeUnload', editor._beforeUnload);\n }\n editor.editorManager.add(editor);\n loadScripts(editor, editor.suffix);\n };\n\n const setEditableRoot = (editor, state) => {\n if (editor._editableRoot !== state) {\n editor._editableRoot = state;\n if (!editor.readonly) {\n editor.getBody().contentEditable = String(editor.hasEditableRoot());\n editor.nodeChanged();\n }\n fireEditableRootStateChange(editor, state);\n }\n };\n const hasEditableRoot = editor => editor._editableRoot;\n\n const sectionResult = (sections, settings) => ({\n sections: constant(sections),\n options: constant(settings)\n });\n const deviceDetection = detect$2().deviceType;\n const isPhone = deviceDetection.isPhone();\n const isTablet = deviceDetection.isTablet();\n const normalizePlugins = plugins => {\n if (isNullable(plugins)) {\n return [];\n } else {\n const pluginNames = isArray$1(plugins) ? plugins : plugins.split(/[ ,]/);\n const trimmedPlugins = map$3(pluginNames, trim$4);\n return filter$5(trimmedPlugins, isNotEmpty);\n }\n };\n const extractSections = (keys, options) => {\n const result = bifilter(options, (value, key) => {\n return contains$2(keys, key);\n });\n return sectionResult(result.t, result.f);\n };\n const getSection = (sectionResult, name, defaults = {}) => {\n const sections = sectionResult.sections();\n const sectionOptions = get$a(sections, name).getOr({});\n return Tools.extend({}, defaults, sectionOptions);\n };\n const hasSection = (sectionResult, name) => {\n return has$2(sectionResult.sections(), name);\n };\n const getSectionConfig = (sectionResult, name) => {\n return hasSection(sectionResult, name) ? sectionResult.sections()[name] : {};\n };\n const getMobileOverrideOptions = (mobileOptions, isPhone) => {\n const defaultMobileOptions = {\n table_grid: false,\n object_resizing: false,\n resize: false,\n toolbar_mode: get$a(mobileOptions, 'toolbar_mode').getOr('scrolling'),\n toolbar_sticky: false\n };\n const defaultPhoneOptions = { menubar: false };\n return {\n ...defaultMobileOptions,\n ...isPhone ? defaultPhoneOptions : {}\n };\n };\n const getExternalPlugins = (overrideOptions, options) => {\n var _a;\n const userDefinedExternalPlugins = (_a = options.external_plugins) !== null && _a !== void 0 ? _a : {};\n if (overrideOptions && overrideOptions.external_plugins) {\n return Tools.extend({}, overrideOptions.external_plugins, userDefinedExternalPlugins);\n } else {\n return userDefinedExternalPlugins;\n }\n };\n const combinePlugins = (forcedPlugins, plugins) => [\n ...normalizePlugins(forcedPlugins),\n ...normalizePlugins(plugins)\n ];\n const getPlatformPlugins = (isMobileDevice, sectionResult, desktopPlugins, mobilePlugins) => {\n if (isMobileDevice && hasSection(sectionResult, 'mobile')) {\n return mobilePlugins;\n } else {\n return desktopPlugins;\n }\n };\n const processPlugins = (isMobileDevice, sectionResult, defaultOverrideOptions, options) => {\n const forcedPlugins = normalizePlugins(defaultOverrideOptions.forced_plugins);\n const desktopPlugins = normalizePlugins(options.plugins);\n const mobileConfig = getSectionConfig(sectionResult, 'mobile');\n const mobilePlugins = mobileConfig.plugins ? normalizePlugins(mobileConfig.plugins) : desktopPlugins;\n const platformPlugins = getPlatformPlugins(isMobileDevice, sectionResult, desktopPlugins, mobilePlugins);\n const combinedPlugins = combinePlugins(forcedPlugins, platformPlugins);\n return Tools.extend(options, {\n forced_plugins: forcedPlugins,\n plugins: combinedPlugins\n });\n };\n const isOnMobile = (isMobileDevice, sectionResult) => {\n return isMobileDevice && hasSection(sectionResult, 'mobile');\n };\n const combineOptions = (isMobileDevice, isPhone, defaultOptions, defaultOverrideOptions, options) => {\n var _a;\n const deviceOverrideOptions = isMobileDevice ? { mobile: getMobileOverrideOptions((_a = options.mobile) !== null && _a !== void 0 ? _a : {}, isPhone) } : {};\n const sectionResult = extractSections(['mobile'], deepMerge(deviceOverrideOptions, options));\n const extendedOptions = Tools.extend(defaultOptions, defaultOverrideOptions, sectionResult.options(), isOnMobile(isMobileDevice, sectionResult) ? getSection(sectionResult, 'mobile') : {}, { external_plugins: getExternalPlugins(defaultOverrideOptions, sectionResult.options()) });\n return processPlugins(isMobileDevice, sectionResult, defaultOverrideOptions, extendedOptions);\n };\n const normalizeOptions = (defaultOverrideOptions, options) => combineOptions(isPhone || isTablet, isPhone, options, defaultOverrideOptions, options);\n\n const addVisual = (editor, elm) => addVisual$1(editor, elm);\n\n const registerExecCommands$3 = editor => {\n const toggleFormat = (name, value) => {\n editor.formatter.toggle(name, value);\n editor.nodeChanged();\n };\n const toggleAlign = align => () => {\n each$e('left,center,right,justify'.split(','), name => {\n if (align !== name) {\n editor.formatter.remove('align' + name);\n }\n });\n if (align !== 'none') {\n toggleFormat('align' + align);\n }\n };\n editor.editorCommands.addCommands({\n JustifyLeft: toggleAlign('left'),\n JustifyCenter: toggleAlign('center'),\n JustifyRight: toggleAlign('right'),\n JustifyFull: toggleAlign('justify'),\n JustifyNone: toggleAlign('none')\n });\n };\n const registerQueryStateCommands$1 = editor => {\n const alignStates = name => () => {\n const selection = editor.selection;\n const nodes = selection.isCollapsed() ? [editor.dom.getParent(selection.getNode(), editor.dom.isBlock)] : selection.getSelectedBlocks();\n return exists(nodes, node => isNonNullable(editor.formatter.matchNode(node, name)));\n };\n editor.editorCommands.addCommands({\n JustifyLeft: alignStates('alignleft'),\n JustifyCenter: alignStates('aligncenter'),\n JustifyRight: alignStates('alignright'),\n JustifyFull: alignStates('alignjustify')\n }, 'state');\n };\n const registerCommands$b = editor => {\n registerExecCommands$3(editor);\n registerQueryStateCommands$1(editor);\n };\n\n const registerCommands$a = editor => {\n editor.editorCommands.addCommands({\n 'Cut,Copy,Paste': command => {\n const doc = editor.getDoc();\n let failed;\n try {\n doc.execCommand(command);\n } catch (ex) {\n failed = true;\n }\n if (command === 'paste' && !doc.queryCommandEnabled(command)) {\n failed = true;\n }\n if (failed || !doc.queryCommandSupported(command)) {\n let msg = editor.translate(`Your browser doesn't support direct access to the clipboard. ` + 'Please use the Ctrl+X/C/V keyboard shortcuts instead.');\n if (Env.os.isMacOS() || Env.os.isiOS()) {\n msg = msg.replace(/Ctrl\\+/g, '\\u2318+');\n }\n editor.notificationManager.open({\n text: msg,\n type: 'error'\n });\n }\n }\n });\n };\n\n const trimOrPadLeftRight = (dom, rng, html, schema) => {\n const root = SugarElement.fromDom(dom.getRoot());\n if (needsToBeNbspLeft(root, CaretPosition.fromRangeStart(rng), schema)) {\n html = html.replace(/^ /, ' ');\n } else {\n html = html.replace(/^ /, ' ');\n }\n if (needsToBeNbspRight(root, CaretPosition.fromRangeEnd(rng), schema)) {\n html = html.replace(/( | )()?$/, ' ');\n } else {\n html = html.replace(/ ()?$/, ' ');\n }\n return html;\n };\n\n const processValue$1 = value => {\n if (typeof value !== 'string') {\n const details = Tools.extend({\n paste: value.paste,\n data: { paste: value.paste }\n }, value);\n return {\n content: value.content,\n details\n };\n }\n return {\n content: value,\n details: {}\n };\n };\n const trimOrPad = (editor, value) => {\n const selection = editor.selection;\n const dom = editor.dom;\n if (/^ | $/.test(value)) {\n return trimOrPadLeftRight(dom, selection.getRng(), value, editor.schema);\n } else {\n return value;\n }\n };\n const insertAtCaret = (editor, value) => {\n if (editor.selection.isEditable()) {\n const {content, details} = processValue$1(value);\n preProcessSetContent(editor, {\n ...details,\n content: trimOrPad(editor, content),\n format: 'html',\n set: false,\n selection: true\n }).each(args => {\n const insertedContent = insertContent$1(editor, args.content, details);\n postProcessSetContent(editor, insertedContent, args);\n editor.addVisual();\n });\n }\n };\n\n const registerCommands$9 = editor => {\n editor.editorCommands.addCommands({\n mceCleanup: () => {\n const bm = editor.selection.getBookmark();\n editor.setContent(editor.getContent());\n editor.selection.moveToBookmark(bm);\n },\n insertImage: (_command, _ui, value) => {\n insertAtCaret(editor, editor.dom.createHTML('img', { src: value }));\n },\n insertHorizontalRule: () => {\n editor.execCommand('mceInsertContent', false, '
    ');\n },\n insertText: (_command, _ui, value) => {\n insertAtCaret(editor, editor.dom.encode(value));\n },\n insertHTML: (_command, _ui, value) => {\n insertAtCaret(editor, value);\n },\n mceInsertContent: (_command, _ui, value) => {\n insertAtCaret(editor, value);\n },\n mceSetContent: (_command, _ui, value) => {\n editor.setContent(value);\n },\n mceReplaceContent: (_command, _ui, value) => {\n editor.execCommand('mceInsertContent', false, value.replace(/\\{\\$selection\\}/g, editor.selection.getContent({ format: 'text' })));\n },\n mceNewDocument: () => {\n editor.setContent(getNewDocumentContent(editor));\n }\n });\n };\n\n const legacyPropNames = {\n 'font-size': 'size',\n 'font-family': 'face'\n };\n const isFont = isTag('font');\n const getSpecifiedFontProp = (propName, rootElm, elm) => {\n const getProperty = elm => getRaw(elm, propName).orThunk(() => {\n if (isFont(elm)) {\n return get$a(legacyPropNames, propName).bind(legacyPropName => getOpt(elm, legacyPropName));\n } else {\n return Optional.none();\n }\n });\n const isRoot = elm => eq(SugarElement.fromDom(rootElm), elm);\n return closest$1(SugarElement.fromDom(elm), elm => getProperty(elm), isRoot);\n };\n const normalizeFontFamily = fontFamily => fontFamily.replace(/[\\'\\\"\\\\]/g, '').replace(/,\\s+/g, ',');\n const getComputedFontProp = (propName, elm) => Optional.from(DOMUtils.DOM.getStyle(elm, propName, true));\n const getFontProp = propName => (rootElm, elm) => Optional.from(elm).map(SugarElement.fromDom).filter(isElement$7).bind(element => getSpecifiedFontProp(propName, rootElm, element.dom).or(getComputedFontProp(propName, element.dom))).getOr('');\n const getFontSize = getFontProp('font-size');\n const getFontFamily = compose(normalizeFontFamily, getFontProp('font-family'));\n\n const findFirstCaretElement = editor => firstPositionIn(editor.getBody()).bind(caret => {\n const container = caret.container();\n return Optional.from(isText$a(container) ? container.parentNode : container);\n });\n const getCaretElement = editor => Optional.from(editor.selection.getRng()).bind(rng => {\n const root = editor.getBody();\n const atStartOfNode = rng.startContainer === root && rng.startOffset === 0;\n return atStartOfNode ? Optional.none() : Optional.from(editor.selection.getStart(true));\n });\n const bindRange = (editor, binder) => getCaretElement(editor).orThunk(curry(findFirstCaretElement, editor)).map(SugarElement.fromDom).filter(isElement$7).bind(binder);\n const mapRange = (editor, mapper) => bindRange(editor, compose1(Optional.some, mapper));\n\n const fromFontSizeNumber = (editor, value) => {\n if (/^[0-9.]+$/.test(value)) {\n const fontSizeNumber = parseInt(value, 10);\n if (fontSizeNumber >= 1 && fontSizeNumber <= 7) {\n const fontSizes = getFontStyleValues(editor);\n const fontClasses = getFontSizeClasses(editor);\n if (fontClasses.length > 0) {\n return fontClasses[fontSizeNumber - 1] || value;\n } else {\n return fontSizes[fontSizeNumber - 1] || value;\n }\n } else {\n return value;\n }\n } else {\n return value;\n }\n };\n const normalizeFontNames = font => {\n const fonts = font.split(/\\s*,\\s*/);\n return map$3(fonts, font => {\n if (font.indexOf(' ') !== -1 && !(startsWith(font, '\"') || startsWith(font, `'`))) {\n return `'${ font }'`;\n } else {\n return font;\n }\n }).join(',');\n };\n const fontNameAction = (editor, value) => {\n const font = fromFontSizeNumber(editor, value);\n editor.formatter.toggle('fontname', { value: normalizeFontNames(font) });\n editor.nodeChanged();\n };\n const fontNameQuery = editor => mapRange(editor, elm => getFontFamily(editor.getBody(), elm.dom)).getOr('');\n const fontSizeAction = (editor, value) => {\n editor.formatter.toggle('fontsize', { value: fromFontSizeNumber(editor, value) });\n editor.nodeChanged();\n };\n const fontSizeQuery = editor => mapRange(editor, elm => getFontSize(editor.getBody(), elm.dom)).getOr('');\n\n const lineHeightQuery = editor => mapRange(editor, elm => {\n const root = SugarElement.fromDom(editor.getBody());\n const specifiedStyle = closest$1(elm, elm => getRaw(elm, 'line-height'), curry(eq, root));\n const computedStyle = () => {\n const lineHeight = parseFloat(get$7(elm, 'line-height'));\n const fontSize = parseFloat(get$7(elm, 'font-size'));\n return String(lineHeight / fontSize);\n };\n return specifiedStyle.getOrThunk(computedStyle);\n }).getOr('');\n const lineHeightAction = (editor, lineHeight) => {\n editor.formatter.toggle('lineheight', { value: String(lineHeight) });\n editor.nodeChanged();\n };\n\n const registerExecCommands$2 = editor => {\n const toggleFormat = (name, value) => {\n editor.formatter.toggle(name, value);\n editor.nodeChanged();\n };\n editor.editorCommands.addCommands({\n 'Bold,Italic,Underline,Strikethrough,Superscript,Subscript': command => {\n toggleFormat(command);\n },\n 'ForeColor,HiliteColor': (command, _ui, value) => {\n toggleFormat(command, { value });\n },\n 'BackColor': (_command, _ui, value) => {\n toggleFormat('hilitecolor', { value });\n },\n 'FontName': (_command, _ui, value) => {\n fontNameAction(editor, value);\n },\n 'FontSize': (_command, _ui, value) => {\n fontSizeAction(editor, value);\n },\n 'LineHeight': (_command, _ui, value) => {\n lineHeightAction(editor, value);\n },\n 'Lang': (command, _ui, lang) => {\n var _a;\n toggleFormat(command, {\n value: lang.code,\n customValue: (_a = lang.customCode) !== null && _a !== void 0 ? _a : null\n });\n },\n 'RemoveFormat': command => {\n editor.formatter.remove(command);\n },\n 'mceBlockQuote': () => {\n toggleFormat('blockquote');\n },\n 'FormatBlock': (_command, _ui, value) => {\n toggleFormat(isString(value) ? value : 'p');\n },\n 'mceToggleFormat': (_command, _ui, value) => {\n toggleFormat(value);\n }\n });\n };\n const registerQueryValueCommands = editor => {\n const isFormatMatch = name => editor.formatter.match(name);\n editor.editorCommands.addCommands({\n 'Bold,Italic,Underline,Strikethrough,Superscript,Subscript': command => isFormatMatch(command),\n 'mceBlockQuote': () => isFormatMatch('blockquote')\n }, 'state');\n editor.editorCommands.addQueryValueHandler('FontName', () => fontNameQuery(editor));\n editor.editorCommands.addQueryValueHandler('FontSize', () => fontSizeQuery(editor));\n editor.editorCommands.addQueryValueHandler('LineHeight', () => lineHeightQuery(editor));\n };\n const registerCommands$8 = editor => {\n registerExecCommands$2(editor);\n registerQueryValueCommands(editor);\n };\n\n const registerCommands$7 = editor => {\n editor.editorCommands.addCommands({\n mceAddUndoLevel: () => {\n editor.undoManager.add();\n },\n mceEndUndoLevel: () => {\n editor.undoManager.add();\n },\n Undo: () => {\n editor.undoManager.undo();\n },\n Redo: () => {\n editor.undoManager.redo();\n }\n });\n };\n\n const registerCommands$6 = editor => {\n editor.editorCommands.addCommands({\n Indent: () => {\n indent(editor);\n },\n Outdent: () => {\n outdent(editor);\n }\n });\n editor.editorCommands.addCommands({ Outdent: () => canOutdent(editor) }, 'state');\n };\n\n const registerCommands$5 = editor => {\n const applyLinkToSelection = (_command, _ui, value) => {\n const linkDetails = isString(value) ? { href: value } : value;\n const anchor = editor.dom.getParent(editor.selection.getNode(), 'a');\n if (isObject(linkDetails) && isString(linkDetails.href)) {\n linkDetails.href = linkDetails.href.replace(/ /g, '%20');\n if (!anchor || !linkDetails.href) {\n editor.formatter.remove('link');\n }\n if (linkDetails.href) {\n editor.formatter.apply('link', linkDetails, anchor);\n }\n }\n };\n editor.editorCommands.addCommands({\n unlink: () => {\n if (editor.selection.isEditable()) {\n if (editor.selection.isCollapsed()) {\n const elm = editor.dom.getParent(editor.selection.getStart(), 'a');\n if (elm) {\n editor.dom.remove(elm, true);\n }\n return;\n }\n editor.formatter.remove('link');\n }\n },\n mceInsertLink: applyLinkToSelection,\n createLink: applyLinkToSelection\n });\n };\n\n const registerExecCommands$1 = editor => {\n editor.editorCommands.addCommands({\n 'InsertUnorderedList,InsertOrderedList': command => {\n editor.getDoc().execCommand(command);\n const listElm = editor.dom.getParent(editor.selection.getNode(), 'ol,ul');\n if (listElm) {\n const listParent = listElm.parentNode;\n if (listParent && /^(H[1-6]|P|ADDRESS|PRE)$/.test(listParent.nodeName)) {\n const bm = editor.selection.getBookmark();\n editor.dom.split(listParent, listElm);\n editor.selection.moveToBookmark(bm);\n }\n }\n }\n });\n };\n const registerQueryStateCommands = editor => {\n editor.editorCommands.addCommands({\n 'InsertUnorderedList,InsertOrderedList': command => {\n const list = editor.dom.getParent(editor.selection.getNode(), 'ul,ol');\n return list && (command === 'insertunorderedlist' && list.tagName === 'UL' || command === 'insertorderedlist' && list.tagName === 'OL');\n }\n }, 'state');\n };\n const registerCommands$4 = editor => {\n registerExecCommands$1(editor);\n registerQueryStateCommands(editor);\n };\n\n const getTopParentBlock = (editor, node, root, container) => {\n const dom = editor.dom;\n const selector = node => dom.isBlock(node) && node.parentElement === root;\n const topParentBlock = selector(node) ? node : dom.getParent(container, selector, root);\n return Optional.from(topParentBlock).map(SugarElement.fromDom);\n };\n const insert = (editor, before) => {\n const dom = editor.dom;\n const rng = editor.selection.getRng();\n const node = before ? editor.selection.getStart() : editor.selection.getEnd();\n const container = before ? rng.startContainer : rng.endContainer;\n const root = getEditableRoot(dom, container);\n if (!root || !root.isContentEditable) {\n return;\n }\n const insertFn = before ? before$3 : after$4;\n const newBlockName = getForcedRootBlock(editor);\n getTopParentBlock(editor, node, root, container).each(parentBlock => {\n const newBlock = createNewBlock(editor, container, parentBlock.dom, root, false, newBlockName);\n insertFn(parentBlock, SugarElement.fromDom(newBlock));\n editor.selection.setCursorLocation(newBlock, 0);\n editor.dispatch('NewBlock', { newBlock });\n fireInputEvent(editor, 'insertParagraph');\n });\n };\n const insertBefore = editor => insert(editor, true);\n const insertAfter = editor => insert(editor, false);\n\n const registerCommands$3 = editor => {\n editor.editorCommands.addCommands({\n InsertNewBlockBefore: () => {\n insertBefore(editor);\n },\n InsertNewBlockAfter: () => {\n insertAfter(editor);\n }\n });\n };\n\n const registerCommands$2 = editor => {\n editor.editorCommands.addCommands({\n insertParagraph: () => {\n insertBreak(blockbreak, editor);\n },\n mceInsertNewLine: (_command, _ui, value) => {\n insert$1(editor, value);\n },\n InsertLineBreak: (_command, _ui, _value) => {\n insertBreak(linebreak, editor);\n }\n });\n };\n\n const registerCommands$1 = editor => {\n editor.editorCommands.addCommands({\n mceSelectNodeDepth: (_command, _ui, value) => {\n let counter = 0;\n editor.dom.getParent(editor.selection.getNode(), node => {\n if (isElement$6(node) && counter++ === value) {\n editor.selection.select(node);\n return false;\n } else {\n return true;\n }\n }, editor.getBody());\n },\n mceSelectNode: (_command, _ui, value) => {\n editor.selection.select(value);\n },\n selectAll: () => {\n const editingHost = editor.dom.getParent(editor.selection.getStart(), isContentEditableTrue$3);\n if (editingHost) {\n const rng = editor.dom.createRng();\n rng.selectNodeContents(editingHost);\n editor.selection.setRng(rng);\n }\n }\n });\n };\n\n const registerExecCommands = editor => {\n editor.editorCommands.addCommands({\n mceRemoveNode: (_command, _ui, value) => {\n const node = value !== null && value !== void 0 ? value : editor.selection.getNode();\n if (node !== editor.getBody()) {\n const bm = editor.selection.getBookmark();\n editor.dom.remove(node, true);\n editor.selection.moveToBookmark(bm);\n }\n },\n mcePrint: () => {\n editor.getWin().print();\n },\n mceFocus: (_command, _ui, value) => {\n focus(editor, value === true);\n },\n mceToggleVisualAid: () => {\n editor.hasVisual = !editor.hasVisual;\n editor.addVisual();\n }\n });\n };\n const registerCommands = editor => {\n registerCommands$b(editor);\n registerCommands$a(editor);\n registerCommands$7(editor);\n registerCommands$1(editor);\n registerCommands$9(editor);\n registerCommands$5(editor);\n registerCommands$6(editor);\n registerCommands$3(editor);\n registerCommands$2(editor);\n registerCommands$4(editor);\n registerCommands$8(editor);\n registerExecCommands(editor);\n };\n\n const selectionSafeCommands = ['toggleview'];\n const isSelectionSafeCommand = command => contains$2(selectionSafeCommands, command.toLowerCase());\n class EditorCommands {\n constructor(editor) {\n this.commands = {\n state: {},\n exec: {},\n value: {}\n };\n this.editor = editor;\n }\n execCommand(command, ui = false, value, args) {\n const editor = this.editor;\n const lowerCaseCommand = command.toLowerCase();\n const skipFocus = args === null || args === void 0 ? void 0 : args.skip_focus;\n if (editor.removed) {\n return false;\n }\n if (lowerCaseCommand !== 'mcefocus') {\n if (!/^(mceAddUndoLevel|mceEndUndoLevel)$/i.test(lowerCaseCommand) && !skipFocus) {\n editor.focus();\n } else {\n restore(editor);\n }\n }\n const eventArgs = editor.dispatch('BeforeExecCommand', {\n command,\n ui,\n value\n });\n if (eventArgs.isDefaultPrevented()) {\n return false;\n }\n const func = this.commands.exec[lowerCaseCommand];\n if (isFunction(func)) {\n func(lowerCaseCommand, ui, value);\n editor.dispatch('ExecCommand', {\n command,\n ui,\n value\n });\n return true;\n }\n return false;\n }\n queryCommandState(command) {\n if (!isSelectionSafeCommand(command) && this.editor.quirks.isHidden() || this.editor.removed) {\n return false;\n }\n const lowerCaseCommand = command.toLowerCase();\n const func = this.commands.state[lowerCaseCommand];\n if (isFunction(func)) {\n return func(lowerCaseCommand);\n }\n return false;\n }\n queryCommandValue(command) {\n if (!isSelectionSafeCommand(command) && this.editor.quirks.isHidden() || this.editor.removed) {\n return '';\n }\n const lowerCaseCommand = command.toLowerCase();\n const func = this.commands.value[lowerCaseCommand];\n if (isFunction(func)) {\n return func(lowerCaseCommand);\n }\n return '';\n }\n addCommands(commandList, type = 'exec') {\n const commands = this.commands;\n each$d(commandList, (callback, command) => {\n each$e(command.toLowerCase().split(','), command => {\n commands[type][command] = callback;\n });\n });\n }\n addCommand(command, callback, scope) {\n const lowerCaseCommand = command.toLowerCase();\n this.commands.exec[lowerCaseCommand] = (_command, ui, value) => callback.call(scope !== null && scope !== void 0 ? scope : this.editor, ui, value);\n }\n queryCommandSupported(command) {\n const lowerCaseCommand = command.toLowerCase();\n if (this.commands.exec[lowerCaseCommand]) {\n return true;\n } else {\n return false;\n }\n }\n addQueryStateHandler(command, callback, scope) {\n this.commands.state[command.toLowerCase()] = () => callback.call(scope !== null && scope !== void 0 ? scope : this.editor);\n }\n addQueryValueHandler(command, callback, scope) {\n this.commands.value[command.toLowerCase()] = () => callback.call(scope !== null && scope !== void 0 ? scope : this.editor);\n }\n }\n\n const internalContentEditableAttr = 'data-mce-contenteditable';\n const toggleClass = (elm, cls, state) => {\n if (has(elm, cls) && !state) {\n remove$7(elm, cls);\n } else if (state) {\n add$2(elm, cls);\n }\n };\n const setEditorCommandState = (editor, cmd, state) => {\n try {\n editor.getDoc().execCommand(cmd, false, String(state));\n } catch (ex) {\n }\n };\n const setContentEditable = (elm, state) => {\n elm.dom.contentEditable = state ? 'true' : 'false';\n };\n const switchOffContentEditableTrue = elm => {\n each$e(descendants(elm, '*[contenteditable=\"true\"]'), elm => {\n set$3(elm, internalContentEditableAttr, 'true');\n setContentEditable(elm, false);\n });\n };\n const switchOnContentEditableTrue = elm => {\n each$e(descendants(elm, `*[${ internalContentEditableAttr }=\"true\"]`), elm => {\n remove$a(elm, internalContentEditableAttr);\n setContentEditable(elm, true);\n });\n };\n const removeFakeSelection = editor => {\n Optional.from(editor.selection.getNode()).each(elm => {\n elm.removeAttribute('data-mce-selected');\n });\n };\n const restoreFakeSelection = editor => {\n editor.selection.setRng(editor.selection.getRng());\n };\n const toggleReadOnly = (editor, state) => {\n const body = SugarElement.fromDom(editor.getBody());\n toggleClass(body, 'mce-content-readonly', state);\n if (state) {\n editor.selection.controlSelection.hideResizeRect();\n editor._selectionOverrides.hideFakeCaret();\n removeFakeSelection(editor);\n editor.readonly = true;\n setContentEditable(body, false);\n switchOffContentEditableTrue(body);\n } else {\n editor.readonly = false;\n if (editor.hasEditableRoot()) {\n setContentEditable(body, true);\n }\n switchOnContentEditableTrue(body);\n setEditorCommandState(editor, 'StyleWithCSS', false);\n setEditorCommandState(editor, 'enableInlineTableEditing', false);\n setEditorCommandState(editor, 'enableObjectResizing', false);\n if (hasEditorOrUiFocus(editor)) {\n editor.focus();\n }\n restoreFakeSelection(editor);\n editor.nodeChanged();\n }\n };\n const isReadOnly = editor => editor.readonly;\n const registerFilters = editor => {\n editor.parser.addAttributeFilter('contenteditable', nodes => {\n if (isReadOnly(editor)) {\n each$e(nodes, node => {\n node.attr(internalContentEditableAttr, node.attr('contenteditable'));\n node.attr('contenteditable', 'false');\n });\n }\n });\n editor.serializer.addAttributeFilter(internalContentEditableAttr, nodes => {\n if (isReadOnly(editor)) {\n each$e(nodes, node => {\n node.attr('contenteditable', node.attr(internalContentEditableAttr));\n });\n }\n });\n editor.serializer.addTempAttr(internalContentEditableAttr);\n };\n const registerReadOnlyContentFilters = editor => {\n if (editor.serializer) {\n registerFilters(editor);\n } else {\n editor.on('PreInit', () => {\n registerFilters(editor);\n });\n }\n };\n const isClickEvent = e => e.type === 'click';\n const allowedEvents = ['copy'];\n const isReadOnlyAllowedEvent = e => contains$2(allowedEvents, e.type);\n const getAnchorHrefOpt = (editor, elm) => {\n const isRoot = elm => eq(elm, SugarElement.fromDom(editor.getBody()));\n return closest$3(elm, 'a', isRoot).bind(a => getOpt(a, 'href'));\n };\n const processReadonlyEvents = (editor, e) => {\n if (isClickEvent(e) && !VK.metaKeyPressed(e)) {\n const elm = SugarElement.fromDom(e.target);\n getAnchorHrefOpt(editor, elm).each(href => {\n e.preventDefault();\n if (/^#/.test(href)) {\n const targetEl = editor.dom.select(`${ href },[name=\"${ removeLeading(href, '#') }\"]`);\n if (targetEl.length) {\n editor.selection.scrollIntoView(targetEl[0], true);\n }\n } else {\n window.open(href, '_blank', 'rel=noopener noreferrer,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes');\n }\n });\n } else if (isReadOnlyAllowedEvent(e)) {\n editor.dispatch(e.type, e);\n }\n };\n const registerReadOnlySelectionBlockers = editor => {\n editor.on('ShowCaret', e => {\n if (isReadOnly(editor)) {\n e.preventDefault();\n }\n });\n editor.on('ObjectSelected', e => {\n if (isReadOnly(editor)) {\n e.preventDefault();\n }\n });\n };\n\n const nativeEvents = Tools.makeMap('focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange ' + 'mouseout mouseenter mouseleave wheel keydown keypress keyup input beforeinput contextmenu dragstart dragend dragover ' + 'draggesture dragdrop drop drag submit ' + 'compositionstart compositionend compositionupdate touchstart touchmove touchend touchcancel', ' ');\n class EventDispatcher {\n static isNative(name) {\n return !!nativeEvents[name.toLowerCase()];\n }\n constructor(settings) {\n this.bindings = {};\n this.settings = settings || {};\n this.scope = this.settings.scope || this;\n this.toggleEvent = this.settings.toggleEvent || never;\n }\n fire(name, args) {\n return this.dispatch(name, args);\n }\n dispatch(name, args) {\n const lcName = name.toLowerCase();\n const event = normalize$3(lcName, args !== null && args !== void 0 ? args : {}, this.scope);\n if (this.settings.beforeFire) {\n this.settings.beforeFire(event);\n }\n const handlers = this.bindings[lcName];\n if (handlers) {\n for (let i = 0, l = handlers.length; i < l; i++) {\n const callback = handlers[i];\n if (callback.removed) {\n continue;\n }\n if (callback.once) {\n this.off(lcName, callback.func);\n }\n if (event.isImmediatePropagationStopped()) {\n return event;\n }\n if (callback.func.call(this.scope, event) === false) {\n event.preventDefault();\n return event;\n }\n }\n }\n return event;\n }\n on(name, callback, prepend, extra) {\n if (callback === false) {\n callback = never;\n }\n if (callback) {\n const wrappedCallback = {\n func: callback,\n removed: false\n };\n if (extra) {\n Tools.extend(wrappedCallback, extra);\n }\n const names = name.toLowerCase().split(' ');\n let i = names.length;\n while (i--) {\n const currentName = names[i];\n let handlers = this.bindings[currentName];\n if (!handlers) {\n handlers = [];\n this.toggleEvent(currentName, true);\n }\n if (prepend) {\n handlers = [\n wrappedCallback,\n ...handlers\n ];\n } else {\n handlers = [\n ...handlers,\n wrappedCallback\n ];\n }\n this.bindings[currentName] = handlers;\n }\n }\n return this;\n }\n off(name, callback) {\n if (name) {\n const names = name.toLowerCase().split(' ');\n let i = names.length;\n while (i--) {\n const currentName = names[i];\n let handlers = this.bindings[currentName];\n if (!currentName) {\n each$d(this.bindings, (_value, bindingName) => {\n this.toggleEvent(bindingName, false);\n delete this.bindings[bindingName];\n });\n return this;\n }\n if (handlers) {\n if (!callback) {\n handlers.length = 0;\n } else {\n const filteredHandlers = partition$2(handlers, handler => handler.func === callback);\n handlers = filteredHandlers.fail;\n this.bindings[currentName] = handlers;\n each$e(filteredHandlers.pass, handler => {\n handler.removed = true;\n });\n }\n if (!handlers.length) {\n this.toggleEvent(name, false);\n delete this.bindings[currentName];\n }\n }\n }\n } else {\n each$d(this.bindings, (_value, name) => {\n this.toggleEvent(name, false);\n });\n this.bindings = {};\n }\n return this;\n }\n once(name, callback, prepend) {\n return this.on(name, callback, prepend, { once: true });\n }\n has(name) {\n name = name.toLowerCase();\n const binding = this.bindings[name];\n return !(!binding || binding.length === 0);\n }\n }\n\n const getEventDispatcher = obj => {\n if (!obj._eventDispatcher) {\n obj._eventDispatcher = new EventDispatcher({\n scope: obj,\n toggleEvent: (name, state) => {\n if (EventDispatcher.isNative(name) && obj.toggleNativeEvent) {\n obj.toggleNativeEvent(name, state);\n }\n }\n });\n }\n return obj._eventDispatcher;\n };\n const Observable = {\n fire(name, args, bubble) {\n return this.dispatch(name, args, bubble);\n },\n dispatch(name, args, bubble) {\n const self = this;\n if (self.removed && name !== 'remove' && name !== 'detach') {\n return normalize$3(name.toLowerCase(), args !== null && args !== void 0 ? args : {}, self);\n }\n const dispatcherArgs = getEventDispatcher(self).dispatch(name, args);\n if (bubble !== false && self.parent) {\n let parent = self.parent();\n while (parent && !dispatcherArgs.isPropagationStopped()) {\n parent.dispatch(name, dispatcherArgs, false);\n parent = parent.parent ? parent.parent() : undefined;\n }\n }\n return dispatcherArgs;\n },\n on(name, callback, prepend) {\n return getEventDispatcher(this).on(name, callback, prepend);\n },\n off(name, callback) {\n return getEventDispatcher(this).off(name, callback);\n },\n once(name, callback) {\n return getEventDispatcher(this).once(name, callback);\n },\n hasEventListeners(name) {\n return getEventDispatcher(this).has(name);\n }\n };\n\n const DOM$2 = DOMUtils.DOM;\n let customEventRootDelegates;\n const getEventTarget = (editor, eventName) => {\n if (eventName === 'selectionchange') {\n return editor.getDoc();\n }\n if (!editor.inline && /^(?:mouse|touch|click|contextmenu|drop|dragover|dragend)/.test(eventName)) {\n return editor.getDoc().documentElement;\n }\n const eventRoot = getEventRoot(editor);\n if (eventRoot) {\n if (!editor.eventRoot) {\n editor.eventRoot = DOM$2.select(eventRoot)[0];\n }\n return editor.eventRoot;\n }\n return editor.getBody();\n };\n const isListening = editor => !editor.hidden && !isReadOnly(editor);\n const fireEvent = (editor, eventName, e) => {\n if (isListening(editor)) {\n editor.dispatch(eventName, e);\n } else if (isReadOnly(editor)) {\n processReadonlyEvents(editor, e);\n }\n };\n const bindEventDelegate = (editor, eventName) => {\n if (!editor.delegates) {\n editor.delegates = {};\n }\n if (editor.delegates[eventName] || editor.removed) {\n return;\n }\n const eventRootElm = getEventTarget(editor, eventName);\n if (getEventRoot(editor)) {\n if (!customEventRootDelegates) {\n customEventRootDelegates = {};\n editor.editorManager.on('removeEditor', () => {\n if (!editor.editorManager.activeEditor) {\n if (customEventRootDelegates) {\n each$d(customEventRootDelegates, (_value, name) => {\n editor.dom.unbind(getEventTarget(editor, name));\n });\n customEventRootDelegates = null;\n }\n }\n });\n }\n if (customEventRootDelegates[eventName]) {\n return;\n }\n const delegate = e => {\n const target = e.target;\n const editors = editor.editorManager.get();\n let i = editors.length;\n while (i--) {\n const body = editors[i].getBody();\n if (body === target || DOM$2.isChildOf(target, body)) {\n fireEvent(editors[i], eventName, e);\n }\n }\n };\n customEventRootDelegates[eventName] = delegate;\n DOM$2.bind(eventRootElm, eventName, delegate);\n } else {\n const delegate = e => {\n fireEvent(editor, eventName, e);\n };\n DOM$2.bind(eventRootElm, eventName, delegate);\n editor.delegates[eventName] = delegate;\n }\n };\n const EditorObservable = {\n ...Observable,\n bindPendingEventDelegates() {\n const self = this;\n Tools.each(self._pendingNativeEvents, name => {\n bindEventDelegate(self, name);\n });\n },\n toggleNativeEvent(name, state) {\n const self = this;\n if (name === 'focus' || name === 'blur') {\n return;\n }\n if (self.removed) {\n return;\n }\n if (state) {\n if (self.initialized) {\n bindEventDelegate(self, name);\n } else {\n if (!self._pendingNativeEvents) {\n self._pendingNativeEvents = [name];\n } else {\n self._pendingNativeEvents.push(name);\n }\n }\n } else if (self.initialized && self.delegates) {\n self.dom.unbind(getEventTarget(self, name), name, self.delegates[name]);\n delete self.delegates[name];\n }\n },\n unbindAllNativeEvents() {\n const self = this;\n const body = self.getBody();\n const dom = self.dom;\n if (self.delegates) {\n each$d(self.delegates, (value, name) => {\n self.dom.unbind(getEventTarget(self, name), name, value);\n });\n delete self.delegates;\n }\n if (!self.inline && body && dom) {\n body.onload = null;\n dom.unbind(self.getWin());\n dom.unbind(self.getDoc());\n }\n if (dom) {\n dom.unbind(body);\n dom.unbind(self.getContainer());\n }\n }\n };\n\n const stringListProcessor = value => {\n if (isString(value)) {\n return {\n value: value.split(/[ ,]/),\n valid: true\n };\n } else if (isArrayOf(value, isString)) {\n return {\n value,\n valid: true\n };\n } else {\n return {\n valid: false,\n message: `The value must be a string[] or a comma/space separated string.`\n };\n }\n };\n const getBuiltInProcessor = type => {\n const validator = (() => {\n switch (type) {\n case 'array':\n return isArray$1;\n case 'boolean':\n return isBoolean;\n case 'function':\n return isFunction;\n case 'number':\n return isNumber;\n case 'object':\n return isObject;\n case 'string':\n return isString;\n case 'string[]':\n return stringListProcessor;\n case 'object[]':\n return val => isArrayOf(val, isObject);\n case 'regexp':\n return val => is$4(val, RegExp);\n default:\n return always;\n }\n })();\n return value => processValue(value, validator, `The value must be a ${ type }.`);\n };\n const isBuiltInSpec = spec => isString(spec.processor);\n const getErrorMessage = (message, result) => {\n const additionalText = isEmpty$3(result.message) ? '' : `. ${ result.message }`;\n return message + additionalText;\n };\n const isValidResult = result => result.valid;\n const processValue = (value, processor, message = '') => {\n const result = processor(value);\n if (isBoolean(result)) {\n return result ? {\n value: value,\n valid: true\n } : {\n valid: false,\n message\n };\n } else {\n return result;\n }\n };\n const processDefaultValue = (name, defaultValue, processor) => {\n if (!isUndefined(defaultValue)) {\n const result = processValue(defaultValue, processor);\n if (isValidResult(result)) {\n return result.value;\n } else {\n console.error(getErrorMessage(`Invalid default value passed for the \"${ name }\" option`, result));\n }\n }\n return undefined;\n };\n const create$5 = (editor, initialOptions) => {\n const registry = {};\n const values = {};\n const setValue = (name, value, processor) => {\n const result = processValue(value, processor);\n if (isValidResult(result)) {\n values[name] = result.value;\n return true;\n } else {\n console.warn(getErrorMessage(`Invalid value passed for the ${ name } option`, result));\n return false;\n }\n };\n const register = (name, spec) => {\n const processor = isBuiltInSpec(spec) ? getBuiltInProcessor(spec.processor) : spec.processor;\n const defaultValue = processDefaultValue(name, spec.default, processor);\n registry[name] = {\n ...spec,\n default: defaultValue,\n processor\n };\n const initValue = get$a(values, name).orThunk(() => get$a(initialOptions, name));\n initValue.each(value => setValue(name, value, processor));\n };\n const isRegistered = name => has$2(registry, name);\n const get = name => get$a(values, name).orThunk(() => get$a(registry, name).map(spec => spec.default)).getOrUndefined();\n const set = (name, value) => {\n if (!isRegistered(name)) {\n console.warn(`\"${ name }\" is not a registered option. Ensure the option has been registered before setting a value.`);\n return false;\n } else {\n const spec = registry[name];\n if (spec.immutable) {\n console.error(`\"${ name }\" is an immutable option and cannot be updated`);\n return false;\n } else {\n return setValue(name, value, spec.processor);\n }\n }\n };\n const unset = name => {\n const registered = isRegistered(name);\n if (registered) {\n delete values[name];\n }\n return registered;\n };\n const isSet = name => has$2(values, name);\n return {\n register,\n isRegistered,\n get,\n set,\n unset,\n isSet\n };\n };\n\n const defaultModes = [\n 'design',\n 'readonly'\n ];\n const switchToMode = (editor, activeMode, availableModes, mode) => {\n const oldMode = availableModes[activeMode.get()];\n const newMode = availableModes[mode];\n try {\n newMode.activate();\n } catch (e) {\n console.error(`problem while activating editor mode ${ mode }:`, e);\n return;\n }\n oldMode.deactivate();\n if (oldMode.editorReadOnly !== newMode.editorReadOnly) {\n toggleReadOnly(editor, newMode.editorReadOnly);\n }\n activeMode.set(mode);\n fireSwitchMode(editor, mode);\n };\n const setMode = (editor, availableModes, activeMode, mode) => {\n if (mode === activeMode.get()) {\n return;\n } else if (!has$2(availableModes, mode)) {\n throw new Error(`Editor mode '${ mode }' is invalid`);\n }\n if (editor.initialized) {\n switchToMode(editor, activeMode, availableModes, mode);\n } else {\n editor.on('init', () => switchToMode(editor, activeMode, availableModes, mode));\n }\n };\n const registerMode = (availableModes, mode, api) => {\n if (contains$2(defaultModes, mode)) {\n throw new Error(`Cannot override default mode ${ mode }`);\n }\n return {\n ...availableModes,\n [mode]: {\n ...api,\n deactivate: () => {\n try {\n api.deactivate();\n } catch (e) {\n console.error(`problem while deactivating editor mode ${ mode }:`, e);\n }\n }\n }\n };\n };\n\n const create$4 = editor => {\n const activeMode = Cell('design');\n const availableModes = Cell({\n design: {\n activate: noop,\n deactivate: noop,\n editorReadOnly: false\n },\n readonly: {\n activate: noop,\n deactivate: noop,\n editorReadOnly: true\n }\n });\n registerReadOnlyContentFilters(editor);\n registerReadOnlySelectionBlockers(editor);\n return {\n isReadOnly: () => isReadOnly(editor),\n set: mode => setMode(editor, availableModes.get(), activeMode, mode),\n get: () => activeMode.get(),\n register: (mode, api) => {\n availableModes.set(registerMode(availableModes.get(), mode, api));\n }\n };\n };\n\n const each$2 = Tools.each, explode = Tools.explode;\n const keyCodeLookup = {\n f1: 112,\n f2: 113,\n f3: 114,\n f4: 115,\n f5: 116,\n f6: 117,\n f7: 118,\n f8: 119,\n f9: 120,\n f10: 121,\n f11: 122,\n f12: 123\n };\n const modifierNames = Tools.makeMap('alt,ctrl,shift,meta,access');\n const isModifier = key => key in modifierNames;\n const parseShortcut = pattern => {\n const shortcut = {};\n const isMac = Env.os.isMacOS() || Env.os.isiOS();\n each$2(explode(pattern.toLowerCase(), '+'), value => {\n if (isModifier(value)) {\n shortcut[value] = true;\n } else {\n if (/^[0-9]{2,}$/.test(value)) {\n shortcut.keyCode = parseInt(value, 10);\n } else {\n shortcut.charCode = value.charCodeAt(0);\n shortcut.keyCode = keyCodeLookup[value] || value.toUpperCase().charCodeAt(0);\n }\n }\n });\n const id = [shortcut.keyCode];\n let key;\n for (key in modifierNames) {\n if (shortcut[key]) {\n id.push(key);\n } else {\n shortcut[key] = false;\n }\n }\n shortcut.id = id.join(',');\n if (shortcut.access) {\n shortcut.alt = true;\n if (isMac) {\n shortcut.ctrl = true;\n } else {\n shortcut.shift = true;\n }\n }\n if (shortcut.meta) {\n if (isMac) {\n shortcut.meta = true;\n } else {\n shortcut.ctrl = true;\n shortcut.meta = false;\n }\n }\n return shortcut;\n };\n class Shortcuts {\n constructor(editor) {\n this.shortcuts = {};\n this.pendingPatterns = [];\n this.editor = editor;\n const self = this;\n editor.on('keyup keypress keydown', e => {\n if ((self.hasModifier(e) || self.isFunctionKey(e)) && !e.isDefaultPrevented()) {\n each$2(self.shortcuts, shortcut => {\n if (self.matchShortcut(e, shortcut)) {\n self.pendingPatterns = shortcut.subpatterns.slice(0);\n if (e.type === 'keydown') {\n self.executeShortcutAction(shortcut);\n }\n }\n });\n if (self.matchShortcut(e, self.pendingPatterns[0])) {\n if (self.pendingPatterns.length === 1) {\n if (e.type === 'keydown') {\n self.executeShortcutAction(self.pendingPatterns[0]);\n }\n }\n self.pendingPatterns.shift();\n }\n }\n });\n }\n add(pattern, desc, cmdFunc, scope) {\n const self = this;\n const func = self.normalizeCommandFunc(cmdFunc);\n each$2(explode(Tools.trim(pattern)), pattern => {\n const shortcut = self.createShortcut(pattern, desc, func, scope);\n self.shortcuts[shortcut.id] = shortcut;\n });\n return true;\n }\n remove(pattern) {\n const shortcut = this.createShortcut(pattern);\n if (this.shortcuts[shortcut.id]) {\n delete this.shortcuts[shortcut.id];\n return true;\n }\n return false;\n }\n normalizeCommandFunc(cmdFunc) {\n const self = this;\n const cmd = cmdFunc;\n if (typeof cmd === 'string') {\n return () => {\n self.editor.execCommand(cmd, false, null);\n };\n } else if (Tools.isArray(cmd)) {\n return () => {\n self.editor.execCommand(cmd[0], cmd[1], cmd[2]);\n };\n } else {\n return cmd;\n }\n }\n createShortcut(pattern, desc, cmdFunc, scope) {\n const shortcuts = Tools.map(explode(pattern, '>'), parseShortcut);\n shortcuts[shortcuts.length - 1] = Tools.extend(shortcuts[shortcuts.length - 1], {\n func: cmdFunc,\n scope: scope || this.editor\n });\n return Tools.extend(shortcuts[0], {\n desc: this.editor.translate(desc),\n subpatterns: shortcuts.slice(1)\n });\n }\n hasModifier(e) {\n return e.altKey || e.ctrlKey || e.metaKey;\n }\n isFunctionKey(e) {\n return e.type === 'keydown' && e.keyCode >= 112 && e.keyCode <= 123;\n }\n matchShortcut(e, shortcut) {\n if (!shortcut) {\n return false;\n }\n if (shortcut.ctrl !== e.ctrlKey || shortcut.meta !== e.metaKey) {\n return false;\n }\n if (shortcut.alt !== e.altKey || shortcut.shift !== e.shiftKey) {\n return false;\n }\n if (e.keyCode === shortcut.keyCode || e.charCode && e.charCode === shortcut.charCode) {\n e.preventDefault();\n return true;\n }\n return false;\n }\n executeShortcutAction(shortcut) {\n return shortcut.func ? shortcut.func.call(shortcut.scope) : null;\n }\n }\n\n const create$3 = () => {\n const buttons = {};\n const menuItems = {};\n const popups = {};\n const icons = {};\n const contextMenus = {};\n const contextToolbars = {};\n const sidebars = {};\n const views = {};\n const add = (collection, type) => (name, spec) => {\n collection[name.toLowerCase()] = {\n ...spec,\n type\n };\n };\n const addIcon = (name, svgData) => icons[name.toLowerCase()] = svgData;\n return {\n addButton: add(buttons, 'button'),\n addGroupToolbarButton: add(buttons, 'grouptoolbarbutton'),\n addToggleButton: add(buttons, 'togglebutton'),\n addMenuButton: add(buttons, 'menubutton'),\n addSplitButton: add(buttons, 'splitbutton'),\n addMenuItem: add(menuItems, 'menuitem'),\n addNestedMenuItem: add(menuItems, 'nestedmenuitem'),\n addToggleMenuItem: add(menuItems, 'togglemenuitem'),\n addAutocompleter: add(popups, 'autocompleter'),\n addContextMenu: add(contextMenus, 'contextmenu'),\n addContextToolbar: add(contextToolbars, 'contexttoolbar'),\n addContextForm: add(contextToolbars, 'contextform'),\n addSidebar: add(sidebars, 'sidebar'),\n addView: add(views, 'views'),\n addIcon,\n getAll: () => ({\n buttons,\n menuItems,\n icons,\n popups,\n contextMenus,\n contextToolbars,\n sidebars,\n views\n })\n };\n };\n\n const registry = () => {\n const bridge = create$3();\n return {\n addAutocompleter: bridge.addAutocompleter,\n addButton: bridge.addButton,\n addContextForm: bridge.addContextForm,\n addContextMenu: bridge.addContextMenu,\n addContextToolbar: bridge.addContextToolbar,\n addIcon: bridge.addIcon,\n addMenuButton: bridge.addMenuButton,\n addMenuItem: bridge.addMenuItem,\n addNestedMenuItem: bridge.addNestedMenuItem,\n addSidebar: bridge.addSidebar,\n addSplitButton: bridge.addSplitButton,\n addToggleButton: bridge.addToggleButton,\n addGroupToolbarButton: bridge.addGroupToolbarButton,\n addToggleMenuItem: bridge.addToggleMenuItem,\n addView: bridge.addView,\n getAll: bridge.getAll\n };\n };\n\n const DOM$1 = DOMUtils.DOM;\n const extend = Tools.extend, each$1 = Tools.each;\n class Editor {\n constructor(id, options, editorManager) {\n this.plugins = {};\n this.contentCSS = [];\n this.contentStyles = [];\n this.loadedCSS = {};\n this.isNotDirty = false;\n this.composing = false;\n this.destroyed = false;\n this.hasHiddenInput = false;\n this.iframeElement = null;\n this.initialized = false;\n this.readonly = false;\n this.removed = false;\n this.startContent = '';\n this._pendingNativeEvents = [];\n this._skinLoaded = false;\n this._editableRoot = true;\n this.editorManager = editorManager;\n this.documentBaseUrl = editorManager.documentBaseURL;\n extend(this, EditorObservable);\n const self = this;\n this.id = id;\n this.hidden = false;\n const normalizedOptions = normalizeOptions(editorManager.defaultOptions, options);\n this.options = create$5(self, normalizedOptions);\n register$7(self);\n const getOption = this.options.get;\n if (getOption('deprecation_warnings')) {\n logWarnings(options, normalizedOptions);\n }\n const suffix = getOption('suffix');\n if (suffix) {\n editorManager.suffix = suffix;\n }\n this.suffix = editorManager.suffix;\n const baseUrl = getOption('base_url');\n if (baseUrl) {\n editorManager._setBaseUrl(baseUrl);\n }\n this.baseUri = editorManager.baseURI;\n const referrerPolicy = getReferrerPolicy(self);\n if (referrerPolicy) {\n ScriptLoader.ScriptLoader._setReferrerPolicy(referrerPolicy);\n DOMUtils.DOM.styleSheetLoader._setReferrerPolicy(referrerPolicy);\n }\n const contentCssCors = hasContentCssCors(self);\n if (isNonNullable(contentCssCors)) {\n DOMUtils.DOM.styleSheetLoader._setContentCssCors(contentCssCors);\n }\n AddOnManager.languageLoad = getOption('language_load');\n AddOnManager.baseURL = editorManager.baseURL;\n this.setDirty(false);\n this.documentBaseURI = new URI(getDocumentBaseUrl(self), { base_uri: this.baseUri });\n this.baseURI = this.baseUri;\n this.inline = isInline$1(self);\n this.hasVisual = isVisualAidsEnabled(self);\n this.shortcuts = new Shortcuts(this);\n this.editorCommands = new EditorCommands(this);\n registerCommands(this);\n const cacheSuffix = getOption('cache_suffix');\n if (cacheSuffix) {\n Env.cacheSuffix = cacheSuffix.replace(/^[\\?\\&]+/, '');\n }\n this.ui = {\n registry: registry(),\n styleSheetLoader: undefined,\n show: noop,\n hide: noop,\n setEnabled: noop,\n isEnabled: always\n };\n this.mode = create$4(self);\n editorManager.dispatch('SetupEditor', { editor: this });\n const setupCallback = getSetupCallback(self);\n if (isFunction(setupCallback)) {\n setupCallback.call(self, self);\n }\n }\n render() {\n render(this);\n }\n focus(skipFocus) {\n this.execCommand('mceFocus', false, skipFocus);\n }\n hasFocus() {\n return hasFocus(this);\n }\n translate(text) {\n return I18n.translate(text);\n }\n getParam(name, defaultVal, type) {\n const options = this.options;\n if (!options.isRegistered(name)) {\n if (isNonNullable(type)) {\n options.register(name, {\n processor: type,\n default: defaultVal\n });\n } else {\n options.register(name, {\n processor: always,\n default: defaultVal\n });\n }\n }\n return !options.isSet(name) && !isUndefined(defaultVal) ? defaultVal : options.get(name);\n }\n hasPlugin(name, loaded) {\n const hasPlugin = contains$2(getPlugins(this), name);\n if (hasPlugin) {\n return loaded ? PluginManager.get(name) !== undefined : true;\n } else {\n return false;\n }\n }\n nodeChanged(args) {\n this._nodeChangeDispatcher.nodeChanged(args);\n }\n addCommand(name, callback, scope) {\n this.editorCommands.addCommand(name, callback, scope);\n }\n addQueryStateHandler(name, callback, scope) {\n this.editorCommands.addQueryStateHandler(name, callback, scope);\n }\n addQueryValueHandler(name, callback, scope) {\n this.editorCommands.addQueryValueHandler(name, callback, scope);\n }\n addShortcut(pattern, desc, cmdFunc, scope) {\n this.shortcuts.add(pattern, desc, cmdFunc, scope);\n }\n execCommand(cmd, ui, value, args) {\n return this.editorCommands.execCommand(cmd, ui, value, args);\n }\n queryCommandState(cmd) {\n return this.editorCommands.queryCommandState(cmd);\n }\n queryCommandValue(cmd) {\n return this.editorCommands.queryCommandValue(cmd);\n }\n queryCommandSupported(cmd) {\n return this.editorCommands.queryCommandSupported(cmd);\n }\n show() {\n const self = this;\n if (self.hidden) {\n self.hidden = false;\n if (self.inline) {\n self.getBody().contentEditable = 'true';\n } else {\n DOM$1.show(self.getContainer());\n DOM$1.hide(self.id);\n }\n self.load();\n self.dispatch('show');\n }\n }\n hide() {\n const self = this;\n if (!self.hidden) {\n self.save();\n if (self.inline) {\n self.getBody().contentEditable = 'false';\n if (self === self.editorManager.focusedEditor) {\n self.editorManager.focusedEditor = null;\n }\n } else {\n DOM$1.hide(self.getContainer());\n DOM$1.setStyle(self.id, 'display', self.orgDisplay);\n }\n self.hidden = true;\n self.dispatch('hide');\n }\n }\n isHidden() {\n return this.hidden;\n }\n setProgressState(state, time) {\n this.dispatch('ProgressState', {\n state,\n time\n });\n }\n load(args = {}) {\n const self = this;\n const elm = self.getElement();\n if (self.removed) {\n return '';\n }\n if (elm) {\n const loadArgs = {\n ...args,\n load: true\n };\n const value = isTextareaOrInput(elm) ? elm.value : elm.innerHTML;\n const html = self.setContent(value, loadArgs);\n if (!loadArgs.no_events) {\n self.dispatch('LoadContent', {\n ...loadArgs,\n element: elm\n });\n }\n return html;\n } else {\n return '';\n }\n }\n save(args = {}) {\n const self = this;\n let elm = self.getElement();\n if (!elm || !self.initialized || self.removed) {\n return '';\n }\n const getArgs = {\n ...args,\n save: true,\n element: elm\n };\n let html = self.getContent(getArgs);\n const saveArgs = {\n ...getArgs,\n content: html\n };\n if (!saveArgs.no_events) {\n self.dispatch('SaveContent', saveArgs);\n }\n if (saveArgs.format === 'raw') {\n self.dispatch('RawSaveContent', saveArgs);\n }\n html = saveArgs.content;\n if (!isTextareaOrInput(elm)) {\n if (args.is_removing || !self.inline) {\n elm.innerHTML = html;\n }\n const form = DOM$1.getParent(self.id, 'form');\n if (form) {\n each$1(form.elements, elm => {\n if (elm.name === self.id) {\n elm.value = html;\n return false;\n } else {\n return true;\n }\n });\n }\n } else {\n elm.value = html;\n }\n saveArgs.element = getArgs.element = elm = null;\n if (saveArgs.set_dirty !== false) {\n self.setDirty(false);\n }\n return html;\n }\n setContent(content, args) {\n return setContent(this, content, args);\n }\n getContent(args) {\n return getContent(this, args);\n }\n insertContent(content, args) {\n if (args) {\n content = extend({ content }, args);\n }\n this.execCommand('mceInsertContent', false, content);\n }\n resetContent(initialContent) {\n if (initialContent === undefined) {\n setContent(this, this.startContent, { format: 'raw' });\n } else {\n setContent(this, initialContent);\n }\n this.undoManager.reset();\n this.setDirty(false);\n this.nodeChanged();\n }\n isDirty() {\n return !this.isNotDirty;\n }\n setDirty(state) {\n const oldState = !this.isNotDirty;\n this.isNotDirty = !state;\n if (state && state !== oldState) {\n this.dispatch('dirty');\n }\n }\n getContainer() {\n const self = this;\n if (!self.container) {\n self.container = self.editorContainer || DOM$1.get(self.id + '_parent');\n }\n return self.container;\n }\n getContentAreaContainer() {\n return this.contentAreaContainer;\n }\n getElement() {\n if (!this.targetElm) {\n this.targetElm = DOM$1.get(this.id);\n }\n return this.targetElm;\n }\n getWin() {\n const self = this;\n if (!self.contentWindow) {\n const elm = self.iframeElement;\n if (elm) {\n self.contentWindow = elm.contentWindow;\n }\n }\n return self.contentWindow;\n }\n getDoc() {\n const self = this;\n if (!self.contentDocument) {\n const win = self.getWin();\n if (win) {\n self.contentDocument = win.document;\n }\n }\n return self.contentDocument;\n }\n getBody() {\n var _a, _b;\n const doc = this.getDoc();\n return (_b = (_a = this.bodyElement) !== null && _a !== void 0 ? _a : doc === null || doc === void 0 ? void 0 : doc.body) !== null && _b !== void 0 ? _b : null;\n }\n convertURL(url, name, elm) {\n const self = this, getOption = self.options.get;\n const urlConverterCallback = getUrlConverterCallback(self);\n if (isFunction(urlConverterCallback)) {\n return urlConverterCallback.call(self, url, elm, true, name);\n }\n if (!getOption('convert_urls') || elm === 'link' || isObject(elm) && elm.nodeName === 'LINK' || url.indexOf('file:') === 0 || url.length === 0) {\n return url;\n }\n const urlObject = new URI(url);\n if (urlObject.protocol !== 'http' && urlObject.protocol !== 'https' && urlObject.protocol !== '') {\n return url;\n }\n if (getOption('relative_urls')) {\n return self.documentBaseURI.toRelative(url);\n }\n url = self.documentBaseURI.toAbsolute(url, getOption('remove_script_host'));\n return url;\n }\n addVisual(elm) {\n addVisual(this, elm);\n }\n setEditableRoot(state) {\n setEditableRoot(this, state);\n }\n hasEditableRoot() {\n return hasEditableRoot(this);\n }\n remove() {\n remove$1(this);\n }\n destroy(automatic) {\n destroy(this, automatic);\n }\n uploadImages() {\n return this.editorUpload.uploadImages();\n }\n _scanForImages() {\n return this.editorUpload.scanForImages();\n }\n }\n\n const DOM = DOMUtils.DOM;\n const each = Tools.each;\n let boundGlobalEvents = false;\n let beforeUnloadDelegate;\n let editors = [];\n const globalEventDelegate = e => {\n const type = e.type;\n each(EditorManager.get(), editor => {\n switch (type) {\n case 'scroll':\n editor.dispatch('ScrollWindow', e);\n break;\n case 'resize':\n editor.dispatch('ResizeWindow', e);\n break;\n }\n });\n };\n const toggleGlobalEvents = state => {\n if (state !== boundGlobalEvents) {\n const DOM = DOMUtils.DOM;\n if (state) {\n DOM.bind(window, 'resize', globalEventDelegate);\n DOM.bind(window, 'scroll', globalEventDelegate);\n } else {\n DOM.unbind(window, 'resize', globalEventDelegate);\n DOM.unbind(window, 'scroll', globalEventDelegate);\n }\n boundGlobalEvents = state;\n }\n };\n const removeEditorFromList = targetEditor => {\n const oldEditors = editors;\n editors = filter$5(editors, editor => {\n return targetEditor !== editor;\n });\n if (EditorManager.activeEditor === targetEditor) {\n EditorManager.activeEditor = editors.length > 0 ? editors[0] : null;\n }\n if (EditorManager.focusedEditor === targetEditor) {\n EditorManager.focusedEditor = null;\n }\n return oldEditors.length !== editors.length;\n };\n const purgeDestroyedEditor = editor => {\n if (editor && editor.initialized && !(editor.getContainer() || editor.getBody()).parentNode) {\n removeEditorFromList(editor);\n editor.unbindAllNativeEvents();\n editor.destroy(true);\n editor.removed = true;\n }\n };\n const isQuirksMode = document.compatMode !== 'CSS1Compat';\n const EditorManager = {\n ...Observable,\n baseURI: null,\n baseURL: null,\n defaultOptions: {},\n documentBaseURL: null,\n suffix: null,\n majorVersion: '6',\n minorVersion: '8.3',\n releaseDate: '2024-02-08',\n i18n: I18n,\n activeEditor: null,\n focusedEditor: null,\n setup() {\n const self = this;\n let baseURL = '';\n let suffix = '';\n let documentBaseURL = URI.getDocumentBaseUrl(document.location);\n if (/^[^:]+:\\/\\/\\/?[^\\/]+\\//.test(documentBaseURL)) {\n documentBaseURL = documentBaseURL.replace(/[\\?#].*$/, '').replace(/[\\/\\\\][^\\/]+$/, '');\n if (!/[\\/\\\\]$/.test(documentBaseURL)) {\n documentBaseURL += '/';\n }\n }\n const preInit = window.tinymce || window.tinyMCEPreInit;\n if (preInit) {\n baseURL = preInit.base || preInit.baseURL;\n suffix = preInit.suffix;\n } else {\n const scripts = document.getElementsByTagName('script');\n for (let i = 0; i < scripts.length; i++) {\n const src = scripts[i].src || '';\n if (src === '') {\n continue;\n }\n const srcScript = src.substring(src.lastIndexOf('/'));\n if (/tinymce(\\.full|\\.jquery|)(\\.min|\\.dev|)\\.js/.test(src)) {\n if (srcScript.indexOf('.min') !== -1) {\n suffix = '.min';\n }\n baseURL = src.substring(0, src.lastIndexOf('/'));\n break;\n }\n }\n if (!baseURL && document.currentScript) {\n const src = document.currentScript.src;\n if (src.indexOf('.min') !== -1) {\n suffix = '.min';\n }\n baseURL = src.substring(0, src.lastIndexOf('/'));\n }\n }\n self.baseURL = new URI(documentBaseURL).toAbsolute(baseURL);\n self.documentBaseURL = documentBaseURL;\n self.baseURI = new URI(self.baseURL);\n self.suffix = suffix;\n setup$w(self);\n },\n overrideDefaults(defaultOptions) {\n const baseUrl = defaultOptions.base_url;\n if (baseUrl) {\n this._setBaseUrl(baseUrl);\n }\n const suffix = defaultOptions.suffix;\n if (suffix) {\n this.suffix = suffix;\n }\n this.defaultOptions = defaultOptions;\n const pluginBaseUrls = defaultOptions.plugin_base_urls;\n if (pluginBaseUrls !== undefined) {\n each$d(pluginBaseUrls, (pluginBaseUrl, pluginName) => {\n AddOnManager.PluginManager.urls[pluginName] = pluginBaseUrl;\n });\n }\n },\n init(options) {\n const self = this;\n let result;\n const invalidInlineTargets = Tools.makeMap('area base basefont br col frame hr img input isindex link meta param embed source wbr track ' + 'colgroup option table tbody tfoot thead tr th td script noscript style textarea video audio iframe object menu', ' ');\n const isInvalidInlineTarget = (options, elm) => options.inline && elm.tagName.toLowerCase() in invalidInlineTargets;\n const createId = elm => {\n let id = elm.id;\n if (!id) {\n id = get$a(elm, 'name').filter(name => !DOM.get(name)).getOrThunk(DOM.uniqueId);\n elm.setAttribute('id', id);\n }\n return id;\n };\n const execCallback = name => {\n const callback = options[name];\n if (!callback) {\n return;\n }\n return callback.apply(self, []);\n };\n const findTargets = options => {\n if (Env.browser.isIE() || Env.browser.isEdge()) {\n initError('TinyMCE does not support the browser you are using. For a list of supported' + ' browsers please see: https://www.tiny.cloud/docs/tinymce/6/support/#supportedwebbrowsers');\n return [];\n } else if (isQuirksMode) {\n initError('Failed to initialize the editor as the document is not in standards mode. ' + 'TinyMCE requires standards mode.');\n return [];\n } else if (isString(options.selector)) {\n return DOM.select(options.selector);\n } else if (isNonNullable(options.target)) {\n return [options.target];\n } else {\n return [];\n }\n };\n let provideResults = editors => {\n result = editors;\n };\n const initEditors = () => {\n let initCount = 0;\n const editors = [];\n let targets;\n const createEditor = (id, options, targetElm) => {\n const editor = new Editor(id, options, self);\n editors.push(editor);\n editor.on('init', () => {\n if (++initCount === targets.length) {\n provideResults(editors);\n }\n });\n editor.targetElm = editor.targetElm || targetElm;\n editor.render();\n };\n DOM.unbind(window, 'ready', initEditors);\n execCallback('onpageload');\n targets = unique$1(findTargets(options));\n Tools.each(targets, elm => {\n purgeDestroyedEditor(self.get(elm.id));\n });\n targets = Tools.grep(targets, elm => {\n return !self.get(elm.id);\n });\n if (targets.length === 0) {\n provideResults([]);\n } else {\n each(targets, elm => {\n if (isInvalidInlineTarget(options, elm)) {\n initError('Could not initialize inline editor on invalid inline target element', elm);\n } else {\n createEditor(createId(elm), options, elm);\n }\n });\n }\n };\n DOM.bind(window, 'ready', initEditors);\n return new Promise(resolve => {\n if (result) {\n resolve(result);\n } else {\n provideResults = editors => {\n resolve(editors);\n };\n }\n });\n },\n get(id) {\n if (arguments.length === 0) {\n return editors.slice(0);\n } else if (isString(id)) {\n return find$2(editors, editor => {\n return editor.id === id;\n }).getOr(null);\n } else if (isNumber(id)) {\n return editors[id] ? editors[id] : null;\n } else {\n return null;\n }\n },\n add(editor) {\n const self = this;\n const existingEditor = self.get(editor.id);\n if (existingEditor === editor) {\n return editor;\n }\n if (existingEditor === null) {\n editors.push(editor);\n }\n toggleGlobalEvents(true);\n self.activeEditor = editor;\n self.dispatch('AddEditor', { editor });\n if (!beforeUnloadDelegate) {\n beforeUnloadDelegate = e => {\n const event = self.dispatch('BeforeUnload');\n if (event.returnValue) {\n e.preventDefault();\n e.returnValue = event.returnValue;\n return event.returnValue;\n }\n };\n window.addEventListener('beforeunload', beforeUnloadDelegate);\n }\n return editor;\n },\n createEditor(id, options) {\n return this.add(new Editor(id, options, this));\n },\n remove(selector) {\n const self = this;\n let editor;\n if (!selector) {\n for (let i = editors.length - 1; i >= 0; i--) {\n self.remove(editors[i]);\n }\n return;\n }\n if (isString(selector)) {\n each(DOM.select(selector), elm => {\n editor = self.get(elm.id);\n if (editor) {\n self.remove(editor);\n }\n });\n return;\n }\n editor = selector;\n if (isNull(self.get(editor.id))) {\n return null;\n }\n if (removeEditorFromList(editor)) {\n self.dispatch('RemoveEditor', { editor });\n }\n if (editors.length === 0) {\n window.removeEventListener('beforeunload', beforeUnloadDelegate);\n }\n editor.remove();\n toggleGlobalEvents(editors.length > 0);\n return editor;\n },\n execCommand(cmd, ui, value) {\n var _a;\n const self = this;\n const editorId = isObject(value) ? (_a = value.id) !== null && _a !== void 0 ? _a : value.index : value;\n switch (cmd) {\n case 'mceAddEditor': {\n if (!self.get(editorId)) {\n const editorOptions = value.options;\n new Editor(editorId, editorOptions, self).render();\n }\n return true;\n }\n case 'mceRemoveEditor': {\n const editor = self.get(editorId);\n if (editor) {\n editor.remove();\n }\n return true;\n }\n case 'mceToggleEditor': {\n const editor = self.get(editorId);\n if (!editor) {\n self.execCommand('mceAddEditor', false, value);\n return true;\n }\n if (editor.isHidden()) {\n editor.show();\n } else {\n editor.hide();\n }\n return true;\n }\n }\n if (self.activeEditor) {\n return self.activeEditor.execCommand(cmd, ui, value);\n }\n return false;\n },\n triggerSave: () => {\n each(editors, editor => {\n editor.save();\n });\n },\n addI18n: (code, items) => {\n I18n.add(code, items);\n },\n translate: text => {\n return I18n.translate(text);\n },\n setActive(editor) {\n const activeEditor = this.activeEditor;\n if (this.activeEditor !== editor) {\n if (activeEditor) {\n activeEditor.dispatch('deactivate', { relatedTarget: editor });\n }\n editor.dispatch('activate', { relatedTarget: activeEditor });\n }\n this.activeEditor = editor;\n },\n _setBaseUrl(baseUrl) {\n this.baseURL = new URI(this.documentBaseURL).toAbsolute(baseUrl.replace(/\\/+$/, ''));\n this.baseURI = new URI(this.baseURL);\n }\n };\n EditorManager.setup();\n\n const setup = () => {\n const dataValue = value$2();\n const FakeClipboardItem = items => ({\n items,\n types: keys(items),\n getType: type => get$a(items, type).getOrUndefined()\n });\n const write = data => {\n dataValue.set(data);\n };\n const read = () => dataValue.get().getOrUndefined();\n const clear = dataValue.clear;\n return {\n FakeClipboardItem,\n write,\n read,\n clear\n };\n };\n const FakeClipboard = setup();\n\n const min = Math.min, max = Math.max, round = Math.round;\n const relativePosition = (rect, targetRect, rel) => {\n let x = targetRect.x;\n let y = targetRect.y;\n const w = rect.w;\n const h = rect.h;\n const targetW = targetRect.w;\n const targetH = targetRect.h;\n const relChars = (rel || '').split('');\n if (relChars[0] === 'b') {\n y += targetH;\n }\n if (relChars[1] === 'r') {\n x += targetW;\n }\n if (relChars[0] === 'c') {\n y += round(targetH / 2);\n }\n if (relChars[1] === 'c') {\n x += round(targetW / 2);\n }\n if (relChars[3] === 'b') {\n y -= h;\n }\n if (relChars[4] === 'r') {\n x -= w;\n }\n if (relChars[3] === 'c') {\n y -= round(h / 2);\n }\n if (relChars[4] === 'c') {\n x -= round(w / 2);\n }\n return create$2(x, y, w, h);\n };\n const findBestRelativePosition = (rect, targetRect, constrainRect, rels) => {\n for (let i = 0; i < rels.length; i++) {\n const pos = relativePosition(rect, targetRect, rels[i]);\n if (pos.x >= constrainRect.x && pos.x + pos.w <= constrainRect.w + constrainRect.x && pos.y >= constrainRect.y && pos.y + pos.h <= constrainRect.h + constrainRect.y) {\n return rels[i];\n }\n }\n return null;\n };\n const inflate = (rect, w, h) => {\n return create$2(rect.x - w, rect.y - h, rect.w + w * 2, rect.h + h * 2);\n };\n const intersect = (rect, cropRect) => {\n const x1 = max(rect.x, cropRect.x);\n const y1 = max(rect.y, cropRect.y);\n const x2 = min(rect.x + rect.w, cropRect.x + cropRect.w);\n const y2 = min(rect.y + rect.h, cropRect.y + cropRect.h);\n if (x2 - x1 < 0 || y2 - y1 < 0) {\n return null;\n }\n return create$2(x1, y1, x2 - x1, y2 - y1);\n };\n const clamp = (rect, clampRect, fixedSize) => {\n let x1 = rect.x;\n let y1 = rect.y;\n let x2 = rect.x + rect.w;\n let y2 = rect.y + rect.h;\n const cx2 = clampRect.x + clampRect.w;\n const cy2 = clampRect.y + clampRect.h;\n const underflowX1 = max(0, clampRect.x - x1);\n const underflowY1 = max(0, clampRect.y - y1);\n const overflowX2 = max(0, x2 - cx2);\n const overflowY2 = max(0, y2 - cy2);\n x1 += underflowX1;\n y1 += underflowY1;\n if (fixedSize) {\n x2 += underflowX1;\n y2 += underflowY1;\n x1 -= overflowX2;\n y1 -= overflowY2;\n }\n x2 -= overflowX2;\n y2 -= overflowY2;\n return create$2(x1, y1, x2 - x1, y2 - y1);\n };\n const create$2 = (x, y, w, h) => {\n return {\n x,\n y,\n w,\n h\n };\n };\n const fromClientRect = clientRect => {\n return create$2(clientRect.left, clientRect.top, clientRect.width, clientRect.height);\n };\n const Rect = {\n inflate,\n relativePosition,\n findBestRelativePosition,\n intersect,\n clamp,\n create: create$2,\n fromClientRect\n };\n\n const awaiter = (resolveCb, rejectCb, timeout = 1000) => {\n let done = false;\n let timer = null;\n const complete = completer => (...args) => {\n if (!done) {\n done = true;\n if (timer !== null) {\n clearTimeout(timer);\n timer = null;\n }\n completer.apply(null, args);\n }\n };\n const resolve = complete(resolveCb);\n const reject = complete(rejectCb);\n const start = (...args) => {\n if (!done && timer === null) {\n timer = setTimeout(() => reject.apply(null, args), timeout);\n }\n };\n return {\n start,\n resolve,\n reject\n };\n };\n const create$1 = () => {\n const tasks = {};\n const resultFns = {};\n const resources = {};\n const load = (id, url) => {\n const loadErrMsg = `Script at URL \"${ url }\" failed to load`;\n const runErrMsg = `Script at URL \"${ url }\" did not call \\`tinymce.Resource.add('${ id }', data)\\` within 1 second`;\n if (tasks[id] !== undefined) {\n return tasks[id];\n } else {\n const task = new Promise((resolve, reject) => {\n const waiter = awaiter(resolve, reject);\n resultFns[id] = waiter.resolve;\n ScriptLoader.ScriptLoader.loadScript(url).then(() => waiter.start(runErrMsg), () => waiter.reject(loadErrMsg));\n });\n tasks[id] = task;\n return task;\n }\n };\n const add = (id, data) => {\n if (resultFns[id] !== undefined) {\n resultFns[id](data);\n delete resultFns[id];\n }\n tasks[id] = Promise.resolve(data);\n resources[id] = data;\n };\n const has = id => {\n return id in resources;\n };\n const unload = id => {\n delete tasks[id];\n };\n const get = id => resources[id];\n return {\n load,\n add,\n has,\n get,\n unload\n };\n };\n const Resource = create$1();\n\n const create = () => (() => {\n let data = {};\n let keys = [];\n const storage = {\n getItem: key => {\n const item = data[key];\n return item ? item : null;\n },\n setItem: (key, value) => {\n keys.push(key);\n data[key] = String(value);\n },\n key: index => {\n return keys[index];\n },\n removeItem: key => {\n keys = keys.filter(k => k === key);\n delete data[key];\n },\n clear: () => {\n keys = [];\n data = {};\n },\n length: 0\n };\n Object.defineProperty(storage, 'length', {\n get: () => keys.length,\n configurable: false,\n enumerable: false\n });\n return storage;\n })();\n\n let localStorage;\n try {\n const test = '__storage_test__';\n localStorage = window.localStorage;\n localStorage.setItem(test, test);\n localStorage.removeItem(test);\n } catch (e) {\n localStorage = create();\n }\n var LocalStorage = localStorage;\n\n const publicApi = {\n geom: { Rect },\n util: {\n Delay,\n Tools,\n VK,\n URI,\n EventDispatcher,\n Observable,\n I18n,\n LocalStorage,\n ImageUploader\n },\n dom: {\n EventUtils,\n TreeWalker: DomTreeWalker,\n TextSeeker,\n DOMUtils,\n ScriptLoader,\n RangeUtils,\n Serializer: DomSerializer,\n StyleSheetLoader,\n ControlSelection,\n BookmarkManager,\n Selection: EditorSelection,\n Event: EventUtils.Event\n },\n html: {\n Styles,\n Entities,\n Node: AstNode,\n Schema,\n DomParser,\n Writer,\n Serializer: HtmlSerializer\n },\n Env,\n AddOnManager,\n Annotator,\n Formatter,\n UndoManager,\n EditorCommands,\n WindowManager,\n NotificationManager,\n EditorObservable,\n Shortcuts,\n Editor,\n FocusManager,\n EditorManager,\n DOM: DOMUtils.DOM,\n ScriptLoader: ScriptLoader.ScriptLoader,\n PluginManager,\n ThemeManager,\n ModelManager,\n IconManager,\n Resource,\n FakeClipboard,\n trim: Tools.trim,\n isArray: Tools.isArray,\n is: Tools.is,\n toArray: Tools.toArray,\n makeMap: Tools.makeMap,\n each: Tools.each,\n map: Tools.map,\n grep: Tools.grep,\n inArray: Tools.inArray,\n extend: Tools.extend,\n walk: Tools.walk,\n resolve: Tools.resolve,\n explode: Tools.explode,\n _addCacheSuffix: Tools._addCacheSuffix\n };\n const tinymce$1 = Tools.extend(EditorManager, publicApi);\n\n const exportToModuleLoaders = tinymce => {\n if (typeof module === 'object') {\n try {\n module.exports = tinymce;\n } catch (_) {\n }\n }\n };\n const exportToWindowGlobal = tinymce => {\n window.tinymce = tinymce;\n window.tinyMCE = tinymce;\n };\n exportToWindowGlobal(tinymce$1);\n exportToModuleLoaders(tinymce$1);\n\n})();\n"],"names":[],"sourceRoot":""}